ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.9
Committed: Mon Feb 4 17:10:56 2013 UTC (12 years, 3 months ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.8: +138 -117 lines
Log Message:
moved histogram definitions to configuration, re-added MC particle d0, dz plots

File Contents

# User Rev Content
1 lantonel 1.1 #include "OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h"
2    
3     OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) :
4     // Retrieve parameters from the configuration file.
5     jets_ (cfg.getParameter<edm::InputTag> ("jets")),
6     muons_ (cfg.getParameter<edm::InputTag> ("muons")),
7     electrons_ (cfg.getParameter<edm::InputTag> ("electrons")),
8     events_ (cfg.getParameter<edm::InputTag> ("events")),
9     taus_ (cfg.getParameter<edm::InputTag> ("taus")),
10     mets_ (cfg.getParameter<edm::InputTag> ("mets")),
11     tracks_ (cfg.getParameter<edm::InputTag> ("tracks")),
12     genjets_ (cfg.getParameter<edm::InputTag> ("genjets")),
13     mcparticles_ (cfg.getParameter<edm::InputTag> ("mcparticles")),
14     primaryvertexs_ (cfg.getParameter<edm::InputTag> ("primaryvertexs")),
15     bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
16     photons_ (cfg.getParameter<edm::InputTag> ("photons")),
17     superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
18 lantonel 1.3 triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
19 lantonel 1.1
20    
21 lantonel 1.9 channels_ (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
22    
23     histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets"))
24 lantonel 1.1
25     {
26 lantonel 1.9
27    
28 lantonel 1.1 TH1::SetDefaultSumw2 ();
29    
30     // Construct Cutflow Objects. These store the results of cut decisions and
31     // handle filling cut flow histograms.
32     masterCutFlow_ = new CutFlow (fs_);
33     std::vector<TFileDirectory> directories;
34    
35 lantonel 1.9 //always get vertex collection so we can assign the primary vertex in the event
36     allNecessaryObjects.push_back("primaryvertexs");
37    
38    
39     //parse the histogram definitions
40     for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
41    
42     string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string>("inputCollection");
43     objectsToPlot.push_back(tempInputCollection);
44     allNecessaryObjects.push_back(tempInputCollection);
45     vector<edm::ParameterSet> histogramList_ (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
46    
47     for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
48    
49     histogram tempHistogram;
50     tempHistogram.inputCollection = tempInputCollection;
51     tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
52     tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
53     tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
54     tempHistogram.inputVariable = histogramList_.at(currentHistogram).getParameter<string>("inputVariable");
55     if(histogramList_.at(currentHistogram).exists("function"))
56     tempHistogram.function = histogramList_.at(currentHistogram).getParameter<string>("function");
57     else
58     tempHistogram.function = "";
59    
60     histograms.push_back(tempHistogram);
61    
62     }
63     }
64    
65    
66 lantonel 1.1
67     channel tempChannel;
68     //loop over all channels (event selections)
69     for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
70 ahart 1.8
71 lantonel 1.1 //get name of channel
72     string channelName (channels_.at(currentChannel).getParameter<string>("name"));
73     tempChannel.name = channelName;
74     TString channelLabel = channelName;
75    
76 lantonel 1.3 //set triggers for this channel
77     vector<string> triggerNames;
78     triggerNames.clear();
79     tempChannel.triggers.clear();
80     if(channels_.at(currentChannel).exists("triggers")){
81     triggerNames = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
82     for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
83 ahart 1.8 tempChannel.triggers.push_back(triggerNames.at(trigger));
84 lantonel 1.3 allNecessaryObjects.push_back("triggers");
85     }
86    
87 lantonel 1.1
88 lantonel 1.9
89 lantonel 1.1 //create cutFlow for this channel
90     cutFlows_.push_back (new CutFlow (fs_, channelName));
91    
92     //book a directory in the output file with the name of the channel
93     TFileDirectory subDir = fs_->mkdir( channelName );
94     directories.push_back(subDir);
95     std::map<std::string, TH1D*> histoMap;
96     oneDHists_.push_back(histoMap);
97    
98 lantonel 1.9 //book all histograms included in the configuration
99     for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
100     histogram currentHistogram = histograms.at(currentHistogramIndex);
101     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));
102     }
103     //book a histogram for the number of each object type to be plotted
104     for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
105     string currentObject = objectsToPlot.at(currentObjectIndex);
106     int maxNum = 10;
107     if(currentObject == "mcparticles") maxNum = 50;
108     currentObject[0] = toupper(currentObject[0]);
109     string histoName = "num" + currentObject;
110     oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
111     }
112 lantonel 1.1
113    
114     //get list of cuts for this channel
115     vector<edm::ParameterSet> cuts_ (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
116    
117     //loop over and parse all cuts
118     for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
119    
120     cut tempCut;
121     //store input collection for cut
122     string inputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
123     tempCut.inputCollection = inputCollection;
124     allNecessaryObjects.push_back(inputCollection);
125    
126     //split cut string into parts and store them
127     string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
128     std::vector<string> cutStringVector = splitString(cutString);
129     tempCut.variable = cutStringVector.at(0);// variable to cut on
130     tempCut.comparativeOperator = cutStringVector.at(1);// comparison to make
131     tempCut.cutValue = atof(cutStringVector.at(2).c_str());// threshold value to pass cut
132    
133     //get number of objects required to pass cut for event to pass
134     string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
135     std::vector<string> numberRequiredVector = splitString(numberRequiredString);
136    
137     // determine number required if comparison contains "="
138 ahart 1.8 int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
139 lantonel 1.1 if(numberRequiredVector.at(0) == ">") numberRequiredInt++;
140     else if(numberRequiredVector.at(0) == "<") numberRequiredInt--;
141    
142     tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
143     tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
144 ahart 1.8
145 lantonel 1.3 if(cuts_.at(currentCut).exists("function")){
146     tempCut.function = cuts_.at(currentCut).getParameter<string> ("function");
147     }
148     else tempCut.function = "";
149 lantonel 1.1 string tempCutName;
150     if(cuts_.at(currentCut).exists("alias")){
151 ahart 1.8 tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
152 lantonel 1.1 }
153     else{
154 ahart 1.8 //construct string for cutflow table
155     bool plural = numberRequiredInt != 1;
156     string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1);
157     string cutName = numberRequiredString + " " + collectionString + " with " + cutString;
158     tempCutName = cutName;
159 lantonel 1.1 }
160     tempCut.name = tempCutName;
161    
162    
163     tempChannel.cuts.push_back(tempCut);
164    
165    
166 lantonel 1.9
167 lantonel 1.1 }//end loop over cuts
168    
169    
170     channels.push_back(tempChannel);
171     tempChannel.cuts.clear();
172    
173     }//end loop over channels
174    
175 lantonel 1.9
176    
177    
178 lantonel 1.1 //make unique vector of objects we need to cut on (so we make sure to get them from the event)
179     sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
180     allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
181    
182    
183     }
184    
185     OSUAnalysis::~OSUAnalysis ()
186     {
187     // Destroying the CutFlow objects causes the cut flow numbers and time
188     // information to be printed to standard output.
189     for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
190     delete cutFlows_.at(currentChannel);
191     }
192     }
193    
194     void
195     OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
196     {
197 lantonel 1.2
198 lantonel 1.3
199 lantonel 1.1 // Retrieve necessary collections from the event.
200 lantonel 1.3 edm::Handle<BNtriggerCollection> triggers;
201     if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
202     event.getByLabel (triggers_, triggers);
203    
204 lantonel 1.1 edm::Handle<BNjetCollection> jets;
205 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
206 lantonel 1.1 event.getByLabel (jets_, jets);
207    
208     edm::Handle<BNmuonCollection> muons;
209 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
210 lantonel 1.1 event.getByLabel (muons_, muons);
211    
212     edm::Handle<BNelectronCollection> electrons;
213 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
214 lantonel 1.1 event.getByLabel (electrons_, electrons);
215    
216     edm::Handle<BNeventCollection> events;
217 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
218 lantonel 1.1 event.getByLabel (events_, events);
219    
220     edm::Handle<BNtauCollection> taus;
221 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
222 lantonel 1.1 event.getByLabel (taus_, taus);
223    
224     edm::Handle<BNmetCollection> mets;
225 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
226 lantonel 1.1 event.getByLabel (mets_, mets);
227    
228     edm::Handle<BNtrackCollection> tracks;
229 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
230 lantonel 1.1 event.getByLabel (tracks_, tracks);
231    
232     edm::Handle<BNgenjetCollection> genjets;
233 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
234 lantonel 1.1 event.getByLabel (genjets_, genjets);
235    
236     edm::Handle<BNmcparticleCollection> mcparticles;
237 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
238 lantonel 1.1 event.getByLabel (mcparticles_, mcparticles);
239    
240     edm::Handle<BNprimaryvertexCollection> primaryvertexs;
241 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
242 lantonel 1.1 event.getByLabel (primaryvertexs_, primaryvertexs);
243    
244     edm::Handle<BNbxlumiCollection> bxlumis;
245 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
246 lantonel 1.1 event.getByLabel (bxlumis_, bxlumis);
247    
248     edm::Handle<BNphotonCollection> photons;
249 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
250 lantonel 1.1 event.getByLabel (photons_, photons);
251    
252     edm::Handle<BNsuperclusterCollection> superclusters;
253 ahart 1.8 if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
254 lantonel 1.1 event.getByLabel (superclusters_, superclusters);
255    
256    
257     //loop over all channels
258    
259     for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
260     channel currentChannel = channels.at(currentChannelIndex);
261 ahart 1.8
262     flagMap individualFlags;
263     flagMap cumulativeFlags;
264     counterMap passingCounter;
265 lantonel 1.1
266 lantonel 1.5 bool triggerDecision = true;
267 lantonel 1.3 if(currentChannel.triggers.size() != 0){ //triggers specified
268 lantonel 1.5 triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
269 lantonel 1.3 cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
270     }
271 lantonel 1.1
272     //loop over all cuts
273     for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
274     cut currentCut = currentChannel.cuts.at(currentCutIndex);
275    
276     for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
277    
278 ahart 1.8 string currentObject = allNecessaryObjects.at(currentObjectIndex);
279     individualFlags[currentObject].push_back (vector<bool> ());
280     cumulativeFlags[currentObject].push_back (vector<bool> ());
281    
282     if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
283     else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
284     else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
285     else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
286     else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
287     else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
288     else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
289     else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
290     else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
291     else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
292     else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
293     else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
294     else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
295 lantonel 1.1
296    
297     }
298    
299    
300    
301     }//end loop over all cuts
302 ahart 1.8
303 lantonel 1.1
304    
305 lantonel 1.2
306 lantonel 1.1 //use cumulative flags to apply cuts at event level
307    
308     bool eventPassedAllCuts = true;
309    
310 lantonel 1.5 //apply trigger (true if none were specified)
311     eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
312 lantonel 1.4
313    
314 lantonel 1.1 for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
315    
316     //loop over all objects and count how many passed the cumulative selection up to this point
317     cut currentCut = currentChannel.cuts.at(currentCutIndex);
318     int numberPassing = 0;
319 lantonel 1.3
320 lantonel 1.1 for (uint object = 0; object != cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).size() ; object++)
321 ahart 1.8 if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++;
322 lantonel 1.1
323    
324     bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
325     cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
326    
327     eventPassedAllCuts = eventPassedAllCuts && cutDecision;
328    
329     }
330    
331 ahart 1.8 cutFlows_.at(currentChannelIndex)->fillCutFlow();
332    
333 lantonel 1.1
334     if(!eventPassedAllCuts)continue;
335    
336    
337 lantonel 1.9 //set position of primary vertex in event, in order to calculate quantities relative to it
338 ahart 1.8 vector<bool> vertexFlags = cumulativeFlags["primaryvertexs"].back();
339     for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
340     if(!vertexFlags.at(vertexIndex)) continue;
341     vertexPosition.SetXYZ (primaryvertexs->at(vertexIndex).x,primaryvertexs->at(vertexIndex).y,primaryvertexs->at(vertexIndex).z);
342     break;
343     }
344    
345 lantonel 1.1
346    
347 lantonel 1.9 //filling histograms
348     for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
349     histogram currentHistogram = histograms.at(histogramIndex);
350    
351     if(currentHistogram.inputCollection == "jets") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,jets.product());
352     else if(currentHistogram.inputCollection == "muons") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,muons.product());
353     else if(currentHistogram.inputCollection == "electrons") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,electrons.product());
354     else if(currentHistogram.inputCollection == "events") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,events.product());
355     else if(currentHistogram.inputCollection == "taus") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,taus.product());
356     else if(currentHistogram.inputCollection == "mets") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,mets.product());
357     else if(currentHistogram.inputCollection == "tracks") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,tracks.product());
358     else if(currentHistogram.inputCollection == "genjets") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,genjets.product());
359     else if(currentHistogram.inputCollection == "mcparticles") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,mcparticles.product());
360     else if(currentHistogram.inputCollection == "primaryvertexs") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,primaryvertexs.product());
361     else if(currentHistogram.inputCollection == "bxlumis") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,bxlumis.product());
362     else if(currentHistogram.inputCollection == "photons") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,photons.product());
363     else if(currentHistogram.inputCollection == "superclusters") fillHistogram(oneDHists_.at(currentChannelIndex)[currentHistogram.name],currentHistogram,superclusters.product());
364 lantonel 1.4
365 lantonel 1.1 }
366    
367 lantonel 1.9 //fills histograms with the sizes of collections
368     for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
369     string currentObject = objectsToPlot.at(currentObjectIndex);
370     string tempCurrentObject = currentObject;
371     tempCurrentObject[0] = toupper(tempCurrentObject[0]);
372     string histoName = "num" + tempCurrentObject;
373    
374     if(currentObject == "jets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(jets->size());
375     else if(currentObject == "muons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(muons->size());
376     else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(electrons->size());
377     else if(currentObject == "events") oneDHists_.at(currentChannelIndex)[histoName]->Fill(events->size());
378     else if(currentObject == "taus") oneDHists_.at(currentChannelIndex)[histoName]->Fill(taus->size());
379     else if(currentObject == "mets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(mets->size());
380     else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex)[histoName]->Fill(tracks->size());
381     else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(genjets->size());
382     else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex)[histoName]->Fill(mcparticles->size());
383     else if(currentObject == "primaryvertexs") oneDHists_.at(currentChannelIndex)[histoName]->Fill(primaryvertexs->size());
384     else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex)[histoName]->Fill(bxlumis->size());
385     else if(currentObject == "photons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(photons->size());
386     else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex)[histoName]->Fill(superclusters->size());
387 ahart 1.8
388 lantonel 1.1 }
389     } //end loop over channel
390    
391 ahart 1.8 masterCutFlow_->fillCutFlow();
392 lantonel 1.1
393    
394     }
395    
396    
397 ahart 1.8 bool
398 lantonel 1.1 OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
399    
400 lantonel 1.3
401 lantonel 1.1 if(comparison == ">") return testValue > cutValue;
402     else if(comparison == ">=") return testValue >= cutValue;
403     else if(comparison == "<") return testValue < cutValue;
404     else if(comparison == "<=") return testValue <= cutValue;
405 ahart 1.8 else if(comparison == "==") return testValue == cutValue;
406     else if(comparison == "!=") return testValue != cutValue;
407 lantonel 1.1 else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
408    
409     }
410    
411 lantonel 1.3 bool
412     OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
413    
414     bool triggerDecision = false;
415    
416     for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
417     {
418     if(trigger->pass != 1) continue;
419     for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
420     {
421     if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
422 ahart 1.8 triggerDecision = true;
423 lantonel 1.3 }
424     }
425     }
426     return triggerDecision;
427    
428     }
429    
430 lantonel 1.1 std::vector<std::string>
431     OSUAnalysis::splitString (string inputString){
432    
433     std::stringstream stringStream(inputString);
434     std::istream_iterator<std::string> begin(stringStream);
435     std::istream_iterator<std::string> end;
436     std::vector<std::string> stringVector(begin, end);
437     return stringVector;
438    
439     }
440    
441     double
442 lantonel 1.3 OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
443 lantonel 1.1
444     double value = 0.0;
445     if(variable == "energy") value = object->energy;
446     else if(variable == "et") value = object->et;
447     else if(variable == "pt") value = object->pt;
448     else if(variable == "px") value = object->px;
449     else if(variable == "py") value = object->py;
450     else if(variable == "pz") value = object->pz;
451     else if(variable == "phi") value = object->phi;
452     else if(variable == "eta") value = object->eta;
453     else if(variable == "theta") value = object->theta;
454     else if(variable == "Upt") value = object->Upt;
455     else if(variable == "Uenergy") value = object->Uenergy;
456     else if(variable == "L2pt") value = object->L2pt;
457     else if(variable == "L2L3pt") value = object->L2L3pt;
458     else if(variable == "L2L3respt") value = object->L2L3respt;
459     else if(variable == "respt") value = object->respt;
460     else if(variable == "EMfrac") value = object->EMfrac;
461     else if(variable == "Hadfrac") value = object->Hadfrac;
462     else if(variable == "charge") value = object->charge;
463     else if(variable == "mass") value = object->mass;
464     else if(variable == "area") value = object->area;
465     else if(variable == "fHPD") value = object->fHPD;
466     else if(variable == "approximatefHPD") value = object->approximatefHPD;
467     else if(variable == "genPartonET") value = object->genPartonET;
468     else if(variable == "genPartonPT") value = object->genPartonPT;
469     else if(variable == "genPartonEta") value = object->genPartonEta;
470     else if(variable == "genPartonPhi") value = object->genPartonPhi;
471     else if(variable == "genJetET") value = object->genJetET;
472     else if(variable == "genJetPT") value = object->genJetPT;
473     else if(variable == "genJetEta") value = object->genJetEta;
474     else if(variable == "genJetPhi") value = object->genJetPhi;
475     else if(variable == "btagTChighPur") value = object->btagTChighPur;
476     else if(variable == "btagTChighEff") value = object->btagTChighEff;
477     else if(variable == "btagJetProb") value = object->btagJetProb;
478     else if(variable == "btagJetBProb") value = object->btagJetBProb;
479     else if(variable == "btagSoftEle") value = object->btagSoftEle;
480     else if(variable == "btagSoftMuon") value = object->btagSoftMuon;
481     else if(variable == "btagSoftMuonNoIP") value = object->btagSoftMuonNoIP;
482     else if(variable == "btagSecVertex") value = object->btagSecVertex;
483     else if(variable == "btagSecVertexHighEff") value = object->btagSecVertexHighEff;
484     else if(variable == "btagSecVertexHighPur") value = object->btagSecVertexHighPur;
485     else if(variable == "btagCombinedSecVertex") value = object->btagCombinedSecVertex;
486     else if(variable == "btagCombinedSecVertexMVA") value = object->btagCombinedSecVertexMVA;
487     else if(variable == "btagSoftMuonByPt") value = object->btagSoftMuonByPt;
488     else if(variable == "btagSoftMuonByIP3") value = object->btagSoftMuonByIP3;
489     else if(variable == "btagSoftElectronByPt") value = object->btagSoftElectronByPt;
490     else if(variable == "btagSoftElectronByIP3") value = object->btagSoftElectronByIP3;
491     else if(variable == "n90Hits") value = object->n90Hits;
492     else if(variable == "hitsInN90") value = object->hitsInN90;
493     else if(variable == "chargedHadronEnergyFraction") value = object->chargedHadronEnergyFraction;
494     else if(variable == "neutralHadronEnergyFraction") value = object->neutralHadronEnergyFraction;
495     else if(variable == "chargedEmEnergyFraction") value = object->chargedEmEnergyFraction;
496     else if(variable == "neutralEmEnergyFraction") value = object->neutralEmEnergyFraction;
497     else if(variable == "fLong") value = object->fLong;
498     else if(variable == "fShort") value = object->fShort;
499     else if(variable == "etaetaMoment") value = object->etaetaMoment;
500     else if(variable == "phiphiMoment") value = object->phiphiMoment;
501     else if(variable == "JESunc") value = object->JESunc;
502     else if(variable == "JECuncUp") value = object->JECuncUp;
503     else if(variable == "JECuncDown") value = object->JECuncDown;
504     else if(variable == "puJetMVA_full") value = object->puJetMVA_full;
505     else if(variable == "puJetMVA_simple") value = object->puJetMVA_simple;
506     else if(variable == "puJetMVA_cutbased") value = object->puJetMVA_cutbased;
507     else if(variable == "dZ") value = object->dZ;
508     else if(variable == "dR2Mean") value = object->dR2Mean;
509     else if(variable == "dRMean") value = object->dRMean;
510     else if(variable == "frac01") value = object->frac01;
511     else if(variable == "frac02") value = object->frac02;
512     else if(variable == "frac03") value = object->frac03;
513     else if(variable == "frac04") value = object->frac04;
514     else if(variable == "frac05") value = object->frac05;
515     else if(variable == "frac06") value = object->frac06;
516     else if(variable == "frac07") value = object->frac07;
517     else if(variable == "beta") value = object->beta;
518     else if(variable == "betaStar") value = object->betaStar;
519     else if(variable == "betaClassic") value = object->betaClassic;
520     else if(variable == "betaStarClassic") value = object->betaStarClassic;
521     else if(variable == "ptD") value = object->ptD;
522     else if(variable == "nvtx") value = object->nvtx;
523     else if(variable == "d0") value = object->d0;
524     else if(variable == "leadCandPt") value = object->leadCandPt;
525     else if(variable == "leadCandVx") value = object->leadCandVx;
526     else if(variable == "leadCandVy") value = object->leadCandVy;
527     else if(variable == "leadCandVz") value = object->leadCandVz;
528     else if(variable == "leadCandDistFromPV") value = object->leadCandDistFromPV;
529     else if(variable == "flavour") value = object->flavour;
530     else if(variable == "Nconst") value = object->Nconst;
531     else if(variable == "jetIDMinimal") value = object->jetIDMinimal;
532     else if(variable == "jetIDLooseAOD") value = object->jetIDLooseAOD;
533     else if(variable == "jetIDLoose") value = object->jetIDLoose;
534     else if(variable == "jetIDTight") value = object->jetIDTight;
535     else if(variable == "genPartonId") value = object->genPartonId;
536     else if(variable == "genPartonMotherId") value = object->genPartonMotherId;
537     else if(variable == "genPartonMother0Id") value = object->genPartonMother0Id;
538     else if(variable == "genPartonMother1Id") value = object->genPartonMother1Id;
539     else if(variable == "genPartonGrandMotherId") value = object->genPartonGrandMotherId;
540     else if(variable == "genPartonGrandMother00Id") value = object->genPartonGrandMother00Id;
541     else if(variable == "genPartonGrandMother01Id") value = object->genPartonGrandMother01Id;
542     else if(variable == "genPartonGrandMother10Id") value = object->genPartonGrandMother10Id;
543     else if(variable == "genPartonGrandMother11Id") value = object->genPartonGrandMother11Id;
544     else if(variable == "chargedMultiplicity") value = object->chargedMultiplicity;
545     else if(variable == "neutralMultiplicity") value = object->neutralMultiplicity;
546     else if(variable == "nconstituents") value = object->nconstituents;
547     else if(variable == "nHit") value = object->nHit;
548     else if(variable == "puJetId_full") value = object->puJetId_full;
549     else if(variable == "puJetId_simple") value = object->puJetId_simple;
550     else if(variable == "puJetId_cutbased") value = object->puJetId_cutbased;
551     else if(variable == "puJetId_tight_full") value = object->puJetId_tight_full;
552     else if(variable == "puJetId_tight_simple") value = object->puJetId_tight_simple;
553     else if(variable == "puJetId_tight_cutbased") value = object->puJetId_tight_cutbased;
554     else if(variable == "puJetId_medium_full") value = object->puJetId_medium_full;
555     else if(variable == "puJetId_medium_simple") value = object->puJetId_medium_simple;
556     else if(variable == "puJetId_medium_cutbased") value = object->puJetId_medium_cutbased;
557     else if(variable == "puJetId_loose_full") value = object->puJetId_loose_full;
558     else if(variable == "puJetId_loose_simple") value = object->puJetId_loose_simple;
559     else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
560 ahart 1.8
561    
562 lantonel 1.1 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
563 ahart 1.8
564 lantonel 1.6 value = applyFunction(function, value);
565 lantonel 1.1
566     return value;
567     }
568    
569    
570    
571     double
572 lantonel 1.3 OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
573 lantonel 1.1
574     double value = 0.0;
575     if(variable == "energy") value = object->energy;
576     else if(variable == "et") value = object->et;
577     else if(variable == "pt") value = object->pt;
578     else if(variable == "px") value = object->px;
579     else if(variable == "py") value = object->py;
580     else if(variable == "pz") value = object->pz;
581     else if(variable == "phi") value = object->phi;
582     else if(variable == "eta") value = object->eta;
583     else if(variable == "theta") value = object->theta;
584     else if(variable == "trackIso") value = object->trackIso;
585     else if(variable == "ecalIso") value = object->ecalIso;
586     else if(variable == "hcalIso") value = object->hcalIso;
587     else if(variable == "caloIso") value = object->caloIso;
588     else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
589     else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
590     else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
591     else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
592     else if(variable == "trackVetoIsoDR03") value = object->trackVetoIsoDR03;
593     else if(variable == "ecalVetoIsoDR03") value = object->ecalVetoIsoDR03;
594     else if(variable == "hcalVetoIsoDR03") value = object->hcalVetoIsoDR03;
595     else if(variable == "caloVetoIsoDR03") value = object->caloVetoIsoDR03;
596     else if(variable == "trackIsoDR05") value = object->trackIsoDR05;
597     else if(variable == "ecalIsoDR05") value = object->ecalIsoDR05;
598     else if(variable == "hcalIsoDR05") value = object->hcalIsoDR05;
599     else if(variable == "caloIsoDR05") value = object->caloIsoDR05;
600     else if(variable == "trackVetoIsoDR05") value = object->trackVetoIsoDR05;
601     else if(variable == "ecalVetoIsoDR05") value = object->ecalVetoIsoDR05;
602     else if(variable == "hcalVetoIsoDR05") value = object->hcalVetoIsoDR05;
603     else if(variable == "caloVetoIsoDR05") value = object->caloVetoIsoDR05;
604     else if(variable == "hcalE") value = object->hcalE;
605     else if(variable == "ecalE") value = object->ecalE;
606     else if(variable == "genET") value = object->genET;
607     else if(variable == "genPT") value = object->genPT;
608     else if(variable == "genPhi") value = object->genPhi;
609     else if(variable == "genEta") value = object->genEta;
610     else if(variable == "genMotherET") value = object->genMotherET;
611     else if(variable == "genMotherPT") value = object->genMotherPT;
612     else if(variable == "genMotherPhi") value = object->genMotherPhi;
613     else if(variable == "genMotherEta") value = object->genMotherEta;
614     else if(variable == "vx") value = object->vx;
615     else if(variable == "vy") value = object->vy;
616     else if(variable == "vz") value = object->vz;
617     else if(variable == "tkNormChi2") value = object->tkNormChi2;
618     else if(variable == "tkPT") value = object->tkPT;
619     else if(variable == "tkEta") value = object->tkEta;
620     else if(variable == "tkPhi") value = object->tkPhi;
621     else if(variable == "tkDZ") value = object->tkDZ;
622     else if(variable == "tkD0") value = object->tkD0;
623     else if(variable == "tkD0bs") value = object->tkD0bs;
624     else if(variable == "tkD0err") value = object->tkD0err;
625     else if(variable == "samNormChi2") value = object->samNormChi2;
626     else if(variable == "samPT") value = object->samPT;
627     else if(variable == "samEta") value = object->samEta;
628     else if(variable == "samPhi") value = object->samPhi;
629     else if(variable == "samDZ") value = object->samDZ;
630     else if(variable == "samD0") value = object->samD0;
631     else if(variable == "samD0bs") value = object->samD0bs;
632     else if(variable == "samD0err") value = object->samD0err;
633     else if(variable == "comNormChi2") value = object->comNormChi2;
634     else if(variable == "comPT") value = object->comPT;
635     else if(variable == "comEta") value = object->comEta;
636     else if(variable == "comPhi") value = object->comPhi;
637     else if(variable == "comDZ") value = object->comDZ;
638     else if(variable == "comD0") value = object->comD0;
639     else if(variable == "comD0bs") value = object->comD0bs;
640     else if(variable == "comD0err") value = object->comD0err;
641     else if(variable == "isolationR03emVetoEt") value = object->isolationR03emVetoEt;
642     else if(variable == "isolationR03hadVetoEt") value = object->isolationR03hadVetoEt;
643     else if(variable == "normalizedChi2") value = object->normalizedChi2;
644     else if(variable == "dVzPVz") value = object->dVzPVz;
645     else if(variable == "dB") value = object->dB;
646     else if(variable == "ptErr") value = object->ptErr;
647     else if(variable == "innerTrackNormChi2") value = object->innerTrackNormChi2;
648     else if(variable == "correctedD0") value = object->correctedD0;
649     else if(variable == "correctedD0Vertex") value = object->correctedD0Vertex;
650     else if(variable == "correctedDZ") value = object->correctedDZ;
651     else if(variable == "particleIso") value = object->particleIso;
652     else if(variable == "chargedHadronIso") value = object->chargedHadronIso;
653     else if(variable == "neutralHadronIso") value = object->neutralHadronIso;
654     else if(variable == "photonIso") value = object->photonIso;
655     else if(variable == "puChargedHadronIso") value = object->puChargedHadronIso;
656     else if(variable == "chargedHadronIsoDR03") value = object->chargedHadronIsoDR03;
657     else if(variable == "neutralHadronIsoDR03") value = object->neutralHadronIsoDR03;
658     else if(variable == "photonIsoDR03") value = object->photonIsoDR03;
659     else if(variable == "puChargedHadronIsoDR03") value = object->puChargedHadronIsoDR03;
660     else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
661     else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
662     else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
663     else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
664     else if(variable == "rhoPrime") value = object->rhoPrime;
665     else if(variable == "AEffDr03") value = object->AEffDr03;
666     else if(variable == "AEffDr04") value = object->AEffDr04;
667     else if(variable == "pfIsoR03SumChargedHadronPt") value = object->pfIsoR03SumChargedHadronPt;
668     else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
669     else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
670     else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
671     else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
672     else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
673     else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
674     else if(variable == "pfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt;
675     else if(variable == "IP") value = object->IP;
676     else if(variable == "IPError") value = object->IPError;
677     else if(variable == "timeAtIpInOut") value = object->timeAtIpInOut;
678     else if(variable == "timeAtIpInOutErr") value = object->timeAtIpInOutErr;
679     else if(variable == "timeAtIpOutIn") value = object->timeAtIpOutIn;
680     else if(variable == "timeAtIpOutInErr") value = object->timeAtIpOutInErr;
681     else if(variable == "ecal_time") value = object->ecal_time;
682     else if(variable == "hcal_time") value = object->hcal_time;
683     else if(variable == "ecal_timeError") value = object->ecal_timeError;
684     else if(variable == "hcal_timeError") value = object->hcal_timeError;
685     else if(variable == "energy_ecal") value = object->energy_ecal;
686     else if(variable == "energy_hcal") value = object->energy_hcal;
687     else if(variable == "e3x3_ecal") value = object->e3x3_ecal;
688     else if(variable == "e3x3_hcal") value = object->e3x3_hcal;
689     else if(variable == "energyMax_ecal") value = object->energyMax_ecal;
690     else if(variable == "energyMax_hcal") value = object->energyMax_hcal;
691     else if(variable == "charge") value = object->charge;
692     else if(variable == "IDGMPTight") value = object->IDGMPTight;
693     else if(variable == "tkNumValidHits") value = object->tkNumValidHits;
694     else if(variable == "tkCharge") value = object->tkCharge;
695     else if(variable == "samNumValidHits") value = object->samNumValidHits;
696     else if(variable == "samCharge") value = object->samCharge;
697     else if(variable == "comNumValidHits") value = object->comNumValidHits;
698     else if(variable == "comCharge") value = object->comCharge;
699     else if(variable == "genId") value = object->genId;
700     else if(variable == "genCharge") value = object->genCharge;
701     else if(variable == "genNumberOfMothers") value = object->genNumberOfMothers;
702     else if(variable == "genMotherId") value = object->genMotherId;
703     else if(variable == "genMotherCharge") value = object->genMotherCharge;
704     else if(variable == "genMother0Id") value = object->genMother0Id;
705     else if(variable == "genMother1Id") value = object->genMother1Id;
706     else if(variable == "genGrandMother00Id") value = object->genGrandMother00Id;
707     else if(variable == "genGrandMother01Id") value = object->genGrandMother01Id;
708     else if(variable == "genGrandMother10Id") value = object->genGrandMother10Id;
709     else if(variable == "genGrandMother11Id") value = object->genGrandMother11Id;
710     else if(variable == "isPFMuon") value = object->isPFMuon;
711     else if(variable == "isGoodMuon_1StationTight") value = object->isGoodMuon_1StationTight;
712     else if(variable == "isGlobalMuon") value = object->isGlobalMuon;
713     else if(variable == "isTrackerMuon") value = object->isTrackerMuon;
714     else if(variable == "isStandAloneMuon") value = object->isStandAloneMuon;
715     else if(variable == "isGlobalMuonPromptTight") value = object->isGlobalMuonPromptTight;
716     else if(variable == "numberOfValidMuonHits") value = object->numberOfValidMuonHits;
717     else if(variable == "numberOfValidTrackerHits") value = object->numberOfValidTrackerHits;
718     else if(variable == "numberOfLayersWithMeasurement") value = object->numberOfLayersWithMeasurement;
719     else if(variable == "pixelLayersWithMeasurement") value = object->pixelLayersWithMeasurement;
720     else if(variable == "numberOfMatches") value = object->numberOfMatches;
721     else if(variable == "numberOfValidTrackerHitsInnerTrack") value = object->numberOfValidTrackerHitsInnerTrack;
722     else if(variable == "numberOfValidPixelHits") value = object->numberOfValidPixelHits;
723     else if(variable == "numberOfMatchedStations") value = object->numberOfMatchedStations;
724     else if(variable == "time_ndof") value = object->time_ndof;
725    
726 lantonel 1.9 //user-defined variables
727     else if(variable == "d0Sig") value = object->correctedD0Vertex / object->tkD0err;
728     else if(variable == "detIso") value = (object->trackIso + object->caloIso) / object->pt;
729     else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
730     else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
731    
732    
733 lantonel 1.1 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
734 ahart 1.8
735 lantonel 1.6 value = applyFunction(function, value);
736 lantonel 1.1
737     return value;
738     }
739    
740    
741     double
742 lantonel 1.3 OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
743 lantonel 1.1
744     double value = 0.0;
745     if(variable == "energy") value = object->energy;
746     else if(variable == "et") value = object->et;
747     else if(variable == "gsfEt") value = object->gsfEt;
748     else if(variable == "pt") value = object->pt;
749     else if(variable == "px") value = object->px;
750     else if(variable == "py") value = object->py;
751     else if(variable == "pz") value = object->pz;
752     else if(variable == "phi") value = object->phi;
753     else if(variable == "eta") value = object->eta;
754     else if(variable == "theta") value = object->theta;
755     else if(variable == "pIn") value = object->pIn;
756     else if(variable == "pOut") value = object->pOut;
757     else if(variable == "EscOverPin") value = object->EscOverPin;
758     else if(variable == "EseedOverPout") value = object->EseedOverPout;
759     else if(variable == "hadOverEm") value = object->hadOverEm;
760     else if(variable == "trackIso") value = object->trackIso;
761     else if(variable == "ecalIso") value = object->ecalIso;
762     else if(variable == "hcalIso") value = object->hcalIso;
763     else if(variable == "caloIso") value = object->caloIso;
764     else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
765     else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
766     else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
767     else if(variable == "hcalIsoDR03depth1") value = object->hcalIsoDR03depth1;
768     else if(variable == "hcalIsoDR03depth2") value = object->hcalIsoDR03depth2;
769     else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
770     else if(variable == "trackIsoDR04") value = object->trackIsoDR04;
771     else if(variable == "ecalIsoDR04") value = object->ecalIsoDR04;
772     else if(variable == "hcalIsoDR04") value = object->hcalIsoDR04;
773     else if(variable == "hcalIsoDR04depth1") value = object->hcalIsoDR04depth1;
774     else if(variable == "hcalIsoDR04depth2") value = object->hcalIsoDR04depth2;
775     else if(variable == "caloIsoDR04") value = object->caloIsoDR04;
776     else if(variable == "fbrem") value = object->fbrem;
777     else if(variable == "absInvEMinusInvPin") value = object->absInvEMinusInvPin;
778     else if(variable == "delPhiIn") value = object->delPhiIn;
779     else if(variable == "delEtaIn") value = object->delEtaIn;
780     else if(variable == "genET") value = object->genET;
781     else if(variable == "genPT") value = object->genPT;
782     else if(variable == "genPhi") value = object->genPhi;
783     else if(variable == "genEta") value = object->genEta;
784     else if(variable == "genMotherET") value = object->genMotherET;
785     else if(variable == "genMotherPT") value = object->genMotherPT;
786     else if(variable == "genMotherPhi") value = object->genMotherPhi;
787     else if(variable == "genMotherEta") value = object->genMotherEta;
788     else if(variable == "vx") value = object->vx;
789     else if(variable == "vy") value = object->vy;
790     else if(variable == "vz") value = object->vz;
791     else if(variable == "scEnergy") value = object->scEnergy;
792     else if(variable == "scRawEnergy") value = object->scRawEnergy;
793     else if(variable == "scSigmaEtaEta") value = object->scSigmaEtaEta;
794     else if(variable == "scSigmaIEtaIEta") value = object->scSigmaIEtaIEta;
795     else if(variable == "scE1x5") value = object->scE1x5;
796     else if(variable == "scE2x5Max") value = object->scE2x5Max;
797     else if(variable == "scE5x5") value = object->scE5x5;
798     else if(variable == "scEt") value = object->scEt;
799     else if(variable == "scEta") value = object->scEta;
800     else if(variable == "scPhi") value = object->scPhi;
801     else if(variable == "scZ") value = object->scZ;
802     else if(variable == "tkNormChi2") value = object->tkNormChi2;
803     else if(variable == "tkPT") value = object->tkPT;
804     else if(variable == "tkEta") value = object->tkEta;
805     else if(variable == "tkPhi") value = object->tkPhi;
806     else if(variable == "tkDZ") value = object->tkDZ;
807     else if(variable == "tkD0") value = object->tkD0;
808     else if(variable == "tkD0bs") value = object->tkD0bs;
809     else if(variable == "tkD0err") value = object->tkD0err;
810     else if(variable == "mva") value = object->mva;
811     else if(variable == "mvaTrigV0") value = object->mvaTrigV0;
812     else if(variable == "mvaNonTrigV0") value = object->mvaNonTrigV0;
813     else if(variable == "dist") value = object->dist;
814     else if(variable == "dcot") value = object->dcot;
815     else if(variable == "convradius") value = object->convradius;
816     else if(variable == "convPointX") value = object->convPointX;
817     else if(variable == "convPointY") value = object->convPointY;
818     else if(variable == "convPointZ") value = object->convPointZ;
819     else if(variable == "eMax") value = object->eMax;
820     else if(variable == "eLeft") value = object->eLeft;
821     else if(variable == "eRight") value = object->eRight;
822     else if(variable == "eTop") value = object->eTop;
823     else if(variable == "eBottom") value = object->eBottom;
824     else if(variable == "e3x3") value = object->e3x3;
825     else if(variable == "swissCross") value = object->swissCross;
826     else if(variable == "seedEnergy") value = object->seedEnergy;
827     else if(variable == "seedTime") value = object->seedTime;
828     else if(variable == "swissCrossNoI85") value = object->swissCrossNoI85;
829     else if(variable == "swissCrossI85") value = object->swissCrossI85;
830     else if(variable == "E2overE9NoI85") value = object->E2overE9NoI85;
831     else if(variable == "E2overE9I85") value = object->E2overE9I85;
832     else if(variable == "correctedD0") value = object->correctedD0;
833     else if(variable == "correctedD0Vertex") value = object->correctedD0Vertex;
834     else if(variable == "correctedDZ") value = object->correctedDZ;
835     else if(variable == "particleIso") value = object->particleIso;
836     else if(variable == "chargedHadronIso") value = object->chargedHadronIso;
837     else if(variable == "neutralHadronIso") value = object->neutralHadronIso;
838     else if(variable == "photonIso") value = object->photonIso;
839     else if(variable == "puChargedHadronIso") value = object->puChargedHadronIso;
840     else if(variable == "chargedHadronIsoDR03") value = object->chargedHadronIsoDR03;
841     else if(variable == "neutralHadronIsoDR03") value = object->neutralHadronIsoDR03;
842     else if(variable == "photonIsoDR03") value = object->photonIsoDR03;
843     else if(variable == "puChargedHadronIsoDR03") value = object->puChargedHadronIsoDR03;
844     else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
845     else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
846     else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
847     else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
848     else if(variable == "rhoPrime") value = object->rhoPrime;
849     else if(variable == "AEffDr03") value = object->AEffDr03;
850     else if(variable == "AEffDr04") value = object->AEffDr04;
851     else if(variable == "IP") value = object->IP;
852     else if(variable == "IPError") value = object->IPError;
853     else if(variable == "charge") value = object->charge;
854     else if(variable == "classification") value = object->classification;
855     else if(variable == "genId") value = object->genId;
856     else if(variable == "genCharge") value = object->genCharge;
857     else if(variable == "genNumberOfMothers") value = object->genNumberOfMothers;
858     else if(variable == "genMotherId") value = object->genMotherId;
859     else if(variable == "genMotherCharge") value = object->genMotherCharge;
860     else if(variable == "genMother0Id") value = object->genMother0Id;
861     else if(variable == "genMother1Id") value = object->genMother1Id;
862     else if(variable == "genGrandMother00Id") value = object->genGrandMother00Id;
863     else if(variable == "genGrandMother01Id") value = object->genGrandMother01Id;
864     else if(variable == "genGrandMother10Id") value = object->genGrandMother10Id;
865     else if(variable == "genGrandMother11Id") value = object->genGrandMother11Id;
866     else if(variable == "numClusters") value = object->numClusters;
867     else if(variable == "tkNumValidHits") value = object->tkNumValidHits;
868     else if(variable == "tkCharge") value = object->tkCharge;
869     else if(variable == "gsfCharge") value = object->gsfCharge;
870     else if(variable == "isEB") value = object->isEB;
871     else if(variable == "isEE") value = object->isEE;
872     else if(variable == "isGap") value = object->isGap;
873     else if(variable == "isEBEEGap") value = object->isEBEEGap;
874     else if(variable == "isEBGap") value = object->isEBGap;
875     else if(variable == "isEEGap") value = object->isEEGap;
876     else if(variable == "isEcalDriven") value = object->isEcalDriven;
877     else if(variable == "isTrackerDriven") value = object->isTrackerDriven;
878     else if(variable == "numberOfLostHits") value = object->numberOfLostHits;
879     else if(variable == "numberOfExpectedInnerHits") value = object->numberOfExpectedInnerHits;
880     else if(variable == "numberOfValidPixelHits") value = object->numberOfValidPixelHits;
881     else if(variable == "numberOfValidPixelBarrelHits") value = object->numberOfValidPixelBarrelHits;
882     else if(variable == "numberOfValidPixelEndcapHits") value = object->numberOfValidPixelEndcapHits;
883     else if(variable == "isHEEP") value = object->isHEEP;
884     else if(variable == "isHEEPnoEt") value = object->isHEEPnoEt;
885     else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
886     else if(variable == "eidRobustHighEnergy") value = object->eidRobustHighEnergy;
887     else if(variable == "eidRobustLoose") value = object->eidRobustLoose;
888     else if(variable == "eidRobustTight") value = object->eidRobustTight;
889     else if(variable == "eidLoose") value = object->eidLoose;
890     else if(variable == "eidTight") value = object->eidTight;
891     else if(variable == "eidVeryLooseMC") value = object->eidVeryLooseMC;
892     else if(variable == "eidLooseMC") value = object->eidLooseMC;
893     else if(variable == "eidMediumMC") value = object->eidMediumMC;
894     else if(variable == "eidTightMC") value = object->eidTightMC;
895     else if(variable == "eidSuperTightMC") value = object->eidSuperTightMC;
896     else if(variable == "eidHyperTight1MC") value = object->eidHyperTight1MC;
897     else if(variable == "eidHyperTight2MC") value = object->eidHyperTight2MC;
898     else if(variable == "eidHyperTight3MC") value = object->eidHyperTight3MC;
899     else if(variable == "eidHyperTight4MC") value = object->eidHyperTight4MC;
900     else if(variable == "passConvVeto") value = object->passConvVeto;
901    
902 lantonel 1.9 //user-defined variables
903     else if(variable == "d0Sig") value = object->correctedD0Vertex / object->tkD0err;
904     else if(variable == "detIso") value = (object->trackIso + object->caloIso) / object->pt;
905     else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
906    
907 lantonel 1.1
908     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
909 ahart 1.8
910 lantonel 1.6 value = applyFunction(function, value);
911 lantonel 1.1
912     return value;
913     }
914    
915    
916     double
917 lantonel 1.3 OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
918 lantonel 1.1
919     double value = 0.0;
920    
921     if(variable == "weight") value = object->weight;
922     else if(variable == "pthat") value = object->pthat;
923     else if(variable == "qScale") value = object->qScale;
924     else if(variable == "alphaQCD") value = object->alphaQCD;
925     else if(variable == "alphaQED") value = object->alphaQED;
926     else if(variable == "scalePDF") value = object->scalePDF;
927     else if(variable == "x1") value = object->x1;
928     else if(variable == "x2") value = object->x2;
929     else if(variable == "xPDF1") value = object->xPDF1;
930     else if(variable == "xPDF2") value = object->xPDF2;
931     else if(variable == "BSx") value = object->BSx;
932     else if(variable == "BSy") value = object->BSy;
933     else if(variable == "BSz") value = object->BSz;
934     else if(variable == "PVx") value = object->PVx;
935     else if(variable == "PVy") value = object->PVy;
936     else if(variable == "PVz") value = object->PVz;
937     else if(variable == "bField") value = object->bField;
938     else if(variable == "instLumi") value = object->instLumi;
939     else if(variable == "bxLumi") value = object->bxLumi;
940     else if(variable == "FilterOutScrapingFraction") value = object->FilterOutScrapingFraction;
941     else if(variable == "sumNVtx") value = object->sumNVtx;
942     else if(variable == "sumTrueNVtx") value = object->sumTrueNVtx;
943     else if(variable == "nm1_true") value = object->nm1_true;
944     else if(variable == "n0_true") value = object->n0_true;
945     else if(variable == "np1_true") value = object->np1_true;
946     else if(variable == "numTruePV") value = object->numTruePV;
947     else if(variable == "Q2ScaleUpWgt") value = object->Q2ScaleUpWgt;
948     else if(variable == "Q2ScaleDownWgt") value = object->Q2ScaleDownWgt;
949     else if(variable == "rho_kt6PFJets") value = object->rho_kt6PFJets;
950     else if(variable == "rho_kt6PFJetsCentralChargedPileUp") value = object->rho_kt6PFJetsCentralChargedPileUp;
951     else if(variable == "rho_kt6PFJetsCentralNeutral") value = object->rho_kt6PFJetsCentralNeutral;
952     else if(variable == "rho_kt6PFJetsCentralNeutralTight") value = object->rho_kt6PFJetsCentralNeutralTight;
953     else if(variable == "run") value = object->run;
954     else if(variable == "lumi") value = object->lumi;
955     else if(variable == "sample") value = object->sample;
956     else if(variable == "numPV") value = object->numPV;
957     else if(variable == "W0decay") value = object->W0decay;
958     else if(variable == "W1decay") value = object->W1decay;
959     else if(variable == "Z0decay") value = object->Z0decay;
960     else if(variable == "Z1decay") value = object->Z1decay;
961     else if(variable == "H0decay") value = object->H0decay;
962     else if(variable == "H1decay") value = object->H1decay;
963     else if(variable == "hcalnoiseLoose") value = object->hcalnoiseLoose;
964     else if(variable == "hcalnoiseTight") value = object->hcalnoiseTight;
965     else if(variable == "GoodVertex") value = object->GoodVertex;
966     else if(variable == "FilterOutScraping") value = object->FilterOutScraping;
967     else if(variable == "HBHENoiseFilter") value = object->HBHENoiseFilter;
968     else if(variable == "CSCLooseHaloId") value = object->CSCLooseHaloId;
969     else if(variable == "CSCTightHaloId") value = object->CSCTightHaloId;
970     else if(variable == "EcalLooseHaloId") value = object->EcalLooseHaloId;
971     else if(variable == "EcalTightHaloId") value = object->EcalTightHaloId;
972     else if(variable == "HcalLooseHaloId") value = object->HcalLooseHaloId;
973     else if(variable == "HcalTightHaloId") value = object->HcalTightHaloId;
974     else if(variable == "GlobalLooseHaloId") value = object->GlobalLooseHaloId;
975     else if(variable == "GlobalTightHaloId") value = object->GlobalTightHaloId;
976     else if(variable == "LooseId") value = object->LooseId;
977     else if(variable == "TightId") value = object->TightId;
978     else if(variable == "numGenPV") value = object->numGenPV;
979     else if(variable == "nm1") value = object->nm1;
980     else if(variable == "n0") value = object->n0;
981     else if(variable == "np1") value = object->np1;
982     else if(variable == "id1") value = object->id1;
983     else if(variable == "id2") value = object->id2;
984     else if(variable == "evt") value = object->evt;
985    
986     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
987 ahart 1.8
988 lantonel 1.6 value = applyFunction(function, value);
989 lantonel 1.1
990     return value;
991     }
992    
993     double
994 lantonel 1.3 OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
995 lantonel 1.1
996     double value = 0.0;
997    
998     if(variable == "px") value = object->px;
999     else if(variable == "py") value = object->py;
1000     else if(variable == "pz") value = object->pz;
1001     else if(variable == "energy") value = object->energy;
1002     else if(variable == "et") value = object->et;
1003     else if(variable == "pt") value = object->pt;
1004     else if(variable == "eta") value = object->eta;
1005     else if(variable == "phi") value = object->phi;
1006     else if(variable == "emFraction") value = object->emFraction;
1007     else if(variable == "leadingTrackPt") value = object->leadingTrackPt;
1008     else if(variable == "leadingTrackIpVtdxy") value = object->leadingTrackIpVtdxy;
1009     else if(variable == "leadingTrackIpVtdz") value = object->leadingTrackIpVtdz;
1010     else if(variable == "leadingTrackIpVtdxyError") value = object->leadingTrackIpVtdxyError;
1011     else if(variable == "leadingTrackIpVtdzError") value = object->leadingTrackIpVtdzError;
1012     else if(variable == "leadingTrackVx") value = object->leadingTrackVx;
1013     else if(variable == "leadingTrackVy") value = object->leadingTrackVy;
1014     else if(variable == "leadingTrackVz") value = object->leadingTrackVz;
1015     else if(variable == "leadingTrackValidHits") value = object->leadingTrackValidHits;
1016     else if(variable == "leadingTrackNormChiSqrd") value = object->leadingTrackNormChiSqrd;
1017     else if(variable == "numProngs") value = object->numProngs;
1018     else if(variable == "numSignalGammas") value = object->numSignalGammas;
1019     else if(variable == "numSignalNeutrals") value = object->numSignalNeutrals;
1020     else if(variable == "numSignalPiZeros") value = object->numSignalPiZeros;
1021     else if(variable == "decayMode") value = object->decayMode;
1022     else if(variable == "charge") value = object->charge;
1023     else if(variable == "inTheCracks") value = object->inTheCracks;
1024     else if(variable == "HPSagainstElectronLoose") value = object->HPSagainstElectronLoose;
1025     else if(variable == "HPSagainstElectronMVA") value = object->HPSagainstElectronMVA;
1026     else if(variable == "HPSagainstElectronMedium") value = object->HPSagainstElectronMedium;
1027     else if(variable == "HPSagainstElectronTight") value = object->HPSagainstElectronTight;
1028     else if(variable == "HPSagainstMuonLoose") value = object->HPSagainstMuonLoose;
1029     else if(variable == "HPSagainstMuonMedium") value = object->HPSagainstMuonMedium;
1030     else if(variable == "HPSagainstMuonTight") value = object->HPSagainstMuonTight;
1031     else if(variable == "HPSbyLooseCombinedIsolationDeltaBetaCorr") value = object->HPSbyLooseCombinedIsolationDeltaBetaCorr;
1032     else if(variable == "HPSbyMediumCombinedIsolationDeltaBetaCorr") value = object->HPSbyMediumCombinedIsolationDeltaBetaCorr;
1033     else if(variable == "HPSbyTightCombinedIsolationDeltaBetaCorr") value = object->HPSbyTightCombinedIsolationDeltaBetaCorr;
1034     else if(variable == "HPSbyVLooseCombinedIsolationDeltaBetaCorr") value = object->HPSbyVLooseCombinedIsolationDeltaBetaCorr;
1035     else if(variable == "HPSdecayModeFinding") value = object->HPSdecayModeFinding;
1036     else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1037    
1038    
1039     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1040 ahart 1.8
1041 lantonel 1.6 value = applyFunction(function, value);
1042 lantonel 1.1
1043     return value;
1044     }
1045    
1046     double
1047 lantonel 1.3 OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
1048 lantonel 1.1
1049     double value = 0.0;
1050    
1051     if(variable == "et") value = object->et;
1052     else if(variable == "pt") value = object->pt;
1053     else if(variable == "px") value = object->px;
1054     else if(variable == "py") value = object->py;
1055     else if(variable == "phi") value = object->phi;
1056     else if(variable == "Upt") value = object->Upt;
1057     else if(variable == "Uphi") value = object->Uphi;
1058     else if(variable == "NeutralEMFraction") value = object->NeutralEMFraction;
1059     else if(variable == "NeutralHadEtFraction") value = object->NeutralHadEtFraction;
1060     else if(variable == "ChargedEMEtFraction") value = object->ChargedEMEtFraction;
1061     else if(variable == "ChargedHadEtFraction") value = object->ChargedHadEtFraction;
1062     else if(variable == "MuonEtFraction") value = object->MuonEtFraction;
1063     else if(variable == "Type6EtFraction") value = object->Type6EtFraction;
1064     else if(variable == "Type7EtFraction") value = object->Type7EtFraction;
1065     else if(variable == "genPT") value = object->genPT;
1066     else if(variable == "genPhi") value = object->genPhi;
1067     else if(variable == "muonCorEx") value = object->muonCorEx;
1068     else if(variable == "muonCorEy") value = object->muonCorEy;
1069     else if(variable == "jet20CorEx") value = object->jet20CorEx;
1070     else if(variable == "jet20CorEy") value = object->jet20CorEy;
1071     else if(variable == "jet1CorEx") value = object->jet1CorEx;
1072     else if(variable == "jet1CorEy") value = object->jet1CorEy;
1073     else if(variable == "sumET") value = object->sumET;
1074     else if(variable == "corSumET") value = object->corSumET;
1075     else if(variable == "mEtSig") value = object->mEtSig;
1076     else if(variable == "metSignificance") value = object->metSignificance;
1077     else if(variable == "significance") value = object->significance;
1078     else if(variable == "sigmaX2") value = object->sigmaX2;
1079     else if(variable == "sigmaY2") value = object->sigmaY2;
1080     else if(variable == "sigmaXY") value = object->sigmaXY;
1081     else if(variable == "sigmaYX") value = object->sigmaYX;
1082     else if(variable == "maxEtInEmTowers") value = object->maxEtInEmTowers;
1083     else if(variable == "emEtFraction") value = object->emEtFraction;
1084     else if(variable == "emEtInEB") value = object->emEtInEB;
1085     else if(variable == "emEtInEE") value = object->emEtInEE;
1086     else if(variable == "emEtInHF") value = object->emEtInHF;
1087     else if(variable == "maxEtInHadTowers") value = object->maxEtInHadTowers;
1088     else if(variable == "hadEtFraction") value = object->hadEtFraction;
1089     else if(variable == "hadEtInHB") value = object->hadEtInHB;
1090     else if(variable == "hadEtInHE") value = object->hadEtInHE;
1091     else if(variable == "hadEtInHF") value = object->hadEtInHF;
1092     else if(variable == "hadEtInHO") value = object->hadEtInHO;
1093     else if(variable == "UDeltaPx") value = object->UDeltaPx;
1094     else if(variable == "UDeltaPy") value = object->UDeltaPy;
1095     else if(variable == "UDeltaP") value = object->UDeltaP;
1096     else if(variable == "Uscale") value = object->Uscale;
1097     else if(variable == "type2corPx") value = object->type2corPx;
1098     else if(variable == "type2corPy") value = object->type2corPy;
1099     else if(variable == "T2pt") value = object->T2pt;
1100     else if(variable == "T2px") value = object->T2px;
1101     else if(variable == "T2py") value = object->T2py;
1102     else if(variable == "T2phi") value = object->T2phi;
1103     else if(variable == "T2sumET") value = object->T2sumET;
1104     else if(variable == "pfT1jet1pt") value = object->pfT1jet1pt;
1105     else if(variable == "pfT1jet1phi") value = object->pfT1jet1phi;
1106     else if(variable == "pfT1jet6pt") value = object->pfT1jet6pt;
1107     else if(variable == "pfT1jet6phi") value = object->pfT1jet6phi;
1108     else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
1109     else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
1110    
1111     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1112 ahart 1.8
1113 lantonel 1.6 value = applyFunction(function, value);
1114 lantonel 1.1
1115     return value;
1116     }
1117    
1118     double
1119 lantonel 1.3 OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1120 lantonel 1.1
1121     double value = 0.0;
1122    
1123     if(variable == "pt") value = object->pt;
1124     else if(variable == "px") value = object->px;
1125     else if(variable == "py") value = object->py;
1126     else if(variable == "pz") value = object->pz;
1127     else if(variable == "phi") value = object->phi;
1128     else if(variable == "eta") value = object->eta;
1129     else if(variable == "theta") value = object->theta;
1130     else if(variable == "normChi2") value = object->normChi2;
1131     else if(variable == "dZ") value = object->dZ;
1132     else if(variable == "d0") value = object->d0;
1133     else if(variable == "d0err") value = object->d0err;
1134     else if(variable == "vx") value = object->vx;
1135     else if(variable == "vy") value = object->vy;
1136     else if(variable == "vz") value = object->vz;
1137     else if(variable == "charge") value = object->charge;
1138     else if(variable == "numValidHits") value = object->numValidHits;
1139     else if(variable == "isHighPurity") value = object->isHighPurity;
1140    
1141    
1142     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1143 ahart 1.8
1144 lantonel 1.6 value = applyFunction(function, value);
1145 lantonel 1.1
1146     return value;
1147     }
1148    
1149     double
1150 lantonel 1.3 OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
1151 lantonel 1.1
1152     double value = 0.0;
1153    
1154     if(variable == "pt") value = object->pt;
1155     else if(variable == "eta") value = object->eta;
1156     else if(variable == "phi") value = object->phi;
1157     else if(variable == "px") value = object->px;
1158     else if(variable == "py") value = object->py;
1159     else if(variable == "pz") value = object->pz;
1160     else if(variable == "et") value = object->et;
1161     else if(variable == "energy") value = object->energy;
1162     else if(variable == "mass") value = object->mass;
1163     else if(variable == "emEnergy") value = object->emEnergy;
1164     else if(variable == "hadEnergy") value = object->hadEnergy;
1165     else if(variable == "invisibleEnergy") value = object->invisibleEnergy;
1166     else if(variable == "auxiliaryEnergy") value = object->auxiliaryEnergy;
1167     else if(variable == "charge") value = object->charge;
1168    
1169    
1170     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1171 ahart 1.8
1172 lantonel 1.6 value = applyFunction(function, value);
1173 lantonel 1.1
1174     return value;
1175     }
1176    
1177     double
1178 lantonel 1.3 OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
1179 lantonel 1.1
1180     double value = 0.0;
1181    
1182     if(variable == "energy") value = object->energy;
1183     else if(variable == "et") value = object->et;
1184     else if(variable == "pt") value = object->pt;
1185     else if(variable == "px") value = object->px;
1186     else if(variable == "py") value = object->py;
1187     else if(variable == "pz") value = object->pz;
1188     else if(variable == "phi") value = object->phi;
1189     else if(variable == "eta") value = object->eta;
1190     else if(variable == "theta") value = object->theta;
1191     else if(variable == "mass") value = object->mass;
1192     else if(variable == "vx") value = object->vx;
1193     else if(variable == "vy") value = object->vy;
1194     else if(variable == "vz") value = object->vz;
1195     else if(variable == "motherET") value = object->motherET;
1196     else if(variable == "motherPT") value = object->motherPT;
1197     else if(variable == "motherPhi") value = object->motherPhi;
1198     else if(variable == "motherEta") value = object->motherEta;
1199     else if(variable == "mother0ET") value = object->mother0ET;
1200     else if(variable == "mother0PT") value = object->mother0PT;
1201     else if(variable == "mother0Phi") value = object->mother0Phi;
1202     else if(variable == "mother0Eta") value = object->mother0Eta;
1203     else if(variable == "mother1ET") value = object->mother1ET;
1204     else if(variable == "mother1PT") value = object->mother1PT;
1205     else if(variable == "mother1Phi") value = object->mother1Phi;
1206     else if(variable == "mother1Eta") value = object->mother1Eta;
1207     else if(variable == "daughter0ET") value = object->daughter0ET;
1208     else if(variable == "daughter0PT") value = object->daughter0PT;
1209     else if(variable == "daughter0Phi") value = object->daughter0Phi;
1210     else if(variable == "daughter0Eta") value = object->daughter0Eta;
1211     else if(variable == "daughter1ET") value = object->daughter1ET;
1212     else if(variable == "daughter1PT") value = object->daughter1PT;
1213     else if(variable == "daughter1Phi") value = object->daughter1Phi;
1214     else if(variable == "daughter1Eta") value = object->daughter1Eta;
1215     else if(variable == "grandMotherET") value = object->grandMotherET;
1216     else if(variable == "grandMotherPT") value = object->grandMotherPT;
1217     else if(variable == "grandMotherPhi") value = object->grandMotherPhi;
1218     else if(variable == "grandMotherEta") value = object->grandMotherEta;
1219     else if(variable == "grandMother00ET") value = object->grandMother00ET;
1220     else if(variable == "grandMother00PT") value = object->grandMother00PT;
1221     else if(variable == "grandMother00Phi") value = object->grandMother00Phi;
1222     else if(variable == "grandMother00Eta") value = object->grandMother00Eta;
1223     else if(variable == "grandMother01ET") value = object->grandMother01ET;
1224     else if(variable == "grandMother01PT") value = object->grandMother01PT;
1225     else if(variable == "grandMother01Phi") value = object->grandMother01Phi;
1226     else if(variable == "grandMother01Eta") value = object->grandMother01Eta;
1227     else if(variable == "grandMother10ET") value = object->grandMother10ET;
1228     else if(variable == "grandMother10PT") value = object->grandMother10PT;
1229     else if(variable == "grandMother10Phi") value = object->grandMother10Phi;
1230     else if(variable == "grandMother10Eta") value = object->grandMother10Eta;
1231     else if(variable == "grandMother11ET") value = object->grandMother11ET;
1232     else if(variable == "grandMother11PT") value = object->grandMother11PT;
1233     else if(variable == "grandMother11Phi") value = object->grandMother11Phi;
1234     else if(variable == "grandMother11Eta") value = object->grandMother11Eta;
1235     else if(variable == "charge") value = object->charge;
1236     else if(variable == "id") value = object->id;
1237     else if(variable == "status") value = object->status;
1238     else if(variable == "motherId") value = object->motherId;
1239     else if(variable == "motherCharge") value = object->motherCharge;
1240     else if(variable == "mother0Id") value = object->mother0Id;
1241     else if(variable == "mother0Status") value = object->mother0Status;
1242     else if(variable == "mother0Charge") value = object->mother0Charge;
1243     else if(variable == "mother1Id") value = object->mother1Id;
1244     else if(variable == "mother1Status") value = object->mother1Status;
1245     else if(variable == "mother1Charge") value = object->mother1Charge;
1246     else if(variable == "daughter0Id") value = object->daughter0Id;
1247     else if(variable == "daughter0Status") value = object->daughter0Status;
1248     else if(variable == "daughter0Charge") value = object->daughter0Charge;
1249     else if(variable == "daughter1Id") value = object->daughter1Id;
1250     else if(variable == "daughter1Status") value = object->daughter1Status;
1251     else if(variable == "daughter1Charge") value = object->daughter1Charge;
1252     else if(variable == "grandMotherId") value = object->grandMotherId;
1253     else if(variable == "grandMotherCharge") value = object->grandMotherCharge;
1254     else if(variable == "grandMother00Id") value = object->grandMother00Id;
1255     else if(variable == "grandMother00Status") value = object->grandMother00Status;
1256     else if(variable == "grandMother00Charge") value = object->grandMother00Charge;
1257     else if(variable == "grandMother01Id") value = object->grandMother01Id;
1258     else if(variable == "grandMother01Status") value = object->grandMother01Status;
1259     else if(variable == "grandMother01Charge") value = object->grandMother01Charge;
1260     else if(variable == "grandMother10Id") value = object->grandMother10Id;
1261     else if(variable == "grandMother10Status") value = object->grandMother10Status;
1262     else if(variable == "grandMother10Charge") value = object->grandMother10Charge;
1263     else if(variable == "grandMother11Id") value = object->grandMother11Id;
1264     else if(variable == "grandMother11Status") value = object->grandMother11Status;
1265     else if(variable == "grandMother11Charge") value = object->grandMother11Charge;
1266    
1267 lantonel 1.9 //user-defined variables
1268     else if (variable == "d0"){
1269     double vx = object->vx - vertexPosition.X (),
1270     vy = object->vy - vertexPosition.Y (),
1271     px = object->px,
1272     py = object->py,
1273     pt = object->pt;
1274     value = (-vx * py + vy * px) / pt;
1275     }
1276     else if (variable == "dz"){
1277     double vx = object->vx - vertexPosition.X (),
1278     vy = object->vy - vertexPosition.Y (),
1279     vz = object->vz - vertexPosition.Z (),
1280     px = object->px,
1281     py = object->py,
1282     pz = object->pz,
1283     pt = object->pt;
1284     value = vz - (vx * px + vy * py)/pt * (pz/pt);
1285     }
1286    
1287    
1288    
1289 lantonel 1.1 else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1290 ahart 1.8
1291 lantonel 1.6 value = applyFunction(function, value);
1292 lantonel 1.1
1293     return value;
1294     }
1295    
1296     double
1297 lantonel 1.3 OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
1298 lantonel 1.1
1299     double value = 0.0;
1300    
1301     if(variable == "x") value = object->x;
1302     else if(variable == "xError") value = object->xError;
1303     else if(variable == "y") value = object->y;
1304     else if(variable == "yError") value = object->yError;
1305     else if(variable == "z") value = object->z;
1306     else if(variable == "zError") value = object->zError;
1307     else if(variable == "rho") value = object->rho;
1308     else if(variable == "normalizedChi2") value = object->normalizedChi2;
1309     else if(variable == "ndof") value = object->ndof;
1310     else if(variable == "isFake") value = object->isFake;
1311     else if(variable == "isValid") value = object->isValid;
1312     else if(variable == "tracksSize") value = object->tracksSize;
1313     else if(variable == "isGood") value = object->isGood;
1314    
1315    
1316     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1317 ahart 1.8
1318 lantonel 1.6 value = applyFunction(function, value);
1319 lantonel 1.1
1320     return value;
1321     }
1322    
1323     double
1324 lantonel 1.3 OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
1325 lantonel 1.1
1326     double value = 0.0;
1327    
1328     if(variable == "bx_B1_now") value = object->bx_B1_now;
1329     else if(variable == "bx_B2_now") value = object->bx_B2_now;
1330     else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
1331    
1332    
1333     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1334 ahart 1.8
1335 lantonel 1.6 value = applyFunction(function, value);
1336 lantonel 1.1
1337     return value;
1338     }
1339    
1340     double
1341 lantonel 1.3 OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
1342 lantonel 1.1
1343     double value = 0.0;
1344    
1345     if(variable == "energy") value = object->energy;
1346     else if(variable == "et") value = object->et;
1347     else if(variable == "pt") value = object->pt;
1348     else if(variable == "px") value = object->px;
1349     else if(variable == "py") value = object->py;
1350     else if(variable == "pz") value = object->pz;
1351     else if(variable == "phi") value = object->phi;
1352     else if(variable == "eta") value = object->eta;
1353     else if(variable == "theta") value = object->theta;
1354     else if(variable == "trackIso") value = object->trackIso;
1355     else if(variable == "ecalIso") value = object->ecalIso;
1356     else if(variable == "hcalIso") value = object->hcalIso;
1357     else if(variable == "caloIso") value = object->caloIso;
1358     else if(variable == "trackIsoHollowConeDR03") value = object->trackIsoHollowConeDR03;
1359     else if(variable == "trackIsoSolidConeDR03") value = object->trackIsoSolidConeDR03;
1360     else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
1361     else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
1362     else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
1363     else if(variable == "trackIsoHollowConeDR04") value = object->trackIsoHollowConeDR04;
1364     else if(variable == "trackIsoSolidConeDR04") value = object->trackIsoSolidConeDR04;
1365     else if(variable == "ecalIsoDR04") value = object->ecalIsoDR04;
1366     else if(variable == "hcalIsoDR04") value = object->hcalIsoDR04;
1367     else if(variable == "caloIsoDR04") value = object->caloIsoDR04;
1368     else if(variable == "hadOverEm") value = object->hadOverEm;
1369     else if(variable == "sigmaEtaEta") value = object->sigmaEtaEta;
1370     else if(variable == "sigmaIetaIeta") value = object->sigmaIetaIeta;
1371     else if(variable == "r9") value = object->r9;
1372     else if(variable == "scEnergy") value = object->scEnergy;
1373     else if(variable == "scRawEnergy") value = object->scRawEnergy;
1374     else if(variable == "scSeedEnergy") value = object->scSeedEnergy;
1375     else if(variable == "scEta") value = object->scEta;
1376     else if(variable == "scPhi") value = object->scPhi;
1377     else if(variable == "scZ") value = object->scZ;
1378     else if(variable == "genET") value = object->genET;
1379     else if(variable == "genPT") value = object->genPT;
1380     else if(variable == "genPhi") value = object->genPhi;
1381     else if(variable == "genEta") value = object->genEta;
1382     else if(variable == "genMotherET") value = object->genMotherET;
1383     else if(variable == "genMotherPT") value = object->genMotherPT;
1384     else if(variable == "genMotherPhi") value = object->genMotherPhi;
1385     else if(variable == "genMotherEta") value = object->genMotherEta;
1386     else if(variable == "eMax") value = object->eMax;
1387     else if(variable == "eLeft") value = object->eLeft;
1388     else if(variable == "eRight") value = object->eRight;
1389     else if(variable == "eTop") value = object->eTop;
1390     else if(variable == "eBottom") value = object->eBottom;
1391     else if(variable == "e3x3") value = object->e3x3;
1392     else if(variable == "swissCross") value = object->swissCross;
1393     else if(variable == "seedEnergy") value = object->seedEnergy;
1394     else if(variable == "seedTime") value = object->seedTime;
1395     else if(variable == "swissCrossNoI85") value = object->swissCrossNoI85;
1396     else if(variable == "swissCrossI85") value = object->swissCrossI85;
1397     else if(variable == "E2overE9NoI85") value = object->E2overE9NoI85;
1398     else if(variable == "E2overE9I85") value = object->E2overE9I85;
1399     else if(variable == "IDTight") value = object->IDTight;
1400     else if(variable == "IDLoose") value = object->IDLoose;
1401     else if(variable == "IDLooseEM") value = object->IDLooseEM;
1402     else if(variable == "genId") value = object->genId;
1403     else if(variable == "genCharge") value = object->genCharge;
1404     else if(variable == "genMotherId") value = object->genMotherId;
1405     else if(variable == "genMotherCharge") value = object->genMotherCharge;
1406     else if(variable == "isEB") value = object->isEB;
1407     else if(variable == "isEE") value = object->isEE;
1408     else if(variable == "isGap") value = object->isGap;
1409     else if(variable == "isEBEEGap") value = object->isEBEEGap;
1410     else if(variable == "isEBGap") value = object->isEBGap;
1411     else if(variable == "isEEGap") value = object->isEEGap;
1412     else if(variable == "hasPixelSeed") value = object->hasPixelSeed;
1413     else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
1414    
1415    
1416     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1417 ahart 1.8
1418 lantonel 1.6 value = applyFunction(function, value);
1419 lantonel 1.1
1420     return value;
1421     }
1422    
1423     double
1424 lantonel 1.3 OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
1425 lantonel 1.1
1426     double value = 0.0;
1427    
1428     if(variable == "energy") value = object->energy;
1429     else if(variable == "et") value = object->et;
1430     else if(variable == "ex") value = object->ex;
1431     else if(variable == "ey") value = object->ey;
1432     else if(variable == "ez") value = object->ez;
1433     else if(variable == "phi") value = object->phi;
1434     else if(variable == "eta") value = object->eta;
1435     else if(variable == "theta") value = object->theta;
1436    
1437    
1438     else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1439 ahart 1.8
1440 lantonel 1.6 value = applyFunction(function, value);
1441 lantonel 1.1
1442     return value;
1443     }
1444    
1445    
1446 lantonel 1.6 double
1447     OSUAnalysis::applyFunction(string function, double value){
1448    
1449 lantonel 1.9 if(function == "abs") value = fabs(value);
1450 lantonel 1.6
1451    
1452     return value;
1453    
1454     }
1455    
1456    
1457 ahart 1.8 template <class InputCollection>
1458 lantonel 1.1 void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
1459    
1460    
1461     for (uint object = 0; object != inputCollection->size(); object++){
1462 ahart 1.8
1463 lantonel 1.1 bool decision = true;//object passes if this cut doesn't cut on that type of object
1464 ahart 1.8
1465     if(currentCut.inputCollection == inputType){
1466    
1467 lantonel 1.3 double value = valueLookup(&inputCollection->at(object), currentCut.variable, currentCut.function);
1468 lantonel 1.1
1469     decision = evaluateComparison(value,currentCut.comparativeOperator,currentCut.cutValue);
1470     }
1471     individualFlags[inputType].at(currentCutIndex).push_back(decision);
1472 ahart 1.8
1473 lantonel 1.1
1474     //set flags for objects that pass each cut AND all the previous cuts
1475     bool previousCumulativeFlag = true;
1476     for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
1477     if(previousCumulativeFlag && individualFlags[inputType].at(previousCutIndex).at(object)) previousCumulativeFlag = true;
1478     else{ previousCumulativeFlag = false; break;}
1479     }
1480     cumulativeFlags[inputType].at(currentCutIndex).push_back(previousCumulativeFlag && decision);
1481 ahart 1.8
1482 lantonel 1.1 }
1483 ahart 1.8
1484 lantonel 1.1 }
1485    
1486    
1487 lantonel 1.9 template <class InputCollection>
1488     void OSUAnalysis::fillHistogram(TH1D* histo, histogram parameters, InputCollection inputCollection){
1489    
1490     for (uint object = 0; object != inputCollection->size(); object++){
1491     double value = valueLookup(&inputCollection->at(object), parameters.inputVariable, parameters.function);
1492     histo->Fill(value);
1493     }
1494    
1495     }
1496    
1497 lantonel 1.1
1498    
1499    
1500     DEFINE_FWK_MODULE(OSUAnalysis);
1501    
1502