ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.92
Committed: Mon Jul 1 11:54:18 2013 UTC (11 years, 10 months ago) by wulsin
Content type: text/plain
Branch: MAIN
CVS Tags: V02-03-00
Changes since 1.91: +26 -11 lines
Log Message:
Add track isolation variables

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 ahart 1.57 trigobjs_ (cfg.getParameter<edm::InputTag> ("trigobjs")),
21     puFile_ (cfg.getParameter<string> ("puFile")),
22     deadEcalFile_ (cfg.getParameter<string> ("deadEcalFile")),
23     muonSFFile_ (cfg.getParameter<string> ("muonSFFile")),
24     dataPU_ (cfg.getParameter<string> ("dataPU")),
25     electronSFID_ (cfg.getParameter<string> ("electronSFID")),
26     muonSF_ (cfg.getParameter<string> ("muonSF")),
27     dataset_ (cfg.getParameter<string> ("dataset")),
28     datasetType_ (cfg.getParameter<string> ("datasetType")),
29 lantonel 1.9 channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
30 lantonel 1.14 histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
31 ahart 1.85 useEDMFormat_ (cfg.getParameter<bool>("useEDMFormat")),
32 wulsin 1.74 treeBranchSets_ (cfg.getParameter<vector<edm::ParameterSet> >("treeBranchSets")),
33 lantonel 1.30 plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
34 wulsin 1.37 doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
35 biliu 1.83 applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
36     applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
37     minBtag_ (cfg.getParameter<int> ("minBtag")),
38     maxBtag_ (cfg.getParameter<int> ("maxBtag")),
39 wulsin 1.82 printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
40     printAllTriggers_ (cfg.getParameter<bool> ("printAllTriggers")),
41 ahart 1.45 useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
42 biliu 1.65 stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
43     GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
44 biliu 1.83 {
45 lantonel 1.9
46 lantonel 1.1 TH1::SetDefaultSumw2 ();
47 lantonel 1.15
48     //create pile-up reweighting object, if necessary
49 ahart 1.31 if(datasetType_ != "data") {
50     if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
51 ahart 1.54 if (applyLeptonSF_){
52     muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
53     electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
54     }
55 biliu 1.83 if (applyBtagSF_){
56     bTagSFWeight_ = new BtagSFWeight;
57     }
58 ahart 1.31 }
59 ahart 1.55 if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
60     stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
61 lantonel 1.1
62 wulsin 1.34
63 lantonel 1.1 // Construct Cutflow Objects. These store the results of cut decisions and
64     // handle filling cut flow histograms.
65     masterCutFlow_ = new CutFlow (fs_);
66    
67 lantonel 1.9 //always get vertex collection so we can assign the primary vertex in the event
68 lantonel 1.29 objectsToGet.push_back("primaryvertexs");
69 lantonel 1.73 objectsToPlot.push_back("primaryvertexs");
70     objectsToCut.push_back("primaryvertexs");
71 lantonel 1.29
72 lantonel 1.9
73 lantonel 1.19 //always get the MC particles to do GEN-matching
74 lantonel 1.23 objectsToGet.push_back("mcparticles");
75 lantonel 1.19
76 lantonel 1.15 //always get the event collection to do pile-up reweighting
77 lantonel 1.23 objectsToGet.push_back("events");
78 lantonel 1.15
79 wulsin 1.74
80 ahart 1.84 // Parse the tree variable definitions.
81 ahart 1.85 for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
82 wulsin 1.78 string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
83 ahart 1.84 if(tempInputCollection.find("pairs")!=string::npos) { cout << "Warning: tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }
84 wulsin 1.78 objectsToGet.push_back(tempInputCollection);
85 ahart 1.84 objectsToCut.push_back(tempInputCollection);
86 wulsin 1.78
87     vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
88    
89     for (uint iBranch = 0; iBranch<branchList.size(); iBranch++) {
90     BranchSpecs br;
91     br.inputCollection = tempInputCollection;
92 ahart 1.84 br.inputVariable = branchList.at(iBranch);
93     TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
94     br.name = string(newName.Data());
95 wulsin 1.78 treeBranches_.push_back(br);
96 ahart 1.84 }
97 wulsin 1.74
98 ahart 1.84 } // end for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
99 wulsin 1.74
100    
101 lantonel 1.9 //parse the histogram definitions
102     for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
103    
104 lantonel 1.17 string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
105     if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
106 biliu 1.87 if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
107     if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
108 lantonel 1.51 if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
109 biliu 1.87 if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
110 lantonel 1.51 if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
111 wulsin 1.89 if(tempInputCollection == "jet-met pairs") tempInputCollection = "met-jet pairs";
112 wulsin 1.42 if(tempInputCollection == "event-track pairs") tempInputCollection = "track-event pairs";
113 lantonel 1.48 if(tempInputCollection == "secondary muon-muon pairs") tempInputCollection = "muon-secondary muon pairs";
114 biliu 1.87 if(tempInputCollection == "secondary jet-muon pairs") tempInputCollection = "muon-secondary jet pairs";
115     if(tempInputCollection == "secondary jet-electron pairs") tempInputCollection = "electron-secondary jet pairs";
116     if(tempInputCollection == "secondary jet-photon pairs") tempInputCollection = "photon-secondary jet pairs";
117     if(tempInputCollection == "secondary jet-jet pairs") tempInputCollection = "jet-secondary jet pairs";
118 lantonel 1.50 if(tempInputCollection == "secondary electron-electron pairs") tempInputCollection = "electron-secondary electron pairs";
119 ahart 1.57 if(tempInputCollection == "trigobj-electron pairs") tempInputCollection = "electron-trigobj pairs";
120     if(tempInputCollection == "trigobj-muon pairs") tempInputCollection = "muon-trigobj pairs";
121     if(tempInputCollection.find("pairs")==string::npos){ //just a single object
122     if(tempInputCollection.find("secondary")!=string::npos){//secondary object
123     int spaceIndex = tempInputCollection.find(" ");
124     int secondWordLength = tempInputCollection.size() - spaceIndex;
125     objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
126 lantonel 1.48 }
127     else{
128 ahart 1.57 objectsToGet.push_back(tempInputCollection);
129 lantonel 1.48 }
130 lantonel 1.17 objectsToPlot.push_back(tempInputCollection);
131 lantonel 1.24 objectsToCut.push_back(tempInputCollection);
132 wulsin 1.74 } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
133 ahart 1.57 string obj1;
134 wulsin 1.49 string obj2;
135     getTwoObjs(tempInputCollection, obj1, obj2);
136 ahart 1.57 string obj2ToGet = getObjToGet(obj2);
137 wulsin 1.49 objectsToCut.push_back(tempInputCollection);
138     objectsToCut.push_back(obj1);
139 ahart 1.57 objectsToCut.push_back(obj2);
140 wulsin 1.49 objectsToPlot.push_back(tempInputCollection);
141     objectsToPlot.push_back(obj1);
142 ahart 1.57 objectsToPlot.push_back(obj2);
143 lantonel 1.23 objectsToGet.push_back(tempInputCollection);
144 wulsin 1.49 objectsToGet.push_back(obj1);
145     objectsToGet.push_back(obj2ToGet);
146 ahart 1.84 } // end else
147 lantonel 1.23
148 lantonel 1.17
149 lantonel 1.73
150 lantonel 1.9 vector<edm::ParameterSet> histogramList_ (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
151 ahart 1.31
152 lantonel 1.9 for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
153    
154 ahart 1.56 vector<double> defaultValue;
155     defaultValue.push_back (-1.0);
156    
157 lantonel 1.9 histogram tempHistogram;
158     tempHistogram.inputCollection = tempInputCollection;
159     tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
160     tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
161 ahart 1.56 tempHistogram.bins = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("bins", defaultValue);
162     tempHistogram.variableBinsX = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsX", defaultValue);
163     tempHistogram.variableBinsY = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsY", defaultValue);
164 lantonel 1.10 tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
165 ahart 1.31
166 lantonel 1.9 histograms.push_back(tempHistogram);
167    
168     }
169 ahart 1.84 } // for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++)
170 wulsin 1.74
171 lantonel 1.19 //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
172 lantonel 1.15 sort( objectsToPlot.begin(), objectsToPlot.end() );
173     objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
174 lantonel 1.9
175    
176 lantonel 1.1
177 lantonel 1.22 //add histograms with the gen-matched id, mother id, and grandmother id
178     for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
179    
180     string currentObject = objectsToPlot.at(currentObjectIndex);
181 lantonel 1.50 if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
182 lantonel 1.22
183     histogram tempIdHisto;
184     histogram tempMomIdHisto;
185     histogram tempGmaIdHisto;
186 lantonel 1.36 histogram tempIdVsMomIdHisto;
187 lantonel 1.50 histogram tempIdVsGmaIdHisto;
188 lantonel 1.22
189     tempIdHisto.inputCollection = currentObject;
190     tempMomIdHisto.inputCollection = currentObject;
191     tempGmaIdHisto.inputCollection = currentObject;
192 lantonel 1.36 tempIdVsMomIdHisto.inputCollection = currentObject;
193 lantonel 1.50 tempIdVsGmaIdHisto.inputCollection = currentObject;
194 lantonel 1.22
195 lantonel 1.48 if(currentObject == "secondary muons") currentObject = "secondaryMuons";
196 lantonel 1.50 if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
197 lantonel 1.48
198 lantonel 1.22 currentObject = currentObject.substr(0, currentObject.size()-1);
199     tempIdHisto.name = currentObject+"GenMatchId";
200     tempMomIdHisto.name = currentObject+"GenMatchMotherId";
201     tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
202 lantonel 1.36 tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
203 lantonel 1.50 tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
204 lantonel 1.22
205     currentObject.at(0) = toupper(currentObject.at(0));
206     tempIdHisto.title = currentObject+" Gen-matched Particle";
207     tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
208     tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
209 lantonel 1.36 tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
210 lantonel 1.50 tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
211    
212 lantonel 1.22
213 jbrinson 1.62 int maxNum = 25;
214 lantonel 1.22 vector<double> binVector;
215     binVector.push_back(maxNum);
216     binVector.push_back(0);
217     binVector.push_back(maxNum);
218    
219     tempIdHisto.bins = binVector;
220     tempIdHisto.inputVariables.push_back("genMatchedId");
221     tempMomIdHisto.bins = binVector;
222     tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
223     tempGmaIdHisto.bins = binVector;
224     tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
225 lantonel 1.36 binVector.push_back(maxNum);
226     binVector.push_back(0);
227     binVector.push_back(maxNum);
228     tempIdVsMomIdHisto.bins = binVector;
229     tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
230     tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
231 lantonel 1.50 tempIdVsGmaIdHisto.bins = binVector;
232     tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
233     tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
234 lantonel 1.22
235     histograms.push_back(tempIdHisto);
236     histograms.push_back(tempMomIdHisto);
237     histograms.push_back(tempGmaIdHisto);
238 lantonel 1.36 histograms.push_back(tempIdVsMomIdHisto);
239 lantonel 1.50 histograms.push_back(tempIdVsGmaIdHisto);
240 lantonel 1.22 }
241    
242    
243 lantonel 1.1 channel tempChannel;
244     //loop over all channels (event selections)
245     for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
246 ahart 1.8
247 lantonel 1.1 //get name of channel
248     string channelName (channels_.at(currentChannel).getParameter<string>("name"));
249     tempChannel.name = channelName;
250     TString channelLabel = channelName;
251    
252 lantonel 1.3 //set triggers for this channel
253     vector<string> triggerNames;
254     triggerNames.clear();
255 biliu 1.71 vector<string> triggerToVetoNames;
256     triggerToVetoNames.clear();
257 lantonel 1.72
258 lantonel 1.3 tempChannel.triggers.clear();
259 biliu 1.71 tempChannel.triggersToVeto.clear();
260 lantonel 1.3 if(channels_.at(currentChannel).exists("triggers")){
261     triggerNames = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
262     for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
263 ahart 1.8 tempChannel.triggers.push_back(triggerNames.at(trigger));
264 lantonel 1.23 objectsToGet.push_back("triggers");
265 lantonel 1.3 }
266 biliu 1.71 if(channels_.at(currentChannel).exists("triggersToVeto")){
267     triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
268     for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
269     tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
270 lantonel 1.72 objectsToGet.push_back("triggers");
271 biliu 1.71 }
272 lantonel 1.1
273 lantonel 1.9
274 lantonel 1.14
275 lantonel 1.1 //create cutFlow for this channel
276     cutFlows_.push_back (new CutFlow (fs_, channelName));
277 biliu 1.65 vector<TFileDirectory> directories; //vector of directories in the output file.
278 ahart 1.84 vector<TFileDirectory> treeDirectories; //vector of directories for trees in the output file.
279 biliu 1.65 vector<string> subSubDirNames;//subdirectories in each channel.
280     //get list of cuts for this channel
281     vector<edm::ParameterSet> cuts_ (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
282 ahart 1.68
283 biliu 1.65
284     //loop over and parse all cuts
285     for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
286     cut tempCut;
287     //store input collection for cut
288     string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
289     if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
290 biliu 1.87 if(tempInputCollection == "photon-electron pairs") tempInputCollection = "electron-photon pairs";
291     if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
292 biliu 1.65 if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
293     if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
294 wulsin 1.89 if(tempInputCollection == "jet-met pairs") tempInputCollection = "met-jet pairs";
295 biliu 1.87 if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
296 biliu 1.65 if(tempInputCollection == "event-track pairs") tempInputCollection = "track-event pairs";
297     if(tempInputCollection == "secondary muon-muon pairs") tempInputCollection = "muon-secondary muon pairs";
298 biliu 1.87 if(tempInputCollection == "secondary jet-jet pairs") tempInputCollection = "jet-secondary jet pairs";
299     if(tempInputCollection == "secondary jet-muon pairs") tempInputCollection = "muon-secondary jet pairs";
300     if(tempInputCollection == "secondary jet-photon pairs") tempInputCollection = "photon-secondary jet pairs";
301     if(tempInputCollection == "secondary jet-electron pairs") tempInputCollection = "electron-secondary jet pairs";
302 biliu 1.65 if(tempInputCollection == "secondary electron-electron pairs") tempInputCollection = "electron-secondary electron pairs";
303     if(tempInputCollection == "trigobj-electron pairs") tempInputCollection = "electron-trigobj pairs";
304     if(tempInputCollection == "trigobj-muon pairs") tempInputCollection = "muon-trigobj pairs";
305     tempCut.inputCollection = tempInputCollection;
306     if(tempInputCollection.find("pairs")==string::npos){ //just a single object
307     if(tempInputCollection.find("secondary")!=string::npos){//secondary object
308     int spaceIndex = tempInputCollection.find(" ");
309     int secondWordLength = tempInputCollection.size() - spaceIndex;
310     objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
311     }
312     else{
313     objectsToGet.push_back(tempInputCollection);
314     }
315     objectsToCut.push_back(tempInputCollection);
316     }
317     else{//pair of objects, need to add them both to objectsToGet
318     string obj1;
319     string obj2;
320     getTwoObjs(tempInputCollection, obj1, obj2);
321     string obj2ToGet = getObjToGet(obj2);
322     objectsToCut.push_back(tempInputCollection);
323     objectsToCut.push_back(obj1);
324     objectsToCut.push_back(obj2);
325     objectsToGet.push_back(tempInputCollection);
326     objectsToGet.push_back(obj1);
327     objectsToGet.push_back(obj2ToGet);
328    
329     }
330 lantonel 1.1
331 lantonel 1.10
332 lantonel 1.1
333 biliu 1.65 //split cut string into parts and store them
334     string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
335     vector<string> cutStringVector = splitString(cutString);
336     if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
337     cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
338     exit(0);
339     }
340     tempCut.numSubcuts = (cutStringVector.size()+1)/4;
341     for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
342     int indexOffset = 4 * subcutIndex;
343     string currentVariableString = cutStringVector.at(indexOffset);
344     if(currentVariableString.find("(")==string::npos){
345     tempCut.functions.push_back("");//no function was specified
346     tempCut.variables.push_back(currentVariableString);// variable to cut on
347     }
348     else{
349     tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
350     string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
351     tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
352     }
353     tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
354     tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
355     tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
356     if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
357     }
358    
359     //get number of objects required to pass cut for event to pass
360     string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
361     vector<string> numberRequiredVector = splitString(numberRequiredString);
362     if(numberRequiredVector.size()!=2){
363     cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
364     exit(0);
365     }
366    
367     int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
368     tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
369     tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
370 ahart 1.68
371 lantonel 1.86 //Set up vectors to store the directories and subDirectories for each channel.
372 ahart 1.68 string subSubDirName;
373 biliu 1.65 string tempCutName;
374     if(cuts_.at(currentCut).exists("alias")){
375     tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
376 lantonel 1.86 subSubDirName = "After " + tempCutName + " Cut Applied";
377 biliu 1.65 }
378     else{
379     //construct string for cutflow table
380     bool plural = numberRequiredInt != 1;
381     string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
382     string cutName = numberRequiredString + " " + collectionString + " with " + cutString;
383     tempCutName = cutName;
384     subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
385     }
386 ahart 1.68
387 lantonel 1.86 tempCut.isVeto = false;
388     if(cuts_.at(currentCut).exists("isVeto")){
389     bool isVeto = cuts_.at(currentCut).getParameter<bool> ("isVeto");
390     if (isVeto == true) tempCut.isVeto = true;
391     }
392 biliu 1.65 subSubDirNames.push_back(subSubDirName);
393     tempCut.name = tempCutName;
394 lantonel 1.14
395 biliu 1.65 tempChannel.cuts.push_back(tempCut);
396 ahart 1.68
397 lantonel 1.36
398 biliu 1.65 }//end loop over cuts
399 ahart 1.68
400 biliu 1.65 vector<map<string, TH1D*>> oneDHistsTmp;
401 ahart 1.68 vector<map<string, TH2D*>> twoDHistsTmp;
402 biliu 1.65 //book a directory in the output file with the name of the channel
403     TFileDirectory subDir = fs_->mkdir( channelName );
404     //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
405     if(GetPlotsAfterEachCut_){
406 wulsin 1.74 for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
407 ahart 1.84 TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
408     directories.push_back(subSubDir);
409     map<string, TH1D*> oneDhistoMap;
410     oneDHistsTmp.push_back(oneDhistoMap);
411     map<string, TH2D*> twoDhistoMap;
412     twoDHistsTmp.push_back(twoDhistoMap);
413 biliu 1.65 }
414 ahart 1.84 treeDirectories.push_back(subDir);
415 ahart 1.68 oneDHists_.push_back(oneDHistsTmp);
416 biliu 1.65 twoDHists_.push_back(twoDHistsTmp);
417     }
418 wulsin 1.74 //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
419     else{
420 biliu 1.65 map<string, TH1D*> oneDhistoMap;
421     oneDHistsTmp.push_back(oneDhistoMap);
422     map<string, TH2D*> twoDhistoMap;
423     twoDHistsTmp.push_back(twoDhistoMap);
424     oneDHists_.push_back(oneDHistsTmp);
425     twoDHists_.push_back(twoDHistsTmp);
426     directories.push_back(subDir);
427 ahart 1.84 treeDirectories.push_back(subDir);
428 wulsin 1.74
429     }
430    
431 ahart 1.85 for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
432 ahart 1.84 TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
433     BNTrees_.push_back(newTree);
434     for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
435     BranchSpecs currentVar = treeBranches_.at(iBranch);
436     vector<float> newVec;
437     BNTreeBranchVals_[currentVar.name] = newVec;
438     BNTrees_.back()->Branch(TString(currentVar.name), &BNTreeBranchVals_.at(currentVar.name));
439     } // end for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++)
440     }
441 wulsin 1.74
442 lantonel 1.9 //book all histograms included in the configuration
443 biliu 1.65 for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
444 wulsin 1.74
445     for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
446    
447 ahart 1.84 histogram currentHistogram = histograms.at(currentHistogramIndex);
448     int numBinsElements = currentHistogram.bins.size();
449     int numInputVariables = currentHistogram.inputVariables.size();
450     int numBinEdgesX = currentHistogram.variableBinsX.size();
451     int numBinEdgesY = currentHistogram.variableBinsY.size();
452    
453     if(numBinsElements == 1){
454     if(numBinEdgesX > 1){
455     if(numBinEdgesY > 1)
456     numBinsElements = 6;
457     else
458     numBinsElements = 3;
459     }
460     }
461     if(numBinsElements != 3 && numBinsElements !=6){
462     cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
463     exit(0);
464     }
465     else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
466     cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
467     exit(0);
468     }
469     else if(numBinsElements == 3){
470     if (currentHistogram.bins.size () == 3)
471     oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
472     else
473     {
474     oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
475     }
476     }
477     else if(numBinsElements == 6){
478     if (currentHistogram.bins.size () == 6)
479     twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).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));
480     else
481     twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
482     }
483 wulsin 1.74
484 ahart 1.84
485     if(currentHistogram.name.find("GenMatch")==string::npos) continue;
486    
487     // bin particle type
488     // --- -------------
489     // 0 unmatched
490     // 1 u
491     // 2 d
492     // 3 s
493     // 4 c
494     // 5 b
495     // 6 t
496     // 7 e
497     // 8 mu
498     // 9 tau
499     // 10 nu
500     // 11 g
501     // 12 gamma
502     // 13 Z
503     // 14 W
504     // 15 light meson
505     // 16 K meson
506     // 17 D meson
507     // 18 B meson
508     // 19 light baryon
509     // 20 strange baryon
510     // 21 charm baryon
511     // 22 bottom baryon
512     // 23 QCD string
513     // 24 other
514    
515     vector<TString> labelArray;
516     labelArray.push_back("unmatched");
517     labelArray.push_back("u");
518     labelArray.push_back("d");
519     labelArray.push_back("s");
520     labelArray.push_back("c");
521     labelArray.push_back("b");
522     labelArray.push_back("t");
523     labelArray.push_back("e");
524     labelArray.push_back("#mu");
525     labelArray.push_back("#tau");
526     labelArray.push_back("#nu");
527     labelArray.push_back("g");
528     labelArray.push_back("#gamma");
529     labelArray.push_back("Z");
530     labelArray.push_back("W");
531     labelArray.push_back("light meson");
532     labelArray.push_back("K meson");
533     labelArray.push_back("D meson");
534     labelArray.push_back("B meson");
535     labelArray.push_back("light baryon");
536     labelArray.push_back("strange baryon");
537     labelArray.push_back("charm baryon");
538     labelArray.push_back("bottom baryon");
539     labelArray.push_back("QCD string");
540     labelArray.push_back("other");
541    
542     for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
543     if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
544     oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
545     }
546     else {
547     twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
548     twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
549     }
550     }
551     if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
552     twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
553     twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
554     }
555    
556     } // end for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++)
557 wulsin 1.74
558 qpython 1.27
559 wulsin 1.74 // Book a histogram for the number of each object type to be plotted.
560     // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
561     for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
562 ahart 1.84 string currentObject = objectsToPlot.at(currentObjectIndex);
563     int maxNum = 10;
564     if(currentObject == "mcparticles") maxNum = 50;
565     else if(currentObject == "primaryvertexs") maxNum = 50;
566    
567     if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
568     else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
569     else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
570 wulsin 1.89 else if(currentObject == "electron-photon pairs") currentObject = "electronPhotonPairs";
571     else if(currentObject == "muon-photon pairs") currentObject = "muonPhotonPairs";
572 ahart 1.84 else if(currentObject == "secondary jets") currentObject = "secondaryJets";
573     else if(currentObject == "jet-jet pairs") currentObject = "dijetPairs";
574 biliu 1.87 else if(currentObject == "jet-secondary jet pairs") currentObject = "jetSecondaryJetPairs";
575 ahart 1.84 else if(currentObject == "electron-jet pairs") currentObject = "electronJetPairs";
576     else if(currentObject == "muon-jet pairs") currentObject = "muonJetPairs";
577 wulsin 1.89 else if(currentObject == "photon-jet pairs") currentObject = "photonJetPairs";
578     else if(currentObject == "met-jet pairs") currentObject = "metJetPairs";
579 biliu 1.87 else if(currentObject == "muon-secondary jet pairs") currentObject = "muonSecondaryJetPairs";
580     else if(currentObject == "photon-secondary jet pairs") currentObject = "photonSecondaryJetPairs";
581     else if(currentObject == "electron-secondary jet pairs") currentObject = "electronSecondaryJetPairs";
582 ahart 1.84 else if(currentObject == "track-event pairs") currentObject = "trackEventPairs";
583     else if(currentObject == "electron-track pairs") currentObject = "electronTrackPairs";
584     else if(currentObject == "muon-track pairs") currentObject = "muonTrackPairs";
585     else if(currentObject == "muon-tau pairs") currentObject = "muonTauPairs";
586     else if(currentObject == "tau-tau pairs") currentObject = "ditauPairs";
587     else if(currentObject == "tau-track pairs") currentObject = "tauTrackPairs";
588     else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
589     else if(currentObject == "secondary muons") currentObject = "secondaryMuons";
590     else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
591     else if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
592     else if(currentObject == "electron-trigobj pairs") currentObject = "electronTrigobjPairs";
593     else if(currentObject == "muon-trigobj pairs") currentObject = "muonTrigobjPairs";
594    
595     currentObject.at(0) = toupper(currentObject.at(0));
596     string histoName = "num" + currentObject;
597    
598     if(histoName == "numPrimaryvertexs"){
599     string newHistoName = histoName + "BeforePileupCorrection";
600     oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
601     newHistoName = histoName + "AfterPileupCorrection";
602     oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
603     }
604     else
605     oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
606 lantonel 1.16 }
607 wulsin 1.74 }//end of loop over directories
608 lantonel 1.1 channels.push_back(tempChannel);
609     tempChannel.cuts.clear();
610     }//end loop over channels
611    
612 lantonel 1.9
613 lantonel 1.23 //make unique vector of objects we need to get from the event
614     sort( objectsToGet.begin(), objectsToGet.end() );
615     objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
616     //make unique vector of objects we need to cut on
617     sort( objectsToCut.begin(), objectsToCut.end() );
618     objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
619 lantonel 1.1
620 ahart 1.85 produces<map<string, bool> > ("channelDecisions");
621 lantonel 1.1
622 ahart 1.84 } // end constructor OSUAnalysis::OSUAnalysis()
623 wulsin 1.82
624 lantonel 1.1
625     OSUAnalysis::~OSUAnalysis ()
626     {
627 wulsin 1.80
628 lantonel 1.1 // Destroying the CutFlow objects causes the cut flow numbers and time
629     // information to be printed to standard output.
630     for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
631     delete cutFlows_.at(currentChannel);
632     }
633     }
634    
635     void
636 ahart 1.85 OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
637 lantonel 1.1 {
638     // Retrieve necessary collections from the event.
639 lantonel 1.22
640 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
641 lantonel 1.3 event.getByLabel (triggers_, triggers);
642    
643 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
644     event.getByLabel (trigobjs_, trigobjs);
645    
646     if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
647 lantonel 1.1 event.getByLabel (jets_, jets);
648    
649 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
650 lantonel 1.1 event.getByLabel (muons_, muons);
651    
652 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
653 lantonel 1.1 event.getByLabel (electrons_, electrons);
654    
655 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
656 lantonel 1.1 event.getByLabel (events_, events);
657    
658 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
659 lantonel 1.1 event.getByLabel (taus_, taus);
660    
661 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
662 lantonel 1.1 event.getByLabel (mets_, mets);
663    
664 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
665 lantonel 1.1 event.getByLabel (tracks_, tracks);
666    
667 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
668 lantonel 1.1 event.getByLabel (genjets_, genjets);
669    
670 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
671 lantonel 1.29 event.getByLabel (mcparticles_, mcparticles);
672 lantonel 1.1
673 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
674 lantonel 1.1 event.getByLabel (primaryvertexs_, primaryvertexs);
675    
676 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
677 lantonel 1.1 event.getByLabel (bxlumis_, bxlumis);
678    
679 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
680 lantonel 1.1 event.getByLabel (photons_, photons);
681    
682 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
683 lantonel 1.1 event.getByLabel (superclusters_, superclusters);
684    
685 lantonel 1.50 if (datasetType_ == "signalMC"){
686 ahart 1.57 if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
687 lantonel 1.50 event.getByLabel (stops_, stops);
688     }
689    
690 ahart 1.57 if (useTrackCaloRhoCorr_) {
691     // Used only for pile-up correction of by-hand calculation of isolation energy.
692     // This rho collection is not available in all BEANs.
693 wulsin 1.42 // For description of rho values for different jet reconstruction algorithms, see
694 ahart 1.57 // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
695     event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
696 wulsin 1.42 }
697    
698 ahart 1.58 double masterScaleFactor = 1.0;
699    
700     //get pile-up event weight
701 wulsin 1.69 if (doPileupReweighting_ && datasetType_ != "data") {
702 lantonel 1.72 //for "data" datasets, the numTruePV is always set to -1
703 ahart 1.84 if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0. Turning off pile-up reweighting." << endl;
704     else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
705 wulsin 1.69 }
706 ahart 1.58
707     stopCTauScaleFactor_ = 1.0;
708     if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
709     stopCTauScaleFactor_ = stopCTauWeight_->at (event);
710     masterScaleFactor *= stopCTauScaleFactor_;
711 lantonel 1.14
712 lantonel 1.1 //loop over all channels
713    
714 ahart 1.85 auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
715 lantonel 1.1 for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
716     channel currentChannel = channels.at(currentChannelIndex);
717 ahart 1.8
718     flagMap individualFlags;
719     counterMap passingCounter;
720 ahart 1.31 cumulativeFlags.clear ();
721 lantonel 1.1
722 ahart 1.84 for (map<string, vector<float>>::iterator iter = BNTreeBranchVals_.begin();
723     iter != BNTreeBranchVals_.end(); iter++) {
724 wulsin 1.78 iter->second.clear(); // clear array
725 wulsin 1.74 }
726    
727 lantonel 1.5 bool triggerDecision = true;
728 lantonel 1.72 if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){ //triggers specified
729 biliu 1.71 triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
730 lantonel 1.3 cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
731     }
732 lantonel 1.1
733     //loop over all cuts
734     for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
735     cut currentCut = currentChannel.cuts.at(currentCutIndex);
736 lantonel 1.23 for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
737     string currentObject = objectsToCut.at(currentObjectIndex);
738 lantonel 1.1
739 ahart 1.31 //initialize maps to get ready to set cuts
740 lantonel 1.86 individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
741     cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
742 ahart 1.8
743 lantonel 1.23 }
744     for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
745     string currentObject = objectsToCut.at(currentObjectIndex);
746    
747 ahart 1.31 int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
748    
749 lantonel 1.14
750 wulsin 1.67 if (currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
751     else if(currentObject == "secondary jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
752     else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
753 lantonel 1.48 else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
754 lantonel 1.50 else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
755 ahart 1.8 else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
756     else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
757     else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
758     else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
759     else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
760     else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
761     else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
762     else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
763     else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
764     else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
765     else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
766 ahart 1.57 else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
767 lantonel 1.1
768 lantonel 1.50
769 ahart 1.31
770     else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
771     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
772     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
773     "muon-muon pairs");
774 lantonel 1.48
775     else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
776 ahart 1.84 cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
777     cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
778     "muon-secondary muon pairs");
779 lantonel 1.48
780 biliu 1.87 else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
781     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
782     cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
783     "muon-secondary jet pairs");
784     else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
785     cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
786     cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
787     "photon-secondary jet pairs");
788    
789     else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
790     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
791     cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
792     "electron-secondary jet pairs");
793    
794 lantonel 1.50 else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
795 ahart 1.84 cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
796     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
797     "electron-secondary electron pairs");
798 lantonel 1.50
799 ahart 1.31 else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
800     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
801     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
802     "electron-electron pairs");
803     else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
804     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
805     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
806     "electron-muon pairs");
807 biliu 1.53 else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
808 ahart 1.84 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
809     cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
810     "jet-jet pairs");
811 biliu 1.87 else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
812     cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
813     cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
814     "jet-secondary jet pairs");
815 lantonel 1.51 else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
816 ahart 1.84 cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
817     cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
818     "electron-jet pairs");
819 biliu 1.87 else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
820     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
821     cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
822     "electron-photon pairs");
823     else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
824     cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
825     cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
826     "photon-jet pairs");
827 lantonel 1.51 else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
828 ahart 1.84 cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
829     cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
830     "muon-jet pairs");
831 wulsin 1.89 else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
832     cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
833     cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
834     "met-jet pairs");
835 biliu 1.87 else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
836     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
837     cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
838     "muon-photon pairs");
839 ahart 1.57 else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
840     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
841     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
842     "track-event pairs");
843     else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
844     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
845     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
846     "electron-track pairs");
847     else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
848     cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
849     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
850     "muon-track pairs");
851     else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
852     cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
853     cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
854     "muon-tau pairs");
855     else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
856     cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
857     cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
858     "tau-tau pairs");
859     else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
860 ahart 1.84 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
861     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
862     "tau-track pairs");
863 ahart 1.57 else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
864     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
865     cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
866     "electron-trigobj pairs");
867     else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
868     cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
869     cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
870     "muon-trigobj pairs");
871 lantonel 1.52
872 ahart 1.57 if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
873 lantonel 1.1 }
874    
875    
876    
877     }//end loop over all cuts
878     //use cumulative flags to apply cuts at event level
879    
880 biliu 1.65 //a vector to store cumulative cut descisions after each cut.
881     vector<bool> eventPassedPreviousCuts;
882 ahart 1.85 bool eventPassedAllCuts = true;
883 lantonel 1.5 //apply trigger (true if none were specified)
884     eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
885 lantonel 1.4
886 lantonel 1.1 for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
887    
888     //loop over all objects and count how many passed the cumulative selection up to this point
889     cut currentCut = currentChannel.cuts.at(currentCutIndex);
890     int numberPassing = 0;
891 lantonel 1.3
892 lantonel 1.17 for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
893 lantonel 1.86 if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
894 lantonel 1.17 }
895 lantonel 1.1 bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
896     cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
897     eventPassedAllCuts = eventPassedAllCuts && cutDecision;
898 biliu 1.65 eventPassedPreviousCuts.push_back(eventPassedAllCuts);
899 lantonel 1.1 }
900 ahart 1.58 double scaleFactor = masterScaleFactor;
901    
902 biliu 1.83 muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
903 ahart 1.58 if(applyLeptonSF_ && datasetType_ != "data"){
904 ahart 1.61 if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
905 lantonel 1.86 flagPair muonFlags;
906 ahart 1.61 for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
907     if (cumulativeFlags.at("muons").at(i).size()){
908     muonFlags = cumulativeFlags.at("muons").at(i);
909     break;
910     }
911     }
912     for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
913 lantonel 1.86 if(!muonFlags.at(muonIndex).second) continue;
914 ahart 1.63 muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
915 ahart 1.61 }
916     }
917     if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
918 lantonel 1.86 flagPair electronFlags;
919 ahart 1.61 for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
920     if (cumulativeFlags.at("electrons").at(i).size()){
921     electronFlags = cumulativeFlags.at("electrons").at(i);
922     break;
923     }
924     }
925     for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
926 lantonel 1.86 if(!electronFlags.at(electronIndex).second) continue;
927 ahart 1.63 electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
928 ahart 1.61 }
929     }
930 ahart 1.54 }
931 biliu 1.83 if(applyBtagSF_ && datasetType_ != "data"){
932     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
933 lantonel 1.86 flagPair jetFlags;
934 biliu 1.83 vector<double> jetSFs;
935     for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
936 ahart 1.84 if (cumulativeFlags.at("jets").at(i).size()){
937 biliu 1.83 jetFlags = cumulativeFlags.at("jets").at(i);
938 ahart 1.84 break;
939 biliu 1.83 }
940 ahart 1.84 }
941 biliu 1.83 for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
942 lantonel 1.86 if(!jetFlags.at(jetIndex).second) continue;
943 biliu 1.87 double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
944 biliu 1.83 jetSFs.push_back(jetSFTmp);
945     }
946 ahart 1.84 bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
947 biliu 1.83 }
948     }
949 ahart 1.63 scaleFactor *= muonScaleFactor_;
950     scaleFactor *= electronScaleFactor_;
951 biliu 1.83 scaleFactor *= bTagScaleFactor_;
952 ahart 1.31 cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
953 lantonel 1.73
954 wulsin 1.37 if (printEventInfo_) {
955 ahart 1.57 // Write information about event to screen, for testing purposes.
956     cout << "Event passed all cuts in channel " << currentChannel.name
957     << ": run=" << events->at(0).run
958     << " lumi=" << events->at(0).lumi
959     << " event=" << events->at(0).evt
960     << endl;
961 wulsin 1.37 }
962 lantonel 1.4
963 lantonel 1.48
964 lantonel 1.73 //filling histograms
965     for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
966     uint currentDir;
967 wulsin 1.80 if (!GetPlotsAfterEachCut_) { currentDir = currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
968 wulsin 1.74 else{
969 ahart 1.84 currentDir = currentCut;
970 wulsin 1.74 }
971 ahart 1.84
972    
973 wulsin 1.74 if(eventPassedPreviousCuts.at(currentDir)){
974 lantonel 1.73
975 wulsin 1.74 for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
976     histogram currentHistogram = histograms.at(histogramIndex);
977    
978 ahart 1.84 if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection: " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
979    
980     if(currentHistogram.inputVariables.size() == 1){
981     TH1D* histo;
982     histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
983     if (currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
984     else if(currentHistogram.inputCollection == "secondary jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
985     else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
986     else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
987     else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
988     else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
989     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
990     cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
991     else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
992     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
993     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
994 biliu 1.87 else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
995     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
996     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
997     else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
998     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
999     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1000     else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1001     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1002     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1003    
1004 ahart 1.84 else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1005     else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1006     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1007     cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1008     else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1009     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1010     cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1011 biliu 1.87 else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1012     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1013     cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1014    
1015 ahart 1.84 else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1016     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1017     cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1018     else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1019     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1020     cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1021     else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1022     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1023     cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1024 biliu 1.87 else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1025     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1026     cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1027 ahart 1.84 else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1028     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1029     cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1030 wulsin 1.89 else if(currentHistogram.inputCollection == "met-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1031     cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1032     cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1033 biliu 1.87 else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1034     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1035     cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1036     else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1037     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1038     cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1039 ahart 1.84 else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1040     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1041     cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1042     else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1043     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1044     cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1045     else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1046     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1047     cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1048     else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1049     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1050     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1051     else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1052     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1053     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1054     else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1055     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1056     cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1057     else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1058     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1059     cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1060    
1061     else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1062     else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1063     else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1064     else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1065     else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1066     else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1067     else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1068     else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1069     else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1070     else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1071     else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1072     else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1073     }
1074     else if(currentHistogram.inputVariables.size() == 2){
1075     TH2D* histo;
1076     histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1077     if (currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1078     else if(currentHistogram.inputCollection == "secondary jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1079     else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1080     else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1081     else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1082     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1083     cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1084     else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1085     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1086     cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1087 biliu 1.87 else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1088     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1089     cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1090     else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1091     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1092     cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1093     else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1094     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1095     cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1096 ahart 1.84 else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1097     else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1098     else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1099     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1100     cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1101     else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1102     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1103     cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1104     else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1105     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1106     cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1107     else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1108     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1109     cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1110     else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1111     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1112     cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1113 biliu 1.87 else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1114     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1115     cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1116 ahart 1.84 else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1117     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1118     cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1119 wulsin 1.89 else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1120     cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1121     cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1122 biliu 1.87 else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1123     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1124     cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1125     else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1126     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1127     cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1128 ahart 1.84 else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1129     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1130     cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1131     else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1132     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1133     cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1134     else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1135     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1136     cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1137     else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1138     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1139     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1140     else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1141     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1142     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1143     else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1144     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1145     cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1146     else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1147     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1148     cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1149     else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1150     else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1151     else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1152     else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1153     else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1154     cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1155     cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1156     else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1157     else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
1158     else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
1159     else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
1160     else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
1161     else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
1162     else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
1163     else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
1164     }
1165    
1166     }
1167    
1168    
1169     //fills histograms with the sizes of collections
1170     for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1171    
1172     string currentObject = objectsToPlot.at(currentObjectIndex);
1173     string objectToPlot = "";
1174    
1175     // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1176     if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
1177     else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
1178     else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
1179 wulsin 1.89 else if(currentObject == "electron-photon pairs") objectToPlot = "electronPhotonPairs";
1180 ahart 1.84 else if(currentObject == "electron-jet pairs") objectToPlot = "electronJetPairs";
1181     else if(currentObject == "muon-jet pairs") objectToPlot = "muonJetPairs";
1182 wulsin 1.89 else if(currentObject == "met-jet pairs") objectToPlot = "metJetPairs";
1183     else if(currentObject == "muon-photon pairs") objectToPlot = "muonPhotonPairs";
1184     else if(currentObject == "photon-jet pairs") objectToPlot = "photonJetPairs";
1185 ahart 1.84 else if(currentObject == "jet-jet pairs") objectToPlot = "dijetPairs";
1186 biliu 1.87 else if(currentObject == "jet-secondary jet pairs") objectToPlot = "jetSecondaryJetPairs";
1187 ahart 1.84 else if(currentObject == "secondary jets") objectToPlot = "secondaryJets";
1188     else if(currentObject == "electron-track pairs") objectToPlot = "electronTrackPairs";
1189     else if(currentObject == "muon-track pairs") objectToPlot = "muonTrackPairs";
1190     else if(currentObject == "muon-tau pairs") objectToPlot = "muonTauPairs";
1191     else if(currentObject == "tau-tau pairs") objectToPlot = "ditauPairs";
1192     else if(currentObject == "tau-track pairs") objectToPlot = "tauTrackPairs";
1193     else if(currentObject == "track-event pairs") objectToPlot = "trackEventPairs";
1194     else if(currentObject == "muon-secondary muon pairs") objectToPlot = "muonSecondaryMuonPairs";
1195     else if(currentObject == "secondary muons") objectToPlot = "secondaryMuons";
1196 biliu 1.87 else if(currentObject == "muon-secondary jet pairs") objectToPlot = "muonSecondaryJetPairs";
1197     else if(currentObject == "electron-secondary jet pairs") objectToPlot = "electronSecondaryJetPairs";
1198 wulsin 1.89 else if(currentObject == "photon-secondary jet pairs") objectToPlot = "photonSecondaryJetPairs";
1199 ahart 1.84 else if(currentObject == "electron-secondary electron pairs") objectToPlot = "electronSecondaryElectronPairs";
1200     else if(currentObject == "secondary electrons") objectToPlot = "secondaryElectrons";
1201     else if(currentObject == "electron-trigobj pairs") objectToPlot = "electronTrigobjPairs";
1202     else if(currentObject == "muon-trigobj pairs") objectToPlot = "muonTrigobjPairs";
1203     else objectToPlot = currentObject;
1204    
1205     string tempCurrentObject = objectToPlot;
1206     tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1207     string histoName = "num" + tempCurrentObject;
1208    
1209 lantonel 1.86
1210 ahart 1.84 if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1211 lantonel 1.86 flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1212 ahart 1.84 int numToPlot = 0;
1213     for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1214 lantonel 1.86 if(lastCutFlags.at(currentFlag).second) numToPlot++;
1215 ahart 1.84 }
1216 lantonel 1.86
1217 ahart 1.84 if(objectToPlot == "primaryvertexs"){
1218     oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1219     oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1220     }
1221     else {
1222     oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1223     }
1224     }
1225     } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1226    
1227    
1228     } // end if(eventPassedPreviousCuts.at(currentDir))
1229     } // end loop over cuts
1230    
1231 ahart 1.85 if (!useEDMFormat_ && eventPassedAllCuts){
1232 ahart 1.84 // Assign BNTree variables
1233     for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1234     BranchSpecs brSpecs = treeBranches_.at(iBranch);
1235     string coll = brSpecs.inputCollection;
1236     if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection: " << coll << ", will cause a seg fault" << endl;
1237    
1238     if (coll == "jets") assignTreeBranch(brSpecs,jets.product(), cumulativeFlags.at(coll).back());
1239     else if(coll == "secondary jets") assignTreeBranch(brSpecs,jets.product(), cumulativeFlags.at(coll).back());
1240     else if(coll == "muons") assignTreeBranch(brSpecs,muons.product(), cumulativeFlags.at(coll).back());
1241     else if(coll == "secondary muons") assignTreeBranch(brSpecs,muons.product(), cumulativeFlags.at(coll).back());
1242     else if(coll == "electrons") assignTreeBranch(brSpecs,electrons.product(), cumulativeFlags.at(coll).back());
1243     else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(), cumulativeFlags.at(coll).back());
1244     else if(coll == "events") assignTreeBranch(brSpecs,events.product(), cumulativeFlags.at(coll).back());
1245     else if(coll == "taus") assignTreeBranch(brSpecs,taus.product(), cumulativeFlags.at(coll).back());
1246     else if(coll == "mets") assignTreeBranch(brSpecs,mets.product(), cumulativeFlags.at(coll).back());
1247     else if(coll == "tracks") assignTreeBranch(brSpecs,tracks.product(), cumulativeFlags.at(coll).back());
1248     else if(coll == "genjets") assignTreeBranch(brSpecs,genjets.product(), cumulativeFlags.at(coll).back());
1249     else if(coll == "mcparticles") assignTreeBranch(brSpecs,mcparticles.product(), cumulativeFlags.at(coll).back());
1250     else if(coll == "primaryvertexs") assignTreeBranch(brSpecs,primaryvertexs.product(),cumulativeFlags.at(coll).back());
1251     else if(coll == "bxlumis") assignTreeBranch(brSpecs,bxlumis.product(), cumulativeFlags.at(coll).back());
1252     else if(coll == "photons") assignTreeBranch(brSpecs,photons.product(), cumulativeFlags.at(coll).back());
1253     else if(coll == "superclusters") assignTreeBranch(brSpecs,superclusters.product(), cumulativeFlags.at(coll).back());
1254     else if(coll == "trigobjs") assignTreeBranch(brSpecs,trigobjs.product(), cumulativeFlags.at(coll).back());
1255     else if(coll == "stops"
1256     && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(), cumulativeFlags.at(coll).back());
1257     } // end loop over branches
1258    
1259     if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR: Undefined BNTree. Will likely seg fault." << endl; }
1260     BNTrees_.at(currentChannelIndex)->Fill(); // only fill if event has passed cuts
1261     }
1262 wulsin 1.74
1263 ahart 1.85 (*channelDecisions)[currentChannel.name] = eventPassedAllCuts;
1264    
1265 wulsin 1.80 } // end loop over channel
1266 lantonel 1.22
1267 ahart 1.58 masterCutFlow_->fillCutFlow(masterScaleFactor);
1268 lantonel 1.1
1269 ahart 1.85 event.put (channelDecisions, "channelDecisions");
1270 wulsin 1.74
1271 wulsin 1.42 } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1272 lantonel 1.1
1273 lantonel 1.14
1274 lantonel 1.1
1275 ahart 1.8 bool
1276 lantonel 1.1 OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
1277    
1278 lantonel 1.3
1279 lantonel 1.1 if(comparison == ">") return testValue > cutValue;
1280     else if(comparison == ">=") return testValue >= cutValue;
1281     else if(comparison == "<") return testValue < cutValue;
1282     else if(comparison == "<=") return testValue <= cutValue;
1283 ahart 1.8 else if(comparison == "==") return testValue == cutValue;
1284 lantonel 1.17 else if(comparison == "=") return testValue == cutValue;
1285 ahart 1.8 else if(comparison == "!=") return testValue != cutValue;
1286 ahart 1.57 else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1287    
1288     }
1289    
1290     bool
1291     OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1292    
1293    
1294     if(comparison == ">") return testValue > cutValue;
1295     else if(comparison == ">=") return testValue >= cutValue;
1296     else if(comparison == "<") return testValue < cutValue;
1297     else if(comparison == "<=") return testValue <= cutValue;
1298     else if(comparison == "==") return testValue == cutValue;
1299     else if(comparison == "=") return testValue == cutValue;
1300     else if(comparison == "!=") return testValue != cutValue;
1301     else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1302 lantonel 1.1
1303     }
1304    
1305 lantonel 1.3 bool
1306 biliu 1.71 OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1307 lantonel 1.3
1308 lantonel 1.72 //initialize to false until a chosen trigger is passed
1309 lantonel 1.3 bool triggerDecision = false;
1310 lantonel 1.72
1311 ahart 1.84 if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1312 lantonel 1.72 //loop over all triggers defined in the event
1313     for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1314    
1315 ahart 1.84 if (printAllTriggers_) cout << " " << trigger->name << endl;
1316 wulsin 1.82
1317 lantonel 1.72 //we're only interested in triggers that actually passed
1318     if(trigger->pass != 1) continue;
1319    
1320     //if the event passes one of the veto triggers, exit and return false
1321     for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1322     if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1323     }
1324     //if the event passes one of the chosen triggers, set triggerDecision to true
1325     for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1326     if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1327 ahart 1.84 }
1328 lantonel 1.72 }
1329 wulsin 1.82
1330 ahart 1.84 printAllTriggers_ = false; // only print triggers once, not every event
1331 wulsin 1.82
1332 ahart 1.84 //if none of the veto triggers fired:
1333 lantonel 1.72 //return the OR of all the chosen triggers
1334     if (triggersToTest.size() != 0) return triggerDecision;
1335     //or if no triggers were defined return true
1336     else return true;
1337 lantonel 1.3 }
1338 lantonel 1.72
1339    
1340 ahart 1.57 vector<string>
1341 lantonel 1.1 OSUAnalysis::splitString (string inputString){
1342    
1343 ahart 1.57 stringstream stringStream(inputString);
1344     istream_iterator<string> begin(stringStream);
1345     istream_iterator<string> end;
1346     vector<string> stringVector(begin, end);
1347 lantonel 1.1 return stringVector;
1348    
1349     }
1350    
1351 wulsin 1.49
1352     void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1353 ahart 1.57 // Set two object strings from the tempInputCollection string,
1354     // For example, if tempInputCollection is "electron-muon pairs",
1355     // then obj1 = "electrons" and obj2 = "muons".
1356     // Note that the objects have an "s" appended.
1357 wulsin 1.49
1358     int dashIndex = tempInputCollection.find("-");
1359     int spaceIndex = tempInputCollection.find_last_of(" ");
1360     int secondWordLength = spaceIndex - dashIndex;
1361 ahart 1.57 obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1362 wulsin 1.49 obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1363 ahart 1.57
1364     }
1365 wulsin 1.49
1366    
1367     string OSUAnalysis::getObjToGet(string obj) {
1368     // Return the string corresponding to the object to get for the given obj string.
1369 ahart 1.57 // Right now this only handles the case in which obj contains "secondary",
1370     // e.g, "secondary muons".
1371     // Note that "s" is NOT appended.
1372    
1373     if (obj.find("secondary")==string::npos) return obj; // "secondary" is not found
1374     int firstSpaceIndex = obj.find_first_of(" ");
1375 wulsin 1.49 return obj.substr(firstSpaceIndex+1,obj.length()-1);
1376    
1377 ahart 1.57 }
1378 wulsin 1.49
1379    
1380 lantonel 1.51 //!jet valueLookup
1381 lantonel 1.1 double
1382 ahart 1.57 OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1383 lantonel 1.1
1384     double value = 0.0;
1385     if(variable == "energy") value = object->energy;
1386     else if(variable == "et") value = object->et;
1387     else if(variable == "pt") value = object->pt;
1388     else if(variable == "px") value = object->px;
1389     else if(variable == "py") value = object->py;
1390     else if(variable == "pz") value = object->pz;
1391     else if(variable == "phi") value = object->phi;
1392     else if(variable == "eta") value = object->eta;
1393     else if(variable == "theta") value = object->theta;
1394     else if(variable == "Upt") value = object->Upt;
1395     else if(variable == "Uenergy") value = object->Uenergy;
1396     else if(variable == "L2pt") value = object->L2pt;
1397     else if(variable == "L2L3pt") value = object->L2L3pt;
1398     else if(variable == "L2L3respt") value = object->L2L3respt;
1399     else if(variable == "respt") value = object->respt;
1400     else if(variable == "EMfrac") value = object->EMfrac;
1401     else if(variable == "Hadfrac") value = object->Hadfrac;
1402     else if(variable == "charge") value = object->charge;
1403     else if(variable == "mass") value = object->mass;
1404     else if(variable == "area") value = object->area;
1405     else if(variable == "fHPD") value = object->fHPD;
1406     else if(variable == "approximatefHPD") value = object->approximatefHPD;
1407     else if(variable == "genPartonET") value = object->genPartonET;
1408     else if(variable == "genPartonPT") value = object->genPartonPT;
1409     else if(variable == "genPartonEta") value = object->genPartonEta;
1410     else if(variable == "genPartonPhi") value = object->genPartonPhi;
1411     else if(variable == "genJetET") value = object->genJetET;
1412     else if(variable == "genJetPT") value = object->genJetPT;
1413     else if(variable == "genJetEta") value = object->genJetEta;
1414     else if(variable == "genJetPhi") value = object->genJetPhi;
1415     else if(variable == "btagTChighPur") value = object->btagTChighPur;
1416     else if(variable == "btagTChighEff") value = object->btagTChighEff;
1417     else if(variable == "btagJetProb") value = object->btagJetProb;
1418     else if(variable == "btagJetBProb") value = object->btagJetBProb;
1419     else if(variable == "btagSoftEle") value = object->btagSoftEle;
1420     else if(variable == "btagSoftMuon") value = object->btagSoftMuon;
1421     else if(variable == "btagSoftMuonNoIP") value = object->btagSoftMuonNoIP;
1422     else if(variable == "btagSecVertex") value = object->btagSecVertex;
1423     else if(variable == "btagSecVertexHighEff") value = object->btagSecVertexHighEff;
1424     else if(variable == "btagSecVertexHighPur") value = object->btagSecVertexHighPur;
1425     else if(variable == "btagCombinedSecVertex") value = object->btagCombinedSecVertex;
1426     else if(variable == "btagCombinedSecVertexMVA") value = object->btagCombinedSecVertexMVA;
1427     else if(variable == "btagSoftMuonByPt") value = object->btagSoftMuonByPt;
1428     else if(variable == "btagSoftMuonByIP3") value = object->btagSoftMuonByIP3;
1429     else if(variable == "btagSoftElectronByPt") value = object->btagSoftElectronByPt;
1430     else if(variable == "btagSoftElectronByIP3") value = object->btagSoftElectronByIP3;
1431     else if(variable == "n90Hits") value = object->n90Hits;
1432     else if(variable == "hitsInN90") value = object->hitsInN90;
1433     else if(variable == "chargedHadronEnergyFraction") value = object->chargedHadronEnergyFraction;
1434     else if(variable == "neutralHadronEnergyFraction") value = object->neutralHadronEnergyFraction;
1435     else if(variable == "chargedEmEnergyFraction") value = object->chargedEmEnergyFraction;
1436     else if(variable == "neutralEmEnergyFraction") value = object->neutralEmEnergyFraction;
1437     else if(variable == "fLong") value = object->fLong;
1438     else if(variable == "fShort") value = object->fShort;
1439     else if(variable == "etaetaMoment") value = object->etaetaMoment;
1440     else if(variable == "phiphiMoment") value = object->phiphiMoment;
1441     else if(variable == "JESunc") value = object->JESunc;
1442     else if(variable == "JECuncUp") value = object->JECuncUp;
1443     else if(variable == "JECuncDown") value = object->JECuncDown;
1444     else if(variable == "puJetMVA_full") value = object->puJetMVA_full;
1445     else if(variable == "puJetMVA_simple") value = object->puJetMVA_simple;
1446     else if(variable == "puJetMVA_cutbased") value = object->puJetMVA_cutbased;
1447     else if(variable == "dZ") value = object->dZ;
1448     else if(variable == "dR2Mean") value = object->dR2Mean;
1449     else if(variable == "dRMean") value = object->dRMean;
1450     else if(variable == "frac01") value = object->frac01;
1451     else if(variable == "frac02") value = object->frac02;
1452     else if(variable == "frac03") value = object->frac03;
1453     else if(variable == "frac04") value = object->frac04;
1454     else if(variable == "frac05") value = object->frac05;
1455     else if(variable == "frac06") value = object->frac06;
1456     else if(variable == "frac07") value = object->frac07;
1457     else if(variable == "beta") value = object->beta;
1458     else if(variable == "betaStar") value = object->betaStar;
1459     else if(variable == "betaClassic") value = object->betaClassic;
1460     else if(variable == "betaStarClassic") value = object->betaStarClassic;
1461     else if(variable == "ptD") value = object->ptD;
1462     else if(variable == "nvtx") value = object->nvtx;
1463     else if(variable == "d0") value = object->d0;
1464     else if(variable == "leadCandPt") value = object->leadCandPt;
1465     else if(variable == "leadCandVx") value = object->leadCandVx;
1466     else if(variable == "leadCandVy") value = object->leadCandVy;
1467     else if(variable == "leadCandVz") value = object->leadCandVz;
1468     else if(variable == "leadCandDistFromPV") value = object->leadCandDistFromPV;
1469     else if(variable == "flavour") value = object->flavour;
1470     else if(variable == "Nconst") value = object->Nconst;
1471     else if(variable == "jetIDMinimal") value = object->jetIDMinimal;
1472     else if(variable == "jetIDLooseAOD") value = object->jetIDLooseAOD;
1473     else if(variable == "jetIDLoose") value = object->jetIDLoose;
1474     else if(variable == "jetIDTight") value = object->jetIDTight;
1475     else if(variable == "genPartonId") value = object->genPartonId;
1476     else if(variable == "genPartonMotherId") value = object->genPartonMotherId;
1477     else if(variable == "genPartonMother0Id") value = object->genPartonMother0Id;
1478     else if(variable == "genPartonMother1Id") value = object->genPartonMother1Id;
1479     else if(variable == "genPartonGrandMotherId") value = object->genPartonGrandMotherId;
1480     else if(variable == "genPartonGrandMother00Id") value = object->genPartonGrandMother00Id;
1481     else if(variable == "genPartonGrandMother01Id") value = object->genPartonGrandMother01Id;
1482     else if(variable == "genPartonGrandMother10Id") value = object->genPartonGrandMother10Id;
1483     else if(variable == "genPartonGrandMother11Id") value = object->genPartonGrandMother11Id;
1484     else if(variable == "chargedMultiplicity") value = object->chargedMultiplicity;
1485     else if(variable == "neutralMultiplicity") value = object->neutralMultiplicity;
1486     else if(variable == "nconstituents") value = object->nconstituents;
1487     else if(variable == "nHit") value = object->nHit;
1488     else if(variable == "puJetId_full") value = object->puJetId_full;
1489     else if(variable == "puJetId_simple") value = object->puJetId_simple;
1490     else if(variable == "puJetId_cutbased") value = object->puJetId_cutbased;
1491     else if(variable == "puJetId_tight_full") value = object->puJetId_tight_full;
1492     else if(variable == "puJetId_tight_simple") value = object->puJetId_tight_simple;
1493     else if(variable == "puJetId_tight_cutbased") value = object->puJetId_tight_cutbased;
1494     else if(variable == "puJetId_medium_full") value = object->puJetId_medium_full;
1495     else if(variable == "puJetId_medium_simple") value = object->puJetId_medium_simple;
1496     else if(variable == "puJetId_medium_cutbased") value = object->puJetId_medium_cutbased;
1497     else if(variable == "puJetId_loose_full") value = object->puJetId_loose_full;
1498     else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
1499     else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1500 ahart 1.8
1501 jbrinson 1.88 //user defined variable
1502     else if(variable == "disappTrkLeadingJetID") {
1503     value = object->pt > 110
1504     && fabs(object->eta) < 2.4
1505     && object->chargedHadronEnergyFraction > 0.2
1506     && object->neutralHadronEnergyFraction < 0.7
1507     && object->chargedEmEnergyFraction < 0.5
1508     && object->neutralEmEnergyFraction < 0.7;
1509     }
1510    
1511     else if(variable == "disappTrkSubLeadingJetID") {
1512     value = object->pt > 30
1513     && fabs(object->eta) < 4.5
1514     && object->neutralHadronEnergyFraction < 0.7
1515     && object->chargedEmEnergyFraction < 0.5;
1516     }
1517    
1518 wulsin 1.89 else if(variable == "dPhiMet") {
1519     if (const BNmet *met = chosenMET ()) {
1520     value = deltaPhi (object->phi, met->phi);
1521     } else value = -999;
1522     }
1523    
1524 ahart 1.8
1525 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1526 ahart 1.8
1527 lantonel 1.6 value = applyFunction(function, value);
1528 lantonel 1.1
1529     return value;
1530 wulsin 1.90 } // end jet valueLookup
1531 lantonel 1.1
1532    
1533 lantonel 1.51 //!muon valueLookup
1534 lantonel 1.1 double
1535 ahart 1.57 OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1536 lantonel 1.1
1537     double value = 0.0;
1538     if(variable == "energy") value = object->energy;
1539     else if(variable == "et") value = object->et;
1540     else if(variable == "pt") value = object->pt;
1541     else if(variable == "px") value = object->px;
1542     else if(variable == "py") value = object->py;
1543     else if(variable == "pz") value = object->pz;
1544     else if(variable == "phi") value = object->phi;
1545     else if(variable == "eta") value = object->eta;
1546     else if(variable == "theta") value = object->theta;
1547     else if(variable == "trackIso") value = object->trackIso;
1548     else if(variable == "ecalIso") value = object->ecalIso;
1549     else if(variable == "hcalIso") value = object->hcalIso;
1550     else if(variable == "caloIso") value = object->caloIso;
1551 lantonel 1.22 else if(variable == "trackIsDR03") value = object->trackIsoDR03;
1552 lantonel 1.1 else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
1553     else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
1554     else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
1555     else if(variable == "trackVetoIsoDR03") value = object->trackVetoIsoDR03;
1556     else if(variable == "ecalVetoIsoDR03") value = object->ecalVetoIsoDR03;
1557     else if(variable == "hcalVetoIsoDR03") value = object->hcalVetoIsoDR03;
1558     else if(variable == "caloVetoIsoDR03") value = object->caloVetoIsoDR03;
1559     else if(variable == "trackIsoDR05") value = object->trackIsoDR05;
1560     else if(variable == "ecalIsoDR05") value = object->ecalIsoDR05;
1561     else if(variable == "hcalIsoDR05") value = object->hcalIsoDR05;
1562     else if(variable == "caloIsoDR05") value = object->caloIsoDR05;
1563     else if(variable == "trackVetoIsoDR05") value = object->trackVetoIsoDR05;
1564     else if(variable == "ecalVetoIsoDR05") value = object->ecalVetoIsoDR05;
1565     else if(variable == "hcalVetoIsoDR05") value = object->hcalVetoIsoDR05;
1566     else if(variable == "caloVetoIsoDR05") value = object->caloVetoIsoDR05;
1567     else if(variable == "hcalE") value = object->hcalE;
1568     else if(variable == "ecalE") value = object->ecalE;
1569     else if(variable == "genET") value = object->genET;
1570     else if(variable == "genPT") value = object->genPT;
1571     else if(variable == "genPhi") value = object->genPhi;
1572     else if(variable == "genEta") value = object->genEta;
1573     else if(variable == "genMotherET") value = object->genMotherET;
1574     else if(variable == "genMotherPT") value = object->genMotherPT;
1575     else if(variable == "genMotherPhi") value = object->genMotherPhi;
1576     else if(variable == "genMotherEta") value = object->genMotherEta;
1577     else if(variable == "vx") value = object->vx;
1578     else if(variable == "vy") value = object->vy;
1579     else if(variable == "vz") value = object->vz;
1580     else if(variable == "tkNormChi2") value = object->tkNormChi2;
1581     else if(variable == "tkPT") value = object->tkPT;
1582     else if(variable == "tkEta") value = object->tkEta;
1583     else if(variable == "tkPhi") value = object->tkPhi;
1584     else if(variable == "tkDZ") value = object->tkDZ;
1585     else if(variable == "tkD0") value = object->tkD0;
1586     else if(variable == "tkD0bs") value = object->tkD0bs;
1587     else if(variable == "tkD0err") value = object->tkD0err;
1588     else if(variable == "samNormChi2") value = object->samNormChi2;
1589     else if(variable == "samPT") value = object->samPT;
1590     else if(variable == "samEta") value = object->samEta;
1591     else if(variable == "samPhi") value = object->samPhi;
1592     else if(variable == "samDZ") value = object->samDZ;
1593     else if(variable == "samD0") value = object->samD0;
1594     else if(variable == "samD0bs") value = object->samD0bs;
1595     else if(variable == "samD0err") value = object->samD0err;
1596     else if(variable == "comNormChi2") value = object->comNormChi2;
1597     else if(variable == "comPT") value = object->comPT;
1598     else if(variable == "comEta") value = object->comEta;
1599     else if(variable == "comPhi") value = object->comPhi;
1600     else if(variable == "comDZ") value = object->comDZ;
1601     else if(variable == "comD0") value = object->comD0;
1602     else if(variable == "comD0bs") value = object->comD0bs;
1603     else if(variable == "comD0err") value = object->comD0err;
1604     else if(variable == "isolationR03emVetoEt") value = object->isolationR03emVetoEt;
1605     else if(variable == "isolationR03hadVetoEt") value = object->isolationR03hadVetoEt;
1606     else if(variable == "normalizedChi2") value = object->normalizedChi2;
1607     else if(variable == "dVzPVz") value = object->dVzPVz;
1608     else if(variable == "dB") value = object->dB;
1609     else if(variable == "ptErr") value = object->ptErr;
1610     else if(variable == "innerTrackNormChi2") value = object->innerTrackNormChi2;
1611     else if(variable == "correctedD0") value = object->correctedD0;
1612     else if(variable == "correctedD0Vertex") value = object->correctedD0Vertex;
1613     else if(variable == "correctedDZ") value = object->correctedDZ;
1614     else if(variable == "particleIso") value = object->particleIso;
1615     else if(variable == "chargedHadronIso") value = object->chargedHadronIso;
1616     else if(variable == "neutralHadronIso") value = object->neutralHadronIso;
1617     else if(variable == "photonIso") value = object->photonIso;
1618     else if(variable == "puChargedHadronIso") value = object->puChargedHadronIso;
1619     else if(variable == "chargedHadronIsoDR03") value = object->chargedHadronIsoDR03;
1620     else if(variable == "neutralHadronIsoDR03") value = object->neutralHadronIsoDR03;
1621     else if(variable == "photonIsoDR03") value = object->photonIsoDR03;
1622     else if(variable == "puChargedHadronIsoDR03") value = object->puChargedHadronIsoDR03;
1623     else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1624     else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1625     else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1626     else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1627     else if(variable == "rhoPrime") value = object->rhoPrime;
1628     else if(variable == "AEffDr03") value = object->AEffDr03;
1629     else if(variable == "AEffDr04") value = object->AEffDr04;
1630     else if(variable == "pfIsoR03SumChargedHadronPt") value = object->pfIsoR03SumChargedHadronPt;
1631     else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1632     else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1633     else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1634     else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1635     else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1636     else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
1637     else if(variable == "pfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt;
1638     else if(variable == "IP") value = object->IP;
1639     else if(variable == "IPError") value = object->IPError;
1640     else if(variable == "timeAtIpInOut") value = object->timeAtIpInOut;
1641     else if(variable == "timeAtIpInOutErr") value = object->timeAtIpInOutErr;
1642     else if(variable == "timeAtIpOutIn") value = object->timeAtIpOutIn;
1643     else if(variable == "timeAtIpOutInErr") value = object->timeAtIpOutInErr;
1644     else if(variable == "ecal_time") value = object->ecal_time;
1645     else if(variable == "hcal_time") value = object->hcal_time;
1646     else if(variable == "ecal_timeError") value = object->ecal_timeError;
1647     else if(variable == "hcal_timeError") value = object->hcal_timeError;
1648     else if(variable == "energy_ecal") value = object->energy_ecal;
1649     else if(variable == "energy_hcal") value = object->energy_hcal;
1650     else if(variable == "e3x3_ecal") value = object->e3x3_ecal;
1651     else if(variable == "e3x3_hcal") value = object->e3x3_hcal;
1652     else if(variable == "energyMax_ecal") value = object->energyMax_ecal;
1653     else if(variable == "energyMax_hcal") value = object->energyMax_hcal;
1654     else if(variable == "charge") value = object->charge;
1655     else if(variable == "IDGMPTight") value = object->IDGMPTight;
1656     else if(variable == "tkNumValidHits") value = object->tkNumValidHits;
1657     else if(variable == "tkCharge") value = object->tkCharge;
1658     else if(variable == "samNumValidHits") value = object->samNumValidHits;
1659     else if(variable == "samCharge") value = object->samCharge;
1660     else if(variable == "comNumValidHits") value = object->comNumValidHits;
1661     else if(variable == "comCharge") value = object->comCharge;
1662     else if(variable == "genId") value = object->genId;
1663     else if(variable == "genCharge") value = object->genCharge;
1664     else if(variable == "genNumberOfMothers") value = object->genNumberOfMothers;
1665     else if(variable == "genMotherId") value = object->genMotherId;
1666     else if(variable == "genMotherCharge") value = object->genMotherCharge;
1667     else if(variable == "genMother0Id") value = object->genMother0Id;
1668     else if(variable == "genMother1Id") value = object->genMother1Id;
1669     else if(variable == "genGrandMother00Id") value = object->genGrandMother00Id;
1670     else if(variable == "genGrandMother01Id") value = object->genGrandMother01Id;
1671     else if(variable == "genGrandMother10Id") value = object->genGrandMother10Id;
1672     else if(variable == "genGrandMother11Id") value = object->genGrandMother11Id;
1673     else if(variable == "isPFMuon") value = object->isPFMuon;
1674     else if(variable == "isGoodMuon_1StationTight") value = object->isGoodMuon_1StationTight;
1675     else if(variable == "isGlobalMuon") value = object->isGlobalMuon;
1676     else if(variable == "isTrackerMuon") value = object->isTrackerMuon;
1677     else if(variable == "isStandAloneMuon") value = object->isStandAloneMuon;
1678     else if(variable == "isGlobalMuonPromptTight") value = object->isGlobalMuonPromptTight;
1679     else if(variable == "numberOfValidMuonHits") value = object->numberOfValidMuonHits;
1680     else if(variable == "numberOfValidTrackerHits") value = object->numberOfValidTrackerHits;
1681     else if(variable == "numberOfLayersWithMeasurement") value = object->numberOfLayersWithMeasurement;
1682     else if(variable == "pixelLayersWithMeasurement") value = object->pixelLayersWithMeasurement;
1683     else if(variable == "numberOfMatches") value = object->numberOfMatches;
1684     else if(variable == "numberOfValidTrackerHitsInnerTrack") value = object->numberOfValidTrackerHitsInnerTrack;
1685     else if(variable == "numberOfValidPixelHits") value = object->numberOfValidPixelHits;
1686     else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations;
1687     else if(variable == "time_ndof") value = object->time_ndof;
1688    
1689 lantonel 1.9 //user-defined variables
1690 jbrinson 1.88 else if(variable == "looseID") {
1691 wulsin 1.90 value = object->pt > 10 &&
1692     (object->isGlobalMuon > 0 ||
1693     object->isTrackerMuon > 0);
1694     }
1695 ahart 1.31 else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1696     else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1697 lantonel 1.19 else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1698 ahart 1.31 else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1699 lantonel 1.9 else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1700 ahart 1.31 else if(variable == "metMT") {
1701 ahart 1.63 if (const BNmet *met = chosenMET ())
1702 ahart 1.31 {
1703 ahart 1.61 double dPhi = deltaPhi (object->phi, met->phi);
1704     value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1705 ahart 1.31 }
1706     else
1707     value = -999;
1708     }
1709 lantonel 1.26
1710    
1711    
1712     else if(variable == "correctedD0VertexInEBPlus"){
1713     if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1714     else value = -999;
1715     }
1716     else if(variable == "correctedD0VertexOutEBPlus"){
1717     if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1718     else value = -999;
1719     }
1720     else if(variable == "correctedD0VertexEEPlus"){
1721     if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1722     else value = -999;
1723     }
1724    
1725     else if(variable == "correctedD0BeamspotInEBPlus"){
1726     if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1727     else value = -999;
1728     }
1729     else if(variable == "correctedD0BeamspotOutEBPlus"){
1730     if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1731     else value = -999;
1732     }
1733     else if(variable == "correctedD0BeamspotEEPlus"){
1734     if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1735     else value = -999;
1736     }
1737    
1738     else if(variable == "correctedD0VertexInEBMinus"){
1739     if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1740     else value = -999;
1741     }
1742     else if(variable == "correctedD0VertexOutEBMinus"){
1743     if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1744     else value = -999;
1745     }
1746     else if(variable == "correctedD0VertexEEMinus"){
1747     if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1748     else value = -999;
1749     }
1750    
1751     else if(variable == "correctedD0BeamspotInEBMinus"){
1752     if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1753     else value = -999;
1754     }
1755     else if(variable == "correctedD0BeamspotOutEBMinus"){
1756     if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1757     else value = -999;
1758     }
1759     else if(variable == "correctedD0BeamspotEEMinus"){
1760     if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1761     else value = -999;
1762     }
1763    
1764    
1765     else if(variable == "correctedD0VertexInEBPositiveCharge"){
1766     if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1767     else value = -999;
1768     }
1769     else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1770     if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1771     else value = -999;
1772     }
1773     else if(variable == "correctedD0VertexEEPositiveCharge"){
1774     if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1775     else value = -999;
1776     }
1777    
1778     else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1779     if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1780     else value = -999;
1781     }
1782     else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1783     if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1784     else value = -999;
1785     }
1786     else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1787     if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1788     else value = -999;
1789     }
1790    
1791     else if(variable == "correctedD0VertexInEBNegativeCharge"){
1792     if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1793     else value = -999;
1794     }
1795     else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1796     if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1797     else value = -999;
1798     }
1799     else if(variable == "correctedD0VertexEENegativeCharge"){
1800     if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1801     else value = -999;
1802     }
1803    
1804     else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1805     if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1806     else value = -999;
1807     }
1808     else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1809     if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1810     else value = -999;
1811     }
1812     else if(variable == "correctedD0BeamspotEENegativeCharge"){
1813     if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1814     else value = -999;
1815     }
1816    
1817    
1818 lantonel 1.10 else if(variable == "tightID") {
1819 ahart 1.31 value = object->isGlobalMuon > 0 \
1820     && object->isPFMuon > 0 \
1821     && object->normalizedChi2 < 10 \
1822 wulsin 1.74 && object->numberOfValidMuonHits > 0 \
1823 ahart 1.31 && object->numberOfMatchedStations > 1 \
1824     && fabs(object->correctedD0Vertex) < 0.2 \
1825     && fabs(object->correctedDZ) < 0.5 \
1826     && object->numberOfValidPixelHits > 0 \
1827 lantonel 1.11 && object->numberOfLayersWithMeasurement > 5;
1828 lantonel 1.10 }
1829     else if(variable == "tightIDdisplaced"){
1830 ahart 1.31 value = object->isGlobalMuon > 0 \
1831 qpython 1.66 && object->isPFMuon > 0 \
1832 ahart 1.31 && object->normalizedChi2 < 10 \
1833 wulsin 1.74 && object->numberOfValidMuonHits > 0 \
1834 ahart 1.31 && object->numberOfMatchedStations > 1 \
1835     && object->numberOfValidPixelHits > 0 \
1836 lantonel 1.11 && object->numberOfLayersWithMeasurement > 5;
1837 lantonel 1.10 }
1838 lantonel 1.9
1839 ahart 1.57 else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1840 lantonel 1.26
1841 lantonel 1.36 else if(variable == "genMatchedPdgId"){
1842     int index = getGenMatchedParticleIndex(object);
1843     if(index == -1) value = 0;
1844     else value = mcparticles->at(index).id;
1845     }
1846 lantonel 1.26
1847 lantonel 1.22 else if(variable == "genMatchedId"){
1848     int index = getGenMatchedParticleIndex(object);
1849     if(index == -1) value = 0;
1850     else value = getPdgIdBinValue(mcparticles->at(index).id);
1851     }
1852     else if(variable == "genMatchedMotherId"){
1853     int index = getGenMatchedParticleIndex(object);
1854     if(index == -1) value = 0;
1855     else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1856     }
1857 lantonel 1.36 else if(variable == "genMatchedMotherIdReverse"){
1858     int index = getGenMatchedParticleIndex(object);
1859 jbrinson 1.62 if(index == -1) value = 24;
1860     else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1861 lantonel 1.36 }
1862 lantonel 1.22 else if(variable == "genMatchedGrandmotherId"){
1863     int index = getGenMatchedParticleIndex(object);
1864     if(index == -1) value = 0;
1865     else if(fabs(mcparticles->at(index).motherId) == 15){
1866     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1867     if(motherIndex == -1) value = 0;
1868     else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1869     }
1870     else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1871     }
1872 lantonel 1.50 else if(variable == "genMatchedGrandmotherIdReverse"){
1873     int index = getGenMatchedParticleIndex(object);
1874 jbrinson 1.62 if(index == -1) value = 24;
1875 lantonel 1.50 else if(fabs(mcparticles->at(index).motherId) == 15){
1876     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1877 jbrinson 1.62 if(motherIndex == -1) value = 24;
1878     else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1879 lantonel 1.50 }
1880 jbrinson 1.62 else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1881 lantonel 1.50 }
1882 ahart 1.64 else if(variable == "pfMuonsFromVertex"){
1883     double d0Error, dzError;
1884    
1885     d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1886     dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1887     value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1888 wulsin 1.74 || fabs (object->correctedD0Vertex / d0Error) > 99.0
1889     || fabs (object->correctedDZ / dzError) > 99.0;
1890 ahart 1.64 value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1891     }
1892 lantonel 1.19
1893    
1894    
1895 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1896 ahart 1.8
1897 lantonel 1.6 value = applyFunction(function, value);
1898 lantonel 1.1
1899     return value;
1900 wulsin 1.90 } // end muon valueLookup
1901    
1902 lantonel 1.1
1903 lantonel 1.51 //!electron valueLookup
1904 lantonel 1.1 double
1905 ahart 1.57 OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
1906 lantonel 1.1
1907     double value = 0.0;
1908     if(variable == "energy") value = object->energy;
1909     else if(variable == "et") value = object->et;
1910     else if(variable == "gsfEt") value = object->gsfEt;
1911     else if(variable == "pt") value = object->pt;
1912     else if(variable == "px") value = object->px;
1913     else if(variable == "py") value = object->py;
1914     else if(variable == "pz") value = object->pz;
1915     else if(variable == "phi") value = object->phi;
1916     else if(variable == "eta") value = object->eta;
1917     else if(variable == "theta") value = object->theta;
1918     else if(variable == "pIn") value = object->pIn;
1919     else if(variable == "pOut") value = object->pOut;
1920     else if(variable == "EscOverPin") value = object->EscOverPin;
1921     else if(variable == "EseedOverPout") value = object->EseedOverPout;
1922     else if(variable == "hadOverEm") value = object->hadOverEm;
1923     else if(variable == "trackIso") value = object->trackIso;
1924     else if(variable == "ecalIso") value = object->ecalIso;
1925     else if(variable == "hcalIso") value = object->hcalIso;
1926     else if(variable == "caloIso") value = object->caloIso;
1927     else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
1928     else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
1929     else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
1930     else if(variable == "hcalIsoDR03depth1") value = object->hcalIsoDR03depth1;
1931     else if(variable == "hcalIsoDR03depth2") value = object->hcalIsoDR03depth2;
1932     else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
1933     else if(variable == "trackIsoDR04") value = object->trackIsoDR04;
1934     else if(variable == "ecalIsoDR04") value = object->ecalIsoDR04;
1935     else if(variable == "hcalIsoDR04") value = object->hcalIsoDR04;
1936     else if(variable == "hcalIsoDR04depth1") value = object->hcalIsoDR04depth1;
1937     else if(variable == "hcalIsoDR04depth2") value = object->hcalIsoDR04depth2;
1938     else if(variable == "caloIsoDR04") value = object->caloIsoDR04;
1939     else if(variable == "fbrem") value = object->fbrem;
1940     else if(variable == "absInvEMinusInvPin") value = object->absInvEMinusInvPin;
1941     else if(variable == "delPhiIn") value = object->delPhiIn;
1942     else if(variable == "delEtaIn") value = object->delEtaIn;
1943     else if(variable == "genET") value = object->genET;
1944     else if(variable == "genPT") value = object->genPT;
1945     else if(variable == "genPhi") value = object->genPhi;
1946     else if(variable == "genEta") value = object->genEta;
1947     else if(variable == "genMotherET") value = object->genMotherET;
1948     else if(variable == "genMotherPT") value = object->genMotherPT;
1949     else if(variable == "genMotherPhi") value = object->genMotherPhi;
1950     else if(variable == "genMotherEta") value = object->genMotherEta;
1951     else if(variable == "vx") value = object->vx;
1952     else if(variable == "vy") value = object->vy;
1953     else if(variable == "vz") value = object->vz;
1954     else if(variable == "scEnergy") value = object->scEnergy;
1955     else if(variable == "scRawEnergy") value = object->scRawEnergy;
1956     else if(variable == "scSigmaEtaEta") value = object->scSigmaEtaEta;
1957     else if(variable == "scSigmaIEtaIEta") value = object->scSigmaIEtaIEta;
1958     else if(variable == "scE1x5") value = object->scE1x5;
1959     else if(variable == "scE2x5Max") value = object->scE2x5Max;
1960     else if(variable == "scE5x5") value = object->scE5x5;
1961     else if(variable == "scEt") value = object->scEt;
1962     else if(variable == "scEta") value = object->scEta;
1963     else if(variable == "scPhi") value = object->scPhi;
1964     else if(variable == "scZ") value = object->scZ;
1965     else if(variable == "tkNormChi2") value = object->tkNormChi2;
1966     else if(variable == "tkPT") value = object->tkPT;
1967     else if(variable == "tkEta") value = object->tkEta;
1968     else if(variable == "tkPhi") value = object->tkPhi;
1969     else if(variable == "tkDZ") value = object->tkDZ;
1970     else if(variable == "tkD0") value = object->tkD0;
1971     else if(variable == "tkD0bs") value = object->tkD0bs;
1972     else if(variable == "tkD0err") value = object->tkD0err;
1973     else if(variable == "mva") value = object->mva;
1974     else if(variable == "mvaTrigV0") value = object->mvaTrigV0;
1975     else if(variable == "mvaNonTrigV0") value = object->mvaNonTrigV0;
1976     else if(variable == "dist") value = object->dist;
1977     else if(variable == "dcot") value = object->dcot;
1978     else if(variable == "convradius") value = object->convradius;
1979     else if(variable == "convPointX") value = object->convPointX;
1980     else if(variable == "convPointY") value = object->convPointY;
1981     else if(variable == "convPointZ") value = object->convPointZ;
1982     else if(variable == "eMax") value = object->eMax;
1983     else if(variable == "eLeft") value = object->eLeft;
1984     else if(variable == "eRight") value = object->eRight;
1985     else if(variable == "eTop") value = object->eTop;
1986     else if(variable == "eBottom") value = object->eBottom;
1987     else if(variable == "e3x3") value = object->e3x3;
1988     else if(variable == "swissCross") value = object->swissCross;
1989     else if(variable == "seedEnergy") value = object->seedEnergy;
1990     else if(variable == "seedTime") value = object->seedTime;
1991     else if(variable == "swissCrossNoI85") value = object->swissCrossNoI85;
1992     else if(variable == "swissCrossI85") value = object->swissCrossI85;
1993     else if(variable == "E2overE9NoI85") value = object->E2overE9NoI85;
1994     else if(variable == "E2overE9I85") value = object->E2overE9I85;
1995     else if(variable == "correctedD0") value = object->correctedD0;
1996     else if(variable == "correctedD0Vertex") value = object->correctedD0Vertex;
1997     else if(variable == "correctedDZ") value = object->correctedDZ;
1998     else if(variable == "particleIso") value = object->particleIso;
1999     else if(variable == "chargedHadronIso") value = object->chargedHadronIso;
2000     else if(variable == "neutralHadronIso") value = object->neutralHadronIso;
2001     else if(variable == "photonIso") value = object->photonIso;
2002     else if(variable == "puChargedHadronIso") value = object->puChargedHadronIso;
2003     else if(variable == "chargedHadronIsoDR03") value = object->chargedHadronIsoDR03;
2004     else if(variable == "neutralHadronIsoDR03") value = object->neutralHadronIsoDR03;
2005     else if(variable == "photonIsoDR03") value = object->photonIsoDR03;
2006     else if(variable == "puChargedHadronIsoDR03") value = object->puChargedHadronIsoDR03;
2007     else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
2008     else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
2009     else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
2010     else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
2011     else if(variable == "rhoPrime") value = object->rhoPrime;
2012     else if(variable == "AEffDr03") value = object->AEffDr03;
2013     else if(variable == "AEffDr04") value = object->AEffDr04;
2014     else if(variable == "IP") value = object->IP;
2015     else if(variable == "IPError") value = object->IPError;
2016     else if(variable == "charge") value = object->charge;
2017     else if(variable == "classification") value = object->classification;
2018     else if(variable == "genId") value = object->genId;
2019     else if(variable == "genCharge") value = object->genCharge;
2020     else if(variable == "genNumberOfMothers") value = object->genNumberOfMothers;
2021     else if(variable == "genMotherId") value = object->genMotherId;
2022     else if(variable == "genMotherCharge") value = object->genMotherCharge;
2023     else if(variable == "genMother0Id") value = object->genMother0Id;
2024     else if(variable == "genMother1Id") value = object->genMother1Id;
2025     else if(variable == "genGrandMother00Id") value = object->genGrandMother00Id;
2026     else if(variable == "genGrandMother01Id") value = object->genGrandMother01Id;
2027     else if(variable == "genGrandMother10Id") value = object->genGrandMother10Id;
2028     else if(variable == "genGrandMother11Id") value = object->genGrandMother11Id;
2029     else if(variable == "numClusters") value = object->numClusters;
2030     else if(variable == "tkNumValidHits") value = object->tkNumValidHits;
2031     else if(variable == "tkCharge") value = object->tkCharge;
2032     else if(variable == "gsfCharge") value = object->gsfCharge;
2033     else if(variable == "isEB") value = object->isEB;
2034     else if(variable == "isEE") value = object->isEE;
2035     else if(variable == "isGap") value = object->isGap;
2036     else if(variable == "isEBEEGap") value = object->isEBEEGap;
2037     else if(variable == "isEBGap") value = object->isEBGap;
2038     else if(variable == "isEEGap") value = object->isEEGap;
2039     else if(variable == "isEcalDriven") value = object->isEcalDriven;
2040     else if(variable == "isTrackerDriven") value = object->isTrackerDriven;
2041     else if(variable == "numberOfLostHits") value = object->numberOfLostHits;
2042     else if(variable == "numberOfExpectedInnerHits") value = object->numberOfExpectedInnerHits;
2043     else if(variable == "numberOfValidPixelHits") value = object->numberOfValidPixelHits;
2044     else if(variable == "numberOfValidPixelBarrelHits") value = object->numberOfValidPixelBarrelHits;
2045     else if(variable == "numberOfValidPixelEndcapHits") value = object->numberOfValidPixelEndcapHits;
2046     else if(variable == "isHEEP") value = object->isHEEP;
2047     else if(variable == "isHEEPnoEt") value = object->isHEEPnoEt;
2048     else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2049     else if(variable == "eidRobustHighEnergy") value = object->eidRobustHighEnergy;
2050     else if(variable == "eidRobustLoose") value = object->eidRobustLoose;
2051     else if(variable == "eidRobustTight") value = object->eidRobustTight;
2052     else if(variable == "eidLoose") value = object->eidLoose;
2053     else if(variable == "eidTight") value = object->eidTight;
2054     else if(variable == "eidVeryLooseMC") value = object->eidVeryLooseMC;
2055     else if(variable == "eidLooseMC") value = object->eidLooseMC;
2056     else if(variable == "eidMediumMC") value = object->eidMediumMC;
2057     else if(variable == "eidTightMC") value = object->eidTightMC;
2058     else if(variable == "eidSuperTightMC") value = object->eidSuperTightMC;
2059     else if(variable == "eidHyperTight1MC") value = object->eidHyperTight1MC;
2060     else if(variable == "eidHyperTight2MC") value = object->eidHyperTight2MC;
2061     else if(variable == "eidHyperTight3MC") value = object->eidHyperTight3MC;
2062     else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC;
2063     else if(variable == "passConvVeto") value = object->passConvVeto;
2064    
2065 lantonel 1.9 //user-defined variables
2066 ahart 1.31 else if(variable == "correctedD0VertexErr") value = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2067     else if(variable == "correctedD0VertexSig") value = object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2068 lantonel 1.13 else if(variable == "detIso") value = (object->trackIso) / object->pt;
2069 lantonel 1.10 else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2070 ahart 1.31 else if(variable == "metMT") {
2071 ahart 1.63 if (const BNmet *met = chosenMET ())
2072 ahart 1.31 {
2073 ahart 1.61 double dPhi = deltaPhi (object->phi, met->phi);
2074     value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
2075 ahart 1.31 }
2076     else
2077     value = -999;
2078     }
2079 lantonel 1.26
2080     else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
2081     if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
2082     else value = -999;
2083     }
2084     else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
2085     if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
2086 lantonel 1.19 else value = -999;
2087     }
2088 lantonel 1.26
2089     else if(variable == "correctedD0VertexInEBPlus"){
2090     if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
2091     else value = -999;
2092     }
2093     else if(variable == "correctedD0VertexOutEBPlus"){
2094     if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
2095     else value = -999;
2096     }
2097     else if(variable == "correctedD0VertexEEPlus"){
2098     if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
2099     else value = -999;
2100     }
2101    
2102     else if(variable == "correctedD0BeamspotInEBPlus"){
2103     if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
2104     else value = -999;
2105     }
2106     else if(variable == "correctedD0BeamspotOutEBPlus"){
2107     if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
2108 lantonel 1.19 else value = -999;
2109     }
2110 lantonel 1.26 else if(variable == "correctedD0BeamspotEEPlus"){
2111     if(object->isEE && object->eta > 0) value = object->correctedD0;
2112 lantonel 1.19 else value = -999;
2113     }
2114    
2115 lantonel 1.26 else if(variable == "correctedD0VertexInEBMinus"){
2116     if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
2117 lantonel 1.19 else value = -999;
2118     }
2119 lantonel 1.26 else if(variable == "correctedD0VertexOutEBMinus"){
2120     if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
2121 lantonel 1.19 else value = -999;
2122     }
2123 lantonel 1.26 else if(variable == "correctedD0VertexEEMinus"){
2124     if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
2125 lantonel 1.19 else value = -999;
2126     }
2127 lantonel 1.9
2128 lantonel 1.26 else if(variable == "correctedD0BeamspotInEBMinus"){
2129     if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
2130 lantonel 1.19 else value = -999;
2131     }
2132 lantonel 1.26 else if(variable == "correctedD0BeamspotOutEBMinus"){
2133     if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
2134 lantonel 1.19 else value = -999;
2135     }
2136 lantonel 1.26 else if(variable == "correctedD0BeamspotEEMinus"){
2137     if(object->isEE && object->eta < 0) value = object->correctedD0;
2138 lantonel 1.19 else value = -999;
2139     }
2140    
2141 ahart 1.31 else if(variable == "tightID"){
2142     if (object->isEB)
2143     {
2144     value = fabs(object->delEtaIn) < 0.004 \
2145     && fabs (object->delPhiIn) < 0.03 \
2146     && object->scSigmaIEtaIEta < 0.01 \
2147     && object->hadOverEm < 0.12 \
2148     && fabs (object->correctedD0Vertex) < 0.02 \
2149     && fabs (object->correctedDZ) < 0.1 \
2150     && object->absInvEMinusInvPin < 0.05 \
2151     && object->passConvVeto;
2152     }
2153     else
2154     {
2155     value = fabs(object->delEtaIn) < 0.005 \
2156     && fabs (object->delPhiIn) < 0.02 \
2157     && object->scSigmaIEtaIEta < 0.03 \
2158     && object->hadOverEm < 0.10 \
2159     && fabs (object->correctedD0Vertex) < 0.02 \
2160     && fabs (object->correctedDZ) < 0.1 \
2161     && object->absInvEMinusInvPin < 0.05 \
2162     && object->passConvVeto;
2163     }
2164     }
2165 lantonel 1.26
2166 jbrinson 1.88 else if(variable == "looseID"){
2167     value = object->pt > 10
2168     && object->mvaNonTrigV0 > 0;
2169     }
2170 lantonel 1.26 else if(variable == "correctedD0VertexInEBPositiveCharge"){
2171     if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2172     else value = -999;
2173     }
2174     else if(variable == "correctedD0VertexOutEBPositiveCharge"){
2175     if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
2176     else value = -999;
2177     }
2178     else if(variable == "correctedD0VertexEEPositiveCharge"){
2179     if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
2180     else value = -999;
2181     }
2182    
2183     else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
2184     if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
2185     else value = -999;
2186     }
2187     else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
2188     if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
2189     else value = -999;
2190     }
2191     else if(variable == "correctedD0BeamspotEEPositiveCharge"){
2192     if(object->isEE && object->charge > 0) value = object->correctedD0;
2193     else value = -999;
2194     }
2195    
2196     else if(variable == "correctedD0VertexInEBNegativeCharge"){
2197     if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
2198     else value = -999;
2199     }
2200     else if(variable == "correctedD0VertexOutEBNegativeCharge"){
2201     if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
2202     else value = -999;
2203     }
2204     else if(variable == "correctedD0VertexEENegativeCharge"){
2205     if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
2206     else value = -999;
2207     }
2208    
2209     else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
2210     if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
2211     else value = -999;
2212     }
2213     else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
2214     if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
2215     else value = -999;
2216     }
2217     else if(variable == "correctedD0BeamspotEENegativeCharge"){
2218     if(object->isEE && object->charge < 0) value = object->correctedD0;
2219     else value = -999;
2220     }
2221    
2222    
2223 lantonel 1.19 else if(variable == "tightIDdisplaced"){
2224     if (object->isEB)
2225     {
2226 ahart 1.31 value = fabs(object->delEtaIn) < 0.004 \
2227     && fabs (object->delPhiIn) < 0.03 \
2228 lantonel 1.19 && object->scSigmaIEtaIEta < 0.01 \
2229     && object->hadOverEm < 0.12 \
2230 ahart 1.31 && object->absInvEMinusInvPin < 0.05;
2231 lantonel 1.19 }
2232     else
2233     {
2234 ahart 1.31 value = fabs (object->delEtaIn) < 0.005 \
2235     && fabs (object->delPhiIn) < 0.02 \
2236 lantonel 1.19 && object->scSigmaIEtaIEta < 0.03 \
2237     && object->hadOverEm < 0.10 \
2238 ahart 1.31 && object->absInvEMinusInvPin < 0.05;
2239 lantonel 1.19 }
2240     }
2241 lantonel 1.1
2242 lantonel 1.36
2243 ahart 1.57 else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2244 lantonel 1.36
2245     else if(variable == "genMatchedPdgId"){
2246     int index = getGenMatchedParticleIndex(object);
2247     if(index == -1) value = 0;
2248     else value = mcparticles->at(index).id;
2249     }
2250    
2251    
2252 lantonel 1.22 else if(variable == "genMatchedId"){
2253     int index = getGenMatchedParticleIndex(object);
2254     if(index == -1) value = 0;
2255     else value = getPdgIdBinValue(mcparticles->at(index).id);
2256     }
2257     else if(variable == "genMatchedMotherId"){
2258     int index = getGenMatchedParticleIndex(object);
2259     if(index == -1) value = 0;
2260     else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2261     }
2262 lantonel 1.36 else if(variable == "genMatchedMotherIdReverse"){
2263     int index = getGenMatchedParticleIndex(object);
2264 jbrinson 1.62 if(index == -1) value = 24;
2265     else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2266 lantonel 1.36 }
2267 lantonel 1.22 else if(variable == "genMatchedGrandmotherId"){
2268     int index = getGenMatchedParticleIndex(object);
2269     if(index == -1) value = 0;
2270     else if(fabs(mcparticles->at(index).motherId) == 15){
2271     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2272     if(motherIndex == -1) value = 0;
2273     else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2274     }
2275     else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2276     }
2277 lantonel 1.50 else if(variable == "genMatchedGrandmotherIdReverse"){
2278     int index = getGenMatchedParticleIndex(object);
2279 jbrinson 1.62 if(index == -1) value = 24;
2280 lantonel 1.50 else if(fabs(mcparticles->at(index).motherId) == 15){
2281     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2282 jbrinson 1.62 if(motherIndex == -1) value = 24;
2283     else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2284 lantonel 1.50 }
2285 jbrinson 1.62 else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2286 lantonel 1.50 }
2287 ahart 1.64 else if(variable == "pfElectronsFromVertex"){
2288     double d0Error, dzError;
2289    
2290     d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2291     dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2292     value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2293 wulsin 1.74 || fabs (object->correctedD0Vertex / d0Error) > 99.0
2294     || fabs (object->correctedDZ / dzError) > 99.0;
2295 ahart 1.64 value = !value;
2296     }
2297 lantonel 1.22
2298    
2299    
2300 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2301 ahart 1.8
2302 lantonel 1.6 value = applyFunction(function, value);
2303 lantonel 1.1
2304     return value;
2305 wulsin 1.90 } // end electron valueLookup
2306    
2307 lantonel 1.1
2308 lantonel 1.51 //!event valueLookup
2309 lantonel 1.1 double
2310 ahart 1.57 OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
2311 lantonel 1.1
2312     double value = 0.0;
2313    
2314     if(variable == "weight") value = object->weight;
2315     else if(variable == "pthat") value = object->pthat;
2316     else if(variable == "qScale") value = object->qScale;
2317     else if(variable == "alphaQCD") value = object->alphaQCD;
2318     else if(variable == "alphaQED") value = object->alphaQED;
2319     else if(variable == "scalePDF") value = object->scalePDF;
2320     else if(variable == "x1") value = object->x1;
2321     else if(variable == "x2") value = object->x2;
2322     else if(variable == "xPDF1") value = object->xPDF1;
2323     else if(variable == "xPDF2") value = object->xPDF2;
2324     else if(variable == "BSx") value = object->BSx;
2325     else if(variable == "BSy") value = object->BSy;
2326     else if(variable == "BSz") value = object->BSz;
2327     else if(variable == "PVx") value = object->PVx;
2328     else if(variable == "PVy") value = object->PVy;
2329     else if(variable == "PVz") value = object->PVz;
2330     else if(variable == "bField") value = object->bField;
2331     else if(variable == "instLumi") value = object->instLumi;
2332     else if(variable == "bxLumi") value = object->bxLumi;
2333     else if(variable == "FilterOutScrapingFraction") value = object->FilterOutScrapingFraction;
2334     else if(variable == "sumNVtx") value = object->sumNVtx;
2335     else if(variable == "sumTrueNVtx") value = object->sumTrueNVtx;
2336     else if(variable == "nm1_true") value = object->nm1_true;
2337     else if(variable == "n0_true") value = object->n0_true;
2338     else if(variable == "np1_true") value = object->np1_true;
2339     else if(variable == "numTruePV") value = object->numTruePV;
2340     else if(variable == "Q2ScaleUpWgt") value = object->Q2ScaleUpWgt;
2341     else if(variable == "Q2ScaleDownWgt") value = object->Q2ScaleDownWgt;
2342     else if(variable == "rho_kt6PFJets") value = object->rho_kt6PFJets;
2343     else if(variable == "rho_kt6PFJetsCentralChargedPileUp") value = object->rho_kt6PFJetsCentralChargedPileUp;
2344     else if(variable == "rho_kt6PFJetsCentralNeutral") value = object->rho_kt6PFJetsCentralNeutral;
2345     else if(variable == "rho_kt6PFJetsCentralNeutralTight") value = object->rho_kt6PFJetsCentralNeutralTight;
2346     else if(variable == "run") value = object->run;
2347     else if(variable == "lumi") value = object->lumi;
2348     else if(variable == "sample") value = object->sample;
2349     else if(variable == "numPV") value = object->numPV;
2350     else if(variable == "W0decay") value = object->W0decay;
2351     else if(variable == "W1decay") value = object->W1decay;
2352     else if(variable == "Z0decay") value = object->Z0decay;
2353     else if(variable == "Z1decay") value = object->Z1decay;
2354     else if(variable == "H0decay") value = object->H0decay;
2355     else if(variable == "H1decay") value = object->H1decay;
2356     else if(variable == "hcalnoiseLoose") value = object->hcalnoiseLoose;
2357     else if(variable == "hcalnoiseTight") value = object->hcalnoiseTight;
2358     else if(variable == "GoodVertex") value = object->GoodVertex;
2359     else if(variable == "FilterOutScraping") value = object->FilterOutScraping;
2360     else if(variable == "HBHENoiseFilter") value = object->HBHENoiseFilter;
2361     else if(variable == "CSCLooseHaloId") value = object->CSCLooseHaloId;
2362     else if(variable == "CSCTightHaloId") value = object->CSCTightHaloId;
2363     else if(variable == "EcalLooseHaloId") value = object->EcalLooseHaloId;
2364     else if(variable == "EcalTightHaloId") value = object->EcalTightHaloId;
2365     else if(variable == "HcalLooseHaloId") value = object->HcalLooseHaloId;
2366     else if(variable == "HcalTightHaloId") value = object->HcalTightHaloId;
2367     else if(variable == "GlobalLooseHaloId") value = object->GlobalLooseHaloId;
2368     else if(variable == "GlobalTightHaloId") value = object->GlobalTightHaloId;
2369     else if(variable == "LooseId") value = object->LooseId;
2370     else if(variable == "TightId") value = object->TightId;
2371     else if(variable == "numGenPV") value = object->numGenPV;
2372     else if(variable == "nm1") value = object->nm1;
2373     else if(variable == "n0") value = object->n0;
2374     else if(variable == "np1") value = object->np1;
2375     else if(variable == "id1") value = object->id1;
2376     else if(variable == "id2") value = object->id2;
2377     else if(variable == "evt") value = object->evt;
2378 ahart 1.31 else if(variable == "puScaleFactor"){
2379 ahart 1.68 if(doPileupReweighting_ && datasetType_ != "data")
2380 ahart 1.31 value = puWeight_->at (events->at (0).numTruePV);
2381     else
2382     value = 1.0;
2383     }
2384 ahart 1.63 else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2385     else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2386     else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2387 biliu 1.83 else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2388 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2389 ahart 1.8
2390 lantonel 1.6 value = applyFunction(function, value);
2391 lantonel 1.1
2392     return value;
2393 wulsin 1.90 } // end event valueLookup
2394    
2395 lantonel 1.1
2396 lantonel 1.51 //!tau valueLookup
2397 lantonel 1.1 double
2398 ahart 1.57 OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2399 lantonel 1.1
2400     double value = 0.0;
2401    
2402     if(variable == "px") value = object->px;
2403     else if(variable == "py") value = object->py;
2404     else if(variable == "pz") value = object->pz;
2405     else if(variable == "energy") value = object->energy;
2406     else if(variable == "et") value = object->et;
2407     else if(variable == "pt") value = object->pt;
2408     else if(variable == "eta") value = object->eta;
2409     else if(variable == "phi") value = object->phi;
2410     else if(variable == "emFraction") value = object->emFraction;
2411     else if(variable == "leadingTrackPt") value = object->leadingTrackPt;
2412     else if(variable == "leadingTrackIpVtdxy") value = object->leadingTrackIpVtdxy;
2413     else if(variable == "leadingTrackIpVtdz") value = object->leadingTrackIpVtdz;
2414     else if(variable == "leadingTrackIpVtdxyError") value = object->leadingTrackIpVtdxyError;
2415     else if(variable == "leadingTrackIpVtdzError") value = object->leadingTrackIpVtdzError;
2416     else if(variable == "leadingTrackVx") value = object->leadingTrackVx;
2417     else if(variable == "leadingTrackVy") value = object->leadingTrackVy;
2418     else if(variable == "leadingTrackVz") value = object->leadingTrackVz;
2419     else if(variable == "leadingTrackValidHits") value = object->leadingTrackValidHits;
2420     else if(variable == "leadingTrackNormChiSqrd") value = object->leadingTrackNormChiSqrd;
2421     else if(variable == "numProngs") value = object->numProngs;
2422     else if(variable == "numSignalGammas") value = object->numSignalGammas;
2423     else if(variable == "numSignalNeutrals") value = object->numSignalNeutrals;
2424     else if(variable == "numSignalPiZeros") value = object->numSignalPiZeros;
2425     else if(variable == "decayMode") value = object->decayMode;
2426     else if(variable == "charge") value = object->charge;
2427     else if(variable == "inTheCracks") value = object->inTheCracks;
2428     else if(variable == "HPSagainstElectronLoose") value = object->HPSagainstElectronLoose;
2429     else if(variable == "HPSagainstElectronMVA") value = object->HPSagainstElectronMVA;
2430     else if(variable == "HPSagainstElectronMedium") value = object->HPSagainstElectronMedium;
2431     else if(variable == "HPSagainstElectronTight") value = object->HPSagainstElectronTight;
2432     else if(variable == "HPSagainstMuonLoose") value = object->HPSagainstMuonLoose;
2433     else if(variable == "HPSagainstMuonMedium") value = object->HPSagainstMuonMedium;
2434     else if(variable == "HPSagainstMuonTight") value = object->HPSagainstMuonTight;
2435     else if(variable == "HPSbyLooseCombinedIsolationDeltaBetaCorr") value = object->HPSbyLooseCombinedIsolationDeltaBetaCorr;
2436     else if(variable == "HPSbyMediumCombinedIsolationDeltaBetaCorr") value = object->HPSbyMediumCombinedIsolationDeltaBetaCorr;
2437     else if(variable == "HPSbyTightCombinedIsolationDeltaBetaCorr") value = object->HPSbyTightCombinedIsolationDeltaBetaCorr;
2438     else if(variable == "HPSbyVLooseCombinedIsolationDeltaBetaCorr") value = object->HPSbyVLooseCombinedIsolationDeltaBetaCorr;
2439     else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
2440     else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
2441    
2442 jbrinson 1.88 else if (variable == "looseHadronicID") {
2443     value = object->pt > 10
2444     && object->eta < 2.3
2445     && object->HPSbyLooseCombinedIsolationDeltaBetaCorr > 0
2446     && object->HPSdecayModeFinding > 0
2447     && object->HPSagainstElectronLoose > 0
2448     && object->HPSagainstMuonTight > 0;
2449     }
2450 lantonel 1.36
2451 ahart 1.57 else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2452 lantonel 1.36
2453     else if(variable == "genMatchedPdgId"){
2454     int index = getGenMatchedParticleIndex(object);
2455     if(index == -1) value = 0;
2456     else value = mcparticles->at(index).id;
2457     }
2458    
2459 lantonel 1.22 else if(variable == "genMatchedId"){
2460     int index = getGenMatchedParticleIndex(object);
2461     if(index == -1) value = 0;
2462     else value = getPdgIdBinValue(mcparticles->at(index).id);
2463     }
2464     else if(variable == "genMatchedMotherId"){
2465     int index = getGenMatchedParticleIndex(object);
2466     if(index == -1) value = 0;
2467     else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2468     }
2469 lantonel 1.36 else if(variable == "genMatchedMotherIdReverse"){
2470     int index = getGenMatchedParticleIndex(object);
2471 jbrinson 1.62 if(index == -1) value = 24;
2472     else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2473 lantonel 1.36 }
2474 lantonel 1.22 else if(variable == "genMatchedGrandmotherId"){
2475     int index = getGenMatchedParticleIndex(object);
2476     if(index == -1) value = 0;
2477     else if(fabs(mcparticles->at(index).motherId) == 15){
2478     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2479     if(motherIndex == -1) value = 0;
2480     else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2481     }
2482     else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2483     }
2484 lantonel 1.50 else if(variable == "genMatchedGrandmotherIdReverse"){
2485     int index = getGenMatchedParticleIndex(object);
2486 jbrinson 1.62 if(index == -1) value = 24;
2487 lantonel 1.50 else if(fabs(mcparticles->at(index).motherId) == 15){
2488     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2489 jbrinson 1.62 if(motherIndex == -1) value = 24;
2490     else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2491 lantonel 1.50 }
2492 jbrinson 1.62 else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2493 lantonel 1.50 }
2494 lantonel 1.22
2495    
2496 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2497 ahart 1.8
2498 lantonel 1.6 value = applyFunction(function, value);
2499 lantonel 1.1
2500     return value;
2501 wulsin 1.90 } // end tau valueLookup
2502    
2503 lantonel 1.1
2504 lantonel 1.51 //!met valueLookup
2505 lantonel 1.1 double
2506 ahart 1.57 OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2507 lantonel 1.1
2508     double value = 0.0;
2509    
2510     if(variable == "et") value = object->et;
2511     else if(variable == "pt") value = object->pt;
2512     else if(variable == "px") value = object->px;
2513     else if(variable == "py") value = object->py;
2514     else if(variable == "phi") value = object->phi;
2515     else if(variable == "Upt") value = object->Upt;
2516     else if(variable == "Uphi") value = object->Uphi;
2517     else if(variable == "NeutralEMFraction") value = object->NeutralEMFraction;
2518     else if(variable == "NeutralHadEtFraction") value = object->NeutralHadEtFraction;
2519     else if(variable == "ChargedEMEtFraction") value = object->ChargedEMEtFraction;
2520     else if(variable == "ChargedHadEtFraction") value = object->ChargedHadEtFraction;
2521     else if(variable == "MuonEtFraction") value = object->MuonEtFraction;
2522     else if(variable == "Type6EtFraction") value = object->Type6EtFraction;
2523     else if(variable == "Type7EtFraction") value = object->Type7EtFraction;
2524     else if(variable == "genPT") value = object->genPT;
2525     else if(variable == "genPhi") value = object->genPhi;
2526     else if(variable == "muonCorEx") value = object->muonCorEx;
2527     else if(variable == "muonCorEy") value = object->muonCorEy;
2528     else if(variable == "jet20CorEx") value = object->jet20CorEx;
2529     else if(variable == "jet20CorEy") value = object->jet20CorEy;
2530     else if(variable == "jet1CorEx") value = object->jet1CorEx;
2531     else if(variable == "jet1CorEy") value = object->jet1CorEy;
2532     else if(variable == "sumET") value = object->sumET;
2533     else if(variable == "corSumET") value = object->corSumET;
2534     else if(variable == "mEtSig") value = object->mEtSig;
2535     else if(variable == "metSignificance") value = object->metSignificance;
2536     else if(variable == "significance") value = object->significance;
2537     else if(variable == "sigmaX2") value = object->sigmaX2;
2538     else if(variable == "sigmaY2") value = object->sigmaY2;
2539     else if(variable == "sigmaXY") value = object->sigmaXY;
2540     else if(variable == "sigmaYX") value = object->sigmaYX;
2541     else if(variable == "maxEtInEmTowers") value = object->maxEtInEmTowers;
2542     else if(variable == "emEtFraction") value = object->emEtFraction;
2543     else if(variable == "emEtInEB") value = object->emEtInEB;
2544     else if(variable == "emEtInEE") value = object->emEtInEE;
2545     else if(variable == "emEtInHF") value = object->emEtInHF;
2546     else if(variable == "maxEtInHadTowers") value = object->maxEtInHadTowers;
2547     else if(variable == "hadEtFraction") value = object->hadEtFraction;
2548     else if(variable == "hadEtInHB") value = object->hadEtInHB;
2549     else if(variable == "hadEtInHE") value = object->hadEtInHE;
2550     else if(variable == "hadEtInHF") value = object->hadEtInHF;
2551     else if(variable == "hadEtInHO") value = object->hadEtInHO;
2552     else if(variable == "UDeltaPx") value = object->UDeltaPx;
2553     else if(variable == "UDeltaPy") value = object->UDeltaPy;
2554     else if(variable == "UDeltaP") value = object->UDeltaP;
2555     else if(variable == "Uscale") value = object->Uscale;
2556     else if(variable == "type2corPx") value = object->type2corPx;
2557     else if(variable == "type2corPy") value = object->type2corPy;
2558     else if(variable == "T2pt") value = object->T2pt;
2559     else if(variable == "T2px") value = object->T2px;
2560     else if(variable == "T2py") value = object->T2py;
2561     else if(variable == "T2phi") value = object->T2phi;
2562     else if(variable == "T2sumET") value = object->T2sumET;
2563     else if(variable == "pfT1jet1pt") value = object->pfT1jet1pt;
2564     else if(variable == "pfT1jet1phi") value = object->pfT1jet1phi;
2565     else if(variable == "pfT1jet6pt") value = object->pfT1jet6pt;
2566     else if(variable == "pfT1jet6phi") value = object->pfT1jet6phi;
2567     else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2568     else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2569    
2570 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2571 ahart 1.8
2572 lantonel 1.6 value = applyFunction(function, value);
2573 lantonel 1.1
2574     return value;
2575 wulsin 1.90 } // end met valueLookup
2576    
2577 lantonel 1.1
2578 lantonel 1.51 //!track valueLookup
2579 lantonel 1.1 double
2580 ahart 1.57 OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2581 lantonel 1.1
2582     double value = 0.0;
2583 jbrinson 1.25 double pMag = sqrt(object->pt * object->pt +
2584 ahart 1.57 object->pz * object->pz);
2585    
2586 lantonel 1.1 if(variable == "pt") value = object->pt;
2587     else if(variable == "px") value = object->px;
2588     else if(variable == "py") value = object->py;
2589     else if(variable == "pz") value = object->pz;
2590     else if(variable == "phi") value = object->phi;
2591     else if(variable == "eta") value = object->eta;
2592     else if(variable == "theta") value = object->theta;
2593     else if(variable == "normChi2") value = object->normChi2;
2594     else if(variable == "dZ") value = object->dZ;
2595     else if(variable == "d0") value = object->d0;
2596     else if(variable == "d0err") value = object->d0err;
2597     else if(variable == "vx") value = object->vx;
2598     else if(variable == "vy") value = object->vy;
2599     else if(variable == "vz") value = object->vz;
2600     else if(variable == "charge") value = object->charge;
2601     else if(variable == "numValidHits") value = object->numValidHits;
2602     else if(variable == "isHighPurity") value = object->isHighPurity;
2603 qpython 1.27
2604 ahart 1.31 //additional BNs info for disappTrks
2605 wulsin 1.92 else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2606     else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2607     else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2608     else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2609     else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2610     else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2611     else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2612     else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2613 jbrinson 1.25 else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2614 wulsin 1.92 else if(variable == "depTrkRp3") value = object->depTrkRp3;
2615     else if(variable == "depEcalRp3") value = object->depEcalRp3;
2616     else if(variable == "depHcalRp3") value = object->depHcalRp3;
2617     else if(variable == "depHoRp3") value = object->depHoRp3;
2618     else if(variable == "nTracksRp3") value = object->nTracksRp3;
2619     else if(variable == "trackerVetoPtRp3") value = object->trackerVetoPtRp3;
2620     else if(variable == "emVetoEtRp3") value = object->emVetoEtRp3;
2621     else if(variable == "hadVetoEtRp3") value = object->hadVetoEtRp3;
2622     else if(variable == "hoVetoEtRp3") value = object->hoVetoEtRp3;
2623     else if(variable == "depTrkRp5") value = object->depTrkRp5;
2624     else if(variable == "depEcalRp5") value = object->depEcalRp5;
2625     else if(variable == "depHcalRp5") value = object->depHcalRp5;
2626     else if(variable == "depHoRp5") value = object->depHoRp5;
2627     else if(variable == "nTracksRp5") value = object->nTracksRp5;
2628     else if(variable == "trackerVetoPtRp5") value = object->trackerVetoPtRp5;
2629     else if(variable == "emVetoEtRp5") value = object->emVetoEtRp5;
2630     else if(variable == "hadVetoEtRp5") value = object->hadVetoEtRp5;
2631     else if(variable == "hoVetoEtRp5") value = object->hoVetoEtRp5;
2632 qpython 1.32
2633 jbrinson 1.25 //user defined variables
2634     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;
2635     else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2636 jbrinson 1.60 else if(variable == "depTrkRp5MinusPt") value = (object->depTrkRp5 - object->pt);
2637 wulsin 1.42 else if(variable == "caloTotDeltaRp5") value = (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2638     else if(variable == "caloTotDeltaRp5ByP") value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2639 ahart 1.57 else if(variable == "caloTotDeltaRp5RhoCorr") value = getTrkCaloTotRhoCorr(object);
2640     else if(variable == "caloTotDeltaRp5ByPRhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;
2641 wulsin 1.42 else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
2642     else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
2643     else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
2644     else if(variable == "ptError") value = object->ptError;
2645     else if(variable == "ptRes") value = getTrkPtRes(object);
2646 ahart 1.57 else if (variable == "d0wrtPV"){
2647     double vx = object->vx - chosenVertex ()->x,
2648     vy = object->vy - chosenVertex ()->y,
2649     px = object->px,
2650     py = object->py,
2651     pt = object->pt;
2652     value = (-vx * py + vy * px) / pt;
2653     }
2654     else if (variable == "dZwrtPV"){
2655     double vx = object->vx - chosenVertex ()->x,
2656     vy = object->vy - chosenVertex ()->y,
2657     vz = object->vz - chosenVertex ()->z,
2658     px = object->px,
2659     py = object->py,
2660     pz = object->pz,
2661     pt = object->pt;
2662     value = vz - (vx * px + vy * py)/pt * (pz/pt);
2663     }
2664 jbrinson 1.88
2665    
2666 ahart 1.57 else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2667 jbrinson 1.33
2668 lantonel 1.36 else if(variable == "genMatchedPdgId"){
2669 jbrinson 1.33 int index = getGenMatchedParticleIndex(object);
2670     if(index == -1) value = 0;
2671     else value = mcparticles->at(index).id;
2672     }
2673    
2674 biliu 1.40
2675 lantonel 1.22 else if(variable == "genMatchedId"){
2676     int index = getGenMatchedParticleIndex(object);
2677     if(index == -1) value = 0;
2678     else value = getPdgIdBinValue(mcparticles->at(index).id);
2679     }
2680     else if(variable == "genMatchedMotherId"){
2681     int index = getGenMatchedParticleIndex(object);
2682     if(index == -1) value = 0;
2683     else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2684     }
2685 lantonel 1.36 else if(variable == "genMatchedMotherIdReverse"){
2686     int index = getGenMatchedParticleIndex(object);
2687 jbrinson 1.62 if(index == -1) value = 24;
2688     else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2689 lantonel 1.36 }
2690 lantonel 1.22 else if(variable == "genMatchedGrandmotherId"){
2691     int index = getGenMatchedParticleIndex(object);
2692     if(index == -1) value = 0;
2693     else if(fabs(mcparticles->at(index).motherId) == 15){
2694     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2695     if(motherIndex == -1) value = 0;
2696     else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2697     }
2698     else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2699     }
2700 lantonel 1.50 else if(variable == "genMatchedGrandmotherIdReverse"){
2701     int index = getGenMatchedParticleIndex(object);
2702 jbrinson 1.62 if(index == -1) value = 24;
2703 lantonel 1.50 else if(fabs(mcparticles->at(index).motherId) == 15){
2704     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2705 jbrinson 1.62 if(motherIndex == -1) value = 24;
2706     else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2707 lantonel 1.50 }
2708 jbrinson 1.62 else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2709 lantonel 1.50 }
2710 lantonel 1.22
2711    
2712    
2713 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2714 ahart 1.8
2715 lantonel 1.6 value = applyFunction(function, value);
2716 lantonel 1.1
2717     return value;
2718 wulsin 1.90 } // end track valueLookup
2719    
2720 lantonel 1.1
2721 lantonel 1.51 //!genjet valueLookup
2722 lantonel 1.1 double
2723 ahart 1.57 OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2724 lantonel 1.1
2725     double value = 0.0;
2726    
2727     if(variable == "pt") value = object->pt;
2728     else if(variable == "eta") value = object->eta;
2729     else if(variable == "phi") value = object->phi;
2730     else if(variable == "px") value = object->px;
2731     else if(variable == "py") value = object->py;
2732     else if(variable == "pz") value = object->pz;
2733     else if(variable == "et") value = object->et;
2734     else if(variable == "energy") value = object->energy;
2735     else if(variable == "mass") value = object->mass;
2736     else if(variable == "emEnergy") value = object->emEnergy;
2737     else if(variable == "hadEnergy") value = object->hadEnergy;
2738     else if(variable == "invisibleEnergy") value = object->invisibleEnergy;
2739     else if(variable == "auxiliaryEnergy") value = object->auxiliaryEnergy;
2740     else if(variable == "charge") value = object->charge;
2741    
2742    
2743 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2744 ahart 1.8
2745 lantonel 1.6 value = applyFunction(function, value);
2746 lantonel 1.1
2747     return value;
2748     }
2749    
2750 lantonel 1.51 //!mcparticle valueLookup
2751 lantonel 1.1 double
2752 ahart 1.57 OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2753 lantonel 1.1
2754     double value = 0.0;
2755    
2756     if(variable == "energy") value = object->energy;
2757     else if(variable == "et") value = object->et;
2758     else if(variable == "pt") value = object->pt;
2759     else if(variable == "px") value = object->px;
2760     else if(variable == "py") value = object->py;
2761     else if(variable == "pz") value = object->pz;
2762     else if(variable == "phi") value = object->phi;
2763     else if(variable == "eta") value = object->eta;
2764     else if(variable == "theta") value = object->theta;
2765     else if(variable == "mass") value = object->mass;
2766     else if(variable == "vx") value = object->vx;
2767     else if(variable == "vy") value = object->vy;
2768     else if(variable == "vz") value = object->vz;
2769     else if(variable == "motherET") value = object->motherET;
2770     else if(variable == "motherPT") value = object->motherPT;
2771     else if(variable == "motherPhi") value = object->motherPhi;
2772     else if(variable == "motherEta") value = object->motherEta;
2773     else if(variable == "mother0ET") value = object->mother0ET;
2774     else if(variable == "mother0PT") value = object->mother0PT;
2775     else if(variable == "mother0Phi") value = object->mother0Phi;
2776     else if(variable == "mother0Eta") value = object->mother0Eta;
2777     else if(variable == "mother1ET") value = object->mother1ET;
2778     else if(variable == "mother1PT") value = object->mother1PT;
2779     else if(variable == "mother1Phi") value = object->mother1Phi;
2780     else if(variable == "mother1Eta") value = object->mother1Eta;
2781     else if(variable == "daughter0ET") value = object->daughter0ET;
2782     else if(variable == "daughter0PT") value = object->daughter0PT;
2783     else if(variable == "daughter0Phi") value = object->daughter0Phi;
2784     else if(variable == "daughter0Eta") value = object->daughter0Eta;
2785     else if(variable == "daughter1ET") value = object->daughter1ET;
2786     else if(variable == "daughter1PT") value = object->daughter1PT;
2787     else if(variable == "daughter1Phi") value = object->daughter1Phi;
2788     else if(variable == "daughter1Eta") value = object->daughter1Eta;
2789     else if(variable == "grandMotherET") value = object->grandMotherET;
2790     else if(variable == "grandMotherPT") value = object->grandMotherPT;
2791     else if(variable == "grandMotherPhi") value = object->grandMotherPhi;
2792     else if(variable == "grandMotherEta") value = object->grandMotherEta;
2793     else if(variable == "grandMother00ET") value = object->grandMother00ET;
2794     else if(variable == "grandMother00PT") value = object->grandMother00PT;
2795     else if(variable == "grandMother00Phi") value = object->grandMother00Phi;
2796     else if(variable == "grandMother00Eta") value = object->grandMother00Eta;
2797     else if(variable == "grandMother01ET") value = object->grandMother01ET;
2798     else if(variable == "grandMother01PT") value = object->grandMother01PT;
2799     else if(variable == "grandMother01Phi") value = object->grandMother01Phi;
2800     else if(variable == "grandMother01Eta") value = object->grandMother01Eta;
2801     else if(variable == "grandMother10ET") value = object->grandMother10ET;
2802     else if(variable == "grandMother10PT") value = object->grandMother10PT;
2803     else if(variable == "grandMother10Phi") value = object->grandMother10Phi;
2804     else if(variable == "grandMother10Eta") value = object->grandMother10Eta;
2805     else if(variable == "grandMother11ET") value = object->grandMother11ET;
2806     else if(variable == "grandMother11PT") value = object->grandMother11PT;
2807     else if(variable == "grandMother11Phi") value = object->grandMother11Phi;
2808     else if(variable == "grandMother11Eta") value = object->grandMother11Eta;
2809     else if(variable == "charge") value = object->charge;
2810     else if(variable == "id") value = object->id;
2811     else if(variable == "status") value = object->status;
2812     else if(variable == "motherId") value = object->motherId;
2813     else if(variable == "motherCharge") value = object->motherCharge;
2814     else if(variable == "mother0Id") value = object->mother0Id;
2815     else if(variable == "mother0Status") value = object->mother0Status;
2816     else if(variable == "mother0Charge") value = object->mother0Charge;
2817     else if(variable == "mother1Id") value = object->mother1Id;
2818     else if(variable == "mother1Status") value = object->mother1Status;
2819     else if(variable == "mother1Charge") value = object->mother1Charge;
2820     else if(variable == "daughter0Id") value = object->daughter0Id;
2821     else if(variable == "daughter0Status") value = object->daughter0Status;
2822     else if(variable == "daughter0Charge") value = object->daughter0Charge;
2823     else if(variable == "daughter1Id") value = object->daughter1Id;
2824     else if(variable == "daughter1Status") value = object->daughter1Status;
2825     else if(variable == "daughter1Charge") value = object->daughter1Charge;
2826     else if(variable == "grandMotherId") value = object->grandMotherId;
2827     else if(variable == "grandMotherCharge") value = object->grandMotherCharge;
2828     else if(variable == "grandMother00Id") value = object->grandMother00Id;
2829     else if(variable == "grandMother00Status") value = object->grandMother00Status;
2830     else if(variable == "grandMother00Charge") value = object->grandMother00Charge;
2831     else if(variable == "grandMother01Id") value = object->grandMother01Id;
2832     else if(variable == "grandMother01Status") value = object->grandMother01Status;
2833     else if(variable == "grandMother01Charge") value = object->grandMother01Charge;
2834     else if(variable == "grandMother10Id") value = object->grandMother10Id;
2835     else if(variable == "grandMother10Status") value = object->grandMother10Status;
2836     else if(variable == "grandMother10Charge") value = object->grandMother10Charge;
2837     else if(variable == "grandMother11Id") value = object->grandMother11Id;
2838     else if(variable == "grandMother11Status") value = object->grandMother11Status;
2839     else if(variable == "grandMother11Charge") value = object->grandMother11Charge;
2840    
2841 lantonel 1.9 //user-defined variables
2842     else if (variable == "d0"){
2843 ahart 1.31 double vx = object->vx - chosenVertex ()->x,
2844     vy = object->vy - chosenVertex ()->y,
2845 lantonel 1.9 px = object->px,
2846     py = object->py,
2847     pt = object->pt;
2848     value = (-vx * py + vy * px) / pt;
2849     }
2850     else if (variable == "dz"){
2851 ahart 1.31 double vx = object->vx - chosenVertex ()->x,
2852     vy = object->vy - chosenVertex ()->y,
2853     vz = object->vz - chosenVertex ()->z,
2854 lantonel 1.9 px = object->px,
2855     py = object->py,
2856     pz = object->pz,
2857     pt = object->pt;
2858     value = vz - (vx * px + vy * py)/pt * (pz/pt);
2859     }
2860 lantonel 1.19 else if(variable == "v0"){
2861     value = sqrt(object->vx*object->vx + object->vy*object->vy);
2862     }
2863     else if(variable == "deltaV0"){
2864 ahart 1.31 value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2865 lantonel 1.19 }
2866     else if (variable == "deltaVx"){
2867 ahart 1.31 value = object->vx - chosenVertex ()->x;
2868 lantonel 1.19 }
2869     else if (variable == "deltaVy"){
2870 ahart 1.31 value = object->vy - chosenVertex ()->y;
2871 lantonel 1.19 }
2872     else if (variable == "deltaVz"){
2873 ahart 1.31 value = object->vz - chosenVertex ()->z;
2874 lantonel 1.19 }
2875 lantonel 1.9
2876    
2877 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2878 ahart 1.8
2879 lantonel 1.6 value = applyFunction(function, value);
2880 lantonel 1.1
2881     return value;
2882 wulsin 1.90 } // end mcparticle valueLookup
2883    
2884 lantonel 1.1
2885 lantonel 1.51 //!primaryvertex valueLookup
2886 lantonel 1.1 double
2887 ahart 1.57 OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
2888 lantonel 1.1
2889     double value = 0.0;
2890    
2891     if(variable == "x") value = object->x;
2892     else if(variable == "xError") value = object->xError;
2893     else if(variable == "y") value = object->y;
2894     else if(variable == "yError") value = object->yError;
2895     else if(variable == "z") value = object->z;
2896     else if(variable == "zError") value = object->zError;
2897     else if(variable == "rho") value = object->rho;
2898     else if(variable == "normalizedChi2") value = object->normalizedChi2;
2899     else if(variable == "ndof") value = object->ndof;
2900     else if(variable == "isFake") value = object->isFake;
2901     else if(variable == "isValid") value = object->isValid;
2902     else if(variable == "tracksSize") value = object->tracksSize;
2903     else if(variable == "isGood") value = object->isGood;
2904    
2905    
2906 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2907 ahart 1.8
2908 lantonel 1.6 value = applyFunction(function, value);
2909 lantonel 1.1
2910     return value;
2911     }
2912    
2913 lantonel 1.51 //!bxlumi valueLookup
2914 lantonel 1.1 double
2915 ahart 1.57 OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
2916 lantonel 1.1
2917     double value = 0.0;
2918    
2919     if(variable == "bx_B1_now") value = object->bx_B1_now;
2920     else if(variable == "bx_B2_now") value = object->bx_B2_now;
2921     else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2922    
2923    
2924 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2925 ahart 1.8
2926 lantonel 1.6 value = applyFunction(function, value);
2927 lantonel 1.1
2928     return value;
2929     }
2930    
2931 lantonel 1.51 //!photon valueLookup
2932 lantonel 1.1 double
2933 ahart 1.57 OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
2934 lantonel 1.1
2935     double value = 0.0;
2936    
2937     if(variable == "energy") value = object->energy;
2938     else if(variable == "et") value = object->et;
2939     else if(variable == "pt") value = object->pt;
2940     else if(variable == "px") value = object->px;
2941     else if(variable == "py") value = object->py;
2942     else if(variable == "pz") value = object->pz;
2943     else if(variable == "phi") value = object->phi;
2944     else if(variable == "eta") value = object->eta;
2945     else if(variable == "theta") value = object->theta;
2946     else if(variable == "trackIso") value = object->trackIso;
2947     else if(variable == "ecalIso") value = object->ecalIso;
2948     else if(variable == "hcalIso") value = object->hcalIso;
2949     else if(variable == "caloIso") value = object->caloIso;
2950     else if(variable == "trackIsoHollowConeDR03") value = object->trackIsoHollowConeDR03;
2951     else if(variable == "trackIsoSolidConeDR03") value = object->trackIsoSolidConeDR03;
2952     else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
2953     else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
2954     else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
2955     else if(variable == "trackIsoHollowConeDR04") value = object->trackIsoHollowConeDR04;
2956     else if(variable == "trackIsoSolidConeDR04") value = object->trackIsoSolidConeDR04;
2957     else if(variable == "ecalIsoDR04") value = object->ecalIsoDR04;
2958     else if(variable == "hcalIsoDR04") value = object->hcalIsoDR04;
2959     else if(variable == "caloIsoDR04") value = object->caloIsoDR04;
2960     else if(variable == "hadOverEm") value = object->hadOverEm;
2961     else if(variable == "sigmaEtaEta") value = object->sigmaEtaEta;
2962     else if(variable == "sigmaIetaIeta") value = object->sigmaIetaIeta;
2963     else if(variable == "r9") value = object->r9;
2964     else if(variable == "scEnergy") value = object->scEnergy;
2965     else if(variable == "scRawEnergy") value = object->scRawEnergy;
2966     else if(variable == "scSeedEnergy") value = object->scSeedEnergy;
2967     else if(variable == "scEta") value = object->scEta;
2968     else if(variable == "scPhi") value = object->scPhi;
2969     else if(variable == "scZ") value = object->scZ;
2970     else if(variable == "genET") value = object->genET;
2971     else if(variable == "genPT") value = object->genPT;
2972     else if(variable == "genPhi") value = object->genPhi;
2973     else if(variable == "genEta") value = object->genEta;
2974     else if(variable == "genMotherET") value = object->genMotherET;
2975     else if(variable == "genMotherPT") value = object->genMotherPT;
2976     else if(variable == "genMotherPhi") value = object->genMotherPhi;
2977     else if(variable == "genMotherEta") value = object->genMotherEta;
2978     else if(variable == "eMax") value = object->eMax;
2979     else if(variable == "eLeft") value = object->eLeft;
2980     else if(variable == "eRight") value = object->eRight;
2981     else if(variable == "eTop") value = object->eTop;
2982     else if(variable == "eBottom") value = object->eBottom;
2983     else if(variable == "e3x3") value = object->e3x3;
2984     else if(variable == "swissCross") value = object->swissCross;
2985     else if(variable == "seedEnergy") value = object->seedEnergy;
2986     else if(variable == "seedTime") value = object->seedTime;
2987     else if(variable == "swissCrossNoI85") value = object->swissCrossNoI85;
2988     else if(variable == "swissCrossI85") value = object->swissCrossI85;
2989     else if(variable == "E2overE9NoI85") value = object->E2overE9NoI85;
2990     else if(variable == "E2overE9I85") value = object->E2overE9I85;
2991     else if(variable == "IDTight") value = object->IDTight;
2992     else if(variable == "IDLoose") value = object->IDLoose;
2993     else if(variable == "IDLooseEM") value = object->IDLooseEM;
2994     else if(variable == "genId") value = object->genId;
2995     else if(variable == "genCharge") value = object->genCharge;
2996     else if(variable == "genMotherId") value = object->genMotherId;
2997     else if(variable == "genMotherCharge") value = object->genMotherCharge;
2998     else if(variable == "isEB") value = object->isEB;
2999     else if(variable == "isEE") value = object->isEE;
3000     else if(variable == "isGap") value = object->isGap;
3001     else if(variable == "isEBEEGap") value = object->isEBEEGap;
3002     else if(variable == "isEBGap") value = object->isEBGap;
3003     else if(variable == "isEEGap") value = object->isEEGap;
3004     else if(variable == "hasPixelSeed") value = object->hasPixelSeed;
3005     else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
3006 biliu 1.40
3007    
3008 jbrinson 1.33
3009 ahart 1.57
3010     else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
3011 lantonel 1.36
3012     else if(variable == "genMatchedPdgId"){
3013     int index = getGenMatchedParticleIndex(object);
3014     if(index == -1) value = 0;
3015     else value = mcparticles->at(index).id;
3016     }
3017 biliu 1.40
3018    
3019    
3020 lantonel 1.22 else if(variable == "genMatchedId"){
3021     int index = getGenMatchedParticleIndex(object);
3022     if(index == -1) value = 0;
3023     else value = getPdgIdBinValue(mcparticles->at(index).id);
3024     }
3025     else if(variable == "genMatchedMotherId"){
3026     int index = getGenMatchedParticleIndex(object);
3027     if(index == -1) value = 0;
3028     else value = getPdgIdBinValue(mcparticles->at(index).motherId);
3029     }
3030 lantonel 1.36 else if(variable == "genMatchedMotherIdReverse"){
3031     int index = getGenMatchedParticleIndex(object);
3032 jbrinson 1.62 if(index == -1) value = 24;
3033     else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
3034 lantonel 1.36 }
3035 lantonel 1.22 else if(variable == "genMatchedGrandmotherId"){
3036     int index = getGenMatchedParticleIndex(object);
3037     if(index == -1) value = 0;
3038     else if(fabs(mcparticles->at(index).motherId) == 15){
3039     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
3040     if(motherIndex == -1) value = 0;
3041     else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
3042     }
3043     else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
3044     }
3045 lantonel 1.50 else if(variable == "genMatchedGrandmotherIdReverse"){
3046     int index = getGenMatchedParticleIndex(object);
3047 jbrinson 1.62 if(index == -1) value = 24;
3048 lantonel 1.50 else if(fabs(mcparticles->at(index).motherId) == 15){
3049     int motherIndex = findTauMotherIndex(&mcparticles->at(index));
3050 jbrinson 1.62 if(motherIndex == -1) value = 24;
3051     else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
3052 lantonel 1.50 }
3053 jbrinson 1.62 else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
3054 lantonel 1.50 }
3055 lantonel 1.22
3056    
3057 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3058 ahart 1.8
3059 lantonel 1.6 value = applyFunction(function, value);
3060 lantonel 1.1
3061     return value;
3062 wulsin 1.90 } // end photon valueLookup
3063    
3064 lantonel 1.1
3065 lantonel 1.51 //!supercluster valueLookup
3066 lantonel 1.1 double
3067 ahart 1.57 OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
3068 lantonel 1.1
3069     double value = 0.0;
3070    
3071     if(variable == "energy") value = object->energy;
3072     else if(variable == "et") value = object->et;
3073     else if(variable == "ex") value = object->ex;
3074     else if(variable == "ey") value = object->ey;
3075     else if(variable == "ez") value = object->ez;
3076     else if(variable == "phi") value = object->phi;
3077     else if(variable == "eta") value = object->eta;
3078     else if(variable == "theta") value = object->theta;
3079    
3080    
3081 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3082    
3083     value = applyFunction(function, value);
3084    
3085     return value;
3086     }
3087    
3088     //!trigobj valueLookup
3089     double
3090     OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
3091    
3092     double value = 0.0;
3093    
3094     if(variable == "pt") value = object->pt;
3095     else if(variable == "eta") value = object->eta;
3096     else if(variable == "phi") value = object->phi;
3097     else if(variable == "px") value = object->px;
3098     else if(variable == "py") value = object->py;
3099     else if(variable == "pz") value = object->pz;
3100     else if(variable == "et") value = object->et;
3101     else if(variable == "energy") value = object->energy;
3102     else if(variable == "etTotal") value = object->etTotal;
3103     else if(variable == "id") value = object->id;
3104     else if(variable == "charge") value = object->charge;
3105     else if(variable == "isIsolated") value = object->isIsolated;
3106     else if(variable == "isMip") value = object->isMip;
3107     else if(variable == "isForward") value = object->isForward;
3108     else if(variable == "isRPC") value = object->isRPC;
3109     else if(variable == "bx") value = object->bx;
3110     else if(variable == "filter") {
3111     if ((stringValue = object->filter) == "")
3112     stringValue = "none"; // stringValue should only be empty if value is filled
3113     }
3114    
3115     else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3116 ahart 1.8
3117 lantonel 1.6 value = applyFunction(function, value);
3118 lantonel 1.1
3119     return value;
3120     }
3121    
3122 lantonel 1.51 //!muon-muon pair valueLookup
3123 lantonel 1.6 double
3124 ahart 1.57 OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
3125 lantonel 1.17
3126     double value = 0.0;
3127    
3128 lantonel 1.23 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3129 lantonel 1.44 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3130 lantonel 1.23 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3131 lantonel 1.17 else if(variable == "invMass"){
3132     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3133     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3134 lantonel 1.29 value = (fourVector1 + fourVector2).M();
3135     }
3136 lantonel 1.38 else if(variable == "pt"){
3137     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3138     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3139 biliu 1.41 value = (fourVector1 + fourVector2).Pt();
3140 lantonel 1.38 }
3141 qpython 1.20 else if(variable == "threeDAngle")
3142     {
3143     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3144     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3145     value = (threeVector1.Angle(threeVector2));
3146     }
3147 qpython 1.27 else if(variable == "alpha")
3148     {
3149     static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3150     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3151     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3152 lantonel 1.29 value = (pi-threeVector1.Angle(threeVector2));
3153 qpython 1.27 }
3154 lantonel 1.18 else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
3155     else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
3156 lantonel 1.19 else if(variable == "d0Sign"){
3157     double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
3158     if(d0Sign < 0) value = -0.5;
3159     else if (d0Sign > 0) value = 0.5;
3160     else value = -999;
3161     }
3162 lantonel 1.29 else if(variable == "chargeProduct"){
3163     value = object1->charge*object2->charge;
3164     }
3165 lantonel 1.19 else if(variable == "muon1CorrectedD0Vertex"){
3166     value = object1->correctedD0Vertex;
3167     }
3168     else if(variable == "muon2CorrectedD0Vertex"){
3169     value = object2->correctedD0Vertex;
3170     }
3171 wulsin 1.43 else if(variable == "muon1timeAtIpInOut"){
3172 qpython 1.27 value = object1->timeAtIpInOut;
3173     }
3174 wulsin 1.43 else if(variable == "muon2timeAtIpInOut"){
3175 qpython 1.27 value = object2->timeAtIpInOut;
3176     }
3177 wulsin 1.43 else if(variable == "muon1correctedD0")
3178     {
3179     value = object1->correctedD0;
3180     }
3181     else if(variable == "muon2correctedD0")
3182     {
3183     value = object2->correctedD0;
3184     }
3185 lantonel 1.36
3186 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3187 lantonel 1.19
3188 lantonel 1.17 value = applyFunction(function, value);
3189    
3190     return value;
3191 wulsin 1.90 } // end muon-muon pair valueLookup
3192    
3193 lantonel 1.17
3194 biliu 1.87 //!muon-photon pair valueLookup
3195     double
3196     OSUAnalysis::valueLookup (const BNmuon* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3197    
3198     double value = 0.0;
3199    
3200     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3201     else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3202     else if(variable == "photonEta") value = object2->eta;
3203     else if(variable == "muonEta") value = object1->eta;
3204     else if(variable == "photonPhi") value = object2->phi;
3205     else if(variable == "muonPhi") value = object1->phi;
3206     else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3207     else if(variable == "photonGenMotherId") value = object2->genMotherId;
3208     else if(variable == "muonRelPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3209     else if(variable == "invMass"){
3210     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3211     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3212     value = (fourVector1 + fourVector2).M();
3213     }
3214     else if(variable == "pt"){
3215     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3216     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3217     value = (fourVector1 + fourVector2).Pt();
3218     }
3219     else if(variable == "threeDAngle")
3220     {
3221     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3222     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3223     value = (threeVector1.Angle(threeVector2));
3224     }
3225     else if(variable == "alpha")
3226     {
3227     static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3228     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3229     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3230     value = (pi-threeVector1.Angle(threeVector2));
3231     }
3232     else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3233    
3234     value = applyFunction(function, value);
3235    
3236     return value;
3237     }
3238    
3239     //!electron-photon pair valueLookup
3240     double
3241     OSUAnalysis::valueLookup (const BNelectron* object1, const BNphoton* object2, string variable, string function, string &stringValue){
3242    
3243     double value = 0.0;
3244    
3245     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3246     else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3247     else if(variable == "photonEta") value = object2->eta;
3248     else if(variable == "electronEta") value = object1->eta;
3249     else if(variable == "photonPhi") value = object2->phi;
3250     else if(variable == "electronPhi") value = object1->phi;
3251     else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3252     else if(variable == "photonGenMotherId") value = object2->genMotherId;
3253     else if(variable == "electronRelPFrhoIso") value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3254     else if(variable == "invMass"){
3255     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3256     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3257     value = (fourVector1 + fourVector2).M();
3258     }
3259     else if(variable == "pt"){
3260     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3261     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3262     value = (fourVector1 + fourVector2).Pt();
3263     }
3264     else if(variable == "threeDAngle")
3265     {
3266     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3267     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3268     value = (threeVector1.Angle(threeVector2));
3269     }
3270     else if(variable == "alpha")
3271     {
3272     static const double pi = 3.1415926535897932384626433832795028841971693993751058;
3273     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3274     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3275     value = (pi-threeVector1.Angle(threeVector2));
3276     }
3277     else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3278    
3279     value = applyFunction(function, value);
3280    
3281     return value;
3282     }
3283    
3284 lantonel 1.51 //!electron-electron pair valueLookup
3285 lantonel 1.17 double
3286 ahart 1.57 OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
3287 lantonel 1.17
3288     double value = 0.0;
3289    
3290 lantonel 1.23 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3291 lantonel 1.44 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3292 lantonel 1.23 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3293 lantonel 1.17 else if(variable == "invMass"){
3294     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3295     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3296 lantonel 1.29 value = (fourVector1 + fourVector2).M();
3297     }
3298 lantonel 1.38 else if(variable == "pt"){
3299     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3300     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3301 biliu 1.41 value = (fourVector1 + fourVector2).Pt();
3302 lantonel 1.38 }
3303 lantonel 1.29 else if(variable == "threeDAngle")
3304 qpython 1.20 {
3305     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3306     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3307     value = (threeVector1.Angle(threeVector2));
3308     }
3309 lantonel 1.18 else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
3310     else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
3311 lantonel 1.19 else if(variable == "d0Sign"){
3312     double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
3313     if(d0Sign < 0) value = -0.5;
3314     else if (d0Sign > 0) value = 0.5;
3315     else value = -999;
3316     }
3317 lantonel 1.29 else if(variable == "chargeProduct"){
3318     value = object1->charge*object2->charge;
3319     }
3320 lantonel 1.19 else if(variable == "electron1CorrectedD0Vertex"){
3321     value = object1->correctedD0Vertex;
3322     }
3323     else if(variable == "electron2CorrectedD0Vertex"){
3324     value = object2->correctedD0Vertex;
3325     }
3326 lantonel 1.36 else if(variable == "electron1CorrectedD0"){
3327     value = object1->correctedD0;
3328     }
3329     else if(variable == "electron2CorrectedD0"){
3330     value = object2->correctedD0;
3331     }
3332 qpython 1.20
3333 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3334 lantonel 1.17
3335     value = applyFunction(function, value);
3336    
3337     return value;
3338     }
3339 wulsin 1.90
3340 lantonel 1.51 //!electron-muon pair valueLookup
3341 lantonel 1.17 double
3342 ahart 1.57 OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
3343 lantonel 1.17
3344     double value = 0.0;
3345    
3346 lantonel 1.23 if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3347 lantonel 1.44 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3348 lantonel 1.23 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3349 lantonel 1.17 else if(variable == "invMass"){
3350     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3351     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3352 lantonel 1.29 value = (fourVector1 + fourVector2).M();
3353     }
3354 lantonel 1.38 else if(variable == "pt"){
3355     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3356     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3357 biliu 1.40 value = (fourVector1 + fourVector2).Pt();
3358 lantonel 1.38 }
3359 lantonel 1.29 else if(variable == "threeDAngle")
3360 qpython 1.20 {
3361     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3362     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3363     value = (threeVector1.Angle(threeVector2));
3364     }
3365 lantonel 1.18 else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
3366     else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
3367 lantonel 1.19 else if(variable == "d0Sign"){
3368     double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
3369     if(d0Sign < 0) value = -0.5;
3370     else if (d0Sign > 0) value = 0.5;
3371     else value = -999;
3372     }
3373 lantonel 1.29 else if(variable == "chargeProduct"){
3374     value = object1->charge*object2->charge;
3375     }
3376 lantonel 1.19 else if(variable == "electronCorrectedD0Vertex"){
3377     value = object1->correctedD0Vertex;
3378     }
3379     else if(variable == "muonCorrectedD0Vertex"){
3380     value = object2->correctedD0Vertex;
3381     }
3382 lantonel 1.22 else if(variable == "electronCorrectedD0"){
3383     value = object1->correctedD0;
3384     }
3385     else if(variable == "muonCorrectedD0"){
3386     value = object2->correctedD0;
3387     }
3388 ahart 1.31 else if(variable == "electronDetIso"){
3389     value = (object1->trackIso) / object1->pt;
3390     }
3391     else if(variable == "muonDetIso"){
3392     value = (object2->trackIsoDR03) / object2->pt;
3393     }
3394 lantonel 1.44 else if(variable == "electronRelPFrhoIso"){
3395     value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3396     }
3397     else if(variable == "muonRelPFdBetaIso"){
3398     value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3399     }
3400 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3401 lantonel 1.17 value = applyFunction(function, value);
3402    
3403     return value;
3404 wulsin 1.90 } // end electron-muon pair valueLookup
3405    
3406 lantonel 1.17
3407 lantonel 1.51 //!electron-jet pair valueLookup
3408     double
3409 ahart 1.57 OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
3410 lantonel 1.51
3411     double value = 0.0;
3412    
3413     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3414     else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3415 biliu 1.79 else if(variable == "jetEta") value = object2->eta;
3416     else if(variable == "jetPhi") value = object2->phi;
3417     else if(variable == "electronEta") value = object1->eta;
3418     else if(variable == "electronPhi") value = object1->phi;
3419 lantonel 1.51 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3420     else if(variable == "invMass"){
3421     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3422     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3423     value = (fourVector1 + fourVector2).M();
3424     }
3425     else if(variable == "pt"){
3426     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3427     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3428     value = (fourVector1 + fourVector2).Pt();
3429     }
3430     else if(variable == "threeDAngle")
3431     {
3432     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3433     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3434     value = (threeVector1.Angle(threeVector2));
3435     }
3436     else if(variable == "chargeProduct"){
3437     value = object1->charge*object2->charge;
3438     }
3439    
3440 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3441 lantonel 1.51 value = applyFunction(function, value);
3442    
3443     return value;
3444     }
3445    
3446 biliu 1.87 //!photon-jet pair valueLookup
3447     double
3448     OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
3449    
3450     double value = 0.0;
3451    
3452     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3453     else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3454     else if(variable == "jetEta") value = object2->eta;
3455     else if(variable == "jetPhi") value = object2->phi;
3456     else if(variable == "photonEta") value = object1->eta;
3457     else if(variable == "photonPhi") value = object1->phi;
3458     else if(variable == "photonGenMotherId") value = object1->genMotherId;
3459     else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3460     else if(variable == "invMass"){
3461     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3462     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3463     value = (fourVector1 + fourVector2).M();
3464     }
3465     else if(variable == "pt"){
3466     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3467     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3468     value = (fourVector1 + fourVector2).Pt();
3469     }
3470     else if(variable == "threeDAngle")
3471     {
3472     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3473     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3474     value = (threeVector1.Angle(threeVector2));
3475     }
3476     else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3477     value = applyFunction(function, value);
3478    
3479     return value;
3480     }
3481    
3482 wulsin 1.89 // met-jet pair valueLookup
3483     double
3484     OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3485    
3486     double value = 0.0;
3487    
3488     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3489    
3490     else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3491     value = applyFunction(function, value);
3492    
3493     return value;
3494    
3495     }
3496    
3497    
3498    
3499 lantonel 1.51 //!muon-jet pair valueLookup
3500     double
3501 ahart 1.57 OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
3502 lantonel 1.51
3503     double value = 0.0;
3504    
3505     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3506 biliu 1.79 else if(variable == "jetEta") value = object2->eta;
3507     else if(variable == "jetPhi") value = object2->phi;
3508     else if(variable == "muonEta") value = object1->eta;
3509     else if(variable == "muonPhi") value = object1->phi;
3510 wulsin 1.89 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3511 lantonel 1.51 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3512     else if(variable == "invMass"){
3513     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3514     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3515     value = (fourVector1 + fourVector2).M();
3516     }
3517     else if(variable == "pt"){
3518     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3519     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3520     value = (fourVector1 + fourVector2).Pt();
3521     }
3522     else if(variable == "threeDAngle")
3523     {
3524     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3525     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3526     value = (threeVector1.Angle(threeVector2));
3527     }
3528     else if(variable == "chargeProduct"){
3529     value = object1->charge*object2->charge;
3530     }
3531    
3532 ahart 1.57 else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3533 lantonel 1.51 value = applyFunction(function, value);
3534 lantonel 1.17
3535 lantonel 1.51 return value;
3536     }
3537 biliu 1.53 //!jet-jet pair valueLookup
3538     double
3539 ahart 1.57 OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3540 biliu 1.53
3541     double value = 0.0;
3542    
3543     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3544     else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3545 biliu 1.65 else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3546 biliu 1.53 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3547     else if(variable == "invMass"){
3548     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3549     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3550     value = (fourVector1 + fourVector2).M();
3551     }
3552     else if(variable == "pt"){
3553     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3554     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3555     value = (fourVector1 + fourVector2).Pt();
3556     }
3557     else if(variable == "threeDAngle")
3558     {
3559     TVector3 threeVector1(object1->px, object1->py, object1->pz);
3560     TVector3 threeVector2(object2->px, object2->py, object2->pz);
3561     value = (threeVector1.Angle(threeVector2));
3562     }
3563     else if(variable == "chargeProduct"){
3564     value = object1->charge*object2->charge;
3565     }
3566 ahart 1.57
3567     else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3568 biliu 1.53 value = applyFunction(function, value);
3569    
3570     return value;
3571     }
3572 wulsin 1.90
3573 lantonel 1.51 //!electron-track pair valueLookup
3574 ahart 1.57 double
3575     OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3576     double electronMass = 0.000511;
3577     double value = 0.0;
3578     TLorentzVector fourVector1(0, 0, 0, 0);
3579     TLorentzVector fourVector2(0, 0, 0, 0);
3580     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3581 lantonel 1.44 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3582 ahart 1.64 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3583     else if(variable == "invMass"){
3584     fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
3585     fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
3586    
3587     value = (fourVector1 + fourVector2).M();
3588 jbrinson 1.60 }
3589     else if(variable == "chargeProduct"){
3590     value = object1->charge*object2->charge;
3591     }
3592 ahart 1.64 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3593     value = applyFunction(function, value);
3594     return value;
3595 ahart 1.57
3596 wulsin 1.43 }
3597    
3598    
3599 lantonel 1.51 //!muon-track pair valueLookup
3600 wulsin 1.43 double
3601 ahart 1.57 OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3602 wulsin 1.43 double pionMass = 0.140;
3603     double muonMass = 0.106;
3604     double value = 0.0;
3605     TLorentzVector fourVector1(0, 0, 0, 0);
3606     TLorentzVector fourVector2(0, 0, 0, 0);
3607     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3608 lantonel 1.44 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3609 wulsin 1.43 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3610     else if(variable == "invMass"){
3611     fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
3612     fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
3613    
3614     value = (fourVector1 + fourVector2).M();
3615     }
3616 jbrinson 1.60 else if(variable == "chargeProduct"){
3617     value = object1->charge*object2->charge;
3618     }
3619 wulsin 1.43
3620 jbrinson 1.60 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3621 wulsin 1.43 value = applyFunction(function, value);
3622     return value;
3623     }
3624    
3625 lantonel 1.51 //!tau-tau pair valueLookup
3626 wulsin 1.43 double
3627 ahart 1.57 OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3628 wulsin 1.43 double value = 0.0;
3629     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3630 lantonel 1.44 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3631 wulsin 1.43 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3632     else if(variable == "invMass"){
3633     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3634     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3635     value = (fourVector1 + fourVector2).M();
3636     }
3637    
3638 jbrinson 1.60 else if(variable == "chargeProduct"){
3639     value = object1->charge*object2->charge;
3640     }
3641    
3642     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3643 wulsin 1.43 value = applyFunction(function, value);
3644     return value;
3645     }
3646    
3647 lantonel 1.51 //!muon-tau pair valueLookup
3648 wulsin 1.43 double
3649 ahart 1.57 OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3650 wulsin 1.43 double value = 0.0;
3651     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3652 lantonel 1.44 else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3653 wulsin 1.43 else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3654     else if(variable == "invMass"){
3655     TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3656     TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3657     value = (fourVector1 + fourVector2).M();
3658     }
3659    
3660 jbrinson 1.60 else if(variable == "chargeProduct"){
3661     value = object1->charge*object2->charge;
3662     }
3663    
3664     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3665 wulsin 1.43 value = applyFunction(function, value);
3666     return value;
3667     }
3668 wulsin 1.42
3669 lantonel 1.51 //!tau-track pair valueLookup
3670 jbrinson 1.46 double
3671 ahart 1.57 OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3672 jbrinson 1.46 double value = 0.0;
3673     if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3674     else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3675 jbrinson 1.60 else if(variable == "chargeProduct"){
3676     value = object1->charge*object2->charge;
3677     }
3678 jbrinson 1.46
3679 jbrinson 1.60 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3680 jbrinson 1.46 value = applyFunction(function, value);
3681     return value;
3682     }
3683    
3684    
3685 lantonel 1.51 //!track-event pair valueLookup
3686 wulsin 1.42 double
3687 ahart 1.57 OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3688 wulsin 1.42
3689     double value = 0.0;
3690     double pMag = sqrt(object1->pt * object1->pt +
3691 ahart 1.57 object1->pz * object1->pz);
3692 wulsin 1.42
3693     if (variable == "numPV") value = object2->numPV;
3694     else if (variable == "caloTotDeltaRp5") value = (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3695     else if (variable == "caloTotDeltaRp5ByP") value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3696 ahart 1.57 else if (variable == "caloTotDeltaRp5_RhoCorr") value = getTrkCaloTotRhoCorr(object1);
3697     else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3698 wulsin 1.42
3699 ahart 1.57 else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3700    
3701     value = applyFunction(function, value);
3702    
3703     return value;
3704    
3705     }
3706    
3707     //!electron-trigobj pair valueLookup
3708     double
3709     OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3710    
3711     double value = 0.0;
3712    
3713     if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3714 ahart 1.61 else if (variable == "match"){
3715     if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3716     stringValue = object2->filter;
3717     else
3718     stringValue = "none";
3719     }
3720 ahart 1.57
3721     else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3722    
3723     value = applyFunction(function, value);
3724    
3725     return value;
3726    
3727     }
3728    
3729     //!muon-trigobj pair valueLookup
3730     double
3731     OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3732    
3733     double value = 0.0;
3734    
3735     if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3736    
3737     else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3738 wulsin 1.42
3739     value = applyFunction(function, value);
3740    
3741     return value;
3742    
3743 lantonel 1.51 }
3744 wulsin 1.42
3745 lantonel 1.51 //!stop valueLookup
3746 lantonel 1.50 double
3747 ahart 1.57 OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3748 lantonel 1.50
3749    
3750     double value = 0.0;
3751    
3752     if(variable == "ctau") value = object->ctau;
3753    
3754     else if (variable == "d0"){
3755     double vx = object->vx - chosenVertex ()->x,
3756     vy = object->vy - chosenVertex ()->y,
3757     px = object->px,
3758     py = object->py,
3759     pt = object->pt;
3760     value = (-vx * py + vy * px) / pt;
3761     }
3762    
3763     else if (variable == "dz"){
3764     double vx = object->vx - chosenVertex ()->x,
3765     vy = object->vy - chosenVertex ()->y,
3766     vz = object->vz - chosenVertex ()->z,
3767     px = object->px,
3768     py = object->py,
3769     pz = object->pz,
3770     pt = object->pt;
3771     value = vz - (vx * px + vy * py)/pt * (pz/pt);
3772     }
3773    
3774     else if (variable == "minD0"){
3775     double minD0=999;
3776     for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3777     double vx = object->vx - vertex->x,
3778 ahart 1.57 vy = object->vy - vertex->y,
3779     px = object->px,
3780     py = object->py,
3781     pt = object->pt;
3782 lantonel 1.50 value = (-vx * py + vy * px) / pt;
3783     if(abs(value) < abs(minD0)) minD0 = value;
3784     }
3785     value = minD0;
3786     }
3787     else if (variable == "minDz"){
3788     double minDz=999;
3789     for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3790     double vx = object->vx - vertex->x,
3791 ahart 1.57 vy = object->vy - vertex->y,
3792     vz = object->vz - vertex->z,
3793     px = object->px,
3794     py = object->py,
3795     pz = object->pz,
3796     pt = object->pt;
3797 lantonel 1.50 value = vz - (vx * px + vy * py)/pt * (pz/pt);
3798     if(abs(value) < abs(minDz)) minDz = value;
3799     }
3800     value = minDz;
3801     }
3802     else if(variable == "distToVertex"){
3803     value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3804 ahart 1.57 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3805     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3806 lantonel 1.50 }
3807     else if (variable == "minDistToVertex"){
3808     double minDistToVertex=999;
3809     for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3810     value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3811 ahart 1.57 (object->vy-vertex->y)*(object->vy-vertex->y) + \
3812     (object->vz-vertex->z)*(object->vz-vertex->z));
3813    
3814 lantonel 1.50 if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3815     }
3816     value = minDistToVertex;
3817     }
3818     else if (variable == "distToVertexDifference"){
3819     double minDistToVertex=999;
3820     for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3821     value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3822 ahart 1.57 (object->vy-vertex->y)*(object->vy-vertex->y) + \
3823     (object->vz-vertex->z)*(object->vz-vertex->z));
3824    
3825 lantonel 1.50 if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3826     }
3827     double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3828 ahart 1.57 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3829     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3830 lantonel 1.50
3831     value = distToChosenVertex - minDistToVertex;
3832     }
3833    
3834     else if (variable == "closestVertexRank"){
3835     double minDistToVertex=999;
3836     int vertex_rank = 0;
3837     for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3838     vertex_rank++;
3839     int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3840 ahart 1.84 (object->vy-vertex->y)*(object->vy-vertex->y) + \
3841     (object->vz-vertex->z)*(object->vz-vertex->z));
3842 ahart 1.57
3843 lantonel 1.50 if(abs(dist) < abs(minDistToVertex)){
3844 ahart 1.57 value = vertex_rank;
3845     minDistToVertex = dist;
3846 lantonel 1.50 }
3847     }
3848     }
3849    
3850    
3851    
3852    
3853 ahart 1.57 else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3854 lantonel 1.50
3855     value = applyFunction(function, value);
3856    
3857     return value;
3858    
3859 wulsin 1.90 } // end stop valueLookup
3860    
3861 lantonel 1.50
3862    
3863    
3864    
3865 ahart 1.31 // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3866     // Return true iff no other tracks are found in this cone.
3867     int
3868 jbrinson 1.25 OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
3869     for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
3870 ahart 1.31 if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
3871 jbrinson 1.28 double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
3872 jbrinson 1.25 if(deltaRtrk < 0.5) return 0;
3873     }
3874     return 1;
3875 ahart 1.31
3876 jbrinson 1.25 }
3877 jbrinson 1.28
3878    
3879 ahart 1.31 double
3880 jbrinson 1.28 OSUAnalysis::getTrkPtRes (const BNtrack* track1){
3881    
3882     double ptTrue = getTrkPtTrue(track1, mcparticles.product());
3883     double PtRes = (track1->pt - ptTrue) / ptTrue;
3884    
3885     return PtRes;
3886 ahart 1.31
3887 jbrinson 1.28 }
3888    
3889    
3890 ahart 1.31 double
3891 jbrinson 1.28 OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
3892     double value = -99;
3893     double genDeltaRLowest = 999;
3894    
3895     for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){
3896     double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
3897     if (genDeltaRtemp < genDeltaRLowest) {
3898     genDeltaRLowest = genDeltaRtemp;
3899 ahart 1.31 if (genDeltaRLowest < 0.05) { // Only consider it truth-matched if DeltaR<0.15.
3900     double ptTrue = genPart->pt;
3901     value = ptTrue;
3902 jbrinson 1.28 }
3903 ahart 1.31 }
3904 jbrinson 1.28 }
3905    
3906     return value;
3907    
3908     }
3909    
3910 wulsin 1.42 double
3911     OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3912 ahart 1.57 // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
3913     if (!useTrackCaloRhoCorr_) return -99;
3914     // if (!rhokt6CaloJetsHandle_) {
3915     // cout << "ERROR [getTrkCaloTotRhoCorr]: The collection rhokt6CaloJetsHandle is not available!" << endl;
3916     // return -99;
3917 wulsin 1.42 // }
3918 ahart 1.57 double radDeltaRCone = 0.5;
3919     double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2); // Define effective area as pi*r^2, where r is radius of DeltaR cone.
3920     double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
3921     double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
3922     return caloTotRhoCorrCalo;
3923    
3924 wulsin 1.42 }
3925    
3926    
3927    
3928    
3929 jbrinson 1.25 //creates a map of the dead Ecal channels in the barrel and endcap
3930     //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
3931     //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
3932 ahart 1.31 void
3933 jbrinson 1.25 OSUAnalysis::WriteDeadEcal (){
3934     double etaEcal, phiEcal;
3935     ifstream DeadEcalFile(deadEcalFile_);
3936     if(!DeadEcalFile) {
3937     cout << "Error: DeadEcalFile has not been found." << endl;
3938 ahart 1.31 return;
3939     }
3940     if(DeadEcalVec.size()!= 0){
3941 jbrinson 1.25 cout << "Error: DeadEcalVec has a nonzero size" << endl;
3942     return;
3943 ahart 1.31 }
3944 jbrinson 1.25 while(!DeadEcalFile.eof())
3945     {
3946     DeadEcalFile >> etaEcal >> phiEcal;
3947     DeadEcal newChan;
3948     newChan.etaEcal = etaEcal;
3949     newChan.phiEcal = phiEcal;
3950     DeadEcalVec.push_back(newChan);
3951     }
3952     if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
3953     }
3954    
3955     //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
3956 ahart 1.31 int
3957 jbrinson 1.25 OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
3958 jbrinson 1.28 double deltaRLowest = 999;
3959 jbrinson 1.25 int value = 0;
3960     if (DeadEcalVec.size() == 0) WriteDeadEcal();
3961 ahart 1.57 for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3962 jbrinson 1.25 double eta = ecal->etaEcal;
3963     double phi = ecal->phiEcal;
3964 jbrinson 1.59 double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
3965 jbrinson 1.28 if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3966 jbrinson 1.25 }
3967 jbrinson 1.28 if (deltaRLowest<0.05) {value = 1;}
3968     else {value = 0;}
3969 jbrinson 1.25 return value;
3970     }
3971    
3972 ahart 1.57 // Returns the smallest DeltaR between the object and any generated true particle in the event.
3973 jbrinson 1.33 template <class InputObject>
3974     double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3975     double genDeltaRLowest = 999.;
3976     for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3977     double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
3978     if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
3979 wulsin 1.43 }
3980 jbrinson 1.33 return genDeltaRLowest;
3981     }
3982 jbrinson 1.25
3983 lantonel 1.17 double
3984 lantonel 1.6 OSUAnalysis::applyFunction(string function, double value){
3985    
3986 lantonel 1.9 if(function == "abs") value = fabs(value);
3987 lantonel 1.19 else if(function == "fabs") value = fabs(value);
3988 qpython 1.27 else if(function == "log10") value = log10(value);
3989     else if(function == "log") value = log10(value);
3990 lantonel 1.6
3991 lantonel 1.19 else if(function == "") value = value;
3992 ahart 1.57 else{cout << "WARNING: invalid function '" << function << "'\n";}
3993 lantonel 1.6
3994     return value;
3995    
3996     }
3997    
3998    
3999 ahart 1.8 template <class InputCollection>
4000 lantonel 1.1 void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
4001 ahart 1.57
4002     if (currentCut.inputCollection.find("pair")!=string::npos) {
4003     string obj1, obj2;
4004 wulsin 1.49 getTwoObjs(currentCut.inputCollection, obj1, obj2);
4005     if (inputType==obj1 ||
4006 ahart 1.84 inputType==obj2) {
4007 wulsin 1.49 // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
4008 ahart 1.57 // and the inputType is a member of the pair.
4009     // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
4010     // For example, if currentCut.inputCollection==electron-muon pairs,
4011     // then the flags should not be set here when inputType==muons or inputType==electrons.
4012     return;
4013     }
4014     }
4015 wulsin 1.49
4016 lantonel 1.1 for (uint object = 0; object != inputCollection->size(); object++){
4017 ahart 1.8
4018 lantonel 1.86 bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4019     bool plotDecision = true;
4020 ahart 1.8
4021     if(currentCut.inputCollection == inputType){
4022    
4023 lantonel 1.17 vector<bool> subcutDecisions;
4024     for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
4025 ahart 1.57 string stringValue = "";
4026     double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
4027     if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4028     else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4029 wulsin 1.49
4030 lantonel 1.17 }
4031 lantonel 1.86 if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4032 lantonel 1.17 else{
4033 ahart 1.31 bool tempDecision = true;
4034     for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
4035     if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
4036     tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
4037     else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
4038 lantonel 1.17 tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
4039 ahart 1.31 }
4040 lantonel 1.86 cutDecision = tempDecision;
4041 lantonel 1.17 }
4042 lantonel 1.86 //invert the cut for plotting if this cut is a veto
4043     if(currentCut.isVeto) plotDecision = !cutDecision;
4044     else plotDecision = cutDecision;
4045 lantonel 1.1 }
4046 wulsin 1.49
4047 lantonel 1.86 individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4048 ahart 1.8
4049 lantonel 1.86 //set flags for objects that pass this cut AND all the previous cuts
4050     bool previousCumulativeCutFlag = true;
4051     for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4052     if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).first) previousCumulativeCutFlag = true;
4053     else{ previousCumulativeCutFlag = false; break;}
4054     }
4055     previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4056     bool previousCumulativePlotFlag = true;
4057 lantonel 1.1 for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4058 lantonel 1.86 if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(object).second) previousCumulativePlotFlag = true;
4059     else{ previousCumulativePlotFlag = false; break;}
4060 lantonel 1.1 }
4061 lantonel 1.86 previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4062    
4063     cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4064 ahart 1.8
4065 lantonel 1.1 }
4066 ahart 1.8
4067 lantonel 1.1 }
4068    
4069    
4070 lantonel 1.17 template <class InputCollection1, class InputCollection2>
4071     void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4072 lantonel 1.86 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4073 lantonel 1.17
4074    
4075     bool sameObjects = false;
4076     if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
4077    
4078 ahart 1.57 // Get the strings for the two objects that make up the pair.
4079     string obj1Type, obj2Type;
4080 wulsin 1.49 getTwoObjs(inputType, obj1Type, obj2Type);
4081     bool isTwoTypesOfObject = true;
4082 ahart 1.57 if (obj1Type==obj2Type) isTwoTypesOfObject = false;
4083 wulsin 1.49
4084 ahart 1.57 // Initialize the flags for individual objects to all be false, if the cut is on the pair.
4085     // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
4086     if (currentCut.inputCollection == inputType) {
4087 wulsin 1.49 for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
4088 lantonel 1.86 individualFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4089     cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(make_pair(false,false));
4090 wulsin 1.49 }
4091 ahart 1.57 if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
4092 wulsin 1.49 for (uint object2 = 0; object2 != inputCollection2->size(); object2++) {
4093 lantonel 1.86 individualFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4094     cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(make_pair(false,false));
4095 wulsin 1.49 }
4096     }
4097     }
4098 ahart 1.57
4099 wulsin 1.49 int counter = 0;
4100 lantonel 1.23
4101 lantonel 1.17 for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
4102     for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
4103 ahart 1.31
4104 lantonel 1.17 if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4105    
4106    
4107 lantonel 1.86 bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4108     bool plotDecision = true;
4109 lantonel 1.17
4110     if(currentCut.inputCollection == inputType){
4111 ahart 1.31
4112     vector<bool> subcutDecisions;
4113     for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
4114 ahart 1.57 string stringValue = "";
4115     double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
4116     if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4117     else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4118 ahart 1.31 }
4119    
4120 lantonel 1.86 if(currentCut.numSubcuts == 1) cutDecision = subcutDecisions.at(0);
4121 ahart 1.31 else{
4122     bool tempDecision = subcutDecisions.at(0);
4123     for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
4124     if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
4125     tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
4126     else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
4127     tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
4128     }
4129 lantonel 1.86 cutDecision = tempDecision;
4130 ahart 1.31 }
4131 lantonel 1.86 //invert the cut for plotting if this cut is a veto
4132     if(currentCut.isVeto) plotDecision = !cutDecision;
4133     else plotDecision = cutDecision;
4134     }
4135     individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4136     if (cutDecision && currentCut.inputCollection == inputType) { // only set the flags for the individual objects if the pair object is being cut on
4137     individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4138     individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4139     }
4140     if (plotDecision && currentCut.inputCollection == inputType) { // only set the flags for the individual objects if the pair object is being cut on
4141     individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4142     individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4143 lantonel 1.17 }
4144 lantonel 1.86
4145     //set flags for objects that pass this cut AND all the previous cuts
4146     bool previousCumulativeCutFlag = true;
4147     for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4148     if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4149     else{ previousCumulativeCutFlag = false; break;}
4150 ahart 1.57 }
4151 lantonel 1.86 previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4152 ahart 1.31
4153 lantonel 1.86 bool previousCumulativePlotFlag = true;
4154 lantonel 1.17 for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4155 lantonel 1.86 if(previousCumulativePlotFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).second) previousCumulativePlotFlag = true;
4156     else{ previousCumulativePlotFlag = false; break;}
4157 lantonel 1.17 }
4158 lantonel 1.86 previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4159    
4160 lantonel 1.23 //apply flags for the components of the composite object as well
4161 lantonel 1.86 bool currentCumulativeCutFlag = true;
4162     bool currentCumulativePlotFlag = true;
4163    
4164     if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4165     else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4166     else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
4167     else currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first && flags2.at(object2).first;
4168    
4169     if(flags1.size() == 0 && flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag;
4170     else if(flags1.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags2.at(object2).second;
4171     else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4172     else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4173    
4174     cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4175    
4176     if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) { // only set the flags for the individual objects if the pair object is being cut on
4177     cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4178     cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4179     }
4180    
4181     if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) { // only set the flags for the individual objects if the pair object is being cut on
4182     cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4183     cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4184 wulsin 1.49 }
4185 lantonel 1.86
4186 wulsin 1.49 counter++;
4187 lantonel 1.17
4188 ahart 1.54 } // end for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
4189     } // end for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
4190 ahart 1.31
4191 wulsin 1.49 }
4192 lantonel 1.17
4193    
4194 lantonel 1.86 bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
4195 ahart 1.57 // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
4196     // all cuts up to currentCutIndex
4197     bool previousCumulativeFlag = true;
4198     for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
4199 lantonel 1.86 bool tempFlag = false;
4200     if(flagType == "cut") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).first;
4201     else if(flagType == "plot") tempFlag = individualFlags.at(obj1Type).at(previousCutIndex).at(object1).second;
4202    
4203     if (previousCumulativeFlag && tempFlag) previousCumulativeFlag = true;
4204 ahart 1.57 else {
4205     previousCumulativeFlag = false; break;
4206 wulsin 1.49 }
4207     }
4208 ahart 1.57 return previousCumulativeFlag;
4209     }
4210 lantonel 1.17
4211    
4212 wulsin 1.74
4213 lantonel 1.86
4214 wulsin 1.74 template <class InputCollection>
4215 lantonel 1.86 void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4216 ahart 1.84 // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4217 wulsin 1.74
4218 ahart 1.84 if (BNTreeBranchVals_.count(parameters.name)==0) cout << "Error[assignTreeBranch]: trying to assign value to " << parameters.name << " that does not have a branch set up. Will likely seg fault." << endl;
4219     for (uint object = 0; object != inputCollection->size(); object++) {
4220 wulsin 1.74
4221 lantonel 1.86 if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4222 wulsin 1.74
4223 ahart 1.84 string inputVariable = parameters.inputVariable;
4224 wulsin 1.74 string function = "";
4225 ahart 1.84 string stringValue = "";
4226     double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4227     BNTreeBranchVals_.at(parameters.name).push_back(value);
4228 wulsin 1.74
4229     }
4230     }
4231    
4232    
4233 lantonel 1.9 template <class InputCollection>
4234 lantonel 1.86 void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4235    
4236 lantonel 1.14
4237     for (uint object = 0; object != inputCollection->size(); object++){
4238 lantonel 1.10
4239 lantonel 1.86 if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4240 lantonel 1.15
4241 lantonel 1.17 string currentString = parameters.inputVariables.at(0);
4242     string inputVariable = "";
4243     string function = "";
4244 ahart 1.57 if(currentString.find("(")==string::npos){
4245 ahart 1.31 inputVariable = currentString;// variable to cut on
4246 lantonel 1.17 }
4247     else{
4248 ahart 1.31 function = currentString.substr(0,currentString.find("("));//function comes before the "("
4249     inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4250     inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4251 ahart 1.84 }
4252 wulsin 1.74
4253 ahart 1.84 string stringValue = "";
4254     double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4255     histo->Fill(value,scaleFactor);
4256 wulsin 1.74
4257 wulsin 1.37 if (printEventInfo_) {
4258 ahart 1.57 // Write information about event to screen, for testing purposes.
4259     cout << " Info for event: value for histogram " << histo->GetName() << ": " << value << endl;
4260 wulsin 1.37 }
4261 ahart 1.57
4262 lantonel 1.15 }
4263     }
4264    
4265 lantonel 1.17 template <class InputCollection1, class InputCollection2>
4266 lantonel 1.86 void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4267 lantonel 1.17
4268     bool sameObjects = false;
4269     if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
4270    
4271 lantonel 1.48 int pairCounter = -1;
4272 lantonel 1.17 for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
4273     for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
4274 ahart 1.31
4275 lantonel 1.17 if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4276    
4277 lantonel 1.48 pairCounter++;
4278 lantonel 1.17 //only take objects which have passed all cuts and pairs which have passed all cuts
4279 lantonel 1.86 if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4280     if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4281     if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4282 lantonel 1.17
4283     string currentString = parameters.inputVariables.at(0);
4284     string inputVariable = "";
4285     string function = "";
4286 ahart 1.57 if(currentString.find("(")==string::npos){
4287 ahart 1.31 inputVariable = currentString;// variable to cut on
4288 lantonel 1.17 }
4289     else{
4290 ahart 1.31 function = currentString.substr(0,currentString.find("("));//function comes before the "("
4291     inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4292     inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4293 lantonel 1.17 }
4294 ahart 1.31
4295 ahart 1.57 string stringValue = "";
4296     double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4297 ahart 1.31 histo->Fill(value,scaleFactor);
4298 lantonel 1.17
4299     }
4300     }
4301    
4302     }
4303    
4304    
4305 lantonel 1.15 template <class InputCollection>
4306 lantonel 1.86 void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4307 lantonel 1.15
4308     for (uint object = 0; object != inputCollection->size(); object++){
4309    
4310 lantonel 1.86 if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4311 lantonel 1.15
4312 ahart 1.57 string stringValue = "";
4313 lantonel 1.17 string currentString = parameters.inputVariables.at(0);
4314     string inputVariable = "";
4315     string function = "";
4316 ahart 1.57 if(currentString.find("(")==string::npos){
4317 ahart 1.31 inputVariable = currentString;// variable to cut on
4318 lantonel 1.17 }
4319     else{
4320 ahart 1.31 function = currentString.substr(0,currentString.find("("));//function comes before the "("
4321     inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4322     inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4323 lantonel 1.17 }
4324 ahart 1.57 double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4325 lantonel 1.17
4326     currentString = parameters.inputVariables.at(1);
4327     inputVariable = "";
4328     function = "";
4329 ahart 1.57 if(currentString.find("(")==string::npos){
4330 ahart 1.31 inputVariable = currentString;// variable to cut on
4331 lantonel 1.17 }
4332     else{
4333 ahart 1.31 function = currentString.substr(0,currentString.find("("));//function comes before the "("
4334     inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4335     inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4336 lantonel 1.17 }
4337    
4338 ahart 1.57 double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
4339 lantonel 1.17
4340 ahart 1.31 histo->Fill(valueX,valueY,scaleFactor);
4341 lantonel 1.14
4342 lantonel 1.9 }
4343    
4344     }
4345    
4346 lantonel 1.17 template <class InputCollection1, class InputCollection2>
4347 lantonel 1.86 void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4348 lantonel 1.17
4349     bool sameObjects = false;
4350     if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
4351    
4352 lantonel 1.48 int pairCounter = -1;
4353 lantonel 1.17 for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
4354     for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
4355 ahart 1.31
4356 lantonel 1.17 if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4357    
4358 lantonel 1.48 pairCounter++;
4359    
4360 lantonel 1.17 //only take objects which have passed all cuts and pairs which have passed all cuts
4361 lantonel 1.86 if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4362     if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4363     if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4364 lantonel 1.17
4365 ahart 1.57 string stringValue = "";
4366 lantonel 1.17 string currentString = parameters.inputVariables.at(0);
4367     string inputVariable = "";
4368     string function = "";
4369 ahart 1.57 if(currentString.find("(")==string::npos){
4370 ahart 1.31 inputVariable = currentString;// variable to cut on
4371 lantonel 1.17 }
4372     else{
4373 ahart 1.31 function = currentString.substr(0,currentString.find("("));//function comes before the "("
4374     inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4375     inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4376 lantonel 1.17 }
4377 ahart 1.57 double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4378 lantonel 1.17
4379     currentString = parameters.inputVariables.at(1);
4380     inputVariable = "";
4381     function = "";
4382 ahart 1.57 if(currentString.find("(")==string::npos){
4383 ahart 1.31 inputVariable = currentString;// variable to cut on
4384 lantonel 1.17 }
4385     else{
4386 ahart 1.31 function = currentString.substr(0,currentString.find("("));//function comes before the "("
4387     inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
4388     inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
4389 lantonel 1.17 }
4390 ahart 1.57 double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4391 lantonel 1.17
4392    
4393 ahart 1.31 histo->Fill(valueX,valueY,scaleFactor);
4394 lantonel 1.17
4395     }
4396     }
4397    
4398     }
4399 lantonel 1.1
4400    
4401 lantonel 1.22 template <class InputObject>
4402     int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
4403 lantonel 1.23
4404 lantonel 1.22 int bestMatchIndex = -1;
4405     double bestMatchDeltaR = 999;
4406 lantonel 1.23
4407 lantonel 1.22 for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
4408    
4409     double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4410     if(currentDeltaR > 0.05) continue;
4411 ahart 1.57 // cout << setprecision(3) << setw(20)
4412 wulsin 1.43 // << "\tcurrentParticle: eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4413 ahart 1.57 // << setw(20)
4414 wulsin 1.43 // << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
4415 ahart 1.57 // << setw(20)
4416 wulsin 1.43 // << "\tdeltaR = " << currentDeltaR
4417 ahart 1.57 // << setprecision(1)
4418     // << setw(20)
4419 wulsin 1.43 // << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
4420 ahart 1.57 // << setw(20)
4421 wulsin 1.43 // << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
4422 ahart 1.57 // << setw(20)
4423 wulsin 1.43 // << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
4424 lantonel 1.22 if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
4425     bestMatchIndex = mcparticle - mcparticles->begin();
4426     bestMatchDeltaR = currentDeltaR;
4427     }
4428    
4429     }
4430 wulsin 1.43 // if(bestMatchDeltaR != 999) cout << "bestMatch: deltaR = " << bestMatchDeltaR << " id = " << mcparticles->at(bestMatchIndex).id << " motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4431     // else cout << "no match found..." << endl;
4432 lantonel 1.22 return bestMatchIndex;
4433    
4434     }
4435    
4436    
4437     int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
4438    
4439     int bestMatchIndex = -1;
4440     double bestMatchDeltaR = 999;
4441    
4442     for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
4443    
4444     if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
4445    
4446     double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
4447     if(currentDeltaR > 0.05) continue;
4448    
4449     if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
4450     bestMatchIndex = mcparticle - mcparticles->begin();
4451     bestMatchDeltaR = currentDeltaR;
4452     }
4453    
4454     }
4455 lantonel 1.23
4456 lantonel 1.22 return bestMatchIndex;
4457     }
4458    
4459    
4460     // bin particle type
4461     // --- -------------
4462     // 0 unmatched
4463     // 1 u
4464     // 2 d
4465     // 3 s
4466     // 4 c
4467     // 5 b
4468     // 6 t
4469     // 7 e
4470     // 8 mu
4471     // 9 tau
4472     // 10 nu
4473     // 11 g
4474     // 12 gamma
4475     // 13 Z
4476     // 14 W
4477     // 15 light meson
4478     // 16 K meson
4479     // 17 D meson
4480     // 18 B meson
4481     // 19 light baryon
4482     // 20 strange baryon
4483     // 21 charm baryon
4484     // 22 bottom baryon
4485 jbrinson 1.62 // 23 QCD string
4486     // 24 other
4487 lantonel 1.22
4488     int OSUAnalysis::getPdgIdBinValue(int pdgId){
4489    
4490     int binValue = -999;
4491 ahart 1.31 int absPdgId = fabs(pdgId);
4492 lantonel 1.22 if(pdgId == -1) binValue = 0;
4493     else if(absPdgId <= 6 ) binValue = absPdgId;
4494     else if(absPdgId == 11 ) binValue = 7;
4495     else if(absPdgId == 13 ) binValue = 8;
4496     else if(absPdgId == 15 ) binValue = 9;
4497     else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
4498     else if(absPdgId == 21 ) binValue = 11;
4499     else if(absPdgId == 22 ) binValue = 12;
4500     else if(absPdgId == 23 ) binValue = 13;
4501     else if(absPdgId == 24 ) binValue = 14;
4502     else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130 ) binValue = 15;
4503     else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400) ) binValue = 16;
4504     else if(absPdgId > 400 && absPdgId < 500 ) binValue = 17;
4505     else if(absPdgId > 500 && absPdgId < 600 ) binValue = 18;
4506     else if(absPdgId > 1000 && absPdgId < 3000 ) binValue = 19;
4507     else if(absPdgId > 3000 && absPdgId < 4000 ) binValue = 20;
4508     else if(absPdgId > 4000 && absPdgId < 5000 ) binValue = 21;
4509     else if(absPdgId > 5000 && absPdgId < 6000 ) binValue = 22;
4510 jbrinson 1.62 else if(absPdgId == 92 ) binValue = 23;
4511 lantonel 1.19
4512 jbrinson 1.62 else binValue = 24;
4513 lantonel 1.22
4514     return binValue;
4515    
4516     }
4517 lantonel 1.19
4518 ahart 1.31 const BNprimaryvertex *
4519     OSUAnalysis::chosenVertex ()
4520     {
4521     const BNprimaryvertex *chosenVertex = 0;
4522 ahart 1.61 if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4523 lantonel 1.86 flagPair vertexFlags;
4524 ahart 1.54 for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4525     if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4526     vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
4527     break;
4528     }
4529     }
4530 ahart 1.31 for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4531 lantonel 1.86 if(!vertexFlags.at(vertexIndex).first) continue;
4532 ahart 1.31 chosenVertex = & primaryvertexs->at(vertexIndex);
4533     break;
4534     }
4535     }
4536 ahart 1.63 else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4537     chosenVertex = & primaryvertexs->at (0);
4538 ahart 1.31
4539     return chosenVertex;
4540     }
4541    
4542     const BNmet *
4543     OSUAnalysis::chosenMET ()
4544     {
4545     const BNmet *chosenMET = 0;
4546 ahart 1.61 if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4547 lantonel 1.86 flagPair metFlags;
4548 ahart 1.54 for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4549     if (cumulativeFlags.at("mets").at(i).size()){
4550     metFlags = cumulativeFlags.at("mets").at(i);
4551     break;
4552     }
4553     }
4554 ahart 1.31 for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4555 lantonel 1.86 if(!metFlags.at(metIndex).first) continue;
4556 ahart 1.31 chosenMET = & mets->at(metIndex);
4557     break;
4558     }
4559     }
4560 ahart 1.63 else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4561     chosenMET = & mets->at (0);
4562 ahart 1.31
4563     return chosenMET;
4564     }
4565    
4566     const BNelectron *
4567     OSUAnalysis::chosenElectron ()
4568     {
4569     const BNelectron *chosenElectron = 0;
4570 ahart 1.61 if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4571 lantonel 1.86 flagPair electronFlags;
4572 ahart 1.54 for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4573     if (cumulativeFlags.at("electrons").at(i).size()){
4574     electronFlags = cumulativeFlags.at("electrons").at(i);
4575     break;
4576     }
4577     }
4578 ahart 1.31 for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4579 lantonel 1.86 if(!electronFlags.at(electronIndex).first) continue;
4580 ahart 1.31 chosenElectron = & electrons->at(electronIndex);
4581     break;
4582     }
4583     }
4584 ahart 1.63 else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4585     chosenElectron = & electrons->at (0);
4586 ahart 1.31
4587     return chosenElectron;
4588     }
4589    
4590 biliu 1.87
4591 ahart 1.31 const BNmuon *
4592     OSUAnalysis::chosenMuon ()
4593     {
4594     const BNmuon *chosenMuon = 0;
4595 ahart 1.61 if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4596 lantonel 1.86 flagPair muonFlags;
4597 ahart 1.54 for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4598     if (cumulativeFlags.at("muons").at(i).size()){
4599     muonFlags = cumulativeFlags.at("muons").at(i);
4600     break;
4601     }
4602     }
4603 ahart 1.31 for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4604 lantonel 1.86 if(!muonFlags.at(muonIndex).first) continue;
4605 ahart 1.31 chosenMuon = & muons->at(muonIndex);
4606     break;
4607     }
4608     }
4609 ahart 1.63 else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4610     chosenMuon = & muons->at (0);
4611 lantonel 1.1
4612 ahart 1.31 return chosenMuon;
4613     }
4614 lantonel 1.1
4615 ahart 1.31 DEFINE_FWK_MODULE(OSUAnalysis);