ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.46
Committed: Thu Apr 11 15:51:01 2013 UTC (12 years ago) by jbrinson
Content type: text/plain
Branch: MAIN
Changes since 1.45: +26 -1 lines
Log Message:
Added tau-track pair

File Contents

# Content
1 #include "OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h"
2
3 OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) :
4 // Retrieve parameters from the configuration file.
5 jets_ (cfg.getParameter<edm::InputTag> ("jets")),
6 muons_ (cfg.getParameter<edm::InputTag> ("muons")),
7 electrons_ (cfg.getParameter<edm::InputTag> ("electrons")),
8 events_ (cfg.getParameter<edm::InputTag> ("events")),
9 taus_ (cfg.getParameter<edm::InputTag> ("taus")),
10 mets_ (cfg.getParameter<edm::InputTag> ("mets")),
11 tracks_ (cfg.getParameter<edm::InputTag> ("tracks")),
12 genjets_ (cfg.getParameter<edm::InputTag> ("genjets")),
13 mcparticles_ (cfg.getParameter<edm::InputTag> ("mcparticles")),
14 stops_ (cfg.getParameter<edm::InputTag> ("stops")),
15 primaryvertexs_ (cfg.getParameter<edm::InputTag> ("primaryvertexs")),
16 bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
17 photons_ (cfg.getParameter<edm::InputTag> ("photons")),
18 superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
19 triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
20 puFile_ (cfg.getParameter<std::string> ("puFile")),
21 deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
22 muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
23 dataPU_ (cfg.getParameter<std::string> ("dataPU")),
24 electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
25 muonSF_ (cfg.getParameter<std::string> ("muonSF")),
26 dataset_ (cfg.getParameter<std::string> ("dataset")),
27 datasetType_ (cfg.getParameter<std::string> ("datasetType")),
28 channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
29 histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30 plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
31 doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
32 printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
33 useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
34 stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
35
36 {
37
38 TH1::SetDefaultSumw2 ();
39
40 //create pile-up reweighting object, if necessary
41 if(datasetType_ != "data") {
42 if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
43 // muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
44 // electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
45 }
46 #ifdef DISPLACED_SUSY
47 if (datasetType_ == "signalMC")
48 cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
49 #endif
50
51
52 // Construct Cutflow Objects. These store the results of cut decisions and
53 // handle filling cut flow histograms.
54 masterCutFlow_ = new CutFlow (fs_);
55 std::vector<TFileDirectory> directories;
56
57 //always get vertex collection so we can assign the primary vertex in the event
58 objectsToGet.push_back("primaryvertexs");
59
60 //always make the plot of number of primary verticex (to check pile-up reweighting)
61 objectsToPlot.push_back("primaryvertexs");
62
63 //always get the MC particles to do GEN-matching
64 objectsToGet.push_back("mcparticles");
65
66 //always get the event collection to do pile-up reweighting
67 objectsToGet.push_back("events");
68
69 //parse the histogram definitions
70 for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
71
72 string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
73 if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
74 if(tempInputCollection == "event-track pairs") tempInputCollection = "track-event pairs";
75 if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
76 objectsToGet.push_back(tempInputCollection);
77 objectsToPlot.push_back(tempInputCollection);
78 objectsToCut.push_back(tempInputCollection);
79 }
80 else{//pair of objects, need to add them both to the things to objectsToGet
81 int dashIndex = tempInputCollection.find("-");
82 int spaceIndex = tempInputCollection.find(" ");
83 int secondWordLength = spaceIndex - dashIndex;
84 objectsToGet.push_back(tempInputCollection);
85 objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
86 objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
87 objectsToPlot.push_back(tempInputCollection);
88 objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
89 objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
90 objectsToCut.push_back(tempInputCollection);
91 objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
92 objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
93
94 }
95
96 vector<edm::ParameterSet> histogramList_ (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
97
98 for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
99
100 histogram tempHistogram;
101 tempHistogram.inputCollection = tempInputCollection;
102 tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
103 tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
104 tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
105 tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
106
107 histograms.push_back(tempHistogram);
108
109 }
110 }
111 //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
112 sort( objectsToPlot.begin(), objectsToPlot.end() );
113 objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
114
115
116
117 //add histograms with the gen-matched id, mother id, and grandmother id
118 for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
119
120 string currentObject = objectsToPlot.at(currentObjectIndex);
121 if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
122
123 histogram tempIdHisto;
124 histogram tempMomIdHisto;
125 histogram tempGmaIdHisto;
126 histogram tempIdVsMomIdHisto;
127
128 tempIdHisto.inputCollection = currentObject;
129 tempMomIdHisto.inputCollection = currentObject;
130 tempGmaIdHisto.inputCollection = currentObject;
131 tempIdVsMomIdHisto.inputCollection = currentObject;
132
133 currentObject = currentObject.substr(0, currentObject.size()-1);
134 tempIdHisto.name = currentObject+"GenMatchId";
135 tempMomIdHisto.name = currentObject+"GenMatchMotherId";
136 tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
137 tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
138
139 currentObject.at(0) = toupper(currentObject.at(0));
140 tempIdHisto.title = currentObject+" Gen-matched Particle";
141 tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
142 tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
143 tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
144
145 int maxNum = 24;
146 vector<double> binVector;
147 binVector.push_back(maxNum);
148 binVector.push_back(0);
149 binVector.push_back(maxNum);
150
151 tempIdHisto.bins = binVector;
152 tempIdHisto.inputVariables.push_back("genMatchedId");
153 tempMomIdHisto.bins = binVector;
154 tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
155 tempGmaIdHisto.bins = binVector;
156 tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
157 binVector.push_back(maxNum);
158 binVector.push_back(0);
159 binVector.push_back(maxNum);
160 tempIdVsMomIdHisto.bins = binVector;
161 tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
162 tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
163
164 histograms.push_back(tempIdHisto);
165 histograms.push_back(tempMomIdHisto);
166 histograms.push_back(tempGmaIdHisto);
167 histograms.push_back(tempIdVsMomIdHisto);
168 }
169
170
171 channel tempChannel;
172 //loop over all channels (event selections)
173 for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
174
175 //get name of channel
176 string channelName (channels_.at(currentChannel).getParameter<string>("name"));
177 tempChannel.name = channelName;
178 TString channelLabel = channelName;
179
180 //set triggers for this channel
181 vector<string> triggerNames;
182 triggerNames.clear();
183 tempChannel.triggers.clear();
184 if(channels_.at(currentChannel).exists("triggers")){
185 triggerNames = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
186 for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
187 tempChannel.triggers.push_back(triggerNames.at(trigger));
188 objectsToGet.push_back("triggers");
189 }
190
191
192
193
194 //create cutFlow for this channel
195 cutFlows_.push_back (new CutFlow (fs_, channelName));
196
197 //book a directory in the output file with the name of the channel
198 TFileDirectory subDir = fs_->mkdir( channelName );
199 directories.push_back(subDir);
200
201 std::map<std::string, TH1D*> oneDhistoMap;
202 oneDHists_.push_back(oneDhistoMap);
203 std::map<std::string, TH2D*> twoDhistoMap;
204 twoDHists_.push_back(twoDhistoMap);
205
206
207
208 //book all histograms included in the configuration
209 for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
210 histogram currentHistogram = histograms.at(currentHistogramIndex);
211 int numBinsElements = currentHistogram.bins.size();
212 int numInputVariables = currentHistogram.inputVariables.size();
213
214 if(numBinsElements != 3 && numBinsElements !=6) {
215 std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
216 exit(0);
217 }
218 else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
219 std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
220 exit(0);
221 }
222 else if(numBinsElements == 3){
223 oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
224 }
225 else if(numBinsElements == 6){
226 twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
227
228 }
229
230
231 if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
232
233 // bin particle type
234 // --- -------------
235 // 0 unmatched
236 // 1 u
237 // 2 d
238 // 3 s
239 // 4 c
240 // 5 b
241 // 6 t
242 // 7 e
243 // 8 mu
244 // 9 tau
245 // 10 nu
246 // 11 g
247 // 12 gamma
248 // 13 Z
249 // 14 W
250 // 15 light meson
251 // 16 K meson
252 // 17 D meson
253 // 18 B meson
254 // 19 light baryon
255 // 20 strange baryon
256 // 21 charm baryon
257 // 22 bottom baryon
258 // 23 other
259
260 vector<TString> labelArray;
261 labelArray.push_back("unmatched");
262 labelArray.push_back("u");
263 labelArray.push_back("d");
264 labelArray.push_back("s");
265 labelArray.push_back("c");
266 labelArray.push_back("b");
267 labelArray.push_back("t");
268 labelArray.push_back("e");
269 labelArray.push_back("#mu");
270 labelArray.push_back("#tau");
271 labelArray.push_back("#nu");
272 labelArray.push_back("g");
273 labelArray.push_back("#gamma");
274 labelArray.push_back("Z");
275 labelArray.push_back("W");
276 labelArray.push_back("light meson");
277 labelArray.push_back("K meson");
278 labelArray.push_back("D meson");
279 labelArray.push_back("B meson");
280 labelArray.push_back("light baryon");
281 labelArray.push_back("strange baryon");
282 labelArray.push_back("charm baryon");
283 labelArray.push_back("bottom baryon");
284 labelArray.push_back("other");
285
286 for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
287 if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
288 oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
289 }
290 else {
291 twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
292 twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
293 }
294 }
295 if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
296 twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
297 twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
298 }
299
300 }
301
302 // Book a histogram for the number of each object type to be plotted.
303 // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
304 for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
305 string currentObject = objectsToPlot.at(currentObjectIndex);
306 int maxNum = 10;
307 if(currentObject == "mcparticles") maxNum = 50;
308 else if(currentObject == "primaryvertexs") maxNum = 50;
309 else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
310 else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
311 else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
312 else if(currentObject == "track-event pairs") currentObject = "trackEventPairs";
313 else if(currentObject == "electron-track pairs") currentObject = "electronTrackPairs";
314 else if(currentObject == "muon-track pairs") currentObject = "muonTrackPairs";
315 else if(currentObject == "muon-tau pairs") currentObject = "muonTauPairs";
316 else if(currentObject == "tau-tau pairs") currentObject = "ditauPairs";
317 else if(currentObject == "tau-track pairs") currentObject = "tauTrackPairs";
318 currentObject.at(0) = toupper(currentObject.at(0));
319 string histoName = "num" + currentObject;
320
321 if(histoName == "numPrimaryvertexs"){
322 string newHistoName = histoName + "BeforePileupCorrection";
323 oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
324 newHistoName = histoName + "AfterPileupCorrection";
325 oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
326 }
327 else
328 oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
329 }
330
331
332
333
334 //get list of cuts for this channel
335 vector<edm::ParameterSet> cuts_ (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
336
337 //loop over and parse all cuts
338 for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
339 cut tempCut;
340 //store input collection for cut
341 string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
342 tempCut.inputCollection = tempInputCollection;
343 if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
344 objectsToGet.push_back(tempInputCollection);
345 objectsToCut.push_back(tempInputCollection);
346 }
347 else{//pair of objects, need to add them both to the things to objectsToGet
348 int dashIndex = tempInputCollection.find("-");
349 int spaceIndex = tempInputCollection.find(" ");
350 int secondWordLength = spaceIndex - dashIndex;
351 objectsToGet.push_back(tempInputCollection);
352 objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
353 objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
354 objectsToCut.push_back(tempInputCollection);
355 objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
356 objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
357
358 }
359
360
361
362 //split cut string into parts and store them
363 string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
364 std::vector<string> cutStringVector = splitString(cutString);
365 if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
366 std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
367 exit(0);
368 }
369 tempCut.numSubcuts = (cutStringVector.size()+1)/4;
370 for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
371 int indexOffset = 4 * subcutIndex;
372 string currentVariableString = cutStringVector.at(indexOffset);
373 if(currentVariableString.find("(")==std::string::npos){
374 tempCut.functions.push_back("");//no function was specified
375 tempCut.variables.push_back(currentVariableString);// variable to cut on
376 }
377 else{
378 tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
379 string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
380 tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
381 }
382 tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
383 tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
384 if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
385 }
386
387 //get number of objects required to pass cut for event to pass
388 string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
389 std::vector<string> numberRequiredVector = splitString(numberRequiredString);
390 if(numberRequiredVector.size()!=2){
391 std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
392 exit(0);
393 }
394
395 int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
396 tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
397 tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
398
399
400 string tempCutName;
401 if(cuts_.at(currentCut).exists("alias")){
402 tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
403 }
404 else{
405 //construct string for cutflow table
406 bool plural = numberRequiredInt != 1;
407 string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
408 string cutName = numberRequiredString + " " + collectionString + " with " + cutString;
409 tempCutName = cutName;
410 }
411 tempCut.name = tempCutName;
412
413
414 tempChannel.cuts.push_back(tempCut);
415
416
417
418 }//end loop over cuts
419
420 channels.push_back(tempChannel);
421 tempChannel.cuts.clear();
422
423 }//end loop over channels
424
425
426 //make unique vector of objects we need to get from the event
427 sort( objectsToGet.begin(), objectsToGet.end() );
428 objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
429 //make unique vector of objects we need to cut on
430 sort( objectsToCut.begin(), objectsToCut.end() );
431 objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
432
433
434 }
435
436 OSUAnalysis::~OSUAnalysis ()
437 {
438 // Destroying the CutFlow objects causes the cut flow numbers and time
439 // information to be printed to standard output.
440 for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
441 delete cutFlows_.at(currentChannel);
442 }
443 }
444
445 void
446 OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
447 {
448
449 // Retrieve necessary collections from the event.
450
451 if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
452 event.getByLabel (triggers_, triggers);
453
454 if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
455 event.getByLabel (jets_, jets);
456
457 if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
458 event.getByLabel (muons_, muons);
459
460 if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
461 event.getByLabel (electrons_, electrons);
462
463 if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
464 event.getByLabel (events_, events);
465
466 if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
467 event.getByLabel (taus_, taus);
468
469 if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
470 event.getByLabel (mets_, mets);
471
472 if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
473 event.getByLabel (tracks_, tracks);
474
475 if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
476 event.getByLabel (genjets_, genjets);
477
478 if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
479 event.getByLabel (mcparticles_, mcparticles);
480
481 if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
482 event.getByLabel (primaryvertexs_, primaryvertexs);
483
484 if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
485 event.getByLabel (bxlumis_, bxlumis);
486
487 if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
488 event.getByLabel (photons_, photons);
489
490 if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
491 event.getByLabel (superclusters_, superclusters);
492
493 if (useTrackCaloRhoCorr_) {
494 // Used only for pile-up correction of by-hand calculation of isolation energy.
495 // This rho collection is not available in all BEANs.
496 // For description of rho values for different jet reconstruction algorithms, see
497 // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
498 event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
499 }
500
501
502 //get pile-up event weight
503 double scaleFactor = 1.00;
504 if(doPileupReweighting_ && datasetType_ != "data")
505 scaleFactor = puWeight_->at (events->at (0).numTruePV);
506
507 cTauScaleFactor_ = 1.0;
508 #ifdef DISPLACED_SUSY
509 if (datasetType_ == "signalMC")
510 cTauScaleFactor_ = cTauWeight_->at (event);
511 #endif
512 scaleFactor *= cTauScaleFactor_;
513
514 //loop over all channels
515
516 for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
517 channel currentChannel = channels.at(currentChannelIndex);
518
519 flagMap individualFlags;
520 counterMap passingCounter;
521 cumulativeFlags.clear ();
522
523 bool triggerDecision = true;
524 if(currentChannel.triggers.size() != 0){ //triggers specified
525 triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
526 cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
527 }
528
529 //loop over all cuts
530
531
532
533 for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
534 cut currentCut = currentChannel.cuts.at(currentCutIndex);
535
536 for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
537 string currentObject = objectsToCut.at(currentObjectIndex);
538
539 //initialize maps to get ready to set cuts
540 individualFlags[currentObject].push_back (vector<bool> ());
541 cumulativeFlags[currentObject].push_back (vector<bool> ());
542
543 }
544 for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
545 string currentObject = objectsToCut.at(currentObjectIndex);
546
547 int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
548
549
550 if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
551 else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
552 else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
553 else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
554 else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
555 else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
556 else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
557 else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
558 else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
559 else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
560 else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
561 else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
562 else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
563
564
565 else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
566 cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
567 cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
568 "muon-muon pairs");
569 else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
570 cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
571 cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
572 "electron-electron pairs");
573 else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
574 cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
575 cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
576 "electron-muon pairs");
577 else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
578 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
579 cumulativeFlags.at("events").at(flagsForPairCutsIndex),
580 "track-event pairs");
581 else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
582 cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
583 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
584 "electron-track pairs");
585 else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
586 cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
587 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
588 "muon-track pairs");
589 else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
590 cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
591 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
592 "muon-tau pairs");
593 else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(),
594 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
595 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
596 "tau-tau pairs");
597 else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
598 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
599 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
600 "tau-track pairs");
601
602
603 }
604
605
606
607 }//end loop over all cuts
608
609
610 //use cumulative flags to apply cuts at event level
611
612 bool eventPassedAllCuts = true;
613
614 //apply trigger (true if none were specified)
615 eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
616
617
618
619 for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
620
621 //loop over all objects and count how many passed the cumulative selection up to this point
622 cut currentCut = currentChannel.cuts.at(currentCutIndex);
623 int numberPassing = 0;
624
625 for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
626 if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
627 }
628
629 bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
630 cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
631
632 eventPassedAllCuts = eventPassedAllCuts && cutDecision;
633
634 }
635
636 // if(datasetType_ != "data") {
637 // scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
638 // scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
639 // }
640
641 cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
642
643
644
645 if(!eventPassedAllCuts)continue;
646
647 if (printEventInfo_) {
648 // Write information about event to screen, for testing purposes.
649 cout << "Event passed all cuts in channel " << currentChannel.name
650 << ": run=" << events->at(0).run
651 << " lumi=" << events->at(0).lumi
652 << " event=" << events->at(0).evt
653 << endl;
654 }
655
656
657 //filling histograms
658 for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
659 histogram currentHistogram = histograms.at(histogramIndex);
660
661 if(currentHistogram.inputVariables.size() == 1){
662 TH1D* histo;
663 histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
664
665
666
667 if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
668 else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
669 else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
670 cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
671 cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
672 else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
673 else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
674 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
675 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
676 else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
677 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
678 cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
679 else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
680 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
681 cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
682 else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
683 cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
684 cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
685 else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
686 cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
687 cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
688 else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
689 cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
690 cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
691 else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
692 cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
693 cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
694
695 else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
696 else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
697 else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
698 else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
699 else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
700 else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
701 else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
702 else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
703 else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
704 else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
705 }
706 else if(currentHistogram.inputVariables.size() == 2){
707 TH2D* histo;
708 histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
709
710
711
712 if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
713 else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
714 else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
715 cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
716 cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
717 else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
718 else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
719 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
720 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
721 else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
722 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
723 cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
724 else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
725 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
726 cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
727 else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
728 cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
729 cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
730 else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
731 cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
732 cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
733 else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
734 cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
735 cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
736 else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
737 cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
738 cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
739 else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
740 else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
741 else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
742 else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
743 else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
744 cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
745 cumulativeFlags.at("track-event pairs").back(),scaleFactor);
746 else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
747 else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
748 else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
749 else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
750 else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
751 else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
752 }
753 }
754
755 //fills histograms with the sizes of collections
756 for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
757
758 string currentObject = objectsToPlot.at(currentObjectIndex);
759
760 string objectToPlot = "";
761
762 // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
763 if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
764 else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
765 else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
766 else if(currentObject == "electron-track pairs") objectToPlot = "electronTrackPairs";
767 else if(currentObject == "muon-track pairs") objectToPlot = "muonTrackPairs";
768 else if(currentObject == "muon-tau pairs") objectToPlot = "muonTauPairs";
769 else if(currentObject == "tau-tau pairs") objectToPlot = "ditauPairs";
770 else if(currentObject == "tau-track pairs") objectToPlot = "tauTrackPairs";
771 else if(currentObject == "track-event pairs") objectToPlot = "trackEventPairs";
772 else objectToPlot = currentObject;
773 string tempCurrentObject = objectToPlot;
774 tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
775 string histoName = "num" + tempCurrentObject;
776
777
778 //set position of primary vertex in event, in order to calculate quantities relative to it
779 if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
780 vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
781 int numToPlot = 0;
782 for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
783 if(lastCutFlags.at(currentFlag)) numToPlot++;
784 }
785 if(objectToPlot == "primaryvertexs"){
786 oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
787 oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
788 }
789 else {
790 oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
791 }
792 }
793 else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
794 else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
795 else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
796 else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
797 else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
798 else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
799 else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
800 else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
801 else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
802 else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
803 else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
804 else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
805 else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
806 else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
807 else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
808 else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
809 else if(objectToPlot == "primaryvertexs"){
810 oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
811 oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
812 }
813
814 } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
815
816 } //end loop over channel
817
818 masterCutFlow_->fillCutFlow(scaleFactor);
819
820 } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
821
822
823
824 bool
825 OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
826
827
828 if(comparison == ">") return testValue > cutValue;
829 else if(comparison == ">=") return testValue >= cutValue;
830 else if(comparison == "<") return testValue < cutValue;
831 else if(comparison == "<=") return testValue <= cutValue;
832 else if(comparison == "==") return testValue == cutValue;
833 else if(comparison == "=") return testValue == cutValue;
834 else if(comparison == "!=") return testValue != cutValue;
835 else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
836
837 }
838
839 bool
840 OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
841
842 bool triggerDecision = false;
843
844 for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
845 {
846 if(trigger->pass != 1) continue;
847 for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
848 {
849 if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
850 triggerDecision = true;
851 }
852 }
853 }
854 return triggerDecision;
855
856 }
857
858 std::vector<std::string>
859 OSUAnalysis::splitString (string inputString){
860
861 std::stringstream stringStream(inputString);
862 std::istream_iterator<std::string> begin(stringStream);
863 std::istream_iterator<std::string> end;
864 std::vector<std::string> stringVector(begin, end);
865 return stringVector;
866
867 }
868
869 double
870 OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
871
872 double value = 0.0;
873 if(variable == "energy") value = object->energy;
874 else if(variable == "et") value = object->et;
875 else if(variable == "pt") value = object->pt;
876 else if(variable == "px") value = object->px;
877 else if(variable == "py") value = object->py;
878 else if(variable == "pz") value = object->pz;
879 else if(variable == "phi") value = object->phi;
880 else if(variable == "eta") value = object->eta;
881 else if(variable == "theta") value = object->theta;
882 else if(variable == "Upt") value = object->Upt;
883 else if(variable == "Uenergy") value = object->Uenergy;
884 else if(variable == "L2pt") value = object->L2pt;
885 else if(variable == "L2L3pt") value = object->L2L3pt;
886 else if(variable == "L2L3respt") value = object->L2L3respt;
887 else if(variable == "respt") value = object->respt;
888 else if(variable == "EMfrac") value = object->EMfrac;
889 else if(variable == "Hadfrac") value = object->Hadfrac;
890 else if(variable == "charge") value = object->charge;
891 else if(variable == "mass") value = object->mass;
892 else if(variable == "area") value = object->area;
893 else if(variable == "fHPD") value = object->fHPD;
894 else if(variable == "approximatefHPD") value = object->approximatefHPD;
895 else if(variable == "genPartonET") value = object->genPartonET;
896 else if(variable == "genPartonPT") value = object->genPartonPT;
897 else if(variable == "genPartonEta") value = object->genPartonEta;
898 else if(variable == "genPartonPhi") value = object->genPartonPhi;
899 else if(variable == "genJetET") value = object->genJetET;
900 else if(variable == "genJetPT") value = object->genJetPT;
901 else if(variable == "genJetEta") value = object->genJetEta;
902 else if(variable == "genJetPhi") value = object->genJetPhi;
903 else if(variable == "btagTChighPur") value = object->btagTChighPur;
904 else if(variable == "btagTChighEff") value = object->btagTChighEff;
905 else if(variable == "btagJetProb") value = object->btagJetProb;
906 else if(variable == "btagJetBProb") value = object->btagJetBProb;
907 else if(variable == "btagSoftEle") value = object->btagSoftEle;
908 else if(variable == "btagSoftMuon") value = object->btagSoftMuon;
909 else if(variable == "btagSoftMuonNoIP") value = object->btagSoftMuonNoIP;
910 else if(variable == "btagSecVertex") value = object->btagSecVertex;
911 else if(variable == "btagSecVertexHighEff") value = object->btagSecVertexHighEff;
912 else if(variable == "btagSecVertexHighPur") value = object->btagSecVertexHighPur;
913 else if(variable == "btagCombinedSecVertex") value = object->btagCombinedSecVertex;
914 else if(variable == "btagCombinedSecVertexMVA") value = object->btagCombinedSecVertexMVA;
915 else if(variable == "btagSoftMuonByPt") value = object->btagSoftMuonByPt;
916 else if(variable == "btagSoftMuonByIP3") value = object->btagSoftMuonByIP3;
917 else if(variable == "btagSoftElectronByPt") value = object->btagSoftElectronByPt;
918 else if(variable == "btagSoftElectronByIP3") value = object->btagSoftElectronByIP3;
919 else if(variable == "n90Hits") value = object->n90Hits;
920 else if(variable == "hitsInN90") value = object->hitsInN90;
921 else if(variable == "chargedHadronEnergyFraction") value = object->chargedHadronEnergyFraction;
922 else if(variable == "neutralHadronEnergyFraction") value = object->neutralHadronEnergyFraction;
923 else if(variable == "chargedEmEnergyFraction") value = object->chargedEmEnergyFraction;
924 else if(variable == "neutralEmEnergyFraction") value = object->neutralEmEnergyFraction;
925 else if(variable == "fLong") value = object->fLong;
926 else if(variable == "fShort") value = object->fShort;
927 else if(variable == "etaetaMoment") value = object->etaetaMoment;
928 else if(variable == "phiphiMoment") value = object->phiphiMoment;
929 else if(variable == "JESunc") value = object->JESunc;
930 else if(variable == "JECuncUp") value = object->JECuncUp;
931 else if(variable == "JECuncDown") value = object->JECuncDown;
932 else if(variable == "puJetMVA_full") value = object->puJetMVA_full;
933 else if(variable == "puJetMVA_simple") value = object->puJetMVA_simple;
934 else if(variable == "puJetMVA_cutbased") value = object->puJetMVA_cutbased;
935 else if(variable == "dZ") value = object->dZ;
936 else if(variable == "dR2Mean") value = object->dR2Mean;
937 else if(variable == "dRMean") value = object->dRMean;
938 else if(variable == "frac01") value = object->frac01;
939 else if(variable == "frac02") value = object->frac02;
940 else if(variable == "frac03") value = object->frac03;
941 else if(variable == "frac04") value = object->frac04;
942 else if(variable == "frac05") value = object->frac05;
943 else if(variable == "frac06") value = object->frac06;
944 else if(variable == "frac07") value = object->frac07;
945 else if(variable == "beta") value = object->beta;
946 else if(variable == "betaStar") value = object->betaStar;
947 else if(variable == "betaClassic") value = object->betaClassic;
948 else if(variable == "betaStarClassic") value = object->betaStarClassic;
949 else if(variable == "ptD") value = object->ptD;
950 else if(variable == "nvtx") value = object->nvtx;
951 else if(variable == "d0") value = object->d0;
952 else if(variable == "leadCandPt") value = object->leadCandPt;
953 else if(variable == "leadCandVx") value = object->leadCandVx;
954 else if(variable == "leadCandVy") value = object->leadCandVy;
955 else if(variable == "leadCandVz") value = object->leadCandVz;
956 else if(variable == "leadCandDistFromPV") value = object->leadCandDistFromPV;
957 else if(variable == "flavour") value = object->flavour;
958 else if(variable == "Nconst") value = object->Nconst;
959 else if(variable == "jetIDMinimal") value = object->jetIDMinimal;
960 else if(variable == "jetIDLooseAOD") value = object->jetIDLooseAOD;
961 else if(variable == "jetIDLoose") value = object->jetIDLoose;
962 else if(variable == "jetIDTight") value = object->jetIDTight;
963 else if(variable == "genPartonId") value = object->genPartonId;
964 else if(variable == "genPartonMotherId") value = object->genPartonMotherId;
965 else if(variable == "genPartonMother0Id") value = object->genPartonMother0Id;
966 else if(variable == "genPartonMother1Id") value = object->genPartonMother1Id;
967 else if(variable == "genPartonGrandMotherId") value = object->genPartonGrandMotherId;
968 else if(variable == "genPartonGrandMother00Id") value = object->genPartonGrandMother00Id;
969 else if(variable == "genPartonGrandMother01Id") value = object->genPartonGrandMother01Id;
970 else if(variable == "genPartonGrandMother10Id") value = object->genPartonGrandMother10Id;
971 else if(variable == "genPartonGrandMother11Id") value = object->genPartonGrandMother11Id;
972 else if(variable == "chargedMultiplicity") value = object->chargedMultiplicity;
973 else if(variable == "neutralMultiplicity") value = object->neutralMultiplicity;
974 else if(variable == "nconstituents") value = object->nconstituents;
975 else if(variable == "nHit") value = object->nHit;
976 else if(variable == "puJetId_full") value = object->puJetId_full;
977 else if(variable == "puJetId_simple") value = object->puJetId_simple;
978 else if(variable == "puJetId_cutbased") value = object->puJetId_cutbased;
979 else if(variable == "puJetId_tight_full") value = object->puJetId_tight_full;
980 else if(variable == "puJetId_tight_simple") value = object->puJetId_tight_simple;
981 else if(variable == "puJetId_tight_cutbased") value = object->puJetId_tight_cutbased;
982 else if(variable == "puJetId_medium_full") value = object->puJetId_medium_full;
983 else if(variable == "puJetId_medium_simple") value = object->puJetId_medium_simple;
984 else if(variable == "puJetId_medium_cutbased") value = object->puJetId_medium_cutbased;
985 else if(variable == "puJetId_loose_full") value = object->puJetId_loose_full;
986 else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
987 else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
988
989
990 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
991
992 value = applyFunction(function, value);
993
994 return value;
995 }
996
997
998
999 double
1000 OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1001
1002 double value = 0.0;
1003 if(variable == "energy") value = object->energy;
1004 else if(variable == "et") value = object->et;
1005 else if(variable == "pt") value = object->pt;
1006 else if(variable == "px") value = object->px;
1007 else if(variable == "py") value = object->py;
1008 else if(variable == "pz") value = object->pz;
1009 else if(variable == "phi") value = object->phi;
1010 else if(variable == "eta") value = object->eta;
1011 else if(variable == "theta") value = object->theta;
1012 else if(variable == "trackIso") value = object->trackIso;
1013 else if(variable == "ecalIso") value = object->ecalIso;
1014 else if(variable == "hcalIso") value = object->hcalIso;
1015 else if(variable == "caloIso") value = object->caloIso;
1016 else if(variable == "trackIsDR03") value = object->trackIsoDR03;
1017 else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
1018 else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
1019 else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
1020 else if(variable == "trackVetoIsoDR03") value = object->trackVetoIsoDR03;
1021 else if(variable == "ecalVetoIsoDR03") value = object->ecalVetoIsoDR03;
1022 else if(variable == "hcalVetoIsoDR03") value = object->hcalVetoIsoDR03;
1023 else if(variable == "caloVetoIsoDR03") value = object->caloVetoIsoDR03;
1024 else if(variable == "trackIsoDR05") value = object->trackIsoDR05;
1025 else if(variable == "ecalIsoDR05") value = object->ecalIsoDR05;
1026 else if(variable == "hcalIsoDR05") value = object->hcalIsoDR05;
1027 else if(variable == "caloIsoDR05") value = object->caloIsoDR05;
1028 else if(variable == "trackVetoIsoDR05") value = object->trackVetoIsoDR05;
1029 else if(variable == "ecalVetoIsoDR05") value = object->ecalVetoIsoDR05;
1030 else if(variable == "hcalVetoIsoDR05") value = object->hcalVetoIsoDR05;
1031 else if(variable == "caloVetoIsoDR05") value = object->caloVetoIsoDR05;
1032 else if(variable == "hcalE") value = object->hcalE;
1033 else if(variable == "ecalE") value = object->ecalE;
1034 else if(variable == "genET") value = object->genET;
1035 else if(variable == "genPT") value = object->genPT;
1036 else if(variable == "genPhi") value = object->genPhi;
1037 else if(variable == "genEta") value = object->genEta;
1038 else if(variable == "genMotherET") value = object->genMotherET;
1039 else if(variable == "genMotherPT") value = object->genMotherPT;
1040 else if(variable == "genMotherPhi") value = object->genMotherPhi;
1041 else if(variable == "genMotherEta") value = object->genMotherEta;
1042 else if(variable == "vx") value = object->vx;
1043 else if(variable == "vy") value = object->vy;
1044 else if(variable == "vz") value = object->vz;
1045 else if(variable == "tkNormChi2") value = object->tkNormChi2;
1046 else if(variable == "tkPT") value = object->tkPT;
1047 else if(variable == "tkEta") value = object->tkEta;
1048 else if(variable == "tkPhi") value = object->tkPhi;
1049 else if(variable == "tkDZ") value = object->tkDZ;
1050 else if(variable == "tkD0") value = object->tkD0;
1051 else if(variable == "tkD0bs") value = object->tkD0bs;
1052 else if(variable == "tkD0err") value = object->tkD0err;
1053 else if(variable == "samNormChi2") value = object->samNormChi2;
1054 else if(variable == "samPT") value = object->samPT;
1055 else if(variable == "samEta") value = object->samEta;
1056 else if(variable == "samPhi") value = object->samPhi;
1057 else if(variable == "samDZ") value = object->samDZ;
1058 else if(variable == "samD0") value = object->samD0;
1059 else if(variable == "samD0bs") value = object->samD0bs;
1060 else if(variable == "samD0err") value = object->samD0err;
1061 else if(variable == "comNormChi2") value = object->comNormChi2;
1062 else if(variable == "comPT") value = object->comPT;
1063 else if(variable == "comEta") value = object->comEta;
1064 else if(variable == "comPhi") value = object->comPhi;
1065 else if(variable == "comDZ") value = object->comDZ;
1066 else if(variable == "comD0") value = object->comD0;
1067 else if(variable == "comD0bs") value = object->comD0bs;
1068 else if(variable == "comD0err") value = object->comD0err;
1069 else if(variable == "isolationR03emVetoEt") value = object->isolationR03emVetoEt;
1070 else if(variable == "isolationR03hadVetoEt") value = object->isolationR03hadVetoEt;
1071 else if(variable == "normalizedChi2") value = object->normalizedChi2;
1072 else if(variable == "dVzPVz") value = object->dVzPVz;
1073 else if(variable == "dB") value = object->dB;
1074 else if(variable == "ptErr") value = object->ptErr;
1075 else if(variable == "innerTrackNormChi2") value = object->innerTrackNormChi2;
1076 else if(variable == "correctedD0") value = object->correctedD0;
1077 else if(variable == "correctedD0Vertex") value = object->correctedD0Vertex;
1078 else if(variable == "correctedDZ") value = object->correctedDZ;
1079 else if(variable == "particleIso") value = object->particleIso;
1080 else if(variable == "chargedHadronIso") value = object->chargedHadronIso;
1081 else if(variable == "neutralHadronIso") value = object->neutralHadronIso;
1082 else if(variable == "photonIso") value = object->photonIso;
1083 else if(variable == "puChargedHadronIso") value = object->puChargedHadronIso;
1084 else if(variable == "chargedHadronIsoDR03") value = object->chargedHadronIsoDR03;
1085 else if(variable == "neutralHadronIsoDR03") value = object->neutralHadronIsoDR03;
1086 else if(variable == "photonIsoDR03") value = object->photonIsoDR03;
1087 else if(variable == "puChargedHadronIsoDR03") value = object->puChargedHadronIsoDR03;
1088 else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1089 else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1090 else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1091 else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1092 else if(variable == "rhoPrime") value = object->rhoPrime;
1093 else if(variable == "AEffDr03") value = object->AEffDr03;
1094 else if(variable == "AEffDr04") value = object->AEffDr04;
1095 else if(variable == "pfIsoR03SumChargedHadronPt") value = object->pfIsoR03SumChargedHadronPt;
1096 else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1097 else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1098 else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1099 else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1100 else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1101 else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
1102 else if(variable == "pfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt;
1103 else if(variable == "IP") value = object->IP;
1104 else if(variable == "IPError") value = object->IPError;
1105 else if(variable == "timeAtIpInOut") value = object->timeAtIpInOut;
1106 else if(variable == "timeAtIpInOutErr") value = object->timeAtIpInOutErr;
1107 else if(variable == "timeAtIpOutIn") value = object->timeAtIpOutIn;
1108 else if(variable == "timeAtIpOutInErr") value = object->timeAtIpOutInErr;
1109 else if(variable == "ecal_time") value = object->ecal_time;
1110 else if(variable == "hcal_time") value = object->hcal_time;
1111 else if(variable == "ecal_timeError") value = object->ecal_timeError;
1112 else if(variable == "hcal_timeError") value = object->hcal_timeError;
1113 else if(variable == "energy_ecal") value = object->energy_ecal;
1114 else if(variable == "energy_hcal") value = object->energy_hcal;
1115 else if(variable == "e3x3_ecal") value = object->e3x3_ecal;
1116 else if(variable == "e3x3_hcal") value = object->e3x3_hcal;
1117 else if(variable == "energyMax_ecal") value = object->energyMax_ecal;
1118 else if(variable == "energyMax_hcal") value = object->energyMax_hcal;
1119 else if(variable == "charge") value = object->charge;
1120 else if(variable == "IDGMPTight") value = object->IDGMPTight;
1121 else if(variable == "tkNumValidHits") value = object->tkNumValidHits;
1122 else if(variable == "tkCharge") value = object->tkCharge;
1123 else if(variable == "samNumValidHits") value = object->samNumValidHits;
1124 else if(variable == "samCharge") value = object->samCharge;
1125 else if(variable == "comNumValidHits") value = object->comNumValidHits;
1126 else if(variable == "comCharge") value = object->comCharge;
1127 else if(variable == "genId") value = object->genId;
1128 else if(variable == "genCharge") value = object->genCharge;
1129 else if(variable == "genNumberOfMothers") value = object->genNumberOfMothers;
1130 else if(variable == "genMotherId") value = object->genMotherId;
1131 else if(variable == "genMotherCharge") value = object->genMotherCharge;
1132 else if(variable == "genMother0Id") value = object->genMother0Id;
1133 else if(variable == "genMother1Id") value = object->genMother1Id;
1134 else if(variable == "genGrandMother00Id") value = object->genGrandMother00Id;
1135 else if(variable == "genGrandMother01Id") value = object->genGrandMother01Id;
1136 else if(variable == "genGrandMother10Id") value = object->genGrandMother10Id;
1137 else if(variable == "genGrandMother11Id") value = object->genGrandMother11Id;
1138 else if(variable == "isPFMuon") value = object->isPFMuon;
1139 else if(variable == "isGoodMuon_1StationTight") value = object->isGoodMuon_1StationTight;
1140 else if(variable == "isGlobalMuon") value = object->isGlobalMuon;
1141 else if(variable == "isTrackerMuon") value = object->isTrackerMuon;
1142 else if(variable == "isStandAloneMuon") value = object->isStandAloneMuon;
1143 else if(variable == "isGlobalMuonPromptTight") value = object->isGlobalMuonPromptTight;
1144 else if(variable == "numberOfValidMuonHits") value = object->numberOfValidMuonHits;
1145 else if(variable == "numberOfValidTrackerHits") value = object->numberOfValidTrackerHits;
1146 else if(variable == "numberOfLayersWithMeasurement") value = object->numberOfLayersWithMeasurement;
1147 else if(variable == "pixelLayersWithMeasurement") value = object->pixelLayersWithMeasurement;
1148 else if(variable == "numberOfMatches") value = object->numberOfMatches;
1149 else if(variable == "numberOfValidTrackerHitsInnerTrack") value = object->numberOfValidTrackerHitsInnerTrack;
1150 else if(variable == "numberOfValidPixelHits") value = object->numberOfValidPixelHits;
1151 else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations;
1152 else if(variable == "time_ndof") value = object->time_ndof;
1153
1154 //user-defined variables
1155 else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1156 else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1157 else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1158 else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1159 else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1160 else if(variable == "metMT") {
1161 const BNmet *met = chosenMET ();
1162 if (met)
1163 {
1164 TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1165 p2 (met->px, met->py, 0.0, met->pt);
1166
1167 value = (p1 + p2).Mt ();
1168 }
1169 else
1170 value = -999;
1171 }
1172
1173
1174
1175 else if(variable == "correctedD0VertexInEBPlus"){
1176 if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1177 else value = -999;
1178 }
1179 else if(variable == "correctedD0VertexOutEBPlus"){
1180 if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1181 else value = -999;
1182 }
1183 else if(variable == "correctedD0VertexEEPlus"){
1184 if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1185 else value = -999;
1186 }
1187
1188 else if(variable == "correctedD0BeamspotInEBPlus"){
1189 if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1190 else value = -999;
1191 }
1192 else if(variable == "correctedD0BeamspotOutEBPlus"){
1193 if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1194 else value = -999;
1195 }
1196 else if(variable == "correctedD0BeamspotEEPlus"){
1197 if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1198 else value = -999;
1199 }
1200
1201 else if(variable == "correctedD0VertexInEBMinus"){
1202 if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1203 else value = -999;
1204 }
1205 else if(variable == "correctedD0VertexOutEBMinus"){
1206 if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1207 else value = -999;
1208 }
1209 else if(variable == "correctedD0VertexEEMinus"){
1210 if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1211 else value = -999;
1212 }
1213
1214 else if(variable == "correctedD0BeamspotInEBMinus"){
1215 if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1216 else value = -999;
1217 }
1218 else if(variable == "correctedD0BeamspotOutEBMinus"){
1219 if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1220 else value = -999;
1221 }
1222 else if(variable == "correctedD0BeamspotEEMinus"){
1223 if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1224 else value = -999;
1225 }
1226
1227
1228 else if(variable == "correctedD0VertexInEBPositiveCharge"){
1229 if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1230 else value = -999;
1231 }
1232 else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1233 if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1234 else value = -999;
1235 }
1236 else if(variable == "correctedD0VertexEEPositiveCharge"){
1237 if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1238 else value = -999;
1239 }
1240
1241 else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1242 if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1243 else value = -999;
1244 }
1245 else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1246 if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1247 else value = -999;
1248 }
1249 else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1250 if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1251 else value = -999;
1252 }
1253
1254 else if(variable == "correctedD0VertexInEBNegativeCharge"){
1255 if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1256 else value = -999;
1257 }
1258 else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1259 if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1260 else value = -999;
1261 }
1262 else if(variable == "correctedD0VertexEENegativeCharge"){
1263 if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1264 else value = -999;
1265 }
1266
1267 else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1268 if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1269 else value = -999;
1270 }
1271 else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1272 if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1273 else value = -999;
1274 }
1275 else if(variable == "correctedD0BeamspotEENegativeCharge"){
1276 if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1277 else value = -999;
1278 }
1279
1280
1281 else if(variable == "tightID") {
1282 value = object->isGlobalMuon > 0 \
1283 && object->isPFMuon > 0 \
1284 && object->normalizedChi2 < 10 \
1285 && object->numberOfValidMuonHits > 0 \
1286 && object->numberOfMatchedStations > 1 \
1287 && fabs(object->correctedD0Vertex) < 0.2 \
1288 && fabs(object->correctedDZ) < 0.5 \
1289 && object->numberOfValidPixelHits > 0 \
1290 && object->numberOfLayersWithMeasurement > 5;
1291 }
1292 else if(variable == "tightIDdisplaced"){
1293 value = object->isGlobalMuon > 0 \
1294 && object->normalizedChi2 < 10 \
1295 && object->numberOfValidMuonHits > 0 \
1296 && object->numberOfMatchedStations > 1 \
1297 && object->numberOfValidPixelHits > 0 \
1298 && object->numberOfLayersWithMeasurement > 5;
1299 }
1300
1301 else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1302
1303 else if(variable == "genMatchedPdgId"){
1304 int index = getGenMatchedParticleIndex(object);
1305 if(index == -1) value = 0;
1306 else value = mcparticles->at(index).id;
1307 }
1308
1309 else if(variable == "genMatchedId"){
1310 int index = getGenMatchedParticleIndex(object);
1311 if(index == -1) value = 0;
1312 else value = getPdgIdBinValue(mcparticles->at(index).id);
1313 }
1314 else if(variable == "genMatchedMotherId"){
1315 int index = getGenMatchedParticleIndex(object);
1316 if(index == -1) value = 0;
1317 else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1318 }
1319 else if(variable == "genMatchedMotherIdReverse"){
1320 int index = getGenMatchedParticleIndex(object);
1321 if(index == -1) value = 23;
1322 else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1323 }
1324 else if(variable == "genMatchedGrandmotherId"){
1325 int index = getGenMatchedParticleIndex(object);
1326 if(index == -1) value = 0;
1327 else if(fabs(mcparticles->at(index).motherId) == 15){
1328 int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1329 if(motherIndex == -1) value = 0;
1330 else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1331 }
1332 else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1333 }
1334
1335
1336
1337 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1338
1339 value = applyFunction(function, value);
1340
1341 return value;
1342 }
1343
1344
1345 double
1346 OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1347
1348 double value = 0.0;
1349 if(variable == "energy") value = object->energy;
1350 else if(variable == "et") value = object->et;
1351 else if(variable == "gsfEt") value = object->gsfEt;
1352 else if(variable == "pt") value = object->pt;
1353 else if(variable == "px") value = object->px;
1354 else if(variable == "py") value = object->py;
1355 else if(variable == "pz") value = object->pz;
1356 else if(variable == "phi") value = object->phi;
1357 else if(variable == "eta") value = object->eta;
1358 else if(variable == "theta") value = object->theta;
1359 else if(variable == "pIn") value = object->pIn;
1360 else if(variable == "pOut") value = object->pOut;
1361 else if(variable == "EscOverPin") value = object->EscOverPin;
1362 else if(variable == "EseedOverPout") value = object->EseedOverPout;
1363 else if(variable == "hadOverEm") value = object->hadOverEm;
1364 else if(variable == "trackIso") value = object->trackIso;
1365 else if(variable == "ecalIso") value = object->ecalIso;
1366 else if(variable == "hcalIso") value = object->hcalIso;
1367 else if(variable == "caloIso") value = object->caloIso;
1368 else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
1369 else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
1370 else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
1371 else if(variable == "hcalIsoDR03depth1") value = object->hcalIsoDR03depth1;
1372 else if(variable == "hcalIsoDR03depth2") value = object->hcalIsoDR03depth2;
1373 else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
1374 else if(variable == "trackIsoDR04") value = object->trackIsoDR04;
1375 else if(variable == "ecalIsoDR04") value = object->ecalIsoDR04;
1376 else if(variable == "hcalIsoDR04") value = object->hcalIsoDR04;
1377 else if(variable == "hcalIsoDR04depth1") value = object->hcalIsoDR04depth1;
1378 else if(variable == "hcalIsoDR04depth2") value = object->hcalIsoDR04depth2;
1379 else if(variable == "caloIsoDR04") value = object->caloIsoDR04;
1380 else if(variable == "fbrem") value = object->fbrem;
1381 else if(variable == "absInvEMinusInvPin") value = object->absInvEMinusInvPin;
1382 else if(variable == "delPhiIn") value = object->delPhiIn;
1383 else if(variable == "delEtaIn") value = object->delEtaIn;
1384 else if(variable == "genET") value = object->genET;
1385 else if(variable == "genPT") value = object->genPT;
1386 else if(variable == "genPhi") value = object->genPhi;
1387 else if(variable == "genEta") value = object->genEta;
1388 else if(variable == "genMotherET") value = object->genMotherET;
1389 else if(variable == "genMotherPT") value = object->genMotherPT;
1390 else if(variable == "genMotherPhi") value = object->genMotherPhi;
1391 else if(variable == "genMotherEta") value = object->genMotherEta;
1392 else if(variable == "vx") value = object->vx;
1393 else if(variable == "vy") value = object->vy;
1394 else if(variable == "vz") value = object->vz;
1395 else if(variable == "scEnergy") value = object->scEnergy;
1396 else if(variable == "scRawEnergy") value = object->scRawEnergy;
1397 else if(variable == "scSigmaEtaEta") value = object->scSigmaEtaEta;
1398 else if(variable == "scSigmaIEtaIEta") value = object->scSigmaIEtaIEta;
1399 else if(variable == "scE1x5") value = object->scE1x5;
1400 else if(variable == "scE2x5Max") value = object->scE2x5Max;
1401 else if(variable == "scE5x5") value = object->scE5x5;
1402 else if(variable == "scEt") value = object->scEt;
1403 else if(variable == "scEta") value = object->scEta;
1404 else if(variable == "scPhi") value = object->scPhi;
1405 else if(variable == "scZ") value = object->scZ;
1406 else if(variable == "tkNormChi2") value = object->tkNormChi2;
1407 else if(variable == "tkPT") value = object->tkPT;
1408 else if(variable == "tkEta") value = object->tkEta;
1409 else if(variable == "tkPhi") value = object->tkPhi;
1410 else if(variable == "tkDZ") value = object->tkDZ;
1411 else if(variable == "tkD0") value = object->tkD0;
1412 else if(variable == "tkD0bs") value = object->tkD0bs;
1413 else if(variable == "tkD0err") value = object->tkD0err;
1414 else if(variable == "mva") value = object->mva;
1415 else if(variable == "mvaTrigV0") value = object->mvaTrigV0;
1416 else if(variable == "mvaNonTrigV0") value = object->mvaNonTrigV0;
1417 else if(variable == "dist") value = object->dist;
1418 else if(variable == "dcot") value = object->dcot;
1419 else if(variable == "convradius") value = object->convradius;
1420 else if(variable == "convPointX") value = object->convPointX;
1421 else if(variable == "convPointY") value = object->convPointY;
1422 else if(variable == "convPointZ") value = object->convPointZ;
1423 else if(variable == "eMax") value = object->eMax;
1424 else if(variable == "eLeft") value = object->eLeft;
1425 else if(variable == "eRight") value = object->eRight;
1426 else if(variable == "eTop") value = object->eTop;
1427 else if(variable == "eBottom") value = object->eBottom;
1428 else if(variable == "e3x3") value = object->e3x3;
1429 else if(variable == "swissCross") value = object->swissCross;
1430 else if(variable == "seedEnergy") value = object->seedEnergy;
1431 else if(variable == "seedTime") value = object->seedTime;
1432 else if(variable == "swissCrossNoI85") value = object->swissCrossNoI85;
1433 else if(variable == "swissCrossI85") value = object->swissCrossI85;
1434 else if(variable == "E2overE9NoI85") value = object->E2overE9NoI85;
1435 else if(variable == "E2overE9I85") value = object->E2overE9I85;
1436 else if(variable == "correctedD0") value = object->correctedD0;
1437 else if(variable == "correctedD0Vertex") value = object->correctedD0Vertex;
1438 else if(variable == "correctedDZ") value = object->correctedDZ;
1439 else if(variable == "particleIso") value = object->particleIso;
1440 else if(variable == "chargedHadronIso") value = object->chargedHadronIso;
1441 else if(variable == "neutralHadronIso") value = object->neutralHadronIso;
1442 else if(variable == "photonIso") value = object->photonIso;
1443 else if(variable == "puChargedHadronIso") value = object->puChargedHadronIso;
1444 else if(variable == "chargedHadronIsoDR03") value = object->chargedHadronIsoDR03;
1445 else if(variable == "neutralHadronIsoDR03") value = object->neutralHadronIsoDR03;
1446 else if(variable == "photonIsoDR03") value = object->photonIsoDR03;
1447 else if(variable == "puChargedHadronIsoDR03") value = object->puChargedHadronIsoDR03;
1448 else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1449 else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1450 else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1451 else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1452 else if(variable == "rhoPrime") value = object->rhoPrime;
1453 else if(variable == "AEffDr03") value = object->AEffDr03;
1454 else if(variable == "AEffDr04") value = object->AEffDr04;
1455 else if(variable == "IP") value = object->IP;
1456 else if(variable == "IPError") value = object->IPError;
1457 else if(variable == "charge") value = object->charge;
1458 else if(variable == "classification") value = object->classification;
1459 else if(variable == "genId") value = object->genId;
1460 else if(variable == "genCharge") value = object->genCharge;
1461 else if(variable == "genNumberOfMothers") value = object->genNumberOfMothers;
1462 else if(variable == "genMotherId") value = object->genMotherId;
1463 else if(variable == "genMotherCharge") value = object->genMotherCharge;
1464 else if(variable == "genMother0Id") value = object->genMother0Id;
1465 else if(variable == "genMother1Id") value = object->genMother1Id;
1466 else if(variable == "genGrandMother00Id") value = object->genGrandMother00Id;
1467 else if(variable == "genGrandMother01Id") value = object->genGrandMother01Id;
1468 else if(variable == "genGrandMother10Id") value = object->genGrandMother10Id;
1469 else if(variable == "genGrandMother11Id") value = object->genGrandMother11Id;
1470 else if(variable == "numClusters") value = object->numClusters;
1471 else if(variable == "tkNumValidHits") value = object->tkNumValidHits;
1472 else if(variable == "tkCharge") value = object->tkCharge;
1473 else if(variable == "gsfCharge") value = object->gsfCharge;
1474 else if(variable == "isEB") value = object->isEB;
1475 else if(variable == "isEE") value = object->isEE;
1476 else if(variable == "isGap") value = object->isGap;
1477 else if(variable == "isEBEEGap") value = object->isEBEEGap;
1478 else if(variable == "isEBGap") value = object->isEBGap;
1479 else if(variable == "isEEGap") value = object->isEEGap;
1480 else if(variable == "isEcalDriven") value = object->isEcalDriven;
1481 else if(variable == "isTrackerDriven") value = object->isTrackerDriven;
1482 else if(variable == "numberOfLostHits") value = object->numberOfLostHits;
1483 else if(variable == "numberOfExpectedInnerHits") value = object->numberOfExpectedInnerHits;
1484 else if(variable == "numberOfValidPixelHits") value = object->numberOfValidPixelHits;
1485 else if(variable == "numberOfValidPixelBarrelHits") value = object->numberOfValidPixelBarrelHits;
1486 else if(variable == "numberOfValidPixelEndcapHits") value = object->numberOfValidPixelEndcapHits;
1487 else if(variable == "isHEEP") value = object->isHEEP;
1488 else if(variable == "isHEEPnoEt") value = object->isHEEPnoEt;
1489 else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
1490 else if(variable == "eidRobustHighEnergy") value = object->eidRobustHighEnergy;
1491 else if(variable == "eidRobustLoose") value = object->eidRobustLoose;
1492 else if(variable == "eidRobustTight") value = object->eidRobustTight;
1493 else if(variable == "eidLoose") value = object->eidLoose;
1494 else if(variable == "eidTight") value = object->eidTight;
1495 else if(variable == "eidVeryLooseMC") value = object->eidVeryLooseMC;
1496 else if(variable == "eidLooseMC") value = object->eidLooseMC;
1497 else if(variable == "eidMediumMC") value = object->eidMediumMC;
1498 else if(variable == "eidTightMC") value = object->eidTightMC;
1499 else if(variable == "eidSuperTightMC") value = object->eidSuperTightMC;
1500 else if(variable == "eidHyperTight1MC") value = object->eidHyperTight1MC;
1501 else if(variable == "eidHyperTight2MC") value = object->eidHyperTight2MC;
1502 else if(variable == "eidHyperTight3MC") value = object->eidHyperTight3MC;
1503 else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC;
1504 else if(variable == "passConvVeto") value = object->passConvVeto;
1505
1506 //user-defined variables
1507 else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1508 else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1509 else if(variable == "detIso") value = (object->trackIso) / object->pt;
1510 else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1511 else if(variable == "metMT") {
1512 const BNmet *met = chosenMET ();
1513 if (met)
1514 {
1515 TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1516 p2 (met->px, met->py, 0.0, met->pt);
1517
1518 value = (p1 + p2).Mt ();
1519 }
1520 else
1521 value = -999;
1522 }
1523
1524 else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1525 if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
1526 else value = -999;
1527 }
1528 else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
1529 if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
1530 else value = -999;
1531 }
1532
1533 else if(variable == "correctedD0VertexInEBPlus"){
1534 if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1535 else value = -999;
1536 }
1537 else if(variable == "correctedD0VertexOutEBPlus"){
1538 if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1539 else value = -999;
1540 }
1541 else if(variable == "correctedD0VertexEEPlus"){
1542 if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
1543 else value = -999;
1544 }
1545
1546 else if(variable == "correctedD0BeamspotInEBPlus"){
1547 if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1548 else value = -999;
1549 }
1550 else if(variable == "correctedD0BeamspotOutEBPlus"){
1551 if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1552 else value = -999;
1553 }
1554 else if(variable == "correctedD0BeamspotEEPlus"){
1555 if(object->isEE && object->eta > 0) value = object->correctedD0;
1556 else value = -999;
1557 }
1558
1559 else if(variable == "correctedD0VertexInEBMinus"){
1560 if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1561 else value = -999;
1562 }
1563 else if(variable == "correctedD0VertexOutEBMinus"){
1564 if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1565 else value = -999;
1566 }
1567 else if(variable == "correctedD0VertexEEMinus"){
1568 if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
1569 else value = -999;
1570 }
1571
1572 else if(variable == "correctedD0BeamspotInEBMinus"){
1573 if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1574 else value = -999;
1575 }
1576 else if(variable == "correctedD0BeamspotOutEBMinus"){
1577 if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1578 else value = -999;
1579 }
1580 else if(variable == "correctedD0BeamspotEEMinus"){
1581 if(object->isEE && object->eta < 0) value = object->correctedD0;
1582 else value = -999;
1583 }
1584
1585 else if(variable == "tightID"){
1586 if (object->isEB)
1587 {
1588 value = fabs(object->delEtaIn) < 0.004 \
1589 && fabs (object->delPhiIn) < 0.03 \
1590 && object->scSigmaIEtaIEta < 0.01 \
1591 && object->hadOverEm < 0.12 \
1592 && fabs (object->correctedD0Vertex) < 0.02 \
1593 && fabs (object->correctedDZ) < 0.1 \
1594 && object->absInvEMinusInvPin < 0.05 \
1595 && object->passConvVeto;
1596 }
1597 else
1598 {
1599 value = fabs(object->delEtaIn) < 0.005 \
1600 && fabs (object->delPhiIn) < 0.02 \
1601 && object->scSigmaIEtaIEta < 0.03 \
1602 && object->hadOverEm < 0.10 \
1603 && fabs (object->correctedD0Vertex) < 0.02 \
1604 && fabs (object->correctedDZ) < 0.1 \
1605 && object->absInvEMinusInvPin < 0.05 \
1606 && object->passConvVeto;
1607 }
1608 }
1609
1610 else if(variable == "correctedD0VertexInEBPositiveCharge"){
1611 if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1612 else value = -999;
1613 }
1614 else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1615 if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1616 else value = -999;
1617 }
1618 else if(variable == "correctedD0VertexEEPositiveCharge"){
1619 if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
1620 else value = -999;
1621 }
1622
1623 else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1624 if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1625 else value = -999;
1626 }
1627 else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1628 if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1629 else value = -999;
1630 }
1631 else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1632 if(object->isEE && object->charge > 0) value = object->correctedD0;
1633 else value = -999;
1634 }
1635
1636 else if(variable == "correctedD0VertexInEBNegativeCharge"){
1637 if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1638 else value = -999;
1639 }
1640 else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1641 if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1642 else value = -999;
1643 }
1644 else if(variable == "correctedD0VertexEENegativeCharge"){
1645 if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
1646 else value = -999;
1647 }
1648
1649 else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1650 if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1651 else value = -999;
1652 }
1653 else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1654 if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1655 else value = -999;
1656 }
1657 else if(variable == "correctedD0BeamspotEENegativeCharge"){
1658 if(object->isEE && object->charge < 0) value = object->correctedD0;
1659 else value = -999;
1660 }
1661
1662
1663 else if(variable == "tightIDdisplaced"){
1664 if (object->isEB)
1665 {
1666 value = fabs(object->delEtaIn) < 0.004 \
1667 && fabs (object->delPhiIn) < 0.03 \
1668 && object->scSigmaIEtaIEta < 0.01 \
1669 && object->hadOverEm < 0.12 \
1670 && object->absInvEMinusInvPin < 0.05;
1671 }
1672 else
1673 {
1674 value = fabs (object->delEtaIn) < 0.005 \
1675 && fabs (object->delPhiIn) < 0.02 \
1676 && object->scSigmaIEtaIEta < 0.03 \
1677 && object->hadOverEm < 0.10 \
1678 && object->absInvEMinusInvPin < 0.05;
1679 }
1680 }
1681
1682
1683 else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1684
1685 else if(variable == "genMatchedPdgId"){
1686 int index = getGenMatchedParticleIndex(object);
1687 if(index == -1) value = 0;
1688 else value = mcparticles->at(index).id;
1689 }
1690
1691
1692 else if(variable == "genMatchedId"){
1693 int index = getGenMatchedParticleIndex(object);
1694 if(index == -1) value = 0;
1695 else value = getPdgIdBinValue(mcparticles->at(index).id);
1696 }
1697 else if(variable == "genMatchedMotherId"){
1698 int index = getGenMatchedParticleIndex(object);
1699 if(index == -1) value = 0;
1700 else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1701 }
1702 else if(variable == "genMatchedMotherIdReverse"){
1703 int index = getGenMatchedParticleIndex(object);
1704 if(index == -1) value = 23;
1705 else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1706 }
1707 else if(variable == "genMatchedGrandmotherId"){
1708 int index = getGenMatchedParticleIndex(object);
1709 if(index == -1) value = 0;
1710 else if(fabs(mcparticles->at(index).motherId) == 15){
1711 int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1712 if(motherIndex == -1) value = 0;
1713 else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1714 }
1715 else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1716 }
1717
1718
1719
1720 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1721
1722 value = applyFunction(function, value);
1723
1724 return value;
1725 }
1726
1727
1728 double
1729 OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
1730
1731 double value = 0.0;
1732
1733 if(variable == "weight") value = object->weight;
1734 else if(variable == "pthat") value = object->pthat;
1735 else if(variable == "qScale") value = object->qScale;
1736 else if(variable == "alphaQCD") value = object->alphaQCD;
1737 else if(variable == "alphaQED") value = object->alphaQED;
1738 else if(variable == "scalePDF") value = object->scalePDF;
1739 else if(variable == "x1") value = object->x1;
1740 else if(variable == "x2") value = object->x2;
1741 else if(variable == "xPDF1") value = object->xPDF1;
1742 else if(variable == "xPDF2") value = object->xPDF2;
1743 else if(variable == "BSx") value = object->BSx;
1744 else if(variable == "BSy") value = object->BSy;
1745 else if(variable == "BSz") value = object->BSz;
1746 else if(variable == "PVx") value = object->PVx;
1747 else if(variable == "PVy") value = object->PVy;
1748 else if(variable == "PVz") value = object->PVz;
1749 else if(variable == "bField") value = object->bField;
1750 else if(variable == "instLumi") value = object->instLumi;
1751 else if(variable == "bxLumi") value = object->bxLumi;
1752 else if(variable == "FilterOutScrapingFraction") value = object->FilterOutScrapingFraction;
1753 else if(variable == "sumNVtx") value = object->sumNVtx;
1754 else if(variable == "sumTrueNVtx") value = object->sumTrueNVtx;
1755 else if(variable == "nm1_true") value = object->nm1_true;
1756 else if(variable == "n0_true") value = object->n0_true;
1757 else if(variable == "np1_true") value = object->np1_true;
1758 else if(variable == "numTruePV") value = object->numTruePV;
1759 else if(variable == "Q2ScaleUpWgt") value = object->Q2ScaleUpWgt;
1760 else if(variable == "Q2ScaleDownWgt") value = object->Q2ScaleDownWgt;
1761 else if(variable == "rho_kt6PFJets") value = object->rho_kt6PFJets;
1762 else if(variable == "rho_kt6PFJetsCentralChargedPileUp") value = object->rho_kt6PFJetsCentralChargedPileUp;
1763 else if(variable == "rho_kt6PFJetsCentralNeutral") value = object->rho_kt6PFJetsCentralNeutral;
1764 else if(variable == "rho_kt6PFJetsCentralNeutralTight") value = object->rho_kt6PFJetsCentralNeutralTight;
1765 else if(variable == "run") value = object->run;
1766 else if(variable == "lumi") value = object->lumi;
1767 else if(variable == "sample") value = object->sample;
1768 else if(variable == "numPV") value = object->numPV;
1769 else if(variable == "W0decay") value = object->W0decay;
1770 else if(variable == "W1decay") value = object->W1decay;
1771 else if(variable == "Z0decay") value = object->Z0decay;
1772 else if(variable == "Z1decay") value = object->Z1decay;
1773 else if(variable == "H0decay") value = object->H0decay;
1774 else if(variable == "H1decay") value = object->H1decay;
1775 else if(variable == "hcalnoiseLoose") value = object->hcalnoiseLoose;
1776 else if(variable == "hcalnoiseTight") value = object->hcalnoiseTight;
1777 else if(variable == "GoodVertex") value = object->GoodVertex;
1778 else if(variable == "FilterOutScraping") value = object->FilterOutScraping;
1779 else if(variable == "HBHENoiseFilter") value = object->HBHENoiseFilter;
1780 else if(variable == "CSCLooseHaloId") value = object->CSCLooseHaloId;
1781 else if(variable == "CSCTightHaloId") value = object->CSCTightHaloId;
1782 else if(variable == "EcalLooseHaloId") value = object->EcalLooseHaloId;
1783 else if(variable == "EcalTightHaloId") value = object->EcalTightHaloId;
1784 else if(variable == "HcalLooseHaloId") value = object->HcalLooseHaloId;
1785 else if(variable == "HcalTightHaloId") value = object->HcalTightHaloId;
1786 else if(variable == "GlobalLooseHaloId") value = object->GlobalLooseHaloId;
1787 else if(variable == "GlobalTightHaloId") value = object->GlobalTightHaloId;
1788 else if(variable == "LooseId") value = object->LooseId;
1789 else if(variable == "TightId") value = object->TightId;
1790 else if(variable == "numGenPV") value = object->numGenPV;
1791 else if(variable == "nm1") value = object->nm1;
1792 else if(variable == "n0") value = object->n0;
1793 else if(variable == "np1") value = object->np1;
1794 else if(variable == "id1") value = object->id1;
1795 else if(variable == "id2") value = object->id2;
1796 else if(variable == "evt") value = object->evt;
1797 else if(variable == "puScaleFactor"){
1798 if(datasetType_ != "data")
1799 value = puWeight_->at (events->at (0).numTruePV);
1800 else
1801 value = 1.0;
1802 }
1803 else if(variable == "muonScaleFactor"){
1804 if(datasetType_ != "data")
1805 // value = muonSFWeight_->at (chosenMuon ()->eta);
1806 value = 1.0;
1807 else
1808 value = 1.0;
1809 }
1810 else if(variable == "electronScaleFactor"){
1811 if(datasetType_ != "data")
1812 // value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1813 value = 1.0;
1814 else
1815 value = 1.0;
1816 }
1817 else if(variable == "cTauScaleFactor")
1818 value = cTauScaleFactor_;
1819
1820 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1821
1822 value = applyFunction(function, value);
1823
1824 return value;
1825 }
1826
1827 double
1828 OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
1829
1830 double value = 0.0;
1831
1832 if(variable == "px") value = object->px;
1833 else if(variable == "py") value = object->py;
1834 else if(variable == "pz") value = object->pz;
1835 else if(variable == "energy") value = object->energy;
1836 else if(variable == "et") value = object->et;
1837 else if(variable == "pt") value = object->pt;
1838 else if(variable == "eta") value = object->eta;
1839 else if(variable == "phi") value = object->phi;
1840 else if(variable == "emFraction") value = object->emFraction;
1841 else if(variable == "leadingTrackPt") value = object->leadingTrackPt;
1842 else if(variable == "leadingTrackIpVtdxy") value = object->leadingTrackIpVtdxy;
1843 else if(variable == "leadingTrackIpVtdz") value = object->leadingTrackIpVtdz;
1844 else if(variable == "leadingTrackIpVtdxyError") value = object->leadingTrackIpVtdxyError;
1845 else if(variable == "leadingTrackIpVtdzError") value = object->leadingTrackIpVtdzError;
1846 else if(variable == "leadingTrackVx") value = object->leadingTrackVx;
1847 else if(variable == "leadingTrackVy") value = object->leadingTrackVy;
1848 else if(variable == "leadingTrackVz") value = object->leadingTrackVz;
1849 else if(variable == "leadingTrackValidHits") value = object->leadingTrackValidHits;
1850 else if(variable == "leadingTrackNormChiSqrd") value = object->leadingTrackNormChiSqrd;
1851 else if(variable == "numProngs") value = object->numProngs;
1852 else if(variable == "numSignalGammas") value = object->numSignalGammas;
1853 else if(variable == "numSignalNeutrals") value = object->numSignalNeutrals;
1854 else if(variable == "numSignalPiZeros") value = object->numSignalPiZeros;
1855 else if(variable == "decayMode") value = object->decayMode;
1856 else if(variable == "charge") value = object->charge;
1857 else if(variable == "inTheCracks") value = object->inTheCracks;
1858 else if(variable == "HPSagainstElectronLoose") value = object->HPSagainstElectronLoose;
1859 else if(variable == "HPSagainstElectronMVA") value = object->HPSagainstElectronMVA;
1860 else if(variable == "HPSagainstElectronMedium") value = object->HPSagainstElectronMedium;
1861 else if(variable == "HPSagainstElectronTight") value = object->HPSagainstElectronTight;
1862 else if(variable == "HPSagainstMuonLoose") value = object->HPSagainstMuonLoose;
1863 else if(variable == "HPSagainstMuonMedium") value = object->HPSagainstMuonMedium;
1864 else if(variable == "HPSagainstMuonTight") value = object->HPSagainstMuonTight;
1865 else if(variable == "HPSbyLooseCombinedIsolationDeltaBetaCorr") value = object->HPSbyLooseCombinedIsolationDeltaBetaCorr;
1866 else if(variable == "HPSbyMediumCombinedIsolationDeltaBetaCorr") value = object->HPSbyMediumCombinedIsolationDeltaBetaCorr;
1867 else if(variable == "HPSbyTightCombinedIsolationDeltaBetaCorr") value = object->HPSbyTightCombinedIsolationDeltaBetaCorr;
1868 else if(variable == "HPSbyVLooseCombinedIsolationDeltaBetaCorr") value = object->HPSbyVLooseCombinedIsolationDeltaBetaCorr;
1869 else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
1870 else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1871
1872
1873
1874 else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1875
1876 else if(variable == "genMatchedPdgId"){
1877 int index = getGenMatchedParticleIndex(object);
1878 if(index == -1) value = 0;
1879 else value = mcparticles->at(index).id;
1880 }
1881
1882 else if(variable == "genMatchedId"){
1883 int index = getGenMatchedParticleIndex(object);
1884 if(index == -1) value = 0;
1885 else value = getPdgIdBinValue(mcparticles->at(index).id);
1886 }
1887 else if(variable == "genMatchedMotherId"){
1888 int index = getGenMatchedParticleIndex(object);
1889 if(index == -1) value = 0;
1890 else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1891 }
1892 else if(variable == "genMatchedMotherIdReverse"){
1893 int index = getGenMatchedParticleIndex(object);
1894 if(index == -1) value = 23;
1895 else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1896 }
1897 else if(variable == "genMatchedGrandmotherId"){
1898 int index = getGenMatchedParticleIndex(object);
1899 if(index == -1) value = 0;
1900 else if(fabs(mcparticles->at(index).motherId) == 15){
1901 int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1902 if(motherIndex == -1) value = 0;
1903 else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1904 }
1905 else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1906 }
1907
1908
1909 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1910
1911 value = applyFunction(function, value);
1912
1913 return value;
1914 }
1915
1916 double
1917 OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
1918
1919 double value = 0.0;
1920
1921 if(variable == "et") value = object->et;
1922 else if(variable == "pt") value = object->pt;
1923 else if(variable == "px") value = object->px;
1924 else if(variable == "py") value = object->py;
1925 else if(variable == "phi") value = object->phi;
1926 else if(variable == "Upt") value = object->Upt;
1927 else if(variable == "Uphi") value = object->Uphi;
1928 else if(variable == "NeutralEMFraction") value = object->NeutralEMFraction;
1929 else if(variable == "NeutralHadEtFraction") value = object->NeutralHadEtFraction;
1930 else if(variable == "ChargedEMEtFraction") value = object->ChargedEMEtFraction;
1931 else if(variable == "ChargedHadEtFraction") value = object->ChargedHadEtFraction;
1932 else if(variable == "MuonEtFraction") value = object->MuonEtFraction;
1933 else if(variable == "Type6EtFraction") value = object->Type6EtFraction;
1934 else if(variable == "Type7EtFraction") value = object->Type7EtFraction;
1935 else if(variable == "genPT") value = object->genPT;
1936 else if(variable == "genPhi") value = object->genPhi;
1937 else if(variable == "muonCorEx") value = object->muonCorEx;
1938 else if(variable == "muonCorEy") value = object->muonCorEy;
1939 else if(variable == "jet20CorEx") value = object->jet20CorEx;
1940 else if(variable == "jet20CorEy") value = object->jet20CorEy;
1941 else if(variable == "jet1CorEx") value = object->jet1CorEx;
1942 else if(variable == "jet1CorEy") value = object->jet1CorEy;
1943 else if(variable == "sumET") value = object->sumET;
1944 else if(variable == "corSumET") value = object->corSumET;
1945 else if(variable == "mEtSig") value = object->mEtSig;
1946 else if(variable == "metSignificance") value = object->metSignificance;
1947 else if(variable == "significance") value = object->significance;
1948 else if(variable == "sigmaX2") value = object->sigmaX2;
1949 else if(variable == "sigmaY2") value = object->sigmaY2;
1950 else if(variable == "sigmaXY") value = object->sigmaXY;
1951 else if(variable == "sigmaYX") value = object->sigmaYX;
1952 else if(variable == "maxEtInEmTowers") value = object->maxEtInEmTowers;
1953 else if(variable == "emEtFraction") value = object->emEtFraction;
1954 else if(variable == "emEtInEB") value = object->emEtInEB;
1955 else if(variable == "emEtInEE") value = object->emEtInEE;
1956 else if(variable == "emEtInHF") value = object->emEtInHF;
1957 else if(variable == "maxEtInHadTowers") value = object->maxEtInHadTowers;
1958 else if(variable == "hadEtFraction") value = object->hadEtFraction;
1959 else if(variable == "hadEtInHB") value = object->hadEtInHB;
1960 else if(variable == "hadEtInHE") value = object->hadEtInHE;
1961 else if(variable == "hadEtInHF") value = object->hadEtInHF;
1962 else if(variable == "hadEtInHO") value = object->hadEtInHO;
1963 else if(variable == "UDeltaPx") value = object->UDeltaPx;
1964 else if(variable == "UDeltaPy") value = object->UDeltaPy;
1965 else if(variable == "UDeltaP") value = object->UDeltaP;
1966 else if(variable == "Uscale") value = object->Uscale;
1967 else if(variable == "type2corPx") value = object->type2corPx;
1968 else if(variable == "type2corPy") value = object->type2corPy;
1969 else if(variable == "T2pt") value = object->T2pt;
1970 else if(variable == "T2px") value = object->T2px;
1971 else if(variable == "T2py") value = object->T2py;
1972 else if(variable == "T2phi") value = object->T2phi;
1973 else if(variable == "T2sumET") value = object->T2sumET;
1974 else if(variable == "pfT1jet1pt") value = object->pfT1jet1pt;
1975 else if(variable == "pfT1jet1phi") value = object->pfT1jet1phi;
1976 else if(variable == "pfT1jet6pt") value = object->pfT1jet6pt;
1977 else if(variable == "pfT1jet6phi") value = object->pfT1jet6phi;
1978 else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
1979 else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
1980
1981 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1982
1983 value = applyFunction(function, value);
1984
1985 return value;
1986 }
1987
1988 double
1989 OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1990
1991 double value = 0.0;
1992 double pMag = sqrt(object->pt * object->pt +
1993 object->pz * object->pz);
1994
1995 if(variable == "pt") value = object->pt;
1996 else if(variable == "px") value = object->px;
1997 else if(variable == "py") value = object->py;
1998 else if(variable == "pz") value = object->pz;
1999 else if(variable == "phi") value = object->phi;
2000 else if(variable == "eta") value = object->eta;
2001 else if(variable == "theta") value = object->theta;
2002 else if(variable == "normChi2") value = object->normChi2;
2003 else if(variable == "dZ") value = object->dZ;
2004 else if(variable == "d0") value = object->d0;
2005 else if(variable == "d0err") value = object->d0err;
2006 else if(variable == "vx") value = object->vx;
2007 else if(variable == "vy") value = object->vy;
2008 else if(variable == "vz") value = object->vz;
2009 else if(variable == "charge") value = object->charge;
2010 else if(variable == "numValidHits") value = object->numValidHits;
2011 else if(variable == "isHighPurity") value = object->isHighPurity;
2012
2013
2014 //additional BNs info for disappTrks
2015 else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2016 else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2017 else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2018 else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2019 else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2020 else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2021 else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2022 else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2023 else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2024 else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2025
2026
2027 //user defined variables
2028 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;
2029 else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2030 else if(variable == "caloTotDeltaRp5") value = (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2031 else if(variable == "caloTotDeltaRp5ByP") value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2032 else if(variable == "caloTotDeltaRp5_RhoCorr") value = getTrkCaloTotRhoCorr(object);
2033 else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;
2034 else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
2035 else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
2036 else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
2037 else if(variable == "ptError") value = object->ptError;
2038 else if(variable == "ptRes") value = getTrkPtRes(object);
2039 else if (variable == "d0wrtPV"){
2040 double vx = object->vx - chosenVertex ()->x,
2041 vy = object->vy - chosenVertex ()->y,
2042 px = object->px,
2043 py = object->py,
2044 pt = object->pt;
2045 value = (-vx * py + vy * px) / pt;
2046 }
2047 else if (variable == "dZwrtPV"){
2048 double vx = object->vx - chosenVertex ()->x,
2049 vy = object->vy - chosenVertex ()->y,
2050 vz = object->vz - chosenVertex ()->z,
2051 px = object->px,
2052 py = object->py,
2053 pz = object->pz,
2054 pt = object->pt;
2055 value = vz - (vx * px + vy * py)/pt * (pz/pt);
2056 }
2057 else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2058
2059 else if(variable == "genMatchedPdgId"){
2060 int index = getGenMatchedParticleIndex(object);
2061 if(index == -1) value = 0;
2062 else value = mcparticles->at(index).id;
2063 }
2064
2065
2066 else if(variable == "genMatchedId"){
2067 int index = getGenMatchedParticleIndex(object);
2068 if(index == -1) value = 0;
2069 else value = getPdgIdBinValue(mcparticles->at(index).id);
2070 }
2071 else if(variable == "genMatchedMotherId"){
2072 int index = getGenMatchedParticleIndex(object);
2073 if(index == -1) value = 0;
2074 else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2075 }
2076 else if(variable == "genMatchedMotherIdReverse"){
2077 int index = getGenMatchedParticleIndex(object);
2078 if(index == -1) value = 23;
2079 else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2080 }
2081 else if(variable == "genMatchedGrandmotherId"){
2082 int index = getGenMatchedParticleIndex(object);
2083 if(index == -1) value = 0;
2084 else if(fabs(mcparticles->at(index).motherId) == 15){
2085 int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2086 if(motherIndex == -1) value = 0;
2087 else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2088 }
2089 else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2090 }
2091
2092
2093
2094 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2095
2096 value = applyFunction(function, value);
2097
2098 return value;
2099 }
2100
2101 double
2102 OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2103
2104 double value = 0.0;
2105
2106 if(variable == "pt") value = object->pt;
2107 else if(variable == "eta") value = object->eta;
2108 else if(variable == "phi") value = object->phi;
2109 else if(variable == "px") value = object->px;
2110 else if(variable == "py") value = object->py;
2111 else if(variable == "pz") value = object->pz;
2112 else if(variable == "et") value = object->et;
2113 else if(variable == "energy") value = object->energy;
2114 else if(variable == "mass") value = object->mass;
2115 else if(variable == "emEnergy") value = object->emEnergy;
2116 else if(variable == "hadEnergy") value = object->hadEnergy;
2117 else if(variable == "invisibleEnergy") value = object->invisibleEnergy;
2118 else if(variable == "auxiliaryEnergy") value = object->auxiliaryEnergy;
2119 else if(variable == "charge") value = object->charge;
2120
2121
2122 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2123
2124 value = applyFunction(function, value);
2125
2126 return value;
2127 }
2128
2129 double
2130 OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2131
2132 double value = 0.0;
2133
2134 if(variable == "energy") value = object->energy;
2135 else if(variable == "et") value = object->et;
2136 else if(variable == "pt") value = object->pt;
2137 else if(variable == "px") value = object->px;
2138 else if(variable == "py") value = object->py;
2139 else if(variable == "pz") value = object->pz;
2140 else if(variable == "phi") value = object->phi;
2141 else if(variable == "eta") value = object->eta;
2142 else if(variable == "theta") value = object->theta;
2143 else if(variable == "mass") value = object->mass;
2144 else if(variable == "vx") value = object->vx;
2145 else if(variable == "vy") value = object->vy;
2146 else if(variable == "vz") value = object->vz;
2147 else if(variable == "motherET") value = object->motherET;
2148 else if(variable == "motherPT") value = object->motherPT;
2149 else if(variable == "motherPhi") value = object->motherPhi;
2150 else if(variable == "motherEta") value = object->motherEta;
2151 else if(variable == "mother0ET") value = object->mother0ET;
2152 else if(variable == "mother0PT") value = object->mother0PT;
2153 else if(variable == "mother0Phi") value = object->mother0Phi;
2154 else if(variable == "mother0Eta") value = object->mother0Eta;
2155 else if(variable == "mother1ET") value = object->mother1ET;
2156 else if(variable == "mother1PT") value = object->mother1PT;
2157 else if(variable == "mother1Phi") value = object->mother1Phi;
2158 else if(variable == "mother1Eta") value = object->mother1Eta;
2159 else if(variable == "daughter0ET") value = object->daughter0ET;
2160 else if(variable == "daughter0PT") value = object->daughter0PT;
2161 else if(variable == "daughter0Phi") value = object->daughter0Phi;
2162 else if(variable == "daughter0Eta") value = object->daughter0Eta;
2163 else if(variable == "daughter1ET") value = object->daughter1ET;
2164 else if(variable == "daughter1PT") value = object->daughter1PT;
2165 else if(variable == "daughter1Phi") value = object->daughter1Phi;
2166 else if(variable == "daughter1Eta") value = object->daughter1Eta;
2167 else if(variable == "grandMotherET") value = object->grandMotherET;
2168 else if(variable == "grandMotherPT") value = object->grandMotherPT;
2169 else if(variable == "grandMotherPhi") value = object->grandMotherPhi;
2170 else if(variable == "grandMotherEta") value = object->grandMotherEta;
2171 else if(variable == "grandMother00ET") value = object->grandMother00ET;
2172 else if(variable == "grandMother00PT") value = object->grandMother00PT;
2173 else if(variable == "grandMother00Phi") value = object->grandMother00Phi;
2174 else if(variable == "grandMother00Eta") value = object->grandMother00Eta;
2175 else if(variable == "grandMother01ET") value = object->grandMother01ET;
2176 else if(variable == "grandMother01PT") value = object->grandMother01PT;
2177 else if(variable == "grandMother01Phi") value = object->grandMother01Phi;
2178 else if(variable == "grandMother01Eta") value = object->grandMother01Eta;
2179 else if(variable == "grandMother10ET") value = object->grandMother10ET;
2180 else if(variable == "grandMother10PT") value = object->grandMother10PT;
2181 else if(variable == "grandMother10Phi") value = object->grandMother10Phi;
2182 else if(variable == "grandMother10Eta") value = object->grandMother10Eta;
2183 else if(variable == "grandMother11ET") value = object->grandMother11ET;
2184 else if(variable == "grandMother11PT") value = object->grandMother11PT;
2185 else if(variable == "grandMother11Phi") value = object->grandMother11Phi;
2186 else if(variable == "grandMother11Eta") value = object->grandMother11Eta;
2187 else if(variable == "charge") value = object->charge;
2188 else if(variable == "id") value = object->id;
2189 else if(variable == "status") value = object->status;
2190 else if(variable == "motherId") value = object->motherId;
2191 else if(variable == "motherCharge") value = object->motherCharge;
2192 else if(variable == "mother0Id") value = object->mother0Id;
2193 else if(variable == "mother0Status") value = object->mother0Status;
2194 else if(variable == "mother0Charge") value = object->mother0Charge;
2195 else if(variable == "mother1Id") value = object->mother1Id;
2196 else if(variable == "mother1Status") value = object->mother1Status;
2197 else if(variable == "mother1Charge") value = object->mother1Charge;
2198 else if(variable == "daughter0Id") value = object->daughter0Id;
2199 else if(variable == "daughter0Status") value = object->daughter0Status;
2200 else if(variable == "daughter0Charge") value = object->daughter0Charge;
2201 else if(variable == "daughter1Id") value = object->daughter1Id;
2202 else if(variable == "daughter1Status") value = object->daughter1Status;
2203 else if(variable == "daughter1Charge") value = object->daughter1Charge;
2204 else if(variable == "grandMotherId") value = object->grandMotherId;
2205 else if(variable == "grandMotherCharge") value = object->grandMotherCharge;
2206 else if(variable == "grandMother00Id") value = object->grandMother00Id;
2207 else if(variable == "grandMother00Status") value = object->grandMother00Status;
2208 else if(variable == "grandMother00Charge") value = object->grandMother00Charge;
2209 else if(variable == "grandMother01Id") value = object->grandMother01Id;
2210 else if(variable == "grandMother01Status") value = object->grandMother01Status;
2211 else if(variable == "grandMother01Charge") value = object->grandMother01Charge;
2212 else if(variable == "grandMother10Id") value = object->grandMother10Id;
2213 else if(variable == "grandMother10Status") value = object->grandMother10Status;
2214 else if(variable == "grandMother10Charge") value = object->grandMother10Charge;
2215 else if(variable == "grandMother11Id") value = object->grandMother11Id;
2216 else if(variable == "grandMother11Status") value = object->grandMother11Status;
2217 else if(variable == "grandMother11Charge") value = object->grandMother11Charge;
2218
2219 //user-defined variables
2220 else if (variable == "d0"){
2221 double vx = object->vx - chosenVertex ()->x,
2222 vy = object->vy - chosenVertex ()->y,
2223 px = object->px,
2224 py = object->py,
2225 pt = object->pt;
2226 value = (-vx * py + vy * px) / pt;
2227 }
2228 else if (variable == "dz"){
2229 double vx = object->vx - chosenVertex ()->x,
2230 vy = object->vy - chosenVertex ()->y,
2231 vz = object->vz - chosenVertex ()->z,
2232 px = object->px,
2233 py = object->py,
2234 pz = object->pz,
2235 pt = object->pt;
2236 value = vz - (vx * px + vy * py)/pt * (pz/pt);
2237 }
2238 else if(variable == "v0"){
2239 value = sqrt(object->vx*object->vx + object->vy*object->vy);
2240 }
2241 else if(variable == "deltaV0"){
2242 value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2243 }
2244 else if (variable == "deltaVx"){
2245 value = object->vx - chosenVertex ()->x;
2246 }
2247 else if (variable == "deltaVy"){
2248 value = object->vy - chosenVertex ()->y;
2249 }
2250 else if (variable == "deltaVz"){
2251 value = object->vz - chosenVertex ()->z;
2252 }
2253
2254
2255 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2256
2257 value = applyFunction(function, value);
2258
2259 return value;
2260 }
2261
2262 double
2263 OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2264
2265 double value = 0.0;
2266
2267 if(variable == "x") value = object->x;
2268 else if(variable == "xError") value = object->xError;
2269 else if(variable == "y") value = object->y;
2270 else if(variable == "yError") value = object->yError;
2271 else if(variable == "z") value = object->z;
2272 else if(variable == "zError") value = object->zError;
2273 else if(variable == "rho") value = object->rho;
2274 else if(variable == "normalizedChi2") value = object->normalizedChi2;
2275 else if(variable == "ndof") value = object->ndof;
2276 else if(variable == "isFake") value = object->isFake;
2277 else if(variable == "isValid") value = object->isValid;
2278 else if(variable == "tracksSize") value = object->tracksSize;
2279 else if(variable == "isGood") value = object->isGood;
2280
2281
2282 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2283
2284 value = applyFunction(function, value);
2285
2286 return value;
2287 }
2288
2289 double
2290 OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2291
2292 double value = 0.0;
2293
2294 if(variable == "bx_B1_now") value = object->bx_B1_now;
2295 else if(variable == "bx_B2_now") value = object->bx_B2_now;
2296 else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2297
2298
2299 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2300
2301 value = applyFunction(function, value);
2302
2303 return value;
2304 }
2305
2306 double
2307 OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2308
2309 double value = 0.0;
2310
2311 if(variable == "energy") value = object->energy;
2312 else if(variable == "et") value = object->et;
2313 else if(variable == "pt") value = object->pt;
2314 else if(variable == "px") value = object->px;
2315 else if(variable == "py") value = object->py;
2316 else if(variable == "pz") value = object->pz;
2317 else if(variable == "phi") value = object->phi;
2318 else if(variable == "eta") value = object->eta;
2319 else if(variable == "theta") value = object->theta;
2320 else if(variable == "trackIso") value = object->trackIso;
2321 else if(variable == "ecalIso") value = object->ecalIso;
2322 else if(variable == "hcalIso") value = object->hcalIso;
2323 else if(variable == "caloIso") value = object->caloIso;
2324 else if(variable == "trackIsoHollowConeDR03") value = object->trackIsoHollowConeDR03;
2325 else if(variable == "trackIsoSolidConeDR03") value = object->trackIsoSolidConeDR03;
2326 else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
2327 else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
2328 else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
2329 else if(variable == "trackIsoHollowConeDR04") value = object->trackIsoHollowConeDR04;
2330 else if(variable == "trackIsoSolidConeDR04") value = object->trackIsoSolidConeDR04;
2331 else if(variable == "ecalIsoDR04") value = object->ecalIsoDR04;
2332 else if(variable == "hcalIsoDR04") value = object->hcalIsoDR04;
2333 else if(variable == "caloIsoDR04") value = object->caloIsoDR04;
2334 else if(variable == "hadOverEm") value = object->hadOverEm;
2335 else if(variable == "sigmaEtaEta") value = object->sigmaEtaEta;
2336 else if(variable == "sigmaIetaIeta") value = object->sigmaIetaIeta;
2337 else if(variable == "r9") value = object->r9;
2338 else if(variable == "scEnergy") value = object->scEnergy;
2339 else if(variable == "scRawEnergy") value = object->scRawEnergy;
2340 else if(variable == "scSeedEnergy") value = object->scSeedEnergy;
2341 else if(variable == "scEta") value = object->scEta;
2342 else if(variable == "scPhi") value = object->scPhi;
2343 else if(variable == "scZ") value = object->scZ;
2344 else if(variable == "genET") value = object->genET;
2345 else if(variable == "genPT") value = object->genPT;
2346 else if(variable == "genPhi") value = object->genPhi;
2347 else if(variable == "genEta") value = object->genEta;
2348 else if(variable == "genMotherET") value = object->genMotherET;
2349 else if(variable == "genMotherPT") value = object->genMotherPT;
2350 else if(variable == "genMotherPhi") value = object->genMotherPhi;
2351 else if(variable == "genMotherEta") value = object->genMotherEta;
2352 else if(variable == "eMax") value = object->eMax;
2353 else if(variable == "eLeft") value = object->eLeft;
2354 else if(variable == "eRight") value = object->eRight;
2355 else if(variable == "eTop") value = object->eTop;
2356 else if(variable == "eBottom") value = object->eBottom;
2357 else if(variable == "e3x3") value = object->e3x3;
2358 else if(variable == "swissCross") value = object->swissCross;
2359 else if(variable == "seedEnergy") value = object->seedEnergy;
2360 else if(variable == "seedTime") value = object->seedTime;
2361 else if(variable == "swissCrossNoI85") value = object->swissCrossNoI85;
2362 else if(variable == "swissCrossI85") value = object->swissCrossI85;
2363 else if(variable == "E2overE9NoI85") value = object->E2overE9NoI85;
2364 else if(variable == "E2overE9I85") value = object->E2overE9I85;
2365 else if(variable == "IDTight") value = object->IDTight;
2366 else if(variable == "IDLoose") value = object->IDLoose;
2367 else if(variable == "IDLooseEM") value = object->IDLooseEM;
2368 else if(variable == "genId") value = object->genId;
2369 else if(variable == "genCharge") value = object->genCharge;
2370 else if(variable == "genMotherId") value = object->genMotherId;
2371 else if(variable == "genMotherCharge") value = object->genMotherCharge;
2372 else if(variable == "isEB") value = object->isEB;
2373 else if(variable == "isEE") value = object->isEE;
2374 else if(variable == "isGap") value = object->isGap;
2375 else if(variable == "isEBEEGap") value = object->isEBEEGap;
2376 else if(variable == "isEBGap") value = object->isEBGap;
2377 else if(variable == "isEEGap") value = object->isEEGap;
2378 else if(variable == "hasPixelSeed") value = object->hasPixelSeed;
2379 else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2380
2381
2382
2383
2384 else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2385
2386 else if(variable == "genMatchedPdgId"){
2387 int index = getGenMatchedParticleIndex(object);
2388 if(index == -1) value = 0;
2389 else value = mcparticles->at(index).id;
2390 }
2391
2392
2393
2394 else if(variable == "genMatchedId"){
2395 int index = getGenMatchedParticleIndex(object);
2396 if(index == -1) value = 0;
2397 else value = getPdgIdBinValue(mcparticles->at(index).id);
2398 }
2399 else if(variable == "genMatchedMotherId"){
2400 int index = getGenMatchedParticleIndex(object);
2401 if(index == -1) value = 0;
2402 else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2403 }
2404 else if(variable == "genMatchedMotherIdReverse"){
2405 int index = getGenMatchedParticleIndex(object);
2406 if(index == -1) value = 23;
2407 else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2408 }
2409 else if(variable == "genMatchedGrandmotherId"){
2410 int index = getGenMatchedParticleIndex(object);
2411 if(index == -1) value = 0;
2412 else if(fabs(mcparticles->at(index).motherId) == 15){
2413 int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2414 if(motherIndex == -1) value = 0;
2415 else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2416 }
2417 else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2418 }
2419
2420
2421 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2422
2423 value = applyFunction(function, value);
2424
2425 return value;
2426 }
2427
2428 double
2429 OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2430
2431 double value = 0.0;
2432
2433 if(variable == "energy") value = object->energy;
2434 else if(variable == "et") value = object->et;
2435 else if(variable == "ex") value = object->ex;
2436 else if(variable == "ey") value = object->ey;
2437 else if(variable == "ez") value = object->ez;
2438 else if(variable == "phi") value = object->phi;
2439 else if(variable == "eta") value = object->eta;
2440 else if(variable == "theta") value = object->theta;
2441
2442
2443 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2444
2445 value = applyFunction(function, value);
2446
2447 return value;
2448 }
2449
2450
2451 double
2452 OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2453
2454 double value = 0.0;
2455
2456 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2457 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2458 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2459 else if(variable == "invMass"){
2460 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2461 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2462 value = (fourVector1 + fourVector2).M();
2463 }
2464 else if(variable == "pt"){
2465 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2466 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2467 value = (fourVector1 + fourVector2).Pt();
2468 }
2469 else if(variable == "threeDAngle")
2470 {
2471 TVector3 threeVector1(object1->px, object1->py, object1->pz);
2472 TVector3 threeVector2(object2->px, object2->py, object2->pz);
2473 value = (threeVector1.Angle(threeVector2));
2474 }
2475 else if(variable == "alpha")
2476 {
2477 static const double pi = 3.1415926535897932384626433832795028841971693993751058;
2478 TVector3 threeVector1(object1->px, object1->py, object1->pz);
2479 TVector3 threeVector2(object2->px, object2->py, object2->pz);
2480 value = (pi-threeVector1.Angle(threeVector2));
2481 }
2482 else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2483 else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2484 else if(variable == "d0Sign"){
2485 double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2486 if(d0Sign < 0) value = -0.5;
2487 else if (d0Sign > 0) value = 0.5;
2488 else value = -999;
2489 }
2490 else if(variable == "chargeProduct"){
2491 value = object1->charge*object2->charge;
2492 }
2493 else if(variable == "muon1CorrectedD0Vertex"){
2494 value = object1->correctedD0Vertex;
2495 }
2496 else if(variable == "muon2CorrectedD0Vertex"){
2497 value = object2->correctedD0Vertex;
2498 }
2499 else if(variable == "muon1timeAtIpInOut"){
2500 value = object1->timeAtIpInOut;
2501 }
2502 else if(variable == "muon2timeAtIpInOut"){
2503 value = object2->timeAtIpInOut;
2504 }
2505 else if(variable == "muon1correctedD0")
2506 {
2507 value = object1->correctedD0;
2508 }
2509 else if(variable == "muon2correctedD0")
2510 {
2511 value = object2->correctedD0;
2512 }
2513
2514 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2515
2516 value = applyFunction(function, value);
2517
2518 return value;
2519 }
2520
2521 double
2522 OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2523
2524 double value = 0.0;
2525
2526 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2527 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2528 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2529 else if(variable == "invMass"){
2530 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2531 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2532 value = (fourVector1 + fourVector2).M();
2533 }
2534 else if(variable == "pt"){
2535 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2536 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2537 value = (fourVector1 + fourVector2).Pt();
2538 }
2539 else if(variable == "threeDAngle")
2540 {
2541 TVector3 threeVector1(object1->px, object1->py, object1->pz);
2542 TVector3 threeVector2(object2->px, object2->py, object2->pz);
2543 value = (threeVector1.Angle(threeVector2));
2544 }
2545 else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2546 else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2547 else if(variable == "d0Sign"){
2548 double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2549 if(d0Sign < 0) value = -0.5;
2550 else if (d0Sign > 0) value = 0.5;
2551 else value = -999;
2552 }
2553 else if(variable == "chargeProduct"){
2554 value = object1->charge*object2->charge;
2555 }
2556 else if(variable == "electron1CorrectedD0Vertex"){
2557 value = object1->correctedD0Vertex;
2558 }
2559 else if(variable == "electron2CorrectedD0Vertex"){
2560 value = object2->correctedD0Vertex;
2561 }
2562 else if(variable == "electron1CorrectedD0"){
2563 value = object1->correctedD0;
2564 }
2565 else if(variable == "electron2CorrectedD0"){
2566 value = object2->correctedD0;
2567 }
2568
2569 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2570
2571 value = applyFunction(function, value);
2572
2573 return value;
2574 }
2575
2576 double
2577 OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2578
2579 double value = 0.0;
2580
2581 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2582 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2583 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2584 else if(variable == "invMass"){
2585 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2586 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2587 value = (fourVector1 + fourVector2).M();
2588 }
2589 else if(variable == "pt"){
2590 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2591 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2592 value = (fourVector1 + fourVector2).Pt();
2593 }
2594 else if(variable == "threeDAngle")
2595 {
2596 TVector3 threeVector1(object1->px, object1->py, object1->pz);
2597 TVector3 threeVector2(object2->px, object2->py, object2->pz);
2598 value = (threeVector1.Angle(threeVector2));
2599 }
2600 else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2601 else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2602 else if(variable == "d0Sign"){
2603 double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2604 if(d0Sign < 0) value = -0.5;
2605 else if (d0Sign > 0) value = 0.5;
2606 else value = -999;
2607 }
2608 else if(variable == "chargeProduct"){
2609 value = object1->charge*object2->charge;
2610 }
2611 else if(variable == "electronCorrectedD0Vertex"){
2612 value = object1->correctedD0Vertex;
2613 }
2614 else if(variable == "muonCorrectedD0Vertex"){
2615 value = object2->correctedD0Vertex;
2616 }
2617 else if(variable == "electronCorrectedD0"){
2618 value = object1->correctedD0;
2619 }
2620 else if(variable == "muonCorrectedD0"){
2621 value = object2->correctedD0;
2622 }
2623 else if(variable == "electronDetIso"){
2624 value = (object1->trackIso) / object1->pt;
2625 }
2626 else if(variable == "muonDetIso"){
2627 value = (object2->trackIsoDR03) / object2->pt;
2628 }
2629 else if(variable == "electronRelPFrhoIso"){
2630 value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2631 }
2632 else if(variable == "muonRelPFdBetaIso"){
2633 value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2634 }
2635
2636 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2637
2638 value = applyFunction(function, value);
2639
2640 return value;
2641 }
2642
2643
2644 double
2645 OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){
2646 double electronMass = 0.000511;
2647 double value = 0.0;
2648 TLorentzVector fourVector1(0, 0, 0, 0);
2649 TLorentzVector fourVector2(0, 0, 0, 0);
2650 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2651 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2652 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2653 else if(variable == "invMass"){
2654 fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
2655 fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
2656
2657 value = (fourVector1 + fourVector2).M();
2658 }
2659 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2660 value = applyFunction(function, value);
2661 return value;
2662 }
2663
2664
2665
2666 double
2667 OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2668 double pionMass = 0.140;
2669 double muonMass = 0.106;
2670 double value = 0.0;
2671 TLorentzVector fourVector1(0, 0, 0, 0);
2672 TLorentzVector fourVector2(0, 0, 0, 0);
2673 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2674 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2675 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2676 else if(variable == "invMass"){
2677 fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
2678 fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
2679
2680 value = (fourVector1 + fourVector2).M();
2681 }
2682
2683 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2684 value = applyFunction(function, value);
2685 return value;
2686 }
2687
2688
2689 double
2690 OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2691 double value = 0.0;
2692 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2693 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2694 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2695 else if(variable == "invMass"){
2696 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2697 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2698 value = (fourVector1 + fourVector2).M();
2699 }
2700
2701 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2702 value = applyFunction(function, value);
2703 return value;
2704 }
2705
2706
2707 double
2708 OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2709 double value = 0.0;
2710 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2711 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2712 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2713 else if(variable == "invMass"){
2714 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2715 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2716 value = (fourVector1 + fourVector2).M();
2717 }
2718
2719 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2720 value = applyFunction(function, value);
2721 return value;
2722 }
2723
2724 double
2725 OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
2726 double value = 0.0;
2727 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2728 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2729
2730 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2731 value = applyFunction(function, value);
2732 return value;
2733 }
2734
2735
2736
2737 double
2738 OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
2739
2740 double value = 0.0;
2741 double pMag = sqrt(object1->pt * object1->pt +
2742 object1->pz * object1->pz);
2743
2744 if (variable == "numPV") value = object2->numPV;
2745 else if (variable == "caloTotDeltaRp5") value = (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
2746 else if (variable == "caloTotDeltaRp5ByP") value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
2747 else if (variable == "caloTotDeltaRp5_RhoCorr") value = getTrkCaloTotRhoCorr(object1);
2748 else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
2749
2750 else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
2751
2752 value = applyFunction(function, value);
2753
2754 return value;
2755
2756 }
2757
2758 // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2759 // Return true iff no other tracks are found in this cone.
2760 int
2761 OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
2762 for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
2763 if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
2764 double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
2765 if(deltaRtrk < 0.5) return 0;
2766 }
2767 return 1;
2768
2769 }
2770
2771
2772 double
2773 OSUAnalysis::getTrkPtRes (const BNtrack* track1){
2774
2775 double ptTrue = getTrkPtTrue(track1, mcparticles.product());
2776 double PtRes = (track1->pt - ptTrue) / ptTrue;
2777
2778 return PtRes;
2779
2780 }
2781
2782
2783 double
2784 OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
2785 double value = -99;
2786 double genDeltaRLowest = 999;
2787
2788 for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){
2789 double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
2790 if (genDeltaRtemp < genDeltaRLowest) {
2791 genDeltaRLowest = genDeltaRtemp;
2792 if (genDeltaRLowest < 0.05) { // Only consider it truth-matched if DeltaR<0.15.
2793 double ptTrue = genPart->pt;
2794 value = ptTrue;
2795 }
2796 }
2797 }
2798
2799 return value;
2800
2801 }
2802
2803 double
2804 OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
2805 // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
2806 if (!useTrackCaloRhoCorr_) return -99;
2807 // if (!rhokt6CaloJetsHandle_) {
2808 // cout << "ERROR [getTrkCaloTotRhoCorr]: The collection rhokt6CaloJetsHandle is not available!" << endl;
2809 // return -99;
2810 // }
2811 double radDeltaRCone = 0.5;
2812 double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2); // Define effective area as pi*r^2, where r is radius of DeltaR cone.
2813 double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
2814 double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
2815 return caloTotRhoCorrCalo;
2816
2817 }
2818
2819
2820
2821
2822 //creates a map of the dead Ecal channels in the barrel and endcap
2823 //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2824 //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
2825 void
2826 OSUAnalysis::WriteDeadEcal (){
2827 double etaEcal, phiEcal;
2828 ifstream DeadEcalFile(deadEcalFile_);
2829 if(!DeadEcalFile) {
2830 cout << "Error: DeadEcalFile has not been found." << endl;
2831 return;
2832 }
2833 if(DeadEcalVec.size()!= 0){
2834 cout << "Error: DeadEcalVec has a nonzero size" << endl;
2835 return;
2836 }
2837 while(!DeadEcalFile.eof())
2838 {
2839 DeadEcalFile >> etaEcal >> phiEcal;
2840 DeadEcal newChan;
2841 newChan.etaEcal = etaEcal;
2842 newChan.phiEcal = phiEcal;
2843 DeadEcalVec.push_back(newChan);
2844 }
2845 if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
2846 }
2847
2848 //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
2849 int
2850 OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
2851 double deltaRLowest = 999;
2852 int value = 0;
2853 if (DeadEcalVec.size() == 0) WriteDeadEcal();
2854 for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
2855 double eta = ecal->etaEcal;
2856 double phi = ecal->phiEcal;
2857 double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
2858 if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
2859 }
2860 if (deltaRLowest<0.05) {value = 1;}
2861 else {value = 0;}
2862 return value;
2863 }
2864
2865 // Returns the smallest DeltaR between the object and any generated true particle in the event.
2866 template <class InputObject>
2867 double OSUAnalysis::getGenDeltaRLowest(InputObject object){
2868 double genDeltaRLowest = 999.;
2869 for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2870 double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
2871 if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
2872 }
2873 return genDeltaRLowest;
2874 }
2875
2876 double
2877 OSUAnalysis::applyFunction(string function, double value){
2878
2879 if(function == "abs") value = fabs(value);
2880 else if(function == "fabs") value = fabs(value);
2881 else if(function == "log10") value = log10(value);
2882 else if(function == "log") value = log10(value);
2883
2884 else if(function == "") value = value;
2885 else{std::cout << "WARNING: invalid function '" << function << "'\n";}
2886
2887 return value;
2888
2889 }
2890
2891
2892 template <class InputCollection>
2893 void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
2894
2895
2896 for (uint object = 0; object != inputCollection->size(); object++){
2897
2898
2899 bool decision = true;//object passes if this cut doesn't cut on that type of object
2900
2901
2902 if(currentCut.inputCollection == inputType){
2903
2904 vector<bool> subcutDecisions;
2905 for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2906 double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2907 subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2908 }
2909 if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2910 else{
2911 bool tempDecision = true;
2912 for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2913 if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2914 tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2915 else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2916 tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2917 }
2918 decision = tempDecision;
2919 }
2920 }
2921 individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2922
2923
2924 //set flags for objects that pass each cut AND all the previous cuts
2925 bool previousCumulativeFlag = true;
2926 for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2927 if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
2928 else{ previousCumulativeFlag = false; break;}
2929 }
2930 cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2931
2932
2933 }
2934
2935 }
2936
2937
2938 template <class InputCollection1, class InputCollection2>
2939 void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2940 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2941
2942
2943 bool sameObjects = false;
2944 if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2945
2946
2947 int counter = 0;
2948 for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2949 for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2950
2951 if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2952
2953
2954 bool decision = true;//object passes if this cut doesn't cut on that type of object
2955
2956 if(currentCut.inputCollection == inputType){
2957
2958 vector<bool> subcutDecisions;
2959 for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2960 double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2961 subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2962 }
2963
2964 if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2965 else{
2966 bool tempDecision = subcutDecisions.at(0);
2967 for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
2968 if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
2969 tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
2970 else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
2971 tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
2972 }
2973 decision = tempDecision;
2974 }
2975 }
2976 individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2977
2978 //set flags for objects that pass each cut AND all the previous cuts
2979 bool previousCumulativeFlag = true;
2980 for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2981 if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2982 else{ previousCumulativeFlag = false; break;}
2983 }
2984 //apply flags for the components of the composite object as well
2985 bool currentCumulativeFlag = true;
2986 if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
2987 else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
2988 else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
2989 else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2990 cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2991
2992 counter++;
2993 }
2994
2995 }
2996
2997
2998 }
2999
3000
3001 template <class InputCollection>
3002 void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3003
3004 for (uint object = 0; object != inputCollection->size(); object++){
3005
3006 if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3007
3008 string currentString = parameters.inputVariables.at(0);
3009 string inputVariable = "";
3010 string function = "";
3011 if(currentString.find("(")==std::string::npos){
3012 inputVariable = currentString;// variable to cut on
3013 }
3014 else{
3015 function = currentString.substr(0,currentString.find("("));//function comes before the "("
3016 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3017 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3018 }
3019
3020 double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3021 histo->Fill(value,scaleFactor);
3022
3023 if (printEventInfo_) {
3024 // Write information about event to screen, for testing purposes.
3025 cout << " Info for event: value for histogram " << histo->GetName() << ": " << value << endl;
3026 }
3027
3028 }
3029 }
3030
3031 template <class InputCollection1, class InputCollection2>
3032 void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3033
3034 bool sameObjects = false;
3035 if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3036
3037 int pairCounter = 0;
3038 for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3039 for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3040
3041 if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3042
3043 //only take objects which have passed all cuts and pairs which have passed all cuts
3044 if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3045 if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3046 if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3047
3048 string currentString = parameters.inputVariables.at(0);
3049 string inputVariable = "";
3050 string function = "";
3051 if(currentString.find("(")==std::string::npos){
3052 inputVariable = currentString;// variable to cut on
3053 }
3054 else{
3055 function = currentString.substr(0,currentString.find("("));//function comes before the "("
3056 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3057 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3058 }
3059
3060 double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3061 histo->Fill(value,scaleFactor);
3062
3063 pairCounter++;
3064 }
3065 }
3066
3067 }
3068
3069
3070 template <class InputCollection>
3071 void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3072
3073 for (uint object = 0; object != inputCollection->size(); object++){
3074
3075 if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3076
3077 string currentString = parameters.inputVariables.at(0);
3078 string inputVariable = "";
3079 string function = "";
3080 if(currentString.find("(")==std::string::npos){
3081 inputVariable = currentString;// variable to cut on
3082 }
3083 else{
3084 function = currentString.substr(0,currentString.find("("));//function comes before the "("
3085 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3086 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3087 }
3088 double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3089
3090 currentString = parameters.inputVariables.at(1);
3091 inputVariable = "";
3092 function = "";
3093 if(currentString.find("(")==std::string::npos){
3094 inputVariable = currentString;// variable to cut on
3095 }
3096 else{
3097 function = currentString.substr(0,currentString.find("("));//function comes before the "("
3098 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3099 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3100 }
3101
3102 double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3103
3104 histo->Fill(valueX,valueY,scaleFactor);
3105
3106 }
3107
3108 }
3109
3110 template <class InputCollection1, class InputCollection2>
3111 void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3112
3113 bool sameObjects = false;
3114 if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3115
3116 int pairCounter = 0;
3117 for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3118 for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3119
3120 if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3121
3122 //only take objects which have passed all cuts and pairs which have passed all cuts
3123 if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3124 if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3125 if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3126
3127 string currentString = parameters.inputVariables.at(0);
3128 string inputVariable = "";
3129 string function = "";
3130 if(currentString.find("(")==std::string::npos){
3131 inputVariable = currentString;// variable to cut on
3132 }
3133 else{
3134 function = currentString.substr(0,currentString.find("("));//function comes before the "("
3135 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3136 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3137 }
3138 double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3139
3140 currentString = parameters.inputVariables.at(1);
3141 inputVariable = "";
3142 function = "";
3143 if(currentString.find("(")==std::string::npos){
3144 inputVariable = currentString;// variable to cut on
3145 }
3146 else{
3147 function = currentString.substr(0,currentString.find("("));//function comes before the "("
3148 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3149 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3150 }
3151 double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3152
3153
3154 histo->Fill(valueX,valueY,scaleFactor);
3155
3156 pairCounter++;
3157
3158 }
3159 }
3160
3161 }
3162
3163
3164 template <class InputObject>
3165 int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
3166
3167 int bestMatchIndex = -1;
3168 double bestMatchDeltaR = 999;
3169
3170 for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3171
3172 double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3173 if(currentDeltaR > 0.05) continue;
3174 // cout << std::setprecision(3) << std::setw(20)
3175 // << "\tcurrentParticle: eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3176 // << std::setw(20)
3177 // << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3178 // << std::setw(20)
3179 // << "\tdeltaR = " << currentDeltaR
3180 // << std::setprecision(1)
3181 // << std::setw(20)
3182 // << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3183 // << std::setw(20)
3184 // << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3185 // << std::setw(20)
3186 // << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3187 if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3188 bestMatchIndex = mcparticle - mcparticles->begin();
3189 bestMatchDeltaR = currentDeltaR;
3190 }
3191
3192 }
3193 // if(bestMatchDeltaR != 999) cout << "bestMatch: deltaR = " << bestMatchDeltaR << " id = " << mcparticles->at(bestMatchIndex).id << " motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3194 // else cout << "no match found..." << endl;
3195 return bestMatchIndex;
3196
3197 }
3198
3199
3200 int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
3201
3202 int bestMatchIndex = -1;
3203 double bestMatchDeltaR = 999;
3204
3205 for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3206
3207 if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
3208
3209 double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
3210 if(currentDeltaR > 0.05) continue;
3211
3212 if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3213 bestMatchIndex = mcparticle - mcparticles->begin();
3214 bestMatchDeltaR = currentDeltaR;
3215 }
3216
3217 }
3218
3219 return bestMatchIndex;
3220 }
3221
3222
3223 // bin particle type
3224 // --- -------------
3225 // 0 unmatched
3226 // 1 u
3227 // 2 d
3228 // 3 s
3229 // 4 c
3230 // 5 b
3231 // 6 t
3232 // 7 e
3233 // 8 mu
3234 // 9 tau
3235 // 10 nu
3236 // 11 g
3237 // 12 gamma
3238 // 13 Z
3239 // 14 W
3240 // 15 light meson
3241 // 16 K meson
3242 // 17 D meson
3243 // 18 B meson
3244 // 19 light baryon
3245 // 20 strange baryon
3246 // 21 charm baryon
3247 // 22 bottom baryon
3248 // 23 other
3249
3250 int OSUAnalysis::getPdgIdBinValue(int pdgId){
3251
3252 int binValue = -999;
3253 int absPdgId = fabs(pdgId);
3254 if(pdgId == -1) binValue = 0;
3255 else if(absPdgId <= 6 ) binValue = absPdgId;
3256 else if(absPdgId == 11 ) binValue = 7;
3257 else if(absPdgId == 13 ) binValue = 8;
3258 else if(absPdgId == 15 ) binValue = 9;
3259 else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
3260 else if(absPdgId == 21 ) binValue = 11;
3261 else if(absPdgId == 22 ) binValue = 12;
3262 else if(absPdgId == 23 ) binValue = 13;
3263 else if(absPdgId == 24 ) binValue = 14;
3264 else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130 ) binValue = 15;
3265 else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400) ) binValue = 16;
3266 else if(absPdgId > 400 && absPdgId < 500 ) binValue = 17;
3267 else if(absPdgId > 500 && absPdgId < 600 ) binValue = 18;
3268 else if(absPdgId > 1000 && absPdgId < 3000 ) binValue = 19;
3269 else if(absPdgId > 3000 && absPdgId < 4000 ) binValue = 20;
3270 else if(absPdgId > 4000 && absPdgId < 5000 ) binValue = 21;
3271 else if(absPdgId > 5000 && absPdgId < 6000 ) binValue = 22;
3272
3273 else binValue = 23;
3274
3275 return binValue;
3276
3277 }
3278
3279 const BNprimaryvertex *
3280 OSUAnalysis::chosenVertex ()
3281 {
3282 const BNprimaryvertex *chosenVertex = 0;
3283 if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3284 vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3285 cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3286 for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3287 if(!vertexFlags.at(vertexIndex)) continue;
3288 chosenVertex = & primaryvertexs->at(vertexIndex);
3289 break;
3290 }
3291 }
3292 else {
3293 chosenVertex = &primaryvertexs->at(0);
3294 }
3295
3296 return chosenVertex;
3297 }
3298
3299 const BNmet *
3300 OSUAnalysis::chosenMET ()
3301 {
3302 const BNmet *chosenMET = 0;
3303 if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3304 vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3305 cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3306 for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3307 if(!metFlags.at(metIndex)) continue;
3308 chosenMET = & mets->at(metIndex);
3309 break;
3310 }
3311 }
3312 else {
3313 chosenMET = &mets->at(0);
3314 }
3315
3316 return chosenMET;
3317 }
3318
3319 const BNelectron *
3320 OSUAnalysis::chosenElectron ()
3321 {
3322 const BNelectron *chosenElectron = 0;
3323 if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3324 vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3325 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3326 for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3327 if(!electronFlags.at(electronIndex)) continue;
3328 chosenElectron = & electrons->at(electronIndex);
3329 break;
3330 }
3331 }
3332 else {
3333 chosenElectron = &electrons->at(0);
3334 }
3335
3336 return chosenElectron;
3337 }
3338
3339 const BNmuon *
3340 OSUAnalysis::chosenMuon ()
3341 {
3342 const BNmuon *chosenMuon = 0;
3343 if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3344 vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3345 cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3346 for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3347 if(!muonFlags.at(muonIndex)) continue;
3348 chosenMuon = & muons->at(muonIndex);
3349 break;
3350 }
3351 }
3352 else {
3353 chosenMuon = &muons->at(0);
3354 }
3355
3356 return chosenMuon;
3357 }
3358
3359
3360 DEFINE_FWK_MODULE(OSUAnalysis);