ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.36
Committed: Thu Mar 21 21:12:21 2013 UTC (12 years, 1 month ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.35: +101 -18 lines
Log Message:
added 2D gen-matching histograms, changed BNtrack 'genId' to 'genMatchedPdgId'

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