ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.55
Committed: Fri May 3 20:10:39 2013 UTC (12 years ago) by ahart
Content type: text/plain
Branch: MAIN
Changes since 1.54: +8 -22 lines
Log Message:
Got rid of the DISPLACED_SUSY macro. <c*tau> reweighting is now done only if datasetType_ == "signalMC" and dataset_ matches "stop.*to.*_.*mm.*".

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