ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.15
Committed: Wed Feb 13 12:51:49 2013 UTC (12 years, 2 months ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.14: +82 -58 lines
Log Message:
added pile-up reweighting

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