ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
(Generate patch)

Comparing UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc (file contents):
Revision 1.18 by lantonel, Fri Feb 22 10:38:08 2013 UTC vs.
Revision 1.45 by ahart, Thu Apr 11 00:56:48 2013 UTC

# Line 11 | Line 11 | OSUAnalysis::OSUAnalysis (const edm::Par
11    tracks_ (cfg.getParameter<edm::InputTag> ("tracks")),
12    genjets_ (cfg.getParameter<edm::InputTag> ("genjets")),
13    mcparticles_ (cfg.getParameter<edm::InputTag> ("mcparticles")),
14 +  stops_ (cfg.getParameter<edm::InputTag> ("stops")),
15    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    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
20    puFile_ (cfg.getParameter<std::string> ("puFile")),
21 +  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
22 +  muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
23    dataPU_ (cfg.getParameter<std::string> ("dataPU")),
24 +  electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
25 +  muonSF_ (cfg.getParameter<std::string> ("muonSF")),
26    dataset_ (cfg.getParameter<std::string> ("dataset")),
27    datasetType_ (cfg.getParameter<std::string> ("datasetType")),
28    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
29    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
30 <  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents"))
30 >  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
31 >  doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
32 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
33 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
34 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
35  
36   {
37  
38    TH1::SetDefaultSumw2 ();
39  
40    //create pile-up reweighting object, if necessary
41 <  if(datasetType_ != "data") puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
41 >  if(datasetType_ != "data") {
42 >    if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
43 >    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
44 >    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
45 >  }
46 > #ifdef DISPLACED_SUSY
47 >  if (datasetType_ == "signalMC")
48 >    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
49 > #endif
50 >
51  
52    // Construct Cutflow Objects. These store the results of cut decisions and
53    // handle filling cut flow histograms.
# Line 37 | Line 55 | OSUAnalysis::OSUAnalysis (const edm::Par
55    std::vector<TFileDirectory> directories;
56  
57    //always get vertex collection so we can assign the primary vertex in the event
58 <  allNecessaryObjects.push_back("primaryvertexs");
58 >  objectsToGet.push_back("primaryvertexs");
59 >
60    //always make the plot of number of primary verticex (to check pile-up reweighting)
61    objectsToPlot.push_back("primaryvertexs");
62  
63 +  //always get the MC particles to do GEN-matching
64 +  objectsToGet.push_back("mcparticles");
65 +
66    //always get the event collection to do pile-up reweighting
67 <  allNecessaryObjects.push_back("events");
67 >  objectsToGet.push_back("events");
68  
69    //parse the histogram definitions
70    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
71  
72      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
73      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
74 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
74 >    if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
75 >    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
76 >      objectsToGet.push_back(tempInputCollection);
77        objectsToPlot.push_back(tempInputCollection);
78 <      allNecessaryObjects.push_back(tempInputCollection);
78 >      objectsToCut.push_back(tempInputCollection);
79      }
80 <    else{//pair of objects, need to add them both to the things to allNecessaryObjects
80 >    else{//pair of objects, need to add them both to the things to objectsToGet
81        int dashIndex = tempInputCollection.find("-");
82        int spaceIndex = tempInputCollection.find(" ");
83        int secondWordLength = spaceIndex - dashIndex;
84 <      allNecessaryObjects.push_back(tempInputCollection);
85 <      allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
86 <      allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
84 >      objectsToGet.push_back(tempInputCollection);
85 >      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
86 >      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
87        objectsToPlot.push_back(tempInputCollection);
88        objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
89        objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
90 <      }
90 >      objectsToCut.push_back(tempInputCollection);
91 >      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
92 >      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
93 >
94 >    }
95  
96      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
97 <    
97 >
98      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
99  
100        histogram tempHistogram;
# Line 75 | Line 103 | OSUAnalysis::OSUAnalysis (const edm::Par
103        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
104        tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
105        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
106 <      
106 >
107        histograms.push_back(tempHistogram);
108  
109      }
110    }
111 <  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object
111 >  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
112    sort( objectsToPlot.begin(), objectsToPlot.end() );
113    objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
114  
115  
116  
117 +  //add histograms with the gen-matched id, mother id, and grandmother id
118 +  for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
119 +
120 +    string currentObject = objectsToPlot.at(currentObjectIndex);
121 +    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
122 +
123 +    histogram tempIdHisto;
124 +    histogram tempMomIdHisto;
125 +    histogram tempGmaIdHisto;
126 +    histogram tempIdVsMomIdHisto;
127 +
128 +    tempIdHisto.inputCollection = currentObject;
129 +    tempMomIdHisto.inputCollection = currentObject;
130 +    tempGmaIdHisto.inputCollection = currentObject;
131 +    tempIdVsMomIdHisto.inputCollection = currentObject;
132 +
133 +    currentObject = currentObject.substr(0, currentObject.size()-1);
134 +    tempIdHisto.name = currentObject+"GenMatchId";
135 +    tempMomIdHisto.name = currentObject+"GenMatchMotherId";
136 +    tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
137 +    tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
138 +
139 +    currentObject.at(0) = toupper(currentObject.at(0));
140 +    tempIdHisto.title = currentObject+" Gen-matched Particle";
141 +    tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
142 +    tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
143 +    tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
144 +
145 +    int maxNum = 24;
146 +    vector<double> binVector;
147 +    binVector.push_back(maxNum);
148 +    binVector.push_back(0);
149 +    binVector.push_back(maxNum);
150 +
151 +    tempIdHisto.bins = binVector;
152 +    tempIdHisto.inputVariables.push_back("genMatchedId");
153 +    tempMomIdHisto.bins = binVector;
154 +    tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
155 +    tempGmaIdHisto.bins = binVector;
156 +    tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
157 +    binVector.push_back(maxNum);
158 +    binVector.push_back(0);
159 +    binVector.push_back(maxNum);
160 +    tempIdVsMomIdHisto.bins = binVector;
161 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
162 +    tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
163 +
164 +    histograms.push_back(tempIdHisto);
165 +    histograms.push_back(tempMomIdHisto);
166 +    histograms.push_back(tempGmaIdHisto);
167 +    histograms.push_back(tempIdVsMomIdHisto);
168 +  }
169 +
170  
171    channel tempChannel;
172    //loop over all channels (event selections)
# Line 104 | Line 185 | OSUAnalysis::OSUAnalysis (const edm::Par
185        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
186        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
187          tempChannel.triggers.push_back(triggerNames.at(trigger));
188 <      allNecessaryObjects.push_back("triggers");
188 >      objectsToGet.push_back("triggers");
189      }
190  
191  
# Line 123 | Line 204 | OSUAnalysis::OSUAnalysis (const edm::Par
204      twoDHists_.push_back(twoDhistoMap);
205  
206  
207 +
208      //book all histograms included in the configuration
209      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
210        histogram currentHistogram = histograms.at(currentHistogramIndex);
# Line 130 | Line 212 | OSUAnalysis::OSUAnalysis (const edm::Par
212        int numInputVariables = currentHistogram.inputVariables.size();
213  
214        if(numBinsElements != 3 && numBinsElements !=6) {
215 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
216 <        exit(0);
215 >        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
216 >        exit(0);
217        }
218        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
219 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
220 <        exit(0);
219 >        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
220 >        exit(0);
221        }
222        else if(numBinsElements == 3){
223 <        oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
223 >        oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
224        }
225        else if(numBinsElements == 6){
226 <        twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
226 >        twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
227  
228        }
229  
230  
231 +      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
232 +
233 +      // bin      particle type
234 +      // ---      -------------
235 +      //  0        unmatched
236 +      //  1        u
237 +      //  2        d
238 +      //  3        s
239 +      //  4        c
240 +      //  5        b
241 +      //  6        t
242 +      //  7        e
243 +      //  8        mu
244 +      //  9        tau
245 +      // 10        nu
246 +      // 11        g
247 +      // 12        gamma
248 +      // 13        Z
249 +      // 14        W
250 +      // 15        light meson
251 +      // 16        K meson
252 +      // 17        D meson
253 +      // 18        B meson
254 +      // 19        light baryon
255 +      // 20        strange baryon
256 +      // 21        charm baryon
257 +      // 22        bottom baryon
258 +      // 23        other
259 +
260 +      vector<TString> labelArray;
261 +      labelArray.push_back("unmatched");
262 +      labelArray.push_back("u");
263 +      labelArray.push_back("d");
264 +      labelArray.push_back("s");
265 +      labelArray.push_back("c");
266 +      labelArray.push_back("b");
267 +      labelArray.push_back("t");
268 +      labelArray.push_back("e");
269 +      labelArray.push_back("#mu");
270 +      labelArray.push_back("#tau");
271 +      labelArray.push_back("#nu");
272 +      labelArray.push_back("g");
273 +      labelArray.push_back("#gamma");
274 +      labelArray.push_back("Z");
275 +      labelArray.push_back("W");
276 +      labelArray.push_back("light meson");
277 +      labelArray.push_back("K meson");
278 +      labelArray.push_back("D meson");
279 +      labelArray.push_back("B meson");
280 +      labelArray.push_back("light baryon");
281 +      labelArray.push_back("strange baryon");
282 +      labelArray.push_back("charm baryon");
283 +      labelArray.push_back("bottom baryon");
284 +      labelArray.push_back("other");
285 +
286 +      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
287 +        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
288 +          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
289 +        }
290 +        else {
291 +          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
292 +          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
293 +        }
294 +      }
295 +      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
296 +        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
297 +        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
298 +      }
299 +
300      }
301 <    //book a histogram for the number of each object type to be plotted
301 >
302 >    // Book a histogram for the number of each object type to be plotted.  
303 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
304      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
305        string currentObject = objectsToPlot.at(currentObjectIndex);
306        int maxNum = 10;
# Line 155 | Line 308 | OSUAnalysis::OSUAnalysis (const edm::Par
308        else if(currentObject == "primaryvertexs") maxNum = 50;
309        else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
310        else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
311 <      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
312 <
313 <      currentObject.at(0) = toupper(currentObject.at(0));
311 >      else if(currentObject == "electron-muon pairs")     currentObject = "electronMuonPairs";
312 >      else if(currentObject == "track-event pairs")       currentObject = "trackEventPairs";
313 >      else if(currentObject == "electron-track pairs")    currentObject = "electronTrackPairs";  
314 >      else if(currentObject == "muon-track pairs")        currentObject = "muonTrackPairs";      
315 >      else if(currentObject == "muon-tau pairs")          currentObject = "muonTauPairs";        
316 >      else if(currentObject == "tau-tau pairs")           currentObject = "ditauPairs";
317 >      currentObject.at(0) = toupper(currentObject.at(0));  
318        string histoName = "num" + currentObject;
319  
320        if(histoName == "numPrimaryvertexs"){
321 <        string newHistoName = histoName + "BeforePileupCorrection";
322 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);    
323 <        newHistoName = histoName + "AfterPileupCorrection";
324 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
321 >        string newHistoName = histoName + "BeforePileupCorrection";
322 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
323 >        newHistoName = histoName + "AfterPileupCorrection";
324 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
325        }
326        else
327 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
327 >        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
328      }
329  
330  
331 +
332 +
333      //get list of cuts for this channel
334      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
335  
# Line 180 | Line 339 | OSUAnalysis::OSUAnalysis (const edm::Par
339        //store input collection for cut
340        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
341        tempCut.inputCollection = tempInputCollection;
342 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
343 <        allNecessaryObjects.push_back(tempInputCollection);
344 <      }
345 <      else{//pair of objects, need to add them both to the things to allNecessaryObjects
346 <        int dashIndex = tempInputCollection.find("-");
347 <        int spaceIndex = tempInputCollection.find(" ");
348 <        int secondWordLength = spaceIndex - dashIndex;
349 <        allNecessaryObjects.push_back(tempInputCollection);
350 <        allNecessaryObjects.push_back(tempInputCollection.substr(0,dashIndex)+"s");
351 <        allNecessaryObjects.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
342 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
343 >        objectsToGet.push_back(tempInputCollection);
344 >        objectsToCut.push_back(tempInputCollection);
345 >      }
346 >      else{//pair of objects, need to add them both to the things to objectsToGet
347 >        int dashIndex = tempInputCollection.find("-");
348 >        int spaceIndex = tempInputCollection.find(" ");
349 >        int secondWordLength = spaceIndex - dashIndex;
350 >        objectsToGet.push_back(tempInputCollection);
351 >        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
352 >        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
353 >        objectsToCut.push_back(tempInputCollection);
354 >        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
355 >        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
356  
357        }
358  
# Line 199 | Line 362 | OSUAnalysis::OSUAnalysis (const edm::Par
362        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
363        std::vector<string> cutStringVector = splitString(cutString);
364        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
365 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
366 <        exit(0);
365 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
366 >        exit(0);
367        }
368        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
369        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
370 <        int indexOffset = 4 * subcutIndex;
371 <        string currentVariableString = cutStringVector.at(indexOffset);
372 <        if(currentVariableString.find("(")==std::string::npos){
373 <          tempCut.functions.push_back("");//no function was specified
374 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
375 <        }
376 <        else{
377 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
378 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
379 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
380 <        }
381 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
382 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
383 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
370 >        int indexOffset = 4 * subcutIndex;
371 >        string currentVariableString = cutStringVector.at(indexOffset);
372 >        if(currentVariableString.find("(")==std::string::npos){
373 >          tempCut.functions.push_back("");//no function was specified
374 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
375 >        }
376 >        else{
377 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
378 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
379 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
380 >        }
381 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
382 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
383 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
384        }
385  
386        //get number of objects required to pass cut for event to pass
387        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
388        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
389        if(numberRequiredVector.size()!=2){
390 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
390 >        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
391          exit(0);
392        }
393  
# Line 259 | Line 422 | OSUAnalysis::OSUAnalysis (const edm::Par
422    }//end loop over channels
423  
424  
425 <  //make unique vector of objects we need to cut on (so we make sure to get them from the event)
426 <  sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
427 <  allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
425 >  //make unique vector of objects we need to get from the event
426 >  sort( objectsToGet.begin(), objectsToGet.end() );
427 >  objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
428 >  //make unique vector of objects we need to cut on
429 >  sort( objectsToCut.begin(), objectsToCut.end() );
430 >  objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
431  
432  
433   }
# Line 279 | Line 445 | void
445   OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
446   {
447  
282
448    // Retrieve necessary collections from the event.
449 <  edm::Handle<BNtriggerCollection> triggers;
450 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
449 >
450 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
451      event.getByLabel (triggers_, triggers);
452  
453 <  edm::Handle<BNjetCollection> jets;
289 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
453 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
454      event.getByLabel (jets_, jets);
455  
456 <  edm::Handle<BNmuonCollection> muons;
293 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
456 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
457      event.getByLabel (muons_, muons);
458  
459 <  edm::Handle<BNelectronCollection> electrons;
297 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
459 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
460      event.getByLabel (electrons_, electrons);
461  
462 <  edm::Handle<BNeventCollection> events;
301 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
462 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
463      event.getByLabel (events_, events);
464  
465 <  edm::Handle<BNtauCollection> taus;
305 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
465 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
466      event.getByLabel (taus_, taus);
467  
468 <  edm::Handle<BNmetCollection> mets;
309 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
468 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
469      event.getByLabel (mets_, mets);
470  
471 <  edm::Handle<BNtrackCollection> tracks;
313 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
471 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
472      event.getByLabel (tracks_, tracks);
473  
474 <  edm::Handle<BNgenjetCollection> genjets;
317 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
474 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
475      event.getByLabel (genjets_, genjets);
476  
477 <  edm::Handle<BNmcparticleCollection> mcparticles;
321 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
477 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
478      event.getByLabel (mcparticles_, mcparticles);
479  
480 <  edm::Handle<BNprimaryvertexCollection> primaryvertexs;
325 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
480 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
481      event.getByLabel (primaryvertexs_, primaryvertexs);
482  
483 <  edm::Handle<BNbxlumiCollection> bxlumis;
329 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
483 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
484      event.getByLabel (bxlumis_, bxlumis);
485  
486 <  edm::Handle<BNphotonCollection> photons;
333 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
486 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
487      event.getByLabel (photons_, photons);
488  
489 <  edm::Handle<BNsuperclusterCollection> superclusters;
337 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
489 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
490      event.getByLabel (superclusters_, superclusters);
491  
492 +  if (useTrackCaloRhoCorr_) {  
493 +    // Used only for pile-up correction of by-hand calculation of isolation energy.  
494 +    // This rho collection is not available in all BEANs.  
495 +    // For description of rho values for different jet reconstruction algorithms, see
496 +    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
497 +    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
498 +  }
499 +
500  
501    //get pile-up event weight
502 <  double puScaleFactor = 0;
503 <  if(datasetType_ != "data")
504 <    puScaleFactor = puWeight_->at (events->at (0).numTruePV);
505 <  else
506 <    puScaleFactor = 1.00;
507 <
502 >  double scaleFactor = 1.00;
503 >  if(doPileupReweighting_ && datasetType_ != "data")
504 >    scaleFactor = puWeight_->at (events->at (0).numTruePV);
505 >
506 >  cTauScaleFactor_ = 1.0;
507 > #ifdef DISPLACED_SUSY
508 >  if (datasetType_ == "signalMC")
509 >    cTauScaleFactor_ = cTauWeight_->at (event);
510 > #endif
511 >  scaleFactor *= cTauScaleFactor_;
512  
513    //loop over all channels
514  
# Line 352 | Line 516 | OSUAnalysis::analyze (const edm::Event &
516      channel currentChannel = channels.at(currentChannelIndex);
517  
518      flagMap individualFlags;
355    flagMap cumulativeFlags;
519      counterMap passingCounter;
520 +    cumulativeFlags.clear ();
521  
522      bool triggerDecision = true;
523      if(currentChannel.triggers.size() != 0){  //triggers specified
# Line 362 | Line 526 | OSUAnalysis::analyze (const edm::Event &
526      }
527  
528      //loop over all cuts
529 +
530 +
531 +
532      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
533        cut currentCut = currentChannel.cuts.at(currentCutIndex);
534  
535 <      for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
536 <        string currentObject = allNecessaryObjects.at(currentObjectIndex);
535 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
536 >        string currentObject = objectsToCut.at(currentObjectIndex);
537  
538 +        //initialize maps to get ready to set cuts
539          individualFlags[currentObject].push_back (vector<bool> ());
540          cumulativeFlags[currentObject].push_back (vector<bool> ());
541  
542 +      }
543 +      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
544 +        string currentObject = objectsToCut.at(currentObjectIndex);
545 +
546 +        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
547 +
548  
549          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
550          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
# Line 386 | Line 560 | OSUAnalysis::analyze (const edm::Event &
560          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
561          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
562  
389        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(),"muon-muon pairs");
390        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(),"electron-electron pairs");
391        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(),"electron-muon pairs");
563  
564 +        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
565 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
566 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
567 +                                                                   "muon-muon pairs");
568 +        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
569 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
570 +                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
571 +                                                                           "electron-electron pairs");
572 +        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
573 +                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
574 +                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
575 +                                                                       "electron-muon pairs");
576 +        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
577 +                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
578 +                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
579 +                                                                     "track-event pairs");
580 +        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
581 +                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
582 +                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
583 +                                                                        "electron-track pairs");
584 +        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
585 +                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
586 +                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
587 +                                                                    "muon-track pairs");
588 +        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
589 +                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
590 +                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
591 +                                                                  "muon-tau pairs");
592 +        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(),
593 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
594 +                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
595 +                                                                 "tau-tau pairs");
596 +        
597 +        
598        }
599  
600  
# Line 397 | Line 602 | OSUAnalysis::analyze (const edm::Event &
602      }//end loop over all cuts
603  
604  
400
605      //use cumulative flags to apply cuts at event level
606  
607      bool eventPassedAllCuts = true;
# Line 406 | Line 610 | OSUAnalysis::analyze (const edm::Event &
610      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
611  
612  
613 +
614      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
615  
616        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 413 | Line 618 | OSUAnalysis::analyze (const edm::Event &
618        int numberPassing = 0;
619  
620        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
621 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
621 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
622        }
623  
624        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
# Line 423 | Line 628 | OSUAnalysis::analyze (const edm::Event &
628  
629      }
630  
631 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(puScaleFactor);
631 >    //     if(datasetType_ != "data") {
632 >    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
633 >    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
634 >    //     }
635  
636 <
429 <
430 <    if(!eventPassedAllCuts)continue;
636 >    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
637  
638  
639  
640 +    if(!eventPassedAllCuts)continue;
641  
642 <    //set position of primary vertex in event, in order to calculate quantities relative to it
643 <    primaryVertex_ = 0;
644 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back();
645 <    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
646 <      if(!vertexFlags.at(vertexIndex)) continue;
647 <      primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex));
648 <      break;
642 >    if (printEventInfo_) {
643 >      // Write information about event to screen, for testing purposes.  
644 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
645 >           << ": run="  << events->at(0).run
646 >           << "  lumi=" << events->at(0).lumi
647 >           << "  event=" << events->at(0).evt
648 >           << endl;  
649      }
650  
651  
445
652      //filling histograms
653      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
654        histogram currentHistogram = histograms.at(histogramIndex);
655  
656        if(currentHistogram.inputVariables.size() == 1){
657 <        TH1D* histo;
658 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
659 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
660 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
661 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),\
662 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(),\
663 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
664 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
665 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
666 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
667 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
668 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
669 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
670 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
671 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
672 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
673 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
674 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
675 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
676 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
677 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
678 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
679 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
680 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
657 >        TH1D* histo;
658 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
659 >
660 >
661 >
662 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
663 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
664 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
665 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
666 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
667 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
668 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
669 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
670 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
671 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
672 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
673 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
674 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
675 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
676 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
677 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
678 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
679 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
680 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
681 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
682 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
683 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
684 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
685 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
686 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
687 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
688 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
689 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
690 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
691 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
692 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
693 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
694 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
695 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
696        }
697        else if(currentHistogram.inputVariables.size() == 2){
698 <        TH2D* histo;
699 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
700 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),puScaleFactor);
701 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),puScaleFactor);
481 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
482 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
483 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),puScaleFactor);
484 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),puScaleFactor);
485 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
486 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
487 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),puScaleFactor);
488 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
489 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
490 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),puScaleFactor);
491 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),puScaleFactor);
492 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),puScaleFactor);
493 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),puScaleFactor);
494 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),puScaleFactor);
495 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),puScaleFactor);
496 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),puScaleFactor);
497 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),puScaleFactor);
498 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),puScaleFactor);
499 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),puScaleFactor);
500 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),puScaleFactor);
501 <      }
502 <    }
698 >        TH2D* histo;
699 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
700 >
701 >
702  
703 +        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
704 +        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
705 +        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
706 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
707 +                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
708 +        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
709 +        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
710 +                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
711 +                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
712 +        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
713 +                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
714 +                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
715 +        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
716 +                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
717 +                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
718 +        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
719 +                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
720 +                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
721 +        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
722 +                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
723 +                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
724 +        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
725 +                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
726 +                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
727 +        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
728 +        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
729 +        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
730 +        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
731 +        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
732 +                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
733 +                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
734 +        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
735 +        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
736 +        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
737 +        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
738 +        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
739 +        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
740 +      }
741 +    }
742  
743      //fills histograms with the sizes of collections
744      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
745 +
746        string currentObject = objectsToPlot.at(currentObjectIndex);
747  
748 <      if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
749 <      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
750 <      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
751 <      string tempCurrentObject = currentObject;
752 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
748 >      string objectToPlot = "";  
749 >
750 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
751 >      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
752 >      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
753 >      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
754 >      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
755 >      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
756 >      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
757 >      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
758 >      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
759 >      else objectToPlot = currentObject;
760 >      string tempCurrentObject = objectToPlot;
761 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
762        string histoName = "num" + tempCurrentObject;
763  
764  
765 <      if(currentObject == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),puScaleFactor);
766 <      else if(currentObject == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),puScaleFactor);
767 <      else if(currentObject == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,puScaleFactor);
768 <      else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),puScaleFactor);
769 <      else if(currentObject == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,puScaleFactor);
770 <      else if(currentObject == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),puScaleFactor);
771 <      else if(currentObject == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),puScaleFactor);
772 <      else if(currentObject == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),puScaleFactor);
773 <      else if(currentObject == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),puScaleFactor);
774 <      else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),puScaleFactor);
775 <      else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),puScaleFactor);
776 <      else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),puScaleFactor);
777 <      else if(currentObject == "primaryvertexs"){
778 <        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
779 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),puScaleFactor);
780 <      }
781 <      else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),puScaleFactor);
782 <      else if(currentObject == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),puScaleFactor);
783 <      else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),puScaleFactor);
765 >      //set position of primary vertex in event, in order to calculate quantities relative to it
766 >      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
767 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
768 >        int numToPlot = 0;
769 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
770 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
771 >        }
772 >        if(objectToPlot == "primaryvertexs"){
773 >          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
774 >          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
775 >        }
776 >        else {
777 >          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
778 >        }
779 >      }
780 >      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
781 >      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
782 >      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
783 >      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
784 >      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
785 >      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
786 >      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
787 >      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
788 >      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
789 >      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
790 >      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
791 >      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
792 >      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
793 >      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
794 >      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
795 >      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
796 >      else if(objectToPlot == "primaryvertexs"){
797 >        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
798 >        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
799 >      }
800  
801 <    }
538 <  } //end loop over channel
801 >    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
802  
803 <  masterCutFlow_->fillCutFlow(puScaleFactor);
803 >  } //end loop over channel
804  
805 +  masterCutFlow_->fillCutFlow(scaleFactor);
806  
807 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
808  
544 }
809  
810  
811   bool
# Line 736 | Line 1000 | OSUAnalysis::valueLookup (const BNmuon*
1000    else if(variable == "ecalIso") value = object->ecalIso;
1001    else if(variable == "hcalIso") value = object->hcalIso;
1002    else if(variable == "caloIso") value = object->caloIso;
1003 <  else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
1003 >  else if(variable == "trackIsDR03") value = object->trackIsoDR03;
1004    else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
1005    else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
1006    else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
# Line 875 | Line 1139 | OSUAnalysis::valueLookup (const BNmuon*
1139    else if(variable == "time_ndof") value = object->time_ndof;
1140  
1141    //user-defined variables
1142 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1143 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1144 <  else if(variable == "detIso") value = (object->trackIso) / object->pt;
1145 <  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1142 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1143 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1144 >  else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1145 >  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1146    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1147 +  else if(variable == "metMT") {
1148 +    const BNmet *met = chosenMET ();
1149 +    if (met)
1150 +      {
1151 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1152 +          p2 (met->px, met->py, 0.0, met->pt);
1153 +
1154 +        value = (p1 + p2).Mt ();
1155 +      }
1156 +    else
1157 +      value = -999;
1158 +  }
1159 +
1160 +
1161 +
1162 +  else if(variable == "correctedD0VertexInEBPlus"){
1163 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1164 +    else value = -999;
1165 +  }
1166 +  else if(variable == "correctedD0VertexOutEBPlus"){
1167 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1168 +    else value = -999;
1169 +  }
1170 +  else if(variable == "correctedD0VertexEEPlus"){
1171 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1172 +    else value = -999;
1173 +  }
1174 +
1175 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1176 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1177 +    else value = -999;
1178 +  }
1179 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1180 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1181 +    else value = -999;
1182 +  }
1183 +  else if(variable == "correctedD0BeamspotEEPlus"){
1184 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1185 +    else value = -999;
1186 +  }
1187 +
1188 +  else if(variable == "correctedD0VertexInEBMinus"){
1189 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1190 +    else value = -999;
1191 +  }
1192 +  else if(variable == "correctedD0VertexOutEBMinus"){
1193 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1194 +    else value = -999;
1195 +  }
1196 +  else if(variable == "correctedD0VertexEEMinus"){
1197 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1198 +    else value = -999;
1199 +  }
1200 +
1201 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1202 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1203 +    else value = -999;
1204 +  }
1205 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1206 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1207 +    else value = -999;
1208 +  }
1209 +  else if(variable == "correctedD0BeamspotEEMinus"){
1210 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1211 +    else value = -999;
1212 +  }
1213 +
1214 +
1215 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1216 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1217 +    else value = -999;
1218 +  }
1219 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1220 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1221 +    else value = -999;
1222 +  }
1223 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1224 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1225 +    else value = -999;
1226 +  }
1227 +
1228 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1229 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1230 +    else value = -999;
1231 +  }
1232 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1233 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1234 +    else value = -999;
1235 +  }
1236 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1237 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1238 +    else value = -999;
1239 +  }
1240 +
1241 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1242 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1243 +    else value = -999;
1244 +  }
1245 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1246 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1247 +    else value = -999;
1248 +  }
1249 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1250 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1251 +    else value = -999;
1252 +  }
1253 +
1254 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1255 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1256 +    else value = -999;
1257 +  }
1258 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1259 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1260 +    else value = -999;
1261 +  }
1262 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1263 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1264 +    else value = -999;
1265 +  }
1266 +
1267 +
1268    else if(variable == "tightID") {
1269 <    value = object->isGlobalMuon > 0            \
1270 <      && object->isPFMuon > 0                   \
1271 <      && object->normalizedChi2 < 10            \
1272 <      && object->numberOfValidMuonHits > 0      \
1273 <      && object->numberOfMatchedStations > 1    \
1274 <      && fabs(object->correctedD0Vertex) < 0.2  \
1275 <      && fabs(object->correctedDZ) < 0.5        \
1276 <      && object->numberOfValidPixelHits > 0     \
1269 >    value = object->isGlobalMuon > 0                \
1270 >      && object->isPFMuon > 0                        \
1271 >      && object->normalizedChi2 < 10                \
1272 >                                  && object->numberOfValidMuonHits > 0        \
1273 >      && object->numberOfMatchedStations > 1        \
1274 >      && fabs(object->correctedD0Vertex) < 0.2        \
1275 >      && fabs(object->correctedDZ) < 0.5        \
1276 >      && object->numberOfValidPixelHits > 0                \
1277        && object->numberOfLayersWithMeasurement > 5;
893    
894
1278    }
1279    else if(variable == "tightIDdisplaced"){
1280 <    value = object->isGlobalMuon > 0            \
1281 <      && object->isPFMuon > 0                   \
1282 <      && object->normalizedChi2 < 10            \
1283 <      && object->numberOfValidMuonHits > 0      \
1284 <      && object->numberOfMatchedStations > 1    \
902 <      && object->numberOfValidPixelHits > 0     \
1280 >    value = object->isGlobalMuon > 0                \
1281 >      && object->normalizedChi2 < 10                \
1282 >                                  && object->numberOfValidMuonHits > 0        \
1283 >      && object->numberOfMatchedStations > 1        \
1284 >      && object->numberOfValidPixelHits > 0        \
1285        && object->numberOfLayersWithMeasurement > 5;
1286    }
1287  
1288 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1289 +
1290 +  else if(variable == "genMatchedPdgId"){
1291 +    int index = getGenMatchedParticleIndex(object);
1292 +    if(index == -1) value = 0;
1293 +    else value = mcparticles->at(index).id;
1294 +  }
1295 +
1296 +  else if(variable == "genMatchedId"){
1297 +    int index = getGenMatchedParticleIndex(object);
1298 +    if(index == -1) value = 0;
1299 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1300 +  }
1301 +  else if(variable == "genMatchedMotherId"){
1302 +    int index = getGenMatchedParticleIndex(object);
1303 +    if(index == -1) value = 0;
1304 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1305 +  }
1306 +  else if(variable == "genMatchedMotherIdReverse"){
1307 +    int index = getGenMatchedParticleIndex(object);
1308 +    if(index == -1) value = 23;
1309 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1310 +  }
1311 +  else if(variable == "genMatchedGrandmotherId"){
1312 +    int index = getGenMatchedParticleIndex(object);
1313 +    if(index == -1) value = 0;
1314 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1315 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1316 +      if(motherIndex == -1) value = 0;
1317 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1318 +    }
1319 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1320 +  }
1321 +
1322 +
1323 +
1324    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1325  
1326    value = applyFunction(function, value);
# Line 1073 | Line 1491 | OSUAnalysis::valueLookup (const BNelectr
1491    else if(variable == "passConvVeto") value = object->passConvVeto;
1492  
1493    //user-defined variables
1494 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1495 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1494 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1495 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1496    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1497    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1498 +  else if(variable == "metMT") {
1499 +    const BNmet *met = chosenMET ();
1500 +    if (met)
1501 +      {
1502 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1503 +          p2 (met->px, met->py, 0.0, met->pt);
1504 +
1505 +        value = (p1 + p2).Mt ();
1506 +      }
1507 +    else
1508 +      value = -999;
1509 +  }
1510 +
1511 +  else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1512 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
1513 +    else value = -999;
1514 +  }
1515 +  else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
1516 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
1517 +    else value = -999;
1518 +  }
1519 +
1520 +  else if(variable == "correctedD0VertexInEBPlus"){
1521 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1522 +    else value = -999;
1523 +  }
1524 +  else if(variable == "correctedD0VertexOutEBPlus"){
1525 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1526 +    else value = -999;
1527 +  }
1528 +  else if(variable == "correctedD0VertexEEPlus"){
1529 +    if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
1530 +    else value = -999;
1531 +  }
1532 +
1533 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1534 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1535 +    else value = -999;
1536 +  }
1537 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1538 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1539 +    else value = -999;
1540 +  }
1541 +  else if(variable == "correctedD0BeamspotEEPlus"){
1542 +    if(object->isEE && object->eta > 0) value = object->correctedD0;
1543 +    else value = -999;
1544 +  }
1545 +
1546 +  else if(variable == "correctedD0VertexInEBMinus"){
1547 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1548 +    else value = -999;
1549 +  }
1550 +  else if(variable == "correctedD0VertexOutEBMinus"){
1551 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1552 +    else value = -999;
1553 +  }
1554 +  else if(variable == "correctedD0VertexEEMinus"){
1555 +    if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
1556 +    else value = -999;
1557 +  }
1558 +
1559 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1560 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1561 +    else value = -999;
1562 +  }
1563 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1564 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1565 +    else value = -999;
1566 +  }
1567 +  else if(variable == "correctedD0BeamspotEEMinus"){
1568 +    if(object->isEE && object->eta < 0) value = object->correctedD0;
1569 +    else value = -999;
1570 +  }
1571 +
1572 +  else if(variable == "tightID"){
1573 +    if (object->isEB)
1574 +      {
1575 +        value = fabs(object->delEtaIn) < 0.004 \
1576 +          && fabs (object->delPhiIn) < 0.03 \
1577 +          && object->scSigmaIEtaIEta < 0.01 \
1578 +          && object->hadOverEm < 0.12 \
1579 +          && fabs (object->correctedD0Vertex) < 0.02 \
1580 +          && fabs (object->correctedDZ) < 0.1 \
1581 +          && object->absInvEMinusInvPin < 0.05 \
1582 +          && object->passConvVeto;
1583 +      }
1584 +    else
1585 +      {
1586 +        value = fabs(object->delEtaIn) < 0.005 \
1587 +          && fabs (object->delPhiIn) < 0.02 \
1588 +          && object->scSigmaIEtaIEta < 0.03 \
1589 +          && object->hadOverEm < 0.10 \
1590 +          && fabs (object->correctedD0Vertex) < 0.02 \
1591 +          && fabs (object->correctedDZ) < 0.1 \
1592 +          && object->absInvEMinusInvPin < 0.05 \
1593 +          && object->passConvVeto;
1594 +      }
1595 +  }
1596 +
1597 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1598 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1599 +    else value = -999;
1600 +  }
1601 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1602 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1603 +    else value = -999;
1604 +  }
1605 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1606 +    if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
1607 +    else value = -999;
1608 +  }
1609 +
1610 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1611 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1612 +    else value = -999;
1613 +  }
1614 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1615 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1616 +    else value = -999;
1617 +  }
1618 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1619 +    if(object->isEE && object->charge > 0) value = object->correctedD0;
1620 +    else value = -999;
1621 +  }
1622 +
1623 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1624 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1625 +    else value = -999;
1626 +  }
1627 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1628 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1629 +    else value = -999;
1630 +  }
1631 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1632 +    if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
1633 +    else value = -999;
1634 +  }
1635 +
1636 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1637 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1638 +    else value = -999;
1639 +  }
1640 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1641 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1642 +    else value = -999;
1643 +  }
1644 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1645 +    if(object->isEE && object->charge < 0) value = object->correctedD0;
1646 +    else value = -999;
1647 +  }
1648 +
1649 +
1650 +  else if(variable == "tightIDdisplaced"){
1651 +    if (object->isEB)
1652 +      {
1653 +        value = fabs(object->delEtaIn) < 0.004 \
1654 +          && fabs (object->delPhiIn) < 0.03 \
1655 +          && object->scSigmaIEtaIEta < 0.01 \
1656 +          && object->hadOverEm < 0.12 \
1657 +          && object->absInvEMinusInvPin < 0.05;
1658 +      }
1659 +    else
1660 +      {
1661 +        value = fabs (object->delEtaIn) < 0.005 \
1662 +          && fabs (object->delPhiIn) < 0.02 \
1663 +          && object->scSigmaIEtaIEta < 0.03 \
1664 +          && object->hadOverEm < 0.10 \
1665 +          && object->absInvEMinusInvPin < 0.05;
1666 +      }
1667 +  }
1668 +
1669 +
1670 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1671 +
1672 +  else if(variable == "genMatchedPdgId"){
1673 +    int index = getGenMatchedParticleIndex(object);
1674 +    if(index == -1) value = 0;
1675 +    else value = mcparticles->at(index).id;
1676 +  }
1677 +
1678 +
1679 +  else if(variable == "genMatchedId"){
1680 +    int index = getGenMatchedParticleIndex(object);
1681 +    if(index == -1) value = 0;
1682 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1683 +  }
1684 +  else if(variable == "genMatchedMotherId"){
1685 +    int index = getGenMatchedParticleIndex(object);
1686 +    if(index == -1) value = 0;
1687 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1688 +  }
1689 +  else if(variable == "genMatchedMotherIdReverse"){
1690 +    int index = getGenMatchedParticleIndex(object);
1691 +    if(index == -1) value = 23;
1692 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1693 +  }
1694 +  else if(variable == "genMatchedGrandmotherId"){
1695 +    int index = getGenMatchedParticleIndex(object);
1696 +    if(index == -1) value = 0;
1697 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1698 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1699 +      if(motherIndex == -1) value = 0;
1700 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1701 +    }
1702 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1703 +  }
1704 +
1705  
1706  
1707    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1156 | Line 1781 | OSUAnalysis::valueLookup (const BNevent*
1781    else if(variable == "id1") value = object->id1;
1782    else if(variable == "id2") value = object->id2;
1783    else if(variable == "evt") value = object->evt;
1784 +  else if(variable == "puScaleFactor"){
1785 +    if(datasetType_ != "data")
1786 +      value = puWeight_->at (events->at (0).numTruePV);
1787 +    else
1788 +      value = 1.0;
1789 +  }
1790 +  else if(variable == "muonScaleFactor"){
1791 +    if(datasetType_ != "data")
1792 +      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1793 +      value = 1.0;
1794 +    else
1795 +      value = 1.0;
1796 +  }
1797 +  else if(variable == "electronScaleFactor"){
1798 +    if(datasetType_ != "data")
1799 +      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1800 +      value = 1.0;
1801 +    else
1802 +      value = 1.0;
1803 +  }
1804 +  else if(variable == "cTauScaleFactor")
1805 +    value = cTauScaleFactor_;
1806  
1807    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1808  
# Line 1210 | Line 1857 | OSUAnalysis::valueLookup (const BNtau* o
1857    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1858  
1859  
1860 +
1861 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1862 +
1863 +  else if(variable == "genMatchedPdgId"){
1864 +    int index = getGenMatchedParticleIndex(object);
1865 +    if(index == -1) value = 0;
1866 +    else value = mcparticles->at(index).id;
1867 +  }
1868 +
1869 +  else if(variable == "genMatchedId"){
1870 +    int index = getGenMatchedParticleIndex(object);
1871 +    if(index == -1) value = 0;
1872 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1873 +  }
1874 +  else if(variable == "genMatchedMotherId"){
1875 +    int index = getGenMatchedParticleIndex(object);
1876 +    if(index == -1) value = 0;
1877 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1878 +  }
1879 +  else if(variable == "genMatchedMotherIdReverse"){
1880 +    int index = getGenMatchedParticleIndex(object);
1881 +    if(index == -1) value = 23;
1882 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1883 +  }
1884 +  else if(variable == "genMatchedGrandmotherId"){
1885 +    int index = getGenMatchedParticleIndex(object);
1886 +    if(index == -1) value = 0;
1887 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1888 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1889 +      if(motherIndex == -1) value = 0;
1890 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1891 +    }
1892 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1893 +  }
1894 +
1895 +
1896    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1897  
1898    value = applyFunction(function, value);
# Line 1293 | Line 1976 | double
1976   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1977  
1978    double value = 0.0;
1979 <
1979 >  double pMag = sqrt(object->pt * object->pt +
1980 >                     object->pz * object->pz);
1981 >  
1982    if(variable == "pt") value = object->pt;
1983    else if(variable == "px") value = object->px;
1984    else if(variable == "py") value = object->py;
# Line 1313 | Line 1998 | OSUAnalysis::valueLookup (const BNtrack*
1998    else if(variable == "isHighPurity") value = object->isHighPurity;
1999  
2000  
2001 +  //additional BNs info for disappTrks
2002 +  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2003 +  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2004 +  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2005 +  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2006 +  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2007 +  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2008 +  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2009 +  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2010 +  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2011 +  else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2012 +  
2013 +
2014 +  //user defined variables
2015 +  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;
2016 +  else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2017 +  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2018 +  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2019 +  else if(variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object);  
2020 +  else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;  
2021 +  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2022 +  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2023 +  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2024 +  else if(variable == "ptError")                    value = object->ptError;
2025 +  else if(variable == "ptRes")                      value = getTrkPtRes(object);
2026 +  else if (variable == "d0wrtPV"){      
2027 +    double vx = object->vx - chosenVertex ()->x,        
2028 +      vy = object->vy - chosenVertex ()->y,      
2029 +      px = object->px,  
2030 +      py = object->py,  
2031 +      pt = object->pt;  
2032 +    value = (-vx * py + vy * px) / pt;  
2033 +  }      
2034 +  else if (variable == "dZwrtPV"){      
2035 +    double vx = object->vx - chosenVertex ()->x,        
2036 +      vy = object->vy - chosenVertex ()->y,      
2037 +      vz = object->vz - chosenVertex ()->z,      
2038 +      px = object->px,  
2039 +      py = object->py,  
2040 +      pz = object->pz,  
2041 +      pt = object->pt;  
2042 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2043 +  }    
2044 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2045 +
2046 +  else if(variable == "genMatchedPdgId"){
2047 +    int index = getGenMatchedParticleIndex(object);
2048 +    if(index == -1) value = 0;
2049 +    else value = mcparticles->at(index).id;
2050 +  }
2051 +
2052 +
2053 +  else if(variable == "genMatchedId"){
2054 +    int index = getGenMatchedParticleIndex(object);
2055 +    if(index == -1) value = 0;
2056 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2057 +  }
2058 +  else if(variable == "genMatchedMotherId"){
2059 +    int index = getGenMatchedParticleIndex(object);
2060 +    if(index == -1) value = 0;
2061 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2062 +  }
2063 +  else if(variable == "genMatchedMotherIdReverse"){
2064 +    int index = getGenMatchedParticleIndex(object);
2065 +    if(index == -1) value = 23;
2066 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2067 +  }
2068 +  else if(variable == "genMatchedGrandmotherId"){
2069 +    int index = getGenMatchedParticleIndex(object);
2070 +    if(index == -1) value = 0;
2071 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2072 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2073 +      if(motherIndex == -1) value = 0;
2074 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2075 +    }
2076 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2077 +  }
2078 +
2079 +
2080 +
2081    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2082  
2083    value = applyFunction(function, value);
# Line 1440 | Line 2205 | OSUAnalysis::valueLookup (const BNmcpart
2205  
2206    //user-defined variables
2207    else if (variable == "d0"){
2208 <    double vx = object->vx - primaryVertex_->x,
2209 <      vy = object->vy - primaryVertex_->y,
2208 >    double vx = object->vx - chosenVertex ()->x,
2209 >      vy = object->vy - chosenVertex ()->y,
2210        px = object->px,
2211        py = object->py,
2212        pt = object->pt;
2213      value = (-vx * py + vy * px) / pt;
2214    }
2215    else if (variable == "dz"){
2216 <    double vx = object->vx - primaryVertex_->x,
2217 <      vy = object->vy - primaryVertex_->y,
2218 <      vz = object->vz - primaryVertex_->z,
2216 >    double vx = object->vx - chosenVertex ()->x,
2217 >      vy = object->vy - chosenVertex ()->y,
2218 >      vz = object->vz - chosenVertex ()->z,
2219        px = object->px,
2220        py = object->py,
2221        pz = object->pz,
2222        pt = object->pt;
2223      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2224    }
2225 <
2225 >  else if(variable == "v0"){
2226 >    value = sqrt(object->vx*object->vx + object->vy*object->vy);
2227 >  }
2228 >  else if(variable == "deltaV0"){
2229 >    value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2230 >  }
2231 >  else if (variable == "deltaVx"){
2232 >    value = object->vx - chosenVertex ()->x;
2233 >  }
2234 >  else if (variable == "deltaVy"){
2235 >    value = object->vy - chosenVertex ()->y;
2236 >  }
2237 >  else if (variable == "deltaVz"){
2238 >    value = object->vz - chosenVertex ()->z;
2239 >  }
2240  
2241  
2242    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1587 | Line 2366 | OSUAnalysis::valueLookup (const BNphoton
2366    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2367  
2368  
2369 +
2370 +
2371 +  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2372 +
2373 +  else if(variable == "genMatchedPdgId"){
2374 +    int index = getGenMatchedParticleIndex(object);
2375 +    if(index == -1) value = 0;
2376 +    else value = mcparticles->at(index).id;
2377 +  }
2378 +
2379 +
2380 +
2381 +  else if(variable == "genMatchedId"){
2382 +    int index = getGenMatchedParticleIndex(object);
2383 +    if(index == -1) value = 0;
2384 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2385 +  }
2386 +  else if(variable == "genMatchedMotherId"){
2387 +    int index = getGenMatchedParticleIndex(object);
2388 +    if(index == -1) value = 0;
2389 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2390 +  }
2391 +  else if(variable == "genMatchedMotherIdReverse"){
2392 +    int index = getGenMatchedParticleIndex(object);
2393 +    if(index == -1) value = 23;
2394 +    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2395 +  }
2396 +  else if(variable == "genMatchedGrandmotherId"){
2397 +    int index = getGenMatchedParticleIndex(object);
2398 +    if(index == -1) value = 0;
2399 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2400 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2401 +      if(motherIndex == -1) value = 0;
2402 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2403 +    }
2404 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2405 +  }
2406 +
2407 +
2408    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2409  
2410    value = applyFunction(function, value);
# Line 1622 | Line 2440 | OSUAnalysis::valueLookup (const BNmuon*
2440  
2441    double value = 0.0;
2442  
2443 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2443 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2444 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2445 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2446    else if(variable == "invMass"){
2447      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2448      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2449      value = (fourVector1 + fourVector2).M();
2450    }
2451 +  else if(variable == "pt"){
2452 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2453 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2454 +    value = (fourVector1 + fourVector2).Pt();
2455 +  }
2456 +  else if(variable == "threeDAngle")
2457 +    {
2458 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2459 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2460 +      value = (threeVector1.Angle(threeVector2));
2461 +    }
2462 +  else if(variable == "alpha")
2463 +    {
2464 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
2465 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2466 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2467 +      value = (pi-threeVector1.Angle(threeVector2));
2468 +    }
2469    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2470    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2471 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2471 >  else if(variable == "d0Sign"){
2472 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2473 >    if(d0Sign < 0) value = -0.5;
2474 >    else if (d0Sign > 0) value = 0.5;
2475 >    else value = -999;
2476 >  }
2477 >  else if(variable == "chargeProduct"){
2478 >    value = object1->charge*object2->charge;
2479 >  }
2480 >  else if(variable == "muon1CorrectedD0Vertex"){
2481 >    value = object1->correctedD0Vertex;
2482 >  }
2483 >  else if(variable == "muon2CorrectedD0Vertex"){
2484 >    value = object2->correctedD0Vertex;
2485 >  }
2486 >  else if(variable == "muon1timeAtIpInOut"){
2487 >    value = object1->timeAtIpInOut;
2488 >  }
2489 >  else if(variable == "muon2timeAtIpInOut"){
2490 >    value = object2->timeAtIpInOut;
2491 >  }
2492 >  else if(variable == "muon1correctedD0")
2493 >    {
2494 >      value = object1->correctedD0;
2495 >    }
2496 >  else if(variable == "muon2correctedD0")
2497 >    {
2498 >      value = object2->correctedD0;
2499 >    }
2500  
2501    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2502  
# Line 1644 | Line 2510 | OSUAnalysis::valueLookup (const BNelectr
2510  
2511    double value = 0.0;
2512  
2513 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2513 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2514 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2515 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2516    else if(variable == "invMass"){
2517      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2518      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2519      value = (fourVector1 + fourVector2).M();
2520    }
2521 +  else if(variable == "pt"){
2522 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2523 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2524 +    value = (fourVector1 + fourVector2).Pt();
2525 +  }
2526 +  else if(variable == "threeDAngle")
2527 +    {
2528 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2529 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2530 +      value = (threeVector1.Angle(threeVector2));
2531 +    }
2532    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2533    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2534 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2534 >  else if(variable == "d0Sign"){
2535 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2536 >    if(d0Sign < 0) value = -0.5;
2537 >    else if (d0Sign > 0) value = 0.5;
2538 >    else value = -999;
2539 >  }
2540 >  else if(variable == "chargeProduct"){
2541 >    value = object1->charge*object2->charge;
2542 >  }
2543 >  else if(variable == "electron1CorrectedD0Vertex"){
2544 >    value = object1->correctedD0Vertex;
2545 >  }
2546 >  else if(variable == "electron2CorrectedD0Vertex"){
2547 >    value = object2->correctedD0Vertex;
2548 >  }
2549 >  else if(variable == "electron1CorrectedD0"){
2550 >    value = object1->correctedD0;
2551 >  }
2552 >  else if(variable == "electron2CorrectedD0"){
2553 >    value = object2->correctedD0;
2554 >  }
2555  
2556    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2557  
# Line 1666 | Line 2565 | OSUAnalysis::valueLookup (const BNelectr
2565  
2566    double value = 0.0;
2567  
2568 <  if(variable == "deltaPhi") value = deltaPhi(object1->phi,object2->phi);
2568 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2569 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2570 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2571    else if(variable == "invMass"){
2572      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2573      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2574      value = (fourVector1 + fourVector2).M();
2575    }
2576 +  else if(variable == "pt"){
2577 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2578 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2579 +    value = (fourVector1 + fourVector2).Pt();
2580 +  }
2581 +  else if(variable == "threeDAngle")
2582 +    {
2583 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2584 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2585 +      value = (threeVector1.Angle(threeVector2));
2586 +    }
2587    else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2588    else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2589 <  else if(variable == "d0Sign") value = object1->correctedD0Vertex*object2->correctedD0Vertex/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2589 >  else if(variable == "d0Sign"){
2590 >    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2591 >    if(d0Sign < 0) value = -0.5;
2592 >    else if (d0Sign > 0) value = 0.5;
2593 >    else value = -999;
2594 >  }
2595 >  else if(variable == "chargeProduct"){
2596 >    value = object1->charge*object2->charge;
2597 >  }
2598 >  else if(variable == "electronCorrectedD0Vertex"){
2599 >    value = object1->correctedD0Vertex;
2600 >  }
2601 >  else if(variable == "muonCorrectedD0Vertex"){
2602 >    value = object2->correctedD0Vertex;
2603 >  }
2604 >  else if(variable == "electronCorrectedD0"){
2605 >    value = object1->correctedD0;
2606 >  }
2607 >  else if(variable == "muonCorrectedD0"){
2608 >    value = object2->correctedD0;
2609 >  }
2610 >  else if(variable == "electronDetIso"){
2611 >    value = (object1->trackIso) / object1->pt;
2612 >  }
2613 >  else if(variable == "muonDetIso"){
2614 >    value = (object2->trackIsoDR03) / object2->pt;
2615 >  }
2616 >  else if(variable == "electronRelPFrhoIso"){
2617 >    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2618 >  }
2619 >  else if(variable == "muonRelPFdBetaIso"){
2620 >    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2621 >  }
2622 >
2623 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2624 >
2625 >  value = applyFunction(function, value);
2626 >
2627 >  return value;
2628 > }
2629 >
2630 >
2631 > double  
2632 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2633 >  double electronMass = 0.000511;        
2634 >  double value = 0.0;    
2635 >  TLorentzVector fourVector1(0, 0, 0, 0);        
2636 >  TLorentzVector fourVector2(0, 0, 0, 0);        
2637 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
2638 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2639 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
2640 >  else if(variable == "invMass"){        
2641 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
2642 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
2643 >        
2644 >    value = (fourVector1 + fourVector2).M();    
2645 >  }
2646 >  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
2647 >  value = applyFunction(function, value);        
2648 >  return value;  
2649 > }
2650 >
2651 >
2652 >
2653 > double
2654 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
2655 >  double pionMass = 0.140;
2656 >  double muonMass = 0.106;
2657 >  double value = 0.0;
2658 >  TLorentzVector fourVector1(0, 0, 0, 0);
2659 >  TLorentzVector fourVector2(0, 0, 0, 0);
2660 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2661 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2662 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2663 >  else if(variable == "invMass"){
2664 >    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
2665 >    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
2666 >
2667 >    value = (fourVector1 + fourVector2).M();
2668 >  }
2669  
2670    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2671 +  value = applyFunction(function, value);
2672 +  return value;
2673 + }
2674 +
2675  
2676 + double
2677 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
2678 +  double value = 0.0;
2679 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2680 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2681 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2682 +  else if(variable == "invMass"){
2683 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2684 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2685 +    value = (fourVector1 + fourVector2).M();
2686 +  }
2687 +
2688 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2689    value = applyFunction(function, value);
2690 +  return value;
2691 + }
2692 +
2693 +
2694 + double
2695 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
2696 +  double value = 0.0;
2697 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2698 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2699 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2700 +  else if(variable == "invMass"){
2701 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2702 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2703 +    value = (fourVector1 + fourVector2).M();
2704 +  }
2705 +
2706 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2707 +  value = applyFunction(function, value);
2708 +  return value;
2709 + }
2710 +
2711 +
2712 + double
2713 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
2714 +
2715 +  double value = 0.0;
2716 +  double pMag = sqrt(object1->pt * object1->pt +
2717 +                     object1->pz * object1->pz);  
2718 +
2719 +  if      (variable == "numPV")                      value = object2->numPV;
2720 +  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
2721 +  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
2722 +  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
2723 +  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
2724 +
2725 +  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
2726 +
2727 +  value = applyFunction(function, value);
2728 +
2729 +  return value;
2730 +
2731 + }  
2732 +
2733 + // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2734 + // Return true iff no other tracks are found in this cone.
2735 + int
2736 + OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
2737 +  for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
2738 +    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
2739 +    double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
2740 +    if(deltaRtrk < 0.5) return 0;
2741 +  }
2742 +  return 1;
2743 +
2744 + }
2745 +
2746 +
2747 + double
2748 + OSUAnalysis::getTrkPtRes (const BNtrack* track1){
2749 +
2750 +  double ptTrue = getTrkPtTrue(track1, mcparticles.product());
2751 +  double PtRes = (track1->pt - ptTrue) / ptTrue;
2752 +
2753 +  return PtRes;
2754 +
2755 + }
2756 +
2757 +
2758 + double
2759 + OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
2760 +  double value = -99;
2761 +  double genDeltaRLowest = 999;
2762 +
2763 +  for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){
2764 +    double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
2765 +    if (genDeltaRtemp < genDeltaRLowest) {
2766 +      genDeltaRLowest = genDeltaRtemp;
2767 +      if (genDeltaRLowest < 0.05) {   // Only consider it truth-matched if DeltaR<0.15.
2768 +        double ptTrue = genPart->pt;
2769 +        value = ptTrue;
2770 +      }
2771 +    }
2772 +  }
2773  
2774    return value;
2775 +
2776   }
2777  
2778 + double
2779 + OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
2780 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
2781 +  if (!useTrackCaloRhoCorr_) return -99;  
2782 +  // if (!rhokt6CaloJetsHandle_) {
2783 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
2784 +  //   return -99;  
2785 +  // }
2786 +  double radDeltaRCone = 0.5;  
2787 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
2788 +  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
2789 +  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
2790 +  return caloTotRhoCorrCalo;  
2791 +
2792 + }
2793 +
2794 +
2795 +
2796 +
2797 + //creates a map of the dead Ecal channels in the barrel and endcap
2798 + //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2799 + //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
2800 + void
2801 + OSUAnalysis::WriteDeadEcal (){
2802 +  double etaEcal, phiEcal;
2803 +  ifstream DeadEcalFile(deadEcalFile_);
2804 +  if(!DeadEcalFile) {
2805 +    cout << "Error: DeadEcalFile has not been found." << endl;
2806 +    return;
2807 +  }
2808 +  if(DeadEcalVec.size()!= 0){
2809 +    cout << "Error: DeadEcalVec has a nonzero size" << endl;
2810 +    return;
2811 +  }
2812 +  while(!DeadEcalFile.eof())
2813 +    {
2814 +      DeadEcalFile >> etaEcal >> phiEcal;
2815 +      DeadEcal newChan;
2816 +      newChan.etaEcal = etaEcal;
2817 +      newChan.phiEcal = phiEcal;
2818 +      DeadEcalVec.push_back(newChan);
2819 +    }
2820 +  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
2821 + }
2822 +
2823 + //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
2824 + int
2825 + OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
2826 +  double deltaRLowest = 999;
2827 +  int value = 0;
2828 +  if (DeadEcalVec.size() == 0) WriteDeadEcal();
2829 +  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
2830 +    double eta = ecal->etaEcal;
2831 +    double phi = ecal->phiEcal;
2832 +    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
2833 +    if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
2834 +  }
2835 +  if (deltaRLowest<0.05) {value = 1;}
2836 +  else {value = 0;}
2837 +  return value;
2838 + }
2839 +
2840 + // Returns the smallest DeltaR between the object and any generated true particle in the event.  
2841 + template <class InputObject>
2842 + double OSUAnalysis::getGenDeltaRLowest(InputObject object){
2843 +  double genDeltaRLowest = 999.;
2844 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2845 +    double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
2846 +    if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
2847 +  }
2848 +  return genDeltaRLowest;
2849 + }
2850  
2851   double
2852   OSUAnalysis::applyFunction(string function, double value){
2853  
2854    if(function == "abs") value = fabs(value);
2855 +  else if(function == "fabs") value = fabs(value);
2856 +  else if(function == "log10") value = log10(value);
2857 +  else if(function == "log") value = log10(value);
2858  
2859 +  else if(function == "") value = value;
2860 +  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
2861  
2862    return value;
2863  
# Line 1698 | Line 2867 | OSUAnalysis::applyFunction(string functi
2867   template <class InputCollection>
2868   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
2869  
2870 +
2871    for (uint object = 0; object != inputCollection->size(); object++){
2872  
2873 +
2874      bool decision = true;//object passes if this cut doesn't cut on that type of object
2875  
2876 +
2877      if(currentCut.inputCollection == inputType){
2878  
2879        vector<bool> subcutDecisions;
2880        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2881 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2882 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2881 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2882 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2883        }
2884        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2885        else{
2886 <        bool tempDecision = true;
2887 <        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2888 <          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2889 <            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2890 <          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2886 >        bool tempDecision = true;
2887 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2888 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2889 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2890 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2891              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2892 <        }
2893 <        decision = tempDecision;
2892 >        }
2893 >        decision = tempDecision;
2894        }
2895      }
2896      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2897  
2898 +
2899      //set flags for objects that pass each cut AND all the previous cuts
2900      bool previousCumulativeFlag = true;
2901      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
# Line 1731 | Line 2904 | void OSUAnalysis::setObjectFlags(cut &cu
2904      }
2905      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2906  
2907 +
2908    }
2909  
2910   }
# Line 1738 | Line 2912 | void OSUAnalysis::setObjectFlags(cut &cu
2912  
2913   template <class InputCollection1, class InputCollection2>
2914   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2915 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){
2915 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2916  
2917  
2918    bool sameObjects = false;
2919    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2920  
2921 <  int counter = 0;  
2921 >
2922 >  int counter = 0;
2923    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2924      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2925 <      
2925 >
2926        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2927  
2928  
# Line 1755 | Line 2930 | void OSUAnalysis::setObjectFlags(cut &cu
2930  
2931        if(currentCut.inputCollection == inputType){
2932  
2933 <        vector<bool> subcutDecisions;
2934 <        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2935 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2936 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2937 <        }
2933 >        vector<bool> subcutDecisions;
2934 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2935 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2936 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2937 >        }
2938  
2939 <        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2940 <        else{
2941 <          bool tempDecision = true;
2942 <          for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2943 <            if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2944 <              tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2945 <            else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2946 <              tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2947 <          }
2948 <          decision = tempDecision;
2949 <        }
2939 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2940 >        else{
2941 >          bool tempDecision = subcutDecisions.at(0);
2942 >          for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
2943 >            if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
2944 >              tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
2945 >            else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
2946 >              tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
2947 >          }
2948 >          decision = tempDecision;
2949 >        }
2950        }
2951        individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2952 <      
2952 >
2953        //set flags for objects that pass each cut AND all the previous cuts
2954        bool previousCumulativeFlag = true;
2955        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2956 <        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2957 <        else{ previousCumulativeFlag = false; break;}
2956 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2957 >        else{ previousCumulativeFlag = false; break;}
2958        }
2959 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2959 >      //apply flags for the components of the composite object as well
2960 >      bool currentCumulativeFlag = true;
2961 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
2962 >      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
2963 >      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
2964 >      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2965 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2966  
2967 <      counter++;      
2967 >      counter++;
2968      }
2969 <    
2969 >
2970    }
2971  
2972  
# Line 1793 | Line 2974 | void OSUAnalysis::setObjectFlags(cut &cu
2974  
2975  
2976   template <class InputCollection>
2977 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
2977 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2978  
2979    for (uint object = 0; object != inputCollection->size(); object++){
2980  
# Line 1803 | Line 2984 | void OSUAnalysis::fill1DHistogram(TH1* h
2984      string inputVariable = "";
2985      string function = "";
2986      if(currentString.find("(")==std::string::npos){
2987 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
2987 >      inputVariable = currentString;// variable to cut on
2988      }
2989      else{
2990 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
2991 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
2992 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
2990 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2991 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2992 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2993      }
2994  
2995      double value = valueLookup(&inputCollection->at(object), inputVariable, function);
2996 <    histo->Fill(value,puScaleFactor);
2996 >    histo->Fill(value,scaleFactor);
2997  
2998 +    if (printEventInfo_) {
2999 +      // Write information about event to screen, for testing purposes.  
3000 +      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3001 +    }
3002 +    
3003    }
1818
3004   }
3005  
3006   template <class InputCollection1, class InputCollection2>
3007 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
3007 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3008  
3009    bool sameObjects = false;
3010    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3011  
3012 <  int counter = 0;  
3012 >  int pairCounter = 0;
3013    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3014      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3015 <      
3015 >
3016        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3017  
3018        //only take objects which have passed all cuts and pairs which have passed all cuts
3019        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3020        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3021 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
3021 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3022  
3023        string currentString = parameters.inputVariables.at(0);
3024        string inputVariable = "";
3025        string function = "";
3026        if(currentString.find("(")==std::string::npos){
3027 <        inputVariable = currentString;// variable to cut on                                                                                                          
3027 >        inputVariable = currentString;// variable to cut on
3028        }
3029        else{
3030 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3031 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3032 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3030 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3031 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3032 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3033        }
3034 <      
3034 >
3035        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3036 <      histo->Fill(value,puScaleFactor);
3036 >      histo->Fill(value,scaleFactor);
3037  
3038 <      counter++;      
3038 >      pairCounter++;
3039      }
3040    }
3041  
# Line 1858 | Line 3043 | void OSUAnalysis::fill1DHistogram(TH1* h
3043  
3044  
3045   template <class InputCollection>
3046 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double puScaleFactor){
3046 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
3047  
3048    for (uint object = 0; object != inputCollection->size(); object++){
3049  
# Line 1868 | Line 3053 | void OSUAnalysis::fill2DHistogram(TH2* h
3053      string inputVariable = "";
3054      string function = "";
3055      if(currentString.find("(")==std::string::npos){
3056 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
3056 >      inputVariable = currentString;// variable to cut on
3057      }
3058      else{
3059 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3060 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3061 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3059 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3060 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3061 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3062      }
3063      double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3064  
# Line 1881 | Line 3066 | void OSUAnalysis::fill2DHistogram(TH2* h
3066      inputVariable = "";
3067      function = "";
3068      if(currentString.find("(")==std::string::npos){
3069 <      inputVariable = currentString;// variable to cut on                                                                                                                                        
3069 >      inputVariable = currentString;// variable to cut on
3070      }
3071      else{
3072 <      function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3073 <      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3074 <      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3072 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
3073 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3074 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3075      }
3076  
3077      double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3078  
3079 <    histo->Fill(valueX,valueY,puScaleFactor);
3079 >    histo->Fill(valueX,valueY,scaleFactor);
3080  
3081    }
3082  
3083   }
3084  
3085   template <class InputCollection1, class InputCollection2>
3086 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double puScaleFactor){
3086 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
3087  
3088    bool sameObjects = false;
3089    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3090  
3091 <  int counter = 0;  
3091 >  int pairCounter = 0;
3092    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3093      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3094 <      
3094 >
3095        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3096  
3097        //only take objects which have passed all cuts and pairs which have passed all cuts
3098        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3099        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3100 <      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(counter)) continue;
3100 >      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3101  
3102        string currentString = parameters.inputVariables.at(0);
3103        string inputVariable = "";
3104        string function = "";
3105        if(currentString.find("(")==std::string::npos){
3106 <        inputVariable = currentString;// variable to cut on                                                                                                          
3106 >        inputVariable = currentString;// variable to cut on
3107        }
3108        else{
3109 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3110 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3111 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3109 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3110 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3111 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3112        }
3113        double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3114  
# Line 1931 | Line 3116 | void OSUAnalysis::fill2DHistogram(TH2* h
3116        inputVariable = "";
3117        function = "";
3118        if(currentString.find("(")==std::string::npos){
3119 <        inputVariable = currentString;// variable to cut on                                                                                                          
3119 >        inputVariable = currentString;// variable to cut on
3120        }
3121        else{
3122 <        function = currentString.substr(0,currentString.find("("));//function comes before the "("                                                                                          
3123 <        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string                                                                                                    
3124 <        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"                                                                                                    
3122 >        function = currentString.substr(0,currentString.find("("));//function comes before the "("
3123 >        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3124 >        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3125        }
3126        double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3127  
3128  
3129 <      histo->Fill(valueX,valueY,puScaleFactor);
3129 >      histo->Fill(valueX,valueY,scaleFactor);
3130 >
3131 >      pairCounter++;
3132  
1946      counter++;      
3133      }
3134    }
3135  
3136   }
3137  
3138  
3139 + template <class InputObject>
3140 + int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
3141  
3142 < DEFINE_FWK_MODULE(OSUAnalysis);
3142 >  int bestMatchIndex = -1;
3143 >  double bestMatchDeltaR = 999;
3144 >
3145 >  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3146 >
3147 >    double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3148 >    if(currentDeltaR > 0.05) continue;
3149 >    //     cout << std::setprecision(3) << std::setw(20)
3150 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3151 >    //          << std::setw(20)
3152 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3153 >    //          << std::setw(20)
3154 >    //          << "\tdeltaR = " << currentDeltaR
3155 >    //          << std::setprecision(1)
3156 >    //          << std::setw(20)
3157 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3158 >    //          << std::setw(20)
3159 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3160 >    //          << std::setw(20)
3161 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3162 >    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3163 >      bestMatchIndex = mcparticle - mcparticles->begin();
3164 >      bestMatchDeltaR = currentDeltaR;
3165 >    }
3166  
3167 +  }
3168 +  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3169 +  //   else cout << "no match found..." << endl;
3170 +  return bestMatchIndex;
3171 +
3172 + }
3173 +
3174 +
3175 + int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
3176 +
3177 +  int bestMatchIndex = -1;
3178 +  double bestMatchDeltaR = 999;
3179 +
3180 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3181 +
3182 +    if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
3183 +
3184 +    double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
3185 +    if(currentDeltaR > 0.05) continue;
3186 +
3187 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3188 +      bestMatchIndex = mcparticle - mcparticles->begin();
3189 +      bestMatchDeltaR = currentDeltaR;
3190 +    }
3191 +
3192 +  }
3193 +
3194 +  return bestMatchIndex;
3195 + }
3196 +
3197 +
3198 + // bin      particle type
3199 + // ---      -------------
3200 + //  0        unmatched
3201 + //  1        u
3202 + //  2        d
3203 + //  3        s
3204 + //  4        c
3205 + //  5        b
3206 + //  6        t
3207 + //  7        e
3208 + //  8        mu
3209 + //  9        tau
3210 + // 10        nu
3211 + // 11        g
3212 + // 12        gamma
3213 + // 13        Z
3214 + // 14        W
3215 + // 15        light meson
3216 + // 16        K meson
3217 + // 17        D meson
3218 + // 18        B meson
3219 + // 19        light baryon
3220 + // 20        strange baryon
3221 + // 21        charm baryon
3222 + // 22        bottom baryon
3223 + // 23        other
3224 +
3225 + int OSUAnalysis::getPdgIdBinValue(int pdgId){
3226 +
3227 +  int binValue = -999;
3228 +  int absPdgId = fabs(pdgId);
3229 +  if(pdgId == -1) binValue = 0;
3230 +  else if(absPdgId <= 6 ) binValue = absPdgId;
3231 +  else if(absPdgId == 11 ) binValue = 7;
3232 +  else if(absPdgId == 13 ) binValue = 8;
3233 +  else if(absPdgId == 15 ) binValue = 9;
3234 +  else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
3235 +  else if(absPdgId == 21 ) binValue = 11;
3236 +  else if(absPdgId == 22 ) binValue = 12;
3237 +  else if(absPdgId == 23 ) binValue = 13;
3238 +  else if(absPdgId == 24 ) binValue = 14;
3239 +  else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130  ) binValue = 15;
3240 +  else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400)  ) binValue = 16;
3241 +  else if(absPdgId > 400 && absPdgId < 500  ) binValue = 17;
3242 +  else if(absPdgId > 500 && absPdgId < 600  ) binValue = 18;
3243 +  else if(absPdgId > 1000 && absPdgId < 3000  ) binValue = 19;
3244 +  else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
3245 +  else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
3246 +  else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
3247 +
3248 +  else binValue = 23;
3249 +
3250 +  return binValue;
3251 +
3252 + }
3253 +
3254 + const BNprimaryvertex *
3255 + OSUAnalysis::chosenVertex ()
3256 + {
3257 +  const BNprimaryvertex *chosenVertex = 0;
3258 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3259 +    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3260 +      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3261 +    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3262 +      if(!vertexFlags.at(vertexIndex)) continue;
3263 +      chosenVertex = & primaryvertexs->at(vertexIndex);
3264 +      break;
3265 +    }
3266 +  }
3267 +  else {
3268 +    chosenVertex = &primaryvertexs->at(0);
3269 +  }
3270  
3271 +  return chosenVertex;
3272 + }
3273 +
3274 + const BNmet *
3275 + OSUAnalysis::chosenMET ()
3276 + {
3277 +  const BNmet *chosenMET = 0;
3278 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3279 +    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3280 +      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3281 +    for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3282 +      if(!metFlags.at(metIndex)) continue;
3283 +      chosenMET = & mets->at(metIndex);
3284 +      break;
3285 +    }
3286 +  }
3287 +  else {
3288 +    chosenMET = &mets->at(0);
3289 +  }
3290 +
3291 +  return chosenMET;
3292 + }
3293 +
3294 + const BNelectron *
3295 + OSUAnalysis::chosenElectron ()
3296 + {
3297 +  const BNelectron *chosenElectron = 0;
3298 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3299 +    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3300 +      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3301 +    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3302 +      if(!electronFlags.at(electronIndex)) continue;
3303 +      chosenElectron = & electrons->at(electronIndex);
3304 +      break;
3305 +    }
3306 +  }
3307 +  else {
3308 +    chosenElectron = &electrons->at(0);
3309 +  }
3310 +
3311 +  return chosenElectron;
3312 + }
3313 +
3314 + const BNmuon *
3315 + OSUAnalysis::chosenMuon ()
3316 + {
3317 +  const BNmuon *chosenMuon = 0;
3318 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
3319 +    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
3320 +      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
3321 +    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
3322 +      if(!muonFlags.at(muonIndex)) continue;
3323 +      chosenMuon = & muons->at(muonIndex);
3324 +      break;
3325 +    }
3326 +  }
3327 +  else {
3328 +    chosenMuon = &muons->at(0);
3329 +  }
3330 +
3331 +  return chosenMuon;
3332 + }
3333 +
3334 +
3335 + DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines