ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.22
Committed: Sun Mar 3 17:16:53 2013 UTC (12 years, 2 months ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.21: +352 -59 lines
Log Message:
added gen. matching histograms

File Contents

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