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.12 by ahart, Fri Feb 8 11:07:51 2013 UTC vs.
Revision 1.32 by qpython, Tue Mar 19 18:05:23 2013 UTC

# Line 16 | Line 16 | OSUAnalysis::OSUAnalysis (const edm::Par
16    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
17    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
18    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
19 <
20 <
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 <
29 <  histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets"))
30 <
28 >  histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
29 >  plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
30 >  doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting"))
31   {
32  
27
33    TH1::SetDefaultSumw2 ();
34 <  TH2::SetDefaultSumw2 ();
34 >
35 >  //create pile-up reweighting object, if necessary
36 >  if(datasetType_ != "data") {
37 >    if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
38 >    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
39 >    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
40 >  }
41  
42    // Construct Cutflow Objects. These store the results of cut decisions and
43    // handle filling cut flow histograms.
# Line 34 | Line 45 | OSUAnalysis::OSUAnalysis (const edm::Par
45    std::vector<TFileDirectory> directories;
46  
47    //always get vertex collection so we can assign the primary vertex in the event
48 <  allNecessaryObjects.push_back("primaryvertexs");
48 >  objectsToGet.push_back("primaryvertexs");
49 >
50 >  //always make the plot of number of primary verticex (to check pile-up reweighting)
51 >  objectsToPlot.push_back("primaryvertexs");
52  
53 +  //always get the MC particles to do GEN-matching
54 +  objectsToGet.push_back("mcparticles");
55 +
56 +  //always get the event collection to do pile-up reweighting
57 +  objectsToGet.push_back("events");
58  
59    //parse the histogram definitions
60    for(uint currentHistogramSet = 0; currentHistogramSet != histogramSets_.size(); currentHistogramSet++){
61  
62 <    string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string>("inputCollection");
63 <    objectsToPlot.push_back(tempInputCollection);
64 <    allNecessaryObjects.push_back(tempInputCollection);
62 >    string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
63 >    if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
64 >    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
65 >      objectsToGet.push_back(tempInputCollection);
66 >      objectsToPlot.push_back(tempInputCollection);
67 >      objectsToCut.push_back(tempInputCollection);
68 >    }
69 >    else{//pair of objects, need to add them both to the things to objectsToGet
70 >      int dashIndex = tempInputCollection.find("-");
71 >      int spaceIndex = tempInputCollection.find(" ");
72 >      int secondWordLength = spaceIndex - dashIndex;
73 >      objectsToGet.push_back(tempInputCollection);
74 >      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
75 >      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
76 >      objectsToPlot.push_back(tempInputCollection);
77 >      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
78 >      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
79 >      objectsToCut.push_back(tempInputCollection);
80 >      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
81 >      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
82 >
83 >      }
84 >
85      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
86 <    
86 >
87      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
88  
89        histogram tempHistogram;
# Line 53 | Line 92 | OSUAnalysis::OSUAnalysis (const edm::Par
92        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
93        tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
94        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
95 <      if(histogramList_.at(currentHistogram).exists("function"))
57 <        tempHistogram.function = histogramList_.at(currentHistogram).getParameter<string>("function");
58 <      else
59 <        tempHistogram.function = "";
60 <      
95 >
96        histograms.push_back(tempHistogram);
97  
98      }
99    }
100 +  //make unique vector of objects we need to plot (so we can book a histogram with the number of each object)
101 +  sort( objectsToPlot.begin(), objectsToPlot.end() );
102 +  objectsToPlot.erase( unique( objectsToPlot.begin(), objectsToPlot.end() ), objectsToPlot.end() );
103 +
104 +
105 +
106 +  //add histograms with the gen-matched id, mother id, and grandmother id
107 +  for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
108 +
109 +    string currentObject = objectsToPlot.at(currentObjectIndex);
110 +    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
111 +
112 +    histogram tempIdHisto;
113 +    histogram tempMomIdHisto;
114 +    histogram tempGmaIdHisto;
115 +
116 +    tempIdHisto.inputCollection = currentObject;
117 +    tempMomIdHisto.inputCollection = currentObject;
118 +    tempGmaIdHisto.inputCollection = currentObject;
119 +
120 +    currentObject = currentObject.substr(0, currentObject.size()-1);
121 +    tempIdHisto.name = currentObject+"GenMatchId";
122 +    tempMomIdHisto.name = currentObject+"GenMatchMotherId";
123 +    tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
124 +
125 +    currentObject.at(0) = toupper(currentObject.at(0));
126 +    tempIdHisto.title = currentObject+" Gen-matched Particle";
127 +    tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
128 +    tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
129 +
130 +    int maxNum = 24;
131 +    vector<double> binVector;
132 +    binVector.push_back(maxNum);
133 +    binVector.push_back(0);
134 +    binVector.push_back(maxNum);
135 +
136 +    tempIdHisto.bins = binVector;
137 +    tempIdHisto.inputVariables.push_back("genMatchedId");
138 +    tempMomIdHisto.bins = binVector;
139 +    tempMomIdHisto.inputVariables.push_back("genMatchedMotherId");
140 +    tempGmaIdHisto.bins = binVector;
141 +    tempGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherId");
142 +
143 +    histograms.push_back(tempIdHisto);
144 +    histograms.push_back(tempMomIdHisto);
145 +    histograms.push_back(tempGmaIdHisto);
146 +
147 +  }
148  
149  
150  
# Line 82 | Line 165 | OSUAnalysis::OSUAnalysis (const edm::Par
165        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
166        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
167          tempChannel.triggers.push_back(triggerNames.at(trigger));
168 <      allNecessaryObjects.push_back("triggers");
168 >      objectsToGet.push_back("triggers");
169      }
170  
171  
172  
173 +
174      //create cutFlow for this channel
175      cutFlows_.push_back (new CutFlow (fs_, channelName));
176  
# Line 99 | Line 183 | OSUAnalysis::OSUAnalysis (const edm::Par
183      std::map<std::string, TH2D*> twoDhistoMap;
184      twoDHists_.push_back(twoDhistoMap);
185  
186 +
187      //book all histograms included in the configuration
188      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
189        histogram currentHistogram = histograms.at(currentHistogramIndex);
190        int numBinsElements = currentHistogram.bins.size();
191        int numInputVariables = currentHistogram.inputVariables.size();
192 +
193        if(numBinsElements != 3 && numBinsElements !=6) {
194 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
195 <        exit(0);
194 >        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
195 >        exit(0);
196        }
197        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
198 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
199 <        exit(0);
198 >        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
199 >        exit(0);
200        }
201 <      else if(numBinsElements == 3)
202 <        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));
203 <      else if(numBinsElements == 6)
204 <        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));
201 >      else if(numBinsElements == 3){
202 >        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));
203 >      }
204 >      else if(numBinsElements == 6){
205 >        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));
206 >
207 >      }
208 >
209 >
210 >      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
211  
212 + // bin      particle type
213 + // ---      -------------
214 + //  0        unmatched
215 + //  1        u
216 + //  2        d
217 + //  3        s
218 + //  4        c
219 + //  5        b
220 + //  6        t
221 + //  7        e
222 + //  8        mu
223 + //  9        tau
224 + // 10        nu
225 + // 11        g
226 + // 12        gamma
227 + // 13        Z
228 + // 14        W
229 + // 15        light meson
230 + // 16        K meson
231 + // 17        D meson
232 + // 18        B meson
233 + // 19        light baryon
234 + // 20        strange baryon
235 + // 21        charm baryon
236 + // 22        bottom baryon
237 + // 23        other
238 +
239 +      vector<TString> labelArray;
240 +      labelArray.push_back("unmatched");
241 +      labelArray.push_back("u");
242 +      labelArray.push_back("d");
243 +      labelArray.push_back("s");
244 +      labelArray.push_back("c");
245 +      labelArray.push_back("b");
246 +      labelArray.push_back("t");
247 +      labelArray.push_back("e");
248 +      labelArray.push_back("#mu");
249 +      labelArray.push_back("#tau");
250 +      labelArray.push_back("#nu");
251 +      labelArray.push_back("g");
252 +      labelArray.push_back("#gamma");
253 +      labelArray.push_back("Z");
254 +      labelArray.push_back("W");
255 +      labelArray.push_back("light meson");
256 +      labelArray.push_back("K meson");
257 +      labelArray.push_back("D meson");
258 +      labelArray.push_back("B meson");
259 +      labelArray.push_back("light baryon");
260 +      labelArray.push_back("strange baryon");
261 +      labelArray.push_back("charm baryon");
262 +      labelArray.push_back("bottom baryon");
263 +      labelArray.push_back("other");
264  
265 +      for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
266 +        oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
267 +      }
268      }
269 +
270      //book a histogram for the number of each object type to be plotted
271 +
272      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
273        string currentObject = objectsToPlot.at(currentObjectIndex);
274        int maxNum = 10;
275        if(currentObject == "mcparticles") maxNum = 50;
276 <      currentObject[0] = toupper(currentObject[0]);
276 >      else if(currentObject == "primaryvertexs") maxNum = 50;
277 >      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
278 >      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
279 >      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
280 >
281 >      currentObject.at(0) = toupper(currentObject.at(0));
282        string histoName = "num" + currentObject;
283 <      oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
283 >
284 >      if(histoName == "numPrimaryvertexs"){
285 >        string newHistoName = histoName + "BeforePileupCorrection";
286 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
287 >        newHistoName = histoName + "AfterPileupCorrection";
288 >        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
289 >      }
290 >      else
291 >        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
292      }
293  
294  
295 +
296 +
297 +
298      //get list of cuts for this channel
299      vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
300  
301      //loop over and parse all cuts
302      for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
138
303        cut tempCut;
304 <     //store input collection for cut
305 <      string inputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
306 <      tempCut.inputCollection = inputCollection;
307 <      allNecessaryObjects.push_back(inputCollection);
304 >      //store input collection for cut
305 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
306 >      tempCut.inputCollection = tempInputCollection;
307 >      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
308 >        objectsToGet.push_back(tempInputCollection);
309 >        objectsToCut.push_back(tempInputCollection);
310 >      }
311 >      else{//pair of objects, need to add them both to the things to objectsToGet
312 >        int dashIndex = tempInputCollection.find("-");
313 >        int spaceIndex = tempInputCollection.find(" ");
314 >        int secondWordLength = spaceIndex - dashIndex;
315 >        objectsToGet.push_back(tempInputCollection);
316 >        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
317 >        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
318 >        objectsToCut.push_back(tempInputCollection);
319 >        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
320 >        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
321 >
322 >      }
323 >
324 >
325  
326        //split cut string into parts and store them
327        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
328        std::vector<string> cutStringVector = splitString(cutString);
329 <      if(cutStringVector.size()!=3){
330 <        std::cout << "Error: Didn't find three elements in the following cut string: '" <<cutString << "'\n";
331 <        exit(0);
329 >      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
330 >        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
331 >        exit(0);
332 >      }
333 >      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
334 >      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
335 >        int indexOffset = 4 * subcutIndex;
336 >        string currentVariableString = cutStringVector.at(indexOffset);
337 >        if(currentVariableString.find("(")==std::string::npos){
338 >          tempCut.functions.push_back("");//no function was specified
339 >          tempCut.variables.push_back(currentVariableString);// variable to cut on
340 >        }
341 >        else{
342 >          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
343 >          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
344 >          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
345 >        }
346 >        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
347 >        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
348 >        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
349        }
152
153      tempCut.variable = cutStringVector.at(0);// variable to cut on
154      tempCut.comparativeOperator = cutStringVector.at(1);// comparison to make
155      tempCut.cutValue = atof(cutStringVector.at(2).c_str());// threshold value to pass cut
350  
351        //get number of objects required to pass cut for event to pass
352        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
353        std::vector<string> numberRequiredVector = splitString(numberRequiredString);
354        if(numberRequiredVector.size()!=2){
355 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
355 >        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
356          exit(0);
357        }
358  
165      // determine number required if comparison contains "="
359        int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
167      if(numberRequiredVector.at(0) == ">") numberRequiredInt++;
168      else if(numberRequiredVector.at(0) == "<") numberRequiredInt--;
169
360        tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
361        tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
362  
363 <      if(cuts_.at(currentCut).exists("function")){
174 <        tempCut.function = cuts_.at(currentCut).getParameter<string> ("function");
175 <      }
176 <      else tempCut.function = "";
363 >
364        string tempCutName;
365        if(cuts_.at(currentCut).exists("alias")){
366          tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
# Line 181 | Line 368 | OSUAnalysis::OSUAnalysis (const edm::Par
368        else{
369          //construct string for cutflow table
370          bool plural = numberRequiredInt != 1;
371 <        string collectionString = plural ? inputCollection : inputCollection.substr(0, inputCollection.size()-1);
371 >        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
372          string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
373          tempCutName = cutName;
374        }
# Line 194 | Line 381 | OSUAnalysis::OSUAnalysis (const edm::Par
381  
382      }//end loop over cuts
383  
197
384      channels.push_back(tempChannel);
385      tempChannel.cuts.clear();
386  
387    }//end loop over channels
388  
389  
390 <
391 <
392 <  //make unique vector of objects we need to cut on (so we make sure to get them from the event)
393 <  sort( allNecessaryObjects.begin(), allNecessaryObjects.end() );
394 <  allNecessaryObjects.erase( unique( allNecessaryObjects.begin(), allNecessaryObjects.end() ), allNecessaryObjects.end() );
390 >  //make unique vector of objects we need to get from the event
391 >  sort( objectsToGet.begin(), objectsToGet.end() );
392 >  objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
393 >  //make unique vector of objects we need to cut on
394 >  sort( objectsToCut.begin(), objectsToCut.end() );
395 >  objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
396  
397  
398   }
# Line 223 | Line 410 | void
410   OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
411   {
412  
226
413    // Retrieve necessary collections from the event.
414 <  edm::Handle<BNtriggerCollection> triggers;
415 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "triggers") != allNecessaryObjects.end())
414 >
415 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
416      event.getByLabel (triggers_, triggers);
417  
418 <  edm::Handle<BNjetCollection> jets;
233 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "jets") != allNecessaryObjects.end())
418 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
419      event.getByLabel (jets_, jets);
420  
421 <  edm::Handle<BNmuonCollection> muons;
237 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "muons") != allNecessaryObjects.end())
421 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
422      event.getByLabel (muons_, muons);
423  
424 <  edm::Handle<BNelectronCollection> electrons;
241 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "electrons") != allNecessaryObjects.end())
424 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
425      event.getByLabel (electrons_, electrons);
426  
427 <  edm::Handle<BNeventCollection> events;
245 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "events") != allNecessaryObjects.end())
427 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
428      event.getByLabel (events_, events);
429  
430 <  edm::Handle<BNtauCollection> taus;
249 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "taus") != allNecessaryObjects.end())
430 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
431      event.getByLabel (taus_, taus);
432  
433 <  edm::Handle<BNmetCollection> mets;
253 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mets") != allNecessaryObjects.end())
433 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
434      event.getByLabel (mets_, mets);
435  
436 <  edm::Handle<BNtrackCollection> tracks;
257 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "tracks") != allNecessaryObjects.end())
436 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
437      event.getByLabel (tracks_, tracks);
438  
439 <  edm::Handle<BNgenjetCollection> genjets;
261 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "genjets") != allNecessaryObjects.end())
439 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
440      event.getByLabel (genjets_, genjets);
441  
442 <  edm::Handle<BNmcparticleCollection> mcparticles;
265 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "mcparticles") != allNecessaryObjects.end())
442 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
443      event.getByLabel (mcparticles_, mcparticles);
444  
445 <  edm::Handle<BNprimaryvertexCollection> primaryvertexs;
269 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "primaryvertexs") != allNecessaryObjects.end())
445 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
446      event.getByLabel (primaryvertexs_, primaryvertexs);
447  
448 <  edm::Handle<BNbxlumiCollection> bxlumis;
273 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "bxlumis") != allNecessaryObjects.end())
448 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
449      event.getByLabel (bxlumis_, bxlumis);
450  
451 <  edm::Handle<BNphotonCollection> photons;
277 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "photons") != allNecessaryObjects.end())
451 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
452      event.getByLabel (photons_, photons);
453  
454 <  edm::Handle<BNsuperclusterCollection> superclusters;
281 <  if (std::find(allNecessaryObjects.begin(), allNecessaryObjects.end(), "superclusters") != allNecessaryObjects.end())
454 >  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
455      event.getByLabel (superclusters_, superclusters);
456  
457 +  //get pile-up event weight
458 +  double scaleFactor = 1.00;
459 +  if(doPileupReweighting_ && datasetType_ != "data")
460 +    scaleFactor = puWeight_->at (events->at (0).numTruePV);
461 +
462  
463    //loop over all channels
464  
# Line 288 | Line 466 | OSUAnalysis::analyze (const edm::Event &
466      channel currentChannel = channels.at(currentChannelIndex);
467  
468      flagMap individualFlags;
291    flagMap cumulativeFlags;
469      counterMap passingCounter;
470 +    cumulativeFlags.clear ();
471  
472      bool triggerDecision = true;
473      if(currentChannel.triggers.size() != 0){  //triggers specified
# Line 298 | Line 476 | OSUAnalysis::analyze (const edm::Event &
476      }
477  
478      //loop over all cuts
479 +
480 +
481 +
482      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
483        cut currentCut = currentChannel.cuts.at(currentCutIndex);
484  
485 <      for(uint currentObjectIndex = 0; currentObjectIndex != allNecessaryObjects.size(); currentObjectIndex++){
485 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
486 >        string currentObject = objectsToCut.at(currentObjectIndex);
487  
488 <        string currentObject = allNecessaryObjects.at(currentObjectIndex);
488 >        //initialize maps to get ready to set cuts
489          individualFlags[currentObject].push_back (vector<bool> ());
490          cumulativeFlags[currentObject].push_back (vector<bool> ());
491  
492 +      }
493 +      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
494 +        string currentObject = objectsToCut.at(currentObjectIndex);
495 +
496 +        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
497 +
498 +
499          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
500          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
501          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
# Line 322 | Line 511 | OSUAnalysis::analyze (const edm::Event &
511          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
512  
513  
514 <      }
514 >        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
515 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
516 >                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
517 >                                                                   "muon-muon pairs");
518 >        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
519 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
520 >                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
521 >                                                                           "electron-electron pairs");
522 >        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
523 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
524 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
525 >                                                                       "electron-muon pairs");
526  
527  
528 +      }
529  
329    }//end loop over all cuts
530  
531  
532 +    }//end loop over all cuts
533  
534  
535      //use cumulative flags to apply cuts at event level
# Line 339 | Line 540 | OSUAnalysis::analyze (const edm::Event &
540      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
541  
542  
543 +
544      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
545  
546        //loop over all objects and count how many passed the cumulative selection up to this point
547        cut currentCut = currentChannel.cuts.at(currentCutIndex);
548        int numberPassing = 0;
549  
550 <      for (uint object = 0; object != cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).size() ; object++)
551 <          if(cumulativeFlags[currentCut.inputCollection].at(currentCutIndex).at(object)) numberPassing++;
552 <
550 >      for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
551 >          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
552 >      }
553  
554        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
555        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
# Line 356 | Line 558 | OSUAnalysis::analyze (const edm::Event &
558  
559      }
560  
561 <    cutFlows_.at(currentChannelIndex)->fillCutFlow();
360 <
561 >    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
562  
362    if(!eventPassedAllCuts)continue;
563  
564  
565 <    //set position of primary vertex in event, in order to calculate quantities relative to it
366 <    primaryVertex_ = 0;
367 <    vector<bool> vertexFlags = cumulativeFlags["primaryvertexs"].back();
368 <    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
369 <      if(!vertexFlags.at(vertexIndex)) continue;
370 <      primaryVertex_ = new BNprimaryvertex (primaryvertexs->at (vertexIndex));
371 <      break;
372 <    }
565 >    if(!eventPassedAllCuts)continue;
566  
567  
568 +    //if(datasetType_ != "data") {
569 +    //  scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
570 +    //  scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
571 +    //}
572  
573      //filling histograms
574      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
575        histogram currentHistogram = histograms.at(histogramIndex);
576  
577        if(currentHistogram.inputVariables.size() == 1){
578 <        TH1D* histo;
579 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
580 <        if(currentHistogram.inputCollection == "jets") fillHistogram(histo,currentHistogram,jets.product());
581 <        else if(currentHistogram.inputCollection == "muons") fillHistogram(histo,currentHistogram,muons.product());
582 <        else if(currentHistogram.inputCollection == "electrons") fillHistogram(histo,currentHistogram,electrons.product());
583 <        else if(currentHistogram.inputCollection == "events") fillHistogram(histo,currentHistogram,events.product());
584 <        else if(currentHistogram.inputCollection == "taus") fillHistogram(histo,currentHistogram,taus.product());
585 <        else if(currentHistogram.inputCollection == "mets") fillHistogram(histo,currentHistogram,mets.product());
586 <        else if(currentHistogram.inputCollection == "tracks") fillHistogram(histo,currentHistogram,tracks.product());
587 <        else if(currentHistogram.inputCollection == "genjets") fillHistogram(histo,currentHistogram,genjets.product());
588 <        else if(currentHistogram.inputCollection == "mcparticles") fillHistogram(histo,currentHistogram,mcparticles.product());
589 <        else if(currentHistogram.inputCollection == "primaryvertexs") fillHistogram(histo,currentHistogram,primaryvertexs.product());
590 <        else if(currentHistogram.inputCollection == "bxlumis") fillHistogram(histo,currentHistogram,bxlumis.product());
591 <        else if(currentHistogram.inputCollection == "photons") fillHistogram(histo,currentHistogram,photons.product());
592 <        else if(currentHistogram.inputCollection == "superclusters") fillHistogram(histo,currentHistogram,superclusters.product());
578 >        TH1D* histo;
579 >        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
580 >
581 >
582 >
583 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
584 >         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
585 >        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
586 >                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
587 >                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
588 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
589 >        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
590 >                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
591 >                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
592 >        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
593 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
594 >                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
595 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
596 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
597 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
598 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
599 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
600 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
601 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
602 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
603 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
604 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
605        }
606        else if(currentHistogram.inputVariables.size() == 2){
607 <        TH2D* histo;
608 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
400 <        if(currentHistogram.inputCollection == "jets") fillHistogram(histo,currentHistogram,jets.product());
401 <        else if(currentHistogram.inputCollection == "muons") fillHistogram(histo,currentHistogram,muons.product());
402 <        else if(currentHistogram.inputCollection == "electrons") fillHistogram(histo,currentHistogram,electrons.product());
403 <        else if(currentHistogram.inputCollection == "events") fillHistogram(histo,currentHistogram,events.product());
404 <        else if(currentHistogram.inputCollection == "taus") fillHistogram(histo,currentHistogram,taus.product());
405 <        else if(currentHistogram.inputCollection == "mets") fillHistogram(histo,currentHistogram,mets.product());
406 <        else if(currentHistogram.inputCollection == "tracks") fillHistogram(histo,currentHistogram,tracks.product());
407 <        else if(currentHistogram.inputCollection == "genjets") fillHistogram(histo,currentHistogram,genjets.product());
408 <        else if(currentHistogram.inputCollection == "mcparticles") fillHistogram(histo,currentHistogram,mcparticles.product());
409 <        else if(currentHistogram.inputCollection == "primaryvertexs") fillHistogram(histo,currentHistogram,primaryvertexs.product());
410 <        else if(currentHistogram.inputCollection == "bxlumis") fillHistogram(histo,currentHistogram,bxlumis.product());
411 <        else if(currentHistogram.inputCollection == "photons") fillHistogram(histo,currentHistogram,photons.product());
412 <        else if(currentHistogram.inputCollection == "superclusters") fillHistogram(histo,currentHistogram,superclusters.product());
413 <      }
414 <    }
607 >        TH2D* histo;
608 >        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
609  
610  
611 +
612 +        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
613 +        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
614 +        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
615 +                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
616 +                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
617 +        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
618 +        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
619 +                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
620 +                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
621 +        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
622 +                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
623 +                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
624 +        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
625 +        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
626 +        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
627 +        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
628 +        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
629 +        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
630 +        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
631 +        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
632 +        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
633 +        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
634 +      }
635 +    }
636 +
637      //fills histograms with the sizes of collections
638      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
639        string currentObject = objectsToPlot.at(currentObjectIndex);
640 <      string tempCurrentObject = currentObject;
641 <      tempCurrentObject[0] = toupper(tempCurrentObject[0]);
640 >
641 >      string objectToPlot = "";
642 >
643 >      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
644 >      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
645 >      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
646 >      else objectToPlot = currentObject;
647 >      string tempCurrentObject = objectToPlot;
648 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
649        string histoName = "num" + tempCurrentObject;
650  
651 <      if(currentObject == "jets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(jets->size());
652 <      else if(currentObject == "muons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(muons->size());
653 <      else if(currentObject == "electrons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(electrons->size());
654 <      else if(currentObject == "events") oneDHists_.at(currentChannelIndex)[histoName]->Fill(events->size());
655 <      else if(currentObject == "taus") oneDHists_.at(currentChannelIndex)[histoName]->Fill(taus->size());
656 <      else if(currentObject == "mets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(mets->size());
657 <      else if(currentObject == "tracks") oneDHists_.at(currentChannelIndex)[histoName]->Fill(tracks->size());
658 <      else if(currentObject == "genjets") oneDHists_.at(currentChannelIndex)[histoName]->Fill(genjets->size());
659 <      else if(currentObject == "mcparticles") oneDHists_.at(currentChannelIndex)[histoName]->Fill(mcparticles->size());
660 <      else if(currentObject == "primaryvertexs") oneDHists_.at(currentChannelIndex)[histoName]->Fill(primaryvertexs->size());
661 <      else if(currentObject == "bxlumis") oneDHists_.at(currentChannelIndex)[histoName]->Fill(bxlumis->size());
662 <      else if(currentObject == "photons") oneDHists_.at(currentChannelIndex)[histoName]->Fill(photons->size());
663 <      else if(currentObject == "superclusters") oneDHists_.at(currentChannelIndex)[histoName]->Fill(superclusters->size());
651 >
652 >
653 >
654 >      //set position of primary vertex in event, in order to calculate quantities relative to it
655 >      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
656 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
657 >        int numToPlot = 0;
658 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
659 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
660 >        }
661 >        if(objectToPlot == "primaryvertexs"){
662 >          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
663 >          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
664 >        }
665 >        else
666 >          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
667 >      }
668 >      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
669 >      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
670 >      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
671 >      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
672 >      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
673 >      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
674 >      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
675 >      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
676 >      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
677 >      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
678 >      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
679 >      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
680 >      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
681 >      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
682 >      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
683 >      else if(objectToPlot == "primaryvertexs"){
684 >        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
685 >        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
686 >      }
687  
688      }
689 +
690 +
691 +
692 +
693    } //end loop over channel
694  
695 <  masterCutFlow_->fillCutFlow();
695 >  masterCutFlow_->fillCutFlow(scaleFactor);
696 >
697  
698  
699   }
# Line 453 | Line 708 | OSUAnalysis::evaluateComparison (double
708    else if(comparison == "<")  return testValue <  cutValue;
709    else if(comparison == "<=") return testValue <= cutValue;
710    else if(comparison == "==") return testValue == cutValue;
711 +  else if(comparison == "=") return testValue == cutValue;
712    else if(comparison == "!=") return testValue != cutValue;
713    else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
714  
# Line 635 | Line 891 | OSUAnalysis::valueLookup (const BNmuon*
891    else if(variable == "ecalIso") value = object->ecalIso;
892    else if(variable == "hcalIso") value = object->hcalIso;
893    else if(variable == "caloIso") value = object->caloIso;
894 <  else if(variable == "trackIsoDR03") value = object->trackIsoDR03;
894 >  else if(variable == "trackIsDR03") value = object->trackIsoDR03;
895    else if(variable == "ecalIsoDR03") value = object->ecalIsoDR03;
896    else if(variable == "hcalIsoDR03") value = object->hcalIsoDR03;
897    else if(variable == "caloIsoDR03") value = object->caloIsoDR03;
# Line 774 | Line 1030 | OSUAnalysis::valueLookup (const BNmuon*
1030    else if(variable == "time_ndof") value = object->time_ndof;
1031  
1032    //user-defined variables
1033 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1034 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1035 <  else if(variable == "detIso") value = (object->trackIso + object->caloIso) / object->pt;
1036 <  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1033 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1034 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1035 >  else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1036 >  else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1037    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1038 +  else if(variable == "metMT") {
1039 +    const BNmet *met = chosenMET ();
1040 +    if (met)
1041 +      {
1042 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1043 +                       p2 (met->px, met->py, 0.0, met->pt);
1044 +
1045 +        value = (p1 + p2).Mt ();
1046 +      }
1047 +    else
1048 +      value = -999;
1049 +  }
1050 +
1051 +
1052 +
1053 +  else if(variable == "correctedD0VertexInEBPlus"){
1054 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1055 +    else value = -999;
1056 +  }
1057 +  else if(variable == "correctedD0VertexOutEBPlus"){
1058 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1059 +    else value = -999;
1060 +  }
1061 +  else if(variable == "correctedD0VertexEEPlus"){
1062 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0Vertex;
1063 +    else value = -999;
1064 +  }
1065 +
1066 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1067 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1068 +    else value = -999;
1069 +  }
1070 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1071 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1072 +    else value = -999;
1073 +  }
1074 +  else if(variable == "correctedD0BeamspotEEPlus"){
1075 +    if(fabs(object->eta) > 1.479 && object->eta > 0) value = object->correctedD0;
1076 +    else value = -999;
1077 +  }
1078 +
1079 +  else if(variable == "correctedD0VertexInEBMinus"){
1080 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1081 +    else value = -999;
1082 +  }
1083 +  else if(variable == "correctedD0VertexOutEBMinus"){
1084 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1085 +    else value = -999;
1086 +  }
1087 +  else if(variable == "correctedD0VertexEEMinus"){
1088 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0Vertex;
1089 +    else value = -999;
1090 +  }
1091 +
1092 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1093 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1094 +    else value = -999;
1095 +  }
1096 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1097 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1098 +    else value = -999;
1099 +  }
1100 +  else if(variable == "correctedD0BeamspotEEMinus"){
1101 +    if(fabs(object->eta) > 1.479 && object->eta < 0) value = object->correctedD0;
1102 +    else value = -999;
1103 +  }
1104 +
1105 +
1106 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1107 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1108 +    else value = -999;
1109 +  }
1110 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1111 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1112 +    else value = -999;
1113 +  }
1114 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1115 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0Vertex;
1116 +    else value = -999;
1117 +  }
1118 +
1119 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1120 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1121 +    else value = -999;
1122 +  }
1123 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1124 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1125 +    else value = -999;
1126 +  }
1127 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1128 +    if(fabs(object->eta) > 1.479 && object->charge > 0) value = object->correctedD0;
1129 +    else value = -999;
1130 +  }
1131 +
1132 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1133 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1134 +    else value = -999;
1135 +  }
1136 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1137 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1138 +    else value = -999;
1139 +  }
1140 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1141 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0Vertex;
1142 +    else value = -999;
1143 +  }
1144 +
1145 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1146 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1147 +    else value = -999;
1148 +  }
1149 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1150 +    if(fabs(object->eta) < 1.479 && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1151 +    else value = -999;
1152 +  }
1153 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1154 +    if(fabs(object->eta) > 1.479 && object->charge < 0) value = object->correctedD0;
1155 +    else value = -999;
1156 +  }
1157 +
1158 +
1159    else if(variable == "tightID") {
1160 <    value = object->isGlobalMuon > 0            \
1161 <      && object->isPFMuon > 0                   \
1162 <      && object->normalizedChi2 < 10            \
1163 <      && object->numberOfValidMuonHits > 0      \
1164 <      && object->numberOfMatchedStations > 1    \
1165 <      && fabs(object->correctedD0Vertex) < 0.2  \
1166 <      && fabs(object->correctedDZ) < 0.5        \
1167 <      && object->numberOfValidPixelHits > 0     \
1160 >    value = object->isGlobalMuon > 0                \
1161 >      && object->isPFMuon > 0                        \
1162 >      && object->normalizedChi2 < 10                \
1163 >      && object->numberOfValidMuonHits > 0        \
1164 >      && object->numberOfMatchedStations > 1        \
1165 >      && fabs(object->correctedD0Vertex) < 0.2        \
1166 >      && fabs(object->correctedDZ) < 0.5        \
1167 >      && object->numberOfValidPixelHits > 0                \
1168        && object->numberOfLayersWithMeasurement > 5;
792    
793
1169    }
1170    else if(variable == "tightIDdisplaced"){
1171 <    value = object->isGlobalMuon > 0            \
1172 <      && object->isPFMuon > 0                   \
1173 <      && object->normalizedChi2 < 10            \
1174 <      && object->numberOfValidMuonHits > 0      \
1175 <      && object->numberOfMatchedStations > 1    \
801 <      && object->numberOfValidPixelHits > 0     \
1171 >    value = object->isGlobalMuon > 0                \
1172 >      && object->normalizedChi2 < 10                \
1173 >      && object->numberOfValidMuonHits > 0        \
1174 >      && object->numberOfMatchedStations > 1        \
1175 >      && object->numberOfValidPixelHits > 0        \
1176        && object->numberOfLayersWithMeasurement > 5;
1177    }
1178  
1179 +
1180 +
1181 +  else if(variable == "genMatchedId"){
1182 +    int index = getGenMatchedParticleIndex(object);
1183 +    if(index == -1) value = 0;
1184 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1185 +  }
1186 +  else if(variable == "genMatchedMotherId"){
1187 +    int index = getGenMatchedParticleIndex(object);
1188 +    if(index == -1) value = 0;
1189 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1190 +  }
1191 +  else if(variable == "genMatchedGrandmotherId"){
1192 +    int index = getGenMatchedParticleIndex(object);
1193 +    if(index == -1) value = 0;
1194 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1195 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1196 +      if(motherIndex == -1) value = 0;
1197 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1198 +    }
1199 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1200 +  }
1201 +
1202 +
1203 +
1204    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1205  
1206    value = applyFunction(function, value);
# Line 972 | Line 1371 | OSUAnalysis::valueLookup (const BNelectr
1371    else if(variable == "passConvVeto") value = object->passConvVeto;
1372  
1373    //user-defined variables
1374 <  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1375 <  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (primaryVertex_->xError, primaryVertex_->yError));
1376 <  else if(variable == "detIso") value = (object->trackIso + object->caloIso) / object->pt;
1374 >  else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1375 >  else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1376 >  else if(variable == "detIso") value = (object->trackIso) / object->pt;
1377    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1378 +  else if(variable == "metMT") {
1379 +    const BNmet *met = chosenMET ();
1380 +    if (met)
1381 +      {
1382 +        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1383 +                       p2 (met->px, met->py, 0.0, met->pt);
1384 +
1385 +        value = (p1 + p2).Mt ();
1386 +      }
1387 +    else
1388 +      value = -999;
1389 +  }
1390 +
1391 +  else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
1392 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
1393 +    else value = -999;
1394 +  }
1395 +  else if(variable == "correctedD0VertexEEPositiveChargeHighPt"){
1396 +    if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt < 45) value = object->correctedD0Vertex;
1397 +    else value = -999;
1398 +  }
1399 +
1400 +  else if(variable == "correctedD0VertexInEBPlus"){
1401 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1402 +    else value = -999;
1403 +  }
1404 +  else if(variable == "correctedD0VertexOutEBPlus"){
1405 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0Vertex;
1406 +    else value = -999;
1407 +  }
1408 +  else if(variable == "correctedD0VertexEEPlus"){
1409 +    if(object->isEE && object->eta > 0) value = object->correctedD0Vertex;
1410 +    else value = -999;
1411 +  }
1412 +
1413 +  else if(variable == "correctedD0BeamspotInEBPlus"){
1414 +    if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0;
1415 +    else value = -999;
1416 +  }
1417 +  else if(variable == "correctedD0BeamspotOutEBPlus"){
1418 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta > 0) value = object->correctedD0;
1419 +    else value = -999;
1420 +  }
1421 +  else if(variable == "correctedD0BeamspotEEPlus"){
1422 +    if(object->isEE && object->eta > 0) value = object->correctedD0;
1423 +    else value = -999;
1424 +  }
1425 +
1426 +  else if(variable == "correctedD0VertexInEBMinus"){
1427 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1428 +    else value = -999;
1429 +  }
1430 +  else if(variable == "correctedD0VertexOutEBMinus"){
1431 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0Vertex;
1432 +    else value = -999;
1433 +  }
1434 +  else if(variable == "correctedD0VertexEEMinus"){
1435 +    if(object->isEE && object->eta < 0) value = object->correctedD0Vertex;
1436 +    else value = -999;
1437 +  }
1438 +
1439 +  else if(variable == "correctedD0BeamspotInEBMinus"){
1440 +    if(fabs(object->eta) < 0.8 && object->eta < 0) value = object->correctedD0;
1441 +    else value = -999;
1442 +  }
1443 +  else if(variable == "correctedD0BeamspotOutEBMinus"){
1444 +    if(object->isEB && fabs(object->eta) > 0.8 && object->eta < 0) value = object->correctedD0;
1445 +    else value = -999;
1446 +  }
1447 +  else if(variable == "correctedD0BeamspotEEMinus"){
1448 +    if(object->isEE && object->eta < 0) value = object->correctedD0;
1449 +    else value = -999;
1450 +  }
1451 +
1452 +  else if(variable == "tightID"){
1453 +    if (object->isEB)
1454 +      {
1455 +        value = fabs(object->delEtaIn) < 0.004 \
1456 +          && fabs (object->delPhiIn) < 0.03 \
1457 +          && object->scSigmaIEtaIEta < 0.01 \
1458 +          && object->hadOverEm < 0.12 \
1459 +          && fabs (object->correctedD0Vertex) < 0.02 \
1460 +          && fabs (object->correctedDZ) < 0.1 \
1461 +          && object->absInvEMinusInvPin < 0.05 \
1462 +          && object->passConvVeto;
1463 +      }
1464 +    else
1465 +      {
1466 +        value = fabs(object->delEtaIn) < 0.005 \
1467 +          && fabs (object->delPhiIn) < 0.02 \
1468 +          && object->scSigmaIEtaIEta < 0.03 \
1469 +          && object->hadOverEm < 0.10 \
1470 +          && fabs (object->correctedD0Vertex) < 0.02 \
1471 +          && fabs (object->correctedDZ) < 0.1 \
1472 +          && object->absInvEMinusInvPin < 0.05 \
1473 +          && object->passConvVeto;
1474 +      }
1475 +  }
1476 +
1477 +  else if(variable == "correctedD0VertexInEBPositiveCharge"){
1478 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1479 +    else value = -999;
1480 +  }
1481 +  else if(variable == "correctedD0VertexOutEBPositiveCharge"){
1482 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0Vertex;
1483 +    else value = -999;
1484 +  }
1485 +  else if(variable == "correctedD0VertexEEPositiveCharge"){
1486 +    if(object->isEE && object->charge > 0) value = object->correctedD0Vertex;
1487 +    else value = -999;
1488 +  }
1489 +
1490 +  else if(variable == "correctedD0BeamspotInEBPositiveCharge"){
1491 +    if(fabs(object->eta) < 0.8 && object->charge > 0) value = object->correctedD0;
1492 +    else value = -999;
1493 +  }
1494 +  else if(variable == "correctedD0BeamspotOutEBPositiveCharge"){
1495 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge > 0) value = object->correctedD0;
1496 +    else value = -999;
1497 +  }
1498 +  else if(variable == "correctedD0BeamspotEEPositiveCharge"){
1499 +    if(object->isEE && object->charge > 0) value = object->correctedD0;
1500 +    else value = -999;
1501 +  }
1502 +
1503 +  else if(variable == "correctedD0VertexInEBNegativeCharge"){
1504 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1505 +    else value = -999;
1506 +  }
1507 +  else if(variable == "correctedD0VertexOutEBNegativeCharge"){
1508 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0Vertex;
1509 +    else value = -999;
1510 +  }
1511 +  else if(variable == "correctedD0VertexEENegativeCharge"){
1512 +    if(object->isEE && object->charge < 0) value = object->correctedD0Vertex;
1513 +    else value = -999;
1514 +  }
1515 +
1516 +  else if(variable == "correctedD0BeamspotInEBNegativeCharge"){
1517 +    if(fabs(object->eta) < 0.8 && object->charge < 0) value = object->correctedD0;
1518 +    else value = -999;
1519 +  }
1520 +  else if(variable == "correctedD0BeamspotOutEBNegativeCharge"){
1521 +    if(object->isEB && fabs(object->eta) > 0.8 && object->charge < 0) value = object->correctedD0;
1522 +    else value = -999;
1523 +  }
1524 +  else if(variable == "correctedD0BeamspotEENegativeCharge"){
1525 +    if(object->isEE && object->charge < 0) value = object->correctedD0;
1526 +    else value = -999;
1527 +  }
1528 +
1529 +
1530 +  else if(variable == "tightIDdisplaced"){
1531 +    if (object->isEB)
1532 +      {
1533 +        value = fabs(object->delEtaIn) < 0.004 \
1534 +          && fabs (object->delPhiIn) < 0.03 \
1535 +          && object->scSigmaIEtaIEta < 0.01 \
1536 +          && object->hadOverEm < 0.12 \
1537 +          && object->absInvEMinusInvPin < 0.05;
1538 +      }
1539 +    else
1540 +      {
1541 +        value = fabs (object->delEtaIn) < 0.005 \
1542 +          && fabs (object->delPhiIn) < 0.02 \
1543 +          && object->scSigmaIEtaIEta < 0.03 \
1544 +          && object->hadOverEm < 0.10 \
1545 +          && object->absInvEMinusInvPin < 0.05;
1546 +      }
1547 +  }
1548 +
1549 +  else if(variable == "genMatchedId"){
1550 +    int index = getGenMatchedParticleIndex(object);
1551 +    if(index == -1) value = 0;
1552 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1553 +  }
1554 +  else if(variable == "genMatchedMotherId"){
1555 +    int index = getGenMatchedParticleIndex(object);
1556 +    if(index == -1) value = 0;
1557 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1558 +  }
1559 +  else if(variable == "genMatchedGrandmotherId"){
1560 +    int index = getGenMatchedParticleIndex(object);
1561 +    if(index == -1) value = 0;
1562 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1563 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1564 +      if(motherIndex == -1) value = 0;
1565 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1566 +    }
1567 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1568 +  }
1569 +
1570  
1571  
1572    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1055 | Line 1646 | OSUAnalysis::valueLookup (const BNevent*
1646    else if(variable == "id1") value = object->id1;
1647    else if(variable == "id2") value = object->id2;
1648    else if(variable == "evt") value = object->evt;
1649 +  else if(variable == "puScaleFactor"){
1650 +    if(datasetType_ != "data")
1651 +      value = puWeight_->at (events->at (0).numTruePV);
1652 +    else
1653 +      value = 1.0;
1654 +  }
1655 +  else if(variable == "muonScaleFactor"){
1656 +    if(datasetType_ != "data")
1657 +      value = muonSFWeight_->at (chosenMuon ()->eta);
1658 +    else
1659 +      value = 1.0;
1660 +  }
1661 +  else if(variable == "electronScaleFactor"){
1662 +    if(datasetType_ != "data")
1663 +      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1664 +    else
1665 +      value = 1.0;
1666 +  }
1667  
1668    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1669  
# Line 1109 | Line 1718 | OSUAnalysis::valueLookup (const BNtau* o
1718    else if(variable == "leadingTrackValid") value = object->leadingTrackValid;
1719  
1720  
1721 +  else if(variable == "genMatchedId"){
1722 +    int index = getGenMatchedParticleIndex(object);
1723 +    if(index == -1) value = 0;
1724 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1725 +  }
1726 +  else if(variable == "genMatchedMotherId"){
1727 +    int index = getGenMatchedParticleIndex(object);
1728 +    if(index == -1) value = 0;
1729 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1730 +  }
1731 +  else if(variable == "genMatchedGrandmotherId"){
1732 +    int index = getGenMatchedParticleIndex(object);
1733 +    if(index == -1) value = 0;
1734 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1735 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1736 +      if(motherIndex == -1) value = 0;
1737 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1738 +    }
1739 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1740 +  }
1741 +
1742 +
1743    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1744  
1745    value = applyFunction(function, value);
# Line 1192 | Line 1823 | double
1823   OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
1824  
1825    double value = 0.0;
1826 +  double pMag = sqrt(object->pt * object->pt +
1827 +                         object->pz * object->pz);
1828  
1829    if(variable == "pt") value = object->pt;
1830    else if(variable == "px") value = object->px;
# Line 1212 | Line 1845 | OSUAnalysis::valueLookup (const BNtrack*
1845    else if(variable == "isHighPurity") value = object->isHighPurity;
1846  
1847  
1848 +  //additional BNs info for disappTrks
1849 +  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
1850 +  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
1851 +  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
1852 +  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
1853 +  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
1854 +  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
1855 +  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
1856 +  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
1857 +  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
1858 +  else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
1859 +  
1860 +
1861 +  //user defined variables
1862 +  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;
1863 +  else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
1864 +  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
1865 +  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
1866 +
1867 +
1868 +
1869 +
1870 +
1871 +  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
1872 +  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
1873 +  else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
1874 +  else if(variable == "ptError") value = object->ptError;
1875 +  else if(variable == "ptRes") value = getTrkPtRes(object);
1876 +
1877 +
1878 +  else if(variable == "genMatchedId"){
1879 +    int index = getGenMatchedParticleIndex(object);
1880 +    if(index == -1) value = 0;
1881 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
1882 +  }
1883 +  else if(variable == "genMatchedMotherId"){
1884 +    int index = getGenMatchedParticleIndex(object);
1885 +    if(index == -1) value = 0;
1886 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
1887 +  }
1888 +  else if(variable == "genMatchedGrandmotherId"){
1889 +    int index = getGenMatchedParticleIndex(object);
1890 +    if(index == -1) value = 0;
1891 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1892 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1893 +      if(motherIndex == -1) value = 0;
1894 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1895 +    }
1896 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1897 +  }
1898 +
1899 +
1900 +
1901    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1902  
1903    value = applyFunction(function, value);
# Line 1339 | Line 2025 | OSUAnalysis::valueLookup (const BNmcpart
2025  
2026    //user-defined variables
2027    else if (variable == "d0"){
2028 <    double vx = object->vx - primaryVertex_->x,
2029 <      vy = object->vy - primaryVertex_->y,
2028 >    double vx = object->vx - chosenVertex ()->x,
2029 >      vy = object->vy - chosenVertex ()->y,
2030        px = object->px,
2031        py = object->py,
2032        pt = object->pt;
2033      value = (-vx * py + vy * px) / pt;
2034    }
2035    else if (variable == "dz"){
2036 <    double vx = object->vx - primaryVertex_->x,
2037 <      vy = object->vy - primaryVertex_->y,
2038 <      vz = object->vz - primaryVertex_->z,
2036 >    double vx = object->vx - chosenVertex ()->x,
2037 >      vy = object->vy - chosenVertex ()->y,
2038 >      vz = object->vz - chosenVertex ()->z,
2039        px = object->px,
2040        py = object->py,
2041        pz = object->pz,
2042        pt = object->pt;
2043      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2044    }
2045 <
2045 >  else if(variable == "v0"){
2046 >    value = sqrt(object->vx*object->vx + object->vy*object->vy);
2047 >  }
2048 >  else if(variable == "deltaV0"){
2049 >    value = sqrt((object->vx-chosenVertex ()->x)*(object->vx-chosenVertex ()->x) + (object->vy-chosenVertex ()->y)*(object->vy-chosenVertex ()->y));
2050 >  }
2051 >  else if (variable == "deltaVx"){
2052 >    value = object->vx - chosenVertex ()->x;
2053 >  }
2054 >  else if (variable == "deltaVy"){
2055 >    value = object->vy - chosenVertex ()->y;
2056 >  }
2057 >  else if (variable == "deltaVz"){
2058 >    value = object->vz - chosenVertex ()->z;
2059 >  }
2060  
2061  
2062    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 1486 | Line 2186 | OSUAnalysis::valueLookup (const BNphoton
2186    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2187  
2188  
2189 +  else if(variable == "genMatchedId"){
2190 +    int index = getGenMatchedParticleIndex(object);
2191 +    if(index == -1) value = 0;
2192 +    else value = getPdgIdBinValue(mcparticles->at(index).id);
2193 +  }
2194 +  else if(variable == "genMatchedMotherId"){
2195 +    int index = getGenMatchedParticleIndex(object);
2196 +    if(index == -1) value = 0;
2197 +    else value = getPdgIdBinValue(mcparticles->at(index).motherId);
2198 +  }
2199 +  else if(variable == "genMatchedGrandmotherId"){
2200 +    int index = getGenMatchedParticleIndex(object);
2201 +    if(index == -1) value = 0;
2202 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2203 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2204 +      if(motherIndex == -1) value = 0;
2205 +      else value = getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2206 +    }
2207 +    else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2208 +  }
2209 +
2210 +
2211    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2212  
2213    value = applyFunction(function, value);
# Line 1517 | Line 2239 | OSUAnalysis::valueLookup (const BNsuperc
2239  
2240  
2241   double
2242 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2243 +
2244 +  double value = 0.0;
2245 +
2246 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2247 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2248 +  else if(variable == "invMass"){
2249 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2250 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2251 +    value = (fourVector1 + fourVector2).M();
2252 +  }
2253 +  else if(variable == "threeDAngle")
2254 +    {
2255 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2256 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2257 +      value = (threeVector1.Angle(threeVector2));
2258 +    }
2259 +  else if(variable == "alpha")
2260 +    {
2261 +      static const double pi = 3.1415926535897932384626433832795028841971693993751058;
2262 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2263 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2264 +      value = (pi-threeVector1.Angle(threeVector2));
2265 +    }
2266 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2267 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2268 +  else if(variable == "d0Sign"){
2269 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2270 +    if(d0Sign < 0) value = -0.5;
2271 +    else if (d0Sign > 0) value = 0.5;
2272 +    else value = -999;
2273 +  }
2274 +  else if(variable == "chargeProduct"){
2275 +    value = object1->charge*object2->charge;
2276 +  }
2277 +  else if(variable == "muon1CorrectedD0Vertex"){
2278 +    value = object1->correctedD0Vertex;
2279 +  }
2280 +  else if(variable == "muon2CorrectedD0Vertex"){
2281 +    value = object2->correctedD0Vertex;
2282 +  }
2283 + else if(variable == "muon1timeAtIpInOut"){
2284 +    value = object1->timeAtIpInOut;
2285 +  }
2286 + else if(variable == "muon2timeAtIpInOut"){
2287 +    value = object2->timeAtIpInOut;
2288 +  }
2289 + else if(variable == "muon1correctedD0")
2290 +   {
2291 +     value = object1->correctedD0;
2292 +   }
2293 + else if(variable == "muon1correctedD0Vertex")
2294 +   {
2295 +     value = object1->correctedD0Vertex;
2296 +   }
2297 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2298 +
2299 +  value = applyFunction(function, value);
2300 +
2301 +  return value;
2302 + }
2303 +
2304 + double
2305 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2306 +
2307 +  double value = 0.0;
2308 +
2309 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2310 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2311 +  else if(variable == "invMass"){
2312 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2313 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2314 +    value = (fourVector1 + fourVector2).M();
2315 +  }
2316 +  else if(variable == "threeDAngle")
2317 +    {
2318 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2319 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2320 +      value = (threeVector1.Angle(threeVector2));
2321 +    }
2322 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2323 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2324 +  else if(variable == "d0Sign"){
2325 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2326 +    if(d0Sign < 0) value = -0.5;
2327 +    else if (d0Sign > 0) value = 0.5;
2328 +    else value = -999;
2329 +  }
2330 +  else if(variable == "chargeProduct"){
2331 +    value = object1->charge*object2->charge;
2332 +  }
2333 +  else if(variable == "electron1CorrectedD0Vertex"){
2334 +    value = object1->correctedD0Vertex;
2335 +  }
2336 +  else if(variable == "electron2CorrectedD0Vertex"){
2337 +    value = object2->correctedD0Vertex;
2338 +  }
2339 +
2340 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2341 +
2342 +  value = applyFunction(function, value);
2343 +
2344 +  return value;
2345 + }
2346 +
2347 + double
2348 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2349 +
2350 +  double value = 0.0;
2351 +
2352 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2353 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2354 +  else if(variable == "invMass"){
2355 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2356 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2357 +    value = (fourVector1 + fourVector2).M();
2358 +  }
2359 +  else if(variable == "threeDAngle")
2360 +    {
2361 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2362 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2363 +      value = (threeVector1.Angle(threeVector2));
2364 +    }
2365 +  else if(variable == "deltaCorrectedD0Vertex") value = object1->correctedD0Vertex - object2->correctedD0Vertex;
2366 +  else if(variable == "deltaAbsCorrectedD0Vertex") value = fabs(object1->correctedD0Vertex) - fabs(object2->correctedD0Vertex);
2367 +  else if(variable == "d0Sign"){
2368 +    double d0Sign = (object1->correctedD0Vertex*object2->correctedD0Vertex)/fabs(object1->correctedD0Vertex*object2->correctedD0Vertex);
2369 +    if(d0Sign < 0) value = -0.5;
2370 +    else if (d0Sign > 0) value = 0.5;
2371 +    else value = -999;
2372 +  }
2373 +  else if(variable == "chargeProduct"){
2374 +    value = object1->charge*object2->charge;
2375 +  }
2376 +  else if(variable == "electronCorrectedD0Vertex"){
2377 +    value = object1->correctedD0Vertex;
2378 +  }
2379 +  else if(variable == "muonCorrectedD0Vertex"){
2380 +    value = object2->correctedD0Vertex;
2381 +  }
2382 +  else if(variable == "electronCorrectedD0"){
2383 +    value = object1->correctedD0;
2384 +  }
2385 +  else if(variable == "muonCorrectedD0"){
2386 +    value = object2->correctedD0;
2387 +  }
2388 +  else if(variable == "electronDetIso"){
2389 +    value = (object1->trackIso) / object1->pt;
2390 +  }
2391 +  else if(variable == "muonDetIso"){
2392 +    value = (object2->trackIsoDR03) / object2->pt;
2393 +  }
2394 +  else if(variable == "chargeProduct"){
2395 +    value = object1->charge * object2->charge;
2396 +  }
2397 +
2398 +
2399 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2400 +
2401 +  value = applyFunction(function, value);
2402 +
2403 +  return value;
2404 + }
2405 +
2406 +
2407 + // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
2408 + // Return true iff no other tracks are found in this cone.
2409 + int
2410 + OSUAnalysis::getTrkIsIso (const BNtrack* track1, const BNtrackCollection* trackColl){
2411 +  for(BNtrackCollection::const_iterator track2 = trackColl->begin(); track2 !=trackColl->end(); track2++){
2412 +    if(track1->eta == track2->eta && track1->phi == track2->phi) continue; // Do not compare the track to itself.
2413 +    double deltaRtrk = deltaR(track1->eta, track1->phi, track2->eta, track2->phi);
2414 +    if(deltaRtrk < 0.5) return 0;
2415 +  }
2416 +  return 1;
2417 +
2418 + }
2419 +
2420 +
2421 + double
2422 + OSUAnalysis::getTrkPtRes (const BNtrack* track1){
2423 +
2424 +  double ptTrue = getTrkPtTrue(track1, mcparticles.product());
2425 +  double PtRes = (track1->pt - ptTrue) / ptTrue;
2426 +
2427 +  return PtRes;
2428 +
2429 + }
2430 +
2431 +
2432 + double
2433 + OSUAnalysis::getTrkPtTrue (const BNtrack* track1, const BNmcparticleCollection* genPartColl){
2434 +  double value = -99;
2435 +  double genDeltaRLowest = 999;
2436 +
2437 +  for (BNmcparticleCollection::const_iterator genPart = genPartColl->begin(); genPart !=genPartColl->end(); genPart++){
2438 +    double genDeltaRtemp = deltaR(genPart->eta, genPart->phi,track1->eta, track1->phi);
2439 +    if (genDeltaRtemp < genDeltaRLowest) {
2440 +      genDeltaRLowest = genDeltaRtemp;
2441 +      if (genDeltaRLowest < 0.05) {   // Only consider it truth-matched if DeltaR<0.15.
2442 +        double ptTrue = genPart->pt;
2443 +        value = ptTrue;
2444 +      }
2445 +    }
2446 +  }
2447 +
2448 +  return value;
2449 +
2450 + }
2451 +
2452 + //creates a map of the dead Ecal channels in the barrel and endcap
2453 + //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
2454 + //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
2455 + void
2456 + OSUAnalysis::WriteDeadEcal (){
2457 +  double etaEcal, phiEcal;
2458 +  ifstream DeadEcalFile(deadEcalFile_);
2459 +  if(!DeadEcalFile) {
2460 +    cout << "Error: DeadEcalFile has not been found." << endl;
2461 +    return;
2462 +  }
2463 +  if(DeadEcalVec.size()!= 0){
2464 +    cout << "Error: DeadEcalVec has a nonzero size" << endl;
2465 +    return;
2466 +  }
2467 +  while(!DeadEcalFile.eof())
2468 +    {
2469 +      DeadEcalFile >> etaEcal >> phiEcal;
2470 +      DeadEcal newChan;
2471 +      newChan.etaEcal = etaEcal;
2472 +      newChan.phiEcal = phiEcal;
2473 +      DeadEcalVec.push_back(newChan);
2474 +    }
2475 +  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
2476 + }
2477 +
2478 + //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
2479 + int
2480 + OSUAnalysis::getTrkIsMatchedDeadEcal (const BNtrack* track1){
2481 +  double deltaRLowest = 999;
2482 +  int value = 0;
2483 +  if (DeadEcalVec.size() == 0) WriteDeadEcal();
2484 +  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
2485 +    double eta = ecal->etaEcal;
2486 +    double phi = ecal->phiEcal;
2487 +    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
2488 +    if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
2489 +  }
2490 +  if (deltaRLowest<0.05) {value = 1;}
2491 +  else {value = 0;}
2492 +  return value;
2493 + }
2494 +
2495 +
2496 +
2497 +
2498 + double
2499   OSUAnalysis::applyFunction(string function, double value){
2500  
2501    if(function == "abs") value = fabs(value);
2502 +  else if(function == "fabs") value = fabs(value);
2503 +  else if(function == "log10") value = log10(value);
2504 +  else if(function == "log") value = log10(value);
2505  
2506 +  else if(function == "") value = value;
2507 +  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
2508  
2509    return value;
2510  
# Line 1533 | Line 2517 | void OSUAnalysis::setObjectFlags(cut &cu
2517  
2518    for (uint object = 0; object != inputCollection->size(); object++){
2519  
2520 +
2521      bool decision = true;//object passes if this cut doesn't cut on that type of object
2522  
1538    if(currentCut.inputCollection == inputType){
2523  
2524 <      double value = valueLookup(&inputCollection->at(object), currentCut.variable, currentCut.function);
2524 >    if(currentCut.inputCollection == inputType){
2525  
2526 <      decision = evaluateComparison(value,currentCut.comparativeOperator,currentCut.cutValue);
2526 >      vector<bool> subcutDecisions;
2527 >      for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2528 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2529 >        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2530 >      }
2531 >      if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2532 >      else{
2533 >        bool tempDecision = true;
2534 >        for( int subcutIndex = 0;subcutIndex != currentCut.numSubcuts-1; subcutIndex++){
2535 >          if(currentCut.logicalOperators.at(subcutIndex) == "&" || currentCut.logicalOperators.at(subcutIndex) == "&&")
2536 >            tempDecision = subcutDecisions.at(subcutIndex) && subcutDecisions.at(subcutIndex+1);
2537 >          else if(currentCut.logicalOperators.at(subcutIndex) == "|"|| currentCut.logicalOperators.at(subcutIndex) == "||")
2538 >            tempDecision = subcutDecisions.at(subcutIndex) || subcutDecisions.at(subcutIndex+1);
2539 >        }
2540 >        decision = tempDecision;
2541 >      }
2542      }
2543 <    individualFlags[inputType].at(currentCutIndex).push_back(decision);
2543 >    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2544  
2545  
2546      //set flags for objects that pass each cut AND all the previous cuts
2547      bool previousCumulativeFlag = true;
2548      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2549 <      if(previousCumulativeFlag && individualFlags[inputType].at(previousCutIndex).at(object)) previousCumulativeFlag = true;
2549 >      if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(object)) previousCumulativeFlag = true;
2550        else{ previousCumulativeFlag = false; break;}
2551      }
2552 <    cumulativeFlags[inputType].at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2552 >    cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
2553 >
2554 >
2555 >  }
2556 >
2557 > }
2558 >
2559 >
2560 > template <class InputCollection1, class InputCollection2>
2561 > void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
2562 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, string inputType){
2563 >
2564 >
2565 >  bool sameObjects = false;
2566 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2567 >
2568 >
2569 >  int counter = 0;
2570 >  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2571 >    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2572 >
2573 >      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2574 >
2575 >
2576 >      bool decision = true;//object passes if this cut doesn't cut on that type of object
2577 >
2578 >      if(currentCut.inputCollection == inputType){
2579 >
2580 >        vector<bool> subcutDecisions;
2581 >        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
2582 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
2583 >          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
2584 >        }
2585 >
2586 >        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
2587 >        else{
2588 >          bool tempDecision = subcutDecisions.at(0);
2589 >          for( int subcutIndex = 1; subcutIndex < currentCut.numSubcuts; subcutIndex++){
2590 >            if(currentCut.logicalOperators.at(subcutIndex-1) == "&" || currentCut.logicalOperators.at(subcutIndex-1) == "&&")
2591 >              tempDecision = tempDecision && subcutDecisions.at(subcutIndex);
2592 >            else if(currentCut.logicalOperators.at(subcutIndex-1) == "|"|| currentCut.logicalOperators.at(subcutIndex-1) == "||")
2593 >              tempDecision = tempDecision || subcutDecisions.at(subcutIndex);
2594 >          }
2595 >          decision = tempDecision;
2596 >        }
2597 >      }
2598 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
2599 >
2600 >      //set flags for objects that pass each cut AND all the previous cuts
2601 >      bool previousCumulativeFlag = true;
2602 >      for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
2603 >        if(previousCumulativeFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter)) previousCumulativeFlag = true;
2604 >        else{ previousCumulativeFlag = false; break;}
2605 >      }
2606 >      //apply flags for the components of the composite object as well
2607 >      bool currentCumulativeFlag = true;
2608 >      if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision;
2609 >      else if(flags1.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags2.at(object2);
2610 >      else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
2611 >      else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
2612 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
2613 >
2614 >      counter++;
2615 >    }
2616  
2617    }
2618  
2619 +
2620   }
2621  
2622  
2623   template <class InputCollection>
2624 < void OSUAnalysis::fillHistogram(TH1* histo, histogram parameters, InputCollection inputCollection){
2624 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2625 >
2626 >  for (uint object = 0; object != inputCollection->size(); object++){
2627 >
2628 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
2629 >
2630 >    string currentString = parameters.inputVariables.at(0);
2631 >    string inputVariable = "";
2632 >    string function = "";
2633 >    if(currentString.find("(")==std::string::npos){
2634 >      inputVariable = currentString;// variable to cut on
2635 >    }
2636 >    else{
2637 >      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2638 >      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2639 >      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2640 >    }
2641  
2642 +    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
2643 +    histo->Fill(value,scaleFactor);
2644 +
2645 +  }
2646 +
2647 + }
2648 +
2649 + template <class InputCollection1, class InputCollection2>
2650 + void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
2651 +
2652 +  bool sameObjects = false;
2653 +  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2654 +
2655 +  int pairCounter = 0;
2656 +  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2657 +    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2658 +
2659 +      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2660 +
2661 +      //only take objects which have passed all cuts and pairs which have passed all cuts
2662 +      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2663 +      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2664 +      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
2665 +
2666 +      string currentString = parameters.inputVariables.at(0);
2667 +      string inputVariable = "";
2668 +      string function = "";
2669 +      if(currentString.find("(")==std::string::npos){
2670 +        inputVariable = currentString;// variable to cut on
2671 +      }
2672 +      else{
2673 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2674 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2675 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2676 +      }
2677 +
2678 +      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2679 +      histo->Fill(value,scaleFactor);
2680 +
2681 +      pairCounter++;
2682 +    }
2683 +  }
2684 +
2685 + }
2686 +
2687 +
2688 + template <class InputCollection>
2689 + void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection inputCollection,vector<bool> flags, double scaleFactor){
2690  
2691    for (uint object = 0; object != inputCollection->size(); object++){
2692 <    if(parameters.inputVariables.size() == 1){
2693 <      double value = valueLookup(&inputCollection->at(object), parameters.inputVariables.at(0), parameters.function);
2694 <      histo->Fill(value);
2695 <    }
2696 <    else if(parameters.inputVariables.size() == 2){
2697 <      double valueX = valueLookup(&inputCollection->at(object), parameters.inputVariables.at(0), parameters.function);
2698 <      double valueY = valueLookup(&inputCollection->at(object), parameters.inputVariables.at(1), parameters.function);
2699 <      histo->Fill(valueX,valueY);
2692 >
2693 >    if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
2694 >
2695 >    string currentString = parameters.inputVariables.at(0);
2696 >    string inputVariable = "";
2697 >    string function = "";
2698 >    if(currentString.find("(")==std::string::npos){
2699 >      inputVariable = currentString;// variable to cut on
2700      }
2701 +    else{
2702 +      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2703 +      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2704 +      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2705 +    }
2706 +    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
2707 +
2708 +    currentString = parameters.inputVariables.at(1);
2709 +    inputVariable = "";
2710 +    function = "";
2711 +    if(currentString.find("(")==std::string::npos){
2712 +      inputVariable = currentString;// variable to cut on
2713 +    }
2714 +    else{
2715 +      function = currentString.substr(0,currentString.find("("));//function comes before the "("
2716 +      inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2717 +      inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2718 +    }
2719 +
2720 +    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
2721 +
2722 +    histo->Fill(valueX,valueY,scaleFactor);
2723 +
2724    }
2725  
2726   }
2727  
2728 + template <class InputCollection1, class InputCollection2>
2729 + void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, vector<bool> flags1, vector<bool> flags2, vector<bool> pairFlags, double scaleFactor){
2730 +
2731 +  bool sameObjects = false;
2732 +  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
2733 +
2734 +  int pairCounter = 0;
2735 +  for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
2736 +    for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
2737 +
2738 +      if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
2739 +
2740 +      //only take objects which have passed all cuts and pairs which have passed all cuts
2741 +      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
2742 +      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
2743 +      if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
2744 +
2745 +      string currentString = parameters.inputVariables.at(0);
2746 +      string inputVariable = "";
2747 +      string function = "";
2748 +      if(currentString.find("(")==std::string::npos){
2749 +        inputVariable = currentString;// variable to cut on
2750 +      }
2751 +      else{
2752 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2753 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2754 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2755 +      }
2756 +      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2757 +
2758 +      currentString = parameters.inputVariables.at(1);
2759 +      inputVariable = "";
2760 +      function = "";
2761 +      if(currentString.find("(")==std::string::npos){
2762 +        inputVariable = currentString;// variable to cut on
2763 +      }
2764 +      else{
2765 +        function = currentString.substr(0,currentString.find("("));//function comes before the "("
2766 +        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
2767 +        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
2768 +      }
2769 +      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
2770  
2771  
2772 +      histo->Fill(valueX,valueY,scaleFactor);
2773  
2774 < DEFINE_FWK_MODULE(OSUAnalysis);
2774 >      pairCounter++;
2775 >
2776 >    }
2777 >  }
2778 >
2779 > }
2780 >
2781 >
2782 > template <class InputObject>
2783 > int OSUAnalysis::getGenMatchedParticleIndex(InputObject object){
2784  
2785 +  int bestMatchIndex = -1;
2786 +  double bestMatchDeltaR = 999;
2787  
2788 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2789 +
2790 +    double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
2791 +    if(currentDeltaR > 0.05) continue;
2792 + //     cout << std::setprecision(3) << std::setw(20)
2793 + //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
2794 + //          << std::setw(20)
2795 + //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
2796 + //          << std::setw(20)
2797 + //          << "\tdeltaR = " << currentDeltaR
2798 + //          << std::setprecision(1)
2799 + //          << std::setw(20)
2800 + //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
2801 + //          << std::setw(20)
2802 + //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
2803 + //          << std::setw(20)
2804 + //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
2805 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2806 +      bestMatchIndex = mcparticle - mcparticles->begin();
2807 +      bestMatchDeltaR = currentDeltaR;
2808 +    }
2809 +
2810 +  }
2811 + //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
2812 + //   else cout << "no match found..." << endl;
2813 +  return bestMatchIndex;
2814 +
2815 + }
2816 +
2817 +
2818 + int OSUAnalysis::findTauMotherIndex(const BNmcparticle* tau){
2819 +
2820 +  int bestMatchIndex = -1;
2821 +  double bestMatchDeltaR = 999;
2822 +
2823 +  for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
2824 +
2825 +    if(fabs(mcparticle->id) != 15 || mcparticle->status !=3) continue;
2826 +
2827 +    double currentDeltaR = deltaR(tau->eta,tau->phi,mcparticle->eta,mcparticle->phi);
2828 +    if(currentDeltaR > 0.05) continue;
2829 +
2830 +    if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
2831 +      bestMatchIndex = mcparticle - mcparticles->begin();
2832 +      bestMatchDeltaR = currentDeltaR;
2833 +    }
2834 +
2835 +  }
2836 +
2837 +  return bestMatchIndex;
2838 + }
2839 +
2840 +
2841 + // bin      particle type
2842 + // ---      -------------
2843 + //  0        unmatched
2844 + //  1        u
2845 + //  2        d
2846 + //  3        s
2847 + //  4        c
2848 + //  5        b
2849 + //  6        t
2850 + //  7        e
2851 + //  8        mu
2852 + //  9        tau
2853 + // 10        nu
2854 + // 11        g
2855 + // 12        gamma
2856 + // 13        Z
2857 + // 14        W
2858 + // 15        light meson
2859 + // 16        K meson
2860 + // 17        D meson
2861 + // 18        B meson
2862 + // 19        light baryon
2863 + // 20        strange baryon
2864 + // 21        charm baryon
2865 + // 22        bottom baryon
2866 + // 23        other
2867 +
2868 + int OSUAnalysis::getPdgIdBinValue(int pdgId){
2869 +
2870 +  int binValue = -999;
2871 +  int absPdgId = fabs(pdgId);
2872 +  if(pdgId == -1) binValue = 0;
2873 +  else if(absPdgId <= 6 ) binValue = absPdgId;
2874 +  else if(absPdgId == 11 ) binValue = 7;
2875 +  else if(absPdgId == 13 ) binValue = 8;
2876 +  else if(absPdgId == 15 ) binValue = 9;
2877 +  else if(absPdgId == 12 || absPdgId == 14 || absPdgId == 16 ) binValue = 10;
2878 +  else if(absPdgId == 21 ) binValue = 11;
2879 +  else if(absPdgId == 22 ) binValue = 12;
2880 +  else if(absPdgId == 23 ) binValue = 13;
2881 +  else if(absPdgId == 24 ) binValue = 14;
2882 +  else if(absPdgId > 100 && absPdgId < 300 && absPdgId != 130  ) binValue = 15;
2883 +  else if( absPdgId == 130 || (absPdgId > 300 && absPdgId < 400)  ) binValue = 16;
2884 +  else if(absPdgId > 400 && absPdgId < 500  ) binValue = 17;
2885 +  else if(absPdgId > 500 && absPdgId < 600  ) binValue = 18;
2886 +  else if(absPdgId > 1000 && absPdgId < 3000  ) binValue = 19;
2887 +  else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
2888 +  else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
2889 +  else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
2890 +
2891 +  else binValue = 23;
2892 +
2893 +  return binValue;
2894 +
2895 + }
2896 +
2897 + const BNprimaryvertex *
2898 + OSUAnalysis::chosenVertex ()
2899 + {
2900 +  const BNprimaryvertex *chosenVertex = 0;
2901 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
2902 +    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
2903 +                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
2904 +    for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
2905 +      if(!vertexFlags.at(vertexIndex)) continue;
2906 +      chosenVertex = & primaryvertexs->at(vertexIndex);
2907 +      break;
2908 +    }
2909 +  }
2910 +  else {
2911 +    chosenVertex = &primaryvertexs->at(0);
2912 +  }
2913 +
2914 +  return chosenVertex;
2915 + }
2916 +
2917 + const BNmet *
2918 + OSUAnalysis::chosenMET ()
2919 + {
2920 +  const BNmet *chosenMET = 0;
2921 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
2922 +    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
2923 +                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
2924 +    for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
2925 +      if(!metFlags.at(metIndex)) continue;
2926 +      chosenMET = & mets->at(metIndex);
2927 +      break;
2928 +    }
2929 +  }
2930 +  else {
2931 +    chosenMET = &mets->at(0);
2932 +  }
2933 +
2934 +  return chosenMET;
2935 + }
2936 +
2937 + const BNelectron *
2938 + OSUAnalysis::chosenElectron ()
2939 + {
2940 +  const BNelectron *chosenElectron = 0;
2941 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
2942 +    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
2943 +                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
2944 +    for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
2945 +      if(!electronFlags.at(electronIndex)) continue;
2946 +      chosenElectron = & electrons->at(electronIndex);
2947 +      break;
2948 +    }
2949 +  }
2950 +  else {
2951 +    chosenElectron = &electrons->at(0);
2952 +  }
2953 +
2954 +  return chosenElectron;
2955 + }
2956 +
2957 + const BNmuon *
2958 + OSUAnalysis::chosenMuon ()
2959 + {
2960 +  const BNmuon *chosenMuon = 0;
2961 +  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
2962 +    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
2963 +                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
2964 +    for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
2965 +      if(!muonFlags.at(muonIndex)) continue;
2966 +      chosenMuon = & muons->at(muonIndex);
2967 +      break;
2968 +    }
2969 +  }
2970 +  else {
2971 +    chosenMuon = &muons->at(0);
2972 +  }
2973 +
2974 +  return chosenMuon;
2975 + }
2976 +
2977 +
2978 + DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines