ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.30
Committed: Fri Mar 15 13:08:45 2013 UTC (12 years, 1 month ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.29: +4 -3 lines
Log Message:
added flag to turn on and off pileup reweighting

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