ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.42
Committed: Wed Mar 27 22:38:08 2013 UTC (12 years, 1 month ago) by wulsin
Content type: text/plain
Branch: MAIN
Changes since 1.41: +89 -32 lines
Log Message:
add PU-correction of isolation energy for BNtrack, also added track-event pair input collection

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