ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.90
Committed: Wed Jun 26 06:17:12 2013 UTC (11 years, 10 months ago) by wulsin
Content type: text/plain
Branch: MAIN
Changes since 1.89: +29 -16 lines
Log Message:
Fix definition of muon looseID to be isGlobalMuon or (not and) isTrackerMuon

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