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.43 by wulsin, Thu Mar 28 10:17:32 2013 UTC vs.
Revision 1.54 by ahart, Wed May 1 19:49:01 2013 UTC

# Line 11 | Line 11 | OSUAnalysis::OSUAnalysis (const edm::Par
11    tracks_ (cfg.getParameter<edm::InputTag> ("tracks")),
12    genjets_ (cfg.getParameter<edm::InputTag> ("genjets")),
13    mcparticles_ (cfg.getParameter<edm::InputTag> ("mcparticles")),
14 +  stops_ (cfg.getParameter<edm::InputTag> ("stops")),
15    primaryvertexs_ (cfg.getParameter<edm::InputTag> ("primaryvertexs")),
16    bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
17    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
# Line 28 | Line 29 | OSUAnalysis::OSUAnalysis (const edm::Par
29    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
31    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
32 +  applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
33    printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
34 <  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr"))
34 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
35 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
36  
37   {
38  
# Line 38 | Line 41 | OSUAnalysis::OSUAnalysis (const edm::Par
41    //create pile-up reweighting object, if necessary
42    if(datasetType_ != "data") {
43      if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
44 <    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
45 <    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
44 >    if (applyLeptonSF_){
45 >      muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
46 >      electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
47 >    }
48    }
49 + #ifdef DISPLACED_SUSY
50 +  if (datasetType_ == "signalMC")
51 +    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
52 + #endif
53  
54  
55    // Construct Cutflow Objects. These store the results of cut decisions and
# Line 51 | Line 60 | OSUAnalysis::OSUAnalysis (const edm::Par
60    //always get vertex collection so we can assign the primary vertex in the event
61    objectsToGet.push_back("primaryvertexs");
62  
63 <  //always make the plot of number of primary verticex (to check pile-up reweighting)
63 >  //always make the plot of number of primary vertices (to check pile-up reweighting)
64    objectsToPlot.push_back("primaryvertexs");
65  
66    //always get the MC particles to do GEN-matching
# Line 65 | Line 74 | OSUAnalysis::OSUAnalysis (const edm::Par
74  
75      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
76      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
77 +    if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
78 +    if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
79      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
80 +    if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
81 +    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
82      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
83 <      objectsToGet.push_back(tempInputCollection);
83 >      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
84 >        int spaceIndex = tempInputCollection.find(" ");
85 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
86 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
87 >      }
88 >      else{
89 >        objectsToGet.push_back(tempInputCollection);
90 >      }
91        objectsToPlot.push_back(tempInputCollection);
92        objectsToCut.push_back(tempInputCollection);
93      }
94 <    else{//pair of objects, need to add them both to the things to objectsToGet
95 <      int dashIndex = tempInputCollection.find("-");
96 <      int spaceIndex = tempInputCollection.find(" ");
97 <      int secondWordLength = spaceIndex - dashIndex;
98 <      objectsToGet.push_back(tempInputCollection);
79 <      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
80 <      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
81 <      objectsToPlot.push_back(tempInputCollection);
82 <      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
83 <      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
94 >    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
95 >      string obj1;
96 >      string obj2;
97 >      getTwoObjs(tempInputCollection, obj1, obj2);
98 >      string obj2ToGet = getObjToGet(obj2);  
99        objectsToCut.push_back(tempInputCollection);
100 <      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
101 <      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
100 >      objectsToCut.push_back(obj1);
101 >      objectsToCut.push_back(obj2);  
102 >      objectsToPlot.push_back(tempInputCollection);
103 >      objectsToPlot.push_back(obj1);
104 >      objectsToPlot.push_back(obj2);  
105 >      objectsToGet.push_back(tempInputCollection);
106 >      objectsToGet.push_back(obj1);
107 >      objectsToGet.push_back(obj2ToGet);
108  
109      }
110  
# Line 112 | Line 133 | OSUAnalysis::OSUAnalysis (const edm::Par
133    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
134  
135      string currentObject = objectsToPlot.at(currentObjectIndex);
136 <    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
136 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
137  
138      histogram tempIdHisto;
139      histogram tempMomIdHisto;
140      histogram tempGmaIdHisto;
141      histogram tempIdVsMomIdHisto;
142 +    histogram tempIdVsGmaIdHisto;
143  
144      tempIdHisto.inputCollection = currentObject;
145      tempMomIdHisto.inputCollection = currentObject;
146      tempGmaIdHisto.inputCollection = currentObject;
147      tempIdVsMomIdHisto.inputCollection = currentObject;
148 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
149 +
150 +    if(currentObject == "secondary muons") currentObject = "secondaryMuons";
151 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
152  
153      currentObject = currentObject.substr(0, currentObject.size()-1);
154      tempIdHisto.name = currentObject+"GenMatchId";
155      tempMomIdHisto.name = currentObject+"GenMatchMotherId";
156      tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
157      tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
158 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
159  
160      currentObject.at(0) = toupper(currentObject.at(0));
161      tempIdHisto.title = currentObject+" Gen-matched Particle";
162      tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
163      tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
164      tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
165 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
166 +
167  
168      int maxNum = 24;
169      vector<double> binVector;
# Line 154 | Line 183 | OSUAnalysis::OSUAnalysis (const edm::Par
183      tempIdVsMomIdHisto.bins = binVector;
184      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
185      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
186 +    tempIdVsGmaIdHisto.bins = binVector;
187 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
188 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
189  
190      histograms.push_back(tempIdHisto);
191      histograms.push_back(tempMomIdHisto);
192      histograms.push_back(tempGmaIdHisto);
193      histograms.push_back(tempIdVsMomIdHisto);
194 +    histograms.push_back(tempIdVsGmaIdHisto);
195    }
196  
197  
# Line 278 | Line 311 | OSUAnalysis::OSUAnalysis (const edm::Par
311        labelArray.push_back("other");
312  
313        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
314 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
314 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==std::string::npos) {
315            oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
316          }
317          else {
# Line 286 | Line 319 | OSUAnalysis::OSUAnalysis (const edm::Par
319            twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
320          }
321        }
322 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
322 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=std::string::npos) {
323          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
324          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
325        }
# Line 300 | Line 333 | OSUAnalysis::OSUAnalysis (const edm::Par
333        int maxNum = 10;
334        if(currentObject == "mcparticles") maxNum = 50;
335        else if(currentObject == "primaryvertexs") maxNum = 50;
336 <      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
337 <      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
338 <      else if(currentObject == "electron-muon pairs")     currentObject = "electronMuonPairs";
339 <      else if(currentObject == "track-event pairs")       currentObject = "trackEventPairs";
340 <      else if(currentObject == "electron-track pairs")    currentObject = "electronTrackPairs";  
341 <      else if(currentObject == "muon-track pairs")        currentObject = "muonTrackPairs";      
342 <      else if(currentObject == "muon-tau pairs")          currentObject = "muonTauPairs";        
343 <      else if(currentObject == "tau-tau pairs")           currentObject = "ditauPairs";
336 >
337 >      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
338 >      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
339 >      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
340 >      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
341 >      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
342 >      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
343 >      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
344 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";        
345 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";    
346 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";      
347 >      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
348 >      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
349 >      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
350 >      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
351 >      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
352 >      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
353 >
354        currentObject.at(0) = toupper(currentObject.at(0));  
355        string histoName = "num" + currentObject;
356  
# Line 332 | Line 375 | OSUAnalysis::OSUAnalysis (const edm::Par
375        cut tempCut;
376        //store input collection for cut
377        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
378 +      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
379 +      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
380 +      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
381 +      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
382 +      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
383 +      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
384        tempCut.inputCollection = tempInputCollection;
385        if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
386 <        objectsToGet.push_back(tempInputCollection);
387 <        objectsToCut.push_back(tempInputCollection);
386 >        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
387 >          int spaceIndex = tempInputCollection.find(" ");
388 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
389 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
390 >        }
391 >        else{
392 >          objectsToGet.push_back(tempInputCollection);
393 >        }
394 >        objectsToCut.push_back(tempInputCollection);
395        }
396 <      else{//pair of objects, need to add them both to the things to objectsToGet
397 <        int dashIndex = tempInputCollection.find("-");
398 <        int spaceIndex = tempInputCollection.find(" ");
399 <        int secondWordLength = spaceIndex - dashIndex;
400 <        objectsToGet.push_back(tempInputCollection);
345 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
346 <        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
396 >      else{//pair of objects, need to add them both to objectsToGet
397 >        string obj1;
398 >        string obj2;
399 >        getTwoObjs(tempInputCollection, obj1, obj2);
400 >        string obj2ToGet = getObjToGet(obj2);  
401          objectsToCut.push_back(tempInputCollection);
402 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
403 <        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
402 >        objectsToCut.push_back(obj1);
403 >        objectsToCut.push_back(obj2);  
404 >        objectsToGet.push_back(tempInputCollection);
405 >        objectsToGet.push_back(obj1);
406 >        objectsToGet.push_back(obj2ToGet);
407  
408        }
409  
# Line 403 | Line 460 | OSUAnalysis::OSUAnalysis (const edm::Par
460        }
461        tempCut.name = tempCutName;
462  
406
463        tempChannel.cuts.push_back(tempCut);
464  
465  
410
466      }//end loop over cuts
467  
468      channels.push_back(tempChannel);
# Line 483 | Line 538 | OSUAnalysis::analyze (const edm::Event &
538    if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
539      event.getByLabel (superclusters_, superclusters);
540  
541 + #ifdef DISPLACED_SUSY
542 +  if (datasetType_ == "signalMC"){
543 +    if (std::find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
544 +      event.getByLabel (stops_, stops);
545 +  }
546 + #endif
547 +
548    if (useTrackCaloRhoCorr_) {  
549      // Used only for pile-up correction of by-hand calculation of isolation energy.  
550      // This rho collection is not available in all BEANs.  
# Line 491 | Line 553 | OSUAnalysis::analyze (const edm::Event &
553      event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
554    }
555  
556 <
495 <  //get pile-up event weight
496 <  double scaleFactor = 1.00;
497 <  if(doPileupReweighting_ && datasetType_ != "data")
498 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
499 <
556 >  double scaleFactor = 1.0;
557  
558    //loop over all channels
559  
# Line 515 | Line 572 | OSUAnalysis::analyze (const edm::Event &
572  
573      //loop over all cuts
574  
518
519
575      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
576        cut currentCut = currentChannel.cuts.at(currentCutIndex);
577  
# Line 535 | Line 590 | OSUAnalysis::analyze (const edm::Event &
590  
591  
592          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
593 +
594          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
595 +
596 +        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
597 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
598          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
599          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
600          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 549 | Line 608 | OSUAnalysis::analyze (const edm::Event &
608          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
609  
610  
611 +
612          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
613                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
614                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
615                                                                     "muon-muon pairs");
616 +
617 +        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
618 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
619 +                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
620 +                                                                   "muon-secondary muon pairs");
621 +
622 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
623 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
624 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
625 +                                                                   "electron-secondary electron pairs");
626 +
627          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
628                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
629                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 561 | Line 632 | OSUAnalysis::analyze (const edm::Event &
632                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
633                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
634                                                                         "electron-muon pairs");
635 +        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
636 +                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
637 +                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
638 +                                                                           "jet-jet pairs");
639 +        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
640 +                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
641 +                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
642 +                                                                       "electron-jet pairs");
643 +        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
644 +                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
645 +                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
646 +                                                                       "muon-jet pairs");
647          else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
648                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
649                                                                       cumulativeFlags.at("events").at(flagsForPairCutsIndex),
# Line 577 | Line 660 | OSUAnalysis::analyze (const edm::Event &
660                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
661                                                                    cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
662                                                                    "muon-tau pairs");
663 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(),
663 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
664                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
665                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
666                                                                   "tau-tau pairs");
667 <        
668 <        
667 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
668 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
669 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
670 >                                                                 "tau-track pairs");
671 >
672 > #ifdef DISPLACED_SUSY
673 >        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
674 > #endif
675        }
676  
677  
# Line 598 | Line 687 | OSUAnalysis::analyze (const edm::Event &
687      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
688  
689  
601
690      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
691  
692        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 608 | Line 696 | OSUAnalysis::analyze (const edm::Event &
696        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
697          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
698        }
611
699        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
700        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
614
701        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
702  
703      }
704  
705 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
705 >  //get pile-up event weight
706 >  if (datasetType_ != "data"){
707 >    if(doPileupReweighting_) scaleFactor *= puWeight_->at (events->at (0).numTruePV);
708 >    if(applyLeptonSF_){
709 >      if (chosenMuon ()) scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
710 >      if (chosenElectron ()) scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
711 >    }
712 >  }
713  
714 +  cTauScaleFactor_ = 1.0;
715 + #ifdef DISPLACED_SUSY
716 +  if (datasetType_ == "signalMC")
717 +    cTauScaleFactor_ = cTauWeight_->at (event);
718 + #endif
719 +  scaleFactor *= cTauScaleFactor_;
720  
721 +    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
722  
723      if(!eventPassedAllCuts)continue;
724  
# Line 631 | Line 731 | OSUAnalysis::analyze (const edm::Event &
731             << endl;  
732      }
733  
634
635    //     if(datasetType_ != "data") {
636    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
637    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
638    //     }
639
734      //filling histograms
735      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
736        histogram currentHistogram = histograms.at(histogramIndex);
# Line 645 | Line 739 | OSUAnalysis::analyze (const edm::Event &
739          TH1D* histo;
740          histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
741  
648
649
742          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
743          else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
744 +        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
745 +        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
746          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
747                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
748                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
749 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
750 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
751 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
752          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
753          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
754                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
755                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
756 +        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
757 +                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(),\
758 +                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
759 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
760 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
761 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
762          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
763                                                                                             cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
764                                                                                             cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
765 +        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
766 +                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(),
767 +                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
768 +        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
769 +                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(),
770 +                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
771          else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
772                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
773                                                                                              cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
# Line 671 | Line 780 | OSUAnalysis::analyze (const edm::Event &
780          else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
781                                                                                       cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
782                                                                                       cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
783 +        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
784 +                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
785 +                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
786 +
787          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
788          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
789          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 681 | Line 794 | OSUAnalysis::analyze (const edm::Event &
794          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
795          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
796          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
797 +
798 + #ifdef DISPLACED_SUSY
799 +        if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
800 + #endif
801        }
802        else if(currentHistogram.inputVariables.size() == 2){
803          TH2D* histo;
804          histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
805  
689
690
806          if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
807          else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
808 +        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
809          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
810                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
811                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
812 +        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
813 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
814 +                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
815          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
816 +        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
817          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
818                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
819                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
820 +        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
821 +                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(), \
822 +                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
823 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
824 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
825 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
826          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
827                                                                                             cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
828                                                                                             cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
829 +        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
830 +                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(), \
831 +                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
832 +        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
833 +                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(), \
834 +                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
835          else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
836                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
837                                                                                              cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
# Line 712 | Line 844 | OSUAnalysis::analyze (const edm::Event &
844          else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
845                                                                                       cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
846                                                                                       cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
847 +        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
848 +                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
849 +                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
850          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
851          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
852          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
# Line 725 | Line 860 | OSUAnalysis::analyze (const edm::Event &
860          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
861          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
862          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
863 + #ifdef DISPLACED_SUSY
864 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
865 + #endif
866        }
867      }
868  
869 +
870 +
871      //fills histograms with the sizes of collections
872      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
873  
# Line 736 | Line 876 | OSUAnalysis::analyze (const edm::Event &
876        string objectToPlot = "";  
877  
878        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
879 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
880 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
881 <      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
882 <      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
883 <      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
884 <      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
885 <      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
886 <      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
879 >      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
880 >      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
881 >      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
882 >      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
883 >      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
884 >      else if(currentObject == "jet-jet pairs")            objectToPlot = "dijetPairs";
885 >      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
886 >      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";    
887 >      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";      
888 >      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
889 >      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
890 >      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";  
891 >      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";  
892 >      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";  
893 >      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";  
894 >      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";  
895        else objectToPlot = currentObject;
896 +
897        string tempCurrentObject = objectToPlot;
898        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
899        string histoName = "num" + tempCurrentObject;
900  
752
901        //set position of primary vertex in event, in order to calculate quantities relative to it
902        if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
903          vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
904 <        int numToPlot = 0;
904 >        int numToPlot = 0;
905          for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
906            if(lastCutFlags.at(currentFlag)) numToPlot++;
907          }
# Line 767 | Line 915 | OSUAnalysis::analyze (const edm::Event &
915        }
916        else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
917        else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
918 +      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
919        else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
920 +      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
921        else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
922 +      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
923        else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
924 +      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
925        else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
926 +      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
927 +      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
928        else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
929        else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
930        else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
# Line 785 | Line 939 | OSUAnalysis::analyze (const edm::Event &
939          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
940          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
941        }
942 + #ifdef DISPLACED_SUSY
943 +      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
944 + #endif
945  
946 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
946 >    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
947  
948    } //end loop over channel
949  
# Line 841 | Line 998 | OSUAnalysis::splitString (string inputSt
998  
999   }
1000  
1001 +
1002 + void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1003 +  // Set two object strings from the tempInputCollection string,
1004 +  // For example, if tempInputCollection is "electron-muon pairs",
1005 +  // then obj1 = "electrons" and obj2 = "muons".  
1006 +  // Note that the objects have an "s" appended.  
1007 +
1008 +  int dashIndex = tempInputCollection.find("-");
1009 +  int spaceIndex = tempInputCollection.find_last_of(" ");
1010 +  int secondWordLength = spaceIndex - dashIndex;
1011 +  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
1012 +  obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1013 +  
1014 + }
1015 +
1016 +
1017 + string OSUAnalysis::getObjToGet(string obj) {
1018 +  // Return the string corresponding to the object to get for the given obj string.
1019 +  // Right now this only handles the case in which obj contains "secondary",
1020 +  // e.g, "secondary muons".  
1021 +  // Note that "s" is NOT appended.  
1022 +  
1023 +  if (obj.find("secondary")==std::string::npos) return obj;  // "secondary" is not found  
1024 +  int firstSpaceIndex = obj.find_first_of(" ");  
1025 +  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1026 +
1027 + }  
1028 +
1029 +
1030 + //!jet valueLookup
1031   double
1032   OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1033  
# Line 970 | Line 1157 | OSUAnalysis::valueLookup (const BNjet* o
1157   }
1158  
1159  
1160 <
1160 > //!muon valueLookup
1161   double
1162   OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1163  
# Line 1294 | Line 1481 | OSUAnalysis::valueLookup (const BNmuon*
1481    else if(variable == "genMatchedMotherIdReverse"){
1482      int index = getGenMatchedParticleIndex(object);
1483      if(index == -1) value = 23;
1484 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1484 >    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1485    }
1486    else if(variable == "genMatchedGrandmotherId"){
1487      int index = getGenMatchedParticleIndex(object);
# Line 1306 | Line 1493 | OSUAnalysis::valueLookup (const BNmuon*
1493      }
1494      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1495    }
1496 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1497 +    int index = getGenMatchedParticleIndex(object);
1498 +    if(index == -1) value = 23;
1499 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1500 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1501 +      if(motherIndex == -1) value = 23;
1502 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1503 +    }
1504 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1505 +  }
1506  
1507  
1508  
# Line 1316 | Line 1513 | OSUAnalysis::valueLookup (const BNmuon*
1513    return value;
1514   }
1515  
1516 <
1516 > //!electron valueLookup
1517   double
1518   OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1519  
# Line 1689 | Line 1886 | OSUAnalysis::valueLookup (const BNelectr
1886      }
1887      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1888    }
1889 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1890 +    int index = getGenMatchedParticleIndex(object);
1891 +    if(index == -1) value = 23;
1892 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1893 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1894 +      if(motherIndex == -1) value = 23;
1895 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1896 +    }
1897 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1898 +  }
1899  
1900  
1901  
# Line 1699 | Line 1906 | OSUAnalysis::valueLookup (const BNelectr
1906    return value;
1907   }
1908  
1909 <
1909 > //!event valueLookup
1910   double
1911   OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
1912  
# Line 1777 | Line 1984 | OSUAnalysis::valueLookup (const BNevent*
1984    }
1985    else if(variable == "muonScaleFactor"){
1986      if(datasetType_ != "data")
1987 <      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1781 <      value = 1.0;
1987 >      value = muonSFWeight_->at (chosenMuon ()->eta);
1988      else
1989        value = 1.0;
1990    }
1991    else if(variable == "electronScaleFactor"){
1992      if(datasetType_ != "data")
1993 <      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1788 <      value = 1.0;
1993 >      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1994      else
1995        value = 1.0;
1996    }
1997 +  else if(variable == "cTauScaleFactor")
1998 +    value = cTauScaleFactor_;
1999  
2000    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2001  
# Line 1797 | Line 2004 | OSUAnalysis::valueLookup (const BNevent*
2004    return value;
2005   }
2006  
2007 + //!tau valueLookup
2008   double
2009   OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2010  
# Line 1877 | Line 2085 | OSUAnalysis::valueLookup (const BNtau* o
2085      }
2086      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2087    }
2088 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2089 +    int index = getGenMatchedParticleIndex(object);
2090 +    if(index == -1) value = 23;
2091 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2092 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2093 +      if(motherIndex == -1) value = 23;
2094 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2095 +    }
2096 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2097 +  }
2098  
2099  
2100    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1886 | Line 2104 | OSUAnalysis::valueLookup (const BNtau* o
2104    return value;
2105   }
2106  
2107 + //!met valueLookup
2108   double
2109   OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2110  
# Line 1958 | Line 2177 | OSUAnalysis::valueLookup (const BNmet* o
2177    return value;
2178   }
2179  
2180 + //!track valueLookup
2181   double
2182   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2183  
# Line 1985 | Line 2205 | OSUAnalysis::valueLookup (const BNtrack*
2205  
2206  
2207    //additional BNs info for disappTrks
1988  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2208    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2209    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2210    else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
# Line 2002 | Line 2221 | OSUAnalysis::valueLookup (const BNtrack*
2221    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2222    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2223    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2224 <  else if(variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object);  
2225 <  else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;  
2224 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);  
2225 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2226    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2227    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2228    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
# Line 2061 | Line 2280 | OSUAnalysis::valueLookup (const BNtrack*
2280      }
2281      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2282    }
2283 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2284 +    int index = getGenMatchedParticleIndex(object);
2285 +    if(index == -1) value = 23;
2286 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2287 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2288 +      if(motherIndex == -1) value = 23;
2289 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2290 +    }
2291 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2292 +  }
2293  
2294  
2295  
# Line 2071 | Line 2300 | OSUAnalysis::valueLookup (const BNtrack*
2300    return value;
2301   }
2302  
2303 + //!genjet valueLookup
2304   double
2305   OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2306  
# Line 2099 | Line 2329 | OSUAnalysis::valueLookup (const BNgenjet
2329    return value;
2330   }
2331  
2332 + //!mcparticle valueLookup
2333   double
2334   OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2335  
# Line 2232 | Line 2463 | OSUAnalysis::valueLookup (const BNmcpart
2463    return value;
2464   }
2465  
2466 + //!primaryvertex valueLookup
2467   double
2468   OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2469  
# Line 2259 | Line 2491 | OSUAnalysis::valueLookup (const BNprimar
2491    return value;
2492   }
2493  
2494 + //!bxlumi valueLookup
2495   double
2496   OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2497  
# Line 2276 | Line 2509 | OSUAnalysis::valueLookup (const BNbxlumi
2509    return value;
2510   }
2511  
2512 + //!photon valueLookup
2513   double
2514   OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2515  
# Line 2389 | Line 2623 | OSUAnalysis::valueLookup (const BNphoton
2623      }
2624      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2625    }
2626 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2627 +    int index = getGenMatchedParticleIndex(object);
2628 +    if(index == -1) value = 23;
2629 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2630 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2631 +      if(motherIndex == -1) value = 23;
2632 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2633 +    }
2634 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2635 +  }
2636  
2637  
2638    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 2398 | Line 2642 | OSUAnalysis::valueLookup (const BNphoton
2642    return value;
2643   }
2644  
2645 + //!supercluster valueLookup
2646   double
2647   OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2648  
# Line 2420 | Line 2665 | OSUAnalysis::valueLookup (const BNsuperc
2665    return value;
2666   }
2667  
2668 <
2668 > //!muon-muon pair valueLookup
2669   double
2670   OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2671  
2672    double value = 0.0;
2673  
2674    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2675 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2676    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2677    else if(variable == "invMass"){
2678      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2490 | Line 2736 | OSUAnalysis::valueLookup (const BNmuon*
2736    return value;
2737   }
2738  
2739 + //!electron-electron pair valueLookup
2740   double
2741   OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2742  
2743    double value = 0.0;
2744  
2745    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2746 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2747    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2748    else if(variable == "invMass"){
2749      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2543 | Line 2791 | OSUAnalysis::valueLookup (const BNelectr
2791  
2792    return value;
2793   }
2794 <
2794 > //!electron-muon pair valueLookup
2795   double
2796   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2797  
2798    double value = 0.0;
2799  
2800    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2801 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2802    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2803    else if(variable == "invMass"){
2804      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2596 | Line 2845 | OSUAnalysis::valueLookup (const BNelectr
2845    else if(variable == "muonDetIso"){
2846      value = (object2->trackIsoDR03) / object2->pt;
2847    }
2848 +  else if(variable == "electronRelPFrhoIso"){
2849 +    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2850 +  }
2851 +  else if(variable == "muonRelPFdBetaIso"){
2852 +    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2853 +  }
2854 +
2855 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2856 +
2857 +  value = applyFunction(function, value);
2858 +
2859 +  return value;
2860 + }
2861 +
2862 + //!electron-jet pair valueLookup
2863 + double
2864 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function){
2865 +
2866 +  double value = 0.0;
2867 +
2868 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2869 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2870 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2871 +  else if(variable == "invMass"){
2872 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2873 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2874 +    value = (fourVector1 + fourVector2).M();
2875 +  }
2876 +  else if(variable == "pt"){
2877 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2878 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2879 +    value = (fourVector1 + fourVector2).Pt();
2880 +  }
2881 +  else if(variable == "threeDAngle")
2882 +    {
2883 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2884 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2885 +      value = (threeVector1.Angle(threeVector2));
2886 +    }
2887 +  else if(variable == "chargeProduct"){
2888 +    value = object1->charge*object2->charge;
2889 +  }
2890 +
2891 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2892 +
2893 +  value = applyFunction(function, value);
2894 +
2895 +  return value;
2896 + }
2897 +
2898 + //!muon-jet pair valueLookup
2899 + double
2900 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function){
2901 +
2902 +  double value = 0.0;
2903  
2904 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2905 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2906 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2907 +  else if(variable == "invMass"){
2908 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2909 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2910 +    value = (fourVector1 + fourVector2).M();
2911 +  }
2912 +  else if(variable == "pt"){
2913 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2914 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2915 +    value = (fourVector1 + fourVector2).Pt();
2916 +  }
2917 +  else if(variable == "threeDAngle")
2918 +    {
2919 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2920 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2921 +      value = (threeVector1.Angle(threeVector2));
2922 +    }
2923 +  else if(variable == "chargeProduct"){
2924 +    value = object1->charge*object2->charge;
2925 +  }
2926  
2927    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2928  
# Line 2605 | Line 2931 | OSUAnalysis::valueLookup (const BNelectr
2931    return value;
2932   }
2933  
2934 + //!jet-jet pair valueLookup
2935 + double
2936 + OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function){
2937 +
2938 +  double value = 0.0;
2939  
2940 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2941 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2942 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2943 +  else if(variable == "invMass"){
2944 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2945 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2946 +    value = (fourVector1 + fourVector2).M();
2947 +  }
2948 +  else if(variable == "pt"){
2949 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2950 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2951 +    value = (fourVector1 + fourVector2).Pt();
2952 +  }
2953 +  else if(variable == "threeDAngle")
2954 +    {
2955 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2956 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2957 +      value = (threeVector1.Angle(threeVector2));
2958 +    }
2959 +  else if(variable == "chargeProduct"){
2960 +    value = object1->charge*object2->charge;
2961 +  }
2962 +  
2963 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2964 +
2965 +  value = applyFunction(function, value);
2966 +
2967 +  return value;
2968 + }
2969 + //!electron-track pair valueLookup
2970   double  
2971   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2972    double electronMass = 0.000511;        
# Line 2613 | Line 2974 | OSUAnalysis::valueLookup (const BNelectr
2974    TLorentzVector fourVector1(0, 0, 0, 0);        
2975    TLorentzVector fourVector2(0, 0, 0, 0);        
2976    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
2977 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2978    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
2979    else if(variable == "invMass"){        
2980      fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
# Line 2626 | Line 2988 | OSUAnalysis::valueLookup (const BNelectr
2988   }
2989  
2990  
2991 <
2991 > //!muon-track pair valueLookup
2992   double
2993   OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2994    double pionMass = 0.140;
# Line 2635 | Line 2997 | OSUAnalysis::valueLookup (const BNmuon*
2997    TLorentzVector fourVector1(0, 0, 0, 0);
2998    TLorentzVector fourVector2(0, 0, 0, 0);
2999    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3000 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3001    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3002    else if(variable == "invMass"){
3003      fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
# Line 2648 | Line 3011 | OSUAnalysis::valueLookup (const BNmuon*
3011    return value;
3012   }
3013  
3014 <
3014 > //!tau-tau pair valueLookup
3015   double
3016   OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
3017    double value = 0.0;
3018    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3019 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3020    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3021    else if(variable == "invMass"){
3022      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2665 | Line 3029 | OSUAnalysis::valueLookup (const BNtau* o
3029    return value;
3030   }
3031  
3032 <
3032 > //!muon-tau pair valueLookup
3033   double
3034   OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
3035    double value = 0.0;
3036    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3037 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3038    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3039    else if(variable == "invMass"){
3040      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2682 | Line 3047 | OSUAnalysis::valueLookup (const BNmuon*
3047    return value;
3048   }
3049  
3050 + //!tau-track pair valueLookup
3051 + double
3052 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
3053 +  double value = 0.0;
3054 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3055 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3056 +
3057 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3058 +  value = applyFunction(function, value);
3059 +  return value;
3060 + }
3061 +
3062  
3063 + //!track-event pair valueLookup
3064   double
3065   OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3066  
# Line 2702 | Line 3080 | OSUAnalysis::valueLookup (const BNtrack*
3080  
3081    return value;
3082  
3083 + }
3084 +
3085 + //!stop valueLookup
3086 + double
3087 + OSUAnalysis::valueLookup (const BNstop* object, string variable, string function){
3088 +
3089 +
3090 +  double value = 0.0;
3091 +
3092 +  if(variable == "ctau") value = object->ctau;
3093 +
3094 +  else if (variable == "d0"){
3095 +    double vx = object->vx - chosenVertex ()->x,
3096 +      vy = object->vy - chosenVertex ()->y,
3097 +      px = object->px,
3098 +      py = object->py,
3099 +      pt = object->pt;
3100 +    value = (-vx * py + vy * px) / pt;
3101 +  }
3102 +
3103 +  else if (variable == "dz"){
3104 +    double vx = object->vx - chosenVertex ()->x,
3105 +      vy = object->vy - chosenVertex ()->y,
3106 +      vz = object->vz - chosenVertex ()->z,
3107 +      px = object->px,
3108 +      py = object->py,
3109 +      pz = object->pz,
3110 +      pt = object->pt;
3111 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3112 +  }
3113 +
3114 +  else if (variable == "minD0"){
3115 +    double minD0=999;
3116 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3117 +      double vx = object->vx - vertex->x,
3118 +        vy = object->vy - vertex->y,
3119 +        px = object->px,
3120 +        py = object->py,
3121 +        pt = object->pt;
3122 +      value = (-vx * py + vy * px) / pt;
3123 +      if(abs(value) < abs(minD0)) minD0 = value;
3124 +    }
3125 +    value = minD0;
3126 +  }
3127 +  else if (variable == "minDz"){
3128 +    double minDz=999;
3129 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3130 +      double vx = object->vx - vertex->x,
3131 +        vy = object->vy - vertex->y,
3132 +        vz = object->vz - vertex->z,
3133 +        px = object->px,
3134 +        py = object->py,
3135 +        pz = object->pz,
3136 +        pt = object->pt;
3137 +      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3138 +      if(abs(value) < abs(minDz)) minDz = value;
3139 +    }
3140 +    value = minDz;
3141 +  }
3142 +  else if(variable == "distToVertex"){
3143 +    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3144 +                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3145 +                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3146 +  }
3147 +  else if (variable == "minDistToVertex"){
3148 +    double minDistToVertex=999;
3149 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3150 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3151 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3152 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3153 +      
3154 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3155 +    }
3156 +    value = minDistToVertex;
3157 +  }
3158 +  else if (variable == "distToVertexDifference"){
3159 +    double minDistToVertex=999;
3160 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3161 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3162 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3163 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3164 +      
3165 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3166 +    }
3167 +    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3168 +                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3169 +                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3170 +
3171 +    value = distToChosenVertex - minDistToVertex;
3172 +  }
3173 +
3174 +  else if (variable == "closestVertexRank"){
3175 +    double minDistToVertex=999;
3176 +    int vertex_rank = 0;
3177 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3178 +      vertex_rank++;
3179 +      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3180 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3181 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3182 +      
3183 +      if(abs(dist) < abs(minDistToVertex)){
3184 +        value = vertex_rank;
3185 +        minDistToVertex = dist;
3186 +      }
3187 +    }
3188 +  }
3189 +
3190 +
3191 +
3192 +
3193 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3194 +
3195 +  value = applyFunction(function, value);
3196 +
3197 +  return value;
3198 +
3199   }  
3200  
3201 +
3202 +
3203 +
3204   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3205   // Return true iff no other tracks are found in this cone.
3206   int
# Line 2840 | Line 3337 | OSUAnalysis::applyFunction(string functi
3337  
3338   template <class InputCollection>
3339   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3340 <
3340 >
3341 >  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
3342 >    string obj1, obj2;
3343 >    getTwoObjs(currentCut.inputCollection, obj1, obj2);
3344 >    if (inputType==obj1 ||
3345 >        inputType==obj2) {
3346 >      // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3347 >      // and the inputType is a member of the pair.  
3348 >      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.  
3349 >      // For example, if currentCut.inputCollection==electron-muon pairs,
3350 >      // then the flags should not be set here when inputType==muons or inputType==electrons.  
3351 >      return;
3352 >    }  
3353 >  }    
3354  
3355    for (uint object = 0; object != inputCollection->size(); object++){
3356  
2847
3357      bool decision = true;//object passes if this cut doesn't cut on that type of object
3358  
2850
3359      if(currentCut.inputCollection == inputType){
3360  
3361        vector<bool> subcutDecisions;
3362        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3363          double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3364          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3365 +
3366        }
3367        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3368        else{
# Line 2867 | Line 3376 | void OSUAnalysis::setObjectFlags(cut &cu
3376          decision = tempDecision;
3377        }
3378      }
2870    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3379  
3380 +    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3381  
3382      //set flags for objects that pass each cut AND all the previous cuts
3383      bool previousCumulativeFlag = true;
# Line 2878 | Line 3387 | void OSUAnalysis::setObjectFlags(cut &cu
3387      }
3388      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3389  
2881
3390    }
3391  
3392   }
# Line 2892 | Line 3400 | void OSUAnalysis::setObjectFlags(cut &cu
3400    bool sameObjects = false;
3401    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3402  
3403 <
3403 >  // Get the strings for the two objects that make up the pair.  
3404 >  string obj1Type, obj2Type;
3405 >  getTwoObjs(inputType, obj1Type, obj2Type);
3406 >  bool isTwoTypesOfObject = true;
3407 >  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
3408 >
3409 >  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
3410 >  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).  
3411 >  if (currentCut.inputCollection == inputType) {    
3412 >    for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3413 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3414 >      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3415 >    }
3416 >    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.  
3417 >      for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3418 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3419 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3420 >      }
3421 >    }
3422 >  }
3423 >  
3424    int counter = 0;
3425 +
3426    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3427      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3428  
# Line 2922 | Line 3451 | void OSUAnalysis::setObjectFlags(cut &cu
3451            decision = tempDecision;
3452          }
3453        }
3454 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3454 >      // if (decision) isPassObj1.at(object1) = true;
3455 >      // if (decision) isPassObj2.at(object2) = true;
3456 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3457 >      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3458 >        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3459 >        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3460 >      }  
3461  
3462        //set flags for objects that pass each cut AND all the previous cuts
3463        bool previousCumulativeFlag = true;
# Line 2937 | Line 3472 | void OSUAnalysis::setObjectFlags(cut &cu
3472        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3473        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3474        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3475 <
3475 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3476 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);  
3477 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);  
3478 >      }
3479        counter++;
2942    }
2943
2944  }
3480  
3481 +    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
3482 +  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
3483  
3484   }
3485  
3486  
3487 + bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3488 +  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3489 +  // all cuts up to currentCutIndex  
3490 +  bool previousCumulativeFlag = true;  
3491 +  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {  
3492 +    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3493 +    else {  
3494 +      previousCumulativeFlag = false; break;  
3495 +    }
3496 +  }
3497 +  return previousCumulativeFlag;  
3498 + }  
3499 +
3500 +
3501   template <class InputCollection>
3502   void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3503  
# Line 2983 | Line 3534 | void OSUAnalysis::fill1DHistogram(TH1* h
3534    bool sameObjects = false;
3535    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3536  
3537 <  int pairCounter = 0;
3537 >  int pairCounter = -1;
3538    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3539      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3540  
3541        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3542  
3543 +      pairCounter++;
3544        //only take objects which have passed all cuts and pairs which have passed all cuts
3545        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3546        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 3009 | Line 3561 | void OSUAnalysis::fill1DHistogram(TH1* h
3561        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3562        histo->Fill(value,scaleFactor);
3563  
3012      pairCounter++;
3564      }
3565    }
3566  
# Line 3062 | Line 3613 | void OSUAnalysis::fill2DHistogram(TH2* h
3613    bool sameObjects = false;
3614    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3615  
3616 <  int pairCounter = 0;
3616 >  int pairCounter = -1;
3617    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3618      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3619  
3620        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3621  
3622 +      pairCounter++;
3623 +
3624        //only take objects which have passed all cuts and pairs which have passed all cuts
3625        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3626        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 3102 | Line 3655 | void OSUAnalysis::fill2DHistogram(TH2* h
3655  
3656        histo->Fill(valueX,valueY,scaleFactor);
3657  
3105      pairCounter++;
3106
3658      }
3659    }
3660  
# Line 3230 | Line 3781 | OSUAnalysis::chosenVertex ()
3781   {
3782    const BNprimaryvertex *chosenVertex = 0;
3783    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3784 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3785 <      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3784 >    vector<bool> vertexFlags;
3785 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
3786 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
3787 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
3788 >        break;
3789 >      }
3790 >    }
3791      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3792        if(!vertexFlags.at(vertexIndex)) continue;
3793        chosenVertex = & primaryvertexs->at(vertexIndex);
# Line 3250 | Line 3806 | OSUAnalysis::chosenMET ()
3806   {
3807    const BNmet *chosenMET = 0;
3808    if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3809 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3810 <      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3809 >    vector<bool> metFlags;
3810 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
3811 >      if (cumulativeFlags.at("mets").at(i).size()){
3812 >        metFlags = cumulativeFlags.at("mets").at(i);
3813 >        break;
3814 >      }
3815 >    }
3816      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3817        if(!metFlags.at(metIndex)) continue;
3818        chosenMET = & mets->at(metIndex);
# Line 3270 | Line 3831 | OSUAnalysis::chosenElectron ()
3831   {
3832    const BNelectron *chosenElectron = 0;
3833    if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3834 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3835 <      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3834 >    vector<bool> electronFlags;
3835 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
3836 >      if (cumulativeFlags.at("electrons").at(i).size()){
3837 >        electronFlags = cumulativeFlags.at("electrons").at(i);
3838 >        break;
3839 >      }
3840 >    }
3841      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3842        if(!electronFlags.at(electronIndex)) continue;
3843        chosenElectron = & electrons->at(electronIndex);
# Line 3290 | Line 3856 | OSUAnalysis::chosenMuon ()
3856   {
3857    const BNmuon *chosenMuon = 0;
3858    if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3859 <    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3860 <      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3859 >    vector<bool> muonFlags;
3860 >    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
3861 >      if (cumulativeFlags.at("muons").at(i).size()){
3862 >        muonFlags = cumulativeFlags.at("muons").at(i);
3863 >        break;
3864 >      }
3865 >    }
3866      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3867        if(!muonFlags.at(muonIndex)) continue;
3868        chosenMuon = & muons->at(muonIndex);
# Line 3305 | Line 3876 | OSUAnalysis::chosenMuon ()
3876    return chosenMuon;
3877   }
3878  
3308
3879   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines