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.18 by lantonel, Fri Feb 22 10:38:08 2013 UTC vs.
Revision 1.26 by lantonel, Mon Mar 11 13:34:26 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    dataPU_ (cfg.getParameter<std::string> ("dataPU")),
22    dataset_ (cfg.getParameter<std::string> ("dataset")),
23    datasetType_ (cfg.getParameter<std::string> ("datasetType")),
# Line 37 | Line 38 | OSUAnalysis::OSUAnalysis (const edm::Par
38    std::vector<TFileDirectory> directories;
39  
40    //always get vertex collection so we can assign the primary vertex in the event
41 <  allNecessaryObjects.push_back("primaryvertexs");
41 >  
42 > objectsToGet.push_back("primaryvertexs");
43    //always make the plot of number of primary verticex (to check pile-up reweighting)
44    objectsToPlot.push_back("primaryvertexs");
45  
46 +  //always get the MC particles to do GEN-matching
47 +  objectsToGet.push_back("mcparticles");
48 +
49    //always get the event collection to do pile-up reweighting
50 <  allNecessaryObjects.push_back("events");
50 >  objectsToGet.push_back("events");
51  
52    //parse the histogram definitions
53    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
# Line 50 | Line 55 | OSUAnalysis::OSUAnalysis (const edm::Par
55      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
56      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
57      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
58 +      objectsToGet.push_back(tempInputCollection);
59        objectsToPlot.push_back(tempInputCollection);
60 <      allNecessaryObjects.push_back(tempInputCollection);
60 >      objectsToCut.push_back(tempInputCollection);
61      }
62 <    else{//pair of objects, need to add them both to the things to allNecessaryObjects
62 >    else{//pair of objects, need to add them both to the things to objectsToGet
63        int dashIndex = tempInputCollection.find("-");
64        int spaceIndex = tempInputCollection.find(" ");
65        int secondWordLength = spaceIndex - dashIndex;
66 <      allNecessaryObjects.push_back(tempInputCollection);
67 <      allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
68 <      allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
66 >      objectsToGet.push_back(tempInputCollection);
67 >      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
68 >      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
69        objectsToPlot.push_back(tempInputCollection);
70        objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
71        objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
72 +      objectsToCut.push_back(tempInputCollection);
73 +      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
74 +      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
75 +
76        }
77  
78      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
# Line 80 | Line 90 | OSUAnalysis::OSUAnalysis (const edm::Par
90  
91      }
92    }
93 <  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object
93 >  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
94    sort( objectsToPlot.begin(), objectsToPlot.end() );
95    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
96  
97  
98  
99 +  //add histograms with the gen-matched id, mother id, and grandmother id
100 +  for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
101 +
102 +    string currentObject = objectsToPlot.at(currentObjectIndex);
103 +    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
104 +
105 +    histogram tempIdHisto;
106 +    histogram tempMomIdHisto;
107 +    histogram tempGmaIdHisto;
108 +
109 +    tempIdHisto.inputCollection = currentObject;
110 +    tempMomIdHisto.inputCollection = currentObject;
111 +    tempGmaIdHisto.inputCollection = currentObject;
112 +
113 +    currentObject = currentObject.substr(0, currentObject.size()-1);
114 +    tempIdHisto.name = currentObject+"GenMatchId";
115 +    tempMomIdHisto.name = currentObject+"GenMatchMotherId";
116 +    tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
117 +
118 +    currentObject.at(0) = toupper(currentObject.at(0));
119 +    tempIdHisto.title = currentObject+" Gen-matched Particle";
120 +    tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
121 +    tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
122 +
123 +    int maxNum = 24;
124 +    vector<double> binVector;
125 +    binVector.push_back(maxNum);
126 +    binVector.push_back(0);
127 +    binVector.push_back(maxNum);
128 +
129 +    tempIdHisto.bins = binVector;
130 +    tempIdHisto.inputVariables.push_back("genMatchedId");
131 +    tempMomIdHisto.bins = binVector;
132 +    tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
133 +    tempGmaIdHisto.bins = binVector;
134 +    tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
135 +
136 +    histograms.push_back(tempIdHisto);
137 +    histograms.push_back(tempMomIdHisto);
138 +    histograms.push_back(tempGmaIdHisto);
139 +    
140 +  }
141 +
142 +
143  
144    channel tempChannel;
145    //loop over all channels (event selections)
# Line 104 | Line 158 | OSUAnalysis::OSUAnalysis (const edm::Par
158        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
159        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
160          tempChannel.triggers.push_back(triggerNames.at(trigger));
161 <      allNecessaryObjects.push_back("triggers");
161 >      objectsToGet.push_back("triggers");
162      }
163  
164  
# Line 146 | Line 200 | OSUAnalysis::OSUAnalysis (const edm::Par
200        }
201  
202  
203 +      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
204 +
205 + // bin      particle type
206 + // ---      -------------
207 + //  0        unmatched
208 + //  1        u
209 + //  2        d
210 + //  3        s
211 + //  4        c
212 + //  5        b
213 + //  6        t
214 + //  7        e
215 + //  8        mu
216 + //  9        tau
217 + // 10        nu
218 + // 11        g
219 + // 12        gamma
220 + // 13        Z
221 + // 14        W
222 + // 15        light meson
223 + // 16        K meson
224 + // 17        D meson
225 + // 18        B meson
226 + // 19        light baryon
227 + // 20        strange baryon
228 + // 21        charm baryon
229 + // 22        bottom baryon
230 + // 23        other
231 +
232 +      vector<TString> labelArray;
233 +      labelArray.push_back("unmatched");
234 +      labelArray.push_back("u");
235 +      labelArray.push_back("d");
236 +      labelArray.push_back("s");
237 +      labelArray.push_back("c");
238 +      labelArray.push_back("b");
239 +      labelArray.push_back("t");
240 +      labelArray.push_back("e");
241 +      labelArray.push_back("#mu");
242 +      labelArray.push_back("#tau");
243 +      labelArray.push_back("#nu");
244 +      labelArray.push_back("g");
245 +      labelArray.push_back("#gamma");
246 +      labelArray.push_back("Z");
247 +      labelArray.push_back("W");
248 +      labelArray.push_back("light meson");
249 +      labelArray.push_back("K meson");
250 +      labelArray.push_back("D meson");
251 +      labelArray.push_back("B meson");
252 +      labelArray.push_back("light baryon");
253 +      labelArray.push_back("strange baryon");
254 +      labelArray.push_back("charm baryon");
255 +      labelArray.push_back("bottom baryon");
256 +      labelArray.push_back("other");
257 +
258 +      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
259 +        oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
260 +      }
261      }
262      //book a histogram for the number of each object type to be plotted
263      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
# Line 171 | Line 283 | OSUAnalysis::OSUAnalysis (const edm::Par
283      }
284  
285  
286 +    
287 +
288 +
289      //get list of cuts for this channel
290      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
291  
# Line 181 | Line 296 | OSUAnalysis::OSUAnalysis (const edm::Par
296        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
297        tempCut.inputCollection = tempInputCollection;
298        if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
299 <        allNecessaryObjects.push_back(tempInputCollection);
299 >        objectsToGet.push_back(tempInputCollection);
300 >        objectsToCut.push_back(tempInputCollection);
301        }
302 <      else{//pair of objects, need to add them both to the things to allNecessaryObjects
302 >      else{//pair of objects, need to add them both to the things to objectsToGet
303          int dashIndex = tempInputCollection.find("-");
304          int spaceIndex = tempInputCollection.find(" ");
305          int secondWordLength = spaceIndex - dashIndex;
306 <        allNecessaryObjects.push_back(tempInputCollection);
307 <        allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
308 <        allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
306 >        objectsToGet.push_back(tempInputCollection);
307 >        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
308 >        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
309 >        objectsToCut.push_back(tempInputCollection);
310 >        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
311 >        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
312  
313        }
314  
# Line 259 | Line 378 | OSUAnalysis::OSUAnalysis (const edm::Par
378    }//end loop over channels
379  
380  
381 <  //make unique vector of objects we need to cut on (so we make sure to get them from the event)
382 <  sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
383 <  allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
381 >  //make unique vector of objects we need to get from the event
382 >  sort( objectsToGet.begin(), objectsToGet.end() );
383 >  objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
384 >  //make unique vector of objects we need to cut on
385 >  sort( objectsToCut.begin(), objectsToCut.end() );
386 >  objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
387  
388  
389   }
# Line 279 | Line 401 | void
401   OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
402   {
403  
282
404    // Retrieve necessary collections from the event.
405 <  edm::Handle<BNtriggerCollection> triggers;
406 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
405 >
406 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
407      event.getByLabel (triggers_, triggers);
408  
409 <  edm::Handle<BNjetCollection> jets;
289 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
409 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
410      event.getByLabel (jets_, jets);
411  
412 <  edm::Handle<BNmuonCollection> muons;
293 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
412 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
413      event.getByLabel (muons_, muons);
414  
415 <  edm::Handle<BNelectronCollection> electrons;
297 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
415 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
416      event.getByLabel (electrons_, electrons);
417  
418 <  edm::Handle<BNeventCollection> events;
301 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
418 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
419      event.getByLabel (events_, events);
420  
421 <  edm::Handle<BNtauCollection> taus;
305 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
421 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
422      event.getByLabel (taus_, taus);
423  
424 <  edm::Handle<BNmetCollection> mets;
309 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
424 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
425      event.getByLabel (mets_, mets);
426  
427 <  edm::Handle<BNtrackCollection> tracks;
313 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
427 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
428      event.getByLabel (tracks_, tracks);
429  
430 <  edm::Handle<BNgenjetCollection> genjets;
317 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
430 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
431      event.getByLabel (genjets_, genjets);
432  
433 <  edm::Handle<BNmcparticleCollection> mcparticles;
321 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
433 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
434      event.getByLabel (mcparticles_, mcparticles);
435  
436 <  edm::Handle<BNprimaryvertexCollection> primaryvertexs;
325 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
436 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
437      event.getByLabel (primaryvertexs_, primaryvertexs);
438  
439 <  edm::Handle<BNbxlumiCollection> bxlumis;
329 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
439 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
440      event.getByLabel (bxlumis_, bxlumis);
441  
442 <  edm::Handle<BNphotonCollection> photons;
333 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
442 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
443      event.getByLabel (photons_, photons);
444  
445 <  edm::Handle<BNsuperclusterCollection> superclusters;
337 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
445 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
446      event.getByLabel (superclusters_, superclusters);
447  
448  
449    //get pile-up event weight
450 <  double puScaleFactor = 0;
451 <  if(datasetType_ != "data")
450 >  double puScaleFactor = 1.00;
451 >  if(datasetType_ != "data"){
452      puScaleFactor = puWeight_->at (events->at (0).numTruePV);
453 <  else
454 <    puScaleFactor = 1.00;
453 >    //    cout << puScaleFactor << endl;
454 >  }
455 >
456  
457  
458    //loop over all channels
# Line 362 | Line 471 | OSUAnalysis::analyze (const edm::Event &
471      }
472  
473      //loop over all cuts
474 +
475 +
476 +
477      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
478        cut currentCut = currentChannel.cuts.at(currentCutIndex);
479  
480 <      for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
481 <        string currentObject = allNecessaryObjects.at(currentObjectIndex);
480 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
481 >        string currentObject = objectsToCut.at(currentObjectIndex);
482  
483 +        //initialize maps to get ready to set cuts
484          individualFlags[currentObject].push_back (vector<bool> ());
485          cumulativeFlags[currentObject].push_back (vector<bool> ());
486  
487 +      }
488 +      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
489 +        string currentObject = objectsToCut.at(currentObjectIndex);
490 +
491 +        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
492  
493          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
494          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
# Line 386 | Line 504 | OSUAnalysis::analyze (const edm::Event &
504          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
505          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
506  
507 <        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(),"muon-muon pairs");
508 <        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(),"electron-electron pairs");
509 <        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(),"electron-muon pairs");
507 >        
508 >        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
509 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
510 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
511 >                                                                   "muon-muon pairs");
512 >        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
513 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
514 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
515 >                                                                           "electron-electron pairs");
516 >        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
517 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
518 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
519 >                                                                       "electron-muon pairs");
520 >
521  
522        }
523  
# Line 397 | Line 526 | OSUAnalysis::analyze (const edm::Event &
526      }//end loop over all cuts
527  
528  
400
529      //use cumulative flags to apply cuts at event level
530  
531      bool eventPassedAllCuts = true;
# Line 406 | Line 534 | OSUAnalysis::analyze (const edm::Event &
534      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
535  
536  
537 +
538      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
539  
540        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 430 | Line 559 | OSUAnalysis::analyze (const edm::Event &
559      if(!eventPassedAllCuts)continue;
560  
561  
562 <
562 >    
563  
564      //set position of primary vertex in event, in order to calculate quantities relative to it
565 <    primaryVertex_ = 0;
566 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
567 <    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
568 <      if(!vertexFlags.at(vertexIndex)) continue;
569 <      primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex));
570 <      break;
565 >    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
566 >      vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
567 >      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
568 >        if(!vertexFlags.at(vertexIndex)) continue;
569 >        chosenPrimaryVertex = & primaryvertexs->at(vertexIndex);
570 >        break;
571 >      }
572 >    }
573 >    else {
574 >      chosenPrimaryVertex = & primaryvertexs->at(0);
575      }
576  
577  
# Line 450 | Line 583 | OSUAnalysis::analyze (const edm::Event &
583        if(currentHistogram.inputVariables.size() == 1){
584          TH1D* histo;
585          histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
586 +
587 +
588 +
589          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
590 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
590 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
591          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\
592                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\
593                                                                                         cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
# Line 476 | Line 612 | OSUAnalysis::analyze (const edm::Event &
612        else if(currentHistogram.inputVariables.size() == 2){
613          TH2D* histo;
614          histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
615 +
616 +
617 +
618          if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
619          else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
620          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
# Line 501 | Line 640 | OSUAnalysis::analyze (const edm::Event &
640        }
641      }
642  
504
643      //fills histograms with the sizes of collections
644      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
645        string currentObject = objectsToPlot.at(currentObjectIndex);
646  
647 <      if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
648 <      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
649 <      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
650 <      string tempCurrentObject = currentObject;
647 >      string objectToPlot = "";
648 >
649 >      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
650 >      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
651 >      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
652 >      else objectToPlot = currentObject;
653 >      string tempCurrentObject = objectToPlot;
654        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
655        string histoName = "num" + tempCurrentObject;
656  
657  
658 <      if(currentObject == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
659 <      else if(currentObject == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
660 <      else if(currentObject == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
661 <      else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
662 <      else if(currentObject == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
663 <      else if(currentObject == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
664 <      else if(currentObject == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
665 <      else if(currentObject == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
666 <      else if(currentObject == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
667 <      else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
668 <      else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
669 <      else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
670 <      else if(currentObject == "primaryvertexs"){
658 >
659 >
660 >      //set position of primary vertex in event, in order to calculate quantities relative to it
661 >      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
662 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
663 >        int numToPlot = 0;
664 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
665 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
666 >        }
667 >        if(objectToPlot == "primaryvertexs"){
668 >          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
669 >          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
670 >        }
671 >        else
672 >          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,puScaleFactor);        
673 >      }
674 >      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
675 >      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
676 >      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
677 >      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
678 >      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
679 >      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
680 >      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
681 >      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
682 >      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
683 >      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
684 >      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
685 >      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
686 >      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
687 >      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
688 >      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
689 >      else if(objectToPlot == "primaryvertexs"){
690          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
691          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
692        }
533      else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
534      else if(currentObject == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
535      else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
693  
694      }
695 +
696 +
697 +
698 +
699    } //end loop over channel
700  
701    masterCutFlow_->fillCutFlow(puScaleFactor);
# Line 736 | Line 897 | OSUAnalysis::valueLookup (const BNmuon*
897    else if(variable == "ecalIso") value = object->ecalIso;
898    else if(variable == "hcalIso") value = object->hcalIso;
899    else if(variable == "caloIso") value = object->caloIso;
900 <  else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
900 >  else if(variable == "trackIsDR03") value = object->trackIsoDR03;
901    else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
902    else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
903    else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
# Line 875 | Line 1036 | OSUAnalysis::valueLookup (const BNmuon*
1036    else if(variable == "time_ndof") value = object->time_ndof;
1037  
1038    //user-defined variables
1039 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1040 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1041 <  else if(variable == "detIso") value = (object->trackIso) / object->pt;
1039 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1040 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1041 >  else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1042    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1043    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1044 +
1045 +
1046 +
1047 +  else if(variable == "correctedD0VertexInEBPlus"){
1048 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1049 +    else value = -999;
1050 +  }
1051 +  else if(variable == "correctedD0VertexOutEBPlus"){
1052 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1053 +    else value = -999;
1054 +  }
1055 +  else if(variable == "correctedD0VertexEEPlus"){
1056 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1057 +    else value = -999;
1058 +  }
1059 +
1060 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1061 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1062 +    else value = -999;
1063 +  }
1064 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1065 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1066 +    else value = -999;
1067 +  }
1068 +  else if(variable == "correctedD0BeamspotEEPlus"){
1069 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1070 +    else value = -999;
1071 +  }
1072 +
1073 +  else if(variable == "correctedD0VertexInEBMinus"){
1074 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1075 +    else value = -999;
1076 +  }
1077 +  else if(variable == "correctedD0VertexOutEBMinus"){
1078 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1079 +    else value = -999;
1080 +  }
1081 +  else if(variable == "correctedD0VertexEEMinus"){
1082 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1083 +    else value = -999;
1084 +  }
1085 +
1086 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1087 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1088 +    else value = -999;
1089 +  }
1090 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1091 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1092 +    else value = -999;
1093 +  }
1094 +  else if(variable == "correctedD0BeamspotEEMinus"){
1095 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1096 +    else value = -999;
1097 +  }
1098 +
1099 +
1100 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1101 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1102 +    else value = -999;
1103 +  }
1104 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1105 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1106 +    else value = -999;
1107 +  }
1108 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1109 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1110 +    else value = -999;
1111 +  }
1112 +
1113 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1114 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1115 +    else value = -999;
1116 +  }
1117 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1118 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1119 +    else value = -999;
1120 +  }
1121 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1122 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1123 +    else value = -999;
1124 +  }
1125 +
1126 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1127 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1128 +    else value = -999;
1129 +  }
1130 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1131 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1132 +    else value = -999;
1133 +  }
1134 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1135 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1136 +    else value = -999;
1137 +  }
1138 +
1139 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1140 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1141 +    else value = -999;
1142 +  }
1143 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1144 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1145 +    else value = -999;
1146 +  }
1147 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1148 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1149 +    else value = -999;
1150 +  }
1151 +
1152 +
1153    else if(variable == "tightID") {
1154      value = object->isGlobalMuon > 0            \
1155        && object->isPFMuon > 0                   \
# Line 888 | Line 1158 | OSUAnalysis::valueLookup (const BNmuon*
1158        && object->numberOfMatchedStations > 1    \
1159        && fabs(object->correctedD0Vertex) < 0.2  \
1160        && fabs(object->correctedDZ) < 0.5        \
1161 <      && object->numberOfValidPixelHits > 0     \
1161 >      && object->numberOfValidPixelHits > 0             \
1162        && object->numberOfLayersWithMeasurement > 5;
893    
894
1163    }
1164    else if(variable == "tightIDdisplaced"){
1165      value = object->isGlobalMuon > 0            \
898      && object->isPFMuon > 0                   \
1166        && object->normalizedChi2 < 10            \
1167        && object->numberOfValidMuonHits > 0      \
1168        && object->numberOfMatchedStations > 1    \
# Line 903 | Line 1170 | OSUAnalysis::valueLookup (const BNmuon*
1170        && object->numberOfLayersWithMeasurement > 5;
1171    }
1172  
1173 +
1174 +
1175 +  else if(variable == "genMatchedId"){
1176 +    int index = getGenMatchedParticleIndex(object);
1177 +    if(index == -1) value = 0;
1178 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1179 +  }
1180 +  else if(variable == "genMatchedMotherId"){
1181 +    int index = getGenMatchedParticleIndex(object);
1182 +    if(index == -1) value = 0;
1183 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1184 +  }
1185 +  else if(variable == "genMatchedGrandmotherId"){
1186 +    int index = getGenMatchedParticleIndex(object);
1187 +    if(index == -1) value = 0;
1188 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1189 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1190 +      if(motherIndex == -1) value = 0;
1191 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1192 +    }
1193 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1194 +  }
1195 +
1196 +
1197 +
1198    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1199  
1200    value = applyFunction(function, value);
# Line 1073 | Line 1365 | OSUAnalysis::valueLookup (const BNelectr
1365    else if(variable == "passConvVeto") value = object->passConvVeto;
1366  
1367    //user-defined variables
1368 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1369 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1368 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1369 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1370    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1371    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1372  
1373  
1374 +  else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1375 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
1376 +    else value = -999;
1377 +  }
1378 +  else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
1379 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
1380 +    else value = -999;
1381 +  }
1382 +
1383 +
1384 +  else if(variable == "correctedD0VertexInEBPlus"){
1385 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1386 +    else value = -999;
1387 +  }
1388 +  else if(variable == "correctedD0VertexOutEBPlus"){
1389 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1390 +    else value = -999;
1391 +  }
1392 +  else if(variable == "correctedD0VertexEEPlus"){
1393 +    if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
1394 +    else value = -999;
1395 +  }
1396 +
1397 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1398 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1399 +    else value = -999;
1400 +  }
1401 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1402 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1403 +    else value = -999;
1404 +  }
1405 +  else if(variable == "correctedD0BeamspotEEPlus"){
1406 +    if(object->isEE && object->eta > 0) value = object->correctedD0;
1407 +    else value = -999;
1408 +  }
1409 +
1410 +  else if(variable == "correctedD0VertexInEBMinus"){
1411 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1412 +    else value = -999;
1413 +  }
1414 +  else if(variable == "correctedD0VertexOutEBMinus"){
1415 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1416 +    else value = -999;
1417 +  }
1418 +  else if(variable == "correctedD0VertexEEMinus"){
1419 +    if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
1420 +    else value = -999;
1421 +  }
1422 +
1423 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1424 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1425 +    else value = -999;
1426 +  }
1427 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1428 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1429 +    else value = -999;
1430 +  }
1431 +  else if(variable == "correctedD0BeamspotEEMinus"){
1432 +    if(object->isEE && object->eta < 0) value = object->correctedD0;
1433 +    else value = -999;
1434 +  }
1435 +
1436 +
1437 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1438 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1439 +    else value = -999;
1440 +  }
1441 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1442 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1443 +    else value = -999;
1444 +  }
1445 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1446 +    if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
1447 +    else value = -999;
1448 +  }
1449 +
1450 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1451 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1452 +    else value = -999;
1453 +  }
1454 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1455 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1456 +    else value = -999;
1457 +  }
1458 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1459 +    if(object->isEE && object->charge > 0) value = object->correctedD0;
1460 +    else value = -999;
1461 +  }
1462 +
1463 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1464 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1465 +    else value = -999;
1466 +  }
1467 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1468 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1469 +    else value = -999;
1470 +  }
1471 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1472 +    if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
1473 +    else value = -999;
1474 +  }
1475 +
1476 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1477 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1478 +    else value = -999;
1479 +  }
1480 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1481 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1482 +    else value = -999;
1483 +  }
1484 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1485 +    if(object->isEE && object->charge < 0) value = object->correctedD0;
1486 +    else value = -999;
1487 +  }
1488 +
1489 +
1490 +  else if(variable == "tightIDdisplaced"){
1491 +    if (object->isEB)
1492 +      {
1493 +        value = fabs(object->delEtaIn) < 0.004 \
1494 +          && fabs (object->delPhiIn) < 0.03 \
1495 +          && object->scSigmaIEtaIEta < 0.01 \
1496 +          && object->hadOverEm < 0.12 \
1497 +          && object->absInvEMinusInvPin < 0.05;
1498 +      }
1499 +    else
1500 +      {
1501 +        value = fabs (object->delEtaIn) < 0.005 \
1502 +          && fabs (object->delPhiIn) < 0.02 \
1503 +          && object->scSigmaIEtaIEta < 0.03 \
1504 +          && object->hadOverEm < 0.10 \
1505 +          && object->absInvEMinusInvPin < 0.05;
1506 +      }
1507 +  }
1508 +
1509 +  else if(variable == "genMatchedId"){
1510 +    int index = getGenMatchedParticleIndex(object);
1511 +    if(index == -1) value = 0;
1512 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1513 +  }
1514 +  else if(variable == "genMatchedMotherId"){
1515 +    int index = getGenMatchedParticleIndex(object);
1516 +    if(index == -1) value = 0;
1517 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1518 +  }
1519 +  else if(variable == "genMatchedGrandmotherId"){
1520 +    int index = getGenMatchedParticleIndex(object);
1521 +    if(index == -1) value = 0;
1522 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1523 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1524 +      if(motherIndex == -1) value = 0;
1525 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1526 +    }
1527 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1528 +  }
1529 +
1530 +
1531 +
1532    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1533  
1534    value = applyFunction(function, value);
# Line 1210 | Line 1660 | OSUAnalysis::valueLookup (const BNtau* o
1660    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1661  
1662  
1663 +  else if(variable == "genMatchedId"){
1664 +    int index = getGenMatchedParticleIndex(object);
1665 +    if(index == -1) value = 0;
1666 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1667 +  }
1668 +  else if(variable == "genMatchedMotherId"){
1669 +    int index = getGenMatchedParticleIndex(object);
1670 +    if(index == -1) value = 0;
1671 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1672 +  }
1673 +  else if(variable == "genMatchedGrandmotherId"){
1674 +    int index = getGenMatchedParticleIndex(object);
1675 +    if(index == -1) value = 0;
1676 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1677 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1678 +      if(motherIndex == -1) value = 0;
1679 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1680 +    }
1681 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1682 +  }
1683 +
1684 +
1685    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1686  
1687    value = applyFunction(function, value);
# Line 1293 | Line 1765 | double
1765   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1766  
1767    double value = 0.0;
1768 <
1768 >  double pMag = sqrt(object->pt * object->pt +
1769 >                         object->pz * object->pz);
1770 >  
1771    if(variable == "pt") value = object->pt;
1772    else if(variable == "px") value = object->px;
1773    else if(variable == "py") value = object->py;
# Line 1311 | Line 1785 | OSUAnalysis::valueLookup (const BNtrack*
1785    else if(variable == "charge") value = object->charge;
1786    else if(variable == "numValidHits") value = object->numValidHits;
1787    else if(variable == "isHighPurity") value = object->isHighPurity;
1788 +  //additional BNs info for disappTrks  
1789 +  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
1790 +  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
1791 +  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
1792 +  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
1793 +  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
1794 +  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
1795 +  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
1796 +  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
1797 +  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
1798 +  else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
1799 +  //user defined variables
1800 +  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;
1801 +  else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
1802 +  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
1803 +  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
1804 +  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
1805 +  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
1806 +
1807 +
1808 +  else if(variable == "genMatchedId"){
1809 +    int index = getGenMatchedParticleIndex(object);
1810 +    if(index == -1) value = 0;
1811 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1812 +  }
1813 +  else if(variable == "genMatchedMotherId"){
1814 +    int index = getGenMatchedParticleIndex(object);
1815 +    if(index == -1) value = 0;
1816 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1817 +  }
1818 +  else if(variable == "genMatchedGrandmotherId"){
1819 +    int index = getGenMatchedParticleIndex(object);
1820 +    if(index == -1) value = 0;
1821 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1822 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1823 +      if(motherIndex == -1) value = 0;
1824 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1825 +    }
1826 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1827 +  }
1828 +
1829  
1830  
1831    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1440 | Line 1955 | OSUAnalysis::valueLookup (const BNmcpart
1955  
1956    //user-defined variables
1957    else if (variable == "d0"){
1958 <    double vx = object->vx - primaryVertex_->x,
1959 <      vy = object->vy - primaryVertex_->y,
1958 >    double vx = object->vx - chosenPrimaryVertex->x,
1959 >      vy = object->vy - chosenPrimaryVertex->y,
1960        px = object->px,
1961        py = object->py,
1962        pt = object->pt;
1963      value = (-vx * py + vy * px) / pt;
1964    }
1965    else if (variable == "dz"){
1966 <    double vx = object->vx - primaryVertex_->x,
1967 <      vy = object->vy - primaryVertex_->y,
1968 <      vz = object->vz - primaryVertex_->z,
1966 >    double vx = object->vx - chosenPrimaryVertex->x,
1967 >      vy = object->vy - chosenPrimaryVertex->y,
1968 >      vz = object->vz - chosenPrimaryVertex->z,
1969        px = object->px,
1970        py = object->py,
1971        pz = object->pz,
1972        pt = object->pt;
1973      value = vz - (vx * px + vy * py)/pt * (pz/pt);
1974    }
1975 <
1975 >  else if(variable == "v0"){
1976 >    value = sqrt(object->vx*object->vx + object->vy*object->vy);
1977 >  }
1978 >  else if(variable == "deltaV0"){
1979 >    value = sqrt((object->vx-chosenPrimaryVertex->x)*(object->vx-chosenPrimaryVertex->x) + (object->vy-chosenPrimaryVertex->y)*(object->vy-chosenPrimaryVertex->y));
1980 >  }
1981 >  else if (variable == "deltaVx"){
1982 >    value = object->vx - chosenPrimaryVertex->x;
1983 >  }
1984 >  else if (variable == "deltaVy"){
1985 >    value = object->vy - chosenPrimaryVertex->y;
1986 >  }
1987 >  else if (variable == "deltaVz"){
1988 >    value = object->vz - chosenPrimaryVertex->z;
1989 >  }
1990  
1991  
1992    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1587 | Line 2116 | OSUAnalysis::valueLookup (const BNphoton
2116    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2117  
2118  
2119 +  else if(variable == "genMatchedId"){
2120 +    int index = getGenMatchedParticleIndex(object);
2121 +    if(index == -1) value = 0;
2122 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2123 +  }
2124 +  else if(variable == "genMatchedMotherId"){
2125 +    int index = getGenMatchedParticleIndex(object);
2126 +    if(index == -1) value = 0;
2127 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2128 +  }
2129 +  else if(variable == "genMatchedGrandmotherId"){
2130 +    int index = getGenMatchedParticleIndex(object);
2131 +    if(index == -1) value = 0;
2132 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2133 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2134 +      if(motherIndex == -1) value = 0;
2135 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2136 +    }
2137 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2138 +  }
2139 +
2140 +
2141    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2142  
2143    value = applyFunction(function, value);
# Line 1622 | Line 2173 | OSUAnalysis::valueLookup (const BNmuon*
2173  
2174    double value = 0.0;
2175  
2176 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2176 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2177 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2178    else if(variable == "invMass"){
2179      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2180      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2181 <    value = (fourVector1 + fourVector2).M();
2182 <  }
2181 >
2182 >    value = (fourVector1 + fourVector2).M();}
2183 >  else if(variable == "threeDAngle")
2184 >    {
2185 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2186 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2187 >      value = (threeVector1.Angle(threeVector2));
2188 >    }
2189 >
2190 >
2191 >
2192    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2193    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2194 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2195 <
2194 >  else if(variable == "d0Sign"){
2195 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2196 >    if(d0Sign < 0) value = -0.5;
2197 >    else if (d0Sign > 0) value = 0.5;
2198 >    else value = -999;
2199 >  }
2200 >  else if(variable == "muon1CorrectedD0Vertex"){
2201 >    value = object1->correctedD0Vertex;
2202 >  }
2203 >  else if(variable == "muon2CorrectedD0Vertex"){
2204 >    value = object2->correctedD0Vertex;
2205 >  }
2206    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2207  
2208 +
2209 +
2210 +
2211 +
2212 +
2213 +
2214 +
2215    value = applyFunction(function, value);
2216  
2217    return value;
# Line 1644 | Line 2222 | OSUAnalysis::valueLookup (const BNelectr
2222  
2223    double value = 0.0;
2224  
2225 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2225 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2226 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2227    else if(variable == "invMass"){
2228      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2229      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2230 <    value = (fourVector1 + fourVector2).M();
2231 <  }
2230 >
2231 >    value = (fourVector1 + fourVector2).M();}
2232 > else if(variable == "threeDAngle")
2233 >    {
2234 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2235 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2236 >      value = (threeVector1.Angle(threeVector2));
2237 >    }
2238 >  
2239 >
2240 >
2241 >
2242    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2243    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2244 +
2245    else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2246  
2247 +
2248 +
2249 +  else if(variable == "d0Sign"){
2250 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2251 +    if(d0Sign < 0) value = -0.5;
2252 +    else if (d0Sign > 0) value = 0.5;
2253 +    else value = -999;
2254 +  }
2255 +  else if(variable == "electron1CorrectedD0Vertex"){
2256 +    value = object1->correctedD0Vertex;
2257 +  }
2258 +  else if(variable == "electron2CorrectedD0Vertex"){
2259 +    value = object2->correctedD0Vertex;
2260 +  }
2261 +
2262    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2263  
2264    value = applyFunction(function, value);
# Line 1666 | Line 2271 | OSUAnalysis::valueLookup (const BNelectr
2271  
2272    double value = 0.0;
2273  
2274 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2274 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2275 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2276    else if(variable == "invMass"){
2277      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2278      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2279 <    value = (fourVector1 + fourVector2).M();
2280 <  }
2279 >
2280 >    value = (fourVector1 + fourVector2).M();}
2281 > else if(variable == "threeDAngle")
2282 >    {
2283 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2284 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2285 >      value = (threeVector1.Angle(threeVector2));
2286 >    }
2287 >
2288 >
2289    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2290    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2291 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2291 >  else if(variable == "d0Sign"){
2292 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2293 >    if(d0Sign < 0) value = -0.5;
2294 >    else if (d0Sign > 0) value = 0.5;
2295 >    else value = -999;
2296 >  }
2297 >  else if(variable == "electronCorrectedD0Vertex"){
2298 >    value = object1->correctedD0Vertex;
2299 >  }
2300 >  else if(variable == "muonCorrectedD0Vertex"){
2301 >    value = object2->correctedD0Vertex;
2302 >  }
2303 >  else if(variable == "electronCorrectedD0"){
2304 >    value = object1->correctedD0;
2305 >  }
2306 >  else if(variable == "muonCorrectedD0"){
2307 >    value = object2->correctedD0;
2308 >  }
2309 >
2310  
2311    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2312  
# Line 1684 | Line 2316 | OSUAnalysis::valueLookup (const BNelectr
2316   }
2317  
2318  
2319 + // Calculate the number of tracks in cone of DeltaR<0.5 around track1.  
2320 + // Return true iff no other tracks are found in this cone.  
2321 + int
2322 + OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
2323 +  for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
2324 +    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.  
2325 +    double deltaRtrk = deltaR(track1->eta, track2->eta, track1->phi, track2->phi);
2326 +    if(deltaRtrk < 0.5) return 0;
2327 +  }
2328 +  return 1;
2329 +  
2330 + }
2331 +  
2332 + //creates a map of the dead Ecal channels in the barrel and endcap
2333 + //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2334 + //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
2335 + void
2336 + OSUAnalysis::WriteDeadEcal (){
2337 +  double etaEcal, phiEcal;
2338 +  ifstream DeadEcalFile(deadEcalFile_);
2339 +  if(!DeadEcalFile) {
2340 +    cout << "Error: DeadEcalFile has not been found." << endl;
2341 +    return;
2342 +  }
2343 +  if(DeadEcalVec.size()!= 0){
2344 +    cout << "Error: DeadEcalVec has a nonzero size" << endl;
2345 +    return;
2346 +  }
2347 +  while(!DeadEcalFile.eof())
2348 +    {
2349 +      DeadEcalFile >> etaEcal >> phiEcal;
2350 +      DeadEcal newChan;
2351 +      newChan.etaEcal = etaEcal;
2352 +      newChan.phiEcal = phiEcal;
2353 +      DeadEcalVec.push_back(newChan);
2354 +    }
2355 +  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
2356 + }
2357 +
2358 + //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
2359 + int
2360 + OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
2361 +  int value = 0;
2362 +  if (DeadEcalVec.size() == 0) WriteDeadEcal();
2363 +  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
2364 +    double eta = ecal->etaEcal;
2365 +    double phi = ecal->phiEcal;
2366 +    if (deltaR(eta, track1->eta, phi, track1->phi)<0.05) {value = 1;}
2367 +    else {value = 0;}
2368 +  }
2369 +  return value;
2370 + }
2371 +
2372 +
2373 +
2374 +
2375   double
2376   OSUAnalysis::applyFunction(string function, double value){
2377  
2378    if(function == "abs") value = fabs(value);
2379 +  else if(function == "fabs") value = fabs(value);
2380 +
2381  
2382 +  else if(function == "") value = value;
2383 +  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
2384  
2385    return value;
2386  
# Line 1698 | Line 2390 | OSUAnalysis::applyFunction(string functi
2390   template <class InputCollection>
2391   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
2392  
2393 +
2394    for (uint object = 0; object != inputCollection->size(); object++){
2395  
2396 +
2397      bool decision = true;//object passes if this cut doesn't cut on that type of object
2398  
2399 +
2400      if(currentCut.inputCollection == inputType){
2401  
2402        vector<bool> subcutDecisions;
# Line 1723 | Line 2418 | void OSUAnalysis::setObjectFlags(cut &cu
2418      }
2419      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2420  
2421 +
2422      //set flags for objects that pass each cut AND all the previous cuts
2423      bool previousCumulativeFlag = true;
2424      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
# Line 1731 | Line 2427 | void OSUAnalysis::setObjectFlags(cut &cu
2427      }
2428      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2429  
2430 +
2431    }
2432  
2433   }
# Line 1738 | Line 2435 | void OSUAnalysis::setObjectFlags(cut &cu
2435  
2436   template <class InputCollection1, class InputCollection2>
2437   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2438 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){
2438 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2439  
2440  
2441    bool sameObjects = false;
2442    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2443  
2444 +
2445    int counter = 0;  
2446    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2447      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
# Line 1781 | Line 2479 | void OSUAnalysis::setObjectFlags(cut &cu
2479          if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2480          else{ previousCumulativeFlag = false; break;}
2481        }
2482 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2482 >      //apply flags for the components of the composite object as well
2483 >      bool currentCumulativeFlag = true;
2484 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
2485 >      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
2486 >      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
2487 >      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2488 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2489  
2490        counter++;      
2491      }
# Line 1824 | Line 2528 | void OSUAnalysis::fill1DHistogram(TH1* h
2528    bool sameObjects = false;
2529    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2530  
2531 <  int counter = 0;  
2531 >  int pairCounter = 0;  
2532    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2533      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2534        
# Line 1833 | Line 2537 | void OSUAnalysis::fill1DHistogram(TH1* h
2537        //only take objects which have passed all cuts and pairs which have passed all cuts
2538        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2539        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2540 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
2540 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
2541  
2542        string currentString = parameters.inputVariables.at(0);
2543        string inputVariable = "";
# Line 1850 | Line 2554 | void OSUAnalysis::fill1DHistogram(TH1* h
2554        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2555        histo->Fill(value,puScaleFactor);
2556  
2557 <      counter++;      
2557 >      pairCounter++;      
2558      }
2559    }
2560  
# Line 1903 | Line 2607 | void OSUAnalysis::fill2DHistogram(TH2* h
2607    bool sameObjects = false;
2608    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2609  
2610 <  int counter = 0;  
2610 >  int pairCounter = 0;  
2611    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2612      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2613        
# Line 1912 | Line 2616 | void OSUAnalysis::fill2DHistogram(TH2* h
2616        //only take objects which have passed all cuts and pairs which have passed all cuts
2617        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2618        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2619 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
2619 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
2620  
2621        string currentString = parameters.inputVariables.at(0);
2622        string inputVariable = "";
# Line 1943 | Line 2647 | void OSUAnalysis::fill2DHistogram(TH2* h
2647  
2648        histo->Fill(valueX,valueY,puScaleFactor);
2649  
2650 <      counter++;      
2650 >      pairCounter++;      
2651      }
2652    }
2653  
2654   }
2655  
2656  
2657 + template <class InputObject>
2658 + int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
2659 +
2660 +  int bestMatchIndex = -1;
2661 +  double bestMatchDeltaR = 999;
2662 +
2663 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2664 +
2665 +    double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
2666 +    if(currentDeltaR > 0.05) continue;
2667 +
2668 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2669 +      bestMatchIndex = mcparticle - mcparticles->begin();
2670 +      bestMatchDeltaR = currentDeltaR;
2671 +    }
2672 +
2673 +  }
2674 +
2675 +  return bestMatchIndex;
2676 +
2677 + }
2678 +
2679 +
2680 + int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
2681 +
2682 +  int bestMatchIndex = -1;
2683 +  double bestMatchDeltaR = 999;
2684 +
2685 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2686 +
2687 +    if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
2688 +
2689 +    double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
2690 +    if(currentDeltaR > 0.05) continue;
2691 +
2692 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2693 +      bestMatchIndex = mcparticle - mcparticles->begin();
2694 +      bestMatchDeltaR = currentDeltaR;
2695 +    }
2696 +
2697 +  }
2698 +
2699 +  return bestMatchIndex;
2700 + }
2701 +
2702 +
2703 + // bin      particle type
2704 + // ---      -------------
2705 + //  0        unmatched
2706 + //  1        u
2707 + //  2        d
2708 + //  3        s
2709 + //  4        c
2710 + //  5        b
2711 + //  6        t
2712 + //  7        e
2713 + //  8        mu
2714 + //  9        tau
2715 + // 10        nu
2716 + // 11        g
2717 + // 12        gamma
2718 + // 13        Z
2719 + // 14        W
2720 + // 15        light meson
2721 + // 16        K meson
2722 + // 17        D meson
2723 + // 18        B meson
2724 + // 19        light baryon
2725 + // 20        strange baryon
2726 + // 21        charm baryon
2727 + // 22        bottom baryon
2728 + // 23        other
2729 +
2730 + int OSUAnalysis::getPdgIdBinValue(int pdgId){
2731 +
2732 +  int binValue = -999;
2733 +  int absPdgId = fabs(pdgId);  
2734 +  if(pdgId == -1) binValue = 0;
2735 +  else if(absPdgId <= 6 ) binValue = absPdgId;
2736 +  else if(absPdgId == 11 ) binValue = 7;
2737 +  else if(absPdgId == 13 ) binValue = 8;
2738 +  else if(absPdgId == 15 ) binValue = 9;
2739 +  else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
2740 +  else if(absPdgId == 21 ) binValue = 11;
2741 +  else if(absPdgId == 22 ) binValue = 12;
2742 +  else if(absPdgId == 23 ) binValue = 13;
2743 +  else if(absPdgId == 24 ) binValue = 14;
2744 +  else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130  ) binValue = 15;
2745 +  else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400)  ) binValue = 16;
2746 +  else if(absPdgId > 400 && absPdgId < 500  ) binValue = 17;
2747 +  else if(absPdgId > 500 && absPdgId < 600  ) binValue = 18;
2748 +  else if(absPdgId > 1000 && absPdgId < 3000  ) binValue = 19;
2749 +  else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
2750 +  else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
2751 +  else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
2752 +
2753 +  else binValue = 23;
2754 +
2755 +  return binValue;
2756 +
2757 + }
2758 +
2759  
2760   DEFINE_FWK_MODULE(OSUAnalysis);
2761  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines