ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.11
Committed: Thu Feb 7 15:51:44 2013 UTC (12 years, 2 months ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.10: +18 -10 lines
Log Message:
corrected muon tightID to match twiki

File Contents

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