ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.97
Committed: Tue Jul 9 20:21:51 2013 UTC (11 years, 9 months ago) by biliu
Content type: text/plain
Branch: MAIN
Changes since 1.96: +74 -9 lines
Log Message:
Add muon-event collection, modify the btag scaling factor function, separate relPFdBetaIso into pieces and add those values in the muon valueLookup function.

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