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.50 by lantonel, Thu Apr 25 07:52:02 2013 UTC vs.
Revision 1.73 by lantonel, Thu May 30 18:09:58 2013 UTC

# Line 17 | Line 17 | OSUAnalysis::OSUAnalysis (const edm::Par
17    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
18    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
19    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
20 <  puFile_ (cfg.getParameter<std::string> ("puFile")),
21 <  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
22 <  muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
23 <  dataPU_ (cfg.getParameter<std::string> ("dataPU")),
24 <  electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
25 <  muonSF_ (cfg.getParameter<std::string> ("muonSF")),
26 <  dataset_ (cfg.getParameter<std::string> ("dataset")),
27 <  datasetType_ (cfg.getParameter<std::string> ("datasetType")),
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 <
36 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
37 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
38   {
39  
40    TH1::SetDefaultSumw2 ();
# Line 40 | Line 42 | OSUAnalysis::OSUAnalysis (const edm::Par
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 < #ifdef DISPLACED_SUSY
51 <  if (datasetType_ == "signalMC")
48 <    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
49 < #endif
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_);
55  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");
59
60  //always make the plot of number of primary vertices (to check pile-up reweighting)
60    objectsToPlot.push_back("primaryvertexs");
61 +  objectsToCut.push_back("primaryvertexs");
62 +
63  
64    //always get the MC particles to do GEN-matching
65    objectsToGet.push_back("mcparticles");
# Line 71 | Line 72 | OSUAnalysis::OSUAnalysis (const edm::Par
72  
73      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
74      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
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.find("pairs")==std::string::npos){ //just a single object
81 <      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
82 <        int spaceIndex = tempInputCollection.find(" ");
83 <        int secondWordLength = tempInputCollection.size() - spaceIndex;
84 <        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
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);
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 the pair and the individual objects to the lists of things to Get/Plot/Cut
95 <      string obj1;
95 >      string obj1;
96        string obj2;
97        getTwoObjs(tempInputCollection, obj1, obj2);
98 <      string obj2ToGet = getObjToGet(obj2);  
98 >      string obj2ToGet = getObjToGet(obj2);
99        objectsToCut.push_back(tempInputCollection);
100        objectsToCut.push_back(obj1);
101 <      objectsToCut.push_back(obj2);  
101 >      objectsToCut.push_back(obj2);
102        objectsToPlot.push_back(tempInputCollection);
103        objectsToPlot.push_back(obj1);
104 <      objectsToPlot.push_back(obj2);  
104 >      objectsToPlot.push_back(obj2);
105        objectsToGet.push_back(tempInputCollection);
106        objectsToGet.push_back(obj1);
107        objectsToGet.push_back(obj2ToGet);
108  
109      }
110  
111 +
112      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
113  
114      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
115  
116 +      vector<double> defaultValue;
117 +      defaultValue.push_back (-1.0);
118 +
119        histogram tempHistogram;
120        tempHistogram.inputCollection = tempInputCollection;
121        tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
122        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
123 <      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
123 >      tempHistogram.bins = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("bins", defaultValue);
124 >      tempHistogram.variableBinsX = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsX", defaultValue);
125 >      tempHistogram.variableBinsY = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsY", defaultValue);
126        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
127  
128        histograms.push_back(tempHistogram);
# Line 160 | Line 171 | OSUAnalysis::OSUAnalysis (const edm::Par
171      tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
172  
173  
174 <    int maxNum = 24;
174 >    int maxNum = 25;
175      vector<double> binVector;
176      binVector.push_back(maxNum);
177      binVector.push_back(0);
# Line 202 | Line 213 | OSUAnalysis::OSUAnalysis (const edm::Par
213      //set triggers for this channel
214      vector<string> triggerNames;
215      triggerNames.clear();
216 +    vector<string> triggerToVetoNames;
217 +    triggerToVetoNames.clear();
218 +
219      tempChannel.triggers.clear();
220 +    tempChannel.triggersToVeto.clear();
221      if(channels_.at(currentChannel).exists("triggers")){
222        triggerNames   = channels_.at(currentChannel).getParameter<vector<string> >("triggers");
223        for(uint trigger = 0; trigger!= triggerNames.size(); trigger++)
224          tempChannel.triggers.push_back(triggerNames.at(trigger));
225        objectsToGet.push_back("triggers");
226      }
227 <
227 >    if(channels_.at(currentChannel).exists("triggersToVeto")){
228 >      triggerToVetoNames = channels_.at(currentChannel).getParameter<vector<string> >("triggersToVeto");
229 >      for(uint trigger = 0; trigger!= triggerToVetoNames.size(); trigger++)
230 >        tempChannel.triggersToVeto.push_back(triggerToVetoNames.at(trigger));
231 >      objectsToGet.push_back("triggers");
232 >    }
233  
234  
235  
236      //create cutFlow for this channel
237      cutFlows_.push_back (new CutFlow (fs_, channelName));
238 +    vector<TFileDirectory> directories; //vector of directories in the output file.
239 +    vector<string> subSubDirNames;//subdirectories in each channel.
240 +    //get list of cuts for this channel
241 +    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
242  
219    //book a directory in the output file with the name of the channel
220    TFileDirectory subDir = fs_->mkdir( channelName );
221    directories.push_back(subDir);
243  
244 <    std::map<std::string, TH1D*> oneDhistoMap;
245 <    oneDHists_.push_back(oneDhistoMap);
246 <    std::map<std::string, TH2D*> twoDhistoMap;
247 <    twoDHists_.push_back(twoDhistoMap);
244 >    //loop over and parse all cuts
245 >    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
246 >      cut tempCut;
247 >      //store input collection for cut
248 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
249 >      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
250 >      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
251 >      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
252 >      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
253 >      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
254 >      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
255 >      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
256 >      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
257 >      tempCut.inputCollection = tempInputCollection;
258 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
259 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
260 >          int spaceIndex = tempInputCollection.find(" ");
261 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
262 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
263 >        }
264 >        else{
265 >          objectsToGet.push_back(tempInputCollection);
266 >        }
267 >        objectsToCut.push_back(tempInputCollection);
268 >      }
269 >      else{//pair of objects, need to add them both to objectsToGet
270 >        string obj1;
271 >        string obj2;
272 >        getTwoObjs(tempInputCollection, obj1, obj2);
273 >        string obj2ToGet = getObjToGet(obj2);
274 >        objectsToCut.push_back(tempInputCollection);
275 >        objectsToCut.push_back(obj1);
276 >        objectsToCut.push_back(obj2);
277 >        objectsToGet.push_back(tempInputCollection);
278 >        objectsToGet.push_back(obj1);
279 >        objectsToGet.push_back(obj2ToGet);
280 >
281 >      }
282 >
283  
284  
285 +      //split cut string into parts and store them
286 +      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
287 +      vector<string> cutStringVector = splitString(cutString);
288 +      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
289 +        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
290 +        exit(0);
291 +      }
292 +      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
293 +      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
294 +        int indexOffset = 4 * subcutIndex;
295 +        string currentVariableString = cutStringVector.at(indexOffset);
296 +        if(currentVariableString.find("(")==string::npos){
297 +          tempCut.functions.push_back("");//no function was specified
298 +          tempCut.variables.push_back(currentVariableString);// variable to cut on
299 +        }
300 +        else{
301 +          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
302 +          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
303 +          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
304 +        }
305 +        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
306 +        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
307 +        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
308 +        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
309 +      }
310  
311 +      //get number of objects required to pass cut for event to pass
312 +      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
313 +      vector<string> numberRequiredVector = splitString(numberRequiredString);
314 +      if(numberRequiredVector.size()!=2){
315 +        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
316 +        exit(0);
317 +      }
318 +
319 +      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
320 +      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
321 +      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
322 +
323 +      //Set up vectors to store the directories and subDIrectories for each channel.
324 +      string subSubDirName;
325 +      string tempCutName;
326 +      if(cuts_.at(currentCut).exists("alias")){
327 +        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
328 +        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
329 +      }
330 +      else{
331 +        //construct string for cutflow table
332 +        bool plural = numberRequiredInt != 1;
333 +        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
334 +        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
335 +        tempCutName = cutName;
336 +        subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
337 +      }
338 +
339 +      subSubDirNames.push_back(subSubDirName);
340 +      tempCut.name = tempCutName;
341 +
342 +      tempChannel.cuts.push_back(tempCut);
343 +
344 +
345 +    }//end loop over cuts
346 +
347 +    vector<map<string, TH1D*>> oneDHistsTmp;
348 +    vector<map<string, TH2D*>> twoDHistsTmp;
349 +    //book a directory in the output file with the name of the channel
350 +    TFileDirectory subDir = fs_->mkdir( channelName );
351 +    //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
352 +    if(GetPlotsAfterEachCut_){
353 +       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){
354 +            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
355 +            directories.push_back(subSubDir);
356 +            map<string, TH1D*> oneDhistoMap;
357 +            oneDHistsTmp.push_back(oneDhistoMap);
358 +            map<string, TH2D*> twoDhistoMap;
359 +            twoDHistsTmp.push_back(twoDhistoMap);
360 +      }
361 +      oneDHists_.push_back(oneDHistsTmp);
362 +      twoDHists_.push_back(twoDHistsTmp);
363 +    }
364 +   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
365 +   else{
366 +      map<string, TH1D*> oneDhistoMap;
367 +      oneDHistsTmp.push_back(oneDhistoMap);
368 +      map<string, TH2D*> twoDhistoMap;
369 +      twoDHistsTmp.push_back(twoDhistoMap);
370 +      oneDHists_.push_back(oneDHistsTmp);
371 +      twoDHists_.push_back(twoDHistsTmp);
372 +      directories.push_back(subDir);
373 +   }
374      //book all histograms included in the configuration
375 +    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
376      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
377        histogram currentHistogram = histograms.at(currentHistogramIndex);
378        int numBinsElements = currentHistogram.bins.size();
379        int numInputVariables = currentHistogram.inputVariables.size();
380 +      int numBinEdgesX = currentHistogram.variableBinsX.size();
381 +      int numBinEdgesY = currentHistogram.variableBinsY.size();
382  
383 <      if(numBinsElements != 3 && numBinsElements !=6) {
384 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
383 >      if(numBinsElements == 1){
384 >        if(numBinEdgesX > 1){
385 >          if(numBinEdgesY > 1)
386 >            numBinsElements = 6;
387 >          else
388 >            numBinsElements = 3;
389 >        }
390 >      }
391 >      if(numBinsElements != 3 && numBinsElements !=6){
392 >        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
393          exit(0);
394        }
395        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
396 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
396 >        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
397          exit(0);
398        }
399        else if(numBinsElements == 3){
400 <        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));
400 >        if (currentHistogram.bins.size () == 3)
401 >          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));
402 >        else
403 >          {
404 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
405 >          }
406        }
407        else if(numBinsElements == 6){
408 <        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));
409 <
408 >        if (currentHistogram.bins.size () == 6)
409 >          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));
410 >        else
411 >          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 ());
412        }
413  
414  
415 <      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
415 >      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
416  
417        // bin      particle type
418        // ---      -------------
# Line 277 | Line 439 | OSUAnalysis::OSUAnalysis (const edm::Par
439        // 20        strange baryon
440        // 21        charm baryon
441        // 22        bottom baryon
442 <      // 23        other
442 >      // 23        QCD string
443 >      // 24        other
444  
445        vector<TString> labelArray;
446        labelArray.push_back("unmatched");
# Line 303 | Line 466 | OSUAnalysis::OSUAnalysis (const edm::Par
466        labelArray.push_back("strange baryon");
467        labelArray.push_back("charm baryon");
468        labelArray.push_back("bottom baryon");
469 +      labelArray.push_back("QCD string");
470        labelArray.push_back("other");
471  
472        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
473 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==std::string::npos) {
474 <          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
475 <        }
476 <        else {
477 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
478 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
479 <        }
473 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
474 >          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
475 >        }
476 >        else {
477 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
478 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
479 >        }
480        }
481 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=std::string::npos) {
482 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
483 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
481 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
482 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
483 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
484        }
485  
486      }
487  
488 <    // Book a histogram for the number of each object type to be plotted.  
489 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
488 >    // Book a histogram for the number of each object type to be plotted.
489 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
490      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
491        string currentObject = objectsToPlot.at(currentObjectIndex);
492        int maxNum = 10;
# Line 332 | Line 496 | OSUAnalysis::OSUAnalysis (const edm::Par
496        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
497        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
498        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
499 +      else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
500 +      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
501 +      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
502 +      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
503        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
504 <      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";        
505 <      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";    
506 <      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";      
504 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
505 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
506 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
507        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
508        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
509        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
510        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
511        else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
512 <      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
512 >      else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
513 >      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
514 >      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
515  
516 <      currentObject.at(0) = toupper(currentObject.at(0));  
516 >      currentObject.at(0) = toupper(currentObject.at(0));
517        string histoName = "num" + currentObject;
518  
519        if(histoName == "numPrimaryvertexs"){
520          string newHistoName = histoName + "BeforePileupCorrection";
521 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
521 >        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);
522          newHistoName = histoName + "AfterPileupCorrection";
523 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
523 >        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);
524        }
525        else
526 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
526 >        oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
527      }
528 <
359 <
360 <
361 <
362 <    //get list of cuts for this channel
363 <    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
364 <
365 <    //loop over and parse all cuts
366 <    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
367 <      cut tempCut;
368 <      //store input collection for cut
369 <      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
370 <      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
371 <      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
372 <      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
373 <      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
374 <      tempCut.inputCollection = tempInputCollection;
375 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
376 <        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
377 <          int spaceIndex = tempInputCollection.find(" ");
378 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
379 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
380 <        }
381 <        else{
382 <          objectsToGet.push_back(tempInputCollection);
383 <        }
384 <        objectsToCut.push_back(tempInputCollection);
385 <      }
386 <      else{//pair of objects, need to add them both to objectsToGet
387 <        string obj1;
388 <        string obj2;
389 <        getTwoObjs(tempInputCollection, obj1, obj2);
390 <        string obj2ToGet = getObjToGet(obj2);  
391 <        objectsToCut.push_back(tempInputCollection);
392 <        objectsToCut.push_back(obj1);
393 <        objectsToCut.push_back(obj2);  
394 <        objectsToGet.push_back(tempInputCollection);
395 <        objectsToGet.push_back(obj1);
396 <        objectsToGet.push_back(obj2ToGet);
397 <
398 <      }
399 <
400 <
401 <
402 <      //split cut string into parts and store them
403 <      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
404 <      std::vector<string> cutStringVector = splitString(cutString);
405 <      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
406 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
407 <        exit(0);
408 <      }
409 <      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
410 <      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
411 <        int indexOffset = 4 * subcutIndex;
412 <        string currentVariableString = cutStringVector.at(indexOffset);
413 <        if(currentVariableString.find("(")==std::string::npos){
414 <          tempCut.functions.push_back("");//no function was specified
415 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
416 <        }
417 <        else{
418 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
419 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
420 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
421 <        }
422 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
423 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
424 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
425 <      }
426 <
427 <      //get number of objects required to pass cut for event to pass
428 <      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
429 <      std::vector<string> numberRequiredVector = splitString(numberRequiredString);
430 <      if(numberRequiredVector.size()!=2){
431 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
432 <        exit(0);
433 <      }
434 <
435 <      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
436 <      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
437 <      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
438 <
439 <
440 <      string tempCutName;
441 <      if(cuts_.at(currentCut).exists("alias")){
442 <        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
443 <      }
444 <      else{
445 <        //construct string for cutflow table
446 <        bool plural = numberRequiredInt != 1;
447 <        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
448 <        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
449 <        tempCutName = cutName;
450 <      }
451 <      tempCut.name = tempCutName;
452 <
453 <      tempChannel.cuts.push_back(tempCut);
454 <
455 <
456 <    }//end loop over cuts
457 <
528 >   }//end of loop over directories
529      channels.push_back(tempChannel);
530      tempChannel.cuts.clear();
460
531    }//end loop over channels
532  
533  
# Line 486 | Line 556 | OSUAnalysis::analyze (const edm::Event &
556  
557    // Retrieve necessary collections from the event.
558  
559 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
559 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
560      event.getByLabel (triggers_, triggers);
561  
562 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
562 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
563 >    event.getByLabel (trigobjs_, trigobjs);
564 >
565 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
566      event.getByLabel (jets_, jets);
567  
568 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
568 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
569      event.getByLabel (muons_, muons);
570  
571 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
571 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
572      event.getByLabel (electrons_, electrons);
573  
574 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
574 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
575      event.getByLabel (events_, events);
576  
577 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
577 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
578      event.getByLabel (taus_, taus);
579  
580 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
580 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
581      event.getByLabel (mets_, mets);
582  
583 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
583 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
584      event.getByLabel (tracks_, tracks);
585  
586 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
586 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
587      event.getByLabel (genjets_, genjets);
588  
589 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
589 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
590      event.getByLabel (mcparticles_, mcparticles);
591  
592 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
592 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
593      event.getByLabel (primaryvertexs_, primaryvertexs);
594  
595 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
595 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
596      event.getByLabel (bxlumis_, bxlumis);
597  
598 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
598 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
599      event.getByLabel (photons_, photons);
600  
601 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
601 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
602      event.getByLabel (superclusters_, superclusters);
603  
604    if (datasetType_ == "signalMC"){
605 <    if (std::find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
605 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
606        event.getByLabel (stops_, stops);
607    }
608  
609 <
610 <  if (useTrackCaloRhoCorr_) {  
611 <    // Used only for pile-up correction of by-hand calculation of isolation energy.  
539 <    // This rho collection is not available in all BEANs.  
609 >  if (useTrackCaloRhoCorr_) {
610 >    // Used only for pile-up correction of by-hand calculation of isolation energy.
611 >    // This rho collection is not available in all BEANs.
612      // For description of rho values for different jet reconstruction algorithms, see
613 <    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
614 <    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
613 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
614 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
615    }
616  
617 +  double masterScaleFactor = 1.0;
618  
619    //get pile-up event weight
620 <  double scaleFactor = 1.00;
621 <  if(doPileupReweighting_ && datasetType_ != "data")
622 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
623 <
624 <  cTauScaleFactor_ = 1.0;
625 < #ifdef DISPLACED_SUSY
626 <  if (datasetType_ == "signalMC")
627 <    cTauScaleFactor_ = cTauWeight_->at (event);
628 < #endif
629 <  scaleFactor *= cTauScaleFactor_;
620 >  if (doPileupReweighting_ && datasetType_ != "data") {
621 >    //for "data" datasets, the numTruePV is always set to -1
622 >    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;  
623 >    else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);  
624 >  }
625 >
626 >  stopCTauScaleFactor_ = 1.0;
627 >  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
628 >    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
629 >  masterScaleFactor *= stopCTauScaleFactor_;
630  
631    //loop over all channels
632  
# Line 565 | Line 638 | OSUAnalysis::analyze (const edm::Event &
638      cumulativeFlags.clear ();
639  
640      bool triggerDecision = true;
641 <    if(currentChannel.triggers.size() != 0){  //triggers specified
642 <      triggerDecision = evaluateTriggers(currentChannel.triggers,triggers.product());
641 >    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
642 >      triggerDecision = evaluateTriggers(currentChannel.triggers, currentChannel.triggersToVeto, triggers.product());
643        cutFlows_.at(currentChannelIndex)->at ("trigger") = triggerDecision;
644      }
645  
646      //loop over all cuts
574
575
576
647      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
648        cut currentCut = currentChannel.cuts.at(currentCutIndex);
579
649        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
650          string currentObject = objectsToCut.at(currentObjectIndex);
651  
# Line 591 | Line 660 | OSUAnalysis::analyze (const edm::Event &
660          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
661  
662  
663 <        if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
664 <
665 <        else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
597 <
663 >        if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
664 >        else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
665 >        else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
666          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
667          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
668          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
# Line 608 | Line 676 | OSUAnalysis::analyze (const edm::Event &
676          else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
677          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
678          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
679 +        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
680  
612        else if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
681  
682  
683          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
# Line 635 | Line 703 | OSUAnalysis::analyze (const edm::Event &
703                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
704                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
705                                                                         "electron-muon pairs");
706 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
707 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
708 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
709 <                                                                     "track-event pairs");
710 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
711 <                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
712 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
713 <                                                                        "electron-track pairs");
714 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
715 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
716 <                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
717 <                                                                    "muon-track pairs");
718 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
719 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
720 <                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
721 <                                                                  "muon-tau pairs");
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 <        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
706 >        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
707 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
708 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
709 >                                                                           "jet-jet pairs");
710 >        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
711 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
712 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
713 >                                                                       "electron-jet pairs");
714 >        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
715 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
716 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
717 >                                                                       "muon-jet pairs");
718 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
719 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
720 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
721 >                                                                     "track-event pairs");
722 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
723 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
724 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
725 >                                                                        "electron-track pairs");
726 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
727 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
728 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
729 >                                                                    "muon-track pairs");
730 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
731 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
732 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
733 >                                                                  "muon-tau pairs");
734 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
735 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
736 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
737 >                                                                 "tau-tau pairs");
738 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
739                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
740                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
741                                                                   "tau-track pairs");
742 <        
743 <        
742 >        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
743 >                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
744 >                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
745 >                                                                          "electron-trigobj pairs");
746 >        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
747 >                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
748 >                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
749 >                                                                      "muon-trigobj pairs");
750 >
751 >        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
752        }
753  
754  
755  
756      }//end loop over all cuts
669
670
757      //use cumulative flags to apply cuts at event level
758  
759      bool eventPassedAllCuts = true;
760 <
760 >    //a vector to store cumulative cut descisions after each cut.
761 >    vector<bool> eventPassedPreviousCuts;
762      //apply trigger (true if none were specified)
763      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
764  
# Line 683 | Line 770 | OSUAnalysis::analyze (const edm::Event &
770        int numberPassing = 0;
771  
772        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
773 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
773 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
774        }
775        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
776        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
777        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
778 <
778 >      eventPassedPreviousCuts.push_back(eventPassedAllCuts);
779      }
780 +    double scaleFactor = masterScaleFactor;
781  
782 <    //     if(datasetType_ != "data") {
783 <    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
784 <    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
785 <    //     }
782 >    muonScaleFactor_ = electronScaleFactor_ = 1.0;
783 >    if(applyLeptonSF_ && datasetType_ != "data"){
784 >      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
785 >        vector<bool> muonFlags;
786 >        for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
787 >          if (cumulativeFlags.at("muons").at(i).size()){
788 >            muonFlags = cumulativeFlags.at("muons").at(i);
789 >            break;
790 >          }
791 >        }
792 >        for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
793 >          if(!muonFlags.at(muonIndex)) continue;
794 >          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
795 >        }
796 >      }
797 >      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
798 >        vector<bool> electronFlags;
799 >        for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
800 >          if (cumulativeFlags.at("electrons").at(i).size()){
801 >            electronFlags = cumulativeFlags.at("electrons").at(i);
802 >            break;
803 >          }
804 >        }
805 >        for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
806 >          if(!electronFlags.at(electronIndex)) continue;
807 >          electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
808 >        }
809 >      }
810 >    }
811 >    scaleFactor *= muonScaleFactor_;
812 >    scaleFactor *= electronScaleFactor_;
813  
814      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
815  
816  
702
703    if(!eventPassedAllCuts)continue;
704
817      if (printEventInfo_) {
818 <      // Write information about event to screen, for testing purposes.  
819 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
820 <           << ": run="  << events->at(0).run
821 <           << "  lumi=" << events->at(0).lumi
822 <           << "  event=" << events->at(0).evt
823 <           << endl;  
818 >      // Write information about event to screen, for testing purposes.
819 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
820 >           << ": run="  << events->at(0).run
821 >           << "  lumi=" << events->at(0).lumi
822 >           << "  event=" << events->at(0).evt
823 >           << endl;
824      }
825  
826  
715    //filling histograms
716    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
717      histogram currentHistogram = histograms.at(histogramIndex);
827  
828 <      if(currentHistogram.inputVariables.size() == 1){
829 <        TH1D* histo;
721 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
722 <
723 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
724 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
725 <        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
726 <        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
727 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
728 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
729 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
730 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
731 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
732 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
733 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
734 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
735 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
736 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
737 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
738 <                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
739 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
740 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
741 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
742 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
743 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
744 <                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
745 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
746 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
747 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
748 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
749 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
750 <                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
751 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
752 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
753 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
754 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
755 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
756 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
757 <                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
758 <
759 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
760 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
761 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
762 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
763 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
764 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
765 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
766 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
767 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
768 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
769 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
770 <
771 <      }
772 <      else if(currentHistogram.inputVariables.size() == 2){
773 <        TH2D* histo;
774 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
775 <
776 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
777 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
778 <        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
779 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
780 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
781 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
782 <        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
783 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
784 <                                                                                       cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
785 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
786 <        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
787 <        else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
788 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
789 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
790 <        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
791 <                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
792 <                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
793 <        else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
794 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
795 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
796 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
797 <                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
798 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
799 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
800 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
801 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
802 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
803 <                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
804 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
805 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
806 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
807 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
808 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
809 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
810 <                                                                                     cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
811 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
812 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
813 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
814 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
815 <        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
816 <                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
817 <                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
818 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
819 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
820 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
821 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
822 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
823 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
824 <        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
828 >    //filling histograms
829 >    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
830  
831 +      uint currentDir;
832 +      if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the last cut.
833 +      else currentDir = currentCut;
834 +
835 +      if(!eventPassedPreviousCuts.at(currentDir)) continue;
836 +
837 +
838 +      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
839 +        histogram currentHistogram = histograms.at(histogramIndex);
840 +
841 +        if(currentHistogram.inputVariables.size() == 1){
842 +          TH1D* histo;
843 +          histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
844 +
845 +          if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
846 +          else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
847 +          else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
848 +          else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
849 +          else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
850 +          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
851 +                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
852 +                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
853 +          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
854 +                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
855 +                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
856 +          else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
857 +          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
858 +                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
859 +                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
860 +          else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
861 +                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
862 +                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
863 +          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
864 +                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
865 +                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
866 +          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
867 +                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
868 +                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
869 +          else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
870 +                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
871 +                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
872 +          else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
873 +                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
874 +                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
875 +          else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
876 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
877 +                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
878 +          else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
879 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
880 +                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
881 +          else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
882 +                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
883 +                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
884 +          else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
885 +                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
886 +                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
887 +          else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
888 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
889 +                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
890 +          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
891 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
892 +                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
893 +          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
894 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
895 +                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
896 +          
897 +          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
898 +          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
899 +          else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
900 +          else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
901 +          else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
902 +          else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
903 +          else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
904 +          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
905 +          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
906 +          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
907 +          else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
908 +          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
909 +        }
910 +        else if(currentHistogram.inputVariables.size() == 2){
911 +          TH2D* histo;
912 +          histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
913 +
914 +          if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
915 +          else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
916 +          else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
917 +          else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
918 +          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
919 +                                                                                         cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
920 +                                                                                         cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
921 +          else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
922 +                                                                                                   cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
923 +                                                                                                   cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
924 +          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
925 +          else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
926 +          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
927 +                                                                                                 cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
928 +                                                                                                 cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
929 +          else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
930 +                                                                                       cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
931 +                                                                                       cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
932 +          else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
933 +                                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
934 +                                                                                                           cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
935 +          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
936 +                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
937 +                                                                                             cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
938 +          else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
939 +                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
940 +                                                                                            cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
941 +          else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
942 +                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
943 +                                                                                        cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
944 +          else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
945 +                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
946 +                                                                                              cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
947 +          else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
948 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
949 +                                                                                          cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
950 +          else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
951 +                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
952 +                                                                                        cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
953 +          else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
954 +                                                                                       cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
955 +                                                                                       cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
956 +          else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
957 +                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
958 +                                                                                         cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
959 +          else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
960 +                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
961 +                                                                                                cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
962 +          else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
963 +                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
964 +                                                                                            cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
965 +          else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
966 +          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
967 +          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
968 +          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
969 +          else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
970 +                                                                                           cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
971 +                                                                                           cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
972 +          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
973 +          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
974 +          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
975 +          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
976 +          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
977 +          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
978 +          else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
979 +          else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
980 +        }
981        }
827    }
828
982  
983 +      //fills histograms with the sizes of collections
984  
985 <    //fills histograms with the sizes of collections
986 <    for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
987 <
988 <      string currentObject = objectsToPlot.at(currentObjectIndex);
985 >      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
986 >        
987 >        string currentObject = objectsToPlot.at(currentObjectIndex);
988 >        string objectToPlot = "";
989 >        
990 >        // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
991 >        if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
992 >        else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
993 >        else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
994 >        else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
995 >        else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
996 >        else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
997 >        else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
998 >        else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
999 >        else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1000 >        else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1001 >        else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1002 >        else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
1003 >        else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
1004 >        else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1005 >        else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1006 >        else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1007 >        else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1008 >        else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1009 >        else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1010 >        else objectToPlot = currentObject;
1011 >        
1012 >        string tempCurrentObject = objectToPlot;
1013 >        tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
1014 >        string histoName = "num" + tempCurrentObject;
1015 >        
1016  
1017 <      string objectToPlot = "";  
1017 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1018  
1019 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
839 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
840 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
841 <      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
842 <      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
843 <      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
844 <      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
845 <      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
846 <      else if(currentObject == "tau-track pairs")         objectToPlot = "tauTrackPairs";
847 <      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
848 <      else if(currentObject == "muon-secondary muon pairs")       objectToPlot = "muonSecondaryMuonPairs";  
849 <      else if(currentObject == "secondary muons")         objectToPlot = "secondaryMuons";  
850 <      else if(currentObject == "electron-secondary electron pairs")       objectToPlot = "electronSecondaryElectronPairs";  
851 <      else if(currentObject == "secondary electrons")         objectToPlot = "secondaryElectrons";  
852 <      else objectToPlot = currentObject;
853 <
854 <      string tempCurrentObject = objectToPlot;
855 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
856 <      string histoName = "num" + tempCurrentObject;
857 <
858 <      //set position of primary vertex in event, in order to calculate quantities relative to it
859 <      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
860 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
1019 >        //count the number of objects passing all cuts
1020          int numToPlot = 0;
1021 <        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1022 <          if(lastCutFlags.at(currentFlag)) numToPlot++;
864 <        }
865 <        if(objectToPlot == "primaryvertexs"){
866 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
867 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
868 <        }
869 <        else {
870 <          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
1021 >        for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1022 >          if(lastCutFlags.at(currentFlag)) numToPlot++;
1023          }
872      }
873      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
874      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
875      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
876      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
877      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
878      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
879      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
880      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
881      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
882      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
883      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
884      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
885      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
886      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
887      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
888      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
889      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
890      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
891      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
892      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
893      else if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
894      else if(objectToPlot == "primaryvertexs"){
895        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
896        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
897      }
1024  
1025 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1025 >        if(objectToPlot == "primaryvertexs"){
1026 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1027 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1028 >        }
1029 >        else {
1030 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1031 >        }
1032 >      } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1033 >    }
1034  
1035    } //end loop over channel
1036  
1037 <  masterCutFlow_->fillCutFlow(scaleFactor);
1037 >  masterCutFlow_->fillCutFlow(masterScaleFactor);
1038  
1039   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1040  
# Line 917 | Line 1051 | OSUAnalysis::evaluateComparison (double
1051    else if(comparison == "==") return testValue == cutValue;
1052    else if(comparison == "=") return testValue == cutValue;
1053    else if(comparison == "!=") return testValue != cutValue;
1054 <  else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1054 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1055 >
1056 > }
1057 >
1058 > bool
1059 > OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1060 >
1061 >
1062 >  if(comparison == ">")       return testValue >  cutValue;
1063 >  else if(comparison == ">=") return testValue >= cutValue;
1064 >  else if(comparison == "<")  return testValue <  cutValue;
1065 >  else if(comparison == "<=") return testValue <= cutValue;
1066 >  else if(comparison == "==") return testValue == cutValue;
1067 >  else if(comparison == "=") return testValue == cutValue;
1068 >  else if(comparison == "!=") return testValue != cutValue;
1069 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1070  
1071   }
1072  
1073   bool
1074 < OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, const BNtriggerCollection* triggerCollection){
1074 > OSUAnalysis::evaluateTriggers (vector<string> triggersToTest, vector<string> triggersToVeto, const BNtriggerCollection* triggerCollection){
1075  
1076 +  //initialize to false until a chosen trigger is passed
1077    bool triggerDecision = false;
1078  
1079 <  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++)
1080 <    {
931 <      if(trigger->pass != 1) continue;
932 <      for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
933 <        {
934 <          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
935 <            triggerDecision = true;
936 <          }
937 <        }
938 <    }
939 <  return triggerDecision;
1079 >  //loop over all triggers defined in the event
1080 >  for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1081  
1082 +    //we're only interested in triggers that actually passed
1083 +    if(trigger->pass != 1) continue;
1084 +
1085 +    //if the event passes one of the veto triggers, exit and return false
1086 +    for(uint triggerName = 0; triggerName != triggersToVeto.size(); triggerName++){
1087 +      if(trigger->name.find(triggersToVeto.at(triggerName))!=string::npos) return false;
1088 +    }
1089 +    //if the event passes one of the chosen triggers, set triggerDecision to true
1090 +    for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++){
1091 +      if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos) triggerDecision = true;
1092 +    }  
1093 +  }
1094 +  //if none of the veto triggers fired:
1095 +  //return the OR of all the chosen triggers
1096 +  if (triggersToTest.size() != 0) return triggerDecision;
1097 +  //or if no triggers were defined return true
1098 +  else return true;
1099   }
1100  
1101 < std::vector<std::string>
1101 >
1102 > vector<string>
1103   OSUAnalysis::splitString (string inputString){
1104  
1105 <  std::stringstream stringStream(inputString);
1106 <  std::istream_iterator<std::string> begin(stringStream);
1107 <  std::istream_iterator<std::string> end;
1108 <  std::vector<std::string> stringVector(begin, end);
1105 >  stringstream stringStream(inputString);
1106 >  istream_iterator<string> begin(stringStream);
1107 >  istream_iterator<string> end;
1108 >  vector<string> stringVector(begin, end);
1109    return stringVector;
1110  
1111   }
1112  
1113  
1114   void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1115 <  // Set two object strings from the tempInputCollection string,
1116 <  // For example, if tempInputCollection is "electron-muon pairs",
1117 <  // then obj1 = "electrons" and obj2 = "muons".  
1118 <  // Note that the objects have an "s" appended.  
1115 >  // Set two object strings from the tempInputCollection string,
1116 >  // For example, if tempInputCollection is "electron-muon pairs",
1117 >  // then obj1 = "electrons" and obj2 = "muons".
1118 >  // Note that the objects have an "s" appended.
1119  
1120    int dashIndex = tempInputCollection.find("-");
1121    int spaceIndex = tempInputCollection.find_last_of(" ");
1122    int secondWordLength = spaceIndex - dashIndex;
1123 <  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
1123 >  obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1124    obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1125 <  
1126 < }
1125 >
1126 > }
1127  
1128  
1129   string OSUAnalysis::getObjToGet(string obj) {
1130    // Return the string corresponding to the object to get for the given obj string.
1131 <  // Right now this only handles the case in which obj contains "secondary",
1132 <  // e.g, "secondary muons".  
1133 <  // Note that "s" is NOT appended.  
975 <  
976 <  if (obj.find("secondary")==std::string::npos) return obj;  // "secondary" is not found  
977 <  int firstSpaceIndex = obj.find_first_of(" ");  
978 <  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1131 >  // Right now this only handles the case in which obj contains "secondary",
1132 >  // e.g, "secondary muons".
1133 >  // Note that "s" is NOT appended.
1134  
1135 < }  
1135 >  if (obj.find("secondary")==string::npos) return obj;  // "secondary" is not found
1136 >  int firstSpaceIndex = obj.find_first_of(" ");
1137 >  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1138  
1139 + }
1140  
1141  
1142 + //!jet valueLookup
1143   double
1144 < OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1144 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1145  
1146    double value = 0.0;
1147    if(variable == "energy") value = object->energy;
# Line 1102 | Line 1261 | OSUAnalysis::valueLookup (const BNjet* o
1261    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1262  
1263  
1264 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1264 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1265  
1266    value = applyFunction(function, value);
1267  
# Line 1110 | Line 1269 | OSUAnalysis::valueLookup (const BNjet* o
1269   }
1270  
1271  
1272 <
1272 > //!muon valueLookup
1273   double
1274 < OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1274 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1275  
1276    double value = 0.0;
1277    if(variable == "energy") value = object->energy;
# Line 1273 | Line 1432 | OSUAnalysis::valueLookup (const BNmuon*
1432    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1433    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1434    else if(variable == "metMT") {
1435 <    const BNmet *met = chosenMET ();
1277 <    if (met)
1435 >    if (const BNmet *met = chosenMET ())
1436        {
1437 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1438 <          p2 (met->px, met->py, 0.0, met->pt);
1281 <
1282 <        value = (p1 + p2).Mt ();
1437 >        double dPhi = deltaPhi (object->phi, met->phi);
1438 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1439        }
1440      else
1441        value = -999;
# Line 1397 | Line 1553 | OSUAnalysis::valueLookup (const BNmuon*
1553      value = object->isGlobalMuon > 0                \
1554        && object->isPFMuon > 0                        \
1555        && object->normalizedChi2 < 10                \
1556 <                                  && object->numberOfValidMuonHits > 0        \
1556 >                                  && object->numberOfValidMuonHits > 0        \
1557        && object->numberOfMatchedStations > 1        \
1558        && fabs(object->correctedD0Vertex) < 0.2        \
1559        && fabs(object->correctedDZ) < 0.5        \
# Line 1406 | Line 1562 | OSUAnalysis::valueLookup (const BNmuon*
1562    }
1563    else if(variable == "tightIDdisplaced"){
1564      value = object->isGlobalMuon > 0                \
1565 +      && object->isPFMuon > 0                        \
1566        && object->normalizedChi2 < 10                \
1567 <                                  && object->numberOfValidMuonHits > 0        \
1567 >                                  && object->numberOfValidMuonHits > 0        \
1568        && object->numberOfMatchedStations > 1        \
1569        && object->numberOfValidPixelHits > 0        \
1570        && object->numberOfLayersWithMeasurement > 5;
1571    }
1572  
1573 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1573 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1574  
1575    else if(variable == "genMatchedPdgId"){
1576      int index = getGenMatchedParticleIndex(object);
# Line 1433 | Line 1590 | OSUAnalysis::valueLookup (const BNmuon*
1590    }
1591    else if(variable == "genMatchedMotherIdReverse"){
1592      int index = getGenMatchedParticleIndex(object);
1593 <    if(index == -1) value = 23;
1594 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1593 >    if(index == -1) value = 24;
1594 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1595    }
1596    else if(variable == "genMatchedGrandmotherId"){
1597      int index = getGenMatchedParticleIndex(object);
# Line 1448 | Line 1605 | OSUAnalysis::valueLookup (const BNmuon*
1605    }
1606    else if(variable == "genMatchedGrandmotherIdReverse"){
1607      int index = getGenMatchedParticleIndex(object);
1608 <    if(index == -1) value = 23;
1608 >    if(index == -1) value = 24;
1609      else if(fabs(mcparticles->at(index).motherId) == 15){
1610        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1611 <      if(motherIndex == -1) value = 23;
1612 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1611 >      if(motherIndex == -1) value = 24;
1612 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1613      }
1614 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1614 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1615    }
1616 +  else if(variable == "pfMuonsFromVertex"){
1617 +    double d0Error, dzError;
1618  
1619 +    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1620 +    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1621 +    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1622 +         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1623 +         || fabs (object->correctedDZ / dzError) > 99.0;
1624 +    value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1625 +  }
1626  
1627  
1628 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1628 >
1629 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1630  
1631    value = applyFunction(function, value);
1632  
1633    return value;
1634   }
1635  
1636 <
1636 > //!electron valueLookup
1637   double
1638 < OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1638 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
1639  
1640    double value = 0.0;
1641    if(variable == "energy") value = object->energy;
# Line 1634 | Line 1801 | OSUAnalysis::valueLookup (const BNelectr
1801    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1802    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1803    else if(variable == "metMT") {
1804 <    const BNmet *met = chosenMET ();
1638 <    if (met)
1804 >    if (const BNmet *met = chosenMET ())
1805        {
1806 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1807 <          p2 (met->px, met->py, 0.0, met->pt);
1642 <
1643 <        value = (p1 + p2).Mt ();
1806 >        double dPhi = deltaPhi (object->phi, met->phi);
1807 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1808        }
1809      else
1810        value = -999;
# Line 1805 | Line 1969 | OSUAnalysis::valueLookup (const BNelectr
1969    }
1970  
1971  
1972 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1972 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1973  
1974    else if(variable == "genMatchedPdgId"){
1975      int index = getGenMatchedParticleIndex(object);
# Line 1826 | Line 1990 | OSUAnalysis::valueLookup (const BNelectr
1990    }
1991    else if(variable == "genMatchedMotherIdReverse"){
1992      int index = getGenMatchedParticleIndex(object);
1993 <    if(index == -1) value = 23;
1994 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1993 >    if(index == -1) value = 24;
1994 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
1995    }
1996    else if(variable == "genMatchedGrandmotherId"){
1997      int index = getGenMatchedParticleIndex(object);
# Line 1841 | Line 2005 | OSUAnalysis::valueLookup (const BNelectr
2005    }
2006    else if(variable == "genMatchedGrandmotherIdReverse"){
2007      int index = getGenMatchedParticleIndex(object);
2008 <    if(index == -1) value = 23;
2008 >    if(index == -1) value = 24;
2009      else if(fabs(mcparticles->at(index).motherId) == 15){
2010        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2011 <      if(motherIndex == -1) value = 23;
2012 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2011 >      if(motherIndex == -1) value = 24;
2012 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2013      }
2014 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2014 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2015 >  }
2016 >  else if(variable == "pfElectronsFromVertex"){
2017 >    double d0Error, dzError;
2018 >
2019 >    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2020 >    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2021 >    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2022 >         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2023 >         || fabs (object->correctedDZ / dzError) > 99.0;
2024 >    value = !value;
2025    }
2026  
2027  
2028  
2029 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2029 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2030  
2031    value = applyFunction(function, value);
2032  
2033    return value;
2034   }
2035  
2036 <
2036 > //!event valueLookup
2037   double
2038 < OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
2038 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
2039  
2040    double value = 0.0;
2041  
# Line 1930 | Line 2104 | OSUAnalysis::valueLookup (const BNevent*
2104    else if(variable == "id2") value = object->id2;
2105    else if(variable == "evt") value = object->evt;
2106    else if(variable == "puScaleFactor"){
2107 <    if(datasetType_ != "data")
2107 >    if(doPileupReweighting_ && datasetType_ != "data")
2108        value = puWeight_->at (events->at (0).numTruePV);
2109      else
2110        value = 1.0;
2111    }
2112 <  else if(variable == "muonScaleFactor"){
2113 <    if(datasetType_ != "data")
2114 <      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1941 <      value = 1.0;
1942 <    else
1943 <      value = 1.0;
1944 <  }
1945 <  else if(variable == "electronScaleFactor"){
1946 <    if(datasetType_ != "data")
1947 <      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1948 <      value = 1.0;
1949 <    else
1950 <      value = 1.0;
1951 <  }
1952 <  else if(variable == "cTauScaleFactor")
1953 <    value = cTauScaleFactor_;
2112 >  else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2113 >  else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2114 >  else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2115  
2116 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2116 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2117  
2118    value = applyFunction(function, value);
2119  
2120    return value;
2121   }
2122  
2123 + //!tau valueLookup
2124   double
2125 < OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2125 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2126  
2127    double value = 0.0;
2128  
# Line 2006 | Line 2168 | OSUAnalysis::valueLookup (const BNtau* o
2168  
2169  
2170  
2171 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2171 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2172  
2173    else if(variable == "genMatchedPdgId"){
2174      int index = getGenMatchedParticleIndex(object);
# Line 2026 | Line 2188 | OSUAnalysis::valueLookup (const BNtau* o
2188    }
2189    else if(variable == "genMatchedMotherIdReverse"){
2190      int index = getGenMatchedParticleIndex(object);
2191 <    if(index == -1) value = 23;
2192 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2191 >    if(index == -1) value = 24;
2192 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2193    }
2194    else if(variable == "genMatchedGrandmotherId"){
2195      int index = getGenMatchedParticleIndex(object);
# Line 2041 | Line 2203 | OSUAnalysis::valueLookup (const BNtau* o
2203    }
2204    else if(variable == "genMatchedGrandmotherIdReverse"){
2205      int index = getGenMatchedParticleIndex(object);
2206 <    if(index == -1) value = 23;
2206 >    if(index == -1) value = 24;
2207      else if(fabs(mcparticles->at(index).motherId) == 15){
2208        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2209 <      if(motherIndex == -1) value = 23;
2210 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2209 >      if(motherIndex == -1) value = 24;
2210 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2211      }
2212 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2212 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2213    }
2214  
2215  
2216 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2216 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2217  
2218    value = applyFunction(function, value);
2219  
2220    return value;
2221   }
2222  
2223 + //!met valueLookup
2224   double
2225 < OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2225 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2226  
2227    double value = 0.0;
2228  
# Line 2123 | Line 2286 | OSUAnalysis::valueLookup (const BNmet* o
2286    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2287    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2288  
2289 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2289 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2290  
2291    value = applyFunction(function, value);
2292  
2293    return value;
2294   }
2295  
2296 + //!track valueLookup
2297   double
2298 < OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2298 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2299  
2300    double value = 0.0;
2301    double pMag = sqrt(object->pt * object->pt +
2302 <                     object->pz * object->pz);
2303 <  
2302 >                     object->pz * object->pz);
2303 >
2304    if(variable == "pt") value = object->pt;
2305    else if(variable == "px") value = object->px;
2306    else if(variable == "py") value = object->py;
# Line 2157 | Line 2321 | OSUAnalysis::valueLookup (const BNtrack*
2321  
2322  
2323    //additional BNs info for disappTrks
2160  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2324    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2325    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2326    else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2327    else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2328    else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2329    else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2330 +  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2331    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2332    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2333    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2334 <  
2334 >  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2335  
2336    //user defined variables
2337    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;
2338    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2339 +  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2340    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2341    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2342 <  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);  
2343 <  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2342 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2343 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2344    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2345    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2346    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2347    else if(variable == "ptError")                    value = object->ptError;
2348    else if(variable == "ptRes")                      value = getTrkPtRes(object);
2349 <  else if (variable == "d0wrtPV"){      
2350 <    double vx = object->vx - chosenVertex ()->x,        
2351 <      vy = object->vy - chosenVertex ()->y,      
2352 <      px = object->px,  
2353 <      py = object->py,  
2354 <      pt = object->pt;  
2355 <    value = (-vx * py + vy * px) / pt;  
2356 <  }      
2357 <  else if (variable == "dZwrtPV"){      
2358 <    double vx = object->vx - chosenVertex ()->x,        
2359 <      vy = object->vy - chosenVertex ()->y,      
2360 <      vz = object->vz - chosenVertex ()->z,      
2361 <      px = object->px,  
2362 <      py = object->py,  
2363 <      pz = object->pz,  
2364 <      pt = object->pt;  
2365 <    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2366 <  }    
2367 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2349 >  else if (variable == "d0wrtPV"){
2350 >    double vx = object->vx - chosenVertex ()->x,
2351 >      vy = object->vy - chosenVertex ()->y,
2352 >      px = object->px,
2353 >      py = object->py,
2354 >      pt = object->pt;
2355 >    value = (-vx * py + vy * px) / pt;
2356 >  }
2357 >  else if (variable == "dZwrtPV"){
2358 >    double vx = object->vx - chosenVertex ()->x,
2359 >      vy = object->vy - chosenVertex ()->y,
2360 >      vz = object->vz - chosenVertex ()->z,
2361 >      px = object->px,
2362 >      py = object->py,
2363 >      pz = object->pz,
2364 >      pt = object->pt;
2365 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2366 >  }
2367 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2368  
2369    else if(variable == "genMatchedPdgId"){
2370      int index = getGenMatchedParticleIndex(object);
# Line 2220 | Line 2385 | OSUAnalysis::valueLookup (const BNtrack*
2385    }
2386    else if(variable == "genMatchedMotherIdReverse"){
2387      int index = getGenMatchedParticleIndex(object);
2388 <    if(index == -1) value = 23;
2389 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2388 >    if(index == -1) value = 24;
2389 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2390    }
2391    else if(variable == "genMatchedGrandmotherId"){
2392      int index = getGenMatchedParticleIndex(object);
# Line 2235 | Line 2400 | OSUAnalysis::valueLookup (const BNtrack*
2400    }
2401    else if(variable == "genMatchedGrandmotherIdReverse"){
2402      int index = getGenMatchedParticleIndex(object);
2403 <    if(index == -1) value = 23;
2403 >    if(index == -1) value = 24;
2404      else if(fabs(mcparticles->at(index).motherId) == 15){
2405        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2406 <      if(motherIndex == -1) value = 23;
2407 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2406 >      if(motherIndex == -1) value = 24;
2407 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2408      }
2409 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2409 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2410    }
2411  
2412  
2413  
2414 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2414 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2415  
2416    value = applyFunction(function, value);
2417  
2418    return value;
2419   }
2420  
2421 + //!genjet valueLookup
2422   double
2423 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2423 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2424  
2425    double value = 0.0;
2426  
# Line 2274 | Line 2440 | OSUAnalysis::valueLookup (const BNgenjet
2440    else if(variable == "charge") value = object->charge;
2441  
2442  
2443 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2443 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2444  
2445    value = applyFunction(function, value);
2446  
2447    return value;
2448   }
2449  
2450 + //!mcparticle valueLookup
2451   double
2452 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2452 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2453  
2454    double value = 0.0;
2455  
# Line 2407 | Line 2574 | OSUAnalysis::valueLookup (const BNmcpart
2574    }
2575  
2576  
2577 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2577 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2578  
2579    value = applyFunction(function, value);
2580  
2581    return value;
2582   }
2583  
2584 + //!primaryvertex valueLookup
2585   double
2586 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2586 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
2587  
2588    double value = 0.0;
2589  
# Line 2434 | Line 2602 | OSUAnalysis::valueLookup (const BNprimar
2602    else if(variable == "isGood") value = object->isGood;
2603  
2604  
2605 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2605 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2606  
2607    value = applyFunction(function, value);
2608  
2609    return value;
2610   }
2611  
2612 + //!bxlumi valueLookup
2613   double
2614 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2614 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
2615  
2616    double value = 0.0;
2617  
# Line 2451 | Line 2620 | OSUAnalysis::valueLookup (const BNbxlumi
2620    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2621  
2622  
2623 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2623 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2624  
2625    value = applyFunction(function, value);
2626  
2627    return value;
2628   }
2629  
2630 + //!photon valueLookup
2631   double
2632 < OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2632 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
2633  
2634    double value = 0.0;
2635  
# Line 2534 | Line 2704 | OSUAnalysis::valueLookup (const BNphoton
2704    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2705  
2706  
2537
2707  
2708 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2708 >
2709 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2710  
2711    else if(variable == "genMatchedPdgId"){
2712      int index = getGenMatchedParticleIndex(object);
# Line 2558 | Line 2728 | OSUAnalysis::valueLookup (const BNphoton
2728    }
2729    else if(variable == "genMatchedMotherIdReverse"){
2730      int index = getGenMatchedParticleIndex(object);
2731 <    if(index == -1) value = 23;
2732 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2731 >    if(index == -1) value = 24;
2732 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2733    }
2734    else if(variable == "genMatchedGrandmotherId"){
2735      int index = getGenMatchedParticleIndex(object);
# Line 2573 | Line 2743 | OSUAnalysis::valueLookup (const BNphoton
2743    }
2744    else if(variable == "genMatchedGrandmotherIdReverse"){
2745      int index = getGenMatchedParticleIndex(object);
2746 <    if(index == -1) value = 23;
2746 >    if(index == -1) value = 24;
2747      else if(fabs(mcparticles->at(index).motherId) == 15){
2748        int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2749 <      if(motherIndex == -1) value = 23;
2750 <      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2749 >      if(motherIndex == -1) value = 24;
2750 >      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2751      }
2752 <    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2752 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2753    }
2754  
2755  
2756 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2756 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2757  
2758    value = applyFunction(function, value);
2759  
2760    return value;
2761   }
2762  
2763 + //!supercluster valueLookup
2764   double
2765 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2765 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
2766  
2767    double value = 0.0;
2768  
# Line 2605 | Line 2776 | OSUAnalysis::valueLookup (const BNsuperc
2776    else if(variable == "theta") value = object->theta;
2777  
2778  
2779 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2779 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2780  
2781    value = applyFunction(function, value);
2782  
2783    return value;
2784   }
2785  
2786 + //!trigobj valueLookup
2787 + double
2788 + OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
2789 +
2790 +  double value = 0.0;
2791  
2792 +  if(variable == "pt") value = object->pt;
2793 +  else if(variable == "eta") value = object->eta;
2794 +  else if(variable == "phi") value = object->phi;
2795 +  else if(variable == "px") value = object->px;
2796 +  else if(variable == "py") value = object->py;
2797 +  else if(variable == "pz") value = object->pz;
2798 +  else if(variable == "et") value = object->et;
2799 +  else if(variable == "energy") value = object->energy;
2800 +  else if(variable == "etTotal") value = object->etTotal;
2801 +  else if(variable == "id") value = object->id;
2802 +  else if(variable == "charge") value = object->charge;
2803 +  else if(variable == "isIsolated") value = object->isIsolated;
2804 +  else if(variable == "isMip") value = object->isMip;
2805 +  else if(variable == "isForward") value = object->isForward;
2806 +  else if(variable == "isRPC") value = object->isRPC;
2807 +  else if(variable == "bx") value = object->bx;
2808 +  else if(variable == "filter") {
2809 +    if ((stringValue = object->filter) == "")
2810 +      stringValue = "none";  // stringValue should only be empty if value is filled
2811 +  }
2812 +
2813 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2814 +
2815 +  value = applyFunction(function, value);
2816 +
2817 +  return value;
2818 + }
2819 +
2820 + //!muon-muon pair valueLookup
2821   double
2822 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2822 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2823  
2824    double value = 0.0;
2825  
# Line 2676 | Line 2881 | OSUAnalysis::valueLookup (const BNmuon*
2881        value = object2->correctedD0;
2882      }
2883  
2884 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2884 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2885  
2886    value = applyFunction(function, value);
2887  
2888    return value;
2889   }
2890  
2891 + //!electron-electron pair valueLookup
2892   double
2893 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2893 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
2894  
2895    double value = 0.0;
2896  
# Line 2731 | Line 2937 | OSUAnalysis::valueLookup (const BNelectr
2937      value = object2->correctedD0;
2938    }
2939  
2940 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2940 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2941  
2942    value = applyFunction(function, value);
2943  
2944    return value;
2945   }
2946 <
2946 > //!electron-muon pair valueLookup
2947   double
2948 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2948 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2949  
2950    double value = 0.0;
2951  
# Line 2797 | Line 3003 | OSUAnalysis::valueLookup (const BNelectr
3003    else if(variable == "muonRelPFdBetaIso"){
3004      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3005    }
3006 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3007 +  value = applyFunction(function, value);
3008  
3009 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3009 >  return value;
3010 > }
3011 >
3012 > //!electron-jet pair valueLookup
3013 > double
3014 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
3015 >
3016 >  double value = 0.0;
3017 >
3018 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3019 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3020 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3021 >  else if(variable == "invMass"){
3022 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3023 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3024 >    value = (fourVector1 + fourVector2).M();
3025 >  }
3026 >  else if(variable == "pt"){
3027 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3028 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3029 >    value = (fourVector1 + fourVector2).Pt();
3030 >  }
3031 >  else if(variable == "threeDAngle")
3032 >    {
3033 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3034 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3035 >      value = (threeVector1.Angle(threeVector2));
3036 >    }
3037 >  else if(variable == "chargeProduct"){
3038 >    value = object1->charge*object2->charge;
3039 >  }
3040  
3041 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3042    value = applyFunction(function, value);
3043  
3044    return value;
3045   }
3046  
3047 + //!muon-jet pair valueLookup
3048 + double
3049 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
3050 +
3051 +  double value = 0.0;
3052  
3053 < double  
2810 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
2811 <  double electronMass = 0.000511;        
2812 <  double value = 0.0;    
2813 <  TLorentzVector fourVector1(0, 0, 0, 0);        
2814 <  TLorentzVector fourVector2(0, 0, 0, 0);        
2815 <  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
3053 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3054    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3055 <  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3056 <  else if(variable == "invMass"){        
3057 <    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
3058 <    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
3059 <        
3060 <    value = (fourVector1 + fourVector2).M();    
3055 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3056 >  else if(variable == "invMass"){
3057 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3058 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3059 >    value = (fourVector1 + fourVector2).M();
3060 >  }
3061 >  else if(variable == "pt"){
3062 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3063 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3064 >    value = (fourVector1 + fourVector2).Pt();
3065    }
3066 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3067 <  value = applyFunction(function, value);        
3068 <  return value;  
3066 >  else if(variable == "threeDAngle")
3067 >    {
3068 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3069 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3070 >      value = (threeVector1.Angle(threeVector2));
3071 >    }
3072 >  else if(variable == "chargeProduct"){
3073 >    value = object1->charge*object2->charge;
3074 >  }
3075 >
3076 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3077 >  value = applyFunction(function, value);
3078 >
3079 >  return value;
3080 > }
3081 >
3082 > //!jet-jet pair valueLookup
3083 > double
3084 > OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3085 >
3086 >  double value = 0.0;
3087 >
3088 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3089 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3090 >  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3091 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3092 >  else if(variable == "invMass"){
3093 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3094 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3095 >    value = (fourVector1 + fourVector2).M();
3096 >  }
3097 >  else if(variable == "pt"){
3098 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3099 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3100 >    value = (fourVector1 + fourVector2).Pt();
3101 >  }
3102 >  else if(variable == "threeDAngle")
3103 >    {
3104 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3105 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3106 >      value = (threeVector1.Angle(threeVector2));
3107 >    }
3108 >  else if(variable == "chargeProduct"){
3109 >    value = object1->charge*object2->charge;
3110 >  }
3111 >
3112 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3113 >  value = applyFunction(function, value);
3114 >
3115 >  return value;
3116   }
3117 + //!electron-track pair valueLookup
3118 + double
3119 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3120 +  double electronMass = 0.000511;
3121 +  double value = 0.0;
3122 +  TLorentzVector fourVector1(0, 0, 0, 0);
3123 +  TLorentzVector fourVector2(0, 0, 0, 0);
3124 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3125 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3126 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3127 +  else if(variable == "invMass"){
3128 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
3129 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
3130 +
3131 +    value = (fourVector1 + fourVector2).M();
3132 +  }
3133 +  else if(variable == "chargeProduct"){
3134 +    value = object1->charge*object2->charge;
3135 +  }
3136 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3137 +  value = applyFunction(function, value);
3138 +  return value;
3139  
3140 + }
3141  
3142  
3143 + //!muon-track pair valueLookup
3144   double
3145 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
3145 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3146    double pionMass = 0.140;
3147    double muonMass = 0.106;
3148    double value = 0.0;
# Line 2844 | Line 3157 | OSUAnalysis::valueLookup (const BNmuon*
3157  
3158      value = (fourVector1 + fourVector2).M();
3159    }
3160 +  else if(variable == "chargeProduct"){
3161 +    value = object1->charge*object2->charge;
3162 +  }
3163  
3164    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3165    value = applyFunction(function, value);
3166    return value;
3167   }
3168  
3169 <
3169 > //!tau-tau pair valueLookup
3170   double
3171 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
3171 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3172    double value = 0.0;
3173    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3174    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 2863 | Line 3179 | OSUAnalysis::valueLookup (const BNtau* o
3179      value = (fourVector1 + fourVector2).M();
3180    }
3181  
3182 +  else if(variable == "chargeProduct"){
3183 +    value = object1->charge*object2->charge;
3184 +  }
3185 +
3186    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3187    value = applyFunction(function, value);
3188    return value;
3189   }
3190  
3191 <
3191 > //!muon-tau pair valueLookup
3192   double
3193 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
3193 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3194    double value = 0.0;
3195    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3196    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 2881 | Line 3201 | OSUAnalysis::valueLookup (const BNmuon*
3201      value = (fourVector1 + fourVector2).M();
3202    }
3203  
3204 +  else if(variable == "chargeProduct"){
3205 +    value = object1->charge*object2->charge;
3206 +  }
3207 +
3208    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3209    value = applyFunction(function, value);
3210    return value;
3211   }
3212  
3213 + //!tau-track pair valueLookup
3214   double
3215 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
3215 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3216    double value = 0.0;
3217    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3218    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3219 +  else if(variable == "chargeProduct"){
3220 +    value = object1->charge*object2->charge;
3221 +  }
3222  
3223    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3224    value = applyFunction(function, value);
# Line 2898 | Line 3226 | OSUAnalysis::valueLookup (const BNtau* o
3226   }
3227  
3228  
3229 <
3229 > //!track-event pair valueLookup
3230   double
3231 < OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3231 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3232  
3233    double value = 0.0;
3234    double pMag = sqrt(object1->pt * object1->pt +
3235 <                     object1->pz * object1->pz);  
3235 >                     object1->pz * object1->pz);
3236  
3237    if      (variable == "numPV")                      value = object2->numPV;
3238    else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3239    else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3240 <  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3241 <  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3240 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3241 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3242 >
3243 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3244 >
3245 >  value = applyFunction(function, value);
3246 >
3247 >  return value;
3248 >
3249 > }
3250 >
3251 > //!electron-trigobj pair valueLookup
3252 > double
3253 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3254 >
3255 >  double value = 0.0;
3256 >
3257 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3258 >  else if (variable == "match"){
3259 >    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3260 >      stringValue = object2->filter;
3261 >    else
3262 >      stringValue = "none";
3263 >  }
3264 >
3265 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3266 >
3267 >  value = applyFunction(function, value);
3268 >
3269 >  return value;
3270 >
3271 > }
3272 >
3273 > //!muon-trigobj pair valueLookup
3274 > double
3275 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3276 >
3277 >  double value = 0.0;
3278 >
3279 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3280  
3281 <  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3281 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3282  
3283    value = applyFunction(function, value);
3284  
3285    return value;
3286  
3287 < }  
3287 > }
3288  
3289 + //!stop valueLookup
3290   double
3291 < OSUAnalysis::valueLookup (const BNstop* object, string variable, string function){
3291 > OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3292  
3293  
3294    double value = 0.0;
# Line 2952 | Line 3319 | OSUAnalysis::valueLookup (const BNstop*
3319      double minD0=999;
3320      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3321        double vx = object->vx - vertex->x,
3322 <        vy = object->vy - vertex->y,
3323 <        px = object->px,
3324 <        py = object->py,
3325 <        pt = object->pt;
3322 >        vy = object->vy - vertex->y,
3323 >        px = object->px,
3324 >        py = object->py,
3325 >        pt = object->pt;
3326        value = (-vx * py + vy * px) / pt;
3327        if(abs(value) < abs(minD0)) minD0 = value;
3328      }
# Line 2965 | Line 3332 | OSUAnalysis::valueLookup (const BNstop*
3332      double minDz=999;
3333      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3334        double vx = object->vx - vertex->x,
3335 <        vy = object->vy - vertex->y,
3336 <        vz = object->vz - vertex->z,
3337 <        px = object->px,
3338 <        py = object->py,
3339 <        pz = object->pz,
3340 <        pt = object->pt;
3335 >        vy = object->vy - vertex->y,
3336 >        vz = object->vz - vertex->z,
3337 >        px = object->px,
3338 >        py = object->py,
3339 >        pz = object->pz,
3340 >        pt = object->pt;
3341        value = vz - (vx * px + vy * py)/pt * (pz/pt);
3342        if(abs(value) < abs(minDz)) minDz = value;
3343      }
# Line 2978 | Line 3345 | OSUAnalysis::valueLookup (const BNstop*
3345    }
3346    else if(variable == "distToVertex"){
3347      value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3348 <                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3349 <                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3348 >                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3349 >                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3350    }
3351    else if (variable == "minDistToVertex"){
3352      double minDistToVertex=999;
3353      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3354        value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3355 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3356 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3357 <      
3355 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3356 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3357 >
3358        if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3359      }
3360      value = minDistToVertex;
# Line 2996 | Line 3363 | OSUAnalysis::valueLookup (const BNstop*
3363      double minDistToVertex=999;
3364      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3365        value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3366 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3367 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3368 <      
3366 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3367 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3368 >
3369        if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3370      }
3371      double distToChosenVertex = 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));
3372 >                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3373 >                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3374  
3375      value = distToChosenVertex - minDistToVertex;
3376    }
# Line 3014 | Line 3381 | OSUAnalysis::valueLookup (const BNstop*
3381      for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3382        vertex_rank++;
3383        int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3384 <                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3385 <                   (object->vz-vertex->z)*(object->vz-vertex->z));
3386 <      
3384 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3385 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3386 >
3387        if(abs(dist) < abs(minDistToVertex)){
3388 <        value = vertex_rank;
3389 <        minDistToVertex = dist;
3388 >        value = vertex_rank;
3389 >        minDistToVertex = dist;
3390        }
3391      }
3392    }
# Line 3027 | Line 3394 | OSUAnalysis::valueLookup (const BNstop*
3394  
3395  
3396  
3397 <  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3397 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3398  
3399    value = applyFunction(function, value);
3400  
3401    return value;
3402  
3403 < }  
3403 > }
3404  
3405  
3406  
# Line 3085 | Line 3452 | OSUAnalysis::getTrkPtTrue (const BNtrack
3452  
3453   double
3454   OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3455 <  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3456 <  if (!useTrackCaloRhoCorr_) return -99;  
3457 <  // if (!rhokt6CaloJetsHandle_) {
3458 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3459 <  //   return -99;  
3455 >  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
3456 >  if (!useTrackCaloRhoCorr_) return -99;
3457 >  // if (!rhokt6CaloJetsHandle_) {
3458 >  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
3459 >  //   return -99;
3460    // }
3461 <  double radDeltaRCone = 0.5;  
3462 <  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3463 <  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3464 <  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3465 <  return caloTotRhoCorrCalo;  
3466 <
3461 >  double radDeltaRCone = 0.5;
3462 >  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.
3463 >  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
3464 >  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
3465 >  return caloTotRhoCorrCalo;
3466 >
3467   }
3468  
3469  
# Line 3134 | Line 3501 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3501    double deltaRLowest = 999;
3502    int value = 0;
3503    if (DeadEcalVec.size() == 0) WriteDeadEcal();
3504 <  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3504 >  for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3505      double eta = ecal->etaEcal;
3506      double phi = ecal->phiEcal;
3507 <    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
3507 >    double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
3508      if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3509    }
3510    if (deltaRLowest<0.05) {value = 1;}
# Line 3145 | Line 3512 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3512    return value;
3513   }
3514  
3515 < // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3515 > // Returns the smallest DeltaR between the object and any generated true particle in the event.
3516   template <class InputObject>
3517   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3518    double genDeltaRLowest = 999.;
# Line 3165 | Line 3532 | OSUAnalysis::applyFunction(string functi
3532    else if(function == "log") value = log10(value);
3533  
3534    else if(function == "") value = value;
3535 <  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
3535 >  else{cout << "WARNING: invalid function '" << function << "'\n";}
3536  
3537    return value;
3538  
# Line 3174 | Line 3541 | OSUAnalysis::applyFunction(string functi
3541  
3542   template <class InputCollection>
3543   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3544 <
3545 <  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
3546 <    string obj1, obj2;
3544 >
3545 >  if (currentCut.inputCollection.find("pair")!=string::npos)  {
3546 >    string obj1, obj2;
3547      getTwoObjs(currentCut.inputCollection, obj1, obj2);
3548      if (inputType==obj1 ||
3549 <        inputType==obj2) {
3549 >          inputType==obj2) {
3550        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3551 <      // and the inputType is a member of the pair.  
3552 <      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.  
3553 <      // For example, if currentCut.inputCollection==electron-muon pairs,
3554 <      // then the flags should not be set here when inputType==muons or inputType==electrons.  
3555 <      return;
3556 <    }  
3557 <  }    
3551 >      // and the inputType is a member of the pair.
3552 >      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
3553 >      // For example, if currentCut.inputCollection==electron-muon pairs,
3554 >      // then the flags should not be set here when inputType==muons or inputType==electrons.
3555 >      return;
3556 >    }
3557 >  }
3558  
3559    for (uint object = 0; object != inputCollection->size(); object++){
3560  
# Line 3197 | Line 3564 | void OSUAnalysis::setObjectFlags(cut &cu
3564  
3565        vector<bool> subcutDecisions;
3566        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3567 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3568 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3567 >        string stringValue = "";
3568 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3569 >        if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3570 >        else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3571  
3572        }
3573        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 3237 | Line 3606 | void OSUAnalysis::setObjectFlags(cut &cu
3606    bool sameObjects = false;
3607    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3608  
3609 <  // Get the strings for the two objects that make up the pair.  
3610 <  string obj1Type, obj2Type;
3609 >  // Get the strings for the two objects that make up the pair.
3610 >  string obj1Type, obj2Type;
3611    getTwoObjs(inputType, obj1Type, obj2Type);
3612    bool isTwoTypesOfObject = true;
3613 <  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
3613 >  if (obj1Type==obj2Type) isTwoTypesOfObject = false;
3614  
3615 <  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
3616 <  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).  
3617 <  if (currentCut.inputCollection == inputType) {    
3615 >  // Initialize the flags for individual objects to all be false, if the cut is on the pair.
3616 >  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
3617 >  if (currentCut.inputCollection == inputType) {
3618      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3619 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3619 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3620        cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3621      }
3622 <    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.  
3622 >    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
3623        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3624 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3625 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3624 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3625 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3626        }
3627      }
3628    }
3629 <  
3629 >
3630    int counter = 0;
3631  
3632    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
# Line 3272 | Line 3641 | void OSUAnalysis::setObjectFlags(cut &cu
3641  
3642          vector<bool> subcutDecisions;
3643          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3644 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3645 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3644 >          string stringValue = "";
3645 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3646 >          if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3647 >          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3648          }
3649  
3650          if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 3288 | Line 3659 | void OSUAnalysis::setObjectFlags(cut &cu
3659            decision = tempDecision;
3660          }
3661        }
3662 <      // if (decision) isPassObj1.at(object1) = true;
3663 <      // if (decision) isPassObj2.at(object2) = true;
3664 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3665 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3666 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3667 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3668 <      }  
3662 >      // if (decision) isPassObj1.at(object1) = true;
3663 >      // if (decision) isPassObj2.at(object2) = true;
3664 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3665 >      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3666 >        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
3667 >        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
3668 >      }
3669  
3670        //set flags for objects that pass each cut AND all the previous cuts
3671        bool previousCumulativeFlag = true;
# Line 3309 | Line 3680 | void OSUAnalysis::setObjectFlags(cut &cu
3680        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3681        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3682        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3683 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3684 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);  
3685 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);  
3683 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3684 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
3685 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
3686        }
3687        counter++;
3688  
3689 <    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3690 <  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3689 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
3690 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
3691  
3692   }
3693  
3694  
3695   bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3696 <  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3697 <  // all cuts up to currentCutIndex  
3698 <  bool previousCumulativeFlag = true;  
3699 <  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {  
3696 >  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3697 >  // all cuts up to currentCutIndex
3698 >  bool previousCumulativeFlag = true;
3699 >  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
3700      if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3701 <    else {  
3702 <      previousCumulativeFlag = false; break;  
3701 >    else {
3702 >      previousCumulativeFlag = false; break;
3703      }
3704    }
3705 <  return previousCumulativeFlag;  
3706 < }  
3705 >  return previousCumulativeFlag;
3706 > }
3707  
3708  
3709   template <class InputCollection>
# Line 3345 | Line 3716 | void OSUAnalysis::fill1DHistogram(TH1* h
3716      string currentString = parameters.inputVariables.at(0);
3717      string inputVariable = "";
3718      string function = "";
3719 <    if(currentString.find("(")==std::string::npos){
3719 >    if(currentString.find("(")==string::npos){
3720        inputVariable = currentString;// variable to cut on
3721      }
3722      else{
# Line 3354 | Line 3725 | void OSUAnalysis::fill1DHistogram(TH1* h
3725        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3726      }
3727  
3728 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3728 >    string stringValue = "";
3729 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3730      histo->Fill(value,scaleFactor);
3359
3731      if (printEventInfo_) {
3732 <      // Write information about event to screen, for testing purposes.  
3733 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3732 >      // Write information about event to screen, for testing purposes.
3733 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
3734      }
3735 <    
3735 >
3736    }
3737   }
3738  
# Line 3386 | Line 3757 | void OSUAnalysis::fill1DHistogram(TH1* h
3757        string currentString = parameters.inputVariables.at(0);
3758        string inputVariable = "";
3759        string function = "";
3760 <      if(currentString.find("(")==std::string::npos){
3760 >      if(currentString.find("(")==string::npos){
3761          inputVariable = currentString;// variable to cut on
3762        }
3763        else{
# Line 3395 | Line 3766 | void OSUAnalysis::fill1DHistogram(TH1* h
3766          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3767        }
3768  
3769 <      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3769 >      string stringValue = "";
3770 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3771        histo->Fill(value,scaleFactor);
3772  
3773      }
# Line 3411 | Line 3783 | void OSUAnalysis::fill2DHistogram(TH2* h
3783  
3784      if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3785  
3786 +    string stringValue = "";
3787      string currentString = parameters.inputVariables.at(0);
3788      string inputVariable = "";
3789      string function = "";
3790 <    if(currentString.find("(")==std::string::npos){
3790 >    if(currentString.find("(")==string::npos){
3791        inputVariable = currentString;// variable to cut on
3792      }
3793      else{
# Line 3422 | Line 3795 | void OSUAnalysis::fill2DHistogram(TH2* h
3795        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3796        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3797      }
3798 <    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3798 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3799  
3800      currentString = parameters.inputVariables.at(1);
3801      inputVariable = "";
3802      function = "";
3803 <    if(currentString.find("(")==std::string::npos){
3803 >    if(currentString.find("(")==string::npos){
3804        inputVariable = currentString;// variable to cut on
3805      }
3806      else{
# Line 3436 | Line 3809 | void OSUAnalysis::fill2DHistogram(TH2* h
3809        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3810      }
3811  
3812 <    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3812 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3813  
3814      histo->Fill(valueX,valueY,scaleFactor);
3815  
# Line 3463 | Line 3836 | void OSUAnalysis::fill2DHistogram(TH2* h
3836        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3837        if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3838  
3839 +      string stringValue = "";
3840        string currentString = parameters.inputVariables.at(0);
3841        string inputVariable = "";
3842        string function = "";
3843 <      if(currentString.find("(")==std::string::npos){
3843 >      if(currentString.find("(")==string::npos){
3844          inputVariable = currentString;// variable to cut on
3845        }
3846        else{
# Line 3474 | Line 3848 | void OSUAnalysis::fill2DHistogram(TH2* h
3848          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3849          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3850        }
3851 <      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3851 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3852  
3853        currentString = parameters.inputVariables.at(1);
3854        inputVariable = "";
3855        function = "";
3856 <      if(currentString.find("(")==std::string::npos){
3856 >      if(currentString.find("(")==string::npos){
3857          inputVariable = currentString;// variable to cut on
3858        }
3859        else{
# Line 3487 | Line 3861 | void OSUAnalysis::fill2DHistogram(TH2* h
3861          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3862          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3863        }
3864 <      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3864 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3865  
3866  
3867        histo->Fill(valueX,valueY,scaleFactor);
# Line 3508 | Line 3882 | int OSUAnalysis::getGenMatchedParticleIn
3882  
3883      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3884      if(currentDeltaR > 0.05) continue;
3885 <    //     cout << std::setprecision(3) << std::setw(20)
3885 >    //     cout << setprecision(3) << setw(20)
3886      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3887 <    //          << std::setw(20)
3887 >    //          << setw(20)
3888      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3889 <    //          << std::setw(20)
3889 >    //          << setw(20)
3890      //          << "\tdeltaR = " << currentDeltaR
3891 <    //          << std::setprecision(1)
3892 <    //          << std::setw(20)
3891 >    //          << setprecision(1)
3892 >    //          << setw(20)
3893      //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3894 <    //          << std::setw(20)
3894 >    //          << setw(20)
3895      //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3896 <    //          << std::setw(20)
3896 >    //          << setw(20)
3897      //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3898      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3899        bestMatchIndex = mcparticle - mcparticles->begin();
# Line 3582 | Line 3956 | int OSUAnalysis::findTauMotherIndex(cons
3956   // 20        strange baryon
3957   // 21        charm baryon
3958   // 22        bottom baryon
3959 < // 23        other
3959 > // 23        QCD string
3960 > // 24        other
3961  
3962   int OSUAnalysis::getPdgIdBinValue(int pdgId){
3963  
# Line 3606 | Line 3981 | int OSUAnalysis::getPdgIdBinValue(int pd
3981    else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
3982    else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
3983    else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
3984 +  else if(absPdgId == 92  ) binValue = 23;
3985  
3986 <  else binValue = 23;
3986 >  else binValue = 24;
3987  
3988    return binValue;
3989  
# Line 3617 | Line 3993 | const BNprimaryvertex *
3993   OSUAnalysis::chosenVertex ()
3994   {
3995    const BNprimaryvertex *chosenVertex = 0;
3996 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3997 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3998 <      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3996 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
3997 >    vector<bool> vertexFlags;
3998 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
3999 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
4000 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
4001 >        break;
4002 >      }
4003 >    }
4004      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4005        if(!vertexFlags.at(vertexIndex)) continue;
4006        chosenVertex = & primaryvertexs->at(vertexIndex);
4007        break;
4008      }
4009    }
4010 <  else {
4011 <    chosenVertex = &primaryvertexs->at(0);
3631 <  }
4010 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4011 >    chosenVertex = & primaryvertexs->at (0);
4012  
4013    return chosenVertex;
4014   }
# Line 3637 | Line 4017 | const BNmet *
4017   OSUAnalysis::chosenMET ()
4018   {
4019    const BNmet *chosenMET = 0;
4020 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
4021 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
4022 <      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
4020 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4021 >    vector<bool> metFlags;
4022 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4023 >      if (cumulativeFlags.at("mets").at(i).size()){
4024 >        metFlags = cumulativeFlags.at("mets").at(i);
4025 >        break;
4026 >      }
4027 >    }
4028      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4029        if(!metFlags.at(metIndex)) continue;
4030        chosenMET = & mets->at(metIndex);
4031        break;
4032      }
4033    }
4034 <  else {
4035 <    chosenMET = &mets->at(0);
3651 <  }
4034 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4035 >    chosenMET = & mets->at (0);
4036  
4037    return chosenMET;
4038   }
# Line 3657 | Line 4041 | const BNelectron *
4041   OSUAnalysis::chosenElectron ()
4042   {
4043    const BNelectron *chosenElectron = 0;
4044 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4045 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
4046 <      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
4044 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4045 >    vector<bool> electronFlags;
4046 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4047 >      if (cumulativeFlags.at("electrons").at(i).size()){
4048 >        electronFlags = cumulativeFlags.at("electrons").at(i);
4049 >        break;
4050 >      }
4051 >    }
4052      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4053        if(!electronFlags.at(electronIndex)) continue;
4054        chosenElectron = & electrons->at(electronIndex);
4055        break;
4056      }
4057    }
4058 <  else {
4059 <    chosenElectron = &electrons->at(0);
3671 <  }
4058 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4059 >    chosenElectron = & electrons->at (0);
4060  
4061    return chosenElectron;
4062   }
# Line 3677 | Line 4065 | const BNmuon *
4065   OSUAnalysis::chosenMuon ()
4066   {
4067    const BNmuon *chosenMuon = 0;
4068 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4069 <    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
4070 <      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
4068 >  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4069 >    vector<bool> muonFlags;
4070 >    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4071 >      if (cumulativeFlags.at("muons").at(i).size()){
4072 >        muonFlags = cumulativeFlags.at("muons").at(i);
4073 >        break;
4074 >      }
4075 >    }
4076      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4077        if(!muonFlags.at(muonIndex)) continue;
4078        chosenMuon = & muons->at(muonIndex);
4079        break;
4080      }
4081    }
4082 <  else {
4083 <    chosenMuon = &muons->at(0);
3691 <  }
4082 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4083 >    chosenMuon = & muons->at (0);
4084  
4085    return chosenMuon;
4086   }
4087  
3696
4088   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines