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.27 by qpython, Mon Mar 11 14:06:33 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 +
263      //book a histogram for the number of each object type to be plotted
264 +
265      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
266        string currentObject = objectsToPlot.at(currentObjectIndex);
267        int maxNum = 10;
268        if(currentObject == "mcparticles") maxNum = 50;
269        else if(currentObject == "primaryvertexs") maxNum = 50;
270 <      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
270 >      else if(currentObject == "muon-muon pairs")
271 >        {
272 >          currentObject = "dimuonPairs";
273 >        }
274        else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
275        else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
276  
# Line 171 | Line 288 | OSUAnalysis::OSUAnalysis (const edm::Par
288      }
289  
290  
291 +    
292 +
293 +
294      //get list of cuts for this channel
295      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
296  
# Line 181 | Line 301 | OSUAnalysis::OSUAnalysis (const edm::Par
301        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
302        tempCut.inputCollection = tempInputCollection;
303        if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
304 <        allNecessaryObjects.push_back(tempInputCollection);
304 >        objectsToGet.push_back(tempInputCollection);
305 >        objectsToCut.push_back(tempInputCollection);
306        }
307 <      else{//pair of objects, need to add them both to the things to allNecessaryObjects
307 >      else{//pair of objects, need to add them both to the things to objectsToGet
308          int dashIndex = tempInputCollection.find("-");
309          int spaceIndex = tempInputCollection.find(" ");
310          int secondWordLength = spaceIndex - dashIndex;
311 <        allNecessaryObjects.push_back(tempInputCollection);
312 <        allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
313 <        allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
311 >        objectsToGet.push_back(tempInputCollection);
312 >        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
313 >        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
314 >        objectsToCut.push_back(tempInputCollection);
315 >        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
316 >        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
317  
318        }
319  
# Line 259 | Line 383 | OSUAnalysis::OSUAnalysis (const edm::Par
383    }//end loop over channels
384  
385  
386 <  //make unique vector of objects we need to cut on (so we make sure to get them from the event)
387 <  sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
388 <  allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
386 >  //make unique vector of objects we need to get from the event
387 >  sort( objectsToGet.begin(), objectsToGet.end() );
388 >  objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
389 >  //make unique vector of objects we need to cut on
390 >  sort( objectsToCut.begin(), objectsToCut.end() );
391 >  objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
392  
393  
394   }
# Line 279 | Line 406 | void
406   OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
407   {
408  
282
409    // Retrieve necessary collections from the event.
410 <  edm::Handle<BNtriggerCollection> triggers;
411 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
410 >
411 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
412      event.getByLabel (triggers_, triggers);
413  
414 <  edm::Handle<BNjetCollection> jets;
289 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
414 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
415      event.getByLabel (jets_, jets);
416  
417 <  edm::Handle<BNmuonCollection> muons;
293 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
417 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
418      event.getByLabel (muons_, muons);
419  
420 <  edm::Handle<BNelectronCollection> electrons;
297 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
420 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
421      event.getByLabel (electrons_, electrons);
422  
423 <  edm::Handle<BNeventCollection> events;
301 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
423 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
424      event.getByLabel (events_, events);
425  
426 <  edm::Handle<BNtauCollection> taus;
305 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
426 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
427      event.getByLabel (taus_, taus);
428  
429 <  edm::Handle<BNmetCollection> mets;
309 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
429 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
430      event.getByLabel (mets_, mets);
431  
432 <  edm::Handle<BNtrackCollection> tracks;
313 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
432 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
433      event.getByLabel (tracks_, tracks);
434  
435 <  edm::Handle<BNgenjetCollection> genjets;
317 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
435 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
436      event.getByLabel (genjets_, genjets);
437  
438 <  edm::Handle<BNmcparticleCollection> mcparticles;
321 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
438 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
439      event.getByLabel (mcparticles_, mcparticles);
440  
441 <  edm::Handle<BNprimaryvertexCollection> primaryvertexs;
325 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
441 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
442      event.getByLabel (primaryvertexs_, primaryvertexs);
443  
444 <  edm::Handle<BNbxlumiCollection> bxlumis;
329 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
444 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
445      event.getByLabel (bxlumis_, bxlumis);
446  
447 <  edm::Handle<BNphotonCollection> photons;
333 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
447 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
448      event.getByLabel (photons_, photons);
449  
450 <  edm::Handle<BNsuperclusterCollection> superclusters;
337 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
450 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
451      event.getByLabel (superclusters_, superclusters);
452  
453  
454    //get pile-up event weight
455 <  double puScaleFactor = 0;
456 <  if(datasetType_ != "data")
455 >  double puScaleFactor = 1.00;
456 >  if(datasetType_ != "data"){
457      puScaleFactor = puWeight_->at (events->at (0).numTruePV);
458 <  else
459 <    puScaleFactor = 1.00;
458 >    //    cout << puScaleFactor << endl;
459 >  }
460 >
461  
462  
463    //loop over all channels
# Line 362 | Line 476 | OSUAnalysis::analyze (const edm::Event &
476      }
477  
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 != allNecessaryObjects.size(); currentObjectIndex++){
486 <        string currentObject = allNecessaryObjects.at(currentObjectIndex);
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
489          individualFlags[currentObject].push_back (vector<bool> ());
490          cumulativeFlags[currentObject].push_back (vector<bool> ());
491  
492 +      }
493 +      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
494 +        string currentObject = objectsToCut.at(currentObjectIndex);
495 +
496 +        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
497  
498          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
499          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
# Line 386 | Line 509 | OSUAnalysis::analyze (const edm::Event &
509          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
510          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
511  
512 <        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(),"muon-muon pairs");
513 <        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(),"electron-electron pairs");
514 <        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(),"electron-muon pairs");
512 >        
513 >        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
514 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
515 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
516 >                                                                   "muon-muon pairs");
517 >        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
518 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
519 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
520 >                                                                           "electron-electron pairs");
521 >        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
522 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
523 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
524 >                                                                       "electron-muon pairs");
525 >
526  
527        }
528  
# Line 397 | Line 531 | OSUAnalysis::analyze (const edm::Event &
531      }//end loop over all cuts
532  
533  
400
534      //use cumulative flags to apply cuts at event level
535  
536      bool eventPassedAllCuts = true;
# Line 406 | Line 539 | OSUAnalysis::analyze (const edm::Event &
539      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
540  
541  
542 +
543      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
544  
545        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 430 | Line 564 | OSUAnalysis::analyze (const edm::Event &
564      if(!eventPassedAllCuts)continue;
565  
566  
567 <
567 >    
568  
569      //set position of primary vertex in event, in order to calculate quantities relative to it
570 <    primaryVertex_ = 0;
571 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
572 <    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
573 <      if(!vertexFlags.at(vertexIndex)) continue;
574 <      primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex));
575 <      break;
570 >    if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
571 >      vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
572 >      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
573 >        if(!vertexFlags.at(vertexIndex)) continue;
574 >        chosenPrimaryVertex = & primaryvertexs->at(vertexIndex);
575 >        break;
576 >      }
577 >    }
578 >    else {
579 >      chosenPrimaryVertex = & primaryvertexs->at(0);
580      }
581  
582  
# Line 450 | Line 588 | OSUAnalysis::analyze (const edm::Event &
588        if(currentHistogram.inputVariables.size() == 1){
589          TH1D* histo;
590          histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
591 +
592 +
593 +
594          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
595 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
596 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\
597 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\
598 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
595 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
596 >        else if(currentHistogram.inputCollection == "muon-muon pairs")
597 >          {
598 >            fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
599 >                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
600 >                            
601 >                            cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
602 >
603 >          }
604          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
605          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
606                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
# Line 476 | Line 622 | OSUAnalysis::analyze (const edm::Event &
622        else if(currentHistogram.inputVariables.size() == 2){
623          TH2D* histo;
624          histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
625 +
626 +
627 +
628          if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
629          else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
630          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
# Line 501 | Line 650 | OSUAnalysis::analyze (const edm::Event &
650        }
651      }
652  
504
653      //fills histograms with the sizes of collections
654      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
655        string currentObject = objectsToPlot.at(currentObjectIndex);
656  
657 <      if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
658 <      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
659 <      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
660 <      string tempCurrentObject = currentObject;
657 >      string objectToPlot = "";
658 >
659 >      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
660 >      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
661 >      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
662 >      else objectToPlot = currentObject;
663 >      string tempCurrentObject = objectToPlot;
664        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
665        string histoName = "num" + tempCurrentObject;
666  
667  
668 <      if(currentObject == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
669 <      else if(currentObject == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
670 <      else if(currentObject == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
671 <      else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
672 <      else if(currentObject == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
673 <      else if(currentObject == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
674 <      else if(currentObject == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
675 <      else if(currentObject == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
676 <      else if(currentObject == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
677 <      else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
678 <      else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
679 <      else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
680 <      else if(currentObject == "primaryvertexs"){
668 >
669 >
670 >      //set position of primary vertex in event, in order to calculate quantities relative to it
671 >      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
672 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
673 >        int numToPlot = 0;
674 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
675 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
676 >        }
677 >        if(objectToPlot == "primaryvertexs"){
678 >          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
679 >          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
680 >        }
681 >        else
682 >          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,puScaleFactor);        
683 >      }
684 >      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
685 >      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
686 >      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
687 >      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
688 >      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
689 >      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
690 >      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
691 >      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
692 >      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
693 >      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
694 >      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
695 >      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
696 >      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
697 >      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
698 >      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
699 >      else if(objectToPlot == "primaryvertexs"){
700          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
701          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
702        }
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);
703  
704      }
705 +
706 +
707 +
708 +
709    } //end loop over channel
710  
711    masterCutFlow_->fillCutFlow(puScaleFactor);
# Line 736 | Line 907 | OSUAnalysis::valueLookup (const BNmuon*
907    else if(variable == "ecalIso") value = object->ecalIso;
908    else if(variable == "hcalIso") value = object->hcalIso;
909    else if(variable == "caloIso") value = object->caloIso;
910 <  else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
910 >  else if(variable == "trackIsDR03") value = object->trackIsoDR03;
911    else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
912    else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
913    else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
# Line 875 | Line 1046 | OSUAnalysis::valueLookup (const BNmuon*
1046    else if(variable == "time_ndof") value = object->time_ndof;
1047  
1048    //user-defined variables
1049 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1050 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1051 <  else if(variable == "detIso") value = (object->trackIso) / object->pt;
1049 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1050 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1051 >  else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1052    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1053    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1054 +
1055 +
1056 +
1057 +  else if(variable == "correctedD0VertexInEBPlus"){
1058 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1059 +    else value = -999;
1060 +  }
1061 +  else if(variable == "correctedD0VertexOutEBPlus"){
1062 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1063 +    else value = -999;
1064 +  }
1065 +  else if(variable == "correctedD0VertexEEPlus"){
1066 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1067 +    else value = -999;
1068 +  }
1069 +
1070 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1071 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1072 +    else value = -999;
1073 +  }
1074 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1075 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1076 +    else value = -999;
1077 +  }
1078 +  else if(variable == "correctedD0BeamspotEEPlus"){
1079 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1080 +    else value = -999;
1081 +  }
1082 +
1083 +  else if(variable == "correctedD0VertexInEBMinus"){
1084 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1085 +    else value = -999;
1086 +  }
1087 +  else if(variable == "correctedD0VertexOutEBMinus"){
1088 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1089 +    else value = -999;
1090 +  }
1091 +  else if(variable == "correctedD0VertexEEMinus"){
1092 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1093 +    else value = -999;
1094 +  }
1095 +
1096 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1097 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1098 +    else value = -999;
1099 +  }
1100 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1101 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1102 +    else value = -999;
1103 +  }
1104 +  else if(variable == "correctedD0BeamspotEEMinus"){
1105 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1106 +    else value = -999;
1107 +  }
1108 +
1109 +
1110 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1111 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1112 +    else value = -999;
1113 +  }
1114 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1115 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1116 +    else value = -999;
1117 +  }
1118 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1119 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1120 +    else value = -999;
1121 +  }
1122 +
1123 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1124 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1125 +    else value = -999;
1126 +  }
1127 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1128 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1129 +    else value = -999;
1130 +  }
1131 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1132 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1133 +    else value = -999;
1134 +  }
1135 +
1136 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1137 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1138 +    else value = -999;
1139 +  }
1140 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1141 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1142 +    else value = -999;
1143 +  }
1144 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1145 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1146 +    else value = -999;
1147 +  }
1148 +
1149 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1150 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1151 +    else value = -999;
1152 +  }
1153 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1154 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1155 +    else value = -999;
1156 +  }
1157 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1158 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1159 +    else value = -999;
1160 +  }
1161 +
1162 +
1163    else if(variable == "tightID") {
1164      value = object->isGlobalMuon > 0            \
1165        && object->isPFMuon > 0                   \
# Line 888 | Line 1168 | OSUAnalysis::valueLookup (const BNmuon*
1168        && object->numberOfMatchedStations > 1    \
1169        && fabs(object->correctedD0Vertex) < 0.2  \
1170        && fabs(object->correctedDZ) < 0.5        \
1171 <      && object->numberOfValidPixelHits > 0     \
1171 >      && object->numberOfValidPixelHits > 0             \
1172        && object->numberOfLayersWithMeasurement > 5;
893    
894
1173    }
1174    else if(variable == "tightIDdisplaced"){
1175      value = object->isGlobalMuon > 0            \
898      && object->isPFMuon > 0                   \
1176        && object->normalizedChi2 < 10            \
1177        && object->numberOfValidMuonHits > 0      \
1178        && object->numberOfMatchedStations > 1    \
# Line 903 | Line 1180 | OSUAnalysis::valueLookup (const BNmuon*
1180        && object->numberOfLayersWithMeasurement > 5;
1181    }
1182  
1183 +
1184 +
1185 +  else if(variable == "genMatchedId"){
1186 +    int index = getGenMatchedParticleIndex(object);
1187 +    if(index == -1) value = 0;
1188 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1189 +  }
1190 +  else if(variable == "genMatchedMotherId"){
1191 +    int index = getGenMatchedParticleIndex(object);
1192 +    if(index == -1) value = 0;
1193 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1194 +  }
1195 +  else if(variable == "genMatchedGrandmotherId"){
1196 +    int index = getGenMatchedParticleIndex(object);
1197 +    if(index == -1) value = 0;
1198 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1199 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1200 +      if(motherIndex == -1) value = 0;
1201 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1202 +    }
1203 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1204 +  }
1205 +
1206 +
1207 +
1208    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1209  
1210    value = applyFunction(function, value);
# Line 1073 | Line 1375 | OSUAnalysis::valueLookup (const BNelectr
1375    else if(variable == "passConvVeto") value = object->passConvVeto;
1376  
1377    //user-defined variables
1378 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1379 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1378 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1379 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenPrimaryVertex->xError, chosenPrimaryVertex->yError));
1380    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1381    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1382  
1383  
1384 +  else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1385 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
1386 +    else value = -999;
1387 +  }
1388 +  else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
1389 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
1390 +    else value = -999;
1391 +  }
1392 +
1393 +
1394 +  else if(variable == "correctedD0VertexInEBPlus"){
1395 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1396 +    else value = -999;
1397 +  }
1398 +  else if(variable == "correctedD0VertexOutEBPlus"){
1399 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1400 +    else value = -999;
1401 +  }
1402 +  else if(variable == "correctedD0VertexEEPlus"){
1403 +    if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
1404 +    else value = -999;
1405 +  }
1406 +
1407 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1408 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1409 +    else value = -999;
1410 +  }
1411 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1412 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1413 +    else value = -999;
1414 +  }
1415 +  else if(variable == "correctedD0BeamspotEEPlus"){
1416 +    if(object->isEE && object->eta > 0) value = object->correctedD0;
1417 +    else value = -999;
1418 +  }
1419 +
1420 +  else if(variable == "correctedD0VertexInEBMinus"){
1421 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1422 +    else value = -999;
1423 +  }
1424 +  else if(variable == "correctedD0VertexOutEBMinus"){
1425 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1426 +    else value = -999;
1427 +  }
1428 +  else if(variable == "correctedD0VertexEEMinus"){
1429 +    if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
1430 +    else value = -999;
1431 +  }
1432 +
1433 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1434 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1435 +    else value = -999;
1436 +  }
1437 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1438 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1439 +    else value = -999;
1440 +  }
1441 +  else if(variable == "correctedD0BeamspotEEMinus"){
1442 +    if(object->isEE && object->eta < 0) value = object->correctedD0;
1443 +    else value = -999;
1444 +  }
1445 +
1446 +
1447 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1448 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1449 +    else value = -999;
1450 +  }
1451 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1452 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1453 +    else value = -999;
1454 +  }
1455 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1456 +    if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
1457 +    else value = -999;
1458 +  }
1459 +
1460 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1461 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1462 +    else value = -999;
1463 +  }
1464 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1465 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1466 +    else value = -999;
1467 +  }
1468 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1469 +    if(object->isEE && object->charge > 0) value = object->correctedD0;
1470 +    else value = -999;
1471 +  }
1472 +
1473 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1474 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1475 +    else value = -999;
1476 +  }
1477 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1478 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1479 +    else value = -999;
1480 +  }
1481 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1482 +    if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
1483 +    else value = -999;
1484 +  }
1485 +
1486 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1487 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1488 +    else value = -999;
1489 +  }
1490 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1491 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1492 +    else value = -999;
1493 +  }
1494 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1495 +    if(object->isEE && object->charge < 0) value = object->correctedD0;
1496 +    else value = -999;
1497 +  }
1498 +
1499 +
1500 +  else if(variable == "tightIDdisplaced"){
1501 +    if (object->isEB)
1502 +      {
1503 +        value = fabs(object->delEtaIn) < 0.004 \
1504 +          && fabs (object->delPhiIn) < 0.03 \
1505 +          && object->scSigmaIEtaIEta < 0.01 \
1506 +          && object->hadOverEm < 0.12 \
1507 +          && object->absInvEMinusInvPin < 0.05;
1508 +      }
1509 +    else
1510 +      {
1511 +        value = fabs (object->delEtaIn) < 0.005 \
1512 +          && fabs (object->delPhiIn) < 0.02 \
1513 +          && object->scSigmaIEtaIEta < 0.03 \
1514 +          && object->hadOverEm < 0.10 \
1515 +          && object->absInvEMinusInvPin < 0.05;
1516 +      }
1517 +  }
1518 +
1519 +  else if(variable == "genMatchedId"){
1520 +    int index = getGenMatchedParticleIndex(object);
1521 +    if(index == -1) value = 0;
1522 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1523 +  }
1524 +  else if(variable == "genMatchedMotherId"){
1525 +    int index = getGenMatchedParticleIndex(object);
1526 +    if(index == -1) value = 0;
1527 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1528 +  }
1529 +  else if(variable == "genMatchedGrandmotherId"){
1530 +    int index = getGenMatchedParticleIndex(object);
1531 +    if(index == -1) value = 0;
1532 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1533 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1534 +      if(motherIndex == -1) value = 0;
1535 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1536 +    }
1537 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1538 +  }
1539 +
1540 +
1541 +
1542    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1543  
1544    value = applyFunction(function, value);
# Line 1210 | Line 1670 | OSUAnalysis::valueLookup (const BNtau* o
1670    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1671  
1672  
1673 +  else if(variable == "genMatchedId"){
1674 +    int index = getGenMatchedParticleIndex(object);
1675 +    if(index == -1) value = 0;
1676 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1677 +  }
1678 +  else if(variable == "genMatchedMotherId"){
1679 +    int index = getGenMatchedParticleIndex(object);
1680 +    if(index == -1) value = 0;
1681 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1682 +  }
1683 +  else if(variable == "genMatchedGrandmotherId"){
1684 +    int index = getGenMatchedParticleIndex(object);
1685 +    if(index == -1) value = 0;
1686 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1687 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1688 +      if(motherIndex == -1) value = 0;
1689 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1690 +    }
1691 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1692 +  }
1693 +
1694 +
1695    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1696  
1697    value = applyFunction(function, value);
# Line 1293 | Line 1775 | double
1775   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1776  
1777    double value = 0.0;
1778 <
1778 >  double pMag = sqrt(object->pt * object->pt +
1779 >                         object->pz * object->pz);
1780 >  
1781    if(variable == "pt") value = object->pt;
1782    else if(variable == "px") value = object->px;
1783    else if(variable == "py") value = object->py;
# Line 1313 | Line 1797 | OSUAnalysis::valueLookup (const BNtrack*
1797    else if(variable == "isHighPurity") value = object->isHighPurity;
1798  
1799  
1800 +  //additional BNs info for disappTrks  
1801 +  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
1802 +  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
1803 +  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
1804 +  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
1805 +  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
1806 +  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
1807 +  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
1808 +  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
1809 +  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
1810 +  else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
1811 +  //user defined variables
1812 +  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;
1813 +  else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
1814 +  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
1815 +  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
1816 +
1817 +
1818 +  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
1819 +  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
1820 +
1821 +
1822 +  else if(variable == "genMatchedId"){
1823 +    int index = getGenMatchedParticleIndex(object);
1824 +    if(index == -1) value = 0;
1825 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1826 +  }
1827 +  else if(variable == "genMatchedMotherId"){
1828 +    int index = getGenMatchedParticleIndex(object);
1829 +    if(index == -1) value = 0;
1830 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1831 +  }
1832 +  else if(variable == "genMatchedGrandmotherId"){
1833 +    int index = getGenMatchedParticleIndex(object);
1834 +    if(index == -1) value = 0;
1835 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1836 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1837 +      if(motherIndex == -1) value = 0;
1838 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1839 +    }
1840 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1841 +  }
1842 +
1843 +
1844 +
1845    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1846  
1847    value = applyFunction(function, value);
# Line 1440 | Line 1969 | OSUAnalysis::valueLookup (const BNmcpart
1969  
1970    //user-defined variables
1971    else if (variable == "d0"){
1972 <    double vx = object->vx - primaryVertex_->x,
1973 <      vy = object->vy - primaryVertex_->y,
1972 >    double vx = object->vx - chosenPrimaryVertex->x,
1973 >      vy = object->vy - chosenPrimaryVertex->y,
1974        px = object->px,
1975        py = object->py,
1976        pt = object->pt;
1977      value = (-vx * py + vy * px) / pt;
1978    }
1979    else if (variable == "dz"){
1980 <    double vx = object->vx - primaryVertex_->x,
1981 <      vy = object->vy - primaryVertex_->y,
1982 <      vz = object->vz - primaryVertex_->z,
1980 >    double vx = object->vx - chosenPrimaryVertex->x,
1981 >      vy = object->vy - chosenPrimaryVertex->y,
1982 >      vz = object->vz - chosenPrimaryVertex->z,
1983        px = object->px,
1984        py = object->py,
1985        pz = object->pz,
1986        pt = object->pt;
1987      value = vz - (vx * px + vy * py)/pt * (pz/pt);
1988    }
1989 <
1989 >  else if(variable == "v0"){
1990 >    value = sqrt(object->vx*object->vx + object->vy*object->vy);
1991 >  }
1992 >  else if(variable == "deltaV0"){
1993 >    value = sqrt((object->vx-chosenPrimaryVertex->x)*(object->vx-chosenPrimaryVertex->x) + (object->vy-chosenPrimaryVertex->y)*(object->vy-chosenPrimaryVertex->y));
1994 >  }
1995 >  else if (variable == "deltaVx"){
1996 >    value = object->vx - chosenPrimaryVertex->x;
1997 >  }
1998 >  else if (variable == "deltaVy"){
1999 >    value = object->vy - chosenPrimaryVertex->y;
2000 >  }
2001 >  else if (variable == "deltaVz"){
2002 >    value = object->vz - chosenPrimaryVertex->z;
2003 >  }
2004  
2005  
2006    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1587 | Line 2130 | OSUAnalysis::valueLookup (const BNphoton
2130    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2131  
2132  
2133 +  else if(variable == "genMatchedId"){
2134 +    int index = getGenMatchedParticleIndex(object);
2135 +    if(index == -1) value = 0;
2136 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2137 +  }
2138 +  else if(variable == "genMatchedMotherId"){
2139 +    int index = getGenMatchedParticleIndex(object);
2140 +    if(index == -1) value = 0;
2141 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2142 +  }
2143 +  else if(variable == "genMatchedGrandmotherId"){
2144 +    int index = getGenMatchedParticleIndex(object);
2145 +    if(index == -1) value = 0;
2146 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2147 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2148 +      if(motherIndex == -1) value = 0;
2149 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2150 +    }
2151 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2152 +  }
2153 +
2154 +
2155    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2156  
2157    value = applyFunction(function, value);
# Line 1622 | Line 2187 | OSUAnalysis::valueLookup (const BNmuon*
2187  
2188    double value = 0.0;
2189  
2190 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2190 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2191 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2192    else if(variable == "invMass"){
2193      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2194      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2195 <    value = (fourVector1 + fourVector2).M();
2196 <  }
2195 >
2196 >    value = (fourVector1 + fourVector2).M();}
2197 >
2198 >  else if(variable == "threeDAngle")
2199 >    {
2200 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2201 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2202 >      value = (threeVector1.Angle(threeVector2));
2203 >    }
2204 >  else if(variable == "alpha")
2205 >    {
2206 >      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
2207 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2208 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2209 >      value = (pi-threeVector1.Angle( threeVector2));
2210 >    }
2211 >
2212 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2213 >
2214 >
2215    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2216    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2217 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2218 <
2217 >  else if(variable == "d0Sign"){
2218 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2219 >    if(d0Sign < 0) value = -0.5;
2220 >    else if (d0Sign > 0) value = 0.5;
2221 >    else value = -999;
2222 >  }
2223 >  else if(variable == "muon1CorrectedD0Vertex"){
2224 >    value = object1->correctedD0Vertex;
2225 >  }
2226 >  else if(variable == "muon2CorrectedD0Vertex"){
2227 >    value = object2->correctedD0Vertex;
2228 >  }
2229 > else if(variable == "muon1timeAtIpInOut"){
2230 >    value = object1->timeAtIpInOut;
2231 >  }
2232 > else if(variable == "muon2timeAtIpInOut"){
2233 >    value = object2->timeAtIpInOut;
2234 >  }
2235    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2236  
2237 +
2238 +
2239 +
2240 +
2241 +
2242 +
2243 +
2244    value = applyFunction(function, value);
2245  
2246    return value;
# Line 1644 | Line 2251 | OSUAnalysis::valueLookup (const BNelectr
2251  
2252    double value = 0.0;
2253  
2254 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2254 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2255 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2256    else if(variable == "invMass"){
2257      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2258      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2259 <    value = (fourVector1 + fourVector2).M();
2260 <  }
2259 >
2260 >    value = (fourVector1 + fourVector2).M();}
2261 > else if(variable == "threeDAngle")
2262 >    {
2263 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2264 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2265 >      value = (threeVector1.Angle(threeVector2));
2266 >    }
2267 >  
2268 >
2269 >
2270 >
2271    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2272    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2273 +
2274    else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2275  
2276 +
2277 +
2278 +  else if(variable == "d0Sign"){
2279 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2280 +    if(d0Sign < 0) value = -0.5;
2281 +    else if (d0Sign > 0) value = 0.5;
2282 +    else value = -999;
2283 +  }
2284 +  else if(variable == "electron1CorrectedD0Vertex"){
2285 +    value = object1->correctedD0Vertex;
2286 +  }
2287 +  else if(variable == "electron2CorrectedD0Vertex"){
2288 +    value = object2->correctedD0Vertex;
2289 +  }
2290 +
2291    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2292  
2293    value = applyFunction(function, value);
# Line 1666 | Line 2300 | OSUAnalysis::valueLookup (const BNelectr
2300  
2301    double value = 0.0;
2302  
2303 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2303 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2304 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2305    else if(variable == "invMass"){
2306      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2307      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2308 <    value = (fourVector1 + fourVector2).M();
2309 <  }
2308 >
2309 >    value = (fourVector1 + fourVector2).M();}
2310 > else if(variable == "threeDAngle")
2311 >    {
2312 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2313 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2314 >      value = (threeVector1.Angle(threeVector2));
2315 >    }
2316 >
2317 >
2318    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2319    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2320 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2320 >  else if(variable == "d0Sign"){
2321 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2322 >    if(d0Sign < 0) value = -0.5;
2323 >    else if (d0Sign > 0) value = 0.5;
2324 >    else value = -999;
2325 >  }
2326 >  else if(variable == "electronCorrectedD0Vertex"){
2327 >    value = object1->correctedD0Vertex;
2328 >  }
2329 >  else if(variable == "muonCorrectedD0Vertex"){
2330 >    value = object2->correctedD0Vertex;
2331 >  }
2332 >  else if(variable == "electronCorrectedD0"){
2333 >    value = object1->correctedD0;
2334 >  }
2335 >  else if(variable == "muonCorrectedD0"){
2336 >    value = object2->correctedD0;
2337 >  }
2338 >
2339  
2340    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2341  
# Line 1684 | Line 2345 | OSUAnalysis::valueLookup (const BNelectr
2345   }
2346  
2347  
2348 + // Calculate the number of tracks in cone of DeltaR<0.5 around track1.  
2349 + // Return true iff no other tracks are found in this cone.  
2350 + int
2351 + OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
2352 +  for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
2353 +    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.  
2354 +    double deltaRtrk = deltaR(track1->eta, track2->eta, track1->phi, track2->phi);
2355 +    if(deltaRtrk < 0.5) return 0;
2356 +  }
2357 +  return 1;
2358 +  
2359 + }
2360 +  
2361 + //creates a map of the dead Ecal channels in the barrel and endcap
2362 + //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2363 + //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
2364 + void
2365 + OSUAnalysis::WriteDeadEcal (){
2366 +  double etaEcal, phiEcal;
2367 +  ifstream DeadEcalFile(deadEcalFile_);
2368 +  if(!DeadEcalFile) {
2369 +    cout << "Error: DeadEcalFile has not been found." << endl;
2370 +    return;
2371 +  }
2372 +  if(DeadEcalVec.size()!= 0){
2373 +    cout << "Error: DeadEcalVec has a nonzero size" << endl;
2374 +    return;
2375 +  }
2376 +  while(!DeadEcalFile.eof())
2377 +    {
2378 +      DeadEcalFile >> etaEcal >> phiEcal;
2379 +      DeadEcal newChan;
2380 +      newChan.etaEcal = etaEcal;
2381 +      newChan.phiEcal = phiEcal;
2382 +      DeadEcalVec.push_back(newChan);
2383 +    }
2384 +  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
2385 + }
2386 +
2387 + //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
2388 + int
2389 + OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
2390 +  int value = 0;
2391 +  if (DeadEcalVec.size() == 0) WriteDeadEcal();
2392 +  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
2393 +    double eta = ecal->etaEcal;
2394 +    double phi = ecal->phiEcal;
2395 +    if (deltaR(eta, track1->eta, phi, track1->phi)<0.05) {value = 1;}
2396 +    else {value = 0;}
2397 +  }
2398 +  return value;
2399 + }
2400 +
2401 +
2402 +
2403 +
2404   double
2405   OSUAnalysis::applyFunction(string function, double value){
2406  
2407    if(function == "abs") value = fabs(value);
2408 +  else if(function == "fabs") value = fabs(value);
2409 +  else if(function == "log10") value = log10(value);
2410 +  else if(function == "log") value = log10(value);
2411  
2412 +  else if(function == "") value = value;
2413 +  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
2414  
2415    return value;
2416  
# Line 1698 | Line 2420 | OSUAnalysis::applyFunction(string functi
2420   template <class InputCollection>
2421   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
2422  
2423 +
2424    for (uint object = 0; object != inputCollection->size(); object++){
2425  
2426 +
2427      bool decision = true;//object passes if this cut doesn't cut on that type of object
2428  
2429 +
2430      if(currentCut.inputCollection == inputType){
2431  
2432        vector<bool> subcutDecisions;
# Line 1723 | Line 2448 | void OSUAnalysis::setObjectFlags(cut &cu
2448      }
2449      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2450  
2451 +
2452      //set flags for objects that pass each cut AND all the previous cuts
2453      bool previousCumulativeFlag = true;
2454      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
# Line 1731 | Line 2457 | void OSUAnalysis::setObjectFlags(cut &cu
2457      }
2458      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2459  
2460 +
2461    }
2462  
2463   }
# Line 1738 | Line 2465 | void OSUAnalysis::setObjectFlags(cut &cu
2465  
2466   template <class InputCollection1, class InputCollection2>
2467   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2468 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){
2468 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2469  
2470  
2471    bool sameObjects = false;
2472    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2473  
2474 +
2475    int counter = 0;  
2476    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2477      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
# Line 1781 | Line 2509 | void OSUAnalysis::setObjectFlags(cut &cu
2509          if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2510          else{ previousCumulativeFlag = false; break;}
2511        }
2512 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2512 >      //apply flags for the components of the composite object as well
2513 >      bool currentCumulativeFlag = true;
2514 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
2515 >      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
2516 >      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
2517 >      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2518 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2519  
2520        counter++;      
2521      }
# Line 1824 | Line 2558 | void OSUAnalysis::fill1DHistogram(TH1* h
2558    bool sameObjects = false;
2559    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2560  
2561 <  int counter = 0;  
2561 >  int pairCounter = 0;  
2562    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2563      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2564        
# Line 1833 | Line 2567 | void OSUAnalysis::fill1DHistogram(TH1* h
2567        //only take objects which have passed all cuts and pairs which have passed all cuts
2568        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2569        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2570 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
2570 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
2571  
2572        string currentString = parameters.inputVariables.at(0);
2573        string inputVariable = "";
# Line 1850 | Line 2584 | void OSUAnalysis::fill1DHistogram(TH1* h
2584        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2585        histo->Fill(value,puScaleFactor);
2586  
2587 <      counter++;      
2587 >      pairCounter++;      
2588      }
2589    }
2590  
# Line 1903 | Line 2637 | void OSUAnalysis::fill2DHistogram(TH2* h
2637    bool sameObjects = false;
2638    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2639  
2640 <  int counter = 0;  
2640 >  int pairCounter = 0;  
2641    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2642      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2643        
# Line 1912 | Line 2646 | void OSUAnalysis::fill2DHistogram(TH2* h
2646        //only take objects which have passed all cuts and pairs which have passed all cuts
2647        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2648        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2649 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
2649 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
2650  
2651        string currentString = parameters.inputVariables.at(0);
2652        string inputVariable = "";
# Line 1943 | Line 2677 | void OSUAnalysis::fill2DHistogram(TH2* h
2677  
2678        histo->Fill(valueX,valueY,puScaleFactor);
2679  
2680 <      counter++;      
2680 >      pairCounter++;      
2681 >
2682 >    }
2683 >  }
2684 >
2685 > }
2686 >
2687 >
2688 > template <class InputObject>
2689 > int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
2690 >
2691 >  int bestMatchIndex = -1;
2692 >  double bestMatchDeltaR = 999;
2693 >
2694 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2695 >
2696 >    double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
2697 >    if(currentDeltaR > 0.05) continue;
2698 >
2699 >    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2700 >      bestMatchIndex = mcparticle - mcparticles->begin();
2701 >      bestMatchDeltaR = currentDeltaR;
2702 >    }
2703 >
2704 >  }
2705 >
2706 >  return bestMatchIndex;
2707 >
2708 > }
2709 >
2710 >
2711 > int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
2712 >
2713 >  int bestMatchIndex = -1;
2714 >  double bestMatchDeltaR = 999;
2715 >
2716 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2717 >
2718 >    if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
2719 >
2720 >    double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
2721 >    if(currentDeltaR > 0.05) continue;
2722 >
2723 >    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2724 >      bestMatchIndex = mcparticle - mcparticles->begin();
2725 >      bestMatchDeltaR = currentDeltaR;
2726      }
2727 +
2728    }
2729  
2730 +  return bestMatchIndex;
2731   }
2732  
2733  
2734 + // bin      particle type
2735 + // ---      -------------
2736 + //  0        unmatched
2737 + //  1        u
2738 + //  2        d
2739 + //  3        s
2740 + //  4        c
2741 + //  5        b
2742 + //  6        t
2743 + //  7        e
2744 + //  8        mu
2745 + //  9        tau
2746 + // 10        nu
2747 + // 11        g
2748 + // 12        gamma
2749 + // 13        Z
2750 + // 14        W
2751 + // 15        light meson
2752 + // 16        K meson
2753 + // 17        D meson
2754 + // 18        B meson
2755 + // 19        light baryon
2756 + // 20        strange baryon
2757 + // 21        charm baryon
2758 + // 22        bottom baryon
2759 + // 23        other
2760 +
2761 + int OSUAnalysis::getPdgIdBinValue(int pdgId){
2762 +
2763 +  int binValue = -999;
2764 +  int absPdgId = fabs(pdgId);  
2765 +  if(pdgId == -1) binValue = 0;
2766 +  else if(absPdgId <= 6 ) binValue = absPdgId;
2767 +  else if(absPdgId == 11 ) binValue = 7;
2768 +  else if(absPdgId == 13 ) binValue = 8;
2769 +  else if(absPdgId == 15 ) binValue = 9;
2770 +  else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
2771 +  else if(absPdgId == 21 ) binValue = 11;
2772 +  else if(absPdgId == 22 ) binValue = 12;
2773 +  else if(absPdgId == 23 ) binValue = 13;
2774 +  else if(absPdgId == 24 ) binValue = 14;
2775 +  else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130  ) binValue = 15;
2776 +  else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400)  ) binValue = 16;
2777 +  else if(absPdgId > 400 && absPdgId < 500  ) binValue = 17;
2778 +  else if(absPdgId > 500 && absPdgId < 600  ) binValue = 18;
2779 +  else if(absPdgId > 1000 && absPdgId < 3000  ) binValue = 19;
2780 +  else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
2781 +  else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
2782 +  else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
2783 +
2784 +  else binValue = 23;
2785 +
2786 +  return binValue;
2787 +
2788 + }
2789 +
2790  
2791   DEFINE_FWK_MODULE(OSUAnalysis);
2792  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines