ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.105
Committed: Mon Jul 22 16:33:25 2013 UTC (11 years, 9 months ago) by wulsin
Content type: text/plain
Branch: MAIN
Changes since 1.104: +5 -1 lines
Log Message:
Fix seg fault when printEventInfo_ is false

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