ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
Revision: 1.67
Committed: Tue May 28 21:35:43 2013 UTC (11 years, 11 months ago) by wulsin
Content type: text/plain
Branch: MAIN
CVS Tags: V02-01-01
Changes since 1.66: +16 -11 lines
Log Message:
add secondary jets collection

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