ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.44
Committed: Tue Apr 9 16:17:50 2013 UTC (12 years ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.43: +13 -1 lines
Log Message:
added object pair deltaEta

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