ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.62
Committed: Tue May 14 10:58:21 2013 UTC (11 years, 11 months ago) by jbrinson
Content type: text/plain
Branch: MAIN
Changes since 1.61: +38 -34 lines
Log Message:
Added bin to genMatchedPdgId for QCD string (pdgId = 92)

File Contents

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