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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines