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.39 by jbrinson, Wed Mar 27 16:52:25 2013 UTC vs.
Revision 1.72 by lantonel, Wed May 29 20:15:01 2013 UTC

# Line 11 | Line 11 | OSUAnalysis::OSUAnalysis (const edm::Par
11    tracks_ (cfg.getParameter<edm::InputTag> ("tracks")),
12    genjets_ (cfg.getParameter<edm::InputTag> ("genjets")),
13    mcparticles_ (cfg.getParameter<edm::InputTag> ("mcparticles")),
14 +  stops_ (cfg.getParameter<edm::InputTag> ("stops")),
15    primaryvertexs_ (cfg.getParameter<edm::InputTag> ("primaryvertexs")),
16    bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
17    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
18    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
19    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
20 <  puFile_ (cfg.getParameter<std::string> ("puFile")),
21 <  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
22 <  
23 < muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
24 <  dataPU_ (cfg.getParameter<std::string> ("dataPU")),
25 <  electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
26 <  muonSF_ (cfg.getParameter<std::string> ("muonSF")),
27 <  dataset_ (cfg.getParameter<std::string> ("dataset")),
28 <  datasetType_ (cfg.getParameter<std::string> ("datasetType")),
20 >  trigobjs_ (cfg.getParameter<edm::InputTag> ("trigobjs")),
21 >  puFile_ (cfg.getParameter<string> ("puFile")),
22 >  deadEcalFile_ (cfg.getParameter<string> ("deadEcalFile")),
23 >  muonSFFile_ (cfg.getParameter<string> ("muonSFFile")),
24 >  dataPU_ (cfg.getParameter<string> ("dataPU")),
25 >  electronSFID_ (cfg.getParameter<string> ("electronSFID")),
26 >  muonSF_ (cfg.getParameter<string> ("muonSF")),
27 >  dataset_ (cfg.getParameter<string> ("dataset")),
28 >  datasetType_ (cfg.getParameter<string> ("datasetType")),
29    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
30    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
31    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
32    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
33 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo"))
33 >  applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
34 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
36 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
37 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
38   {
39  
40    TH1::SetDefaultSumw2 ();
# Line 37 | Line 42 | muonSFFile_ (cfg.getParameter<std::strin
42    //create pile-up reweighting object, if necessary
43    if(datasetType_ != "data") {
44      if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
45 <    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
46 <    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
45 >    if (applyLeptonSF_){
46 >      muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
47 >      electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
48 >    }
49    }
50 +  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
51 +    stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
52  
53  
54    // Construct Cutflow Objects. These store the results of cut decisions and
55    // handle filling cut flow histograms.
56    masterCutFlow_ = new CutFlow (fs_);
48  std::vector<TFileDirectory> directories;
57  
58    //always get vertex collection so we can assign the primary vertex in the event
59    objectsToGet.push_back("primaryvertexs");
60  
61 <  //always make the plot of number of primary verticex (to check pile-up reweighting)
61 >  //always make the plot of number of primary vertices (to check pile-up reweighting)
62    objectsToPlot.push_back("primaryvertexs");
63  
64    //always get the MC particles to do GEN-matching
# Line 64 | Line 72 | muonSFFile_ (cfg.getParameter<std::strin
72  
73      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
74      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
75 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
76 <      objectsToGet.push_back(tempInputCollection);
75 >    if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
76 >    if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
77 >    if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
78 >    if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
79 >    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
80 >    if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
81 >    if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
82 >    if(tempInputCollection.find("pairs")==string::npos){ //just a single object
83 >      if(tempInputCollection.find("secondary")!=string::npos){//secondary object
84 >        int spaceIndex = tempInputCollection.find(" ");
85 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
86 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
87 >      }
88 >      else{
89 >        objectsToGet.push_back(tempInputCollection);
90 >      }
91        objectsToPlot.push_back(tempInputCollection);
92        objectsToCut.push_back(tempInputCollection);
93      }
94 <    else{//pair of objects, need to add them both to the things to objectsToGet
95 <      int dashIndex = tempInputCollection.find("-");
96 <      int spaceIndex = tempInputCollection.find(" ");
97 <      int secondWordLength = spaceIndex - dashIndex;
98 <      objectsToGet.push_back(tempInputCollection);
77 <      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
78 <      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
79 <      objectsToPlot.push_back(tempInputCollection);
80 <      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
81 <      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
94 >    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
95 >      string obj1;
96 >      string obj2;
97 >      getTwoObjs(tempInputCollection, obj1, obj2);
98 >      string obj2ToGet = getObjToGet(obj2);
99        objectsToCut.push_back(tempInputCollection);
100 <      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
101 <      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
100 >      objectsToCut.push_back(obj1);
101 >      objectsToCut.push_back(obj2);
102 >      objectsToPlot.push_back(tempInputCollection);
103 >      objectsToPlot.push_back(obj1);
104 >      objectsToPlot.push_back(obj2);
105 >      objectsToGet.push_back(tempInputCollection);
106 >      objectsToGet.push_back(obj1);
107 >      objectsToGet.push_back(obj2ToGet);
108  
109 <      }
109 >    }
110  
111      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
112  
113      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
114  
115 +      vector<double> defaultValue;
116 +      defaultValue.push_back (-1.0);
117 +
118        histogram tempHistogram;
119        tempHistogram.inputCollection = tempInputCollection;
120        tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
121        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
122 <      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
122 >      tempHistogram.bins = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("bins", defaultValue);
123 >      tempHistogram.variableBinsX = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsX", defaultValue);
124 >      tempHistogram.variableBinsY = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsY", defaultValue);
125        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
126  
127        histograms.push_back(tempHistogram);
# Line 110 | Line 138 | muonSFFile_ (cfg.getParameter<std::strin
138    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
139  
140      string currentObject = objectsToPlot.at(currentObjectIndex);
141 <    if(currentObject != "muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
141 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
142  
143      histogram tempIdHisto;
144      histogram tempMomIdHisto;
145      histogram tempGmaIdHisto;
146      histogram tempIdVsMomIdHisto;
147 +    histogram tempIdVsGmaIdHisto;
148  
149      tempIdHisto.inputCollection = currentObject;
150      tempMomIdHisto.inputCollection = currentObject;
151      tempGmaIdHisto.inputCollection = currentObject;
152      tempIdVsMomIdHisto.inputCollection = currentObject;
153 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
154 +
155 +    if(currentObject == "secondary muons") currentObject = "secondaryMuons";
156 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
157  
158      currentObject = currentObject.substr(0, currentObject.size()-1);
159      tempIdHisto.name = currentObject+"GenMatchId";
160      tempMomIdHisto.name = currentObject+"GenMatchMotherId";
161      tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
162      tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
163 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
164  
165      currentObject.at(0) = toupper(currentObject.at(0));
166      tempIdHisto.title = currentObject+" Gen-matched Particle";
167      tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
168      tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
169      tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
170 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
171 +
172  
173 <    int maxNum = 24;
173 >    int maxNum = 25;
174      vector<double> binVector;
175      binVector.push_back(maxNum);
176      binVector.push_back(0);
# Line 152 | Line 188 | muonSFFile_ (cfg.getParameter<std::strin
188      tempIdVsMomIdHisto.bins = binVector;
189      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
190      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
191 +    tempIdVsGmaIdHisto.bins = binVector;
192 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
193 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
194  
195      histograms.push_back(tempIdHisto);
196      histograms.push_back(tempMomIdHisto);
197      histograms.push_back(tempGmaIdHisto);
198      histograms.push_back(tempIdVsMomIdHisto);
199 +    histograms.push_back(tempIdVsGmaIdHisto);
200    }
201  
202  
# Line 172 | Line 212 | muonSFFile_ (cfg.getParameter<std::strin
212      //set triggers for this channel
213      vector<string> triggerNames;
214      triggerNames.clear();
215 +    vector<string> triggerToVetoNames;
216 +    triggerToVetoNames.clear();
217 +
218      tempChannel.triggers.clear();
219 +    tempChannel.triggersToVeto.clear();
220      if(channels_.at(currentChannel).exists("triggers")){
221        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
222        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
223          tempChannel.triggers.push_back(triggerNames.at(trigger));
224        objectsToGet.push_back("triggers");
225      }
226 <
226 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
227 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
228 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
229 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
230 >      objectsToGet.push_back("triggers");
231 >    }
232  
233  
234  
235      //create cutFlow for this channel
236      cutFlows_.push_back (new CutFlow (fs_, channelName));
237 +    vector<TFileDirectory> directories; //vector of directories in the output file.
238 +    vector<string> subSubDirNames;//subdirectories in each channel.
239 +    //get list of cuts for this channel
240 +    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
241  
189    //book a directory in the output file with the name of the channel
190    TFileDirectory subDir = fs_->mkdir( channelName );
191    directories.push_back(subDir);
242  
243 <    std::map<std::string, TH1D*> oneDhistoMap;
244 <    oneDHists_.push_back(oneDhistoMap);
245 <    std::map<std::string, TH2D*> twoDhistoMap;
246 <    twoDHists_.push_back(twoDhistoMap);
243 >    //loop over and parse all cuts
244 >    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
245 >      cut tempCut;
246 >      //store input collection for cut
247 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
248 >      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
249 >      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
250 >      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
251 >      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
252 >      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
253 >      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
254 >      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
255 >      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
256 >      tempCut.inputCollection = tempInputCollection;
257 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
258 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
259 >          int spaceIndex = tempInputCollection.find(" ");
260 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
261 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
262 >        }
263 >        else{
264 >          objectsToGet.push_back(tempInputCollection);
265 >        }
266 >        objectsToCut.push_back(tempInputCollection);
267 >      }
268 >      else{//pair of objects, need to add them both to objectsToGet
269 >        string obj1;
270 >        string obj2;
271 >        getTwoObjs(tempInputCollection, obj1, obj2);
272 >        string obj2ToGet = getObjToGet(obj2);
273 >        objectsToCut.push_back(tempInputCollection);
274 >        objectsToCut.push_back(obj1);
275 >        objectsToCut.push_back(obj2);
276 >        objectsToGet.push_back(tempInputCollection);
277 >        objectsToGet.push_back(obj1);
278 >        objectsToGet.push_back(obj2ToGet);
279 >
280 >      }
281 >
282  
283  
284 +      //split cut string into parts and store them
285 +      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
286 +      vector<string> cutStringVector = splitString(cutString);
287 +      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
288 +        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
289 +        exit(0);
290 +      }
291 +      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
292 +      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
293 +        int indexOffset = 4 * subcutIndex;
294 +        string currentVariableString = cutStringVector.at(indexOffset);
295 +        if(currentVariableString.find("(")==string::npos){
296 +          tempCut.functions.push_back("");//no function was specified
297 +          tempCut.variables.push_back(currentVariableString);// variable to cut on
298 +        }
299 +        else{
300 +          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
301 +          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
302 +          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
303 +        }
304 +        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
305 +        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
306 +        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
307 +        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
308 +      }
309 +
310 +      //get number of objects required to pass cut for event to pass
311 +      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
312 +      vector<string> numberRequiredVector = splitString(numberRequiredString);
313 +      if(numberRequiredVector.size()!=2){
314 +        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
315 +        exit(0);
316 +      }
317 +
318 +      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
319 +      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
320 +      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
321 +
322 +      //Set up vectors to store the directories and subDIrectories for each channel.
323 +      string subSubDirName;
324 +      string tempCutName;
325 +      if(cuts_.at(currentCut).exists("alias")){
326 +        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
327 +        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
328 +      }
329 +      else{
330 +        //construct string for cutflow table
331 +        bool plural = numberRequiredInt != 1;
332 +        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
333 +        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
334 +        tempCutName = cutName;
335 +        subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
336 +      }
337  
338 +      subSubDirNames.push_back(subSubDirName);
339 +      tempCut.name = tempCutName;
340 +
341 +      tempChannel.cuts.push_back(tempCut);
342 +
343 +
344 +    }//end loop over cuts
345 +
346 +    vector<map<string, TH1D*>> oneDHistsTmp;
347 +    vector<map<string, TH2D*>> twoDHistsTmp;
348 +    //book a directory in the output file with the name of the channel
349 +    TFileDirectory subDir = fs_->mkdir( channelName );
350 +    //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
351 +    if(GetPlotsAfterEachCut_){
352 +       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
353 +            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
354 +            directories.push_back(subSubDir);
355 +            map<string, TH1D*> oneDhistoMap;
356 +            oneDHistsTmp.push_back(oneDhistoMap);
357 +            map<string, TH2D*> twoDhistoMap;
358 +            twoDHistsTmp.push_back(twoDhistoMap);
359 +      }
360 +      oneDHists_.push_back(oneDHistsTmp);
361 +      twoDHists_.push_back(twoDHistsTmp);
362 +    }
363 +   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
364 +   else{
365 +      map<string, TH1D*> oneDhistoMap;
366 +      oneDHistsTmp.push_back(oneDhistoMap);
367 +      map<string, TH2D*> twoDhistoMap;
368 +      twoDHistsTmp.push_back(twoDhistoMap);
369 +      oneDHists_.push_back(oneDHistsTmp);
370 +      twoDHists_.push_back(twoDHistsTmp);
371 +      directories.push_back(subDir);
372 +   }
373      //book all histograms included in the configuration
374 +    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
375      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
376        histogram currentHistogram = histograms.at(currentHistogramIndex);
377        int numBinsElements = currentHistogram.bins.size();
378        int numInputVariables = currentHistogram.inputVariables.size();
379 +      int numBinEdgesX = currentHistogram.variableBinsX.size();
380 +      int numBinEdgesY = currentHistogram.variableBinsY.size();
381  
382 <      if(numBinsElements != 3 && numBinsElements !=6) {
383 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
382 >      if(numBinsElements == 1){
383 >        if(numBinEdgesX > 1){
384 >          if(numBinEdgesY > 1)
385 >            numBinsElements = 6;
386 >          else
387 >            numBinsElements = 3;
388 >        }
389 >      }
390 >      if(numBinsElements != 3 && numBinsElements !=6){
391 >        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
392          exit(0);
393        }
394        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
395 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
395 >        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
396          exit(0);
397        }
398        else if(numBinsElements == 3){
399 <        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));
399 >        if (currentHistogram.bins.size () == 3)
400 >          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2));
401 >        else
402 >          {
403 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
404 >          }
405        }
406        else if(numBinsElements == 6){
407 <        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));
408 <
407 >        if (currentHistogram.bins.size () == 6)
408 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, currentHistogram.bins.at(0), currentHistogram.bins.at(1), currentHistogram.bins.at(2),currentHistogram.bins.at(3),currentHistogram.bins.at(4),currentHistogram.bins.at(5));
409 >        else
410 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
411        }
412  
413  
414 <      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
414 >      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
415  
416 < // bin      particle type
417 < // ---      -------------
418 < //  0        unmatched
419 < //  1        u
420 < //  2        d
421 < //  3        s
422 < //  4        c
423 < //  5        b
424 < //  6        t
425 < //  7        e
426 < //  8        mu
427 < //  9        tau
428 < // 10        nu
429 < // 11        g
430 < // 12        gamma
431 < // 13        Z
432 < // 14        W
433 < // 15        light meson
434 < // 16        K meson
435 < // 17        D meson
436 < // 18        B meson
437 < // 19        light baryon
438 < // 20        strange baryon
439 < // 21        charm baryon
440 < // 22        bottom baryon
441 < // 23        other
416 >      // bin      particle type
417 >      // ---      -------------
418 >      //  0        unmatched
419 >      //  1        u
420 >      //  2        d
421 >      //  3        s
422 >      //  4        c
423 >      //  5        b
424 >      //  6        t
425 >      //  7        e
426 >      //  8        mu
427 >      //  9        tau
428 >      // 10        nu
429 >      // 11        g
430 >      // 12        gamma
431 >      // 13        Z
432 >      // 14        W
433 >      // 15        light meson
434 >      // 16        K meson
435 >      // 17        D meson
436 >      // 18        B meson
437 >      // 19        light baryon
438 >      // 20        strange baryon
439 >      // 21        charm baryon
440 >      // 22        bottom baryon
441 >      // 23        QCD string
442 >      // 24        other
443  
444        vector<TString> labelArray;
445        labelArray.push_back("unmatched");
# Line 273 | Line 465 | muonSFFile_ (cfg.getParameter<std::strin
465        labelArray.push_back("strange baryon");
466        labelArray.push_back("charm baryon");
467        labelArray.push_back("bottom baryon");
468 +      labelArray.push_back("QCD string");
469        labelArray.push_back("other");
470  
471        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
472 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
473 <          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
474 <        }
475 <        else {
476 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
477 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
478 <        }
472 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
473 >          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
474 >        }
475 >        else {
476 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
477 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
478 >        }
479        }
480 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
481 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
482 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
480 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
481 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
482 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
483        }
484  
485      }
486  
487 <    //book a histogram for the number of each object type to be plotted
488 <
487 >    // Book a histogram for the number of each object type to be plotted.
488 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
489      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
490        string currentObject = objectsToPlot.at(currentObjectIndex);
491        int maxNum = 10;
492        if(currentObject == "mcparticles") maxNum = 50;
493        else if(currentObject == "primaryvertexs") maxNum = 50;
494 <      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
495 <      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
496 <      else if(currentObject == "electron-muon pairs") currentObject = "electronMuonPairs";
497 <
498 <      else if(currentObject == "electron-track pairs") currentObject = "electronTrackPairs";
499 <      else if(currentObject == "muon-track pairs") currentObject = "muonTrackPairs";
500 <      else if(currentObject == "muon-tau pairs") currentObject = "muonTauPairs";
501 <      else if(currentObject == "tau-tau pairs") currentObject = "ditauPairs";
494 >
495 >      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
496 >      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
497 >      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
498 >      else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
499 >      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
500 >      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
501 >      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
502 >      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
503 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
504 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
505 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
506 >      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
507 >      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
508 >      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
509 >      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
510 >      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
511 >      else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
512 >      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
513 >      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
514  
515        currentObject.at(0) = toupper(currentObject.at(0));
516        string histoName = "num" + currentObject;
517  
518        if(histoName == "numPrimaryvertexs"){
519          string newHistoName = histoName + "BeforePileupCorrection";
520 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
520 >        oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
521          newHistoName = histoName + "AfterPileupCorrection";
522 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
522 >        oneDHists_.at(currentChannel).at(currentDir)[newHistoName] = directories.at(currentDir).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
523        }
524        else
525 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
525 >        oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
526      }
527 <
323 <
324 <
325 <
326 <    //get list of cuts for this channel
327 <    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
328 <
329 <    //loop over and parse all cuts
330 <    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
331 <      cut tempCut;
332 <      //store input collection for cut
333 <      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
334 <      tempCut.inputCollection = tempInputCollection;
335 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
336 <        objectsToGet.push_back(tempInputCollection);
337 <        objectsToCut.push_back(tempInputCollection);
338 <      }
339 <      else{//pair of objects, need to add them both to the things to objectsToGet
340 <        int dashIndex = tempInputCollection.find("-");
341 <        int spaceIndex = tempInputCollection.find(" ");
342 <        int secondWordLength = spaceIndex - dashIndex;
343 <        objectsToGet.push_back(tempInputCollection);
344 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
345 <        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
346 <        objectsToCut.push_back(tempInputCollection);
347 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
348 <        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
349 <
350 <      }
351 <
352 <
353 <
354 <      //split cut string into parts and store them
355 <      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
356 <      std::vector<string> cutStringVector = splitString(cutString);
357 <      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
358 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
359 <        exit(0);
360 <      }
361 <      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
362 <      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
363 <        int indexOffset = 4 * subcutIndex;
364 <        string currentVariableString = cutStringVector.at(indexOffset);
365 <        if(currentVariableString.find("(")==std::string::npos){
366 <          tempCut.functions.push_back("");//no function was specified
367 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
368 <        }
369 <        else{
370 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
371 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
372 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
373 <        }
374 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
375 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
376 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
377 <      }
378 <
379 <      //get number of objects required to pass cut for event to pass
380 <      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
381 <      std::vector<string> numberRequiredVector = splitString(numberRequiredString);
382 <      if(numberRequiredVector.size()!=2){
383 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
384 <        exit(0);
385 <      }
386 <
387 <      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
388 <      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
389 <      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
390 <
391 <
392 <      string tempCutName;
393 <      if(cuts_.at(currentCut).exists("alias")){
394 <        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
395 <      }
396 <      else{
397 <        //construct string for cutflow table
398 <        bool plural = numberRequiredInt != 1;
399 <        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
400 <        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
401 <        tempCutName = cutName;
402 <      }
403 <      tempCut.name = tempCutName;
404 <
405 <
406 <      tempChannel.cuts.push_back(tempCut);
407 <
408 <
409 <
410 <    }//end loop over cuts
411 <
527 >   }//end of loop over directories
528      channels.push_back(tempChannel);
529      tempChannel.cuts.clear();
414
530    }//end loop over channels
531  
532  
# Line 440 | Line 555 | OSUAnalysis::analyze (const edm::Event &
555  
556    // Retrieve necessary collections from the event.
557  
558 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
558 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
559      event.getByLabel (triggers_, triggers);
560  
561 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
561 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
562 >    event.getByLabel (trigobjs_, trigobjs);
563 >
564 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
565      event.getByLabel (jets_, jets);
566  
567 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
567 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
568      event.getByLabel (muons_, muons);
569  
570 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
570 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
571      event.getByLabel (electrons_, electrons);
572  
573 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
573 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
574      event.getByLabel (events_, events);
575  
576 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
576 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
577      event.getByLabel (taus_, taus);
578  
579 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
579 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
580      event.getByLabel (mets_, mets);
581  
582 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
582 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
583      event.getByLabel (tracks_, tracks);
584  
585 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
585 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
586      event.getByLabel (genjets_, genjets);
587  
588 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
588 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
589      event.getByLabel (mcparticles_, mcparticles);
590  
591 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
591 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
592      event.getByLabel (primaryvertexs_, primaryvertexs);
593  
594 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
594 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
595      event.getByLabel (bxlumis_, bxlumis);
596  
597 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
597 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
598      event.getByLabel (photons_, photons);
599  
600 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
600 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
601      event.getByLabel (superclusters_, superclusters);
602  
603 +  if (datasetType_ == "signalMC"){
604 +    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
605 +      event.getByLabel (stops_, stops);
606 +  }
607 +
608 +  if (useTrackCaloRhoCorr_) {
609 +    // Used only for pile-up correction of by-hand calculation of isolation energy.
610 +    // This rho collection is not available in all BEANs.
611 +    // For description of rho values for different jet reconstruction algorithms, see
612 +    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
613 +    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
614 +  }
615 +
616 +  double masterScaleFactor = 1.0;
617 +
618    //get pile-up event weight
619 <  double scaleFactor = 1.00;
620 <  if(doPileupReweighting_ && datasetType_ != "data")
621 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
619 >  if (doPileupReweighting_ && datasetType_ != "data") {
620 >    //for "data" datasets, the numTruePV is always set to -1
621 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
622 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
623 >  }
624  
625 +  stopCTauScaleFactor_ = 1.0;
626 +  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
627 +    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
628 +  masterScaleFactor *= stopCTauScaleFactor_;
629  
630    //loop over all channels
631  
# Line 498 | Line 637 | OSUAnalysis::analyze (const edm::Event &
637      cumulativeFlags.clear ();
638  
639      bool triggerDecision = true;
640 <    if(currentChannel.triggers.size() != 0){  //triggers specified
641 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
640 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
641 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
642        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
643      }
644  
645      //loop over all cuts
507
508
509
646      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
647        cut currentCut = currentChannel.cuts.at(currentCutIndex);
512
648        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
649          string currentObject = objectsToCut.at(currentObjectIndex);
650  
# Line 524 | Line 659 | OSUAnalysis::analyze (const edm::Event &
659          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
660  
661  
662 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
663 <        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
662 >        if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
663 >        else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
664 >        else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
665 >        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
666 >        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
667          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
668          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
669          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 537 | Line 675 | OSUAnalysis::analyze (const edm::Event &
675          else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
676          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
677          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
678 +        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
679 +
680  
681  
682          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
683                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
684                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
685                                                                     "muon-muon pairs");
686 +
687 +        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
688 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
689 +                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
690 +                                                                   "muon-secondary muon pairs");
691 +
692 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
693 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
694 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
695 +                                                                   "electron-secondary electron pairs");
696 +
697          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
698                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
699                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 551 | Line 702 | OSUAnalysis::analyze (const edm::Event &
702                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
703                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
704                                                                         "electron-muon pairs");
705 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(), \
705 >        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
706 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
707 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
708 >                                                                           "jet-jet pairs");
709 >        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
710                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
711 <                                                                       cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
712 <                                                                       "electron-track pairs");
713 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(), \
714 <                                                                        cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
715 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
716 <                                                                        "muon-track pairs");
717 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(), \
718 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
719 <                                                                    cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
720 <                                                                    "muon-tau pairs");
721 <
722 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(), \
723 <                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
724 <                                                                        cumulativeFlags.at("taus").at(flagsForPairCutsIndex), \
725 <                                                                        "tau-tau pairs");
726 <
711 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
712 >                                                                       "electron-jet pairs");
713 >        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
714 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
715 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
716 >                                                                       "muon-jet pairs");
717 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
718 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
719 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
720 >                                                                     "track-event pairs");
721 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
722 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
723 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
724 >                                                                        "electron-track pairs");
725 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
726 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
727 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
728 >                                                                    "muon-track pairs");
729 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
730 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
731 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
732 >                                                                  "muon-tau pairs");
733 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
734 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
735 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
736 >                                                                 "tau-tau pairs");
737 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
738 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
739 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
740 >                                                                 "tau-track pairs");
741 >        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
742 >                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
743 >                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
744 >                                                                          "electron-trigobj pairs");
745 >        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
746 >                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
747 >                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
748 >                                                                      "muon-trigobj pairs");
749  
750 +        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
751        }
752  
753  
754  
755      }//end loop over all cuts
578
579
756      //use cumulative flags to apply cuts at event level
757  
758      bool eventPassedAllCuts = true;
759 <
759 >    //a vector to store cumulative cut descisions after each cut.
760 >    vector<bool> eventPassedPreviousCuts;
761      //apply trigger (true if none were specified)
762      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
763  
764  
588
765      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
766  
767        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 593 | Line 769 | OSUAnalysis::analyze (const edm::Event &
769        int numberPassing = 0;
770  
771        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
772 <          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
772 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
773        }
598
774        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
775        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
601
776        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
777 +      eventPassedPreviousCuts.push_back(eventPassedAllCuts);
778 +    }
779 +    double scaleFactor = masterScaleFactor;
780  
781 +    muonScaleFactor_ = electronScaleFactor_ = 1.0;
782 +    if(applyLeptonSF_ && datasetType_ != "data"){
783 +      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
784 +        vector<bool> muonFlags;
785 +        for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
786 +          if (cumulativeFlags.at("muons").at(i).size()){
787 +            muonFlags = cumulativeFlags.at("muons").at(i);
788 +            break;
789 +          }
790 +        }
791 +        for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
792 +          if(!muonFlags.at(muonIndex)) continue;
793 +          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
794 +        }
795 +      }
796 +      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
797 +        vector<bool> electronFlags;
798 +        for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
799 +          if (cumulativeFlags.at("electrons").at(i).size()){
800 +            electronFlags = cumulativeFlags.at("electrons").at(i);
801 +            break;
802 +          }
803 +        }
804 +        for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
805 +          if(!electronFlags.at(electronIndex)) continue;
806 +          electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
807 +        }
808 +      }
809      }
810 +    scaleFactor *= muonScaleFactor_;
811 +    scaleFactor *= electronScaleFactor_;
812  
813      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
814 <
608 <
609 <
610 <    if(!eventPassedAllCuts)continue;
814 >    if(!(GetPlotsAfterEachCut_ || eventPassedAllCuts)) continue;
815  
816      if (printEventInfo_) {
817 <      // Write information about event to screen, for testing purposes.  
818 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
819 <           << ": run="  << events->at(0).run
820 <           << "  lumi=" << events->at(0).lumi
821 <           << "  event=" << events->at(0).evt
822 <           << endl;  
817 >      // Write information about event to screen, for testing purposes.
818 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
819 >           << ": run="  << events->at(0).run
820 >           << "  lumi=" << events->at(0).lumi
821 >           << "  event=" << events->at(0).evt
822 >           << endl;
823      }
620
621
622 //     if(datasetType_ != "data") {
623 //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
624 //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
625 //     }
626
824      //filling histograms
825 <    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
826 <      histogram currentHistogram = histograms.at(histogramIndex);
825 >    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
826 >        uint currentDir;
827 >        if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
828 >        else{
829 >          currentDir = currentCut;
830 >        }
831 >        if(eventPassedPreviousCuts.at(currentDir)){
832 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
833 >          histogram currentHistogram = histograms.at(histogramIndex);
834  
835        if(currentHistogram.inputVariables.size() == 1){
836          TH1D* histo;
837 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
838 <
839 <
840 <
841 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
842 <         else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
837 >        histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
838 >        if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
839 >        else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
840 >        else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
841 >        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
842 >        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
843          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
844 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
845 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
846 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
844 >                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
845 >                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
846 >        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
847 >                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
848 >                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
849 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
850          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
851 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
852 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
851 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
852 >                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
853 >        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
854 >                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
855 >                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
856 >        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
857 >                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
858 >                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
859          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
860 <                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
861 <                                                                                              cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
862 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(), \
863 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
864 <                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
865 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(), \
866 <                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
867 <                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
868 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(), \
869 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
870 <                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
871 <
872 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(), \
873 <                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
874 <                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
875 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
876 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
877 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
878 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
879 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
880 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
881 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
882 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
883 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
884 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
860 >                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
861 >                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
862 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
863 >                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
864 >                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
865 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
866 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
867 >                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
868 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
869 >                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
870 >                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
871 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
872 >                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
873 >                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
874 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
875 >                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
876 >                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
877 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
878 >                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
879 >                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
880 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
881 >                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
882 >                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
883 >        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
884 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
885 >                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
886 >        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
887 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
888 >                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
889 >
890 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
891 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
892 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
893 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
894 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
895 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
896 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
897 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
898 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
899 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
900 >        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
901 >        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
902        }
903        else if(currentHistogram.inputVariables.size() == 2){
904          TH2D* histo;
905 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
906 <
907 <
908 <
909 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
680 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
905 >        histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
906 >        if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
907 >        else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
908 >        else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
909 >        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
910          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
911 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
912 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
913 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
911 >                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
912 >                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
913 >        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
914 >                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
915 >                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
916 >        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
917 >        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
918          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
919 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
920 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
919 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
920 >                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
921 >        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
922 >                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
923 >                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
924 >        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
925 >                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
926 >                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
927          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
928 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
929 <                                                                                               cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
930 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(), \
931 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(), \
932 <                                                                                           cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
933 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(), \
934 <                                                                                            cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(), \
935 <                                                                                            cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
936 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(), \
937 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(), \
938 <                                                                                        cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
939 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(), \
940 <                                                                                            cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(), \
941 <                                                                                            cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
942 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
943 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
944 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
945 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
946 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
947 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
948 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
949 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
950 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
951 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
928 >                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
929 >                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
930 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
931 >                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
932 >                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
933 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
934 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
935 >                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
936 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
937 >                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
938 >                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
939 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
940 >                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
941 >                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
942 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
943 >                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
944 >                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
945 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
946 >                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
947 >                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
948 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
949 >                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
950 >                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
951 >        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
952 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
953 >                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
954 >        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
955 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
956 >                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
957 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
958 >        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
959 >        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
960 >        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
961 >        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
962 >                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
963 >                                                                                         cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
964 >        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
965 >        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
966 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
967 >        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
968 >        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
969 >        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
970 >        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
971 >        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
972        }
973      }
974  
975 +
976 +
977      //fills histograms with the sizes of collections
978      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
718      string currentObject = objectsToPlot.at(currentObjectIndex);
979  
980 +      string currentObject = objectsToPlot.at(currentObjectIndex);
981        string objectToPlot = "";
982  
983 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
984 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
985 <      else if(currentObject == "electron-muon pairs") objectToPlot = "electronMuonPairs";
986 <      else if(currentObject == "electron-track pairs") objectToPlot = "electronTrackPairs";
987 <      else if(currentObject == "muon-track pairs") objectToPlot = "muonTrackPairs";
988 <      else if(currentObject == "muon-tau pairs") objectToPlot = "muonTauPairs";
989 <      else if(currentObject == "tau-tau pairs") objectToPlot = "ditauPairs";
983 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
984 >      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
985 >      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
986 >      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
987 >      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
988 >      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
989 >      else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
990 >      else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
991 >      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
992 >      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
993 >      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
994 >      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
995 >      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
996 >      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
997 >      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
998 >      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
999 >      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1000 >      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1001 >      else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1002 >      else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1003        else objectToPlot = currentObject;
1004 +
1005        string tempCurrentObject = objectToPlot;
1006        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1007        string histoName = "num" + tempCurrentObject;
1008  
734
735
736
1009        //set position of primary vertex in event, in order to calculate quantities relative to it
1010 <      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1011 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
1010 >      if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1011 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1012          int numToPlot = 0;
1013          for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1014            if(lastCutFlags.at(currentFlag)) numToPlot++;
1015          }
1016          if(objectToPlot == "primaryvertexs"){
1017 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1018 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1017 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1018 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1019 >        }
1020 >        else {
1021 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1022          }
748        else
749          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
1023        }
1024 <      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
1025 <      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
1026 <      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1027 <      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
1028 <      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1029 <      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1030 <      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1031 <      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
1032 <      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
1033 <      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
1034 <      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
1035 <      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
1036 <      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1037 <      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1038 <      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
1039 <      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
1024 >      else if(objectToPlot == "jets")           oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1025 >      else if(objectToPlot == "secondaryJets")  oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1026 >      else if(objectToPlot == "muons")          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1027 >      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1028 >      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1029 >      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1030 >      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1031 >      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1032 >      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1033 >      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1034 >      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1035 >      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1036 >      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1037 >      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1038 >      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1039 >      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1040 >      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(events->size(),scaleFactor);
1041 >      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(taus->size(),scaleFactor);
1042 >      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mets->size(),scaleFactor);
1043 >      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(tracks->size(),scaleFactor);
1044 >      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(genjets->size(),scaleFactor);
1045 >      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1046 >      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1047 >      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(photons->size(),scaleFactor);
1048 >      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(superclusters->size(),scaleFactor);
1049 >      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1050        else if(objectToPlot == "primaryvertexs"){
1051 <        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1052 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1051 >        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1052 >        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1053        }
1054 +      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(stops->size(),scaleFactor);
1055  
1056 +     } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1057      }
1058 +  }
1059 +  } //end loop over channel
1060  
1061 +  masterCutFlow_->fillCutFlow(masterScaleFactor);
1062  
1063 + } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1064  
1065  
777  } //end loop over channel
1066  
1067 <  masterCutFlow_->fillCutFlow(scaleFactor);
1067 > bool
1068 > OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
1069  
1070  
1071 +  if(comparison == ">")       return testValue >  cutValue;
1072 +  else if(comparison == ">=") return testValue >= cutValue;
1073 +  else if(comparison == "<")  return testValue <  cutValue;
1074 +  else if(comparison == "<=") return testValue <= cutValue;
1075 +  else if(comparison == "==") return testValue == cutValue;
1076 +  else if(comparison == "=") return testValue == cutValue;
1077 +  else if(comparison == "!=") return testValue != cutValue;
1078 +  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1079  
1080   }
1081  
785
1082   bool
1083 < OSUAnalysis::evaluateComparison (double testValue, string comparison, double cutValue){
1083 > OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1084  
1085  
1086    if(comparison == ">")       return testValue >  cutValue;
# Line 794 | Line 1090 | OSUAnalysis::evaluateComparison (double
1090    else if(comparison == "==") return testValue == cutValue;
1091    else if(comparison == "=") return testValue == cutValue;
1092    else if(comparison == "!=") return testValue != cutValue;
1093 <  else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1093 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1094  
1095   }
1096  
1097   bool
1098 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1098 > OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1099  
1100 +  //initialize to false until a chosen trigger is passed
1101    bool triggerDecision = false;
1102  
1103 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1104 <    {
1105 <      if(trigger->pass != 1) continue;
1106 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1107 <        {
811 <          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
812 <            triggerDecision = true;
813 <          }
814 <        }
815 <    }
816 <  return triggerDecision;
1103 >  //loop over all triggers defined in the event
1104 >  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1105 >
1106 >    //we're only interested in triggers that actually passed
1107 >    if(trigger->pass != 1) continue;
1108  
1109 +    //if the event passes one of the veto triggers, exit and return false
1110 +    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1111 +      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1112 +    }
1113 +    //if the event passes one of the chosen triggers, set triggerDecision to true
1114 +    for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1115 +      if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1116 +    }  
1117 +  }
1118 +  //if none of the veto triggers fired:
1119 +  //return the OR of all the chosen triggers
1120 +  if (triggersToTest.size() != 0) return triggerDecision;
1121 +  //or if no triggers were defined return true
1122 +  else return true;
1123   }
1124  
1125 < std::vector<std::string>
1125 >
1126 > vector<string>
1127   OSUAnalysis::splitString (string inputString){
1128  
1129 <  std::stringstream stringStream(inputString);
1130 <  std::istream_iterator<std::string> begin(stringStream);
1131 <  std::istream_iterator<std::string> end;
1132 <  std::vector<std::string> stringVector(begin, end);
1129 >  stringstream stringStream(inputString);
1130 >  istream_iterator<string> begin(stringStream);
1131 >  istream_iterator<string> end;
1132 >  vector<string> stringVector(begin, end);
1133    return stringVector;
1134  
1135   }
1136  
1137 +
1138 + void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1139 +  // Set two object strings from the tempInputCollection string,
1140 +  // For example, if tempInputCollection is "electron-muon pairs",
1141 +  // then obj1 = "electrons" and obj2 = "muons".
1142 +  // Note that the objects have an "s" appended.
1143 +
1144 +  int dashIndex = tempInputCollection.find("-");
1145 +  int spaceIndex = tempInputCollection.find_last_of(" ");
1146 +  int secondWordLength = spaceIndex - dashIndex;
1147 +  obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1148 +  obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1149 +
1150 + }
1151 +
1152 +
1153 + string OSUAnalysis::getObjToGet(string obj) {
1154 +  // Return the string corresponding to the object to get for the given obj string.
1155 +  // Right now this only handles the case in which obj contains "secondary",
1156 +  // e.g, "secondary muons".
1157 +  // Note that "s" is NOT appended.
1158 +
1159 +  if (obj.find("secondary")==string::npos) return obj;  // "secondary" is not found
1160 +  int firstSpaceIndex = obj.find_first_of(" ");
1161 +  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1162 +
1163 + }
1164 +
1165 +
1166 + //!jet valueLookup
1167   double
1168 < OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1168 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1169  
1170    double value = 0.0;
1171    if(variable == "energy") value = object->energy;
# Line 949 | Line 1285 | OSUAnalysis::valueLookup (const BNjet* o
1285    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1286  
1287  
1288 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1288 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1289  
1290    value = applyFunction(function, value);
1291  
# Line 957 | Line 1293 | OSUAnalysis::valueLookup (const BNjet* o
1293   }
1294  
1295  
1296 <
1296 > //!muon valueLookup
1297   double
1298 < OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1298 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1299  
1300    double value = 0.0;
1301    if(variable == "energy") value = object->energy;
# Line 1120 | Line 1456 | OSUAnalysis::valueLookup (const BNmuon*
1456    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1457    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1458    else if(variable == "metMT") {
1459 <    const BNmet *met = chosenMET ();
1124 <    if (met)
1459 >    if (const BNmet *met = chosenMET ())
1460        {
1461 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1462 <                       p2 (met->px, met->py, 0.0, met->pt);
1128 <
1129 <        value = (p1 + p2).Mt ();
1461 >        double dPhi = deltaPhi (object->phi, met->phi);
1462 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1463        }
1464      else
1465        value = -999;
# Line 1244 | Line 1577 | OSUAnalysis::valueLookup (const BNmuon*
1577      value = object->isGlobalMuon > 0                \
1578        && object->isPFMuon > 0                        \
1579        && object->normalizedChi2 < 10                \
1580 <      && object->numberOfValidMuonHits > 0        \
1580 >                                  && object->numberOfValidMuonHits > 0        \
1581        && object->numberOfMatchedStations > 1        \
1582        && fabs(object->correctedD0Vertex) < 0.2        \
1583        && fabs(object->correctedDZ) < 0.5        \
# Line 1253 | Line 1586 | OSUAnalysis::valueLookup (const BNmuon*
1586    }
1587    else if(variable == "tightIDdisplaced"){
1588      value = object->isGlobalMuon > 0                \
1589 +      && object->isPFMuon > 0                        \
1590        && object->normalizedChi2 < 10                \
1591 <      && object->numberOfValidMuonHits > 0        \
1591 >                                  && object->numberOfValidMuonHits > 0        \
1592        && object->numberOfMatchedStations > 1        \
1593        && object->numberOfValidPixelHits > 0        \
1594        && object->numberOfLayersWithMeasurement > 5;
1595    }
1596  
1597 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1597 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1598  
1599    else if(variable == "genMatchedPdgId"){
1600      int index = getGenMatchedParticleIndex(object);
# Line 1280 | Line 1614 | OSUAnalysis::valueLookup (const BNmuon*
1614    }
1615    else if(variable == "genMatchedMotherIdReverse"){
1616      int index = getGenMatchedParticleIndex(object);
1617 <    if(index == -1) value = 23;
1618 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1617 >    if(index == -1) value = 24;
1618 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1619    }
1620    else if(variable == "genMatchedGrandmotherId"){
1621      int index = getGenMatchedParticleIndex(object);
# Line 1293 | Line 1627 | OSUAnalysis::valueLookup (const BNmuon*
1627      }
1628      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1629    }
1630 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1631 +    int index = getGenMatchedParticleIndex(object);
1632 +    if(index == -1) value = 24;
1633 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1634 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1635 +      if(motherIndex == -1) value = 24;
1636 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1637 +    }
1638 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1639 +  }
1640 +  else if(variable == "pfMuonsFromVertex"){
1641 +    double d0Error, dzError;
1642  
1643 +    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1644 +    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1645 +    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1646 +         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1647 +         || fabs (object->correctedDZ / dzError) > 99.0;
1648 +    value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1649 +  }
1650  
1651  
1652 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1652 >
1653 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1654  
1655    value = applyFunction(function, value);
1656  
1657    return value;
1658   }
1659  
1660 <
1660 > //!electron valueLookup
1661   double
1662 < OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1662 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
1663  
1664    double value = 0.0;
1665    if(variable == "energy") value = object->energy;
# Line 1471 | Line 1825 | OSUAnalysis::valueLookup (const BNelectr
1825    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1826    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1827    else if(variable == "metMT") {
1828 <    const BNmet *met = chosenMET ();
1475 <    if (met)
1828 >    if (const BNmet *met = chosenMET ())
1829        {
1830 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1831 <                       p2 (met->px, met->py, 0.0, met->pt);
1479 <
1480 <        value = (p1 + p2).Mt ();
1830 >        double dPhi = deltaPhi (object->phi, met->phi);
1831 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1832        }
1833      else
1834        value = -999;
# Line 1642 | Line 1993 | OSUAnalysis::valueLookup (const BNelectr
1993    }
1994  
1995  
1996 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1996 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1997  
1998    else if(variable == "genMatchedPdgId"){
1999      int index = getGenMatchedParticleIndex(object);
# Line 1663 | Line 2014 | OSUAnalysis::valueLookup (const BNelectr
2014    }
2015    else if(variable == "genMatchedMotherIdReverse"){
2016      int index = getGenMatchedParticleIndex(object);
2017 <    if(index == -1) value = 23;
2018 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2017 >    if(index == -1) value = 24;
2018 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2019    }
2020    else if(variable == "genMatchedGrandmotherId"){
2021      int index = getGenMatchedParticleIndex(object);
# Line 1676 | Line 2027 | OSUAnalysis::valueLookup (const BNelectr
2027      }
2028      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2029    }
2030 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2031 +    int index = getGenMatchedParticleIndex(object);
2032 +    if(index == -1) value = 24;
2033 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2034 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2035 +      if(motherIndex == -1) value = 24;
2036 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2037 +    }
2038 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2039 +  }
2040 +  else if(variable == "pfElectronsFromVertex"){
2041 +    double d0Error, dzError;
2042  
2043 +    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2044 +    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2045 +    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2046 +         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2047 +         || fabs (object->correctedDZ / dzError) > 99.0;
2048 +    value = !value;
2049 +  }
2050  
2051  
2052 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2052 >
2053 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2054  
2055    value = applyFunction(function, value);
2056  
2057    return value;
2058   }
2059  
2060 <
2060 > //!event valueLookup
2061   double
2062 < OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
2062 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
2063  
2064    double value = 0.0;
2065  
# Line 1757 | Line 2128 | OSUAnalysis::valueLookup (const BNevent*
2128    else if(variable == "id2") value = object->id2;
2129    else if(variable == "evt") value = object->evt;
2130    else if(variable == "puScaleFactor"){
2131 <    if(datasetType_ != "data")
2131 >    if(doPileupReweighting_ && datasetType_ != "data")
2132        value = puWeight_->at (events->at (0).numTruePV);
2133      else
2134        value = 1.0;
2135    }
2136 <  else if(variable == "muonScaleFactor"){
2137 <    if(datasetType_ != "data")
2138 <      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1768 <    value = 1.0;
1769 <    else
1770 <      value = 1.0;
1771 <  }
1772 <  else if(variable == "electronScaleFactor"){
1773 <    if(datasetType_ != "data")
1774 <      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1775 <    value = 1.0;
1776 <    else
1777 <      value = 1.0;
1778 <  }
2136 >  else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2137 >  else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2138 >  else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2139  
2140 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2140 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2141  
2142    value = applyFunction(function, value);
2143  
2144    return value;
2145   }
2146  
2147 + //!tau valueLookup
2148   double
2149 < OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2149 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2150  
2151    double value = 0.0;
2152  
# Line 1831 | Line 2192 | OSUAnalysis::valueLookup (const BNtau* o
2192  
2193  
2194  
2195 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2195 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2196  
2197    else if(variable == "genMatchedPdgId"){
2198      int index = getGenMatchedParticleIndex(object);
# Line 1851 | Line 2212 | OSUAnalysis::valueLookup (const BNtau* o
2212    }
2213    else if(variable == "genMatchedMotherIdReverse"){
2214      int index = getGenMatchedParticleIndex(object);
2215 <    if(index == -1) value = 23;
2216 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2215 >    if(index == -1) value = 24;
2216 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2217    }
2218    else if(variable == "genMatchedGrandmotherId"){
2219      int index = getGenMatchedParticleIndex(object);
# Line 1864 | Line 2225 | OSUAnalysis::valueLookup (const BNtau* o
2225      }
2226      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2227    }
2228 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2229 +    int index = getGenMatchedParticleIndex(object);
2230 +    if(index == -1) value = 24;
2231 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2232 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2233 +      if(motherIndex == -1) value = 24;
2234 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2235 +    }
2236 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2237 +  }
2238  
2239  
2240 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2240 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2241  
2242    value = applyFunction(function, value);
2243  
2244    return value;
2245   }
2246  
2247 + //!met valueLookup
2248   double
2249 < OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2249 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2250  
2251    double value = 0.0;
2252  
# Line 1938 | Line 2310 | OSUAnalysis::valueLookup (const BNmet* o
2310    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2311    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2312  
2313 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2313 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2314  
2315    value = applyFunction(function, value);
2316  
2317    return value;
2318   }
2319  
2320 + //!track valueLookup
2321   double
2322 < OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2322 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2323  
2324    double value = 0.0;
2325    double pMag = sqrt(object->pt * object->pt +
2326 <                         object->pz * object->pz);
2326 >                     object->pz * object->pz);
2327  
2328    if(variable == "pt") value = object->pt;
2329    else if(variable == "px") value = object->px;
# Line 1972 | Line 2345 | OSUAnalysis::valueLookup (const BNtrack*
2345  
2346  
2347    //additional BNs info for disappTrks
1975  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2348    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2349    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2350    else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2351    else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2352    else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2353    else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2354 +  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2355    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2356    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2357    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2358 <  
2358 >  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2359  
2360    //user defined variables
2361    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;
2362    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2363 <  else if(variable == "caloTotDeltaRp5") value =(object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2364 <  else if(variable == "caloTotDeltaRp5ByP") value =( (object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2365 <  else if(variable == "isIso") value = getTrkIsIso(object, tracks.product());
2366 <  else if(variable == "isMatchedDeadEcal") value = getTrkIsMatchedDeadEcal(object);
2367 <  else if(variable == "ptErrorByPt") value = (object->ptError/object->pt);
2368 <  else if(variable == "ptError") value = object->ptError;
2369 <  else if(variable == "ptRes") value = getTrkPtRes(object);
2370 <
2363 >  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2364 >  else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2365 >  else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2366 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2367 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2368 >  else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2369 >  else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2370 >  else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2371 >  else if(variable == "ptError")                    value = object->ptError;
2372 >  else if(variable == "ptRes")                      value = getTrkPtRes(object);
2373    else if (variable == "d0wrtPV"){
2374      double vx = object->vx - chosenVertex ()->x,
2375        vy = object->vy - chosenVertex ()->y,
# Line 2013 | Line 2388 | OSUAnalysis::valueLookup (const BNtrack*
2388        pt = object->pt;
2389      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2390    }
2391 <
2017 <
2018 <
2019 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2391 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2392  
2393    else if(variable == "genMatchedPdgId"){
2394      int index = getGenMatchedParticleIndex(object);
# Line 2024 | Line 2396 | OSUAnalysis::valueLookup (const BNtrack*
2396      else value = mcparticles->at(index).id;
2397    }
2398  
2399 +
2400    else if(variable == "genMatchedId"){
2401      int index = getGenMatchedParticleIndex(object);
2402      if(index == -1) value = 0;
# Line 2036 | Line 2409 | OSUAnalysis::valueLookup (const BNtrack*
2409    }
2410    else if(variable == "genMatchedMotherIdReverse"){
2411      int index = getGenMatchedParticleIndex(object);
2412 <    if(index == -1) value = 23;
2413 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2412 >    if(index == -1) value = 24;
2413 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2414    }
2415    else if(variable == "genMatchedGrandmotherId"){
2416      int index = getGenMatchedParticleIndex(object);
# Line 2049 | Line 2422 | OSUAnalysis::valueLookup (const BNtrack*
2422      }
2423      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2424    }
2425 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2426 +    int index = getGenMatchedParticleIndex(object);
2427 +    if(index == -1) value = 24;
2428 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2429 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2430 +      if(motherIndex == -1) value = 24;
2431 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2432 +    }
2433 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2434 +  }
2435  
2436  
2437  
2438 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2438 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2439  
2440    value = applyFunction(function, value);
2441  
2442    return value;
2443   }
2444  
2445 + //!genjet valueLookup
2446   double
2447 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2447 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2448  
2449    double value = 0.0;
2450  
# Line 2080 | Line 2464 | OSUAnalysis::valueLookup (const BNgenjet
2464    else if(variable == "charge") value = object->charge;
2465  
2466  
2467 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2467 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2468  
2469    value = applyFunction(function, value);
2470  
2471    return value;
2472   }
2473  
2474 + //!mcparticle valueLookup
2475   double
2476 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2476 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2477  
2478    double value = 0.0;
2479  
# Line 2213 | Line 2598 | OSUAnalysis::valueLookup (const BNmcpart
2598    }
2599  
2600  
2601 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2601 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2602  
2603    value = applyFunction(function, value);
2604  
2605    return value;
2606   }
2607  
2608 + //!primaryvertex valueLookup
2609   double
2610 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2610 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
2611  
2612    double value = 0.0;
2613  
# Line 2240 | Line 2626 | OSUAnalysis::valueLookup (const BNprimar
2626    else if(variable == "isGood") value = object->isGood;
2627  
2628  
2629 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2629 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2630  
2631    value = applyFunction(function, value);
2632  
2633    return value;
2634   }
2635  
2636 + //!bxlumi valueLookup
2637   double
2638 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2638 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
2639  
2640    double value = 0.0;
2641  
# Line 2257 | Line 2644 | OSUAnalysis::valueLookup (const BNbxlumi
2644    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2645  
2646  
2647 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2647 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2648  
2649    value = applyFunction(function, value);
2650  
2651    return value;
2652   }
2653  
2654 + //!photon valueLookup
2655   double
2656 < OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2656 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
2657  
2658    double value = 0.0;
2659  
# Line 2338 | Line 2726 | OSUAnalysis::valueLookup (const BNphoton
2726    else if(variable == "isEEGap") value = object->isEEGap;
2727    else if(variable == "hasPixelSeed") value = object->hasPixelSeed;
2728    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2341
2729  
2730 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2730 >
2731 >
2732 >
2733 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2734  
2735    else if(variable == "genMatchedPdgId"){
2736      int index = getGenMatchedParticleIndex(object);
2737      if(index == -1) value = 0;
2738      else value = mcparticles->at(index).id;
2739    }
2740 +
2741 +
2742 +
2743    else if(variable == "genMatchedId"){
2744      int index = getGenMatchedParticleIndex(object);
2745      if(index == -1) value = 0;
# Line 2359 | Line 2752 | OSUAnalysis::valueLookup (const BNphoton
2752    }
2753    else if(variable == "genMatchedMotherIdReverse"){
2754      int index = getGenMatchedParticleIndex(object);
2755 <    if(index == -1) value = 23;
2756 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2755 >    if(index == -1) value = 24;
2756 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2757    }
2758    else if(variable == "genMatchedGrandmotherId"){
2759      int index = getGenMatchedParticleIndex(object);
# Line 2372 | Line 2765 | OSUAnalysis::valueLookup (const BNphoton
2765      }
2766      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2767    }
2768 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2769 +    int index = getGenMatchedParticleIndex(object);
2770 +    if(index == -1) value = 24;
2771 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2772 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2773 +      if(motherIndex == -1) value = 24;
2774 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2775 +    }
2776 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2777 +  }
2778  
2779  
2780 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2780 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2781  
2782    value = applyFunction(function, value);
2783  
2784    return value;
2785   }
2786  
2787 + //!supercluster valueLookup
2788   double
2789 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2789 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
2790  
2791    double value = 0.0;
2792  
# Line 2396 | Line 2800 | OSUAnalysis::valueLookup (const BNsuperc
2800    else if(variable == "theta") value = object->theta;
2801  
2802  
2803 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2803 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2804  
2805    value = applyFunction(function, value);
2806  
2807    return value;
2808   }
2809  
2810 + //!trigobj valueLookup
2811 + double
2812 + OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
2813  
2814 +  double value = 0.0;
2815 +
2816 +  if(variable == "pt") value = object->pt;
2817 +  else if(variable == "eta") value = object->eta;
2818 +  else if(variable == "phi") value = object->phi;
2819 +  else if(variable == "px") value = object->px;
2820 +  else if(variable == "py") value = object->py;
2821 +  else if(variable == "pz") value = object->pz;
2822 +  else if(variable == "et") value = object->et;
2823 +  else if(variable == "energy") value = object->energy;
2824 +  else if(variable == "etTotal") value = object->etTotal;
2825 +  else if(variable == "id") value = object->id;
2826 +  else if(variable == "charge") value = object->charge;
2827 +  else if(variable == "isIsolated") value = object->isIsolated;
2828 +  else if(variable == "isMip") value = object->isMip;
2829 +  else if(variable == "isForward") value = object->isForward;
2830 +  else if(variable == "isRPC") value = object->isRPC;
2831 +  else if(variable == "bx") value = object->bx;
2832 +  else if(variable == "filter") {
2833 +    if ((stringValue = object->filter) == "")
2834 +      stringValue = "none";  // stringValue should only be empty if value is filled
2835 +  }
2836 +
2837 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2838 +
2839 +  value = applyFunction(function, value);
2840 +
2841 +  return value;
2842 + }
2843 +
2844 + //!muon-muon pair valueLookup
2845   double
2846 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2846 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2847  
2848    double value = 0.0;
2849  
2850    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2851 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2852    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2853    else if(variable == "invMass"){
2854      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2419 | Line 2858 | OSUAnalysis::valueLookup (const BNmuon*
2858    else if(variable == "pt"){
2859      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2860      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2861 <    value = (fourVector1 + fourVector2).Et();
2861 >    value = (fourVector1 + fourVector2).Pt();
2862    }
2863    else if(variable == "threeDAngle")
2864      {
# Line 2451 | Line 2890 | OSUAnalysis::valueLookup (const BNmuon*
2890    else if(variable == "muon2CorrectedD0Vertex"){
2891      value = object2->correctedD0Vertex;
2892    }
2893 < else if(variable == "muon1timeAtIpInOut"){
2893 >  else if(variable == "muon1timeAtIpInOut"){
2894      value = object1->timeAtIpInOut;
2895    }
2896 < else if(variable == "muon2timeAtIpInOut"){
2896 >  else if(variable == "muon2timeAtIpInOut"){
2897      value = object2->timeAtIpInOut;
2898    }
2899 < else if(variable == "muon1correctedD0")
2900 <   {
2901 <     value = object1->correctedD0;
2902 <   }
2903 < else if(variable == "muon2correctedD0")
2904 <   {
2905 <     value = object2->correctedD0;
2906 <   }
2899 >  else if(variable == "muon1correctedD0")
2900 >    {
2901 >      value = object1->correctedD0;
2902 >    }
2903 >  else if(variable == "muon2correctedD0")
2904 >    {
2905 >      value = object2->correctedD0;
2906 >    }
2907  
2908 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2908 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2909  
2910    value = applyFunction(function, value);
2911  
2912    return value;
2913   }
2914  
2915 + //!electron-electron pair valueLookup
2916   double
2917 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2917 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
2918  
2919    double value = 0.0;
2920  
2921    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2922 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2923    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2924    else if(variable == "invMass"){
2925      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2488 | Line 2929 | OSUAnalysis::valueLookup (const BNelectr
2929    else if(variable == "pt"){
2930      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2931      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2932 <    value = (fourVector1 + fourVector2).Et();
2932 >    value = (fourVector1 + fourVector2).Pt();
2933    }
2934    else if(variable == "threeDAngle")
2935      {
# Line 2520 | Line 2961 | OSUAnalysis::valueLookup (const BNelectr
2961      value = object2->correctedD0;
2962    }
2963  
2964 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2964 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2965  
2966    value = applyFunction(function, value);
2967  
2968    return value;
2969   }
2970 <
2970 > //!electron-muon pair valueLookup
2971   double
2972 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2972 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2973  
2974    double value = 0.0;
2975  
2976    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2977 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2978    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2979    else if(variable == "invMass"){
2980      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2542 | Line 2984 | OSUAnalysis::valueLookup (const BNelectr
2984    else if(variable == "pt"){
2985      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2986      TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2987 <    value = (fourVector1 + fourVector2).Et();
2987 >    value = (fourVector1 + fourVector2).Pt();
2988    }
2989    else if(variable == "threeDAngle")
2990      {
# Line 2579 | Line 3021 | OSUAnalysis::valueLookup (const BNelectr
3021    else if(variable == "muonDetIso"){
3022      value = (object2->trackIsoDR03) / object2->pt;
3023    }
3024 +  else if(variable == "electronRelPFrhoIso"){
3025 +    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
3026 +  }
3027 +  else if(variable == "muonRelPFdBetaIso"){
3028 +    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3029 +  }
3030 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3031 +  value = applyFunction(function, value);
3032 +
3033 +  return value;
3034 + }
3035  
3036 + //!electron-jet pair valueLookup
3037 + double
3038 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
3039  
3040 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3040 >  double value = 0.0;
3041  
3042 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3043 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3044 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3045 +  else if(variable == "invMass"){
3046 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3047 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3048 +    value = (fourVector1 + fourVector2).M();
3049 +  }
3050 +  else if(variable == "pt"){
3051 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3052 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3053 +    value = (fourVector1 + fourVector2).Pt();
3054 +  }
3055 +  else if(variable == "threeDAngle")
3056 +    {
3057 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3058 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3059 +      value = (threeVector1.Angle(threeVector2));
3060 +    }
3061 +  else if(variable == "chargeProduct"){
3062 +    value = object1->charge*object2->charge;
3063 +  }
3064 +
3065 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3066    value = applyFunction(function, value);
3067  
3068    return value;
3069   }
3070  
3071 + //!muon-jet pair valueLookup
3072 + double
3073 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
3074 +
3075 +  double value = 0.0;
3076 +
3077 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3078 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3079 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3080 +  else if(variable == "invMass"){
3081 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3082 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3083 +    value = (fourVector1 + fourVector2).M();
3084 +  }
3085 +  else if(variable == "pt"){
3086 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3087 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3088 +    value = (fourVector1 + fourVector2).Pt();
3089 +  }
3090 +  else if(variable == "threeDAngle")
3091 +    {
3092 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3093 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3094 +      value = (threeVector1.Angle(threeVector2));
3095 +    }
3096 +  else if(variable == "chargeProduct"){
3097 +    value = object1->charge*object2->charge;
3098 +  }
3099 +
3100 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3101 +  value = applyFunction(function, value);
3102 +
3103 +  return value;
3104 + }
3105 +
3106 + //!jet-jet pair valueLookup
3107 + double
3108 + OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3109 +
3110 +  double value = 0.0;
3111  
3112 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3113 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3114 +  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3115 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3116 +  else if(variable == "invMass"){
3117 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3118 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3119 +    value = (fourVector1 + fourVector2).M();
3120 +  }
3121 +  else if(variable == "pt"){
3122 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3123 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3124 +    value = (fourVector1 + fourVector2).Pt();
3125 +  }
3126 +  else if(variable == "threeDAngle")
3127 +    {
3128 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3129 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3130 +      value = (threeVector1.Angle(threeVector2));
3131 +    }
3132 +  else if(variable == "chargeProduct"){
3133 +    value = object1->charge*object2->charge;
3134 +  }
3135 +
3136 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3137 +  value = applyFunction(function, value);
3138 +
3139 +  return value;
3140 + }
3141 + //!electron-track pair valueLookup
3142   double
3143 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){
3143 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3144    double electronMass = 0.000511;
3145    double value = 0.0;
3146 <  TLorentzVector fourVector1(0, 0, 0, 0);  
3147 <  TLorentzVector fourVector2(0, 0, 0, 0);  
3146 >  TLorentzVector fourVector1(0, 0, 0, 0);
3147 >  TLorentzVector fourVector2(0, 0, 0, 0);
3148    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3149 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3150    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3151    else if(variable == "invMass"){
3152      fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
3153      fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
3154 <    
3154 >
3155      value = (fourVector1 + fourVector2).M();
3156    }
3157 <  
3157 >  else if(variable == "chargeProduct"){
3158 >    value = object1->charge*object2->charge;
3159 >  }
3160    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3161    value = applyFunction(function, value);
3162    return value;
3163 +
3164   }
3165  
3166 +
3167 + //!muon-track pair valueLookup
3168   double
3169 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
3169 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3170    double pionMass = 0.140;
3171    double muonMass = 0.106;
3172    double value = 0.0;
3173    TLorentzVector fourVector1(0, 0, 0, 0);
3174    TLorentzVector fourVector2(0, 0, 0, 0);
3175    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3176 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3177    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3178    else if(variable == "invMass"){
3179      fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
# Line 2624 | Line 3181 | OSUAnalysis::valueLookup (const BNmuon*
3181  
3182      value = (fourVector1 + fourVector2).M();
3183    }
3184 +  else if(variable == "chargeProduct"){
3185 +    value = object1->charge*object2->charge;
3186 +  }
3187  
3188    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3189    value = applyFunction(function, value);
3190    return value;
3191   }
3192  
3193 <
3193 > //!tau-tau pair valueLookup
3194   double
3195 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
3195 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3196    double value = 0.0;
3197    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3198 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3199    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3200    else if(variable == "invMass"){
3201 <  TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3202 <  TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3203 <     value = (fourVector1 + fourVector2).M();
3201 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3202 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3203 >    value = (fourVector1 + fourVector2).M();
3204 >  }
3205 >
3206 >  else if(variable == "chargeProduct"){
3207 >    value = object1->charge*object2->charge;
3208    }
3209  
3210    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
# Line 2647 | Line 3212 | OSUAnalysis::valueLookup (const BNtau* o
3212    return value;
3213   }
3214  
3215 + //!muon-tau pair valueLookup
3216   double
3217 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
3217 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3218    double value = 0.0;
3219    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3220 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3221    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3222    else if(variable == "invMass"){
3223      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2658 | Line 3225 | OSUAnalysis::valueLookup (const BNmuon*
3225      value = (fourVector1 + fourVector2).M();
3226    }
3227  
3228 +  else if(variable == "chargeProduct"){
3229 +    value = object1->charge*object2->charge;
3230 +  }
3231 +
3232    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3233    value = applyFunction(function, value);
3234    return value;
3235   }
3236  
3237 + //!tau-track pair valueLookup
3238 + double
3239 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3240 +  double value = 0.0;
3241 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3242 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3243 +  else if(variable == "chargeProduct"){
3244 +    value = object1->charge*object2->charge;
3245 +  }
3246 +
3247 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3248 +  value = applyFunction(function, value);
3249 +  return value;
3250 + }
3251 +
3252 +
3253 + //!track-event pair valueLookup
3254 + double
3255 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3256 +
3257 +  double value = 0.0;
3258 +  double pMag = sqrt(object1->pt * object1->pt +
3259 +                     object1->pz * object1->pz);
3260 +
3261 +  if      (variable == "numPV")                      value = object2->numPV;
3262 +  else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3263 +  else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3264 +  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3265 +  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3266 +
3267 +  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3268 +
3269 +  value = applyFunction(function, value);
3270 +
3271 +  return value;
3272 +
3273 + }
3274 +
3275 + //!electron-trigobj pair valueLookup
3276 + double
3277 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3278 +
3279 +  double value = 0.0;
3280 +
3281 +  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3282 +  else if (variable == "match"){
3283 +    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3284 +      stringValue = object2->filter;
3285 +    else
3286 +      stringValue = "none";
3287 +  }
3288 +
3289 +  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3290 +
3291 +  value = applyFunction(function, value);
3292 +
3293 +  return value;
3294 +
3295 + }
3296 +
3297 + //!muon-trigobj pair valueLookup
3298 + double
3299 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3300 +
3301 +  double value = 0.0;
3302 +
3303 +  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3304 +
3305 +  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3306 +
3307 +  value = applyFunction(function, value);
3308 +
3309 +  return value;
3310 +
3311 + }
3312 +
3313 + //!stop valueLookup
3314 + double
3315 + OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3316 +
3317 +
3318 +  double value = 0.0;
3319 +
3320 +  if(variable == "ctau") value = object->ctau;
3321 +
3322 +  else if (variable == "d0"){
3323 +    double vx = object->vx - chosenVertex ()->x,
3324 +      vy = object->vy - chosenVertex ()->y,
3325 +      px = object->px,
3326 +      py = object->py,
3327 +      pt = object->pt;
3328 +    value = (-vx * py + vy * px) / pt;
3329 +  }
3330 +
3331 +  else if (variable == "dz"){
3332 +    double vx = object->vx - chosenVertex ()->x,
3333 +      vy = object->vy - chosenVertex ()->y,
3334 +      vz = object->vz - chosenVertex ()->z,
3335 +      px = object->px,
3336 +      py = object->py,
3337 +      pz = object->pz,
3338 +      pt = object->pt;
3339 +    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3340 +  }
3341 +
3342 +  else if (variable == "minD0"){
3343 +    double minD0=999;
3344 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3345 +      double vx = object->vx - vertex->x,
3346 +        vy = object->vy - vertex->y,
3347 +        px = object->px,
3348 +        py = object->py,
3349 +        pt = object->pt;
3350 +      value = (-vx * py + vy * px) / pt;
3351 +      if(abs(value) < abs(minD0)) minD0 = value;
3352 +    }
3353 +    value = minD0;
3354 +  }
3355 +  else if (variable == "minDz"){
3356 +    double minDz=999;
3357 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3358 +      double vx = object->vx - vertex->x,
3359 +        vy = object->vy - vertex->y,
3360 +        vz = object->vz - vertex->z,
3361 +        px = object->px,
3362 +        py = object->py,
3363 +        pz = object->pz,
3364 +        pt = object->pt;
3365 +      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3366 +      if(abs(value) < abs(minDz)) minDz = value;
3367 +    }
3368 +    value = minDz;
3369 +  }
3370 +  else if(variable == "distToVertex"){
3371 +    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3372 +                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3373 +                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3374 +  }
3375 +  else if (variable == "minDistToVertex"){
3376 +    double minDistToVertex=999;
3377 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3378 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3379 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3380 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3381 +
3382 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3383 +    }
3384 +    value = minDistToVertex;
3385 +  }
3386 +  else if (variable == "distToVertexDifference"){
3387 +    double minDistToVertex=999;
3388 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3389 +      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3390 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3391 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3392 +
3393 +      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3394 +    }
3395 +    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3396 +                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3397 +                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3398 +
3399 +    value = distToChosenVertex - minDistToVertex;
3400 +  }
3401 +
3402 +  else if (variable == "closestVertexRank"){
3403 +    double minDistToVertex=999;
3404 +    int vertex_rank = 0;
3405 +    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3406 +      vertex_rank++;
3407 +      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3408 +                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3409 +                   (object->vz-vertex->z)*(object->vz-vertex->z));
3410 +
3411 +      if(abs(dist) < abs(minDistToVertex)){
3412 +        value = vertex_rank;
3413 +        minDistToVertex = dist;
3414 +      }
3415 +    }
3416 +  }
3417 +
3418 +
3419 +
3420 +
3421 +  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3422 +
3423 +  value = applyFunction(function, value);
3424 +
3425 +  return value;
3426 +
3427 + }
3428 +
3429 +
3430  
3431  
3432   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
# Line 2710 | Line 3474 | OSUAnalysis::getTrkPtTrue (const BNtrack
3474  
3475   }
3476  
3477 + double
3478 + OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3479 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
3480 +  if (!useTrackCaloRhoCorr_) return -99;
3481 +  // if (!rhokt6CaloJetsHandle_) {
3482 +  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
3483 +  //   return -99;
3484 +  // }
3485 +  double radDeltaRCone = 0.5;
3486 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.
3487 +  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
3488 +  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
3489 +  return caloTotRhoCorrCalo;
3490 +
3491 + }
3492 +
3493 +
3494 +
3495 +
3496   //creates a map of the dead Ecal channels in the barrel and endcap
3497   //to see how the map of dead Ecal channels is created look at function getChannelStatusMaps() here:
3498   //http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/UserCode/jbrinson/DisappTrk/OSUT3Analysis/AnaTools/src/OSUAnalysis.cc?revision=1.88&view=markup
# Line 2742 | Line 3525 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3525    double deltaRLowest = 999;
3526    int value = 0;
3527    if (DeadEcalVec.size() == 0) WriteDeadEcal();
3528 <  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3528 >  for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3529      double eta = ecal->etaEcal;
3530      double phi = ecal->phiEcal;
3531 <    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
3531 >    double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
3532      if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3533    }
3534    if (deltaRLowest<0.05) {value = 1;}
# Line 2753 | Line 3536 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3536    return value;
3537   }
3538  
3539 <
2757 < // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3539 > // Returns the smallest DeltaR between the object and any generated true particle in the event.
3540   template <class InputObject>
3541   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3542    double genDeltaRLowest = 999.;
3543    for(BNmcparticleCollection::const_iterator mcparticle = mcparticles->begin (); mcparticle != mcparticles->end (); mcparticle++){
3544      double deltaRtemp = deltaR(mcparticle->eta, mcparticle->phi, object->eta, object->phi);
3545      if (deltaRtemp < genDeltaRLowest) genDeltaRLowest = deltaRtemp;
3546 < }
3546 >  }
3547    return genDeltaRLowest;
3548   }
3549  
2768
3550   double
3551   OSUAnalysis::applyFunction(string function, double value){
3552  
# Line 2775 | Line 3556 | OSUAnalysis::applyFunction(string functi
3556    else if(function == "log") value = log10(value);
3557  
3558    else if(function == "") value = value;
3559 <  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
3559 >  else{cout << "WARNING: invalid function '" << function << "'\n";}
3560  
3561    return value;
3562  
# Line 2785 | Line 3566 | OSUAnalysis::applyFunction(string functi
3566   template <class InputCollection>
3567   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3568  
3569 +  if (currentCut.inputCollection.find("pair")!=string::npos)  {
3570 +    string obj1, obj2;
3571 +    getTwoObjs(currentCut.inputCollection, obj1, obj2);
3572 +    if (inputType==obj1 ||
3573 +          inputType==obj2) {
3574 +      // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3575 +      // and the inputType is a member of the pair.
3576 +      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
3577 +      // For example, if currentCut.inputCollection==electron-muon pairs,
3578 +      // then the flags should not be set here when inputType==muons or inputType==electrons.
3579 +      return;
3580 +    }
3581 +  }
3582  
3583    for (uint object = 0; object != inputCollection->size(); object++){
3584  
2791
3585      bool decision = true;//object passes if this cut doesn't cut on that type of object
3586  
2794
3587      if(currentCut.inputCollection == inputType){
3588  
3589        vector<bool> subcutDecisions;
3590        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3591 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3592 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3591 >        string stringValue = "";
3592 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3593 >        if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3594 >        else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3595 >
3596        }
3597        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3598        else{
# Line 2811 | Line 3606 | void OSUAnalysis::setObjectFlags(cut &cu
3606          decision = tempDecision;
3607        }
3608      }
2814    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3609  
3610 +    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3611  
3612      //set flags for objects that pass each cut AND all the previous cuts
3613      bool previousCumulativeFlag = true;
# Line 2822 | Line 3617 | void OSUAnalysis::setObjectFlags(cut &cu
3617      }
3618      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3619  
2825
3620    }
3621  
3622   }
# Line 2836 | Line 3630 | void OSUAnalysis::setObjectFlags(cut &cu
3630    bool sameObjects = false;
3631    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3632  
3633 +  // Get the strings for the two objects that make up the pair.
3634 +  string obj1Type, obj2Type;
3635 +  getTwoObjs(inputType, obj1Type, obj2Type);
3636 +  bool isTwoTypesOfObject = true;
3637 +  if (obj1Type==obj2Type) isTwoTypesOfObject = false;
3638 +
3639 +  // Initialize the flags for individual objects to all be false, if the cut is on the pair.
3640 +  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
3641 +  if (currentCut.inputCollection == inputType) {
3642 +    for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3643 +      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3644 +      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3645 +    }
3646 +    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
3647 +      for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3648 +        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3649 +        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3650 +      }
3651 +    }
3652 +  }
3653  
3654    int counter = 0;
3655 +
3656    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3657      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3658  
# Line 2850 | Line 3665 | void OSUAnalysis::setObjectFlags(cut &cu
3665  
3666          vector<bool> subcutDecisions;
3667          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3668 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3669 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3668 >          string stringValue = "";
3669 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3670 >          if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3671 >          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3672          }
3673  
3674          if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 2866 | Line 3683 | void OSUAnalysis::setObjectFlags(cut &cu
3683            decision = tempDecision;
3684          }
3685        }
3686 +      // if (decision) isPassObj1.at(object1) = true;
3687 +      // if (decision) isPassObj2.at(object2) = true;
3688        individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3689 +      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3690 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
3691 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
3692 +      }
3693  
3694        //set flags for objects that pass each cut AND all the previous cuts
3695        bool previousCumulativeFlag = true;
# Line 2881 | Line 3704 | void OSUAnalysis::setObjectFlags(cut &cu
3704        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3705        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3706        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3707 <
3707 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3708 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
3709 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
3710 >      }
3711        counter++;
2886    }
3712  
3713 <  }
3713 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
3714 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
3715 >
3716 > }
3717  
3718  
3719 + bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3720 +  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3721 +  // all cuts up to currentCutIndex
3722 +  bool previousCumulativeFlag = true;
3723 +  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
3724 +    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3725 +    else {
3726 +      previousCumulativeFlag = false; break;
3727 +    }
3728 +  }
3729 +  return previousCumulativeFlag;
3730   }
3731  
3732  
# Line 2901 | Line 3740 | void OSUAnalysis::fill1DHistogram(TH1* h
3740      string currentString = parameters.inputVariables.at(0);
3741      string inputVariable = "";
3742      string function = "";
3743 <    if(currentString.find("(")==std::string::npos){
3743 >    if(currentString.find("(")==string::npos){
3744        inputVariable = currentString;// variable to cut on
3745      }
3746      else{
# Line 2910 | Line 3749 | void OSUAnalysis::fill1DHistogram(TH1* h
3749        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3750      }
3751  
3752 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3752 >    string stringValue = "";
3753 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3754      histo->Fill(value,scaleFactor);
2915
3755      if (printEventInfo_) {
3756 <      // Write information about event to screen, for testing purposes.  
3757 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3756 >      // Write information about event to screen, for testing purposes.
3757 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
3758      }
3759 <    
3759 >
3760    }
3761   }
3762  
# Line 2927 | Line 3766 | void OSUAnalysis::fill1DHistogram(TH1* h
3766    bool sameObjects = false;
3767    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3768  
3769 <  int pairCounter = 0;
3769 >  int pairCounter = -1;
3770    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3771      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3772  
3773        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3774  
3775 +      pairCounter++;
3776        //only take objects which have passed all cuts and pairs which have passed all cuts
3777        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3778        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 2941 | Line 3781 | void OSUAnalysis::fill1DHistogram(TH1* h
3781        string currentString = parameters.inputVariables.at(0);
3782        string inputVariable = "";
3783        string function = "";
3784 <      if(currentString.find("(")==std::string::npos){
3784 >      if(currentString.find("(")==string::npos){
3785          inputVariable = currentString;// variable to cut on
3786        }
3787        else{
# Line 2950 | Line 3790 | void OSUAnalysis::fill1DHistogram(TH1* h
3790          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3791        }
3792  
3793 <      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3793 >      string stringValue = "";
3794 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3795        histo->Fill(value,scaleFactor);
3796  
2956      pairCounter++;
3797      }
3798    }
3799  
# Line 2967 | Line 3807 | void OSUAnalysis::fill2DHistogram(TH2* h
3807  
3808      if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3809  
3810 +    string stringValue = "";
3811      string currentString = parameters.inputVariables.at(0);
3812      string inputVariable = "";
3813      string function = "";
3814 <    if(currentString.find("(")==std::string::npos){
3814 >    if(currentString.find("(")==string::npos){
3815        inputVariable = currentString;// variable to cut on
3816      }
3817      else{
# Line 2978 | Line 3819 | void OSUAnalysis::fill2DHistogram(TH2* h
3819        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3820        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3821      }
3822 <    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3822 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3823  
3824      currentString = parameters.inputVariables.at(1);
3825      inputVariable = "";
3826      function = "";
3827 <    if(currentString.find("(")==std::string::npos){
3827 >    if(currentString.find("(")==string::npos){
3828        inputVariable = currentString;// variable to cut on
3829      }
3830      else{
# Line 2992 | Line 3833 | void OSUAnalysis::fill2DHistogram(TH2* h
3833        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3834      }
3835  
3836 <    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3836 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3837  
3838      histo->Fill(valueX,valueY,scaleFactor);
3839  
# Line 3006 | Line 3847 | void OSUAnalysis::fill2DHistogram(TH2* h
3847    bool sameObjects = false;
3848    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3849  
3850 <  int pairCounter = 0;
3850 >  int pairCounter = -1;
3851    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3852      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3853  
3854        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3855  
3856 +      pairCounter++;
3857 +
3858        //only take objects which have passed all cuts and pairs which have passed all cuts
3859        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3860        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3861        if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3862  
3863 +      string stringValue = "";
3864        string currentString = parameters.inputVariables.at(0);
3865        string inputVariable = "";
3866        string function = "";
3867 <      if(currentString.find("(")==std::string::npos){
3867 >      if(currentString.find("(")==string::npos){
3868          inputVariable = currentString;// variable to cut on
3869        }
3870        else{
# Line 3028 | Line 3872 | void OSUAnalysis::fill2DHistogram(TH2* h
3872          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3873          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3874        }
3875 <      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3875 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3876  
3877        currentString = parameters.inputVariables.at(1);
3878        inputVariable = "";
3879        function = "";
3880 <      if(currentString.find("(")==std::string::npos){
3880 >      if(currentString.find("(")==string::npos){
3881          inputVariable = currentString;// variable to cut on
3882        }
3883        else{
# Line 3041 | Line 3885 | void OSUAnalysis::fill2DHistogram(TH2* h
3885          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3886          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3887        }
3888 <      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3888 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3889  
3890  
3891        histo->Fill(valueX,valueY,scaleFactor);
3892  
3049      pairCounter++;
3050
3893      }
3894    }
3895  
# Line 3064 | Line 3906 | int OSUAnalysis::getGenMatchedParticleIn
3906  
3907      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3908      if(currentDeltaR > 0.05) continue;
3909 < //     cout << std::setprecision(3) << std::setw(20)
3910 < //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3911 < //          << std::setw(20)
3912 < //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3913 < //          << std::setw(20)
3914 < //          << "\tdeltaR = " << currentDeltaR
3915 < //          << std::setprecision(1)
3916 < //          << std::setw(20)
3917 < //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3918 < //          << std::setw(20)
3919 < //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3920 < //          << std::setw(20)
3921 < //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3909 >    //     cout << setprecision(3) << setw(20)
3910 >    //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3911 >    //          << setw(20)
3912 >    //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3913 >    //          << setw(20)
3914 >    //          << "\tdeltaR = " << currentDeltaR
3915 >    //          << setprecision(1)
3916 >    //          << setw(20)
3917 >    //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3918 >    //          << setw(20)
3919 >    //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3920 >    //          << setw(20)
3921 >    //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3922      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3923        bestMatchIndex = mcparticle - mcparticles->begin();
3924        bestMatchDeltaR = currentDeltaR;
3925      }
3926  
3927    }
3928 < //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3929 < //   else cout << "no match found..." << endl;
3928 >  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
3929 >  //   else cout << "no match found..." << endl;
3930    return bestMatchIndex;
3931  
3932   }
# Line 3138 | Line 3980 | int OSUAnalysis::findTauMotherIndex(cons
3980   // 20        strange baryon
3981   // 21        charm baryon
3982   // 22        bottom baryon
3983 < // 23        other
3983 > // 23        QCD string
3984 > // 24        other
3985  
3986   int OSUAnalysis::getPdgIdBinValue(int pdgId){
3987  
# Line 3162 | Line 4005 | int OSUAnalysis::getPdgIdBinValue(int pd
4005    else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
4006    else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
4007    else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
4008 +  else if(absPdgId == 92  ) binValue = 23;
4009  
4010 <  else binValue = 23;
4010 >  else binValue = 24;
4011  
4012    return binValue;
4013  
# Line 3173 | Line 4017 | const BNprimaryvertex *
4017   OSUAnalysis::chosenVertex ()
4018   {
4019    const BNprimaryvertex *chosenVertex = 0;
4020 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
4021 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
4022 <                               cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
4020 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
4021 >    vector<bool> vertexFlags;
4022 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
4023 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4024 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
4025 >        break;
4026 >      }
4027 >    }
4028      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4029        if(!vertexFlags.at(vertexIndex)) continue;
4030        chosenVertex = & primaryvertexs->at(vertexIndex);
4031        break;
4032      }
4033    }
4034 <  else {
4035 <    chosenVertex = &primaryvertexs->at(0);
3187 <  }
4034 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4035 >    chosenVertex = & primaryvertexs->at (0);
4036  
4037    return chosenVertex;
4038   }
# Line 3193 | Line 4041 | const BNmet *
4041   OSUAnalysis::chosenMET ()
4042   {
4043    const BNmet *chosenMET = 0;
4044 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
4045 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
4046 <                            cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
4044 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4045 >    vector<bool> metFlags;
4046 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4047 >      if (cumulativeFlags.at("mets").at(i).size()){
4048 >        metFlags = cumulativeFlags.at("mets").at(i);
4049 >        break;
4050 >      }
4051 >    }
4052      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4053        if(!metFlags.at(metIndex)) continue;
4054        chosenMET = & mets->at(metIndex);
4055        break;
4056      }
4057    }
4058 <  else {
4059 <    chosenMET = &mets->at(0);
3207 <  }
4058 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4059 >    chosenMET = & mets->at (0);
4060  
4061    return chosenMET;
4062   }
# Line 3213 | Line 4065 | const BNelectron *
4065   OSUAnalysis::chosenElectron ()
4066   {
4067    const BNelectron *chosenElectron = 0;
4068 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4069 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
4070 <                                 cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
4068 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4069 >    vector<bool> electronFlags;
4070 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4071 >      if (cumulativeFlags.at("electrons").at(i).size()){
4072 >        electronFlags = cumulativeFlags.at("electrons").at(i);
4073 >        break;
4074 >      }
4075 >    }
4076      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4077        if(!electronFlags.at(electronIndex)) continue;
4078        chosenElectron = & electrons->at(electronIndex);
4079        break;
4080      }
4081    }
4082 <  else {
4083 <    chosenElectron = &electrons->at(0);
3227 <  }
4082 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4083 >    chosenElectron = & electrons->at (0);
4084  
4085    return chosenElectron;
4086   }
# Line 3233 | Line 4089 | const BNmuon *
4089   OSUAnalysis::chosenMuon ()
4090   {
4091    const BNmuon *chosenMuon = 0;
4092 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4093 <    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
4094 <                             cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
4092 >  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4093 >    vector<bool> muonFlags;
4094 >    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4095 >      if (cumulativeFlags.at("muons").at(i).size()){
4096 >        muonFlags = cumulativeFlags.at("muons").at(i);
4097 >        break;
4098 >      }
4099 >    }
4100      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4101        if(!muonFlags.at(muonIndex)) continue;
4102        chosenMuon = & muons->at(muonIndex);
4103        break;
4104      }
4105    }
4106 <  else {
4107 <    chosenMuon = &muons->at(0);
3247 <  }
4106 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4107 >    chosenMuon = & muons->at (0);
4108  
4109    return chosenMuon;
4110   }
4111  
3252
4112   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines