ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.100
Committed: Tue Jul 16 19:48:04 2013 UTC (11 years, 9 months ago) by ahart
Content type: text/plain
Branch: MAIN
Changes since 1.99: +6 -6 lines
Log Message:
Added a value to BNstop which is true iff the stop decays directly to a tau. Also changed the definition of "lead" in leadElectronPair and leadMuonPair to be based on the scalar sum of the transverse momenta instead of the vector sum.

File Contents

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