ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.60
Committed: Thu May 9 10:28:52 2013 UTC (11 years, 11 months ago) by jbrinson
Content type: text/plain
Branch: MAIN
CVS Tags: V01-01-00, V01-00-01
Changes since 1.59: +34 -19 lines
Log Message:
Added charge product to object-track pairs and member to BNtrack

File Contents

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