ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
(Generate patch)

Comparing UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc (file contents):
Revision 1.37 by wulsin, Tue Mar 26 13:17:54 2013 UTC vs.
Revision 1.39 by jbrinson, Wed Mar 27 16:52:25 2013 UTC

# Line 18 | Line 18 | OSUAnalysis::OSUAnalysis (const edm::Par
18    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
19    puFile_ (cfg.getParameter<std::string> ("puFile")),
20    deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
21 <  muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
21 >  
22 > muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
23    dataPU_ (cfg.getParameter<std::string> ("dataPU")),
24    electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
25    muonSF_ (cfg.getParameter<std::string> ("muonSF")),
# Line 301 | Line 302 | OSUAnalysis::OSUAnalysis (const edm::Par
302        else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
303        else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
304  
305 +      else if(currentObject == "electron-track pairs") currentObject = "electronTrackPairs";
306 +      else if(currentObject == "muon-track pairs") currentObject = "muonTrackPairs";
307 +      else if(currentObject == "muon-tau pairs") currentObject = "muonTauPairs";
308 +      else if(currentObject == "tau-tau pairs") currentObject = "ditauPairs";
309 +
310        currentObject.at(0) = toupper(currentObject.at(0));
311        string histoName = "num" + currentObject;
312  
# Line 545 | Line 551 | OSUAnalysis::analyze (const edm::Event &
551                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
552                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
553                                                                         "electron-muon pairs");
554 +        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(), \
555 +                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
556 +                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
557 +                                                                       "electron-track pairs");
558 +        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(), \
559 +                                                                        cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
560 +                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
561 +                                                                        "muon-track pairs");
562 +        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(), \
563 +                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
564 +                                                                    cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
565 +                                                                    "muon-tau pairs");
566 +
567 +        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(), \
568 +                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
569 +                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
570 +                                                                        "tau-tau pairs");
571  
572  
573        }
# Line 623 | Line 646 | OSUAnalysis::analyze (const edm::Event &
646          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
647                                                                                                cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
648                                                                                                cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
649 +        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(), \
650 +                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
651 +                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
652 +        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(), \
653 +                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
654 +                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
655 +        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(), \
656 +                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
657 +                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
658 +
659 +        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(), \
660 +                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
661 +                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
662          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
663          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
664          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 652 | Line 688 | OSUAnalysis::analyze (const edm::Event &
688          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
689                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
690                                                                                                 cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
691 +        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(), \
692 +                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(), \
693 +                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
694 +        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(), \
695 +                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(), \
696 +                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
697 +        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(), \
698 +                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(), \
699 +                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
700 +        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(), \
701 +                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(), \
702 +                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
703          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
704          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
705          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 674 | Line 722 | OSUAnalysis::analyze (const edm::Event &
722        if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
723        else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
724        else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
725 +      else if(currentObject == "electron-track pairs") objectToPlot = "electronTrackPairs";
726 +      else if(currentObject == "muon-track pairs") objectToPlot = "muonTrackPairs";
727 +      else if(currentObject == "muon-tau pairs") objectToPlot = "muonTauPairs";
728 +      else if(currentObject == "tau-tau pairs") objectToPlot = "ditauPairs";
729        else objectToPlot = currentObject;
730        string tempCurrentObject = objectToPlot;
731        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
# Line 702 | Line 754 | OSUAnalysis::analyze (const edm::Event &
754        else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
755        else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
756        else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
757 +      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
758        else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
759        else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
760        else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
# Line 1936 | Line 1989 | OSUAnalysis::valueLookup (const BNtrack*
1989    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
1990    else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
1991    else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
1939
1940
1941
1942
1943
1992    else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
1993    else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
1994    else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
1995    else if(variable == "ptError") value = object->ptError;
1996    else if(variable == "ptRes") value = getTrkPtRes(object);
1997  
1998 +  else if (variable == "d0wrtPV"){
1999 +    double vx = object->vx - chosenVertex ()->x,
2000 +      vy = object->vy - chosenVertex ()->y,
2001 +      px = object->px,
2002 +      py = object->py,
2003 +      pt = object->pt;
2004 +    value = (-vx * py + vy * px) / pt;
2005 +  }
2006 +  else if (variable == "dZwrtPV"){
2007 +    double vx = object->vx - chosenVertex ()->x,
2008 +      vy = object->vy - chosenVertex ()->y,
2009 +      vz = object->vz - chosenVertex ()->z,
2010 +      px = object->px,
2011 +      py = object->py,
2012 +      pz = object->pz,
2013 +      pt = object->pt;
2014 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2015 +  }
2016 +
2017 +
2018 +
2019    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2020  
2021    else if(variable == "genMatchedPdgId"){
# Line 1955 | Line 2024 | OSUAnalysis::valueLookup (const BNtrack*
2024      else value = mcparticles->at(index).id;
2025    }
2026  
1958
2027    else if(variable == "genMatchedId"){
2028      int index = getGenMatchedParticleIndex(object);
2029      if(index == -1) value = 0;
# Line 2270 | Line 2338 | OSUAnalysis::valueLookup (const BNphoton
2338    else if(variable == "isEEGap") value = object->isEEGap;
2339    else if(variable == "hasPixelSeed") value = object->hasPixelSeed;
2340    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2273
2274
2341  
2342  
2343    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
# Line 2281 | Line 2347 | OSUAnalysis::valueLookup (const BNphoton
2347      if(index == -1) value = 0;
2348      else value = mcparticles->at(index).id;
2349    }
2284
2285
2286
2350    else if(variable == "genMatchedId"){
2351      int index = getGenMatchedParticleIndex(object);
2352      if(index == -1) value = 0;
# Line 2353 | Line 2416 | OSUAnalysis::valueLookup (const BNmuon*
2416      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2417      value = (fourVector1 + fourVector2).M();
2418    }
2419 +  else if(variable == "pt"){
2420 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2421 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2422 +    value = (fourVector1 + fourVector2).Et();
2423 +  }
2424    else if(variable == "threeDAngle")
2425      {
2426        TVector3 threeVector1(object1->px, object1->py, object1->pz);
# Line 2417 | Line 2485 | OSUAnalysis::valueLookup (const BNelectr
2485      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2486      value = (fourVector1 + fourVector2).M();
2487    }
2488 +  else if(variable == "pt"){
2489 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2490 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2491 +    value = (fourVector1 + fourVector2).Et();
2492 +  }
2493    else if(variable == "threeDAngle")
2494      {
2495        TVector3 threeVector1(object1->px, object1->py, object1->pz);
# Line 2466 | Line 2539 | OSUAnalysis::valueLookup (const BNelectr
2539      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2540      value = (fourVector1 + fourVector2).M();
2541    }
2542 +  else if(variable == "pt"){
2543 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2544 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2545 +    value = (fourVector1 + fourVector2).Et();
2546 +  }
2547    else if(variable == "threeDAngle")
2548      {
2549        TVector3 threeVector1(object1->px, object1->py, object1->pz);
# Line 2511 | Line 2589 | OSUAnalysis::valueLookup (const BNelectr
2589   }
2590  
2591  
2592 + double
2593 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){
2594 +  double electronMass = 0.000511;
2595 +  double value = 0.0;
2596 +  TLorentzVector fourVector1(0, 0, 0, 0);  
2597 +  TLorentzVector fourVector2(0, 0, 0, 0);  
2598 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2599 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2600 +  else if(variable == "invMass"){
2601 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
2602 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
2603 +    
2604 +    value = (fourVector1 + fourVector2).M();
2605 +  }
2606 +  
2607 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2608 +  value = applyFunction(function, value);
2609 +  return value;
2610 + }
2611 +
2612 + double
2613 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2614 +  double pionMass = 0.140;
2615 +  double muonMass = 0.106;
2616 +  double value = 0.0;
2617 +  TLorentzVector fourVector1(0, 0, 0, 0);
2618 +  TLorentzVector fourVector2(0, 0, 0, 0);
2619 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2620 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2621 +  else if(variable == "invMass"){
2622 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
2623 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
2624 +
2625 +    value = (fourVector1 + fourVector2).M();
2626 +  }
2627 +
2628 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2629 +  value = applyFunction(function, value);
2630 +  return value;
2631 + }
2632 +
2633 +
2634 + double
2635 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2636 +  double value = 0.0;
2637 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2638 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2639 +  else if(variable == "invMass"){
2640 +  TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2641 +  TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2642 +     value = (fourVector1 + fourVector2).M();
2643 +  }
2644 +
2645 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2646 +  value = applyFunction(function, value);
2647 +  return value;
2648 + }
2649 +
2650 + double
2651 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2652 +  double value = 0.0;
2653 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2654 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2655 +  else if(variable == "invMass"){
2656 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2657 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2658 +    value = (fourVector1 + fourVector2).M();
2659 +  }
2660 +
2661 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2662 +  value = applyFunction(function, value);
2663 +  return value;
2664 + }
2665 +
2666 +
2667 +
2668   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2669   // Return true iff no other tracks are found in this cone.
2670   int
# Line 2599 | Line 2753 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
2753    return value;
2754   }
2755  
2756 +
2757   // Returns the smallest DeltaR between the object and any generated true particle in the event.  
2758   template <class InputObject>
2759   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
# Line 2610 | Line 2765 | double OSUAnalysis::getGenDeltaRLowest(I
2765    return genDeltaRLowest;
2766   }
2767  
2768 +
2769   double
2770   OSUAnalysis::applyFunction(string function, double value){
2771  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines