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.23 by lantonel, Mon Mar 4 22:38:39 2013 UTC vs.
Revision 1.31 by ahart, Mon Mar 18 10:21:44 2013 UTC

# Line 17 | Line 17 | OSUAnalysis::OSUAnalysis (const edm::Par
17    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
18    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
19    puFile_ (cfg.getParameter<std::string> ("puFile")),
20 +  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
21 +  muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
22    dataPU_ (cfg.getParameter<std::string> ("dataPU")),
23 +  electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
24 +  muonSF_ (cfg.getParameter<std::string> ("muonSF")),
25    dataset_ (cfg.getParameter<std::string> ("dataset")),
26    datasetType_ (cfg.getParameter<std::string> ("datasetType")),
27    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
28    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
29 <  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents"))
30 <
29 >  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
30 >  doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting"))
31   {
32  
33    TH1::SetDefaultSumw2 ();
34  
35    //create pile-up reweighting object, if necessary
36 <  if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
36 >  if(datasetType_ != "data") {
37 >    if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
38 >    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
39 >    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
40 >  }
41  
42    // Construct Cutflow Objects. These store the results of cut decisions and
43    // handle filling cut flow histograms.
# Line 38 | Line 46 | OSUAnalysis::OSUAnalysis (const edm::Par
46  
47    //always get vertex collection so we can assign the primary vertex in the event
48    objectsToGet.push_back("primaryvertexs");
49 +
50    //always make the plot of number of primary verticex (to check pile-up reweighting)
51    objectsToPlot.push_back("primaryvertexs");
43  //always make flags for the vertices to pick the best good one
44  //  objectsToCut.push_back("primaryvertexs");
52  
53    //always get the MC particles to do GEN-matching
54    objectsToGet.push_back("mcparticles");
# Line 54 | Line 61 | OSUAnalysis::OSUAnalysis (const edm::Par
61  
62      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
63      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
64 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
64 >    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
65        objectsToGet.push_back(tempInputCollection);
66        objectsToPlot.push_back(tempInputCollection);
67 +      objectsToCut.push_back(tempInputCollection);
68      }
69      else{//pair of objects, need to add them both to the things to objectsToGet
70        int dashIndex = tempInputCollection.find("-");
# Line 75 | Line 83 | OSUAnalysis::OSUAnalysis (const edm::Par
83        }
84  
85      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
86 <    
86 >
87      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
88  
89        histogram tempHistogram;
# Line 84 | Line 92 | OSUAnalysis::OSUAnalysis (const edm::Par
92        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
93        tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
94        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
95 <      
95 >
96        histograms.push_back(tempHistogram);
97  
98      }
# Line 135 | Line 143 | OSUAnalysis::OSUAnalysis (const edm::Par
143      histograms.push_back(tempIdHisto);
144      histograms.push_back(tempMomIdHisto);
145      histograms.push_back(tempGmaIdHisto);
146 <    
146 >
147    }
148  
149  
# Line 183 | Line 191 | OSUAnalysis::OSUAnalysis (const edm::Par
191        int numInputVariables = currentHistogram.inputVariables.size();
192  
193        if(numBinsElements != 3 && numBinsElements !=6) {
194 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
195 <        exit(0);
194 >        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
195 >        exit(0);
196        }
197        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
198 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
199 <        exit(0);
198 >        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
199 >        exit(0);
200        }
201        else if(numBinsElements == 3){
202 <        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));
202 >        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));
203        }
204        else if(numBinsElements == 6){
205 <        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));
205 >        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));
206  
207        }
208  
# Line 255 | Line 263 | OSUAnalysis::OSUAnalysis (const edm::Par
263        labelArray.push_back("other");
264  
265        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
266 <        oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
266 >        oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
267        }
268      }
269 +
270      //book a histogram for the number of each object type to be plotted
271 +
272      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
273        string currentObject = objectsToPlot.at(currentObjectIndex);
274        int maxNum = 10;
# Line 272 | Line 282 | OSUAnalysis::OSUAnalysis (const edm::Par
282        string histoName = "num" + currentObject;
283  
284        if(histoName == "numPrimaryvertexs"){
285 <        string newHistoName = histoName + "BeforePileupCorrection";
286 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);    
287 <        newHistoName = histoName + "AfterPileupCorrection";
288 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
285 >        string newHistoName = histoName + "BeforePileupCorrection";
286 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
287 >        newHistoName = histoName + "AfterPileupCorrection";
288 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
289        }
290        else
291 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
291 >        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
292      }
293  
294  
295 <    
295 >
296  
297  
298      //get list of cuts for this channel
# Line 294 | Line 304 | OSUAnalysis::OSUAnalysis (const edm::Par
304        //store input collection for cut
305        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
306        tempCut.inputCollection = tempInputCollection;
307 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
308 <        objectsToGet.push_back(tempInputCollection);
309 <        objectsToCut.push_back(tempInputCollection);
307 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
308 >        objectsToGet.push_back(tempInputCollection);
309 >        objectsToCut.push_back(tempInputCollection);
310        }
311        else{//pair of objects, need to add them both to the things to objectsToGet
312 <        int dashIndex = tempInputCollection.find("-");
313 <        int spaceIndex = tempInputCollection.find(" ");
314 <        int secondWordLength = spaceIndex - dashIndex;
315 <        objectsToGet.push_back(tempInputCollection);
316 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
312 >        int dashIndex = tempInputCollection.find("-");
313 >        int spaceIndex = tempInputCollection.find(" ");
314 >        int secondWordLength = spaceIndex - dashIndex;
315 >        objectsToGet.push_back(tempInputCollection);
316 >        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
317          objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
318 <        objectsToCut.push_back(tempInputCollection);
319 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
318 >        objectsToCut.push_back(tempInputCollection);
319 >        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
320          objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
321  
322        }
# Line 317 | Line 327 | OSUAnalysis::OSUAnalysis (const edm::Par
327        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
328        std::vector<string> cutStringVector = splitString(cutString);
329        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
330 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
331 <        exit(0);
330 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
331 >        exit(0);
332        }
333        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
334        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
335 <        int indexOffset = 4 * subcutIndex;
336 <        string currentVariableString = cutStringVector.at(indexOffset);
337 <        if(currentVariableString.find("(")==std::string::npos){
338 <          tempCut.functions.push_back("");//no function was specified
339 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
340 <        }
341 <        else{
342 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
343 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
344 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
345 <        }
346 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
347 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
348 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
335 >        int indexOffset = 4 * subcutIndex;
336 >        string currentVariableString = cutStringVector.at(indexOffset);
337 >        if(currentVariableString.find("(")==std::string::npos){
338 >          tempCut.functions.push_back("");//no function was specified
339 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
340 >        }
341 >        else{
342 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
343 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
344 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
345 >        }
346 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
347 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
348 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
349        }
350  
351        //get number of objects required to pass cut for event to pass
352        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
353        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
354        if(numberRequiredVector.size()!=2){
355 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
355 >        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
356          exit(0);
357        }
358  
# Line 444 | Line 454 | OSUAnalysis::analyze (const edm::Event &
454    if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
455      event.getByLabel (superclusters_, superclusters);
456  
447
457    //get pile-up event weight
458 <  double puScaleFactor = 1.00;
459 <  if(datasetType_ != "data")
460 <    puScaleFactor = puWeight_->at (events->at (0).numTruePV);
458 >  double scaleFactor = 1.00;
459 >  if(doPileupReweighting_ && datasetType_ != "data")
460 >    scaleFactor = puWeight_->at (events->at (0).numTruePV);
461 >
462  
463    //loop over all channels
464  
# Line 456 | Line 466 | OSUAnalysis::analyze (const edm::Event &
466      channel currentChannel = channels.at(currentChannelIndex);
467  
468      flagMap individualFlags;
459    flagMap cumulativeFlags;
469      counterMap passingCounter;
470 +    cumulativeFlags.clear ();
471  
472      bool triggerDecision = true;
473      if(currentChannel.triggers.size() != 0){  //triggers specified
# Line 468 | Line 478 | OSUAnalysis::analyze (const edm::Event &
478      //loop over all cuts
479  
480  
481 +
482      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
483        cut currentCut = currentChannel.cuts.at(currentCutIndex);
484  
485        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
486          string currentObject = objectsToCut.at(currentObjectIndex);
487  
488 <        //initialize maps to get ready to set cuts
488 >        //initialize maps to get ready to set cuts
489          individualFlags[currentObject].push_back (vector<bool> ());
490          cumulativeFlags[currentObject].push_back (vector<bool> ());
491  
# Line 482 | Line 493 | OSUAnalysis::analyze (const edm::Event &
493        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
494          string currentObject = objectsToCut.at(currentObjectIndex);
495  
496 <        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
496 >        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
497 >
498  
499          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
500          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
# Line 498 | Line 510 | OSUAnalysis::analyze (const edm::Event &
510          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
511          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
512  
513 <        
514 <        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
515 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
516 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
517 <                                                                   "muon-muon pairs");
518 <        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
519 <                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
520 <                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
521 <                                                                           "electron-electron pairs");
522 <        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
523 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
524 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
525 <                                                                       "electron-muon pairs");
513 >
514 >        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
515 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
516 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
517 >                                                                   "muon-muon pairs");
518 >        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
519 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
520 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
521 >                                                                           "electron-electron pairs");
522 >        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
523 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
524 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
525 >                                                                       "electron-muon pairs");
526 >
527  
528        }
529  
# Line 527 | Line 540 | OSUAnalysis::analyze (const edm::Event &
540      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
541  
542  
543 +
544      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
545  
546        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 544 | Line 558 | OSUAnalysis::analyze (const edm::Event &
558  
559      }
560  
561 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor);
561 >    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
562  
563  
564  
565      if(!eventPassedAllCuts)continue;
566  
567  
568 <    
569 <
570 <    //set position of primary vertex in event, in order to calculate quantities relative to it
571 <    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
558 <      vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
559 <      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
560 <        if(!vertexFlags.at(vertexIndex)) continue;
561 <        chosenPrimaryVertex = & primaryvertexs->at(vertexIndex);
562 <        break;
563 <      }
564 <    }
565 <    else {
566 <      chosenPrimaryVertex = & primaryvertexs->at(0);
567 <    }
568 <
568 >    //if(datasetType_ != "data") {
569 >    //  scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
570 >    //  scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
571 >    //}
572  
573      //filling histograms
574      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
575        histogram currentHistogram = histograms.at(histogramIndex);
576  
577        if(currentHistogram.inputVariables.size() == 1){
578 <        TH1D* histo;
579 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
578 >        TH1D* histo;
579 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
580 >
581 >
582  
583 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
584 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
585 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\
586 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\
587 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
588 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
589 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
590 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
591 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
592 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
593 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
594 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
595 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
596 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
597 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
598 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
599 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
600 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
601 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
602 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
603 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
604 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
583 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
584 >         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
585 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
586 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
587 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
588 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
589 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
590 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
591 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
592 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
593 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
594 >                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
595 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
596 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
597 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
598 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
599 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
600 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
601 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
602 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
603 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
604 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
605        }
606        else if(currentHistogram.inputVariables.size() == 2){
607 <        TH2D* histo;
608 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
609 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
610 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
611 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
612 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
613 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
614 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
615 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
616 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
617 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
618 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
619 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
620 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
621 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
622 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
623 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
624 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
625 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
626 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
627 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
628 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
629 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
630 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
631 <      }
607 >        TH2D* histo;
608 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
609 >
610 >
611 >
612 >        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
613 >        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
614 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
615 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
616 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
617 >        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
618 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
619 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
620 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
621 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
622 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
623 >                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
624 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
625 >        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
626 >        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
627 >        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
628 >        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
629 >        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
630 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
631 >        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
632 >        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
633 >        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
634 >      }
635      }
636  
637      //fills histograms with the sizes of collections
# Line 645 | Line 653 | OSUAnalysis::analyze (const edm::Event &
653  
654        //set position of primary vertex in event, in order to calculate quantities relative to it
655        if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
656 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
657 <        int numToPlot = 0;
658 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
659 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
660 <        }
661 <        if(objectToPlot == "primaryvertexs"){
662 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
663 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
664 <        }
665 <        else
666 <          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,puScaleFactor);        
667 <      }
668 <      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
669 <      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
670 <      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
671 <      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
672 <      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
673 <      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
674 <      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
675 <      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
676 <      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
677 <      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
678 <      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
679 <      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
680 <      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
681 <      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
682 <      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
656 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
657 >        int numToPlot = 0;
658 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
659 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
660 >        }
661 >        if(objectToPlot == "primaryvertexs"){
662 >          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
663 >          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
664 >        }
665 >        else
666 >          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
667 >      }
668 >      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
669 >      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
670 >      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
671 >      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
672 >      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
673 >      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
674 >      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
675 >      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
676 >      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
677 >      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
678 >      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
679 >      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
680 >      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
681 >      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
682 >      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
683        else if(objectToPlot == "primaryvertexs"){
684 <        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
685 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
684 >        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
685 >        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
686        }
687  
688      }
# Line 684 | Line 692 | OSUAnalysis::analyze (const edm::Event &
692  
693    } //end loop over channel
694  
695 <  masterCutFlow_->fillCutFlow(puScaleFactor);
695 >  masterCutFlow_->fillCutFlow(scaleFactor);
696  
697  
698  
# Line 1022 | Line 1030 | OSUAnalysis::valueLookup (const BNmuon*
1030    else if(variable == "time_ndof") value = object->time_ndof;
1031  
1032    //user-defined variables
1033 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1034 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1033 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1034 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1035    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1036 <  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1036 >  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1037    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1038 +  else if(variable == "metMT") {
1039 +    const BNmet *met = chosenMET ();
1040 +    if (met)
1041 +      {
1042 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1043 +                       p2 (met->px, met->py, 0.0, met->pt);
1044 +
1045 +        value = (p1 + p2).Mt ();
1046 +      }
1047 +    else
1048 +      value = -999;
1049 +  }
1050 +
1051 +
1052 +
1053 +  else if(variable == "correctedD0VertexInEBPlus"){
1054 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1055 +    else value = -999;
1056 +  }
1057 +  else if(variable == "correctedD0VertexOutEBPlus"){
1058 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1059 +    else value = -999;
1060 +  }
1061 +  else if(variable == "correctedD0VertexEEPlus"){
1062 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1063 +    else value = -999;
1064 +  }
1065 +
1066 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1067 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1068 +    else value = -999;
1069 +  }
1070 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1071 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1072 +    else value = -999;
1073 +  }
1074 +  else if(variable == "correctedD0BeamspotEEPlus"){
1075 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1076 +    else value = -999;
1077 +  }
1078 +
1079 +  else if(variable == "correctedD0VertexInEBMinus"){
1080 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1081 +    else value = -999;
1082 +  }
1083 +  else if(variable == "correctedD0VertexOutEBMinus"){
1084 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1085 +    else value = -999;
1086 +  }
1087 +  else if(variable == "correctedD0VertexEEMinus"){
1088 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1089 +    else value = -999;
1090 +  }
1091 +
1092 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1093 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1094 +    else value = -999;
1095 +  }
1096 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1097 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1098 +    else value = -999;
1099 +  }
1100 +  else if(variable == "correctedD0BeamspotEEMinus"){
1101 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1102 +    else value = -999;
1103 +  }
1104 +
1105 +
1106 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1107 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1108 +    else value = -999;
1109 +  }
1110 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1111 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1112 +    else value = -999;
1113 +  }
1114 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1115 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1116 +    else value = -999;
1117 +  }
1118 +
1119 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1120 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1121 +    else value = -999;
1122 +  }
1123 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1124 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1125 +    else value = -999;
1126 +  }
1127 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1128 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1129 +    else value = -999;
1130 +  }
1131 +
1132 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1133 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1134 +    else value = -999;
1135 +  }
1136 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1137 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1138 +    else value = -999;
1139 +  }
1140 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1141 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1142 +    else value = -999;
1143 +  }
1144 +
1145 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1146 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1147 +    else value = -999;
1148 +  }
1149 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1150 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1151 +    else value = -999;
1152 +  }
1153 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1154 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1155 +    else value = -999;
1156 +  }
1157 +
1158 +
1159    else if(variable == "tightID") {
1160 <    value = object->isGlobalMuon > 0            \
1161 <      && object->isPFMuon > 0                   \
1162 <      && object->normalizedChi2 < 10            \
1163 <      && object->numberOfValidMuonHits > 0      \
1164 <      && object->numberOfMatchedStations > 1    \
1165 <      && fabs(object->correctedD0Vertex) < 0.2  \
1166 <      && fabs(object->correctedDZ) < 0.5        \
1167 <      && object->numberOfValidPixelHits > 0             \
1160 >    value = object->isGlobalMuon > 0                \
1161 >      && object->isPFMuon > 0                        \
1162 >      && object->normalizedChi2 < 10                \
1163 >      && object->numberOfValidMuonHits > 0        \
1164 >      && object->numberOfMatchedStations > 1        \
1165 >      && fabs(object->correctedD0Vertex) < 0.2        \
1166 >      && fabs(object->correctedDZ) < 0.5        \
1167 >      && object->numberOfValidPixelHits > 0                \
1168        && object->numberOfLayersWithMeasurement > 5;
1169    }
1170    else if(variable == "tightIDdisplaced"){
1171 <    value = object->isGlobalMuon > 0            \
1172 <      && object->normalizedChi2 < 10            \
1173 <      && object->numberOfValidMuonHits > 0      \
1174 <      && object->numberOfMatchedStations > 1    \
1175 <      && object->numberOfValidPixelHits > 0     \
1171 >    value = object->isGlobalMuon > 0                \
1172 >      && object->normalizedChi2 < 10                \
1173 >      && object->numberOfValidMuonHits > 0        \
1174 >      && object->numberOfMatchedStations > 1        \
1175 >      && object->numberOfValidPixelHits > 0        \
1176        && object->numberOfLayersWithMeasurement > 5;
1177    }
1178  
1179 +
1180 +
1181    else if(variable == "genMatchedId"){
1182      int index = getGenMatchedParticleIndex(object);
1183      if(index == -1) value = 0;
# Line 1240 | Line 1371 | OSUAnalysis::valueLookup (const BNelectr
1371    else if(variable == "passConvVeto") value = object->passConvVeto;
1372  
1373    //user-defined variables
1374 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1375 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1374 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1375 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1376    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1377    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1378 <  else if(variable == "correctedD0VertexInEB"){
1379 <    if(fabs(object->eta) < 0.8) value = object->correctedD0Vertex;
1378 >  else if(variable == "metMT") {
1379 >    const BNmet *met = chosenMET ();
1380 >    if (met)
1381 >      {
1382 >        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1383 >                       p2 (met->px, met->py, 0.0, met->pt);
1384 >
1385 >        value = (p1 + p2).Mt ();
1386 >      }
1387 >    else
1388 >      value = -999;
1389 >  }
1390 >
1391 >  else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1392 >    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
1393 >    else value = -999;
1394 >  }
1395 >  else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
1396 >    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
1397 >    else value = -999;
1398 >  }
1399 >
1400 >  else if(variable == "correctedD0VertexInEBPlus"){
1401 >    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1402 >    else value = -999;
1403 >  }
1404 >  else if(variable == "correctedD0VertexOutEBPlus"){
1405 >    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1406      else value = -999;
1407    }
1408 <  else if(variable == "correctedD0VertexOutEB"){
1409 <    if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0Vertex;
1408 >  else if(variable == "correctedD0VertexEEPlus"){
1409 >    if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
1410      else value = -999;
1411    }
1412 <  else if(variable == "correctedD0VertexEE"){
1413 <    if(object->isEE) value = object->correctedD0Vertex;
1412 >
1413 >  else if(variable == "correctedD0BeamspotInEBPlus"){
1414 >    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1415 >    else value = -999;
1416 >  }
1417 >  else if(variable == "correctedD0BeamspotOutEBPlus"){
1418 >    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1419 >    else value = -999;
1420 >  }
1421 >  else if(variable == "correctedD0BeamspotEEPlus"){
1422 >    if(object->isEE && object->eta > 0) value = object->correctedD0;
1423      else value = -999;
1424    }
1425  
1426 <  else if(variable == "correctedD0BeamspotInEB"){
1427 <    if(fabs(object->eta) < 0.8) value = object->correctedD0;
1426 >  else if(variable == "correctedD0VertexInEBMinus"){
1427 >    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1428      else value = -999;
1429    }
1430 <  else if(variable == "correctedD0BeamspotOutEB"){
1431 <    if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0;
1430 >  else if(variable == "correctedD0VertexOutEBMinus"){
1431 >    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1432      else value = -999;
1433    }
1434 <  else if(variable == "correctedD0BeamspotEE"){
1435 <    if(object->isEE) value = object->correctedD0;
1434 >  else if(variable == "correctedD0VertexEEMinus"){
1435 >    if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
1436      else value = -999;
1437    }
1438  
1439 <  else if(variable == "correctedD0OriginInEB"){
1440 <    if(fabs(object->eta) < 0.8) value = object->tkD0;
1439 >  else if(variable == "correctedD0BeamspotInEBMinus"){
1440 >    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1441      else value = -999;
1442    }
1443 <  else if(variable == "correctedD0OriginOutEB"){
1444 <    if(object->isEB && fabs(object->eta) > 0.8) value = object->tkD0;
1443 >  else if(variable == "correctedD0BeamspotOutEBMinus"){
1444 >    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1445      else value = -999;
1446    }
1447 <  else if(variable == "correctedD0OriginEE"){
1448 <    if(object->isEE) value = object->tkD0;
1447 >  else if(variable == "correctedD0BeamspotEEMinus"){
1448 >    if(object->isEE && object->eta < 0) value = object->correctedD0;
1449      else value = -999;
1450    }
1451  
1452 +  else if(variable == "tightID"){
1453 +    if (object->isEB)
1454 +      {
1455 +        value = fabs(object->delEtaIn) < 0.004 \
1456 +          && fabs (object->delPhiIn) < 0.03 \
1457 +          && object->scSigmaIEtaIEta < 0.01 \
1458 +          && object->hadOverEm < 0.12 \
1459 +          && fabs (object->correctedD0Vertex) < 0.02 \
1460 +          && fabs (object->correctedDZ) < 0.1 \
1461 +          && object->absInvEMinusInvPin < 0.05 \
1462 +          && object->passConvVeto;
1463 +      }
1464 +    else
1465 +      {
1466 +        value = fabs(object->delEtaIn) < 0.005 \
1467 +          && fabs (object->delPhiIn) < 0.02 \
1468 +          && object->scSigmaIEtaIEta < 0.03 \
1469 +          && object->hadOverEm < 0.10 \
1470 +          && fabs (object->correctedD0Vertex) < 0.02 \
1471 +          && fabs (object->correctedDZ) < 0.1 \
1472 +          && object->absInvEMinusInvPin < 0.05 \
1473 +          && object->passConvVeto;
1474 +      }
1475 +  }
1476 +
1477 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1478 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1479 +    else value = -999;
1480 +  }
1481 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1482 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1483 +    else value = -999;
1484 +  }
1485 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1486 +    if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
1487 +    else value = -999;
1488 +  }
1489 +
1490 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1491 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1492 +    else value = -999;
1493 +  }
1494 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1495 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1496 +    else value = -999;
1497 +  }
1498 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1499 +    if(object->isEE && object->charge > 0) value = object->correctedD0;
1500 +    else value = -999;
1501 +  }
1502 +
1503 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1504 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1505 +    else value = -999;
1506 +  }
1507 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1508 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1509 +    else value = -999;
1510 +  }
1511 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1512 +    if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
1513 +    else value = -999;
1514 +  }
1515 +
1516 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1517 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1518 +    else value = -999;
1519 +  }
1520 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1521 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1522 +    else value = -999;
1523 +  }
1524 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1525 +    if(object->isEE && object->charge < 0) value = object->correctedD0;
1526 +    else value = -999;
1527 +  }
1528 +
1529 +
1530    else if(variable == "tightIDdisplaced"){
1531      if (object->isEB)
1532        {
1533 <        value = fabs(object->delEtaIn) < 0.004 \
1534 <          && fabs (object->delPhiIn) < 0.03 \
1533 >        value = fabs(object->delEtaIn) < 0.004 \
1534 >          && fabs (object->delPhiIn) < 0.03 \
1535            && object->scSigmaIEtaIEta < 0.01 \
1536            && object->hadOverEm < 0.12 \
1537 <          && object->absInvEMinusInvPin < 0.05;
1537 >          && object->absInvEMinusInvPin < 0.05;
1538        }
1539      else
1540        {
1541 <        value = fabs (object->delEtaIn) < 0.005 \
1542 <          && fabs (object->delPhiIn) < 0.02 \
1541 >        value = fabs (object->delEtaIn) < 0.005 \
1542 >          && fabs (object->delPhiIn) < 0.02 \
1543            && object->scSigmaIEtaIEta < 0.03 \
1544            && object->hadOverEm < 0.10 \
1545 <          && object->absInvEMinusInvPin < 0.05;
1545 >          && object->absInvEMinusInvPin < 0.05;
1546        }
1547    }
1548  
# Line 1402 | Line 1646 | OSUAnalysis::valueLookup (const BNevent*
1646    else if(variable == "id1") value = object->id1;
1647    else if(variable == "id2") value = object->id2;
1648    else if(variable == "evt") value = object->evt;
1649 +  else if(variable == "puScaleFactor"){
1650 +    if(datasetType_ != "data")
1651 +      value = puWeight_->at (events->at (0).numTruePV);
1652 +    else
1653 +      value = 1.0;
1654 +  }
1655 +  else if(variable == "muonScaleFactor"){
1656 +    if(datasetType_ != "data")
1657 +      value = muonSFWeight_->at (chosenMuon ()->eta);
1658 +    else
1659 +      value = 1.0;
1660 +  }
1661 +  else if(variable == "electronScaleFactor"){
1662 +    if(datasetType_ != "data")
1663 +      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1664 +    else
1665 +      value = 1.0;
1666 +  }
1667  
1668    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1669  
# Line 1561 | Line 1823 | double
1823   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1824  
1825    double value = 0.0;
1826 +  double pMag = sqrt(object->pt * object->pt +
1827 +                         object->pz * object->pz);
1828  
1829    if(variable == "pt") value = object->pt;
1830    else if(variable == "px") value = object->px;
# Line 1581 | Line 1845 | OSUAnalysis::valueLookup (const BNtrack*
1845    else if(variable == "isHighPurity") value = object->isHighPurity;
1846  
1847  
1848 +  //additional BNs info for disappTrks
1849 +  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
1850 +  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
1851 +  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
1852 +  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
1853 +  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
1854 +  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
1855 +  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
1856 +  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
1857 +  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
1858 +  else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
1859 +  //user defined variables
1860 +  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;
1861 +  else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
1862 +  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
1863 +  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
1864 +  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
1865 +  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
1866 +  else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
1867 +  else if(variable == "ptError") value = object->ptError;
1868 +  else if(variable == "ptRes") value = getTrkPtRes(object);
1869 +
1870 +
1871    else if(variable == "genMatchedId"){
1872      int index = getGenMatchedParticleIndex(object);
1873      if(index == -1) value = 0;
# Line 1731 | Line 2018 | OSUAnalysis::valueLookup (const BNmcpart
2018  
2019    //user-defined variables
2020    else if (variable == "d0"){
2021 <    double vx = object->vx - chosenPrimaryVertex->x,
2022 <      vy = object->vy - chosenPrimaryVertex->y,
2021 >    double vx = object->vx - chosenVertex ()->x,
2022 >      vy = object->vy - chosenVertex ()->y,
2023        px = object->px,
2024        py = object->py,
2025        pt = object->pt;
2026      value = (-vx * py + vy * px) / pt;
2027    }
2028    else if (variable == "dz"){
2029 <    double vx = object->vx - chosenPrimaryVertex->x,
2030 <      vy = object->vy - chosenPrimaryVertex->y,
2031 <      vz = object->vz - chosenPrimaryVertex->z,
2029 >    double vx = object->vx - chosenVertex ()->x,
2030 >      vy = object->vy - chosenVertex ()->y,
2031 >      vz = object->vz - chosenVertex ()->z,
2032        px = object->px,
2033        py = object->py,
2034        pz = object->pz,
# Line 1752 | Line 2039 | OSUAnalysis::valueLookup (const BNmcpart
2039      value = sqrt(object->vx*object->vx + object->vy*object->vy);
2040    }
2041    else if(variable == "deltaV0"){
2042 <    value = sqrt((object->vx-chosenPrimaryVertex->x)*(object->vx-chosenPrimaryVertex->x) + (object->vy-chosenPrimaryVertex->y)*(object->vy-chosenPrimaryVertex->y));
2042 >    value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2043    }
2044    else if (variable == "deltaVx"){
2045 <    value = object->vx - chosenPrimaryVertex->x;
2045 >    value = object->vx - chosenVertex ()->x;
2046    }
2047    else if (variable == "deltaVy"){
2048 <    value = object->vy - chosenPrimaryVertex->y;
2048 >    value = object->vy - chosenVertex ()->y;
2049    }
2050    else if (variable == "deltaVz"){
2051 <    value = object->vz - chosenPrimaryVertex->z;
2051 >    value = object->vz - chosenVertex ()->z;
2052    }
2053  
2054  
# Line 1954 | Line 2241 | OSUAnalysis::valueLookup (const BNmuon*
2241    else if(variable == "invMass"){
2242      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2243      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2244 <
2245 <    value = (fourVector1 + fourVector2).M();}
2244 >    value = (fourVector1 + fourVector2).M();
2245 >  }
2246    else if(variable == "threeDAngle")
2247      {
2248        TVector3 threeVector1(object1->px, object1->py, object1->pz);
2249        TVector3 threeVector2(object2->px, object2->py, object2->pz);
2250        value = (threeVector1.Angle(threeVector2));
2251      }
2252 <
2253 <
2254 <
2252 >  else if(variable == "alpha")
2253 >    {
2254 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
2255 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2256 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2257 >      value = (pi-threeVector1.Angle(threeVector2));
2258 >    }
2259    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2260    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2261    else if(variable == "d0Sign"){
# Line 1973 | Line 2264 | OSUAnalysis::valueLookup (const BNmuon*
2264      else if (d0Sign > 0) value = 0.5;
2265      else value = -999;
2266    }
2267 +  else if(variable == "chargeProduct"){
2268 +    value = object1->charge*object2->charge;
2269 +  }
2270    else if(variable == "muon1CorrectedD0Vertex"){
2271      value = object1->correctedD0Vertex;
2272    }
2273    else if(variable == "muon2CorrectedD0Vertex"){
2274      value = object2->correctedD0Vertex;
2275    }
2276 + else if(variable == "muon1timeAtIpInOut"){
2277 +    value = object1->timeAtIpInOut;
2278 +  }
2279 + else if(variable == "muon2timeAtIpInOut"){
2280 +    value = object2->timeAtIpInOut;
2281 +  }
2282    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2283  
1984
1985
1986
1987
1988
1989
1990
2284    value = applyFunction(function, value);
2285  
2286    return value;
# Line 2003 | Line 2296 | OSUAnalysis::valueLookup (const BNelectr
2296    else if(variable == "invMass"){
2297      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2298      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2299 <
2300 <    value = (fourVector1 + fourVector2).M();}
2301 < else if(variable == "threeDAngle")
2299 >    value = (fourVector1 + fourVector2).M();
2300 >  }
2301 >  else if(variable == "threeDAngle")
2302      {
2303        TVector3 threeVector1(object1->px, object1->py, object1->pz);
2304        TVector3 threeVector2(object2->px, object2->py, object2->pz);
2305        value = (threeVector1.Angle(threeVector2));
2306      }
2014  
2015
2016
2017
2307    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2308    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2020
2021  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2022
2023
2024
2309    else if(variable == "d0Sign"){
2310      double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2311      if(d0Sign < 0) value = -0.5;
2312      else if (d0Sign > 0) value = 0.5;
2313      else value = -999;
2314    }
2315 +  else if(variable == "chargeProduct"){
2316 +    value = object1->charge*object2->charge;
2317 +  }
2318    else if(variable == "electron1CorrectedD0Vertex"){
2319      value = object1->correctedD0Vertex;
2320    }
# Line 2052 | Line 2339 | OSUAnalysis::valueLookup (const BNelectr
2339    else if(variable == "invMass"){
2340      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2341      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2342 <
2343 <    value = (fourVector1 + fourVector2).M();}
2344 < else if(variable == "threeDAngle")
2342 >    value = (fourVector1 + fourVector2).M();
2343 >  }
2344 >  else if(variable == "threeDAngle")
2345      {
2346        TVector3 threeVector1(object1->px, object1->py, object1->pz);
2347        TVector3 threeVector2(object2->px, object2->py, object2->pz);
2348        value = (threeVector1.Angle(threeVector2));
2349      }
2063
2064
2350    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2351    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2352    else if(variable == "d0Sign"){
# Line 2070 | Line 2355 | OSUAnalysis::valueLookup (const BNelectr
2355      else if (d0Sign > 0) value = 0.5;
2356      else value = -999;
2357    }
2358 +  else if(variable == "chargeProduct"){
2359 +    value = object1->charge*object2->charge;
2360 +  }
2361    else if(variable == "electronCorrectedD0Vertex"){
2362      value = object1->correctedD0Vertex;
2363    }
# Line 2082 | Line 2370 | OSUAnalysis::valueLookup (const BNelectr
2370    else if(variable == "muonCorrectedD0"){
2371      value = object2->correctedD0;
2372    }
2373 +  else if(variable == "electronDetIso"){
2374 +    value = (object1->trackIso) / object1->pt;
2375 +  }
2376 +  else if(variable == "muonDetIso"){
2377 +    value = (object2->trackIsoDR03) / object2->pt;
2378 +  }
2379 +  else if(variable == "chargeProduct"){
2380 +    value = object1->charge * object2->charge;
2381 +  }
2382  
2383  
2384    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 2092 | Line 2389 | OSUAnalysis::valueLookup (const BNelectr
2389   }
2390  
2391  
2392 + // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2393 + // Return true iff no other tracks are found in this cone.
2394 + int
2395 + OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
2396 +  for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
2397 +    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
2398 +    double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
2399 +    if(deltaRtrk < 0.5) return 0;
2400 +  }
2401 +  return 1;
2402 +
2403 + }
2404 +
2405 +
2406 + double
2407 + OSUAnalysis::getTrkPtRes (const BNtrack* track1){
2408 +
2409 +  double ptTrue = getTrkPtTrue(track1, mcparticles.product());
2410 +  double PtRes = (track1->pt - ptTrue) / ptTrue;
2411 +
2412 +  return PtRes;
2413 +
2414 + }
2415 +
2416 +
2417 + double
2418 + OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
2419 +  double value = -99;
2420 +  double genDeltaRLowest = 999;
2421 +
2422 +  for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){
2423 +    double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
2424 +    if (genDeltaRtemp < genDeltaRLowest) {
2425 +      genDeltaRLowest = genDeltaRtemp;
2426 +      if (genDeltaRLowest < 0.05) {   // Only consider it truth-matched if DeltaR<0.15.
2427 +        double ptTrue = genPart->pt;
2428 +        value = ptTrue;
2429 +      }
2430 +    }
2431 +  }
2432 +
2433 +  return value;
2434 +
2435 + }
2436 +
2437 + //creates a map of the dead Ecal channels in the barrel and endcap
2438 + //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2439 + //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
2440 + void
2441 + OSUAnalysis::WriteDeadEcal (){
2442 +  double etaEcal, phiEcal;
2443 +  ifstream DeadEcalFile(deadEcalFile_);
2444 +  if(!DeadEcalFile) {
2445 +    cout << "Error: DeadEcalFile has not been found." << endl;
2446 +    return;
2447 +  }
2448 +  if(DeadEcalVec.size()!= 0){
2449 +    cout << "Error: DeadEcalVec has a nonzero size" << endl;
2450 +    return;
2451 +  }
2452 +  while(!DeadEcalFile.eof())
2453 +    {
2454 +      DeadEcalFile >> etaEcal >> phiEcal;
2455 +      DeadEcal newChan;
2456 +      newChan.etaEcal = etaEcal;
2457 +      newChan.phiEcal = phiEcal;
2458 +      DeadEcalVec.push_back(newChan);
2459 +    }
2460 +  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
2461 + }
2462 +
2463 + //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
2464 + int
2465 + OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
2466 +  double deltaRLowest = 999;
2467 +  int value = 0;
2468 +  if (DeadEcalVec.size() == 0) WriteDeadEcal();
2469 +  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
2470 +    double eta = ecal->etaEcal;
2471 +    double phi = ecal->phiEcal;
2472 +    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
2473 +    if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
2474 +  }
2475 +  if (deltaRLowest<0.05) {value = 1;}
2476 +  else {value = 0;}
2477 +  return value;
2478 + }
2479 +
2480 +
2481 +
2482 +
2483   double
2484   OSUAnalysis::applyFunction(string function, double value){
2485  
2486    if(function == "abs") value = fabs(value);
2487    else if(function == "fabs") value = fabs(value);
2488 <
2488 >  else if(function == "log10") value = log10(value);
2489 >  else if(function == "log") value = log10(value);
2490  
2491    else if(function == "") value = value;
2492    else{std::cout << "WARNING: invalid function '" << function << "'\n";}
# Line 2121 | Line 2510 | void OSUAnalysis::setObjectFlags(cut &cu
2510  
2511        vector<bool> subcutDecisions;
2512        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2513 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2514 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2513 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2514 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2515        }
2516        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2517        else{
2518 <        bool tempDecision = true;
2519 <        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2520 <          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2521 <            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2522 <          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2518 >        bool tempDecision = true;
2519 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2520 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2521 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2522 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2523              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2524 <        }
2525 <        decision = tempDecision;
2524 >        }
2525 >        decision = tempDecision;
2526        }
2527      }
2528      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
# Line 2155 | Line 2544 | void OSUAnalysis::setObjectFlags(cut &cu
2544  
2545   template <class InputCollection1, class InputCollection2>
2546   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2547 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2547 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2548  
2549  
2550    bool sameObjects = false;
2551    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2552  
2553  
2554 <  int counter = 0;  
2554 >  int counter = 0;
2555    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2556      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2557 <      
2557 >
2558        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2559  
2560  
# Line 2173 | Line 2562 | void OSUAnalysis::setObjectFlags(cut &cu
2562  
2563        if(currentCut.inputCollection == inputType){
2564  
2565 <        vector<bool> subcutDecisions;
2566 <        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2567 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2568 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2569 <        }
2570 <
2571 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2572 <        else{
2573 <          bool tempDecision = true;
2574 <          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2575 <            if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2576 <              tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2577 <            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2578 <              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2579 <          }
2580 <          decision = tempDecision;
2581 <        }
2565 >        vector<bool> subcutDecisions;
2566 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2567 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2568 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2569 >        }
2570 >
2571 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2572 >        else{
2573 >          bool tempDecision = subcutDecisions.at(0);
2574 >          for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
2575 >            if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
2576 >              tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
2577 >            else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
2578 >              tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
2579 >          }
2580 >          decision = tempDecision;
2581 >        }
2582        }
2583        individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2584 <      
2584 >
2585        //set flags for objects that pass each cut AND all the previous cuts
2586        bool previousCumulativeFlag = true;
2587        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2588 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2589 <        else{ previousCumulativeFlag = false; break;}
2588 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2589 >        else{ previousCumulativeFlag = false; break;}
2590        }
2591        //apply flags for the components of the composite object as well
2592        bool currentCumulativeFlag = true;
# Line 2207 | Line 2596 | void OSUAnalysis::setObjectFlags(cut &cu
2596        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2597        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2598  
2599 <      counter++;      
2599 >      counter++;
2600      }
2601 <    
2601 >
2602    }
2603  
2604  
# Line 2217 | Line 2606 | void OSUAnalysis::setObjectFlags(cut &cu
2606  
2607  
2608   template <class InputCollection>
2609 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2609 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2610  
2611    for (uint object = 0; object != inputCollection->size(); object++){
2612  
# Line 2227 | Line 2616 | void OSUAnalysis::fill1DHistogram(TH1* h
2616      string inputVariable = "";
2617      string function = "";
2618      if(currentString.find("(")==std::string::npos){
2619 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
2619 >      inputVariable = currentString;// variable to cut on
2620      }
2621      else{
2622 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2623 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2624 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2622 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2623 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2624 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2625      }
2626  
2627      double value = valueLookup(&inputCollection->at(object), inputVariable, function);
2628 <    histo->Fill(value,puScaleFactor);
2628 >    histo->Fill(value,scaleFactor);
2629  
2630    }
2631  
2632   }
2633  
2634   template <class InputCollection1, class InputCollection2>
2635 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
2635 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
2636  
2637    bool sameObjects = false;
2638    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2639  
2640 <  int pairCounter = 0;  
2640 >  int pairCounter = 0;
2641    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2642      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2643 <      
2643 >
2644        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2645  
2646        //only take objects which have passed all cuts and pairs which have passed all cuts
# Line 2263 | Line 2652 | void OSUAnalysis::fill1DHistogram(TH1* h
2652        string inputVariable = "";
2653        string function = "";
2654        if(currentString.find("(")==std::string::npos){
2655 <        inputVariable = currentString;// variable to cut on                                                                                                          
2655 >        inputVariable = currentString;// variable to cut on
2656        }
2657        else{
2658 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2659 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2660 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2658 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2659 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2660 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2661        }
2662 <      
2662 >
2663        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2664 <      histo->Fill(value,puScaleFactor);
2664 >      histo->Fill(value,scaleFactor);
2665  
2666 <      pairCounter++;      
2666 >      pairCounter++;
2667      }
2668    }
2669  
# Line 2282 | Line 2671 | void OSUAnalysis::fill1DHistogram(TH1* h
2671  
2672  
2673   template <class InputCollection>
2674 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2674 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2675  
2676    for (uint object = 0; object != inputCollection->size(); object++){
2677  
# Line 2292 | Line 2681 | void OSUAnalysis::fill2DHistogram(TH2* h
2681      string inputVariable = "";
2682      string function = "";
2683      if(currentString.find("(")==std::string::npos){
2684 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
2684 >      inputVariable = currentString;// variable to cut on
2685      }
2686      else{
2687 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2688 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2689 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2687 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2688 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2689 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2690      }
2691      double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
2692  
# Line 2305 | Line 2694 | void OSUAnalysis::fill2DHistogram(TH2* h
2694      inputVariable = "";
2695      function = "";
2696      if(currentString.find("(")==std::string::npos){
2697 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
2697 >      inputVariable = currentString;// variable to cut on
2698      }
2699      else{
2700 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2701 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2702 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2700 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2701 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2702 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2703      }
2704  
2705      double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
2706  
2707 <    histo->Fill(valueX,valueY,puScaleFactor);
2707 >    histo->Fill(valueX,valueY,scaleFactor);
2708  
2709    }
2710  
2711   }
2712  
2713   template <class InputCollection1, class InputCollection2>
2714 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
2714 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
2715  
2716    bool sameObjects = false;
2717    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2718  
2719 <  int pairCounter = 0;  
2719 >  int pairCounter = 0;
2720    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2721      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2722 <      
2722 >
2723        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2724  
2725        //only take objects which have passed all cuts and pairs which have passed all cuts
# Line 2342 | Line 2731 | void OSUAnalysis::fill2DHistogram(TH2* h
2731        string inputVariable = "";
2732        string function = "";
2733        if(currentString.find("(")==std::string::npos){
2734 <        inputVariable = currentString;// variable to cut on                                                                                                          
2734 >        inputVariable = currentString;// variable to cut on
2735        }
2736        else{
2737 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2738 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2739 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2737 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2738 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2739 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2740        }
2741        double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2742  
# Line 2355 | Line 2744 | void OSUAnalysis::fill2DHistogram(TH2* h
2744        inputVariable = "";
2745        function = "";
2746        if(currentString.find("(")==std::string::npos){
2747 <        inputVariable = currentString;// variable to cut on                                                                                                          
2747 >        inputVariable = currentString;// variable to cut on
2748        }
2749        else{
2750 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2751 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2752 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2750 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2751 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2752 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2753        }
2754        double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2755  
2756  
2757 <      histo->Fill(valueX,valueY,puScaleFactor);
2757 >      histo->Fill(valueX,valueY,scaleFactor);
2758 >
2759 >      pairCounter++;
2760  
2370      pairCounter++;      
2761      }
2762    }
2763  
# Line 2384 | Line 2774 | int OSUAnalysis::getGenMatchedParticleIn
2774  
2775      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
2776      if(currentDeltaR > 0.05) continue;
2777 <
2777 > //     cout << std::setprecision(3) << std::setw(20)
2778 > //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
2779 > //          << std::setw(20)
2780 > //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
2781 > //          << std::setw(20)
2782 > //          << "\tdeltaR = " << currentDeltaR
2783 > //          << std::setprecision(1)
2784 > //          << std::setw(20)
2785 > //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
2786 > //          << std::setw(20)
2787 > //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
2788 > //          << std::setw(20)
2789 > //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
2790      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2791        bestMatchIndex = mcparticle - mcparticles->begin();
2792        bestMatchDeltaR = currentDeltaR;
2793      }
2794  
2795    }
2796 <
2796 > //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
2797 > //   else cout << "no match found..." << endl;
2798    return bestMatchIndex;
2799  
2800   }
# Line 2450 | Line 2853 | int OSUAnalysis::findTauMotherIndex(cons
2853   int OSUAnalysis::getPdgIdBinValue(int pdgId){
2854  
2855    int binValue = -999;
2856 <  int absPdgId = fabs(pdgId);  
2856 >  int absPdgId = fabs(pdgId);
2857    if(pdgId == -1) binValue = 0;
2858    else if(absPdgId <= 6 ) binValue = absPdgId;
2859    else if(absPdgId == 11 ) binValue = 7;
# Line 2476 | Line 2879 | int OSUAnalysis::getPdgIdBinValue(int pd
2879  
2880   }
2881  
2882 + const BNprimaryvertex *
2883 + OSUAnalysis::chosenVertex ()
2884 + {
2885 +  const BNprimaryvertex *chosenVertex = 0;
2886 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
2887 +    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
2888 +                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
2889 +    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
2890 +      if(!vertexFlags.at(vertexIndex)) continue;
2891 +      chosenVertex = & primaryvertexs->at(vertexIndex);
2892 +      break;
2893 +    }
2894 +  }
2895 +  else {
2896 +    chosenVertex = &primaryvertexs->at(0);
2897 +  }
2898  
2899 < DEFINE_FWK_MODULE(OSUAnalysis);
2899 >  return chosenVertex;
2900 > }
2901 >
2902 > const BNmet *
2903 > OSUAnalysis::chosenMET ()
2904 > {
2905 >  const BNmet *chosenMET = 0;
2906 >  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
2907 >    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
2908 >                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
2909 >    for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
2910 >      if(!metFlags.at(metIndex)) continue;
2911 >      chosenMET = & mets->at(metIndex);
2912 >      break;
2913 >    }
2914 >  }
2915 >  else {
2916 >    chosenMET = &mets->at(0);
2917 >  }
2918  
2919 +  return chosenMET;
2920 + }
2921  
2922 + const BNelectron *
2923 + OSUAnalysis::chosenElectron ()
2924 + {
2925 +  const BNelectron *chosenElectron = 0;
2926 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
2927 +    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
2928 +                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
2929 +    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
2930 +      if(!electronFlags.at(electronIndex)) continue;
2931 +      chosenElectron = & electrons->at(electronIndex);
2932 +      break;
2933 +    }
2934 +  }
2935 +  else {
2936 +    chosenElectron = &electrons->at(0);
2937 +  }
2938 +
2939 +  return chosenElectron;
2940 + }
2941 +
2942 + const BNmuon *
2943 + OSUAnalysis::chosenMuon ()
2944 + {
2945 +  const BNmuon *chosenMuon = 0;
2946 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
2947 +    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
2948 +                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
2949 +    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
2950 +      if(!muonFlags.at(muonIndex)) continue;
2951 +      chosenMuon = & muons->at(muonIndex);
2952 +      break;
2953 +    }
2954 +  }
2955 +  else {
2956 +    chosenMuon = &muons->at(0);
2957 +  }
2958 +
2959 +  return chosenMuon;
2960 + }
2961 +
2962 +
2963 + DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines