ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.33
Committed: Wed Mar 20 12:56:37 2013 UTC (12 years, 1 month ago) by jbrinson
Content type: text/plain
Branch: MAIN
Changes since 1.32: +25 -3 lines
Log Message:
Added funiton getGenDeltaRLowest

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