ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.54
Committed: Wed May 1 19:49:01 2013 UTC (12 years ago) by ahart
Content type: text/plain
Branch: MAIN
Changes since 1.53: +54 -39 lines
Log Message:
Added a parameter applyLeptonSF for turning on application of lepton scale factors. This functionality currently only works if there is exactly one electron and/or exactly one muon; i.e., it's not correct when there are multiple muons or multiple electrons.

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