ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.45
Committed: Thu Apr 11 00:56:48 2013 UTC (12 years, 1 month ago) by ahart
Content type: text/plain
Branch: MAIN
Changes since 1.44: +20 -6 lines
Log Message:
Implemented stop <c*tau> reweighting. This machinery has no effect if the DISPLACED_SUSY macro is not defined.

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