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.30 by lantonel, Fri Mar 15 13:08:45 2013 UTC vs.
Revision 1.43 by wulsin, Thu Mar 28 10:17:32 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")),
22    dataPU_ (cfg.getParameter<std::string> ("dataPU")),
23 +  electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
24 +  muonSF_ (cfg.getParameter<std::string> ("muonSF")),
25    dataset_ (cfg.getParameter<std::string> ("dataset")),
26    datasetType_ (cfg.getParameter<std::string> ("datasetType")),
27    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
28    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
29    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
30 <  doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting"))
30 >  doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
31 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
32 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr"))
33  
34   {
35  
36    TH1::SetDefaultSumw2 ();
37  
38    //create pile-up reweighting object, if necessary
39 <  if(doPileupReweighting_ && datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
39 >  if(datasetType_ != "data") {
40 >    if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
41 >    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
42 >    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
43 >  }
44 >
45  
46    // Construct Cutflow Objects. These store the results of cut decisions and
47    // handle filling cut flow histograms.
# Line 55 | Line 65 | OSUAnalysis::OSUAnalysis (const edm::Par
65  
66      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
67      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
68 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
68 >    if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
69 >    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
70        objectsToGet.push_back(tempInputCollection);
71        objectsToPlot.push_back(tempInputCollection);
72        objectsToCut.push_back(tempInputCollection);
# Line 74 | Line 85 | OSUAnalysis::OSUAnalysis (const edm::Par
85        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
86        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
87  
88 <      }
88 >    }
89  
90      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
91 <    
91 >
92      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
93  
94        histogram tempHistogram;
# Line 86 | Line 97 | OSUAnalysis::OSUAnalysis (const edm::Par
97        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
98        tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
99        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
100 <      
100 >
101        histograms.push_back(tempHistogram);
102  
103      }
# Line 106 | Line 117 | OSUAnalysis::OSUAnalysis (const edm::Par
117      histogram tempIdHisto;
118      histogram tempMomIdHisto;
119      histogram tempGmaIdHisto;
120 +    histogram tempIdVsMomIdHisto;
121  
122      tempIdHisto.inputCollection = currentObject;
123      tempMomIdHisto.inputCollection = currentObject;
124      tempGmaIdHisto.inputCollection = currentObject;
125 +    tempIdVsMomIdHisto.inputCollection = currentObject;
126  
127      currentObject = currentObject.substr(0, currentObject.size()-1);
128      tempIdHisto.name = currentObject+"GenMatchId";
129      tempMomIdHisto.name = currentObject+"GenMatchMotherId";
130      tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
131 +    tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
132  
133      currentObject.at(0) = toupper(currentObject.at(0));
134      tempIdHisto.title = currentObject+" Gen-matched Particle";
135      tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
136      tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
137 +    tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
138  
139      int maxNum = 24;
140      vector<double> binVector;
# Line 133 | Line 148 | OSUAnalysis::OSUAnalysis (const edm::Par
148      tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
149      tempGmaIdHisto.bins = binVector;
150      tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
151 +    binVector.push_back(maxNum);
152 +    binVector.push_back(0);
153 +    binVector.push_back(maxNum);
154 +    tempIdVsMomIdHisto.bins = binVector;
155 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
156 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
157  
158      histograms.push_back(tempIdHisto);
159      histograms.push_back(tempMomIdHisto);
160      histograms.push_back(tempGmaIdHisto);
161 <    
161 >    histograms.push_back(tempIdVsMomIdHisto);
162    }
163  
164  
144
165    channel tempChannel;
166    //loop over all channels (event selections)
167    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
# Line 178 | Line 198 | OSUAnalysis::OSUAnalysis (const edm::Par
198      twoDHists_.push_back(twoDhistoMap);
199  
200  
201 +
202      //book all histograms included in the configuration
203      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
204        histogram currentHistogram = histograms.at(currentHistogramIndex);
# Line 185 | Line 206 | OSUAnalysis::OSUAnalysis (const edm::Par
206        int numInputVariables = currentHistogram.inputVariables.size();
207  
208        if(numBinsElements != 3 && numBinsElements !=6) {
209 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
210 <        exit(0);
209 >        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
210 >        exit(0);
211        }
212        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
213 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
214 <        exit(0);
213 >        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
214 >        exit(0);
215        }
216        else if(numBinsElements == 3){
217 <        oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
217 >        oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
218        }
219        else if(numBinsElements == 6){
220 <        twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
220 >        twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
221  
222        }
223  
224  
225        if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
226  
227 < // bin      particle type
228 < // ---      -------------
229 < //  0        unmatched
230 < //  1        u
231 < //  2        d
232 < //  3        s
233 < //  4        c
234 < //  5        b
235 < //  6        t
236 < //  7        e
237 < //  8        mu
238 < //  9        tau
239 < // 10        nu
240 < // 11        g
241 < // 12        gamma
242 < // 13        Z
243 < // 14        W
244 < // 15        light meson
245 < // 16        K meson
246 < // 17        D meson
247 < // 18        B meson
248 < // 19        light baryon
249 < // 20        strange baryon
250 < // 21        charm baryon
251 < // 22        bottom baryon
252 < // 23        other
227 >      // bin      particle type
228 >      // ---      -------------
229 >      //  0        unmatched
230 >      //  1        u
231 >      //  2        d
232 >      //  3        s
233 >      //  4        c
234 >      //  5        b
235 >      //  6        t
236 >      //  7        e
237 >      //  8        mu
238 >      //  9        tau
239 >      // 10        nu
240 >      // 11        g
241 >      // 12        gamma
242 >      // 13        Z
243 >      // 14        W
244 >      // 15        light meson
245 >      // 16        K meson
246 >      // 17        D meson
247 >      // 18        B meson
248 >      // 19        light baryon
249 >      // 20        strange baryon
250 >      // 21        charm baryon
251 >      // 22        bottom baryon
252 >      // 23        other
253  
254        vector<TString> labelArray;
255        labelArray.push_back("unmatched");
# Line 257 | Line 278 | OSUAnalysis::OSUAnalysis (const edm::Par
278        labelArray.push_back("other");
279  
280        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
281 <        oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
281 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
282 >          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
283 >        }
284 >        else {
285 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
286 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
287 >        }
288 >      }
289 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
290 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
291 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
292        }
262    }
293  
294 <    //book a histogram for the number of each object type to be plotted
294 >    }
295  
296 +    // Book a histogram for the number of each object type to be plotted.  
297 +    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
298      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
299        string currentObject = objectsToPlot.at(currentObjectIndex);
300        int maxNum = 10;
# Line 270 | Line 302 | OSUAnalysis::OSUAnalysis (const edm::Par
302        else if(currentObject == "primaryvertexs") maxNum = 50;
303        else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
304        else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
305 <      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
306 <
307 <      currentObject.at(0) = toupper(currentObject.at(0));
305 >      else if(currentObject == "electron-muon pairs")     currentObject = "electronMuonPairs";
306 >      else if(currentObject == "track-event pairs")       currentObject = "trackEventPairs";
307 >      else if(currentObject == "electron-track pairs")    currentObject = "electronTrackPairs";  
308 >      else if(currentObject == "muon-track pairs")        currentObject = "muonTrackPairs";      
309 >      else if(currentObject == "muon-tau pairs")          currentObject = "muonTauPairs";        
310 >      else if(currentObject == "tau-tau pairs")           currentObject = "ditauPairs";
311 >      currentObject.at(0) = toupper(currentObject.at(0));  
312        string histoName = "num" + currentObject;
313  
314        if(histoName == "numPrimaryvertexs"){
315 <        string newHistoName = histoName + "BeforePileupCorrection";
316 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);    
317 <        newHistoName = histoName + "AfterPileupCorrection";
318 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
315 >        string newHistoName = histoName + "BeforePileupCorrection";
316 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
317 >        newHistoName = histoName + "AfterPileupCorrection";
318 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
319        }
320        else
321 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
321 >        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
322      }
323  
324  
289    
325  
326  
327      //get list of cuts for this channel
# Line 298 | Line 333 | OSUAnalysis::OSUAnalysis (const edm::Par
333        //store input collection for cut
334        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
335        tempCut.inputCollection = tempInputCollection;
336 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
337 <        objectsToGet.push_back(tempInputCollection);
338 <        objectsToCut.push_back(tempInputCollection);
336 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
337 >        objectsToGet.push_back(tempInputCollection);
338 >        objectsToCut.push_back(tempInputCollection);
339        }
340        else{//pair of objects, need to add them both to the things to objectsToGet
341 <        int dashIndex = tempInputCollection.find("-");
342 <        int spaceIndex = tempInputCollection.find(" ");
343 <        int secondWordLength = spaceIndex - dashIndex;
344 <        objectsToGet.push_back(tempInputCollection);
345 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
341 >        int dashIndex = tempInputCollection.find("-");
342 >        int spaceIndex = tempInputCollection.find(" ");
343 >        int secondWordLength = spaceIndex - dashIndex;
344 >        objectsToGet.push_back(tempInputCollection);
345 >        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
346          objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
347 <        objectsToCut.push_back(tempInputCollection);
348 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
347 >        objectsToCut.push_back(tempInputCollection);
348 >        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
349          objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
350  
351        }
# Line 321 | Line 356 | OSUAnalysis::OSUAnalysis (const edm::Par
356        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
357        std::vector<string> cutStringVector = splitString(cutString);
358        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
359 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
360 <        exit(0);
359 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
360 >        exit(0);
361        }
362        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
363        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
364 <        int indexOffset = 4 * subcutIndex;
365 <        string currentVariableString = cutStringVector.at(indexOffset);
366 <        if(currentVariableString.find("(")==std::string::npos){
367 <          tempCut.functions.push_back("");//no function was specified
368 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
369 <        }
370 <        else{
371 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
372 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
373 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
374 <        }
375 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
376 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
377 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
364 >        int indexOffset = 4 * subcutIndex;
365 >        string currentVariableString = cutStringVector.at(indexOffset);
366 >        if(currentVariableString.find("(")==std::string::npos){
367 >          tempCut.functions.push_back("");//no function was specified
368 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
369 >        }
370 >        else{
371 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
372 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
373 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
374 >        }
375 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
376 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
377 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
378        }
379  
380        //get number of objects required to pass cut for event to pass
381        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
382        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
383        if(numberRequiredVector.size()!=2){
384 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
384 >        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
385          exit(0);
386        }
387  
# Line 448 | Line 483 | OSUAnalysis::analyze (const edm::Event &
483    if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
484      event.getByLabel (superclusters_, superclusters);
485  
486 <
487 <  //get pile-up event weight
488 <  double puScaleFactor = 1.00;
489 <  if(doPileupReweighting_ && datasetType_ != "data"){
490 <    puScaleFactor = puWeight_->at (events->at (0).numTruePV);
491 <    //cout << puScaleFactor << endl;
486 >  if (useTrackCaloRhoCorr_) {  
487 >    // Used only for pile-up correction of by-hand calculation of isolation energy.  
488 >    // This rho collection is not available in all BEANs.  
489 >    // For description of rho values for different jet reconstruction algorithms, see
490 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
491 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
492    }
493  
494  
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 +
500  
501    //loop over all channels
502  
# Line 464 | Line 504 | OSUAnalysis::analyze (const edm::Event &
504      channel currentChannel = channels.at(currentChannelIndex);
505  
506      flagMap individualFlags;
467    flagMap cumulativeFlags;
507      counterMap passingCounter;
508 +    cumulativeFlags.clear ();
509  
510      bool triggerDecision = true;
511      if(currentChannel.triggers.size() != 0){  //triggers specified
# Line 483 | Line 523 | OSUAnalysis::analyze (const edm::Event &
523        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
524          string currentObject = objectsToCut.at(currentObjectIndex);
525  
526 <        //initialize maps to get ready to set cuts
526 >        //initialize maps to get ready to set cuts
527          individualFlags[currentObject].push_back (vector<bool> ());
528          cumulativeFlags[currentObject].push_back (vector<bool> ());
529  
# Line 491 | Line 531 | OSUAnalysis::analyze (const edm::Event &
531        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
532          string currentObject = objectsToCut.at(currentObjectIndex);
533  
534 <        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
534 >        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
535 >
536  
537          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
538          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
# Line 507 | Line 548 | OSUAnalysis::analyze (const edm::Event &
548          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
549          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
550  
510        
511        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
512                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
513                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
514                                                                   "muon-muon pairs");
515        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
516                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
517                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
518                                                                           "electron-electron pairs");
519        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
520                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
521                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
522                                                                       "electron-muon pairs");
523
551  
552 +        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
553 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
554 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
555 +                                                                   "muon-muon pairs");
556 +        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
557 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
558 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
559 +                                                                           "electron-electron pairs");
560 +        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
561 +                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
562 +                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
563 +                                                                       "electron-muon pairs");
564 +        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
565 +                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
566 +                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
567 +                                                                     "track-event pairs");
568 +        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
569 +                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
570 +                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
571 +                                                                        "electron-track pairs");
572 +        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
573 +                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
574 +                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
575 +                                                                    "muon-track pairs");
576 +        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
577 +                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
578 +                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
579 +                                                                  "muon-tau pairs");
580 +        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(),
581 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
582 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
583 +                                                                 "tau-tau pairs");
584 +        
585 +        
586        }
587  
588  
# Line 545 | Line 606 | OSUAnalysis::analyze (const edm::Event &
606        int numberPassing = 0;
607  
608        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
609 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
609 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
610        }
611  
612        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
# Line 555 | Line 616 | OSUAnalysis::analyze (const edm::Event &
616  
617      }
618  
619 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor);
619 >    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
620  
621  
622  
623      if(!eventPassedAllCuts)continue;
624  
625 <
626 <    
627 <
628 <    //set position of primary vertex in event, in order to calculate quantities relative to it
629 <    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
630 <      vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
631 <      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
571 <        if(!vertexFlags.at(vertexIndex)) continue;
572 <        chosenPrimaryVertex = & primaryvertexs->at(vertexIndex);
573 <        break;
574 <      }
575 <    }
576 <    else {
577 <      chosenPrimaryVertex = & primaryvertexs->at(0);
625 >    if (printEventInfo_) {
626 >      // Write information about event to screen, for testing purposes.  
627 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
628 >           << ": run="  << events->at(0).run
629 >           << "  lumi=" << events->at(0).lumi
630 >           << "  event=" << events->at(0).evt
631 >           << endl;  
632      }
633  
634  
635 +    //     if(datasetType_ != "data") {
636 +    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
637 +    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
638 +    //     }
639  
640      //filling histograms
641      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
642        histogram currentHistogram = histograms.at(histogramIndex);
643  
644        if(currentHistogram.inputVariables.size() == 1){
645 <        TH1D* histo;
646 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
645 >        TH1D* histo;
646 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
647  
648  
649  
650 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
651 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
652 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
653 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
654 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
655 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
656 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
657 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
658 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
659 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
660 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
661 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
662 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
663 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
664 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
665 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
666 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
667 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
668 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
669 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
670 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
671 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
650 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
651 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
652 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
653 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
654 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
655 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
656 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
657 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
658 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
659 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
660 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
661 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
662 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
663 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
664 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
665 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
666 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
667 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
668 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
669 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
670 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
671 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
672 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
673 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
674 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
675 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
676 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
677 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
678 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
679 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
680 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
681 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
682 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
683 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
684        }
685        else if(currentHistogram.inputVariables.size() == 2){
686 <        TH2D* histo;
687 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
686 >        TH2D* histo;
687 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
688  
689  
690  
691 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
692 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
693 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
694 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
695 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
696 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
697 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
698 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
699 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
700 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
701 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
702 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
703 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
704 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
705 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
706 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
707 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
708 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
709 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
710 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
711 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
712 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
713 <      }
691 >        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
692 >        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
693 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
694 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
695 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
696 >        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
697 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
698 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
699 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
700 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
701 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
702 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
703 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
704 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
705 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
706 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
707 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
708 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
709 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
710 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
711 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
712 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
713 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
714 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
715 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
716 >        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
717 >        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
718 >        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
719 >        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
720 >                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
721 >                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
722 >        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
723 >        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
724 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
725 >        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
726 >        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
727 >        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
728 >      }
729      }
730  
731      //fills histograms with the sizes of collections
732      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
733 +
734        string currentObject = objectsToPlot.at(currentObjectIndex);
735  
736 <      string objectToPlot = "";
736 >      string objectToPlot = "";  
737  
738 +      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
739        if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
740        else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
741 <      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
741 >      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
742 >      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
743 >      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
744 >      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
745 >      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
746 >      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
747        else objectToPlot = currentObject;
748        string tempCurrentObject = objectToPlot;
749 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
749 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
750        string histoName = "num" + tempCurrentObject;
751  
752  
661
662
753        //set position of primary vertex in event, in order to calculate quantities relative to it
754        if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
755 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
756 <        int numToPlot = 0;
757 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
758 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
759 <        }
760 <        if(objectToPlot == "primaryvertexs"){
761 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
762 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
755 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
756 >        int numToPlot = 0;
757 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
758 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
759 >        }
760 >        if(objectToPlot == "primaryvertexs"){
761 >          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
762 >          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
763 >        }
764 >        else {
765 >          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
766          }
674        else
675          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,puScaleFactor);        
676      }
677      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
678      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
679      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
680      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
681      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
682      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
683      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
684      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
685      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
686      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
687      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
688      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
689      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
690      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
691      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
692      else if(objectToPlot == "primaryvertexs"){
693        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
694        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
767        }
768 +      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
769 +      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
770 +      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
771 +      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
772 +      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
773 +      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
774 +      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
775 +      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
776 +      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
777 +      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
778 +      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
779 +      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
780 +      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
781 +      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
782 +      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
783 +      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
784 +      else if(objectToPlot == "primaryvertexs"){
785 +        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
786 +        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
787 +      }
788  
789 <    }
698 <
699 <
700 <
789 >    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
790  
791    } //end loop over channel
792  
793 <  masterCutFlow_->fillCutFlow(puScaleFactor);
793 >  masterCutFlow_->fillCutFlow(scaleFactor);
794  
795 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
796  
797  
708 }
709
798  
799   bool
800   OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
# Line 1039 | Line 1127 | OSUAnalysis::valueLookup (const BNmuon*
1127    else if(variable == "time_ndof") value = object->time_ndof;
1128  
1129    //user-defined variables
1130 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1131 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1130 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1131 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1132    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1133 <  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1133 >  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1134    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1135 +  else if(variable == "metMT") {
1136 +    const BNmet *met = chosenMET ();
1137 +    if (met)
1138 +      {
1139 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1140 +          p2 (met->px, met->py, 0.0, met->pt);
1141 +
1142 +        value = (p1 + p2).Mt ();
1143 +      }
1144 +    else
1145 +      value = -999;
1146 +  }
1147  
1148  
1149  
# Line 1154 | Line 1254 | OSUAnalysis::valueLookup (const BNmuon*
1254  
1255  
1256    else if(variable == "tightID") {
1257 <    value = object->isGlobalMuon > 0            \
1258 <      && object->isPFMuon > 0                   \
1259 <      && object->normalizedChi2 < 10            \
1260 <      && object->numberOfValidMuonHits > 0      \
1261 <      && object->numberOfMatchedStations > 1    \
1262 <      && fabs(object->correctedD0Vertex) < 0.2  \
1263 <      && fabs(object->correctedDZ) < 0.5        \
1264 <      && object->numberOfValidPixelHits > 0             \
1257 >    value = object->isGlobalMuon > 0                \
1258 >      && object->isPFMuon > 0                        \
1259 >      && object->normalizedChi2 < 10                \
1260 >                                  && object->numberOfValidMuonHits > 0        \
1261 >      && object->numberOfMatchedStations > 1        \
1262 >      && fabs(object->correctedD0Vertex) < 0.2        \
1263 >      && fabs(object->correctedDZ) < 0.5        \
1264 >      && object->numberOfValidPixelHits > 0                \
1265        && object->numberOfLayersWithMeasurement > 5;
1266    }
1267    else if(variable == "tightIDdisplaced"){
1268 <    value = object->isGlobalMuon > 0            \
1269 <      && object->normalizedChi2 < 10            \
1270 <      && object->numberOfValidMuonHits > 0      \
1271 <      && object->numberOfMatchedStations > 1    \
1272 <      && object->numberOfValidPixelHits > 0     \
1268 >    value = object->isGlobalMuon > 0                \
1269 >      && object->normalizedChi2 < 10                \
1270 >                                  && object->numberOfValidMuonHits > 0        \
1271 >      && object->numberOfMatchedStations > 1        \
1272 >      && object->numberOfValidPixelHits > 0        \
1273        && object->numberOfLayersWithMeasurement > 5;
1274    }
1275  
1276 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1277  
1278 +  else if(variable == "genMatchedPdgId"){
1279 +    int index = getGenMatchedParticleIndex(object);
1280 +    if(index == -1) value = 0;
1281 +    else value = mcparticles->at(index).id;
1282 +  }
1283  
1284    else if(variable == "genMatchedId"){
1285      int index = getGenMatchedParticleIndex(object);
# Line 1185 | Line 1291 | OSUAnalysis::valueLookup (const BNmuon*
1291      if(index == -1) value = 0;
1292      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1293    }
1294 +  else if(variable == "genMatchedMotherIdReverse"){
1295 +    int index = getGenMatchedParticleIndex(object);
1296 +    if(index == -1) value = 23;
1297 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1298 +  }
1299    else if(variable == "genMatchedGrandmotherId"){
1300      int index = getGenMatchedParticleIndex(object);
1301      if(index == -1) value = 0;
# Line 1368 | Line 1479 | OSUAnalysis::valueLookup (const BNelectr
1479    else if(variable == "passConvVeto") value = object->passConvVeto;
1480  
1481    //user-defined variables
1482 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1483 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1482 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1483 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1484    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1485    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1486 +  else if(variable == "metMT") {
1487 +    const BNmet *met = chosenMET ();
1488 +    if (met)
1489 +      {
1490 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1491 +          p2 (met->px, met->py, 0.0, met->pt);
1492  
1493 +        value = (p1 + p2).Mt ();
1494 +      }
1495 +    else
1496 +      value = -999;
1497 +  }
1498  
1499    else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1500      if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
# Line 1383 | Line 1505 | OSUAnalysis::valueLookup (const BNelectr
1505      else value = -999;
1506    }
1507  
1386
1508    else if(variable == "correctedD0VertexInEBPlus"){
1509      if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1510      else value = -999;
# Line 1436 | Line 1557 | OSUAnalysis::valueLookup (const BNelectr
1557      else value = -999;
1558    }
1559  
1560 +  else if(variable == "tightID"){
1561 +    if (object->isEB)
1562 +      {
1563 +        value = fabs(object->delEtaIn) < 0.004 \
1564 +          && fabs (object->delPhiIn) < 0.03 \
1565 +          && object->scSigmaIEtaIEta < 0.01 \
1566 +          && object->hadOverEm < 0.12 \
1567 +          && fabs (object->correctedD0Vertex) < 0.02 \
1568 +          && fabs (object->correctedDZ) < 0.1 \
1569 +          && object->absInvEMinusInvPin < 0.05 \
1570 +          && object->passConvVeto;
1571 +      }
1572 +    else
1573 +      {
1574 +        value = fabs(object->delEtaIn) < 0.005 \
1575 +          && fabs (object->delPhiIn) < 0.02 \
1576 +          && object->scSigmaIEtaIEta < 0.03 \
1577 +          && object->hadOverEm < 0.10 \
1578 +          && fabs (object->correctedD0Vertex) < 0.02 \
1579 +          && fabs (object->correctedDZ) < 0.1 \
1580 +          && object->absInvEMinusInvPin < 0.05 \
1581 +          && object->passConvVeto;
1582 +      }
1583 +  }
1584  
1585    else if(variable == "correctedD0VertexInEBPositiveCharge"){
1586      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
# Line 1493 | Line 1638 | OSUAnalysis::valueLookup (const BNelectr
1638    else if(variable == "tightIDdisplaced"){
1639      if (object->isEB)
1640        {
1641 <        value = fabs(object->delEtaIn) < 0.004 \
1642 <          && fabs (object->delPhiIn) < 0.03 \
1641 >        value = fabs(object->delEtaIn) < 0.004 \
1642 >          && fabs (object->delPhiIn) < 0.03 \
1643            && object->scSigmaIEtaIEta < 0.01 \
1644            && object->hadOverEm < 0.12 \
1645 <          && object->absInvEMinusInvPin < 0.05;
1645 >          && object->absInvEMinusInvPin < 0.05;
1646        }
1647      else
1648        {
1649 <        value = fabs (object->delEtaIn) < 0.005 \
1650 <          && fabs (object->delPhiIn) < 0.02 \
1649 >        value = fabs (object->delEtaIn) < 0.005 \
1650 >          && fabs (object->delPhiIn) < 0.02 \
1651            && object->scSigmaIEtaIEta < 0.03 \
1652            && object->hadOverEm < 0.10 \
1653 <          && object->absInvEMinusInvPin < 0.05;
1653 >          && object->absInvEMinusInvPin < 0.05;
1654        }
1655    }
1656  
1657 +
1658 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1659 +
1660 +  else if(variable == "genMatchedPdgId"){
1661 +    int index = getGenMatchedParticleIndex(object);
1662 +    if(index == -1) value = 0;
1663 +    else value = mcparticles->at(index).id;
1664 +  }
1665 +
1666 +
1667    else if(variable == "genMatchedId"){
1668      int index = getGenMatchedParticleIndex(object);
1669      if(index == -1) value = 0;
# Line 1519 | Line 1674 | OSUAnalysis::valueLookup (const BNelectr
1674      if(index == -1) value = 0;
1675      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1676    }
1677 +  else if(variable == "genMatchedMotherIdReverse"){
1678 +    int index = getGenMatchedParticleIndex(object);
1679 +    if(index == -1) value = 23;
1680 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1681 +  }
1682    else if(variable == "genMatchedGrandmotherId"){
1683      int index = getGenMatchedParticleIndex(object);
1684      if(index == -1) value = 0;
# Line 1609 | Line 1769 | OSUAnalysis::valueLookup (const BNevent*
1769    else if(variable == "id1") value = object->id1;
1770    else if(variable == "id2") value = object->id2;
1771    else if(variable == "evt") value = object->evt;
1772 +  else if(variable == "puScaleFactor"){
1773 +    if(datasetType_ != "data")
1774 +      value = puWeight_->at (events->at (0).numTruePV);
1775 +    else
1776 +      value = 1.0;
1777 +  }
1778 +  else if(variable == "muonScaleFactor"){
1779 +    if(datasetType_ != "data")
1780 +      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1781 +      value = 1.0;
1782 +    else
1783 +      value = 1.0;
1784 +  }
1785 +  else if(variable == "electronScaleFactor"){
1786 +    if(datasetType_ != "data")
1787 +      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1788 +      value = 1.0;
1789 +    else
1790 +      value = 1.0;
1791 +  }
1792  
1793    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1794  
# Line 1663 | Line 1843 | OSUAnalysis::valueLookup (const BNtau* o
1843    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1844  
1845  
1846 +
1847 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1848 +
1849 +  else if(variable == "genMatchedPdgId"){
1850 +    int index = getGenMatchedParticleIndex(object);
1851 +    if(index == -1) value = 0;
1852 +    else value = mcparticles->at(index).id;
1853 +  }
1854 +
1855    else if(variable == "genMatchedId"){
1856      int index = getGenMatchedParticleIndex(object);
1857      if(index == -1) value = 0;
# Line 1673 | Line 1862 | OSUAnalysis::valueLookup (const BNtau* o
1862      if(index == -1) value = 0;
1863      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1864    }
1865 +  else if(variable == "genMatchedMotherIdReverse"){
1866 +    int index = getGenMatchedParticleIndex(object);
1867 +    if(index == -1) value = 23;
1868 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1869 +  }
1870    else if(variable == "genMatchedGrandmotherId"){
1871      int index = getGenMatchedParticleIndex(object);
1872      if(index == -1) value = 0;
# Line 1769 | Line 1963 | OSUAnalysis::valueLookup (const BNtrack*
1963  
1964    double value = 0.0;
1965    double pMag = sqrt(object->pt * object->pt +
1966 <                         object->pz * object->pz);
1966 >                     object->pz * object->pz);
1967    
1968    if(variable == "pt") value = object->pt;
1969    else if(variable == "px") value = object->px;
# Line 1790 | Line 1984 | OSUAnalysis::valueLookup (const BNtrack*
1984    else if(variable == "isHighPurity") value = object->isHighPurity;
1985  
1986  
1987 <  //additional BNs info for disappTrks  
1987 >  //additional BNs info for disappTrks
1988    else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
1989    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
1990    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
# Line 1801 | Line 1995 | OSUAnalysis::valueLookup (const BNtrack*
1995    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
1996    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
1997    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
1998 +  
1999 +
2000    //user defined variables
2001    else if(variable == "d0wrtBS") value = (object->vx-events->at(0).BSx)*object->py/object->pt - (object->vy-events->at(0).BSy)*object->px/object->pt;
2002    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2003 <  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2004 <  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2005 <  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
2006 <  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
2007 <  else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
2008 <  else if(variable == "ptError") value = object->ptError;
2009 <  else if(variable == "ptRes") value = getTrkPtRes(object);  
2003 >  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2004 >  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2005 >  else if(variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object);  
2006 >  else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;  
2007 >  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2008 >  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2009 >  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2010 >  else if(variable == "ptError")                    value = object->ptError;
2011 >  else if(variable == "ptRes")                      value = getTrkPtRes(object);
2012 >  else if (variable == "d0wrtPV"){      
2013 >    double vx = object->vx - chosenVertex ()->x,        
2014 >      vy = object->vy - chosenVertex ()->y,      
2015 >      px = object->px,  
2016 >      py = object->py,  
2017 >      pt = object->pt;  
2018 >    value = (-vx * py + vy * px) / pt;  
2019 >  }      
2020 >  else if (variable == "dZwrtPV"){      
2021 >    double vx = object->vx - chosenVertex ()->x,        
2022 >      vy = object->vy - chosenVertex ()->y,      
2023 >      vz = object->vz - chosenVertex ()->z,      
2024 >      px = object->px,  
2025 >      py = object->py,  
2026 >      pz = object->pz,  
2027 >      pt = object->pt;  
2028 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2029 >  }    
2030 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2031 >
2032 >  else if(variable == "genMatchedPdgId"){
2033 >    int index = getGenMatchedParticleIndex(object);
2034 >    if(index == -1) value = 0;
2035 >    else value = mcparticles->at(index).id;
2036 >  }
2037  
2038  
2039    else if(variable == "genMatchedId"){
# Line 1823 | Line 2046 | OSUAnalysis::valueLookup (const BNtrack*
2046      if(index == -1) value = 0;
2047      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2048    }
2049 +  else if(variable == "genMatchedMotherIdReverse"){
2050 +    int index = getGenMatchedParticleIndex(object);
2051 +    if(index == -1) value = 23;
2052 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2053 +  }
2054    else if(variable == "genMatchedGrandmotherId"){
2055      int index = getGenMatchedParticleIndex(object);
2056      if(index == -1) value = 0;
# Line 1963 | Line 2191 | OSUAnalysis::valueLookup (const BNmcpart
2191  
2192    //user-defined variables
2193    else if (variable == "d0"){
2194 <    double vx = object->vx - chosenPrimaryVertex->x,
2195 <      vy = object->vy - chosenPrimaryVertex->y,
2194 >    double vx = object->vx - chosenVertex ()->x,
2195 >      vy = object->vy - chosenVertex ()->y,
2196        px = object->px,
2197        py = object->py,
2198        pt = object->pt;
2199      value = (-vx * py + vy * px) / pt;
2200    }
2201    else if (variable == "dz"){
2202 <    double vx = object->vx - chosenPrimaryVertex->x,
2203 <      vy = object->vy - chosenPrimaryVertex->y,
2204 <      vz = object->vz - chosenPrimaryVertex->z,
2202 >    double vx = object->vx - chosenVertex ()->x,
2203 >      vy = object->vy - chosenVertex ()->y,
2204 >      vz = object->vz - chosenVertex ()->z,
2205        px = object->px,
2206        py = object->py,
2207        pz = object->pz,
# Line 1984 | Line 2212 | OSUAnalysis::valueLookup (const BNmcpart
2212      value = sqrt(object->vx*object->vx + object->vy*object->vy);
2213    }
2214    else if(variable == "deltaV0"){
2215 <    value = sqrt((object->vx-chosenPrimaryVertex->x)*(object->vx-chosenPrimaryVertex->x) + (object->vy-chosenPrimaryVertex->y)*(object->vy-chosenPrimaryVertex->y));
2215 >    value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2216    }
2217    else if (variable == "deltaVx"){
2218 <    value = object->vx - chosenPrimaryVertex->x;
2218 >    value = object->vx - chosenVertex ()->x;
2219    }
2220    else if (variable == "deltaVy"){
2221 <    value = object->vy - chosenPrimaryVertex->y;
2221 >    value = object->vy - chosenVertex ()->y;
2222    }
2223    else if (variable == "deltaVz"){
2224 <    value = object->vz - chosenPrimaryVertex->z;
2224 >    value = object->vz - chosenVertex ()->z;
2225    }
2226  
2227  
# Line 2124 | Line 2352 | OSUAnalysis::valueLookup (const BNphoton
2352    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2353  
2354  
2355 +
2356 +
2357 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2358 +
2359 +  else if(variable == "genMatchedPdgId"){
2360 +    int index = getGenMatchedParticleIndex(object);
2361 +    if(index == -1) value = 0;
2362 +    else value = mcparticles->at(index).id;
2363 +  }
2364 +
2365 +
2366 +
2367    else if(variable == "genMatchedId"){
2368      int index = getGenMatchedParticleIndex(object);
2369      if(index == -1) value = 0;
# Line 2134 | Line 2374 | OSUAnalysis::valueLookup (const BNphoton
2374      if(index == -1) value = 0;
2375      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2376    }
2377 +  else if(variable == "genMatchedMotherIdReverse"){
2378 +    int index = getGenMatchedParticleIndex(object);
2379 +    if(index == -1) value = 23;
2380 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2381 +  }
2382    else if(variable == "genMatchedGrandmotherId"){
2383      int index = getGenMatchedParticleIndex(object);
2384      if(index == -1) value = 0;
# Line 2188 | Line 2433 | OSUAnalysis::valueLookup (const BNmuon*
2433      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2434      value = (fourVector1 + fourVector2).M();
2435    }
2436 +  else if(variable == "pt"){
2437 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2438 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2439 +    value = (fourVector1 + fourVector2).Pt();
2440 +  }
2441    else if(variable == "threeDAngle")
2442      {
2443        TVector3 threeVector1(object1->px, object1->py, object1->pz);
# Line 2218 | Line 2468 | OSUAnalysis::valueLookup (const BNmuon*
2468    else if(variable == "muon2CorrectedD0Vertex"){
2469      value = object2->correctedD0Vertex;
2470    }
2471 < else if(variable == "muon1timeAtIpInOut"){
2471 >  else if(variable == "muon1timeAtIpInOut"){
2472      value = object1->timeAtIpInOut;
2473    }
2474 < else if(variable == "muon2timeAtIpInOut"){
2474 >  else if(variable == "muon2timeAtIpInOut"){
2475      value = object2->timeAtIpInOut;
2476    }
2477 +  else if(variable == "muon1correctedD0")
2478 +    {
2479 +      value = object1->correctedD0;
2480 +    }
2481 +  else if(variable == "muon2correctedD0")
2482 +    {
2483 +      value = object2->correctedD0;
2484 +    }
2485 +
2486    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2487  
2488    value = applyFunction(function, value);
# Line 2243 | Line 2502 | OSUAnalysis::valueLookup (const BNelectr
2502      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2503      value = (fourVector1 + fourVector2).M();
2504    }
2505 +  else if(variable == "pt"){
2506 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2507 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2508 +    value = (fourVector1 + fourVector2).Pt();
2509 +  }
2510    else if(variable == "threeDAngle")
2511      {
2512        TVector3 threeVector1(object1->px, object1->py, object1->pz);
# Line 2266 | Line 2530 | OSUAnalysis::valueLookup (const BNelectr
2530    else if(variable == "electron2CorrectedD0Vertex"){
2531      value = object2->correctedD0Vertex;
2532    }
2533 +  else if(variable == "electron1CorrectedD0"){
2534 +    value = object1->correctedD0;
2535 +  }
2536 +  else if(variable == "electron2CorrectedD0"){
2537 +    value = object2->correctedD0;
2538 +  }
2539  
2540    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2541  
# Line 2286 | Line 2556 | OSUAnalysis::valueLookup (const BNelectr
2556      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2557      value = (fourVector1 + fourVector2).M();
2558    }
2559 +  else if(variable == "pt"){
2560 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2561 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2562 +    value = (fourVector1 + fourVector2).Pt();
2563 +  }
2564    else if(variable == "threeDAngle")
2565      {
2566        TVector3 threeVector1(object1->px, object1->py, object1->pz);
# Line 2315 | Line 2590 | OSUAnalysis::valueLookup (const BNelectr
2590    else if(variable == "muonCorrectedD0"){
2591      value = object2->correctedD0;
2592    }
2593 +  else if(variable == "electronDetIso"){
2594 +    value = (object1->trackIso) / object1->pt;
2595 +  }
2596 +  else if(variable == "muonDetIso"){
2597 +    value = (object2->trackIsoDR03) / object2->pt;
2598 +  }
2599 +
2600 +
2601 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2602 +
2603 +  value = applyFunction(function, value);
2604 +
2605 +  return value;
2606 + }
2607 +
2608 +
2609 + double  
2610 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2611 +  double electronMass = 0.000511;        
2612 +  double value = 0.0;    
2613 +  TLorentzVector fourVector1(0, 0, 0, 0);        
2614 +  TLorentzVector fourVector2(0, 0, 0, 0);        
2615 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
2616 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
2617 +  else if(variable == "invMass"){        
2618 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
2619 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
2620 +        
2621 +    value = (fourVector1 + fourVector2).M();    
2622 +  }
2623 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
2624 +  value = applyFunction(function, value);        
2625 +  return value;  
2626 + }
2627 +
2628 +
2629 +
2630 + double
2631 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2632 +  double pionMass = 0.140;
2633 +  double muonMass = 0.106;
2634 +  double value = 0.0;
2635 +  TLorentzVector fourVector1(0, 0, 0, 0);
2636 +  TLorentzVector fourVector2(0, 0, 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 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
2641 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
2642  
2643 +    value = (fourVector1 + fourVector2).M();
2644 +  }
2645  
2646    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2647 +  value = applyFunction(function, value);
2648 +  return value;
2649 + }
2650  
2651 +
2652 + double
2653 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2654 +  double value = 0.0;
2655 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2656 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2657 +  else if(variable == "invMass"){
2658 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2659 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2660 +    value = (fourVector1 + fourVector2).M();
2661 +  }
2662 +
2663 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2664    value = applyFunction(function, value);
2665 +  return value;
2666 + }
2667  
2668 +
2669 + double
2670 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2671 +  double value = 0.0;
2672 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2673 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2674 +  else if(variable == "invMass"){
2675 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2676 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2677 +    value = (fourVector1 + fourVector2).M();
2678 +  }
2679 +
2680 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2681 +  value = applyFunction(function, value);
2682    return value;
2683   }
2684  
2685  
2686 < // Calculate the number of tracks in cone of DeltaR<0.5 around track1.  
2687 < // Return true iff no other tracks are found in this cone.  
2688 < int
2686 > double
2687 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
2688 >
2689 >  double value = 0.0;
2690 >  double pMag = sqrt(object1->pt * object1->pt +
2691 >                     object1->pz * object1->pz);  
2692 >
2693 >  if      (variable == "numPV")                      value = object2->numPV;
2694 >  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
2695 >  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
2696 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
2697 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
2698 >
2699 >  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
2700 >
2701 >  value = applyFunction(function, value);
2702 >
2703 >  return value;
2704 >
2705 > }  
2706 >
2707 > // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2708 > // Return true iff no other tracks are found in this cone.
2709 > int
2710   OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
2711    for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
2712 <    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.  
2712 >    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
2713      double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
2714      if(deltaRtrk < 0.5) return 0;
2715    }
2716    return 1;
2717 <  
2717 >
2718   }
2719  
2720  
2721 < double
2721 > double
2722   OSUAnalysis::getTrkPtRes (const BNtrack* track1){
2723  
2724    double ptTrue = getTrkPtTrue(track1, mcparticles.product());
2725    double PtRes = (track1->pt - ptTrue) / ptTrue;
2726  
2727    return PtRes;
2728 <  
2728 >
2729   }
2730  
2731  
2732 < double
2732 > double
2733   OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
2734    double value = -99;
2735    double genDeltaRLowest = 999;
# Line 2359 | Line 2738 | OSUAnalysis::getTrkPtTrue (const BNtrack
2738      double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
2739      if (genDeltaRtemp < genDeltaRLowest) {
2740        genDeltaRLowest = genDeltaRtemp;
2741 <      if (genDeltaRLowest < 0.05) {   // Only consider it truth-matched if DeltaR<0.15.  
2742 <        double ptTrue = genPart->pt;
2743 <        value = ptTrue;
2741 >      if (genDeltaRLowest < 0.05) {   // Only consider it truth-matched if DeltaR<0.15.
2742 >        double ptTrue = genPart->pt;
2743 >        value = ptTrue;
2744        }
2745 <    }
2745 >    }
2746    }
2747  
2748    return value;
2749  
2750   }
2751  
2752 + double
2753 + OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
2754 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
2755 +  if (!useTrackCaloRhoCorr_) return -99;  
2756 +  // if (!rhokt6CaloJetsHandle_) {
2757 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
2758 +  //   return -99;  
2759 +  // }
2760 +  double radDeltaRCone = 0.5;  
2761 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
2762 +  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
2763 +  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
2764 +  return caloTotRhoCorrCalo;  
2765 +
2766 + }
2767 +
2768 +
2769 +
2770 +
2771   //creates a map of the dead Ecal channels in the barrel and endcap
2772   //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2773   //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
2774 < void
2774 > void
2775   OSUAnalysis::WriteDeadEcal (){
2776    double etaEcal, phiEcal;
2777    ifstream DeadEcalFile(deadEcalFile_);
2778    if(!DeadEcalFile) {
2779      cout << "Error: DeadEcalFile has not been found." << endl;
2780 <    return;
2781 <  }
2782 <  if(DeadEcalVec.size()!= 0){
2780 >    return;
2781 >  }
2782 >  if(DeadEcalVec.size()!= 0){
2783      cout << "Error: DeadEcalVec has a nonzero size" << endl;
2784      return;
2785 <  }
2785 >  }
2786    while(!DeadEcalFile.eof())
2787      {
2788        DeadEcalFile >> etaEcal >> phiEcal;
# Line 2397 | Line 2795 | OSUAnalysis::WriteDeadEcal (){
2795   }
2796  
2797   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
2798 < int
2798 > int
2799   OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
2800    double deltaRLowest = 999;
2801    int value = 0;
# Line 2413 | Line 2811 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
2811    return value;
2812   }
2813  
2814 <
2815 <
2814 > // Returns the smallest DeltaR between the object and any generated true particle in the event.  
2815 > template <class InputObject>
2816 > double OSUAnalysis::getGenDeltaRLowest(InputObject object){
2817 >  double genDeltaRLowest = 999.;
2818 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2819 >    double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
2820 >    if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
2821 >  }
2822 >  return genDeltaRLowest;
2823 > }
2824  
2825   double
2826   OSUAnalysis::applyFunction(string function, double value){
# Line 2446 | Line 2852 | void OSUAnalysis::setObjectFlags(cut &cu
2852  
2853        vector<bool> subcutDecisions;
2854        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2855 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2856 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2855 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2856 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2857        }
2858        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2859        else{
2860 <        bool tempDecision = true;
2861 <        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2862 <          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2863 <            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2864 <          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2860 >        bool tempDecision = true;
2861 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2862 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2863 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2864 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2865              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2866 <        }
2867 <        decision = tempDecision;
2866 >        }
2867 >        decision = tempDecision;
2868        }
2869      }
2870      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
# Line 2480 | Line 2886 | void OSUAnalysis::setObjectFlags(cut &cu
2886  
2887   template <class InputCollection1, class InputCollection2>
2888   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2889 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2889 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2890  
2891  
2892    bool sameObjects = false;
2893    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2894  
2895  
2896 <  int counter = 0;  
2896 >  int counter = 0;
2897    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2898      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2899 <      
2899 >
2900        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2901  
2902  
2903        bool decision = true;//object passes if this cut doesn't cut on that type of object
2904  
2905        if(currentCut.inputCollection == inputType){
2500        
2501        vector<bool> subcutDecisions;
2502        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2503          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2504          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2505        }
2906  
2907 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2908 <        else{
2909 <          bool tempDecision = subcutDecisions.at(0);
2910 <          for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
2911 <            if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
2912 <              tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
2913 <            else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
2914 <              tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
2915 <          }
2916 <          decision = tempDecision;
2917 <        }
2907 >        vector<bool> subcutDecisions;
2908 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2909 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2910 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2911 >        }
2912 >
2913 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2914 >        else{
2915 >          bool tempDecision = subcutDecisions.at(0);
2916 >          for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
2917 >            if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
2918 >              tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
2919 >            else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
2920 >              tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
2921 >          }
2922 >          decision = tempDecision;
2923 >        }
2924        }
2925        individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2926 <      
2926 >
2927        //set flags for objects that pass each cut AND all the previous cuts
2928        bool previousCumulativeFlag = true;
2929        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2930 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2931 <        else{ previousCumulativeFlag = false; break;}
2930 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2931 >        else{ previousCumulativeFlag = false; break;}
2932        }
2933        //apply flags for the components of the composite object as well
2934        bool currentCumulativeFlag = true;
# Line 2532 | Line 2938 | void OSUAnalysis::setObjectFlags(cut &cu
2938        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2939        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2940  
2941 <      counter++;      
2941 >      counter++;
2942      }
2943 <    
2943 >
2944    }
2945  
2946  
# Line 2542 | Line 2948 | void OSUAnalysis::setObjectFlags(cut &cu
2948  
2949  
2950   template <class InputCollection>
2951 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2951 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2952  
2953    for (uint object = 0; object != inputCollection->size(); object++){
2954  
# Line 2552 | Line 2958 | void OSUAnalysis::fill1DHistogram(TH1* h
2958      string inputVariable = "";
2959      string function = "";
2960      if(currentString.find("(")==std::string::npos){
2961 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
2961 >      inputVariable = currentString;// variable to cut on
2962      }
2963      else{
2964 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2965 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2966 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2964 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2965 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2966 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2967      }
2968  
2969      double value = valueLookup(&inputCollection->at(object), inputVariable, function);
2970 <    histo->Fill(value,puScaleFactor);
2970 >    histo->Fill(value,scaleFactor);
2971  
2972 +    if (printEventInfo_) {
2973 +      // Write information about event to screen, for testing purposes.  
2974 +      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
2975 +    }
2976 +    
2977    }
2567
2978   }
2979  
2980   template <class InputCollection1, class InputCollection2>
2981 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
2981 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
2982  
2983    bool sameObjects = false;
2984    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2985  
2986 <  int pairCounter = 0;  
2986 >  int pairCounter = 0;
2987    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2988      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2989 <      
2989 >
2990        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2991  
2992        //only take objects which have passed all cuts and pairs which have passed all cuts
# Line 2588 | Line 2998 | void OSUAnalysis::fill1DHistogram(TH1* h
2998        string inputVariable = "";
2999        string function = "";
3000        if(currentString.find("(")==std::string::npos){
3001 <        inputVariable = currentString;// variable to cut on                                                                                                          
3001 >        inputVariable = currentString;// variable to cut on
3002        }
3003        else{
3004 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3005 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3006 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3004 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3005 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3006 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3007        }
3008 <      
3008 >
3009        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3010 <      histo->Fill(value,puScaleFactor);
3010 >      histo->Fill(value,scaleFactor);
3011  
3012 <      pairCounter++;      
3012 >      pairCounter++;
3013      }
3014    }
3015  
# Line 2607 | Line 3017 | void OSUAnalysis::fill1DHistogram(TH1* h
3017  
3018  
3019   template <class InputCollection>
3020 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
3020 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3021  
3022    for (uint object = 0; object != inputCollection->size(); object++){
3023  
# Line 2617 | Line 3027 | void OSUAnalysis::fill2DHistogram(TH2* h
3027      string inputVariable = "";
3028      string function = "";
3029      if(currentString.find("(")==std::string::npos){
3030 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
3030 >      inputVariable = currentString;// variable to cut on
3031      }
3032      else{
3033 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3034 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3035 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3033 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3034 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3035 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3036      }
3037      double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3038  
# Line 2630 | Line 3040 | void OSUAnalysis::fill2DHistogram(TH2* h
3040      inputVariable = "";
3041      function = "";
3042      if(currentString.find("(")==std::string::npos){
3043 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
3043 >      inputVariable = currentString;// variable to cut on
3044      }
3045      else{
3046 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3047 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3048 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3046 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3047 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3048 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3049      }
3050  
3051      double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3052  
3053 <    histo->Fill(valueX,valueY,puScaleFactor);
3053 >    histo->Fill(valueX,valueY,scaleFactor);
3054  
3055    }
3056  
3057   }
3058  
3059   template <class InputCollection1, class InputCollection2>
3060 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
3060 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3061  
3062    bool sameObjects = false;
3063    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3064  
3065 <  int pairCounter = 0;  
3065 >  int pairCounter = 0;
3066    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3067      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3068 <      
3068 >
3069        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3070  
3071        //only take objects which have passed all cuts and pairs which have passed all cuts
# Line 2667 | Line 3077 | void OSUAnalysis::fill2DHistogram(TH2* h
3077        string inputVariable = "";
3078        string function = "";
3079        if(currentString.find("(")==std::string::npos){
3080 <        inputVariable = currentString;// variable to cut on                                                                                                          
3080 >        inputVariable = currentString;// variable to cut on
3081        }
3082        else{
3083 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3084 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3085 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3083 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3084 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3085 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3086        }
3087        double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3088  
# Line 2680 | Line 3090 | void OSUAnalysis::fill2DHistogram(TH2* h
3090        inputVariable = "";
3091        function = "";
3092        if(currentString.find("(")==std::string::npos){
3093 <        inputVariable = currentString;// variable to cut on                                                                                                          
3093 >        inputVariable = currentString;// variable to cut on
3094        }
3095        else{
3096 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3097 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3098 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3096 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3097 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3098 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3099        }
3100        double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3101  
3102  
3103 <      histo->Fill(valueX,valueY,puScaleFactor);
3103 >      histo->Fill(valueX,valueY,scaleFactor);
3104  
3105 <      pairCounter++;      
3105 >      pairCounter++;
3106  
3107      }
3108    }
# Line 2710 | Line 3120 | int OSUAnalysis::getGenMatchedParticleIn
3120  
3121      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3122      if(currentDeltaR > 0.05) continue;
3123 < //     cout << std::setprecision(3) << std::setw(20)
3124 < //       << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3125 < //       << std::setw(20)
3126 < //       << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3127 < //       << std::setw(20)
3128 < //       << "\tdeltaR = " << currentDeltaR  
3129 < //       << std::setprecision(1)
3130 < //       << std::setw(20)
3131 < //       << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3132 < //       << std::setw(20)
3133 < //       << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3134 < //       << std::setw(20)
3135 < //       << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3123 >    //     cout << std::setprecision(3) << std::setw(20)
3124 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3125 >    //          << std::setw(20)
3126 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3127 >    //          << std::setw(20)
3128 >    //          << "\tdeltaR = " << currentDeltaR
3129 >    //          << std::setprecision(1)
3130 >    //          << std::setw(20)
3131 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3132 >    //          << std::setw(20)
3133 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3134 >    //          << std::setw(20)
3135 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3136      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3137        bestMatchIndex = mcparticle - mcparticles->begin();
3138        bestMatchDeltaR = currentDeltaR;
3139      }
3140  
3141    }
3142 < //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3143 < //   else cout << "no match found..." << endl;
3142 >  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3143 >  //   else cout << "no match found..." << endl;
3144    return bestMatchIndex;
3145  
3146   }
# Line 2789 | Line 3199 | int OSUAnalysis::findTauMotherIndex(cons
3199   int OSUAnalysis::getPdgIdBinValue(int pdgId){
3200  
3201    int binValue = -999;
3202 <  int absPdgId = fabs(pdgId);  
3202 >  int absPdgId = fabs(pdgId);
3203    if(pdgId == -1) binValue = 0;
3204    else if(absPdgId <= 6 ) binValue = absPdgId;
3205    else if(absPdgId == 11 ) binValue = 7;
# Line 2815 | Line 3225 | int OSUAnalysis::getPdgIdBinValue(int pd
3225  
3226   }
3227  
3228 + const BNprimaryvertex *
3229 + OSUAnalysis::chosenVertex ()
3230 + {
3231 +  const BNprimaryvertex *chosenVertex = 0;
3232 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3233 +    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3234 +      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3235 +    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3236 +      if(!vertexFlags.at(vertexIndex)) continue;
3237 +      chosenVertex = & primaryvertexs->at(vertexIndex);
3238 +      break;
3239 +    }
3240 +  }
3241 +  else {
3242 +    chosenVertex = &primaryvertexs->at(0);
3243 +  }
3244  
3245 < DEFINE_FWK_MODULE(OSUAnalysis);
3245 >  return chosenVertex;
3246 > }
3247  
3248 + const BNmet *
3249 + OSUAnalysis::chosenMET ()
3250 + {
3251 +  const BNmet *chosenMET = 0;
3252 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3253 +    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3254 +      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3255 +    for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3256 +      if(!metFlags.at(metIndex)) continue;
3257 +      chosenMET = & mets->at(metIndex);
3258 +      break;
3259 +    }
3260 +  }
3261 +  else {
3262 +    chosenMET = &mets->at(0);
3263 +  }
3264  
3265 +  return chosenMET;
3266 + }
3267 +
3268 + const BNelectron *
3269 + OSUAnalysis::chosenElectron ()
3270 + {
3271 +  const BNelectron *chosenElectron = 0;
3272 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3273 +    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3274 +      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3275 +    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3276 +      if(!electronFlags.at(electronIndex)) continue;
3277 +      chosenElectron = & electrons->at(electronIndex);
3278 +      break;
3279 +    }
3280 +  }
3281 +  else {
3282 +    chosenElectron = &electrons->at(0);
3283 +  }
3284 +
3285 +  return chosenElectron;
3286 + }
3287 +
3288 + const BNmuon *
3289 + OSUAnalysis::chosenMuon ()
3290 + {
3291 +  const BNmuon *chosenMuon = 0;
3292 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3293 +    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3294 +      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3295 +    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3296 +      if(!muonFlags.at(muonIndex)) continue;
3297 +      chosenMuon = & muons->at(muonIndex);
3298 +      break;
3299 +    }
3300 +  }
3301 +  else {
3302 +    chosenMuon = &muons->at(0);
3303 +  }
3304 +
3305 +  return chosenMuon;
3306 + }
3307 +
3308 +
3309 + DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines