ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.29
Committed: Thu Mar 14 13:43:25 2013 UTC (12 years, 1 month ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.28: +52 -62 lines
Log Message:
fixed a bug which was incorrectly applying cuts with 3 or more requirements, as well as some minor formatting changes

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