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.26 by lantonel, Mon Mar 11 13:34:26 2013 UTC vs.
Revision 1.42 by wulsin, Wed Mar 27 22:38:08 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"))
29 >  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
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(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 38 | Line 49 | OSUAnalysis::OSUAnalysis (const edm::Par
49    std::vector<TFileDirectory> directories;
50  
51    //always get vertex collection so we can assign the primary vertex in the event
52 <  
53 < objectsToGet.push_back("primaryvertexs");
52 >  objectsToGet.push_back("primaryvertexs");
53 >
54    //always make the plot of number of primary verticex (to check pile-up reweighting)
55    objectsToPlot.push_back("primaryvertexs");
56  
# Line 54 | Line 65 | objectsToGet.push_back("primaryvertexs")
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 76 | Line 88 | objectsToGet.push_back("primaryvertexs")
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 85 | Line 97 | objectsToGet.push_back("primaryvertexs")
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 105 | Line 117 | objectsToGet.push_back("primaryvertexs")
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 132 | Line 148 | objectsToGet.push_back("primaryvertexs")
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  
143
165    channel tempChannel;
166    //loop over all channels (event selections)
167    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
# Line 177 | Line 198 | objectsToGet.push_back("primaryvertexs")
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 184 | Line 206 | objectsToGet.push_back("primaryvertexs")
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  
# Line 256 | Line 278 | objectsToGet.push_back("primaryvertexs")
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        }
293 +
294      }
295 <    //book a histogram for the number of each object type to be plotted
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 267 | Line 302 | objectsToGet.push_back("primaryvertexs")
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";
305 >      else if(currentObject == "electron-muon pairs")     currentObject = "electronMuonPairs";
306 >      else if(currentObject == "track-event pairs")       currentObject = "trackEventPairs";
307  
308        currentObject.at(0) = toupper(currentObject.at(0));
309        string histoName = "num" + currentObject;
310  
311        if(histoName == "numPrimaryvertexs"){
312 <        string newHistoName = histoName + "BeforePileupCorrection";
313 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);    
314 <        newHistoName = histoName + "AfterPileupCorrection";
315 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
312 >        string newHistoName = histoName + "BeforePileupCorrection";
313 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
314 >        newHistoName = histoName + "AfterPileupCorrection";
315 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
316        }
317        else
318 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
318 >        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
319      }
320  
321  
286    
322  
323  
324      //get list of cuts for this channel
# Line 295 | Line 330 | objectsToGet.push_back("primaryvertexs")
330        //store input collection for cut
331        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
332        tempCut.inputCollection = tempInputCollection;
333 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
334 <        objectsToGet.push_back(tempInputCollection);
335 <        objectsToCut.push_back(tempInputCollection);
333 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
334 >        objectsToGet.push_back(tempInputCollection);
335 >        objectsToCut.push_back(tempInputCollection);
336        }
337        else{//pair of objects, need to add them both to the things to objectsToGet
338 <        int dashIndex = tempInputCollection.find("-");
339 <        int spaceIndex = tempInputCollection.find(" ");
340 <        int secondWordLength = spaceIndex - dashIndex;
341 <        objectsToGet.push_back(tempInputCollection);
342 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
338 >        int dashIndex = tempInputCollection.find("-");
339 >        int spaceIndex = tempInputCollection.find(" ");
340 >        int secondWordLength = spaceIndex - dashIndex;
341 >        objectsToGet.push_back(tempInputCollection);
342 >        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
343          objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
344 <        objectsToCut.push_back(tempInputCollection);
345 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
344 >        objectsToCut.push_back(tempInputCollection);
345 >        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
346          objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
347  
348        }
# Line 318 | Line 353 | objectsToGet.push_back("primaryvertexs")
353        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
354        std::vector<string> cutStringVector = splitString(cutString);
355        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
356 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
357 <        exit(0);
356 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
357 >        exit(0);
358        }
359        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
360        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
361 <        int indexOffset = 4 * subcutIndex;
362 <        string currentVariableString = cutStringVector.at(indexOffset);
363 <        if(currentVariableString.find("(")==std::string::npos){
364 <          tempCut.functions.push_back("");//no function was specified
365 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
366 <        }
367 <        else{
368 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
369 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
370 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
371 <        }
372 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
373 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
374 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
361 >        int indexOffset = 4 * subcutIndex;
362 >        string currentVariableString = cutStringVector.at(indexOffset);
363 >        if(currentVariableString.find("(")==std::string::npos){
364 >          tempCut.functions.push_back("");//no function was specified
365 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
366 >        }
367 >        else{
368 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
369 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
370 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
371 >        }
372 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
373 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
374 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
375        }
376  
377        //get number of objects required to pass cut for event to pass
378        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
379        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
380        if(numberRequiredVector.size()!=2){
381 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
381 >        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
382          exit(0);
383        }
384  
# Line 445 | Line 480 | OSUAnalysis::analyze (const edm::Event &
480    if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
481      event.getByLabel (superclusters_, superclusters);
482  
483 <
484 <  //get pile-up event weight
485 <  double puScaleFactor = 1.00;
486 <  if(datasetType_ != "data"){
487 <    puScaleFactor = puWeight_->at (events->at (0).numTruePV);
488 <    //    cout << puScaleFactor << endl;
483 >  if (useTrackCaloRhoCorr_) {  
484 >    // Used only for pile-up correction of by-hand calculation of isolation energy.  
485 >    // This rho collection is not available in all BEANs.  
486 >    // For description of rho values for different jet reconstruction algorithms, see
487 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
488 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
489    }
490  
491  
492 +  //get pile-up event weight
493 +  double scaleFactor = 1.00;
494 +  if(doPileupReweighting_ && datasetType_ != "data")
495 +    scaleFactor = puWeight_->at (events->at (0).numTruePV);
496 +
497  
498    //loop over all channels
499  
# Line 461 | Line 501 | OSUAnalysis::analyze (const edm::Event &
501      channel currentChannel = channels.at(currentChannelIndex);
502  
503      flagMap individualFlags;
464    flagMap cumulativeFlags;
504      counterMap passingCounter;
505 +    cumulativeFlags.clear ();
506  
507      bool triggerDecision = true;
508      if(currentChannel.triggers.size() != 0){  //triggers specified
# Line 480 | Line 520 | OSUAnalysis::analyze (const edm::Event &
520        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
521          string currentObject = objectsToCut.at(currentObjectIndex);
522  
523 <        //initialize maps to get ready to set cuts
523 >        //initialize maps to get ready to set cuts
524          individualFlags[currentObject].push_back (vector<bool> ());
525          cumulativeFlags[currentObject].push_back (vector<bool> ());
526  
# Line 488 | Line 528 | OSUAnalysis::analyze (const edm::Event &
528        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
529          string currentObject = objectsToCut.at(currentObjectIndex);
530  
531 <        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
531 >        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
532 >
533  
534          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
535          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
# Line 504 | Line 545 | OSUAnalysis::analyze (const edm::Event &
545          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
546          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
547  
507        
508        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
509                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
510                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
511                                                                   "muon-muon pairs");
512        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
513                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
514                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
515                                                                           "electron-electron pairs");
516        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
517                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
518                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
519                                                                       "electron-muon pairs");
548  
549 +        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
550 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
551 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
552 +                                                                   "muon-muon pairs");
553 +        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
554 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
555 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
556 +                                                                           "electron-electron pairs");
557 +        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
558 +                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
559 +                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
560 +                                                                       "electron-muon pairs");
561 +        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
562 +                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
563 +                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
564 +                                                                     "track-event pairs");
565 +        
566  
567        }
568  
# Line 552 | Line 597 | OSUAnalysis::analyze (const edm::Event &
597  
598      }
599  
600 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor);
600 >    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
601  
602  
603  
604      if(!eventPassedAllCuts)continue;
605  
606 <
607 <    
608 <
609 <    //set position of primary vertex in event, in order to calculate quantities relative to it
610 <    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
611 <      vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
612 <      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
568 <        if(!vertexFlags.at(vertexIndex)) continue;
569 <        chosenPrimaryVertex = & primaryvertexs->at(vertexIndex);
570 <        break;
571 <      }
572 <    }
573 <    else {
574 <      chosenPrimaryVertex = & primaryvertexs->at(0);
606 >    if (printEventInfo_) {
607 >      // Write information about event to screen, for testing purposes.  
608 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
609 >           << ": run="  << events->at(0).run
610 >           << "  lumi=" << events->at(0).lumi
611 >           << "  event=" << events->at(0).evt
612 >           << endl;  
613      }
614  
615  
616 + //     if(datasetType_ != "data") {
617 + //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
618 + //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
619 + //     }
620  
621      //filling histograms
622      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
623        histogram currentHistogram = histograms.at(histogramIndex);
624  
625        if(currentHistogram.inputVariables.size() == 1){
626 <        TH1D* histo;
627 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
626 >        TH1D* histo;
627 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
628  
629  
630  
631 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
632 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
633 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\
634 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\
635 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
636 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
637 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
638 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
639 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
640 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
641 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
642 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
643 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
644 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
645 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
646 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
647 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
648 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
649 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
650 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
651 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
652 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
631 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
632 >         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
633 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
634 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
635 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
636 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
637 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
638 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
639 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
640 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
641 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
642 >                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
643 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
644 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
645 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
646 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
647 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
648 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
649 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
650 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
651 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
652 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
653        }
654        else if(currentHistogram.inputVariables.size() == 2){
655 <        TH2D* histo;
656 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
655 >        TH2D* histo;
656 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
657  
658  
659  
660 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
661 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
662 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
663 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
664 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
665 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
666 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
667 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
668 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
669 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
670 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
671 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
672 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
673 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
674 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
675 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
676 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
677 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
678 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
679 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
680 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
681 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
682 <      }
660 >        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
661 >        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
662 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
663 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
664 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
665 >        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
666 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
667 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
668 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
669 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
670 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
671 >                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
672 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
673 >        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
674 >        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
675 >        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
676 >        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
677 >                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
678 >                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
679 >        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
680 >        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
681 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
682 >        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
683 >        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
684 >        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
685 >      }
686      }
687  
688      //fills histograms with the sizes of collections
689      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
690 +
691        string currentObject = objectsToPlot.at(currentObjectIndex);
692  
693 <      string objectToPlot = "";
693 >      string objectToPlot = "";  
694  
695 +      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
696        if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
697        else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
698 <      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
698 >      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
699 >      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
700        else objectToPlot = currentObject;
701        string tempCurrentObject = objectToPlot;
702 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
702 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  // Capitalize the first letter.  
703        string histoName = "num" + tempCurrentObject;
704  
705  
658
659
706        //set position of primary vertex in event, in order to calculate quantities relative to it
707        if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
708 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
709 <        int numToPlot = 0;
710 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
711 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
712 <        }
713 <        if(objectToPlot == "primaryvertexs"){
714 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
715 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
708 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
709 >        int numToPlot = 0;
710 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
711 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
712 >        }
713 >        if(objectToPlot == "primaryvertexs"){
714 >          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
715 >          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
716 >        }
717 >        else {
718 >          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
719          }
671        else
672          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,puScaleFactor);        
673      }
674      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
675      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
676      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
677      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
678      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
679      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
680      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
681      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
682      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
683      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
684      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
685      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
686      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
687      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
688      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
689      else if(objectToPlot == "primaryvertexs"){
690        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
691        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
720        }
721 +      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
722 +      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
723 +      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
724 +      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
725 +      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
726 +      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
727 +      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
728 +      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
729 +      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
730 +      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
731 +      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
732 +      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
733 +      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
734 +      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
735 +      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
736 +      else if(objectToPlot == "primaryvertexs"){
737 +        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
738 +        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
739 +      }
740  
741 <    }
695 <
696 <
697 <
741 >    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
742  
743    } //end loop over channel
744  
745 <  masterCutFlow_->fillCutFlow(puScaleFactor);
745 >  masterCutFlow_->fillCutFlow(scaleFactor);
746  
747 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
748  
749  
705 }
706
750  
751   bool
752   OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
# Line 1036 | Line 1079 | OSUAnalysis::valueLookup (const BNmuon*
1079    else if(variable == "time_ndof") value = object->time_ndof;
1080  
1081    //user-defined variables
1082 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1083 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1082 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1083 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1084    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1085 <  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1085 >  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1086    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1087 +  else if(variable == "metMT") {
1088 +    const BNmet *met = chosenMET ();
1089 +    if (met)
1090 +      {
1091 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1092 +                       p2 (met->px, met->py, 0.0, met->pt);
1093 +
1094 +        value = (p1 + p2).Mt ();
1095 +      }
1096 +    else
1097 +      value = -999;
1098 +  }
1099  
1100  
1101  
# Line 1151 | Line 1206 | OSUAnalysis::valueLookup (const BNmuon*
1206  
1207  
1208    else if(variable == "tightID") {
1209 <    value = object->isGlobalMuon > 0            \
1210 <      && object->isPFMuon > 0                   \
1211 <      && object->normalizedChi2 < 10            \
1212 <      && object->numberOfValidMuonHits > 0      \
1213 <      && object->numberOfMatchedStations > 1    \
1214 <      && fabs(object->correctedD0Vertex) < 0.2  \
1215 <      && fabs(object->correctedDZ) < 0.5        \
1216 <      && object->numberOfValidPixelHits > 0             \
1209 >    value = object->isGlobalMuon > 0                \
1210 >      && object->isPFMuon > 0                        \
1211 >      && object->normalizedChi2 < 10                \
1212 >      && object->numberOfValidMuonHits > 0        \
1213 >      && object->numberOfMatchedStations > 1        \
1214 >      && fabs(object->correctedD0Vertex) < 0.2        \
1215 >      && fabs(object->correctedDZ) < 0.5        \
1216 >      && object->numberOfValidPixelHits > 0                \
1217        && object->numberOfLayersWithMeasurement > 5;
1218    }
1219    else if(variable == "tightIDdisplaced"){
1220 <    value = object->isGlobalMuon > 0            \
1221 <      && object->normalizedChi2 < 10            \
1222 <      && object->numberOfValidMuonHits > 0      \
1223 <      && object->numberOfMatchedStations > 1    \
1224 <      && object->numberOfValidPixelHits > 0     \
1220 >    value = object->isGlobalMuon > 0                \
1221 >      && object->normalizedChi2 < 10                \
1222 >      && object->numberOfValidMuonHits > 0        \
1223 >      && object->numberOfMatchedStations > 1        \
1224 >      && object->numberOfValidPixelHits > 0        \
1225        && object->numberOfLayersWithMeasurement > 5;
1226    }
1227  
1228 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1229  
1230 +  else if(variable == "genMatchedPdgId"){
1231 +    int index = getGenMatchedParticleIndex(object);
1232 +    if(index == -1) value = 0;
1233 +    else value = mcparticles->at(index).id;
1234 +  }
1235  
1236    else if(variable == "genMatchedId"){
1237      int index = getGenMatchedParticleIndex(object);
# Line 1182 | Line 1243 | OSUAnalysis::valueLookup (const BNmuon*
1243      if(index == -1) value = 0;
1244      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1245    }
1246 +  else if(variable == "genMatchedMotherIdReverse"){
1247 +    int index = getGenMatchedParticleIndex(object);
1248 +    if(index == -1) value = 23;
1249 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1250 +  }
1251    else if(variable == "genMatchedGrandmotherId"){
1252      int index = getGenMatchedParticleIndex(object);
1253      if(index == -1) value = 0;
# Line 1365 | Line 1431 | OSUAnalysis::valueLookup (const BNelectr
1431    else if(variable == "passConvVeto") value = object->passConvVeto;
1432  
1433    //user-defined variables
1434 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1435 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1434 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1435 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1436    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1437    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1438 +  else if(variable == "metMT") {
1439 +    const BNmet *met = chosenMET ();
1440 +    if (met)
1441 +      {
1442 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1443 +                       p2 (met->px, met->py, 0.0, met->pt);
1444  
1445 +        value = (p1 + p2).Mt ();
1446 +      }
1447 +    else
1448 +      value = -999;
1449 +  }
1450  
1451    else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1452      if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
# Line 1380 | Line 1457 | OSUAnalysis::valueLookup (const BNelectr
1457      else value = -999;
1458    }
1459  
1383
1460    else if(variable == "correctedD0VertexInEBPlus"){
1461      if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1462      else value = -999;
# Line 1433 | Line 1509 | OSUAnalysis::valueLookup (const BNelectr
1509      else value = -999;
1510    }
1511  
1512 +  else if(variable == "tightID"){
1513 +    if (object->isEB)
1514 +      {
1515 +        value = fabs(object->delEtaIn) < 0.004 \
1516 +          && fabs (object->delPhiIn) < 0.03 \
1517 +          && object->scSigmaIEtaIEta < 0.01 \
1518 +          && object->hadOverEm < 0.12 \
1519 +          && fabs (object->correctedD0Vertex) < 0.02 \
1520 +          && fabs (object->correctedDZ) < 0.1 \
1521 +          && object->absInvEMinusInvPin < 0.05 \
1522 +          && object->passConvVeto;
1523 +      }
1524 +    else
1525 +      {
1526 +        value = fabs(object->delEtaIn) < 0.005 \
1527 +          && fabs (object->delPhiIn) < 0.02 \
1528 +          && object->scSigmaIEtaIEta < 0.03 \
1529 +          && object->hadOverEm < 0.10 \
1530 +          && fabs (object->correctedD0Vertex) < 0.02 \
1531 +          && fabs (object->correctedDZ) < 0.1 \
1532 +          && object->absInvEMinusInvPin < 0.05 \
1533 +          && object->passConvVeto;
1534 +      }
1535 +  }
1536  
1537    else if(variable == "correctedD0VertexInEBPositiveCharge"){
1538      if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
# Line 1490 | Line 1590 | OSUAnalysis::valueLookup (const BNelectr
1590    else if(variable == "tightIDdisplaced"){
1591      if (object->isEB)
1592        {
1593 <        value = fabs(object->delEtaIn) < 0.004 \
1594 <          && fabs (object->delPhiIn) < 0.03 \
1593 >        value = fabs(object->delEtaIn) < 0.004 \
1594 >          && fabs (object->delPhiIn) < 0.03 \
1595            && object->scSigmaIEtaIEta < 0.01 \
1596            && object->hadOverEm < 0.12 \
1597 <          && object->absInvEMinusInvPin < 0.05;
1597 >          && object->absInvEMinusInvPin < 0.05;
1598        }
1599      else
1600        {
1601 <        value = fabs (object->delEtaIn) < 0.005 \
1602 <          && fabs (object->delPhiIn) < 0.02 \
1601 >        value = fabs (object->delEtaIn) < 0.005 \
1602 >          && fabs (object->delPhiIn) < 0.02 \
1603            && object->scSigmaIEtaIEta < 0.03 \
1604            && object->hadOverEm < 0.10 \
1605 <          && object->absInvEMinusInvPin < 0.05;
1605 >          && object->absInvEMinusInvPin < 0.05;
1606        }
1607    }
1608  
1609 +
1610 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1611 +
1612 +  else if(variable == "genMatchedPdgId"){
1613 +    int index = getGenMatchedParticleIndex(object);
1614 +    if(index == -1) value = 0;
1615 +    else value = mcparticles->at(index).id;
1616 +  }
1617 +
1618 +
1619    else if(variable == "genMatchedId"){
1620      int index = getGenMatchedParticleIndex(object);
1621      if(index == -1) value = 0;
# Line 1516 | Line 1626 | OSUAnalysis::valueLookup (const BNelectr
1626      if(index == -1) value = 0;
1627      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1628    }
1629 +  else if(variable == "genMatchedMotherIdReverse"){
1630 +    int index = getGenMatchedParticleIndex(object);
1631 +    if(index == -1) value = 23;
1632 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1633 +  }
1634    else if(variable == "genMatchedGrandmotherId"){
1635      int index = getGenMatchedParticleIndex(object);
1636      if(index == -1) value = 0;
# Line 1606 | Line 1721 | OSUAnalysis::valueLookup (const BNevent*
1721    else if(variable == "id1") value = object->id1;
1722    else if(variable == "id2") value = object->id2;
1723    else if(variable == "evt") value = object->evt;
1724 +  else if(variable == "puScaleFactor"){
1725 +    if(datasetType_ != "data")
1726 +      value = puWeight_->at (events->at (0).numTruePV);
1727 +    else
1728 +      value = 1.0;
1729 +  }
1730 +  else if(variable == "muonScaleFactor"){
1731 +    if(datasetType_ != "data")
1732 +      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1733 +    value = 1.0;
1734 +    else
1735 +      value = 1.0;
1736 +  }
1737 +  else if(variable == "electronScaleFactor"){
1738 +    if(datasetType_ != "data")
1739 +      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1740 +    value = 1.0;
1741 +    else
1742 +      value = 1.0;
1743 +  }
1744  
1745    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1746  
# Line 1660 | Line 1795 | OSUAnalysis::valueLookup (const BNtau* o
1795    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1796  
1797  
1798 +
1799 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1800 +
1801 +  else if(variable == "genMatchedPdgId"){
1802 +    int index = getGenMatchedParticleIndex(object);
1803 +    if(index == -1) value = 0;
1804 +    else value = mcparticles->at(index).id;
1805 +  }
1806 +
1807    else if(variable == "genMatchedId"){
1808      int index = getGenMatchedParticleIndex(object);
1809      if(index == -1) value = 0;
# Line 1670 | Line 1814 | OSUAnalysis::valueLookup (const BNtau* o
1814      if(index == -1) value = 0;
1815      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1816    }
1817 +  else if(variable == "genMatchedMotherIdReverse"){
1818 +    int index = getGenMatchedParticleIndex(object);
1819 +    if(index == -1) value = 23;
1820 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1821 +  }
1822    else if(variable == "genMatchedGrandmotherId"){
1823      int index = getGenMatchedParticleIndex(object);
1824      if(index == -1) value = 0;
# Line 1766 | Line 1915 | OSUAnalysis::valueLookup (const BNtrack*
1915  
1916    double value = 0.0;
1917    double pMag = sqrt(object->pt * object->pt +
1918 <                         object->pz * object->pz);
1918 >                     object->pz * object->pz);
1919    
1920    if(variable == "pt") value = object->pt;
1921    else if(variable == "px") value = object->px;
# Line 1785 | Line 1934 | OSUAnalysis::valueLookup (const BNtrack*
1934    else if(variable == "charge") value = object->charge;
1935    else if(variable == "numValidHits") value = object->numValidHits;
1936    else if(variable == "isHighPurity") value = object->isHighPurity;
1937 <  //additional BNs info for disappTrks  
1937 >
1938 >
1939 >  //additional BNs info for disappTrks
1940    else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
1941    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
1942    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
# Line 1796 | Line 1947 | OSUAnalysis::valueLookup (const BNtrack*
1947    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
1948    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
1949    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
1950 +  
1951 +
1952    //user defined variables
1953    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;
1954    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
1955 <  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
1956 <  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
1957 <  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
1958 <  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
1955 >  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
1956 >  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
1957 >  else if(variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object);  
1958 >  else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;  
1959 >  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
1960 >  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
1961 >  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
1962 >  else if(variable == "ptError")                    value = object->ptError;
1963 >  else if(variable == "ptRes")                      value = getTrkPtRes(object);
1964 >
1965 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1966 >
1967 >  else if(variable == "genMatchedPdgId"){
1968 >    int index = getGenMatchedParticleIndex(object);
1969 >    if(index == -1) value = 0;
1970 >    else value = mcparticles->at(index).id;
1971 >  }
1972  
1973  
1974    else if(variable == "genMatchedId"){
# Line 1815 | Line 1981 | OSUAnalysis::valueLookup (const BNtrack*
1981      if(index == -1) value = 0;
1982      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1983    }
1984 +  else if(variable == "genMatchedMotherIdReverse"){
1985 +    int index = getGenMatchedParticleIndex(object);
1986 +    if(index == -1) value = 23;
1987 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1988 +  }
1989    else if(variable == "genMatchedGrandmotherId"){
1990      int index = getGenMatchedParticleIndex(object);
1991      if(index == -1) value = 0;
# Line 1955 | Line 2126 | OSUAnalysis::valueLookup (const BNmcpart
2126  
2127    //user-defined variables
2128    else if (variable == "d0"){
2129 <    double vx = object->vx - chosenPrimaryVertex->x,
2130 <      vy = object->vy - chosenPrimaryVertex->y,
2129 >    double vx = object->vx - chosenVertex ()->x,
2130 >      vy = object->vy - chosenVertex ()->y,
2131        px = object->px,
2132        py = object->py,
2133        pt = object->pt;
2134      value = (-vx * py + vy * px) / pt;
2135    }
2136    else if (variable == "dz"){
2137 <    double vx = object->vx - chosenPrimaryVertex->x,
2138 <      vy = object->vy - chosenPrimaryVertex->y,
2139 <      vz = object->vz - chosenPrimaryVertex->z,
2137 >    double vx = object->vx - chosenVertex ()->x,
2138 >      vy = object->vy - chosenVertex ()->y,
2139 >      vz = object->vz - chosenVertex ()->z,
2140        px = object->px,
2141        py = object->py,
2142        pz = object->pz,
# Line 1976 | Line 2147 | OSUAnalysis::valueLookup (const BNmcpart
2147      value = sqrt(object->vx*object->vx + object->vy*object->vy);
2148    }
2149    else if(variable == "deltaV0"){
2150 <    value = sqrt((object->vx-chosenPrimaryVertex->x)*(object->vx-chosenPrimaryVertex->x) + (object->vy-chosenPrimaryVertex->y)*(object->vy-chosenPrimaryVertex->y));
2150 >    value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2151    }
2152    else if (variable == "deltaVx"){
2153 <    value = object->vx - chosenPrimaryVertex->x;
2153 >    value = object->vx - chosenVertex ()->x;
2154    }
2155    else if (variable == "deltaVy"){
2156 <    value = object->vy - chosenPrimaryVertex->y;
2156 >    value = object->vy - chosenVertex ()->y;
2157    }
2158    else if (variable == "deltaVz"){
2159 <    value = object->vz - chosenPrimaryVertex->z;
2159 >    value = object->vz - chosenVertex ()->z;
2160    }
2161  
2162  
# Line 2116 | Line 2287 | OSUAnalysis::valueLookup (const BNphoton
2287    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2288  
2289  
2290 +
2291 +
2292 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2293 +
2294 +  else if(variable == "genMatchedPdgId"){
2295 +    int index = getGenMatchedParticleIndex(object);
2296 +    if(index == -1) value = 0;
2297 +    else value = mcparticles->at(index).id;
2298 +  }
2299 +
2300 +
2301 +
2302    else if(variable == "genMatchedId"){
2303      int index = getGenMatchedParticleIndex(object);
2304      if(index == -1) value = 0;
# Line 2126 | Line 2309 | OSUAnalysis::valueLookup (const BNphoton
2309      if(index == -1) value = 0;
2310      else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2311    }
2312 +  else if(variable == "genMatchedMotherIdReverse"){
2313 +    int index = getGenMatchedParticleIndex(object);
2314 +    if(index == -1) value = 23;
2315 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2316 +  }
2317    else if(variable == "genMatchedGrandmotherId"){
2318      int index = getGenMatchedParticleIndex(object);
2319      if(index == -1) value = 0;
# Line 2178 | Line 2366 | OSUAnalysis::valueLookup (const BNmuon*
2366    else if(variable == "invMass"){
2367      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2368      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2369 <
2370 <    value = (fourVector1 + fourVector2).M();}
2369 >    value = (fourVector1 + fourVector2).M();
2370 >  }
2371 >  else if(variable == "pt"){
2372 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2373 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2374 >    value = (fourVector1 + fourVector2).Pt();
2375 >  }
2376    else if(variable == "threeDAngle")
2377      {
2378        TVector3 threeVector1(object1->px, object1->py, object1->pz);
2379        TVector3 threeVector2(object2->px, object2->py, object2->pz);
2380        value = (threeVector1.Angle(threeVector2));
2381      }
2382 <
2383 <
2384 <
2382 >  else if(variable == "alpha")
2383 >    {
2384 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
2385 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2386 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2387 >      value = (pi-threeVector1.Angle(threeVector2));
2388 >    }
2389    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2390    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2391    else if(variable == "d0Sign"){
# Line 2197 | Line 2394 | OSUAnalysis::valueLookup (const BNmuon*
2394      else if (d0Sign > 0) value = 0.5;
2395      else value = -999;
2396    }
2397 +  else if(variable == "chargeProduct"){
2398 +    value = object1->charge*object2->charge;
2399 +  }
2400    else if(variable == "muon1CorrectedD0Vertex"){
2401      value = object1->correctedD0Vertex;
2402    }
2403    else if(variable == "muon2CorrectedD0Vertex"){
2404      value = object2->correctedD0Vertex;
2405    }
2406 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2407 <
2408 <
2409 <
2410 <
2411 <
2412 <
2406 > else if(variable == "muon1timeAtIpInOut"){
2407 >    value = object1->timeAtIpInOut;
2408 >  }
2409 > else if(variable == "muon2timeAtIpInOut"){
2410 >    value = object2->timeAtIpInOut;
2411 >  }
2412 > else if(variable == "muon1correctedD0")
2413 >   {
2414 >     value = object1->correctedD0;
2415 >   }
2416 > else if(variable == "muon2correctedD0")
2417 >   {
2418 >     value = object2->correctedD0;
2419 >   }
2420  
2421 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2422  
2423    value = applyFunction(function, value);
2424  
# Line 2227 | Line 2435 | OSUAnalysis::valueLookup (const BNelectr
2435    else if(variable == "invMass"){
2436      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2437      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2438 <
2439 <    value = (fourVector1 + fourVector2).M();}
2440 < else if(variable == "threeDAngle")
2438 >    value = (fourVector1 + fourVector2).M();
2439 >  }
2440 >  else if(variable == "pt"){
2441 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2442 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2443 >    value = (fourVector1 + fourVector2).Pt();
2444 >  }
2445 >  else if(variable == "threeDAngle")
2446      {
2447        TVector3 threeVector1(object1->px, object1->py, object1->pz);
2448        TVector3 threeVector2(object2->px, object2->py, object2->pz);
2449        value = (threeVector1.Angle(threeVector2));
2450      }
2238  
2239
2240
2241
2451    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2452    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2244
2245  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2246
2247
2248
2453    else if(variable == "d0Sign"){
2454      double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2455      if(d0Sign < 0) value = -0.5;
2456      else if (d0Sign > 0) value = 0.5;
2457      else value = -999;
2458    }
2459 +  else if(variable == "chargeProduct"){
2460 +    value = object1->charge*object2->charge;
2461 +  }
2462    else if(variable == "electron1CorrectedD0Vertex"){
2463      value = object1->correctedD0Vertex;
2464    }
2465    else if(variable == "electron2CorrectedD0Vertex"){
2466      value = object2->correctedD0Vertex;
2467    }
2468 +  else if(variable == "electron1CorrectedD0"){
2469 +    value = object1->correctedD0;
2470 +  }
2471 +  else if(variable == "electron2CorrectedD0"){
2472 +    value = object2->correctedD0;
2473 +  }
2474  
2475    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2476  
# Line 2276 | Line 2489 | OSUAnalysis::valueLookup (const BNelectr
2489    else if(variable == "invMass"){
2490      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2491      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2492 <
2493 <    value = (fourVector1 + fourVector2).M();}
2494 < else if(variable == "threeDAngle")
2492 >    value = (fourVector1 + fourVector2).M();
2493 >  }
2494 >  else if(variable == "pt"){
2495 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2496 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2497 >    value = (fourVector1 + fourVector2).Pt();
2498 >  }
2499 >  else if(variable == "threeDAngle")
2500      {
2501        TVector3 threeVector1(object1->px, object1->py, object1->pz);
2502        TVector3 threeVector2(object2->px, object2->py, object2->pz);
2503        value = (threeVector1.Angle(threeVector2));
2504      }
2287
2288
2505    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2506    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2507    else if(variable == "d0Sign"){
# Line 2294 | Line 2510 | OSUAnalysis::valueLookup (const BNelectr
2510      else if (d0Sign > 0) value = 0.5;
2511      else value = -999;
2512    }
2513 +  else if(variable == "chargeProduct"){
2514 +    value = object1->charge*object2->charge;
2515 +  }
2516    else if(variable == "electronCorrectedD0Vertex"){
2517      value = object1->correctedD0Vertex;
2518    }
# Line 2306 | Line 2525 | OSUAnalysis::valueLookup (const BNelectr
2525    else if(variable == "muonCorrectedD0"){
2526      value = object2->correctedD0;
2527    }
2528 +  else if(variable == "electronDetIso"){
2529 +    value = (object1->trackIso) / object1->pt;
2530 +  }
2531 +  else if(variable == "muonDetIso"){
2532 +    value = (object2->trackIsoDR03) / object2->pt;
2533 +  }
2534  
2535  
2536    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 2316 | Line 2541 | OSUAnalysis::valueLookup (const BNelectr
2541   }
2542  
2543  
2544 < // Calculate the number of tracks in cone of DeltaR<0.5 around track1.  
2545 < // Return true iff no other tracks are found in this cone.  
2546 < int
2544 >
2545 >
2546 > double
2547 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
2548 >
2549 >  double value = 0.0;
2550 >  double pMag = sqrt(object1->pt * object1->pt +
2551 >                     object1->pz * object1->pz);  
2552 >
2553 >  if      (variable == "numPV")                      value = object2->numPV;
2554 >  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
2555 >  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
2556 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
2557 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
2558 >
2559 >  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
2560 >
2561 >  value = applyFunction(function, value);
2562 >
2563 >  return value;
2564 >
2565 > }  
2566 >
2567 > // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2568 > // Return true iff no other tracks are found in this cone.
2569 > int
2570   OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
2571    for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
2572 <    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.  
2573 <    double deltaRtrk = deltaR(track1->eta, track2->eta, track1->phi, track2->phi);
2572 >    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
2573 >    double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
2574      if(deltaRtrk < 0.5) return 0;
2575    }
2576    return 1;
2577 <  
2577 >
2578   }
2579 <  
2579 >
2580 >
2581 > double
2582 > OSUAnalysis::getTrkPtRes (const BNtrack* track1){
2583 >
2584 >  double ptTrue = getTrkPtTrue(track1, mcparticles.product());
2585 >  double PtRes = (track1->pt - ptTrue) / ptTrue;
2586 >
2587 >  return PtRes;
2588 >
2589 > }
2590 >
2591 >
2592 > double
2593 > OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
2594 >  double value = -99;
2595 >  double genDeltaRLowest = 999;
2596 >
2597 >  for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){
2598 >    double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
2599 >    if (genDeltaRtemp < genDeltaRLowest) {
2600 >      genDeltaRLowest = genDeltaRtemp;
2601 >      if (genDeltaRLowest < 0.05) {   // Only consider it truth-matched if DeltaR<0.15.
2602 >        double ptTrue = genPart->pt;
2603 >        value = ptTrue;
2604 >      }
2605 >    }
2606 >  }
2607 >
2608 >  return value;
2609 >
2610 > }
2611 >
2612 > double
2613 > OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
2614 >  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
2615 >  if (!useTrackCaloRhoCorr_) return -99;  
2616 >  // if (!rhokt6CaloJetsHandle_) {
2617 >  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
2618 >  //   return -99;  
2619 >  // }
2620 >  double radDeltaRCone = 0.5;  
2621 >  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
2622 >  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
2623 >  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
2624 >  return caloTotRhoCorrCalo;  
2625 >
2626 > }
2627 >
2628 >
2629 >
2630 >
2631   //creates a map of the dead Ecal channels in the barrel and endcap
2632   //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2633   //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
2634 < void
2634 > void
2635   OSUAnalysis::WriteDeadEcal (){
2636    double etaEcal, phiEcal;
2637    ifstream DeadEcalFile(deadEcalFile_);
2638    if(!DeadEcalFile) {
2639      cout << "Error: DeadEcalFile has not been found." << endl;
2640 <    return;
2641 <  }
2642 <  if(DeadEcalVec.size()!= 0){
2640 >    return;
2641 >  }
2642 >  if(DeadEcalVec.size()!= 0){
2643      cout << "Error: DeadEcalVec has a nonzero size" << endl;
2644      return;
2645 <  }
2645 >  }
2646    while(!DeadEcalFile.eof())
2647      {
2648        DeadEcalFile >> etaEcal >> phiEcal;
# Line 2356 | Line 2655 | OSUAnalysis::WriteDeadEcal (){
2655   }
2656  
2657   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
2658 < int
2658 > int
2659   OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
2660 +  double deltaRLowest = 999;
2661    int value = 0;
2662    if (DeadEcalVec.size() == 0) WriteDeadEcal();
2663    for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
2664      double eta = ecal->etaEcal;
2665      double phi = ecal->phiEcal;
2666 <    if (deltaR(eta, track1->eta, phi, track1->phi)<0.05) {value = 1;}
2667 <    else {value = 0;}
2666 >    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
2667 >    if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
2668    }
2669 +  if (deltaRLowest<0.05) {value = 1;}
2670 +  else {value = 0;}
2671    return value;
2672   }
2673  
2674 <
2675 <
2674 > // Returns the smallest DeltaR between the object and any generated true particle in the event.  
2675 > template <class InputObject>
2676 > double OSUAnalysis::getGenDeltaRLowest(InputObject object){
2677 >  double genDeltaRLowest = 999.;
2678 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2679 >    double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
2680 >    if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
2681 > }
2682 >  return genDeltaRLowest;
2683 > }
2684  
2685   double
2686   OSUAnalysis::applyFunction(string function, double value){
2687  
2688    if(function == "abs") value = fabs(value);
2689    else if(function == "fabs") value = fabs(value);
2690 <
2690 >  else if(function == "log10") value = log10(value);
2691 >  else if(function == "log") value = log10(value);
2692  
2693    else if(function == "") value = value;
2694    else{std::cout << "WARNING: invalid function '" << function << "'\n";}
# Line 2401 | Line 2712 | void OSUAnalysis::setObjectFlags(cut &cu
2712  
2713        vector<bool> subcutDecisions;
2714        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2715 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2716 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2715 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2716 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2717        }
2718        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2719        else{
2720 <        bool tempDecision = true;
2721 <        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2722 <          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2723 <            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2724 <          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2720 >        bool tempDecision = true;
2721 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2722 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2723 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2724 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2725              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2726 <        }
2727 <        decision = tempDecision;
2726 >        }
2727 >        decision = tempDecision;
2728        }
2729      }
2730      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
# Line 2435 | Line 2746 | void OSUAnalysis::setObjectFlags(cut &cu
2746  
2747   template <class InputCollection1, class InputCollection2>
2748   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2749 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2749 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2750  
2751  
2752    bool sameObjects = false;
2753    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2754  
2755  
2756 <  int counter = 0;  
2756 >  int counter = 0;
2757    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2758      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2759 <      
2759 >
2760        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2761  
2762  
# Line 2453 | Line 2764 | void OSUAnalysis::setObjectFlags(cut &cu
2764  
2765        if(currentCut.inputCollection == inputType){
2766  
2767 <        vector<bool> subcutDecisions;
2768 <        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2769 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2770 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2771 <        }
2767 >        vector<bool> subcutDecisions;
2768 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2769 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2770 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2771 >        }
2772  
2773 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2774 <        else{
2775 <          bool tempDecision = true;
2776 <          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2777 <            if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2778 <              tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2779 <            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2780 <              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2781 <          }
2782 <          decision = tempDecision;
2783 <        }
2773 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2774 >        else{
2775 >          bool tempDecision = subcutDecisions.at(0);
2776 >          for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
2777 >            if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
2778 >              tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
2779 >            else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
2780 >              tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
2781 >          }
2782 >          decision = tempDecision;
2783 >        }
2784        }
2785        individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2786 <      
2786 >
2787        //set flags for objects that pass each cut AND all the previous cuts
2788        bool previousCumulativeFlag = true;
2789        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2790 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2791 <        else{ previousCumulativeFlag = false; break;}
2790 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2791 >        else{ previousCumulativeFlag = false; break;}
2792        }
2793        //apply flags for the components of the composite object as well
2794        bool currentCumulativeFlag = true;
# Line 2487 | Line 2798 | void OSUAnalysis::setObjectFlags(cut &cu
2798        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2799        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2800  
2801 <      counter++;      
2801 >      counter++;
2802      }
2803 <    
2803 >
2804    }
2805  
2806  
# Line 2497 | Line 2808 | void OSUAnalysis::setObjectFlags(cut &cu
2808  
2809  
2810   template <class InputCollection>
2811 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2811 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2812  
2813    for (uint object = 0; object != inputCollection->size(); object++){
2814  
# Line 2507 | Line 2818 | void OSUAnalysis::fill1DHistogram(TH1* h
2818      string inputVariable = "";
2819      string function = "";
2820      if(currentString.find("(")==std::string::npos){
2821 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
2821 >      inputVariable = currentString;// variable to cut on
2822      }
2823      else{
2824 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2825 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2826 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2824 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2825 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2826 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2827      }
2828  
2829      double value = valueLookup(&inputCollection->at(object), inputVariable, function);
2830 <    histo->Fill(value,puScaleFactor);
2830 >    histo->Fill(value,scaleFactor);
2831  
2832 +    if (printEventInfo_) {
2833 +      // Write information about event to screen, for testing purposes.  
2834 +      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
2835 +    }
2836 +    
2837    }
2522
2838   }
2839  
2840   template <class InputCollection1, class InputCollection2>
2841 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
2841 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
2842  
2843    bool sameObjects = false;
2844    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2845  
2846 <  int pairCounter = 0;  
2846 >  int pairCounter = 0;
2847    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2848      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2849 <      
2849 >
2850        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2851  
2852        //only take objects which have passed all cuts and pairs which have passed all cuts
# Line 2543 | Line 2858 | void OSUAnalysis::fill1DHistogram(TH1* h
2858        string inputVariable = "";
2859        string function = "";
2860        if(currentString.find("(")==std::string::npos){
2861 <        inputVariable = currentString;// variable to cut on                                                                                                          
2861 >        inputVariable = currentString;// variable to cut on
2862        }
2863        else{
2864 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2865 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2866 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2864 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2865 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2866 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2867        }
2868 <      
2868 >
2869        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2870 <      histo->Fill(value,puScaleFactor);
2870 >      histo->Fill(value,scaleFactor);
2871  
2872 <      pairCounter++;      
2872 >      pairCounter++;
2873      }
2874    }
2875  
# Line 2562 | Line 2877 | void OSUAnalysis::fill1DHistogram(TH1* h
2877  
2878  
2879   template <class InputCollection>
2880 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2880 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2881  
2882    for (uint object = 0; object != inputCollection->size(); object++){
2883  
# Line 2572 | Line 2887 | void OSUAnalysis::fill2DHistogram(TH2* h
2887      string inputVariable = "";
2888      string function = "";
2889      if(currentString.find("(")==std::string::npos){
2890 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
2890 >      inputVariable = currentString;// variable to cut on
2891      }
2892      else{
2893 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2894 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2895 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2893 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2894 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2895 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2896      }
2897      double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
2898  
# Line 2585 | Line 2900 | void OSUAnalysis::fill2DHistogram(TH2* h
2900      inputVariable = "";
2901      function = "";
2902      if(currentString.find("(")==std::string::npos){
2903 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
2903 >      inputVariable = currentString;// variable to cut on
2904      }
2905      else{
2906 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2907 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2908 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2906 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2907 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2908 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2909      }
2910  
2911      double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
2912  
2913 <    histo->Fill(valueX,valueY,puScaleFactor);
2913 >    histo->Fill(valueX,valueY,scaleFactor);
2914  
2915    }
2916  
2917   }
2918  
2919   template <class InputCollection1, class InputCollection2>
2920 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
2920 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
2921  
2922    bool sameObjects = false;
2923    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2924  
2925 <  int pairCounter = 0;  
2925 >  int pairCounter = 0;
2926    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2927      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2928 <      
2928 >
2929        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2930  
2931        //only take objects which have passed all cuts and pairs which have passed all cuts
# Line 2622 | Line 2937 | void OSUAnalysis::fill2DHistogram(TH2* h
2937        string inputVariable = "";
2938        string function = "";
2939        if(currentString.find("(")==std::string::npos){
2940 <        inputVariable = currentString;// variable to cut on                                                                                                          
2940 >        inputVariable = currentString;// variable to cut on
2941        }
2942        else{
2943 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2944 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2945 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2943 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2944 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2945 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2946        }
2947        double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2948  
# Line 2635 | Line 2950 | void OSUAnalysis::fill2DHistogram(TH2* h
2950        inputVariable = "";
2951        function = "";
2952        if(currentString.find("(")==std::string::npos){
2953 <        inputVariable = currentString;// variable to cut on                                                                                                          
2953 >        inputVariable = currentString;// variable to cut on
2954        }
2955        else{
2956 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2957 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2958 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2956 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2957 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2958 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2959        }
2960        double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2961  
2962  
2963 <      histo->Fill(valueX,valueY,puScaleFactor);
2963 >      histo->Fill(valueX,valueY,scaleFactor);
2964 >
2965 >      pairCounter++;
2966  
2650      pairCounter++;      
2967      }
2968    }
2969  
# Line 2664 | Line 2980 | int OSUAnalysis::getGenMatchedParticleIn
2980  
2981      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
2982      if(currentDeltaR > 0.05) continue;
2983 <
2983 > //     cout << std::setprecision(3) << std::setw(20)
2984 > //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
2985 > //          << std::setw(20)
2986 > //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
2987 > //          << std::setw(20)
2988 > //          << "\tdeltaR = " << currentDeltaR
2989 > //          << std::setprecision(1)
2990 > //          << std::setw(20)
2991 > //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
2992 > //          << std::setw(20)
2993 > //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
2994 > //          << std::setw(20)
2995 > //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
2996      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2997        bestMatchIndex = mcparticle - mcparticles->begin();
2998        bestMatchDeltaR = currentDeltaR;
2999      }
3000  
3001    }
3002 <
3002 > //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3003 > //   else cout << "no match found..." << endl;
3004    return bestMatchIndex;
3005  
3006   }
# Line 2730 | Line 3059 | int OSUAnalysis::findTauMotherIndex(cons
3059   int OSUAnalysis::getPdgIdBinValue(int pdgId){
3060  
3061    int binValue = -999;
3062 <  int absPdgId = fabs(pdgId);  
3062 >  int absPdgId = fabs(pdgId);
3063    if(pdgId == -1) binValue = 0;
3064    else if(absPdgId <= 6 ) binValue = absPdgId;
3065    else if(absPdgId == 11 ) binValue = 7;
# Line 2756 | Line 3085 | int OSUAnalysis::getPdgIdBinValue(int pd
3085  
3086   }
3087  
3088 + const BNprimaryvertex *
3089 + OSUAnalysis::chosenVertex ()
3090 + {
3091 +  const BNprimaryvertex *chosenVertex = 0;
3092 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3093 +    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3094 +                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3095 +    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3096 +      if(!vertexFlags.at(vertexIndex)) continue;
3097 +      chosenVertex = & primaryvertexs->at(vertexIndex);
3098 +      break;
3099 +    }
3100 +  }
3101 +  else {
3102 +    chosenVertex = &primaryvertexs->at(0);
3103 +  }
3104  
3105 < DEFINE_FWK_MODULE(OSUAnalysis);
3105 >  return chosenVertex;
3106 > }
3107 >
3108 > const BNmet *
3109 > OSUAnalysis::chosenMET ()
3110 > {
3111 >  const BNmet *chosenMET = 0;
3112 >  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3113 >    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3114 >                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3115 >    for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3116 >      if(!metFlags.at(metIndex)) continue;
3117 >      chosenMET = & mets->at(metIndex);
3118 >      break;
3119 >    }
3120 >  }
3121 >  else {
3122 >    chosenMET = &mets->at(0);
3123 >  }
3124  
3125 +  return chosenMET;
3126 + }
3127  
3128 + const BNelectron *
3129 + OSUAnalysis::chosenElectron ()
3130 + {
3131 +  const BNelectron *chosenElectron = 0;
3132 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3133 +    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3134 +                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3135 +    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3136 +      if(!electronFlags.at(electronIndex)) continue;
3137 +      chosenElectron = & electrons->at(electronIndex);
3138 +      break;
3139 +    }
3140 +  }
3141 +  else {
3142 +    chosenElectron = &electrons->at(0);
3143 +  }
3144 +
3145 +  return chosenElectron;
3146 + }
3147 +
3148 + const BNmuon *
3149 + OSUAnalysis::chosenMuon ()
3150 + {
3151 +  const BNmuon *chosenMuon = 0;
3152 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3153 +    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3154 +                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3155 +    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3156 +      if(!muonFlags.at(muonIndex)) continue;
3157 +      chosenMuon = & muons->at(muonIndex);
3158 +      break;
3159 +    }
3160 +  }
3161 +  else {
3162 +    chosenMuon = &muons->at(0);
3163 +  }
3164 +
3165 +  return chosenMuon;
3166 + }
3167 +
3168 +
3169 + DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines