ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.21
Committed: Wed Feb 27 14:16:26 2013 UTC (12 years, 2 months ago) by qpython
Content type: text/plain
Branch: MAIN
Changes since 1.20: +1 -1 lines
Log Message:
remove an unnecessary line I added by mistake

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 primaryvertexs_ (cfg.getParameter<edm::InputTag> ("primaryvertexs")),
15 bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
16 photons_ (cfg.getParameter<edm::InputTag> ("photons")),
17 superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
18 triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
19 puFile_ (cfg.getParameter<std::string> ("puFile")),
20 dataPU_ (cfg.getParameter<std::string> ("dataPU")),
21 dataset_ (cfg.getParameter<std::string> ("dataset")),
22 datasetType_ (cfg.getParameter<std::string> ("datasetType")),
23 channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
24 histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
25 plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents"))
26
27 {
28
29 TH1::SetDefaultSumw2 ();
30
31 //create pile-up reweighting object, if necessary
32 if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
33
34 // Construct Cutflow Objects. These store the results of cut decisions and
35 // handle filling cut flow histograms.
36 masterCutFlow_ = new CutFlow (fs_);
37 std::vector<TFileDirectory> directories;
38
39 //always get vertex collection so we can assign the primary vertex in the event
40 allNecessaryObjects.push_back("primaryvertexs");
41 //always make the plot of number of primary verticex (to check pile-up reweighting)
42 objectsToPlot.push_back("primaryvertexs");
43
44 //always get the MC particles to do GEN-matching
45 allNecessaryObjects.push_back("mcparticles");
46
47 //always get the event collection to do pile-up reweighting
48 allNecessaryObjects.push_back("events");
49
50 //parse the histogram definitions
51 for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
52
53 string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
54 if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
55 if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
56 objectsToPlot.push_back(tempInputCollection);
57 allNecessaryObjects.push_back(tempInputCollection);
58 }
59 else{//pair of objects, need to add them both to the things to allNecessaryObjects
60 int dashIndex = tempInputCollection.find("-");
61 int spaceIndex = tempInputCollection.find(" ");
62 int secondWordLength = spaceIndex - dashIndex;
63 allNecessaryObjects.push_back(tempInputCollection);
64 allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
65 allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
66 objectsToPlot.push_back(tempInputCollection);
67 objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
68 objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
69 }
70
71 vector<edm::ParameterSet> histogramList_ (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
72
73 for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
74
75 histogram tempHistogram;
76 tempHistogram.inputCollection = tempInputCollection;
77 tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
78 tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
79 tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
80 tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
81
82 histograms.push_back(tempHistogram);
83
84 }
85 }
86 //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
87 sort( objectsToPlot.begin(), objectsToPlot.end() );
88 objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
89
90
91
92
93 channel tempChannel;
94 //loop over all channels (event selections)
95 for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
96
97 //get name of channel
98 string channelName (channels_.at(currentChannel).getParameter<string>("name"));
99 tempChannel.name = channelName;
100 TString channelLabel = channelName;
101
102 //set triggers for this channel
103 vector<string> triggerNames;
104 triggerNames.clear();
105 tempChannel.triggers.clear();
106 if(channels_.at(currentChannel).exists("triggers")){
107 triggerNames = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
108 for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
109 tempChannel.triggers.push_back(triggerNames.at(trigger));
110 allNecessaryObjects.push_back("triggers");
111 }
112
113
114
115
116 //create cutFlow for this channel
117 cutFlows_.push_back (new CutFlow (fs_, channelName));
118
119 //book a directory in the output file with the name of the channel
120 TFileDirectory subDir = fs_->mkdir( channelName );
121 directories.push_back(subDir);
122
123 std::map<std::string, TH1D*> oneDhistoMap;
124 oneDHists_.push_back(oneDhistoMap);
125 std::map<std::string, TH2D*> twoDhistoMap;
126 twoDHists_.push_back(twoDhistoMap);
127
128
129 //book all histograms included in the configuration
130 for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
131 histogram currentHistogram = histograms.at(currentHistogramIndex);
132 int numBinsElements = currentHistogram.bins.size();
133 int numInputVariables = currentHistogram.inputVariables.size();
134
135 if(numBinsElements != 3 && numBinsElements !=6) {
136 std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
137 exit(0);
138 }
139 else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
140 std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
141 exit(0);
142 }
143 else if(numBinsElements == 3){
144 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));
145 }
146 else if(numBinsElements == 6){
147 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));
148
149 }
150
151
152 }
153 //book a histogram for the number of each object type to be plotted
154 for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
155 string currentObject = objectsToPlot.at(currentObjectIndex);
156 int maxNum = 10;
157 if(currentObject == "mcparticles") maxNum = 50;
158 else if(currentObject == "primaryvertexs") maxNum = 50;
159 else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
160 else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
161 else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
162
163 currentObject.at(0) = toupper(currentObject.at(0));
164 string histoName = "num" + currentObject;
165
166 if(histoName == "numPrimaryvertexs"){
167 string newHistoName = histoName + "BeforePileupCorrection";
168 oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
169 newHistoName = histoName + "AfterPileupCorrection";
170 oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
171 }
172 else
173 oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
174 }
175
176
177 //get list of cuts for this channel
178 vector<edm::ParameterSet> cuts_ (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
179
180 //loop over and parse all cuts
181 for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
182 cut tempCut;
183 //store input collection for cut
184 string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
185 tempCut.inputCollection = tempInputCollection;
186 if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
187 allNecessaryObjects.push_back(tempInputCollection);
188 }
189 else{//pair of objects, need to add them both to the things to allNecessaryObjects
190 int dashIndex = tempInputCollection.find("-");
191 int spaceIndex = tempInputCollection.find(" ");
192 int secondWordLength = spaceIndex - dashIndex;
193 allNecessaryObjects.push_back(tempInputCollection);
194 allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
195 allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
196
197 }
198
199
200
201 //split cut string into parts and store them
202 string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
203 std::vector<string> cutStringVector = splitString(cutString);
204 if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
205 std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
206 exit(0);
207 }
208 tempCut.numSubcuts = (cutStringVector.size()+1)/4;
209 for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
210 int indexOffset = 4 * subcutIndex;
211 string currentVariableString = cutStringVector.at(indexOffset);
212 if(currentVariableString.find("(")==std::string::npos){
213 tempCut.functions.push_back("");//no function was specified
214 tempCut.variables.push_back(currentVariableString);// variable to cut on
215 }
216 else{
217 tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
218 string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
219 tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
220 }
221 tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
222 tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
223 if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
224 }
225
226 //get number of objects required to pass cut for event to pass
227 string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
228 std::vector<string> numberRequiredVector = splitString(numberRequiredString);
229 if(numberRequiredVector.size()!=2){
230 std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
231 exit(0);
232 }
233
234 int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
235 tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
236 tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
237
238
239 string tempCutName;
240 if(cuts_.at(currentCut).exists("alias")){
241 tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
242 }
243 else{
244 //construct string for cutflow table
245 bool plural = numberRequiredInt != 1;
246 string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
247 string cutName = numberRequiredString + " " + collectionString + " with " + cutString;
248 tempCutName = cutName;
249 }
250 tempCut.name = tempCutName;
251
252
253 tempChannel.cuts.push_back(tempCut);
254
255
256
257 }//end loop over cuts
258
259 channels.push_back(tempChannel);
260 tempChannel.cuts.clear();
261
262 }//end loop over channels
263
264
265 //make unique vector of objects we need to cut on (so we make sure to get them from the event)
266 sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
267 allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
268
269
270 }
271
272 OSUAnalysis::~OSUAnalysis ()
273 {
274 // Destroying the CutFlow objects causes the cut flow numbers and time
275 // information to be printed to standard output.
276 for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
277 delete cutFlows_.at(currentChannel);
278 }
279 }
280
281 void
282 OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
283 {
284
285
286 // Retrieve necessary collections from the event.
287 edm::Handle<BNtriggerCollection> triggers;
288 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
289 event.getByLabel (triggers_, triggers);
290
291 edm::Handle<BNjetCollection> jets;
292 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
293 event.getByLabel (jets_, jets);
294
295 edm::Handle<BNmuonCollection> muons;
296 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
297 event.getByLabel (muons_, muons);
298
299 edm::Handle<BNelectronCollection> electrons;
300 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
301 event.getByLabel (electrons_, electrons);
302
303 edm::Handle<BNeventCollection> events;
304 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
305 event.getByLabel (events_, events);
306
307 edm::Handle<BNtauCollection> taus;
308 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
309 event.getByLabel (taus_, taus);
310
311 edm::Handle<BNmetCollection> mets;
312 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
313 event.getByLabel (mets_, mets);
314
315 edm::Handle<BNtrackCollection> tracks;
316 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
317 event.getByLabel (tracks_, tracks);
318
319 edm::Handle<BNgenjetCollection> genjets;
320 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
321 event.getByLabel (genjets_, genjets);
322
323 edm::Handle<BNmcparticleCollection> mcparticles;
324 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
325 event.getByLabel (mcparticles_, mcparticles);
326
327 edm::Handle<BNprimaryvertexCollection> primaryvertexs;
328 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
329 event.getByLabel (primaryvertexs_, primaryvertexs);
330
331 edm::Handle<BNbxlumiCollection> bxlumis;
332 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
333 event.getByLabel (bxlumis_, bxlumis);
334
335 edm::Handle<BNphotonCollection> photons;
336 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
337 event.getByLabel (photons_, photons);
338
339 edm::Handle<BNsuperclusterCollection> superclusters;
340 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
341 event.getByLabel (superclusters_, superclusters);
342
343
344 //get pile-up event weight
345 double puScaleFactor = 0;
346 if(datasetType_ != "data")
347 puScaleFactor = puWeight_->at (events->at (0).numTruePV);
348 else
349 puScaleFactor = 1.00;
350
351
352 //loop over all channels
353
354 for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
355 channel currentChannel = channels.at(currentChannelIndex);
356
357 flagMap individualFlags;
358 flagMap cumulativeFlags;
359 counterMap passingCounter;
360
361 bool triggerDecision = true;
362 if(currentChannel.triggers.size() != 0){ //triggers specified
363 triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
364 cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
365 }
366
367 //loop over all cuts
368 for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
369 cut currentCut = currentChannel.cuts.at(currentCutIndex);
370
371 for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
372 string currentObject = allNecessaryObjects.at(currentObjectIndex);
373
374 individualFlags[currentObject].push_back (vector<bool> ());
375 cumulativeFlags[currentObject].push_back (vector<bool> ());
376
377
378 if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
379 else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
380 else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
381 else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
382 else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
383 else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
384 else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
385 else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
386 else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
387 else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
388 else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
389 else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
390 else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
391
392 else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(),"muon-muon pairs");
393 else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(),"electron-electron pairs");
394 else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(),"electron-muon pairs");
395
396 }
397
398
399
400 }//end loop over all cuts
401
402
403
404 //use cumulative flags to apply cuts at event level
405
406 bool eventPassedAllCuts = true;
407
408 //apply trigger (true if none were specified)
409 eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
410
411
412 for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
413
414 //loop over all objects and count how many passed the cumulative selection up to this point
415 cut currentCut = currentChannel.cuts.at(currentCutIndex);
416 int numberPassing = 0;
417
418 for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
419 if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
420 }
421
422 bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
423 cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
424
425 eventPassedAllCuts = eventPassedAllCuts && cutDecision;
426
427 }
428
429 cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor);
430
431
432
433 if(!eventPassedAllCuts)continue;
434
435
436
437
438 //set position of primary vertex in event, in order to calculate quantities relative to it
439 primaryVertex_ = 0;
440 vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
441 for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
442 if(!vertexFlags.at(vertexIndex)) continue;
443 primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex));
444 break;
445 }
446
447
448 //filling histograms
449 for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
450 histogram currentHistogram = histograms.at(histogramIndex);
451
452 if(currentHistogram.inputVariables.size() == 1){
453 TH1D* histo;
454 histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
455 if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
456 else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
457 else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\
458 cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\
459 cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
460 else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
461 else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
462 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
463 cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
464 else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
465 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
466 cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
467 else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
468 else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
469 else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
470 else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
471 else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
472 else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
473 else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
474 else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
475 else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
476 else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
477 }
478 else if(currentHistogram.inputVariables.size() == 2){
479 TH2D* histo;
480 histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
481 if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
482 else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
483 else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
484 cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
485 cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
486 else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
487 else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
488 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
489 cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
490 else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
491 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
492 cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
493 else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
494 else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
495 else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
496 else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
497 else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
498 else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
499 else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
500 else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
501 else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
502 else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
503 }
504 }
505
506
507 //fills histograms with the sizes of collections
508 for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
509 string currentObject = objectsToPlot.at(currentObjectIndex);
510
511 if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
512 else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
513 else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
514 string tempCurrentObject = currentObject;
515 tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
516 string histoName = "num" + tempCurrentObject;
517
518
519 if(currentObject == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
520 else if(currentObject == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
521 else if(currentObject == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
522 else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
523 else if(currentObject == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
524 else if(currentObject == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
525 else if(currentObject == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
526 else if(currentObject == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
527 else if(currentObject == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
528 else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
529 else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
530 else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
531 else if(currentObject == "primaryvertexs"){
532 oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
533 oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
534 }
535 else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
536 else if(currentObject == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
537 else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
538
539 }
540 } //end loop over channel
541
542 masterCutFlow_->fillCutFlow(puScaleFactor);
543
544
545
546 }
547
548
549 bool
550 OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
551
552
553 if(comparison == ">") return testValue > cutValue;
554 else if(comparison == ">=") return testValue >= cutValue;
555 else if(comparison == "<") return testValue < cutValue;
556 else if(comparison == "<=") return testValue <= cutValue;
557 else if(comparison == "==") return testValue == cutValue;
558 else if(comparison == "=") return testValue == cutValue;
559 else if(comparison == "!=") return testValue != cutValue;
560 else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
561
562 }
563
564 bool
565 OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
566
567 bool triggerDecision = false;
568
569 for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
570 {
571 if(trigger->pass != 1) continue;
572 for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
573 {
574 if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
575 triggerDecision = true;
576 }
577 }
578 }
579 return triggerDecision;
580
581 }
582
583 std::vector<std::string>
584 OSUAnalysis::splitString (string inputString){
585
586 std::stringstream stringStream(inputString);
587 std::istream_iterator<std::string> begin(stringStream);
588 std::istream_iterator<std::string> end;
589 std::vector<std::string> stringVector(begin, end);
590 return stringVector;
591
592 }
593
594 double
595 OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
596
597 double value = 0.0;
598 if(variable == "energy") value = object->energy;
599 else if(variable == "et") value = object->et;
600 else if(variable == "pt") value = object->pt;
601 else if(variable == "px") value = object->px;
602 else if(variable == "py") value = object->py;
603 else if(variable == "pz") value = object->pz;
604 else if(variable == "phi") value = object->phi;
605 else if(variable == "eta") value = object->eta;
606 else if(variable == "theta") value = object->theta;
607 else if(variable == "Upt") value = object->Upt;
608 else if(variable == "Uenergy") value = object->Uenergy;
609 else if(variable == "L2pt") value = object->L2pt;
610 else if(variable == "L2L3pt") value = object->L2L3pt;
611 else if(variable == "L2L3respt") value = object->L2L3respt;
612 else if(variable == "respt") value = object->respt;
613 else if(variable == "EMfrac") value = object->EMfrac;
614 else if(variable == "Hadfrac") value = object->Hadfrac;
615 else if(variable == "charge") value = object->charge;
616 else if(variable == "mass") value = object->mass;
617 else if(variable == "area") value = object->area;
618 else if(variable == "fHPD") value = object->fHPD;
619 else if(variable == "approximatefHPD") value = object->approximatefHPD;
620 else if(variable == "genPartonET") value = object->genPartonET;
621 else if(variable == "genPartonPT") value = object->genPartonPT;
622 else if(variable == "genPartonEta") value = object->genPartonEta;
623 else if(variable == "genPartonPhi") value = object->genPartonPhi;
624 else if(variable == "genJetET") value = object->genJetET;
625 else if(variable == "genJetPT") value = object->genJetPT;
626 else if(variable == "genJetEta") value = object->genJetEta;
627 else if(variable == "genJetPhi") value = object->genJetPhi;
628 else if(variable == "btagTChighPur") value = object->btagTChighPur;
629 else if(variable == "btagTChighEff") value = object->btagTChighEff;
630 else if(variable == "btagJetProb") value = object->btagJetProb;
631 else if(variable == "btagJetBProb") value = object->btagJetBProb;
632 else if(variable == "btagSoftEle") value = object->btagSoftEle;
633 else if(variable == "btagSoftMuon") value = object->btagSoftMuon;
634 else if(variable == "btagSoftMuonNoIP") value = object->btagSoftMuonNoIP;
635 else if(variable == "btagSecVertex") value = object->btagSecVertex;
636 else if(variable == "btagSecVertexHighEff") value = object->btagSecVertexHighEff;
637 else if(variable == "btagSecVertexHighPur") value = object->btagSecVertexHighPur;
638 else if(variable == "btagCombinedSecVertex") value = object->btagCombinedSecVertex;
639 else if(variable == "btagCombinedSecVertexMVA") value = object->btagCombinedSecVertexMVA;
640 else if(variable == "btagSoftMuonByPt") value = object->btagSoftMuonByPt;
641 else if(variable == "btagSoftMuonByIP3") value = object->btagSoftMuonByIP3;
642 else if(variable == "btagSoftElectronByPt") value = object->btagSoftElectronByPt;
643 else if(variable == "btagSoftElectronByIP3") value = object->btagSoftElectronByIP3;
644 else if(variable == "n90Hits") value = object->n90Hits;
645 else if(variable == "hitsInN90") value = object->hitsInN90;
646 else if(variable == "chargedHadronEnergyFraction") value = object->chargedHadronEnergyFraction;
647 else if(variable == "neutralHadronEnergyFraction") value = object->neutralHadronEnergyFraction;
648 else if(variable == "chargedEmEnergyFraction") value = object->chargedEmEnergyFraction;
649 else if(variable == "neutralEmEnergyFraction") value = object->neutralEmEnergyFraction;
650 else if(variable == "fLong") value = object->fLong;
651 else if(variable == "fShort") value = object->fShort;
652 else if(variable == "etaetaMoment") value = object->etaetaMoment;
653 else if(variable == "phiphiMoment") value = object->phiphiMoment;
654 else if(variable == "JESunc") value = object->JESunc;
655 else if(variable == "JECuncUp") value = object->JECuncUp;
656 else if(variable == "JECuncDown") value = object->JECuncDown;
657 else if(variable == "puJetMVA_full") value = object->puJetMVA_full;
658 else if(variable == "puJetMVA_simple") value = object->puJetMVA_simple;
659 else if(variable == "puJetMVA_cutbased") value = object->puJetMVA_cutbased;
660 else if(variable == "dZ") value = object->dZ;
661 else if(variable == "dR2Mean") value = object->dR2Mean;
662 else if(variable == "dRMean") value = object->dRMean;
663 else if(variable == "frac01") value = object->frac01;
664 else if(variable == "frac02") value = object->frac02;
665 else if(variable == "frac03") value = object->frac03;
666 else if(variable == "frac04") value = object->frac04;
667 else if(variable == "frac05") value = object->frac05;
668 else if(variable == "frac06") value = object->frac06;
669 else if(variable == "frac07") value = object->frac07;
670 else if(variable == "beta") value = object->beta;
671 else if(variable == "betaStar") value = object->betaStar;
672 else if(variable == "betaClassic") value = object->betaClassic;
673 else if(variable == "betaStarClassic") value = object->betaStarClassic;
674 else if(variable == "ptD") value = object->ptD;
675 else if(variable == "nvtx") value = object->nvtx;
676 else if(variable == "d0") value = object->d0;
677 else if(variable == "leadCandPt") value = object->leadCandPt;
678 else if(variable == "leadCandVx") value = object->leadCandVx;
679 else if(variable == "leadCandVy") value = object->leadCandVy;
680 else if(variable == "leadCandVz") value = object->leadCandVz;
681 else if(variable == "leadCandDistFromPV") value = object->leadCandDistFromPV;
682 else if(variable == "flavour") value = object->flavour;
683 else if(variable == "Nconst") value = object->Nconst;
684 else if(variable == "jetIDMinimal") value = object->jetIDMinimal;
685 else if(variable == "jetIDLooseAOD") value = object->jetIDLooseAOD;
686 else if(variable == "jetIDLoose") value = object->jetIDLoose;
687 else if(variable == "jetIDTight") value = object->jetIDTight;
688 else if(variable == "genPartonId") value = object->genPartonId;
689 else if(variable == "genPartonMotherId") value = object->genPartonMotherId;
690 else if(variable == "genPartonMother0Id") value = object->genPartonMother0Id;
691 else if(variable == "genPartonMother1Id") value = object->genPartonMother1Id;
692 else if(variable == "genPartonGrandMotherId") value = object->genPartonGrandMotherId;
693 else if(variable == "genPartonGrandMother00Id") value = object->genPartonGrandMother00Id;
694 else if(variable == "genPartonGrandMother01Id") value = object->genPartonGrandMother01Id;
695 else if(variable == "genPartonGrandMother10Id") value = object->genPartonGrandMother10Id;
696 else if(variable == "genPartonGrandMother11Id") value = object->genPartonGrandMother11Id;
697 else if(variable == "chargedMultiplicity") value = object->chargedMultiplicity;
698 else if(variable == "neutralMultiplicity") value = object->neutralMultiplicity;
699 else if(variable == "nconstituents") value = object->nconstituents;
700 else if(variable == "nHit") value = object->nHit;
701 else if(variable == "puJetId_full") value = object->puJetId_full;
702 else if(variable == "puJetId_simple") value = object->puJetId_simple;
703 else if(variable == "puJetId_cutbased") value = object->puJetId_cutbased;
704 else if(variable == "puJetId_tight_full") value = object->puJetId_tight_full;
705 else if(variable == "puJetId_tight_simple") value = object->puJetId_tight_simple;
706 else if(variable == "puJetId_tight_cutbased") value = object->puJetId_tight_cutbased;
707 else if(variable == "puJetId_medium_full") value = object->puJetId_medium_full;
708 else if(variable == "puJetId_medium_simple") value = object->puJetId_medium_simple;
709 else if(variable == "puJetId_medium_cutbased") value = object->puJetId_medium_cutbased;
710 else if(variable == "puJetId_loose_full") value = object->puJetId_loose_full;
711 else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
712 else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
713
714
715 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
716
717 value = applyFunction(function, value);
718
719 return value;
720 }
721
722
723
724 double
725 OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
726
727 double value = 0.0;
728 if(variable == "energy") value = object->energy;
729 else if(variable == "et") value = object->et;
730 else if(variable == "pt") value = object->pt;
731 else if(variable == "px") value = object->px;
732 else if(variable == "py") value = object->py;
733 else if(variable == "pz") value = object->pz;
734 else if(variable == "phi") value = object->phi;
735 else if(variable == "eta") value = object->eta;
736 else if(variable == "theta") value = object->theta;
737 else if(variable == "trackIso") value = object->trackIso;
738 else if(variable == "ecalIso") value = object->ecalIso;
739 else if(variable == "hcalIso") value = object->hcalIso;
740 else if(variable == "caloIso") value = object->caloIso;
741 else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
742 else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
743 else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
744 else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
745 else if(variable == "trackVetoIsoDR03") value = object->trackVetoIsoDR03;
746 else if(variable == "ecalVetoIsoDR03") value = object->ecalVetoIsoDR03;
747 else if(variable == "hcalVetoIsoDR03") value = object->hcalVetoIsoDR03;
748 else if(variable == "caloVetoIsoDR03") value = object->caloVetoIsoDR03;
749 else if(variable == "trackIsoDR05") value = object->trackIsoDR05;
750 else if(variable == "ecalIsoDR05") value = object->ecalIsoDR05;
751 else if(variable == "hcalIsoDR05") value = object->hcalIsoDR05;
752 else if(variable == "caloIsoDR05") value = object->caloIsoDR05;
753 else if(variable == "trackVetoIsoDR05") value = object->trackVetoIsoDR05;
754 else if(variable == "ecalVetoIsoDR05") value = object->ecalVetoIsoDR05;
755 else if(variable == "hcalVetoIsoDR05") value = object->hcalVetoIsoDR05;
756 else if(variable == "caloVetoIsoDR05") value = object->caloVetoIsoDR05;
757 else if(variable == "hcalE") value = object->hcalE;
758 else if(variable == "ecalE") value = object->ecalE;
759 else if(variable == "genET") value = object->genET;
760 else if(variable == "genPT") value = object->genPT;
761 else if(variable == "genPhi") value = object->genPhi;
762 else if(variable == "genEta") value = object->genEta;
763 else if(variable == "genMotherET") value = object->genMotherET;
764 else if(variable == "genMotherPT") value = object->genMotherPT;
765 else if(variable == "genMotherPhi") value = object->genMotherPhi;
766 else if(variable == "genMotherEta") value = object->genMotherEta;
767 else if(variable == "vx") value = object->vx;
768 else if(variable == "vy") value = object->vy;
769 else if(variable == "vz") value = object->vz;
770 else if(variable == "tkNormChi2") value = object->tkNormChi2;
771 else if(variable == "tkPT") value = object->tkPT;
772 else if(variable == "tkEta") value = object->tkEta;
773 else if(variable == "tkPhi") value = object->tkPhi;
774 else if(variable == "tkDZ") value = object->tkDZ;
775 else if(variable == "tkD0") value = object->tkD0;
776 else if(variable == "tkD0bs") value = object->tkD0bs;
777 else if(variable == "tkD0err") value = object->tkD0err;
778 else if(variable == "samNormChi2") value = object->samNormChi2;
779 else if(variable == "samPT") value = object->samPT;
780 else if(variable == "samEta") value = object->samEta;
781 else if(variable == "samPhi") value = object->samPhi;
782 else if(variable == "samDZ") value = object->samDZ;
783 else if(variable == "samD0") value = object->samD0;
784 else if(variable == "samD0bs") value = object->samD0bs;
785 else if(variable == "samD0err") value = object->samD0err;
786 else if(variable == "comNormChi2") value = object->comNormChi2;
787 else if(variable == "comPT") value = object->comPT;
788 else if(variable == "comEta") value = object->comEta;
789 else if(variable == "comPhi") value = object->comPhi;
790 else if(variable == "comDZ") value = object->comDZ;
791 else if(variable == "comD0") value = object->comD0;
792 else if(variable == "comD0bs") value = object->comD0bs;
793 else if(variable == "comD0err") value = object->comD0err;
794 else if(variable == "isolationR03emVetoEt") value = object->isolationR03emVetoEt;
795 else if(variable == "isolationR03hadVetoEt") value = object->isolationR03hadVetoEt;
796 else if(variable == "normalizedChi2") value = object->normalizedChi2;
797 else if(variable == "dVzPVz") value = object->dVzPVz;
798 else if(variable == "dB") value = object->dB;
799 else if(variable == "ptErr") value = object->ptErr;
800 else if(variable == "innerTrackNormChi2") value = object->innerTrackNormChi2;
801 else if(variable == "correctedD0") value = object->correctedD0;
802 else if(variable == "correctedD0Vertex") value = object->correctedD0Vertex;
803 else if(variable == "correctedDZ") value = object->correctedDZ;
804 else if(variable == "particleIso") value = object->particleIso;
805 else if(variable == "chargedHadronIso") value = object->chargedHadronIso;
806 else if(variable == "neutralHadronIso") value = object->neutralHadronIso;
807 else if(variable == "photonIso") value = object->photonIso;
808 else if(variable == "puChargedHadronIso") value = object->puChargedHadronIso;
809 else if(variable == "chargedHadronIsoDR03") value = object->chargedHadronIsoDR03;
810 else if(variable == "neutralHadronIsoDR03") value = object->neutralHadronIsoDR03;
811 else if(variable == "photonIsoDR03") value = object->photonIsoDR03;
812 else if(variable == "puChargedHadronIsoDR03") value = object->puChargedHadronIsoDR03;
813 else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
814 else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
815 else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
816 else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
817 else if(variable == "rhoPrime") value = object->rhoPrime;
818 else if(variable == "AEffDr03") value = object->AEffDr03;
819 else if(variable == "AEffDr04") value = object->AEffDr04;
820 else if(variable == "pfIsoR03SumChargedHadronPt") value = object->pfIsoR03SumChargedHadronPt;
821 else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
822 else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
823 else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
824 else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
825 else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
826 else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
827 else if(variable == "pfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt;
828 else if(variable == "IP") value = object->IP;
829 else if(variable == "IPError") value = object->IPError;
830 else if(variable == "timeAtIpInOut") value = object->timeAtIpInOut;
831 else if(variable == "timeAtIpInOutErr") value = object->timeAtIpInOutErr;
832 else if(variable == "timeAtIpOutIn") value = object->timeAtIpOutIn;
833 else if(variable == "timeAtIpOutInErr") value = object->timeAtIpOutInErr;
834 else if(variable == "ecal_time") value = object->ecal_time;
835 else if(variable == "hcal_time") value = object->hcal_time;
836 else if(variable == "ecal_timeError") value = object->ecal_timeError;
837 else if(variable == "hcal_timeError") value = object->hcal_timeError;
838 else if(variable == "energy_ecal") value = object->energy_ecal;
839 else if(variable == "energy_hcal") value = object->energy_hcal;
840 else if(variable == "e3x3_ecal") value = object->e3x3_ecal;
841 else if(variable == "e3x3_hcal") value = object->e3x3_hcal;
842 else if(variable == "energyMax_ecal") value = object->energyMax_ecal;
843 else if(variable == "energyMax_hcal") value = object->energyMax_hcal;
844 else if(variable == "charge") value = object->charge;
845 else if(variable == "IDGMPTight") value = object->IDGMPTight;
846 else if(variable == "tkNumValidHits") value = object->tkNumValidHits;
847 else if(variable == "tkCharge") value = object->tkCharge;
848 else if(variable == "samNumValidHits") value = object->samNumValidHits;
849 else if(variable == "samCharge") value = object->samCharge;
850 else if(variable == "comNumValidHits") value = object->comNumValidHits;
851 else if(variable == "comCharge") value = object->comCharge;
852 else if(variable == "genId") value = object->genId;
853 else if(variable == "genCharge") value = object->genCharge;
854 else if(variable == "genNumberOfMothers") value = object->genNumberOfMothers;
855 else if(variable == "genMotherId") value = object->genMotherId;
856 else if(variable == "genMotherCharge") value = object->genMotherCharge;
857 else if(variable == "genMother0Id") value = object->genMother0Id;
858 else if(variable == "genMother1Id") value = object->genMother1Id;
859 else if(variable == "genGrandMother00Id") value = object->genGrandMother00Id;
860 else if(variable == "genGrandMother01Id") value = object->genGrandMother01Id;
861 else if(variable == "genGrandMother10Id") value = object->genGrandMother10Id;
862 else if(variable == "genGrandMother11Id") value = object->genGrandMother11Id;
863 else if(variable == "isPFMuon") value = object->isPFMuon;
864 else if(variable == "isGoodMuon_1StationTight") value = object->isGoodMuon_1StationTight;
865 else if(variable == "isGlobalMuon") value = object->isGlobalMuon;
866 else if(variable == "isTrackerMuon") value = object->isTrackerMuon;
867 else if(variable == "isStandAloneMuon") value = object->isStandAloneMuon;
868 else if(variable == "isGlobalMuonPromptTight") value = object->isGlobalMuonPromptTight;
869 else if(variable == "numberOfValidMuonHits") value = object->numberOfValidMuonHits;
870 else if(variable == "numberOfValidTrackerHits") value = object->numberOfValidTrackerHits;
871 else if(variable == "numberOfLayersWithMeasurement") value = object->numberOfLayersWithMeasurement;
872 else if(variable == "pixelLayersWithMeasurement") value = object->pixelLayersWithMeasurement;
873 else if(variable == "numberOfMatches") value = object->numberOfMatches;
874 else if(variable == "numberOfValidTrackerHitsInnerTrack") value = object->numberOfValidTrackerHitsInnerTrack;
875 else if(variable == "numberOfValidPixelHits") value = object->numberOfValidPixelHits;
876 else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations;
877 else if(variable == "time_ndof") value = object->time_ndof;
878
879 //user-defined variables
880 else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
881 else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
882 else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
883 else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
884 else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
885 else if(variable == "tightID") {
886 value = object->isGlobalMuon > 0 \
887 && object->isPFMuon > 0 \
888 && object->normalizedChi2 < 10 \
889 && object->numberOfValidMuonHits > 0 \
890 && object->numberOfMatchedStations > 1 \
891 && fabs(object->correctedD0Vertex) < 0.2 \
892 && fabs(object->correctedDZ) < 0.5 \
893 && object->numberOfValidPixelHits > 0 \
894 && object->numberOfLayersWithMeasurement > 5;
895 }
896 else if(variable == "tightIDdisplaced"){
897 value = object->isGlobalMuon > 0 \
898 && object->normalizedChi2 < 10 \
899 && object->numberOfValidMuonHits > 0 \
900 && object->numberOfMatchedStations > 1 \
901 && object->numberOfValidPixelHits > 0 \
902 && object->numberOfLayersWithMeasurement > 5;
903 }
904
905 // else if(variable == "genMatchedID"){
906 // value = getGenMatchedParticle(object)->id;
907 // }
908 // else if(variable == "genMatchedMotherID"){
909 // value = getGenMatchedParticle(object)->motherId;
910 // }
911 // else if(variable == "genMatchedGrandmotherID"){
912 // value = getGenMatchedParticle(object)->grandMotherId;
913 // }
914
915
916
917 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
918
919 value = applyFunction(function, value);
920
921 return value;
922 }
923
924
925 double
926 OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
927
928 double value = 0.0;
929 if(variable == "energy") value = object->energy;
930 else if(variable == "et") value = object->et;
931 else if(variable == "gsfEt") value = object->gsfEt;
932 else if(variable == "pt") value = object->pt;
933 else if(variable == "px") value = object->px;
934 else if(variable == "py") value = object->py;
935 else if(variable == "pz") value = object->pz;
936 else if(variable == "phi") value = object->phi;
937 else if(variable == "eta") value = object->eta;
938 else if(variable == "theta") value = object->theta;
939 else if(variable == "pIn") value = object->pIn;
940 else if(variable == "pOut") value = object->pOut;
941 else if(variable == "EscOverPin") value = object->EscOverPin;
942 else if(variable == "EseedOverPout") value = object->EseedOverPout;
943 else if(variable == "hadOverEm") value = object->hadOverEm;
944 else if(variable == "trackIso") value = object->trackIso;
945 else if(variable == "ecalIso") value = object->ecalIso;
946 else if(variable == "hcalIso") value = object->hcalIso;
947 else if(variable == "caloIso") value = object->caloIso;
948 else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
949 else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
950 else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
951 else if(variable == "hcalIsoDR03depth1") value = object->hcalIsoDR03depth1;
952 else if(variable == "hcalIsoDR03depth2") value = object->hcalIsoDR03depth2;
953 else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
954 else if(variable == "trackIsoDR04") value = object->trackIsoDR04;
955 else if(variable == "ecalIsoDR04") value = object->ecalIsoDR04;
956 else if(variable == "hcalIsoDR04") value = object->hcalIsoDR04;
957 else if(variable == "hcalIsoDR04depth1") value = object->hcalIsoDR04depth1;
958 else if(variable == "hcalIsoDR04depth2") value = object->hcalIsoDR04depth2;
959 else if(variable == "caloIsoDR04") value = object->caloIsoDR04;
960 else if(variable == "fbrem") value = object->fbrem;
961 else if(variable == "absInvEMinusInvPin") value = object->absInvEMinusInvPin;
962 else if(variable == "delPhiIn") value = object->delPhiIn;
963 else if(variable == "delEtaIn") value = object->delEtaIn;
964 else if(variable == "genET") value = object->genET;
965 else if(variable == "genPT") value = object->genPT;
966 else if(variable == "genPhi") value = object->genPhi;
967 else if(variable == "genEta") value = object->genEta;
968 else if(variable == "genMotherET") value = object->genMotherET;
969 else if(variable == "genMotherPT") value = object->genMotherPT;
970 else if(variable == "genMotherPhi") value = object->genMotherPhi;
971 else if(variable == "genMotherEta") value = object->genMotherEta;
972 else if(variable == "vx") value = object->vx;
973 else if(variable == "vy") value = object->vy;
974 else if(variable == "vz") value = object->vz;
975 else if(variable == "scEnergy") value = object->scEnergy;
976 else if(variable == "scRawEnergy") value = object->scRawEnergy;
977 else if(variable == "scSigmaEtaEta") value = object->scSigmaEtaEta;
978 else if(variable == "scSigmaIEtaIEta") value = object->scSigmaIEtaIEta;
979 else if(variable == "scE1x5") value = object->scE1x5;
980 else if(variable == "scE2x5Max") value = object->scE2x5Max;
981 else if(variable == "scE5x5") value = object->scE5x5;
982 else if(variable == "scEt") value = object->scEt;
983 else if(variable == "scEta") value = object->scEta;
984 else if(variable == "scPhi") value = object->scPhi;
985 else if(variable == "scZ") value = object->scZ;
986 else if(variable == "tkNormChi2") value = object->tkNormChi2;
987 else if(variable == "tkPT") value = object->tkPT;
988 else if(variable == "tkEta") value = object->tkEta;
989 else if(variable == "tkPhi") value = object->tkPhi;
990 else if(variable == "tkDZ") value = object->tkDZ;
991 else if(variable == "tkD0") value = object->tkD0;
992 else if(variable == "tkD0bs") value = object->tkD0bs;
993 else if(variable == "tkD0err") value = object->tkD0err;
994 else if(variable == "mva") value = object->mva;
995 else if(variable == "mvaTrigV0") value = object->mvaTrigV0;
996 else if(variable == "mvaNonTrigV0") value = object->mvaNonTrigV0;
997 else if(variable == "dist") value = object->dist;
998 else if(variable == "dcot") value = object->dcot;
999 else if(variable == "convradius") value = object->convradius;
1000 else if(variable == "convPointX") value = object->convPointX;
1001 else if(variable == "convPointY") value = object->convPointY;
1002 else if(variable == "convPointZ") value = object->convPointZ;
1003 else if(variable == "eMax") value = object->eMax;
1004 else if(variable == "eLeft") value = object->eLeft;
1005 else if(variable == "eRight") value = object->eRight;
1006 else if(variable == "eTop") value = object->eTop;
1007 else if(variable == "eBottom") value = object->eBottom;
1008 else if(variable == "e3x3") value = object->e3x3;
1009 else if(variable == "swissCross") value = object->swissCross;
1010 else if(variable == "seedEnergy") value = object->seedEnergy;
1011 else if(variable == "seedTime") value = object->seedTime;
1012 else if(variable == "swissCrossNoI85") value = object->swissCrossNoI85;
1013 else if(variable == "swissCrossI85") value = object->swissCrossI85;
1014 else if(variable == "E2overE9NoI85") value = object->E2overE9NoI85;
1015 else if(variable == "E2overE9I85") value = object->E2overE9I85;
1016 else if(variable == "correctedD0") value = object->correctedD0;
1017 else if(variable == "correctedD0Vertex") value = object->correctedD0Vertex;
1018 else if(variable == "correctedDZ") value = object->correctedDZ;
1019 else if(variable == "particleIso") value = object->particleIso;
1020 else if(variable == "chargedHadronIso") value = object->chargedHadronIso;
1021 else if(variable == "neutralHadronIso") value = object->neutralHadronIso;
1022 else if(variable == "photonIso") value = object->photonIso;
1023 else if(variable == "puChargedHadronIso") value = object->puChargedHadronIso;
1024 else if(variable == "chargedHadronIsoDR03") value = object->chargedHadronIsoDR03;
1025 else if(variable == "neutralHadronIsoDR03") value = object->neutralHadronIsoDR03;
1026 else if(variable == "photonIsoDR03") value = object->photonIsoDR03;
1027 else if(variable == "puChargedHadronIsoDR03") value = object->puChargedHadronIsoDR03;
1028 else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1029 else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1030 else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1031 else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1032 else if(variable == "rhoPrime") value = object->rhoPrime;
1033 else if(variable == "AEffDr03") value = object->AEffDr03;
1034 else if(variable == "AEffDr04") value = object->AEffDr04;
1035 else if(variable == "IP") value = object->IP;
1036 else if(variable == "IPError") value = object->IPError;
1037 else if(variable == "charge") value = object->charge;
1038 else if(variable == "classification") value = object->classification;
1039 else if(variable == "genId") value = object->genId;
1040 else if(variable == "genCharge") value = object->genCharge;
1041 else if(variable == "genNumberOfMothers") value = object->genNumberOfMothers;
1042 else if(variable == "genMotherId") value = object->genMotherId;
1043 else if(variable == "genMotherCharge") value = object->genMotherCharge;
1044 else if(variable == "genMother0Id") value = object->genMother0Id;
1045 else if(variable == "genMother1Id") value = object->genMother1Id;
1046 else if(variable == "genGrandMother00Id") value = object->genGrandMother00Id;
1047 else if(variable == "genGrandMother01Id") value = object->genGrandMother01Id;
1048 else if(variable == "genGrandMother10Id") value = object->genGrandMother10Id;
1049 else if(variable == "genGrandMother11Id") value = object->genGrandMother11Id;
1050 else if(variable == "numClusters") value = object->numClusters;
1051 else if(variable == "tkNumValidHits") value = object->tkNumValidHits;
1052 else if(variable == "tkCharge") value = object->tkCharge;
1053 else if(variable == "gsfCharge") value = object->gsfCharge;
1054 else if(variable == "isEB") value = object->isEB;
1055 else if(variable == "isEE") value = object->isEE;
1056 else if(variable == "isGap") value = object->isGap;
1057 else if(variable == "isEBEEGap") value = object->isEBEEGap;
1058 else if(variable == "isEBGap") value = object->isEBGap;
1059 else if(variable == "isEEGap") value = object->isEEGap;
1060 else if(variable == "isEcalDriven") value = object->isEcalDriven;
1061 else if(variable == "isTrackerDriven") value = object->isTrackerDriven;
1062 else if(variable == "numberOfLostHits") value = object->numberOfLostHits;
1063 else if(variable == "numberOfExpectedInnerHits") value = object->numberOfExpectedInnerHits;
1064 else if(variable == "numberOfValidPixelHits") value = object->numberOfValidPixelHits;
1065 else if(variable == "numberOfValidPixelBarrelHits") value = object->numberOfValidPixelBarrelHits;
1066 else if(variable == "numberOfValidPixelEndcapHits") value = object->numberOfValidPixelEndcapHits;
1067 else if(variable == "isHEEP") value = object->isHEEP;
1068 else if(variable == "isHEEPnoEt") value = object->isHEEPnoEt;
1069 else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
1070 else if(variable == "eidRobustHighEnergy") value = object->eidRobustHighEnergy;
1071 else if(variable == "eidRobustLoose") value = object->eidRobustLoose;
1072 else if(variable == "eidRobustTight") value = object->eidRobustTight;
1073 else if(variable == "eidLoose") value = object->eidLoose;
1074 else if(variable == "eidTight") value = object->eidTight;
1075 else if(variable == "eidVeryLooseMC") value = object->eidVeryLooseMC;
1076 else if(variable == "eidLooseMC") value = object->eidLooseMC;
1077 else if(variable == "eidMediumMC") value = object->eidMediumMC;
1078 else if(variable == "eidTightMC") value = object->eidTightMC;
1079 else if(variable == "eidSuperTightMC") value = object->eidSuperTightMC;
1080 else if(variable == "eidHyperTight1MC") value = object->eidHyperTight1MC;
1081 else if(variable == "eidHyperTight2MC") value = object->eidHyperTight2MC;
1082 else if(variable == "eidHyperTight3MC") value = object->eidHyperTight3MC;
1083 else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC;
1084 else if(variable == "passConvVeto") value = object->passConvVeto;
1085
1086 //user-defined variables
1087 else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1088 else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1089 else if(variable == "detIso") value = (object->trackIso) / object->pt;
1090 else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1091 else if(variable == "correctedD0VertexInEB"){
1092 if(fabs(object->eta) < 0.8) value = object->correctedD0Vertex;
1093 else value = -999;
1094 }
1095 else if(variable == "correctedD0VertexOutEB"){
1096 if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0Vertex;
1097 else value = -999;
1098 }
1099 else if(variable == "correctedD0VertexEE"){
1100 if(object->isEE) value = object->correctedD0Vertex;
1101 else value = -999;
1102 }
1103
1104 else if(variable == "correctedD0BeamspotInEB"){
1105 if(fabs(object->eta) < 0.8) value = object->correctedD0;
1106 else value = -999;
1107 }
1108 else if(variable == "correctedD0BeamspotOutEB"){
1109 if(object->isEB && fabs(object->eta) > 0.8) value = object->correctedD0;
1110 else value = -999;
1111 }
1112 else if(variable == "correctedD0BeamspotEE"){
1113 if(object->isEE) value = object->correctedD0;
1114 else value = -999;
1115 }
1116
1117 else if(variable == "correctedD0OriginInEB"){
1118 if(fabs(object->eta) < 0.8) value = object->tkD0;
1119 else value = -999;
1120 }
1121 else if(variable == "correctedD0OriginOutEB"){
1122 if(object->isEB && fabs(object->eta) > 0.8) value = object->tkD0;
1123 else value = -999;
1124 }
1125 else if(variable == "correctedD0OriginEE"){
1126 if(object->isEE) value = object->tkD0;
1127 else value = -999;
1128 }
1129
1130 else if(variable == "tightIDdisplaced"){
1131 if (object->isEB)
1132 {
1133 value = fabs(object->delEtaIn) < 0.004 \
1134 && fabs (object->delPhiIn) < 0.03 \
1135 && object->scSigmaIEtaIEta < 0.01 \
1136 && object->hadOverEm < 0.12 \
1137 && object->absInvEMinusInvPin < 0.05;
1138 }
1139 else
1140 {
1141 value = fabs (object->delEtaIn) < 0.005 \
1142 && fabs (object->delPhiIn) < 0.02 \
1143 && object->scSigmaIEtaIEta < 0.03 \
1144 && object->hadOverEm < 0.10 \
1145 && object->absInvEMinusInvPin < 0.05;
1146 }
1147 }
1148
1149 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1150
1151 value = applyFunction(function, value);
1152
1153 return value;
1154 }
1155
1156
1157 double
1158 OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
1159
1160 double value = 0.0;
1161
1162 if(variable == "weight") value = object->weight;
1163 else if(variable == "pthat") value = object->pthat;
1164 else if(variable == "qScale") value = object->qScale;
1165 else if(variable == "alphaQCD") value = object->alphaQCD;
1166 else if(variable == "alphaQED") value = object->alphaQED;
1167 else if(variable == "scalePDF") value = object->scalePDF;
1168 else if(variable == "x1") value = object->x1;
1169 else if(variable == "x2") value = object->x2;
1170 else if(variable == "xPDF1") value = object->xPDF1;
1171 else if(variable == "xPDF2") value = object->xPDF2;
1172 else if(variable == "BSx") value = object->BSx;
1173 else if(variable == "BSy") value = object->BSy;
1174 else if(variable == "BSz") value = object->BSz;
1175 else if(variable == "PVx") value = object->PVx;
1176 else if(variable == "PVy") value = object->PVy;
1177 else if(variable == "PVz") value = object->PVz;
1178 else if(variable == "bField") value = object->bField;
1179 else if(variable == "instLumi") value = object->instLumi;
1180 else if(variable == "bxLumi") value = object->bxLumi;
1181 else if(variable == "FilterOutScrapingFraction") value = object->FilterOutScrapingFraction;
1182 else if(variable == "sumNVtx") value = object->sumNVtx;
1183 else if(variable == "sumTrueNVtx") value = object->sumTrueNVtx;
1184 else if(variable == "nm1_true") value = object->nm1_true;
1185 else if(variable == "n0_true") value = object->n0_true;
1186 else if(variable == "np1_true") value = object->np1_true;
1187 else if(variable == "numTruePV") value = object->numTruePV;
1188 else if(variable == "Q2ScaleUpWgt") value = object->Q2ScaleUpWgt;
1189 else if(variable == "Q2ScaleDownWgt") value = object->Q2ScaleDownWgt;
1190 else if(variable == "rho_kt6PFJets") value = object->rho_kt6PFJets;
1191 else if(variable == "rho_kt6PFJetsCentralChargedPileUp") value = object->rho_kt6PFJetsCentralChargedPileUp;
1192 else if(variable == "rho_kt6PFJetsCentralNeutral") value = object->rho_kt6PFJetsCentralNeutral;
1193 else if(variable == "rho_kt6PFJetsCentralNeutralTight") value = object->rho_kt6PFJetsCentralNeutralTight;
1194 else if(variable == "run") value = object->run;
1195 else if(variable == "lumi") value = object->lumi;
1196 else if(variable == "sample") value = object->sample;
1197 else if(variable == "numPV") value = object->numPV;
1198 else if(variable == "W0decay") value = object->W0decay;
1199 else if(variable == "W1decay") value = object->W1decay;
1200 else if(variable == "Z0decay") value = object->Z0decay;
1201 else if(variable == "Z1decay") value = object->Z1decay;
1202 else if(variable == "H0decay") value = object->H0decay;
1203 else if(variable == "H1decay") value = object->H1decay;
1204 else if(variable == "hcalnoiseLoose") value = object->hcalnoiseLoose;
1205 else if(variable == "hcalnoiseTight") value = object->hcalnoiseTight;
1206 else if(variable == "GoodVertex") value = object->GoodVertex;
1207 else if(variable == "FilterOutScraping") value = object->FilterOutScraping;
1208 else if(variable == "HBHENoiseFilter") value = object->HBHENoiseFilter;
1209 else if(variable == "CSCLooseHaloId") value = object->CSCLooseHaloId;
1210 else if(variable == "CSCTightHaloId") value = object->CSCTightHaloId;
1211 else if(variable == "EcalLooseHaloId") value = object->EcalLooseHaloId;
1212 else if(variable == "EcalTightHaloId") value = object->EcalTightHaloId;
1213 else if(variable == "HcalLooseHaloId") value = object->HcalLooseHaloId;
1214 else if(variable == "HcalTightHaloId") value = object->HcalTightHaloId;
1215 else if(variable == "GlobalLooseHaloId") value = object->GlobalLooseHaloId;
1216 else if(variable == "GlobalTightHaloId") value = object->GlobalTightHaloId;
1217 else if(variable == "LooseId") value = object->LooseId;
1218 else if(variable == "TightId") value = object->TightId;
1219 else if(variable == "numGenPV") value = object->numGenPV;
1220 else if(variable == "nm1") value = object->nm1;
1221 else if(variable == "n0") value = object->n0;
1222 else if(variable == "np1") value = object->np1;
1223 else if(variable == "id1") value = object->id1;
1224 else if(variable == "id2") value = object->id2;
1225 else if(variable == "evt") value = object->evt;
1226
1227 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1228
1229 value = applyFunction(function, value);
1230
1231 return value;
1232 }
1233
1234 double
1235 OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
1236
1237 double value = 0.0;
1238
1239 if(variable == "px") value = object->px;
1240 else if(variable == "py") value = object->py;
1241 else if(variable == "pz") value = object->pz;
1242 else if(variable == "energy") value = object->energy;
1243 else if(variable == "et") value = object->et;
1244 else if(variable == "pt") value = object->pt;
1245 else if(variable == "eta") value = object->eta;
1246 else if(variable == "phi") value = object->phi;
1247 else if(variable == "emFraction") value = object->emFraction;
1248 else if(variable == "leadingTrackPt") value = object->leadingTrackPt;
1249 else if(variable == "leadingTrackIpVtdxy") value = object->leadingTrackIpVtdxy;
1250 else if(variable == "leadingTrackIpVtdz") value = object->leadingTrackIpVtdz;
1251 else if(variable == "leadingTrackIpVtdxyError") value = object->leadingTrackIpVtdxyError;
1252 else if(variable == "leadingTrackIpVtdzError") value = object->leadingTrackIpVtdzError;
1253 else if(variable == "leadingTrackVx") value = object->leadingTrackVx;
1254 else if(variable == "leadingTrackVy") value = object->leadingTrackVy;
1255 else if(variable == "leadingTrackVz") value = object->leadingTrackVz;
1256 else if(variable == "leadingTrackValidHits") value = object->leadingTrackValidHits;
1257 else if(variable == "leadingTrackNormChiSqrd") value = object->leadingTrackNormChiSqrd;
1258 else if(variable == "numProngs") value = object->numProngs;
1259 else if(variable == "numSignalGammas") value = object->numSignalGammas;
1260 else if(variable == "numSignalNeutrals") value = object->numSignalNeutrals;
1261 else if(variable == "numSignalPiZeros") value = object->numSignalPiZeros;
1262 else if(variable == "decayMode") value = object->decayMode;
1263 else if(variable == "charge") value = object->charge;
1264 else if(variable == "inTheCracks") value = object->inTheCracks;
1265 else if(variable == "HPSagainstElectronLoose") value = object->HPSagainstElectronLoose;
1266 else if(variable == "HPSagainstElectronMVA") value = object->HPSagainstElectronMVA;
1267 else if(variable == "HPSagainstElectronMedium") value = object->HPSagainstElectronMedium;
1268 else if(variable == "HPSagainstElectronTight") value = object->HPSagainstElectronTight;
1269 else if(variable == "HPSagainstMuonLoose") value = object->HPSagainstMuonLoose;
1270 else if(variable == "HPSagainstMuonMedium") value = object->HPSagainstMuonMedium;
1271 else if(variable == "HPSagainstMuonTight") value = object->HPSagainstMuonTight;
1272 else if(variable == "HPSbyLooseCombinedIsolationDeltaBetaCorr") value = object->HPSbyLooseCombinedIsolationDeltaBetaCorr;
1273 else if(variable == "HPSbyMediumCombinedIsolationDeltaBetaCorr") value = object->HPSbyMediumCombinedIsolationDeltaBetaCorr;
1274 else if(variable == "HPSbyTightCombinedIsolationDeltaBetaCorr") value = object->HPSbyTightCombinedIsolationDeltaBetaCorr;
1275 else if(variable == "HPSbyVLooseCombinedIsolationDeltaBetaCorr") value = object->HPSbyVLooseCombinedIsolationDeltaBetaCorr;
1276 else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
1277 else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1278
1279
1280 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1281
1282 value = applyFunction(function, value);
1283
1284 return value;
1285 }
1286
1287 double
1288 OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
1289
1290 double value = 0.0;
1291
1292 if(variable == "et") value = object->et;
1293 else if(variable == "pt") value = object->pt;
1294 else if(variable == "px") value = object->px;
1295 else if(variable == "py") value = object->py;
1296 else if(variable == "phi") value = object->phi;
1297 else if(variable == "Upt") value = object->Upt;
1298 else if(variable == "Uphi") value = object->Uphi;
1299 else if(variable == "NeutralEMFraction") value = object->NeutralEMFraction;
1300 else if(variable == "NeutralHadEtFraction") value = object->NeutralHadEtFraction;
1301 else if(variable == "ChargedEMEtFraction") value = object->ChargedEMEtFraction;
1302 else if(variable == "ChargedHadEtFraction") value = object->ChargedHadEtFraction;
1303 else if(variable == "MuonEtFraction") value = object->MuonEtFraction;
1304 else if(variable == "Type6EtFraction") value = object->Type6EtFraction;
1305 else if(variable == "Type7EtFraction") value = object->Type7EtFraction;
1306 else if(variable == "genPT") value = object->genPT;
1307 else if(variable == "genPhi") value = object->genPhi;
1308 else if(variable == "muonCorEx") value = object->muonCorEx;
1309 else if(variable == "muonCorEy") value = object->muonCorEy;
1310 else if(variable == "jet20CorEx") value = object->jet20CorEx;
1311 else if(variable == "jet20CorEy") value = object->jet20CorEy;
1312 else if(variable == "jet1CorEx") value = object->jet1CorEx;
1313 else if(variable == "jet1CorEy") value = object->jet1CorEy;
1314 else if(variable == "sumET") value = object->sumET;
1315 else if(variable == "corSumET") value = object->corSumET;
1316 else if(variable == "mEtSig") value = object->mEtSig;
1317 else if(variable == "metSignificance") value = object->metSignificance;
1318 else if(variable == "significance") value = object->significance;
1319 else if(variable == "sigmaX2") value = object->sigmaX2;
1320 else if(variable == "sigmaY2") value = object->sigmaY2;
1321 else if(variable == "sigmaXY") value = object->sigmaXY;
1322 else if(variable == "sigmaYX") value = object->sigmaYX;
1323 else if(variable == "maxEtInEmTowers") value = object->maxEtInEmTowers;
1324 else if(variable == "emEtFraction") value = object->emEtFraction;
1325 else if(variable == "emEtInEB") value = object->emEtInEB;
1326 else if(variable == "emEtInEE") value = object->emEtInEE;
1327 else if(variable == "emEtInHF") value = object->emEtInHF;
1328 else if(variable == "maxEtInHadTowers") value = object->maxEtInHadTowers;
1329 else if(variable == "hadEtFraction") value = object->hadEtFraction;
1330 else if(variable == "hadEtInHB") value = object->hadEtInHB;
1331 else if(variable == "hadEtInHE") value = object->hadEtInHE;
1332 else if(variable == "hadEtInHF") value = object->hadEtInHF;
1333 else if(variable == "hadEtInHO") value = object->hadEtInHO;
1334 else if(variable == "UDeltaPx") value = object->UDeltaPx;
1335 else if(variable == "UDeltaPy") value = object->UDeltaPy;
1336 else if(variable == "UDeltaP") value = object->UDeltaP;
1337 else if(variable == "Uscale") value = object->Uscale;
1338 else if(variable == "type2corPx") value = object->type2corPx;
1339 else if(variable == "type2corPy") value = object->type2corPy;
1340 else if(variable == "T2pt") value = object->T2pt;
1341 else if(variable == "T2px") value = object->T2px;
1342 else if(variable == "T2py") value = object->T2py;
1343 else if(variable == "T2phi") value = object->T2phi;
1344 else if(variable == "T2sumET") value = object->T2sumET;
1345 else if(variable == "pfT1jet1pt") value = object->pfT1jet1pt;
1346 else if(variable == "pfT1jet1phi") value = object->pfT1jet1phi;
1347 else if(variable == "pfT1jet6pt") value = object->pfT1jet6pt;
1348 else if(variable == "pfT1jet6phi") value = object->pfT1jet6phi;
1349 else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
1350 else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
1351
1352 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1353
1354 value = applyFunction(function, value);
1355
1356 return value;
1357 }
1358
1359 double
1360 OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1361
1362 double value = 0.0;
1363
1364 if(variable == "pt") value = object->pt;
1365 else if(variable == "px") value = object->px;
1366 else if(variable == "py") value = object->py;
1367 else if(variable == "pz") value = object->pz;
1368 else if(variable == "phi") value = object->phi;
1369 else if(variable == "eta") value = object->eta;
1370 else if(variable == "theta") value = object->theta;
1371 else if(variable == "normChi2") value = object->normChi2;
1372 else if(variable == "dZ") value = object->dZ;
1373 else if(variable == "d0") value = object->d0;
1374 else if(variable == "d0err") value = object->d0err;
1375 else if(variable == "vx") value = object->vx;
1376 else if(variable == "vy") value = object->vy;
1377 else if(variable == "vz") value = object->vz;
1378 else if(variable == "charge") value = object->charge;
1379 else if(variable == "numValidHits") value = object->numValidHits;
1380 else if(variable == "isHighPurity") value = object->isHighPurity;
1381
1382
1383 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1384
1385 value = applyFunction(function, value);
1386
1387 return value;
1388 }
1389
1390 double
1391 OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
1392
1393 double value = 0.0;
1394
1395 if(variable == "pt") value = object->pt;
1396 else if(variable == "eta") value = object->eta;
1397 else if(variable == "phi") value = object->phi;
1398 else if(variable == "px") value = object->px;
1399 else if(variable == "py") value = object->py;
1400 else if(variable == "pz") value = object->pz;
1401 else if(variable == "et") value = object->et;
1402 else if(variable == "energy") value = object->energy;
1403 else if(variable == "mass") value = object->mass;
1404 else if(variable == "emEnergy") value = object->emEnergy;
1405 else if(variable == "hadEnergy") value = object->hadEnergy;
1406 else if(variable == "invisibleEnergy") value = object->invisibleEnergy;
1407 else if(variable == "auxiliaryEnergy") value = object->auxiliaryEnergy;
1408 else if(variable == "charge") value = object->charge;
1409
1410
1411 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1412
1413 value = applyFunction(function, value);
1414
1415 return value;
1416 }
1417
1418 double
1419 OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
1420
1421 double value = 0.0;
1422
1423 if(variable == "energy") value = object->energy;
1424 else if(variable == "et") value = object->et;
1425 else if(variable == "pt") value = object->pt;
1426 else if(variable == "px") value = object->px;
1427 else if(variable == "py") value = object->py;
1428 else if(variable == "pz") value = object->pz;
1429 else if(variable == "phi") value = object->phi;
1430 else if(variable == "eta") value = object->eta;
1431 else if(variable == "theta") value = object->theta;
1432 else if(variable == "mass") value = object->mass;
1433 else if(variable == "vx") value = object->vx;
1434 else if(variable == "vy") value = object->vy;
1435 else if(variable == "vz") value = object->vz;
1436 else if(variable == "motherET") value = object->motherET;
1437 else if(variable == "motherPT") value = object->motherPT;
1438 else if(variable == "motherPhi") value = object->motherPhi;
1439 else if(variable == "motherEta") value = object->motherEta;
1440 else if(variable == "mother0ET") value = object->mother0ET;
1441 else if(variable == "mother0PT") value = object->mother0PT;
1442 else if(variable == "mother0Phi") value = object->mother0Phi;
1443 else if(variable == "mother0Eta") value = object->mother0Eta;
1444 else if(variable == "mother1ET") value = object->mother1ET;
1445 else if(variable == "mother1PT") value = object->mother1PT;
1446 else if(variable == "mother1Phi") value = object->mother1Phi;
1447 else if(variable == "mother1Eta") value = object->mother1Eta;
1448 else if(variable == "daughter0ET") value = object->daughter0ET;
1449 else if(variable == "daughter0PT") value = object->daughter0PT;
1450 else if(variable == "daughter0Phi") value = object->daughter0Phi;
1451 else if(variable == "daughter0Eta") value = object->daughter0Eta;
1452 else if(variable == "daughter1ET") value = object->daughter1ET;
1453 else if(variable == "daughter1PT") value = object->daughter1PT;
1454 else if(variable == "daughter1Phi") value = object->daughter1Phi;
1455 else if(variable == "daughter1Eta") value = object->daughter1Eta;
1456 else if(variable == "grandMotherET") value = object->grandMotherET;
1457 else if(variable == "grandMotherPT") value = object->grandMotherPT;
1458 else if(variable == "grandMotherPhi") value = object->grandMotherPhi;
1459 else if(variable == "grandMotherEta") value = object->grandMotherEta;
1460 else if(variable == "grandMother00ET") value = object->grandMother00ET;
1461 else if(variable == "grandMother00PT") value = object->grandMother00PT;
1462 else if(variable == "grandMother00Phi") value = object->grandMother00Phi;
1463 else if(variable == "grandMother00Eta") value = object->grandMother00Eta;
1464 else if(variable == "grandMother01ET") value = object->grandMother01ET;
1465 else if(variable == "grandMother01PT") value = object->grandMother01PT;
1466 else if(variable == "grandMother01Phi") value = object->grandMother01Phi;
1467 else if(variable == "grandMother01Eta") value = object->grandMother01Eta;
1468 else if(variable == "grandMother10ET") value = object->grandMother10ET;
1469 else if(variable == "grandMother10PT") value = object->grandMother10PT;
1470 else if(variable == "grandMother10Phi") value = object->grandMother10Phi;
1471 else if(variable == "grandMother10Eta") value = object->grandMother10Eta;
1472 else if(variable == "grandMother11ET") value = object->grandMother11ET;
1473 else if(variable == "grandMother11PT") value = object->grandMother11PT;
1474 else if(variable == "grandMother11Phi") value = object->grandMother11Phi;
1475 else if(variable == "grandMother11Eta") value = object->grandMother11Eta;
1476 else if(variable == "charge") value = object->charge;
1477 else if(variable == "id") value = object->id;
1478 else if(variable == "status") value = object->status;
1479 else if(variable == "motherId") value = object->motherId;
1480 else if(variable == "motherCharge") value = object->motherCharge;
1481 else if(variable == "mother0Id") value = object->mother0Id;
1482 else if(variable == "mother0Status") value = object->mother0Status;
1483 else if(variable == "mother0Charge") value = object->mother0Charge;
1484 else if(variable == "mother1Id") value = object->mother1Id;
1485 else if(variable == "mother1Status") value = object->mother1Status;
1486 else if(variable == "mother1Charge") value = object->mother1Charge;
1487 else if(variable == "daughter0Id") value = object->daughter0Id;
1488 else if(variable == "daughter0Status") value = object->daughter0Status;
1489 else if(variable == "daughter0Charge") value = object->daughter0Charge;
1490 else if(variable == "daughter1Id") value = object->daughter1Id;
1491 else if(variable == "daughter1Status") value = object->daughter1Status;
1492 else if(variable == "daughter1Charge") value = object->daughter1Charge;
1493 else if(variable == "grandMotherId") value = object->grandMotherId;
1494 else if(variable == "grandMotherCharge") value = object->grandMotherCharge;
1495 else if(variable == "grandMother00Id") value = object->grandMother00Id;
1496 else if(variable == "grandMother00Status") value = object->grandMother00Status;
1497 else if(variable == "grandMother00Charge") value = object->grandMother00Charge;
1498 else if(variable == "grandMother01Id") value = object->grandMother01Id;
1499 else if(variable == "grandMother01Status") value = object->grandMother01Status;
1500 else if(variable == "grandMother01Charge") value = object->grandMother01Charge;
1501 else if(variable == "grandMother10Id") value = object->grandMother10Id;
1502 else if(variable == "grandMother10Status") value = object->grandMother10Status;
1503 else if(variable == "grandMother10Charge") value = object->grandMother10Charge;
1504 else if(variable == "grandMother11Id") value = object->grandMother11Id;
1505 else if(variable == "grandMother11Status") value = object->grandMother11Status;
1506 else if(variable == "grandMother11Charge") value = object->grandMother11Charge;
1507
1508 //user-defined variables
1509 else if (variable == "d0"){
1510 double vx = object->vx - primaryVertex_->x,
1511 vy = object->vy - primaryVertex_->y,
1512 px = object->px,
1513 py = object->py,
1514 pt = object->pt;
1515 value = (-vx * py + vy * px) / pt;
1516 }
1517 else if (variable == "dz"){
1518 double vx = object->vx - primaryVertex_->x,
1519 vy = object->vy - primaryVertex_->y,
1520 vz = object->vz - primaryVertex_->z,
1521 px = object->px,
1522 py = object->py,
1523 pz = object->pz,
1524 pt = object->pt;
1525 value = vz - (vx * px + vy * py)/pt * (pz/pt);
1526 }
1527 else if(variable == "v0"){
1528 value = sqrt(object->vx*object->vx + object->vy*object->vy);
1529 }
1530 else if(variable == "deltaV0"){
1531 value = sqrt((object->vx-primaryVertex_->x)*(object->vx-primaryVertex_->x) + (object->vy-primaryVertex_->y)*(object->vy-primaryVertex_->y));
1532 }
1533 else if (variable == "deltaVx"){
1534 value = object->vx - primaryVertex_->x;
1535 }
1536 else if (variable == "deltaVy"){
1537 value = object->vy - primaryVertex_->y;
1538 }
1539 else if (variable == "deltaVz"){
1540 value = object->vz - primaryVertex_->z;
1541 }
1542
1543
1544 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1545
1546 value = applyFunction(function, value);
1547
1548 return value;
1549 }
1550
1551 double
1552 OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
1553
1554 double value = 0.0;
1555
1556 if(variable == "x") value = object->x;
1557 else if(variable == "xError") value = object->xError;
1558 else if(variable == "y") value = object->y;
1559 else if(variable == "yError") value = object->yError;
1560 else if(variable == "z") value = object->z;
1561 else if(variable == "zError") value = object->zError;
1562 else if(variable == "rho") value = object->rho;
1563 else if(variable == "normalizedChi2") value = object->normalizedChi2;
1564 else if(variable == "ndof") value = object->ndof;
1565 else if(variable == "isFake") value = object->isFake;
1566 else if(variable == "isValid") value = object->isValid;
1567 else if(variable == "tracksSize") value = object->tracksSize;
1568 else if(variable == "isGood") value = object->isGood;
1569
1570
1571 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1572
1573 value = applyFunction(function, value);
1574
1575 return value;
1576 }
1577
1578 double
1579 OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
1580
1581 double value = 0.0;
1582
1583 if(variable == "bx_B1_now") value = object->bx_B1_now;
1584 else if(variable == "bx_B2_now") value = object->bx_B2_now;
1585 else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
1586
1587
1588 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1589
1590 value = applyFunction(function, value);
1591
1592 return value;
1593 }
1594
1595 double
1596 OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
1597
1598 double value = 0.0;
1599
1600 if(variable == "energy") value = object->energy;
1601 else if(variable == "et") value = object->et;
1602 else if(variable == "pt") value = object->pt;
1603 else if(variable == "px") value = object->px;
1604 else if(variable == "py") value = object->py;
1605 else if(variable == "pz") value = object->pz;
1606 else if(variable == "phi") value = object->phi;
1607 else if(variable == "eta") value = object->eta;
1608 else if(variable == "theta") value = object->theta;
1609 else if(variable == "trackIso") value = object->trackIso;
1610 else if(variable == "ecalIso") value = object->ecalIso;
1611 else if(variable == "hcalIso") value = object->hcalIso;
1612 else if(variable == "caloIso") value = object->caloIso;
1613 else if(variable == "trackIsoHollowConeDR03") value = object->trackIsoHollowConeDR03;
1614 else if(variable == "trackIsoSolidConeDR03") value = object->trackIsoSolidConeDR03;
1615 else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
1616 else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
1617 else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
1618 else if(variable == "trackIsoHollowConeDR04") value = object->trackIsoHollowConeDR04;
1619 else if(variable == "trackIsoSolidConeDR04") value = object->trackIsoSolidConeDR04;
1620 else if(variable == "ecalIsoDR04") value = object->ecalIsoDR04;
1621 else if(variable == "hcalIsoDR04") value = object->hcalIsoDR04;
1622 else if(variable == "caloIsoDR04") value = object->caloIsoDR04;
1623 else if(variable == "hadOverEm") value = object->hadOverEm;
1624 else if(variable == "sigmaEtaEta") value = object->sigmaEtaEta;
1625 else if(variable == "sigmaIetaIeta") value = object->sigmaIetaIeta;
1626 else if(variable == "r9") value = object->r9;
1627 else if(variable == "scEnergy") value = object->scEnergy;
1628 else if(variable == "scRawEnergy") value = object->scRawEnergy;
1629 else if(variable == "scSeedEnergy") value = object->scSeedEnergy;
1630 else if(variable == "scEta") value = object->scEta;
1631 else if(variable == "scPhi") value = object->scPhi;
1632 else if(variable == "scZ") value = object->scZ;
1633 else if(variable == "genET") value = object->genET;
1634 else if(variable == "genPT") value = object->genPT;
1635 else if(variable == "genPhi") value = object->genPhi;
1636 else if(variable == "genEta") value = object->genEta;
1637 else if(variable == "genMotherET") value = object->genMotherET;
1638 else if(variable == "genMotherPT") value = object->genMotherPT;
1639 else if(variable == "genMotherPhi") value = object->genMotherPhi;
1640 else if(variable == "genMotherEta") value = object->genMotherEta;
1641 else if(variable == "eMax") value = object->eMax;
1642 else if(variable == "eLeft") value = object->eLeft;
1643 else if(variable == "eRight") value = object->eRight;
1644 else if(variable == "eTop") value = object->eTop;
1645 else if(variable == "eBottom") value = object->eBottom;
1646 else if(variable == "e3x3") value = object->e3x3;
1647 else if(variable == "swissCross") value = object->swissCross;
1648 else if(variable == "seedEnergy") value = object->seedEnergy;
1649 else if(variable == "seedTime") value = object->seedTime;
1650 else if(variable == "swissCrossNoI85") value = object->swissCrossNoI85;
1651 else if(variable == "swissCrossI85") value = object->swissCrossI85;
1652 else if(variable == "E2overE9NoI85") value = object->E2overE9NoI85;
1653 else if(variable == "E2overE9I85") value = object->E2overE9I85;
1654 else if(variable == "IDTight") value = object->IDTight;
1655 else if(variable == "IDLoose") value = object->IDLoose;
1656 else if(variable == "IDLooseEM") value = object->IDLooseEM;
1657 else if(variable == "genId") value = object->genId;
1658 else if(variable == "genCharge") value = object->genCharge;
1659 else if(variable == "genMotherId") value = object->genMotherId;
1660 else if(variable == "genMotherCharge") value = object->genMotherCharge;
1661 else if(variable == "isEB") value = object->isEB;
1662 else if(variable == "isEE") value = object->isEE;
1663 else if(variable == "isGap") value = object->isGap;
1664 else if(variable == "isEBEEGap") value = object->isEBEEGap;
1665 else if(variable == "isEBGap") value = object->isEBGap;
1666 else if(variable == "isEEGap") value = object->isEEGap;
1667 else if(variable == "hasPixelSeed") value = object->hasPixelSeed;
1668 else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
1669
1670
1671 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1672
1673 value = applyFunction(function, value);
1674
1675 return value;
1676 }
1677
1678 double
1679 OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
1680
1681 double value = 0.0;
1682
1683 if(variable == "energy") value = object->energy;
1684 else if(variable == "et") value = object->et;
1685 else if(variable == "ex") value = object->ex;
1686 else if(variable == "ey") value = object->ey;
1687 else if(variable == "ez") value = object->ez;
1688 else if(variable == "phi") value = object->phi;
1689 else if(variable == "eta") value = object->eta;
1690 else if(variable == "theta") value = object->theta;
1691
1692
1693 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1694
1695 value = applyFunction(function, value);
1696
1697 return value;
1698 }
1699
1700
1701 double
1702 OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
1703
1704 double value = 0.0;
1705
1706 if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
1707 else if(variable == "invMass"){
1708 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
1709 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
1710
1711 value = (fourVector1 + fourVector2).M();}
1712 else if(variable == "threeDAngle")
1713 {
1714 TVector3 threeVector1(object1->px, object1->py, object1->pz);
1715 TVector3 threeVector2(object2->px, object2->py, object2->pz);
1716 value = (threeVector1.Angle(threeVector2));
1717 }
1718
1719
1720
1721 else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
1722 else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
1723 else if(variable == "d0Sign"){
1724 double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
1725 if(d0Sign < 0) value = -0.5;
1726 else if (d0Sign > 0) value = 0.5;
1727 else value = -999;
1728 }
1729 else if(variable == "muon1CorrectedD0Vertex"){
1730 value = object1->correctedD0Vertex;
1731 }
1732 else if(variable == "muon2CorrectedD0Vertex"){
1733 value = object2->correctedD0Vertex;
1734 }
1735 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1736
1737
1738
1739
1740
1741
1742
1743
1744 value = applyFunction(function, value);
1745
1746 return value;
1747 }
1748
1749 double
1750 OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
1751
1752 double value = 0.0;
1753
1754 if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
1755 else if(variable == "invMass"){
1756 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
1757 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
1758
1759 value = (fourVector1 + fourVector2).M();}
1760 else if(variable == "threeDAngle")
1761 {
1762 TVector3 threeVector1(object1->px, object1->py, object1->pz);
1763 TVector3 threeVector2(object2->px, object2->py, object2->pz);
1764 value = (threeVector1.Angle(threeVector2));
1765 }
1766
1767
1768
1769
1770 else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
1771 else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
1772
1773
1774
1775
1776
1777 else if(variable == "d0Sign"){
1778 double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
1779 if(d0Sign < 0) value = -0.5;
1780 else if (d0Sign > 0) value = 0.5;
1781 else value = -999;
1782 }
1783 else if(variable == "electron1CorrectedD0Vertex"){
1784 value = object1->correctedD0Vertex;
1785 }
1786 else if(variable == "electron2CorrectedD0Vertex"){
1787 value = object2->correctedD0Vertex;
1788 }
1789
1790 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1791
1792 value = applyFunction(function, value);
1793
1794 return value;
1795 }
1796
1797 double
1798 OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
1799
1800 double value = 0.0;
1801
1802 if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
1803 else if(variable == "invMass"){
1804 TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
1805 TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
1806
1807 value = (fourVector1 + fourVector2).M();}
1808 else if(variable == "threeDAngle")
1809 {
1810 TVector3 threeVector1(object1->px, object1->py, object1->pz);
1811 TVector3 threeVector2(object2->px, object2->py, object2->pz);
1812 value = (threeVector1.Angle(threeVector2));
1813 }
1814
1815
1816
1817
1818 else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
1819 else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
1820 else if(variable == "d0Sign"){
1821 double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
1822 if(d0Sign < 0) value = -0.5;
1823 else if (d0Sign > 0) value = 0.5;
1824 else value = -999;
1825 }
1826 else if(variable == "electronCorrectedD0Vertex"){
1827 value = object1->correctedD0Vertex;
1828 }
1829 else if(variable == "muonCorrectedD0Vertex"){
1830 value = object2->correctedD0Vertex;
1831 }
1832
1833
1834 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1835
1836 value = applyFunction(function, value);
1837
1838 return value;
1839 }
1840
1841
1842 double
1843 OSUAnalysis::applyFunction(string function, double value){
1844
1845 if(function == "abs") value = fabs(value);
1846 else if(function == "fabs") value = fabs(value);
1847
1848
1849 else if(function == "") value = value;
1850 else{std::cout << "WARNING: invalid function '" << function << "'\n";}
1851
1852 return value;
1853
1854 }
1855
1856
1857 template <class InputCollection>
1858 void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
1859
1860 for (uint object = 0; object != inputCollection->size(); object++){
1861
1862 bool decision = true;//object passes if this cut doesn't cut on that type of object
1863
1864 if(currentCut.inputCollection == inputType){
1865
1866 vector<bool> subcutDecisions;
1867 for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
1868 double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
1869 subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
1870 }
1871 if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
1872 else{
1873 bool tempDecision = true;
1874 for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
1875 if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
1876 tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
1877 else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
1878 tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
1879 }
1880 decision = tempDecision;
1881 }
1882 }
1883 individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
1884
1885 //set flags for objects that pass each cut AND all the previous cuts
1886 bool previousCumulativeFlag = true;
1887 for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
1888 if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
1889 else{ previousCumulativeFlag = false; break;}
1890 }
1891 cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
1892
1893 }
1894
1895 }
1896
1897
1898 template <class InputCollection1, class InputCollection2>
1899 void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
1900 InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){
1901
1902
1903 bool sameObjects = false;
1904 if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
1905
1906 int counter = 0;
1907 for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
1908 for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
1909
1910 if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
1911
1912
1913 bool decision = true;//object passes if this cut doesn't cut on that type of object
1914
1915 if(currentCut.inputCollection == inputType){
1916
1917 vector<bool> subcutDecisions;
1918 for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
1919 double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
1920 subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
1921 }
1922
1923 if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
1924 else{
1925 bool tempDecision = true;
1926 for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
1927 if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
1928 tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
1929 else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
1930 tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
1931 }
1932 decision = tempDecision;
1933 }
1934 }
1935 individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
1936
1937 //set flags for objects that pass each cut AND all the previous cuts
1938 bool previousCumulativeFlag = true;
1939 for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
1940 if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
1941 else{ previousCumulativeFlag = false; break;}
1942 }
1943 cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
1944
1945 counter++;
1946 }
1947
1948 }
1949
1950
1951 }
1952
1953
1954 template <class InputCollection>
1955 void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
1956
1957 for (uint object = 0; object != inputCollection->size(); object++){
1958
1959 if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
1960
1961 string currentString = parameters.inputVariables.at(0);
1962 string inputVariable = "";
1963 string function = "";
1964 if(currentString.find("(")==std::string::npos){
1965 inputVariable = currentString;// variable to cut on
1966 }
1967 else{
1968 function = currentString.substr(0,currentString.find("("));//function comes before the "("
1969 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
1970 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
1971 }
1972
1973 double value = valueLookup(&inputCollection->at(object), inputVariable, function);
1974 histo->Fill(value,puScaleFactor);
1975
1976 }
1977
1978 }
1979
1980 template <class InputCollection1, class InputCollection2>
1981 void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
1982
1983 bool sameObjects = false;
1984 if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
1985
1986 int counter = 0;
1987 for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
1988 for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
1989
1990 if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
1991
1992 //only take objects which have passed all cuts and pairs which have passed all cuts
1993 if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
1994 if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
1995 if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
1996
1997 string currentString = parameters.inputVariables.at(0);
1998 string inputVariable = "";
1999 string function = "";
2000 if(currentString.find("(")==std::string::npos){
2001 inputVariable = currentString;// variable to cut on
2002 }
2003 else{
2004 function = currentString.substr(0,currentString.find("("));//function comes before the "("
2005 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2006 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2007 }
2008
2009 double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2010 histo->Fill(value,puScaleFactor);
2011
2012 counter++;
2013 }
2014 }
2015
2016 }
2017
2018
2019 template <class InputCollection>
2020 void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2021
2022 for (uint object = 0; object != inputCollection->size(); object++){
2023
2024 if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
2025
2026 string currentString = parameters.inputVariables.at(0);
2027 string inputVariable = "";
2028 string function = "";
2029 if(currentString.find("(")==std::string::npos){
2030 inputVariable = currentString;// variable to cut on
2031 }
2032 else{
2033 function = currentString.substr(0,currentString.find("("));//function comes before the "("
2034 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2035 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2036 }
2037 double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
2038
2039 currentString = parameters.inputVariables.at(1);
2040 inputVariable = "";
2041 function = "";
2042 if(currentString.find("(")==std::string::npos){
2043 inputVariable = currentString;// variable to cut on
2044 }
2045 else{
2046 function = currentString.substr(0,currentString.find("("));//function comes before the "("
2047 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2048 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2049 }
2050
2051 double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
2052
2053 histo->Fill(valueX,valueY,puScaleFactor);
2054
2055 }
2056
2057 }
2058
2059 template <class InputCollection1, class InputCollection2>
2060 void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
2061
2062 bool sameObjects = false;
2063 if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2064
2065 int counter = 0;
2066 for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2067 for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2068
2069 if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2070
2071 //only take objects which have passed all cuts and pairs which have passed all cuts
2072 if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2073 if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2074 if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
2075
2076 string currentString = parameters.inputVariables.at(0);
2077 string inputVariable = "";
2078 string function = "";
2079 if(currentString.find("(")==std::string::npos){
2080 inputVariable = currentString;// variable to cut on
2081 }
2082 else{
2083 function = currentString.substr(0,currentString.find("("));//function comes before the "("
2084 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2085 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2086 }
2087 double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2088
2089 currentString = parameters.inputVariables.at(1);
2090 inputVariable = "";
2091 function = "";
2092 if(currentString.find("(")==std::string::npos){
2093 inputVariable = currentString;// variable to cut on
2094 }
2095 else{
2096 function = currentString.substr(0,currentString.find("("));//function comes before the "("
2097 inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2098 inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2099 }
2100 double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2101
2102
2103 histo->Fill(valueX,valueY,puScaleFactor);
2104
2105 counter++;
2106 }
2107 }
2108
2109 }
2110
2111
2112 // template <class InputObject>
2113 // BNmcparticle* getGenMatchedParticle(InputObject object){
2114
2115 // BNmcparticle bestMatch;
2116 // std::cout << bestMatch.energy() << std:endl;
2117 // for(BNmcparticleCollection::const_iterator mcparticle = mcParticles_->begin (); mcparticle != mcParticles_->end (); mcparticle++){
2118
2119 // }
2120 // return bestMatch;
2121 // }
2122
2123
2124 DEFINE_FWK_MODULE(OSUAnalysis);
2125
2126