ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.19
Committed: Wed Feb 27 10:45:29 2013 UTC (12 years, 2 months ago) by lantonel
Content type: text/plain
Branch: MAIN
Changes since 1.18: +142 -13 lines
Log Message:
added a bunch of new user-defined variables

File Contents

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