ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.95
Committed: Tue Jul 9 08:16:18 2013 UTC (11 years, 9 months ago) by jbrinson
Content type: text/plain
Branch: MAIN
Changes since 1.94: +20 -1 lines
Log Message:
Added depTrkRp3MinusPt and dPhiMet to BNtrack; If depTrkRp5MinusPt and depTrkRp3MinusPt are < 0, set value to 0

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