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.44 by lantonel, Tue Apr 9 16:17:50 2013 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines