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.43 by wulsin, Thu Mar 28 10:17:32 2013 UTC vs.
Revision 1.65 by biliu, Fri May 24 18:49:24 2013 UTC

# Line 11 | Line 11 | OSUAnalysis::OSUAnalysis (const edm::Par
11    tracks_ (cfg.getParameter<edm::InputTag> ("tracks")),
12    genjets_ (cfg.getParameter<edm::InputTag> ("genjets")),
13    mcparticles_ (cfg.getParameter<edm::InputTag> ("mcparticles")),
14 +  stops_ (cfg.getParameter<edm::InputTag> ("stops")),
15    primaryvertexs_ (cfg.getParameter<edm::InputTag> ("primaryvertexs")),
16    bxlumis_ (cfg.getParameter<edm::InputTag> ("bxlumis")),
17    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
18    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
19    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
20 <  puFile_ (cfg.getParameter<std::string> ("puFile")),
21 <  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
22 <  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")),
34 <  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr"))
35 <
33 >  applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
34 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35 >  useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
36 >  stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
37 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
38   {
39  
40    TH1::SetDefaultSumw2 ();
# Line 38 | 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 +  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_);
49  std::vector<TFileDirectory> directories;
57  
58    //always get vertex collection so we can assign the primary vertex in the event
59    objectsToGet.push_back("primaryvertexs");
60  
61 <  //always make the plot of number of primary verticex (to check pile-up reweighting)
61 >  //always make the plot of number of primary vertices (to check pile-up reweighting)
62    objectsToPlot.push_back("primaryvertexs");
63  
64    //always get the MC particles to do GEN-matching
# Line 65 | 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.find("pairs")==std::string::npos){ //just a single object
79 <      objectsToGet.push_back(tempInputCollection);
78 >    if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
79 >    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
80 >    if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
81 >    if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
82 >    if(tempInputCollection.find("pairs")==string::npos){ //just a single object
83 >      if(tempInputCollection.find("secondary")!=string::npos){//secondary object
84 >        int spaceIndex = tempInputCollection.find(" ");
85 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
86 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
87 >      }
88 >      else{
89 >        objectsToGet.push_back(tempInputCollection);
90 >      }
91        objectsToPlot.push_back(tempInputCollection);
92        objectsToCut.push_back(tempInputCollection);
93      }
94 <    else{//pair of objects, need to add them both to the things to objectsToGet
95 <      int dashIndex = tempInputCollection.find("-");
96 <      int spaceIndex = tempInputCollection.find(" ");
97 <      int secondWordLength = spaceIndex - dashIndex;
98 <      objectsToGet.push_back(tempInputCollection);
79 <      objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
80 <      objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
81 <      objectsToPlot.push_back(tempInputCollection);
82 <      objectsToPlot.push_back(tempInputCollection.substr(0,dashIndex)+"s");
83 <      objectsToPlot.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
94 >    else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
95 >      string obj1;
96 >      string obj2;
97 >      getTwoObjs(tempInputCollection, obj1, obj2);
98 >      string obj2ToGet = getObjToGet(obj2);
99        objectsToCut.push_back(tempInputCollection);
100 <      objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
101 <      objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
100 >      objectsToCut.push_back(obj1);
101 >      objectsToCut.push_back(obj2);
102 >      objectsToPlot.push_back(tempInputCollection);
103 >      objectsToPlot.push_back(obj1);
104 >      objectsToPlot.push_back(obj2);
105 >      objectsToGet.push_back(tempInputCollection);
106 >      objectsToGet.push_back(obj1);
107 >      objectsToGet.push_back(obj2ToGet);
108  
109      }
110  
# Line 91 | 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 112 | 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 != "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 154 | 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 187 | Line 225 | OSUAnalysis::OSUAnalysis (const edm::Par
225  
226      //create cutFlow for this channel
227      cutFlows_.push_back (new CutFlow (fs_, channelName));
228 +    vector<TFileDirectory> directories; //vector of directories in the output file.
229 +    vector<string> subSubDirNames;//subdirectories in each channel.
230 +    //get list of cuts for this channel
231 +    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
232 +    
233  
234 <    //book a directory in the output file with the name of the channel
235 <    TFileDirectory subDir = fs_->mkdir( channelName );
236 <    directories.push_back(subDir);
234 >    //loop over and parse all cuts
235 >    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
236 >      cut tempCut;
237 >      //store input collection for cut
238 >      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
239 >      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
240 >      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
241 >      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
242 >      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
243 >      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
244 >      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
245 >      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
246 >      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
247 >      tempCut.inputCollection = tempInputCollection;
248 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
249 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
250 >          int spaceIndex = tempInputCollection.find(" ");
251 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
252 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
253 >        }
254 >        else{
255 >          objectsToGet.push_back(tempInputCollection);
256 >        }
257 >        objectsToCut.push_back(tempInputCollection);
258 >      }
259 >      else{//pair of objects, need to add them both to objectsToGet
260 >        string obj1;
261 >        string obj2;
262 >        getTwoObjs(tempInputCollection, obj1, obj2);
263 >        string obj2ToGet = getObjToGet(obj2);
264 >        objectsToCut.push_back(tempInputCollection);
265 >        objectsToCut.push_back(obj1);
266 >        objectsToCut.push_back(obj2);
267 >        objectsToGet.push_back(tempInputCollection);
268 >        objectsToGet.push_back(obj1);
269 >        objectsToGet.push_back(obj2ToGet);
270  
271 <    std::map<std::string, TH1D*> oneDhistoMap;
196 <    oneDHists_.push_back(oneDhistoMap);
197 <    std::map<std::string, TH2D*> twoDhistoMap;
198 <    twoDHists_.push_back(twoDhistoMap);
271 >      }
272  
273  
274  
275 +      //split cut string into parts and store them
276 +      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
277 +      vector<string> cutStringVector = splitString(cutString);
278 +      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
279 +        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
280 +        exit(0);
281 +      }
282 +      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
283 +      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
284 +        int indexOffset = 4 * subcutIndex;
285 +        string currentVariableString = cutStringVector.at(indexOffset);
286 +        if(currentVariableString.find("(")==string::npos){
287 +          tempCut.functions.push_back("");//no function was specified
288 +          tempCut.variables.push_back(currentVariableString);// variable to cut on
289 +        }
290 +        else{
291 +          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
292 +          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
293 +          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
294 +        }
295 +        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
296 +        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
297 +        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
298 +        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
299 +      }
300 +
301 +      //get number of objects required to pass cut for event to pass
302 +      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
303 +      vector<string> numberRequiredVector = splitString(numberRequiredString);
304 +      if(numberRequiredVector.size()!=2){
305 +        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
306 +        exit(0);
307 +      }
308 +
309 +      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
310 +      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
311 +      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
312 +      
313 +      //Set up vectors to store the directories and subDIrectories for each channel.
314 +      string subSubDirName;      
315 +      string tempCutName;
316 +      if(cuts_.at(currentCut).exists("alias")){
317 +        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
318 +        subSubDirName = "After " + cuts_.at(currentCut).getParameter<string> ("alias") + " Cut Applied";
319 +      }
320 +      else{
321 +        //construct string for cutflow table
322 +        bool plural = numberRequiredInt != 1;
323 +        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
324 +        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
325 +        tempCutName = cutName;
326 +        subSubDirName = "After " + numberRequiredString + " " + collectionString + " with " + cutString + " Cut Applied";
327 +      }
328 +      
329 +      subSubDirNames.push_back(subSubDirName);
330 +      tempCut.name = tempCutName;
331 +
332 +      tempChannel.cuts.push_back(tempCut);
333 +      
334 +
335 +    }//end loop over cuts
336 +    
337 +    vector<map<string, TH1D*>> oneDHistsTmp;
338 +    vector<map<string, TH2D*>> twoDHistsTmp;
339 +    //book a directory in the output file with the name of the channel
340 +    TFileDirectory subDir = fs_->mkdir( channelName );
341 +    //loop over the cuts to set up subdirectory for each cut if GetPlotsAfterEachCut_ is true.
342 +    if(GetPlotsAfterEachCut_){
343 +       for( uint currentDir=0; currentDir != subSubDirNames.size(); currentDir++){  
344 +            TFileDirectory subSubDir = subDir.mkdir( subSubDirNames[currentDir] );
345 +            directories.push_back(subSubDir);
346 +            map<string, TH1D*> oneDhistoMap;
347 +            oneDHistsTmp.push_back(oneDhistoMap);
348 +            map<string, TH2D*> twoDhistoMap;
349 +            twoDHistsTmp.push_back(twoDhistoMap);
350 +      }
351 +      oneDHists_.push_back(oneDHistsTmp);    
352 +      twoDHists_.push_back(twoDHistsTmp);
353 +    }
354 +   //only set up directories with names of the channels if GetPlotsAfterEachCut_ is false.
355 +   else{
356 +      map<string, TH1D*> oneDhistoMap;
357 +      oneDHistsTmp.push_back(oneDhistoMap);
358 +      map<string, TH2D*> twoDhistoMap;
359 +      twoDHistsTmp.push_back(twoDhistoMap);
360 +      oneDHists_.push_back(oneDHistsTmp);
361 +      twoDHists_.push_back(twoDHistsTmp);
362 +      directories.push_back(subDir);
363 +   }
364      //book all histograms included in the configuration
365 +    for(uint currentDir = 0; currentDir != directories.size(); currentDir++){//loop over all the directories.
366      for(uint currentHistogramIndex = 0; currentHistogramIndex != histograms.size(); currentHistogramIndex++){
367        histogram currentHistogram = histograms.at(currentHistogramIndex);
368        int numBinsElements = currentHistogram.bins.size();
369        int numInputVariables = currentHistogram.inputVariables.size();
370 +      int numBinEdgesX = currentHistogram.variableBinsX.size();
371 +      int numBinEdgesY = currentHistogram.variableBinsY.size();
372  
373 <      if(numBinsElements != 3 && numBinsElements !=6) {
374 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
373 >      if(numBinsElements == 1){
374 >        if(numBinEdgesX > 1){
375 >          if(numBinEdgesY > 1)
376 >            numBinsElements = 6;
377 >          else
378 >            numBinsElements = 3;
379 >        }
380 >      }
381 >      if(numBinsElements != 3 && numBinsElements !=6){
382 >        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
383          exit(0);
384        }
385        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
386 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
386 >        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
387          exit(0);
388        }
389        else if(numBinsElements == 3){
390 <        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));
390 >        if (currentHistogram.bins.size () == 3)
391 >          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));
392 >        else
393 >          {
394 >            oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name] = directories.at(currentDir).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
395 >          }
396        }
397        else if(numBinsElements == 6){
398 <        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));
399 <
398 >        if (currentHistogram.bins.size () == 6)
399 >          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));
400 >        else
401 >          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 ());
402        }
403  
404  
405 <      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
405 >      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
406  
407        // bin      particle type
408        // ---      -------------
# Line 249 | Line 429 | OSUAnalysis::OSUAnalysis (const edm::Par
429        // 20        strange baryon
430        // 21        charm baryon
431        // 22        bottom baryon
432 <      // 23        other
432 >      // 23        QCD string
433 >      // 24        other
434  
435        vector<TString> labelArray;
436        labelArray.push_back("unmatched");
# Line 275 | Line 456 | OSUAnalysis::OSUAnalysis (const edm::Par
456        labelArray.push_back("strange baryon");
457        labelArray.push_back("charm baryon");
458        labelArray.push_back("bottom baryon");
459 +      labelArray.push_back("QCD string");
460        labelArray.push_back("other");
461  
462        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
463 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
464 <          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
465 <        }
466 <        else {
467 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
468 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
469 <        }
463 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
464 >          oneDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
465 >        }
466 >        else {
467 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
468 >          twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
469 >        }
470        }
471 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
472 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
473 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
471 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
472 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetXaxis()->CenterTitle();
473 >        twoDHists_.at(currentChannel).at(currentDir)[currentHistogram.name]->GetYaxis()->CenterTitle();
474        }
475  
476      }
477  
478 <    // Book a histogram for the number of each object type to be plotted.  
479 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
478 >    // Book a histogram for the number of each object type to be plotted.
479 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
480      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
481        string currentObject = objectsToPlot.at(currentObjectIndex);
482        int maxNum = 10;
483        if(currentObject == "mcparticles") maxNum = 50;
484        else if(currentObject == "primaryvertexs") maxNum = 50;
485 <      else if(currentObject == "muon-muon pairs") currentObject = "dimuonPairs";
486 <      else if(currentObject == "electron-electron pairs") currentObject = "dielectronPairs";
487 <      else if(currentObject == "electron-muon pairs")     currentObject = "electronMuonPairs";
488 <      else if(currentObject == "track-event pairs")       currentObject = "trackEventPairs";
489 <      else if(currentObject == "electron-track pairs")    currentObject = "electronTrackPairs";  
490 <      else if(currentObject == "muon-track pairs")        currentObject = "muonTrackPairs";      
491 <      else if(currentObject == "muon-tau pairs")          currentObject = "muonTauPairs";        
492 <      else if(currentObject == "tau-tau pairs")           currentObject = "ditauPairs";
493 <      currentObject.at(0) = toupper(currentObject.at(0));  
485 >
486 >      if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
487 >      else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
488 >      else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
489 >      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
490 >      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
491 >      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
492 >      else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
493 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
494 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
495 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
496 >      else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
497 >      else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
498 >      else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
499 >      else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
500 >      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
501 >      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
502 >      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
503 >      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
504 >
505 >      currentObject.at(0) = toupper(currentObject.at(0));
506        string histoName = "num" + currentObject;
507  
508        if(histoName == "numPrimaryvertexs"){
509          string newHistoName = histoName + "BeforePileupCorrection";
510 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+" Before Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
510 >        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);
511          newHistoName = histoName + "AfterPileupCorrection";
512 <        oneDHists_.at(currentChannel)[newHistoName] = directories.at(currentChannel).make<TH1D> (TString(newHistoName),channelLabel+" channel: Number of Selected "+currentObject+ " After Pileup Correction; # "+currentObject, maxNum, 0, maxNum);
512 >        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);
513        }
514        else
515 <        oneDHists_.at(currentChannel)[histoName] = directories.at(currentChannel).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
515 >        oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
516      }
517 <
324 <
325 <
326 <
327 <    //get list of cuts for this channel
328 <    vector<edm::ParameterSet> cuts_  (channels_.at(currentChannel).getParameter<vector<edm::ParameterSet> >("cuts"));
329 <
330 <    //loop over and parse all cuts
331 <    for(uint currentCut = 0; currentCut != cuts_.size(); currentCut++){
332 <      cut tempCut;
333 <      //store input collection for cut
334 <      string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
335 <      tempCut.inputCollection = tempInputCollection;
336 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
337 <        objectsToGet.push_back(tempInputCollection);
338 <        objectsToCut.push_back(tempInputCollection);
339 <      }
340 <      else{//pair of objects, need to add them both to the things to objectsToGet
341 <        int dashIndex = tempInputCollection.find("-");
342 <        int spaceIndex = tempInputCollection.find(" ");
343 <        int secondWordLength = spaceIndex - dashIndex;
344 <        objectsToGet.push_back(tempInputCollection);
345 <        objectsToGet.push_back(tempInputCollection.substr(0,dashIndex)+"s");
346 <        objectsToGet.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
347 <        objectsToCut.push_back(tempInputCollection);
348 <        objectsToCut.push_back(tempInputCollection.substr(0,dashIndex)+"s");
349 <        objectsToCut.push_back(tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s");
350 <
351 <      }
352 <
353 <
354 <
355 <      //split cut string into parts and store them
356 <      string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
357 <      std::vector<string> cutStringVector = splitString(cutString);
358 <      if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
359 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
360 <        exit(0);
361 <      }
362 <      tempCut.numSubcuts = (cutStringVector.size()+1)/4;
363 <      for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
364 <        int indexOffset = 4 * subcutIndex;
365 <        string currentVariableString = cutStringVector.at(indexOffset);
366 <        if(currentVariableString.find("(")==std::string::npos){
367 <          tempCut.functions.push_back("");//no function was specified
368 <          tempCut.variables.push_back(currentVariableString);// variable to cut on
369 <        }
370 <        else{
371 <          tempCut.functions.push_back(currentVariableString.substr(0,currentVariableString.find("(")));//function comes before the "("
372 <          string tempVariable = currentVariableString.substr(currentVariableString.find("(")+1);//get rest of string
373 <          tempCut.variables.push_back(tempVariable.substr(0,tempVariable.size()-1));//remove trailing ")"
374 <        }
375 <        tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
376 <        tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
377 <        if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
378 <      }
379 <
380 <      //get number of objects required to pass cut for event to pass
381 <      string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
382 <      std::vector<string> numberRequiredVector = splitString(numberRequiredString);
383 <      if(numberRequiredVector.size()!=2){
384 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
385 <        exit(0);
386 <      }
387 <
388 <      int numberRequiredInt = atoi(numberRequiredVector.at(1).c_str());
389 <      tempCut.numberRequired = numberRequiredInt;// number of objects required to pass the cut
390 <      tempCut.eventComparativeOperator = numberRequiredVector.at(0);// comparison to make
391 <
392 <
393 <      string tempCutName;
394 <      if(cuts_.at(currentCut).exists("alias")){
395 <        tempCutName = cuts_.at(currentCut).getParameter<string> ("alias");
396 <      }
397 <      else{
398 <        //construct string for cutflow table
399 <        bool plural = numberRequiredInt != 1;
400 <        string collectionString = plural ? tempInputCollection : tempInputCollection.substr(0, tempInputCollection.size()-1);
401 <        string cutName =  numberRequiredString + " " + collectionString + " with " + cutString;
402 <        tempCutName = cutName;
403 <      }
404 <      tempCut.name = tempCutName;
405 <
406 <
407 <      tempChannel.cuts.push_back(tempCut);
408 <
409 <
410 <
411 <    }//end loop over cuts
412 <
517 >   }//end of loop over directories
518      channels.push_back(tempChannel);
519      tempChannel.cuts.clear();
415
520    }//end loop over channels
521  
522  
# Line 441 | Line 545 | OSUAnalysis::analyze (const edm::Event &
545  
546    // Retrieve necessary collections from the event.
547  
548 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
548 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
549      event.getByLabel (triggers_, triggers);
550  
551 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
551 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
552 >    event.getByLabel (trigobjs_, trigobjs);
553 >
554 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
555      event.getByLabel (jets_, jets);
556  
557 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
557 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
558      event.getByLabel (muons_, muons);
559  
560 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
560 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
561      event.getByLabel (electrons_, electrons);
562  
563 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
563 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
564      event.getByLabel (events_, events);
565  
566 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
566 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
567      event.getByLabel (taus_, taus);
568  
569 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
569 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
570      event.getByLabel (mets_, mets);
571  
572 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
572 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
573      event.getByLabel (tracks_, tracks);
574  
575 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
575 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
576      event.getByLabel (genjets_, genjets);
577  
578 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
578 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
579      event.getByLabel (mcparticles_, mcparticles);
580  
581 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
581 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
582      event.getByLabel (primaryvertexs_, primaryvertexs);
583  
584 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
584 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
585      event.getByLabel (bxlumis_, bxlumis);
586  
587 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
587 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
588      event.getByLabel (photons_, photons);
589  
590 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
590 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
591      event.getByLabel (superclusters_, superclusters);
592  
593 <  if (useTrackCaloRhoCorr_) {  
594 <    // Used only for pile-up correction of by-hand calculation of isolation energy.  
595 <    // This rho collection is not available in all BEANs.  
593 >  if (datasetType_ == "signalMC"){
594 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
595 >      event.getByLabel (stops_, stops);
596 >  }
597 >
598 >  if (useTrackCaloRhoCorr_) {
599 >    // Used only for pile-up correction of by-hand calculation of isolation energy.
600 >    // This rho collection is not available in all BEANs.
601      // For description of rho values for different jet reconstruction algorithms, see
602 <    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
603 <    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
602 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
603 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
604    }
605  
606 +  double masterScaleFactor = 1.0;
607  
608    //get pile-up event weight
609 <  double scaleFactor = 1.00;
497 <  if(doPileupReweighting_ && datasetType_ != "data")
498 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
609 >  if(doPileupReweighting_ && datasetType_ != "data") masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
610  
611 +  stopCTauScaleFactor_ = 1.0;
612 +  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
613 +    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
614 +  masterScaleFactor *= stopCTauScaleFactor_;
615  
616    //loop over all channels
617  
# Line 514 | Line 629 | OSUAnalysis::analyze (const edm::Event &
629      }
630  
631      //loop over all cuts
517
518
519
632      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
633        cut currentCut = currentChannel.cuts.at(currentCutIndex);
522
634        for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
635          string currentObject = objectsToCut.at(currentObjectIndex);
636  
# Line 536 | Line 647 | OSUAnalysis::analyze (const edm::Event &
647  
648          if(currentObject == "jets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
649          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
650 +
651 +        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
652 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
653          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
654          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
655          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 547 | Line 661 | OSUAnalysis::analyze (const edm::Event &
661          else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
662          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
663          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
664 +        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
665 +
666  
667  
668          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
669                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
670                                                                     cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
671                                                                     "muon-muon pairs");
672 +
673 +        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
674 +                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
675 +                                                                   cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
676 +                                                                   "muon-secondary muon pairs");
677 +
678 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
679 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
680 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
681 +                                                                   "electron-secondary electron pairs");
682 +
683          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
684                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
685                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 561 | Line 688 | OSUAnalysis::analyze (const edm::Event &
688                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
689                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
690                                                                         "electron-muon pairs");
691 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
692 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
693 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
694 <                                                                     "track-event pairs");
695 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
696 <                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
697 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
698 <                                                                        "electron-track pairs");
699 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
700 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
701 <                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
702 <                                                                    "muon-track pairs");
703 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
704 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
705 <                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
706 <                                                                  "muon-tau pairs");
707 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),taus.product(),
708 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
709 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
710 <                                                                 "tau-tau pairs");
711 <        
712 <        
691 >        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
692 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
693 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
694 >                                                                           "jet-jet pairs");
695 >        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
696 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
697 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
698 >                                                                       "electron-jet pairs");
699 >        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
700 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
701 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
702 >                                                                       "muon-jet pairs");
703 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
704 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
705 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
706 >                                                                     "track-event pairs");
707 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
708 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
709 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
710 >                                                                        "electron-track pairs");
711 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
712 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
713 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
714 >                                                                    "muon-track pairs");
715 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
716 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
717 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
718 >                                                                  "muon-tau pairs");
719 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
720 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
721 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
722 >                                                                 "tau-tau pairs");
723 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
724 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
725 >                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
726 >                                                                 "tau-track pairs");
727 >        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
728 >                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
729 >                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
730 >                                                                          "electron-trigobj pairs");
731 >        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
732 >                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
733 >                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
734 >                                                                      "muon-trigobj pairs");
735 >
736 >        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
737        }
738  
739  
740  
741      }//end loop over all cuts
591
592
742      //use cumulative flags to apply cuts at event level
743  
744      bool eventPassedAllCuts = true;
745 <
745 >    //a vector to store cumulative cut descisions after each cut.
746 >    vector<bool> eventPassedPreviousCuts;
747      //apply trigger (true if none were specified)
748      eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
749  
750  
601
751      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
752  
753        //loop over all objects and count how many passed the cumulative selection up to this point
# Line 606 | Line 755 | OSUAnalysis::analyze (const edm::Event &
755        int numberPassing = 0;
756  
757        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
758 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
758 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
759        }
611
760        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
761        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
614
762        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
763 +      eventPassedPreviousCuts.push_back(eventPassedAllCuts);
764 +    }
765 +    double scaleFactor = masterScaleFactor;
766  
767 +    muonScaleFactor_ = electronScaleFactor_ = 1.0;
768 +    if(applyLeptonSF_ && datasetType_ != "data"){
769 +      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
770 +        vector<bool> muonFlags;
771 +        for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
772 +          if (cumulativeFlags.at("muons").at(i).size()){
773 +            muonFlags = cumulativeFlags.at("muons").at(i);
774 +            break;
775 +          }
776 +        }
777 +        for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
778 +          if(!muonFlags.at(muonIndex)) continue;
779 +          muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
780 +        }
781 +      }
782 +      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
783 +        vector<bool> electronFlags;
784 +        for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
785 +          if (cumulativeFlags.at("electrons").at(i).size()){
786 +            electronFlags = cumulativeFlags.at("electrons").at(i);
787 +            break;
788 +          }
789 +        }
790 +        for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
791 +          if(!electronFlags.at(electronIndex)) continue;
792 +          electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
793 +        }
794 +      }
795      }
796 +    scaleFactor *= muonScaleFactor_;
797 +    scaleFactor *= electronScaleFactor_;
798  
799      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
800 <
621 <
622 <
623 <    if(!eventPassedAllCuts)continue;
800 >    if(!(GetPlotsAfterEachCut_ || eventPassedAllCuts)) continue;
801  
802      if (printEventInfo_) {
803 <      // Write information about event to screen, for testing purposes.  
804 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
805 <           << ": run="  << events->at(0).run
806 <           << "  lumi=" << events->at(0).lumi
807 <           << "  event=" << events->at(0).evt
808 <           << endl;  
803 >      // Write information about event to screen, for testing purposes.
804 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
805 >           << ": run="  << events->at(0).run
806 >           << "  lumi=" << events->at(0).lumi
807 >           << "  event=" << events->at(0).evt
808 >           << endl;
809      }
633
634
635    //     if(datasetType_ != "data") {
636    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
637    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
638    //     }
639
810      //filling histograms
811 <    for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
812 <      histogram currentHistogram = histograms.at(histogramIndex);
811 >    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
812 >        uint currentDir;
813 >        if(!GetPlotsAfterEachCut_){ currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size();}//if GetPlotsAfterEachCut_ is true, set currentDir point to the lat cut.
814 >        else{
815 >          currentDir = currentCut;
816 >        }
817 >        if(eventPassedPreviousCuts.at(currentDir)){
818 >        for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
819 >          histogram currentHistogram = histograms.at(histogramIndex);
820  
821        if(currentHistogram.inputVariables.size() == 1){
822          TH1D* histo;
823 <        histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
824 <
825 <
826 <
827 <        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
651 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
823 >        histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
824 >        if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
825 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
826 >        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
827 >        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
828          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
829 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
830 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
831 <        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
829 >                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
830 >                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
831 >        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
832 >                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
833 >                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
834 >        else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
835          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
836 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
837 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
836 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
837 >                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
838 >        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
839 >                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
840 >                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
841 >        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
842 >                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
843 >                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
844          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
845 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
846 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
847 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
848 <                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
849 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
850 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
851 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
852 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
853 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
854 <                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
855 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
856 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
857 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
858 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
859 <        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
860 <        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
861 <        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
862 <        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
863 <        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
864 <        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
865 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
866 <        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
867 <        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
868 <        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
845 >                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
846 >                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
847 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
848 >                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
849 >                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
850 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
851 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
852 >                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
853 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
854 >                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
855 >                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
856 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
857 >                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
858 >                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
859 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
860 >                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
861 >                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
862 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
863 >                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
864 >                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
865 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
866 >                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
867 >                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
868 >        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
869 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
870 >                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
871 >        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
872 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
873 >                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
874 >
875 >        else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
876 >        else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
877 >        else if(currentHistogram.inputCollection == "mets") fill1DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
878 >        else if(currentHistogram.inputCollection == "tracks") fill1DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
879 >        else if(currentHistogram.inputCollection == "genjets") fill1DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
880 >        else if(currentHistogram.inputCollection == "mcparticles") fill1DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
881 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill1DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
882 >        else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
883 >        else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
884 >        else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
885 >        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
886 >        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
887        }
888        else if(currentHistogram.inputVariables.size() == 2){
889          TH2D* histo;
890 <        histo = twoDHists_.at(currentChannelIndex).at(currentHistogram.name);
891 <
892 <
893 <
691 <        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
692 <        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
890 >        histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
891 >        if(currentHistogram.inputCollection == "jets") fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
892 >        else if(currentHistogram.inputCollection == "muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
893 >        else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
894          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
895 <                                                                                       cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
896 <                                                                                       cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
897 <        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
895 >                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
896 >                                                                                       cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
897 >        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
898 >                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
899 >                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
900 >        else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
901 >        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
902          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
903 <                                                                                               cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
904 <                                                                                               cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
903 >                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
904 >                                                                                               cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
905 >        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
906 >                                                                                               cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
907 >                                                                                               cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
908 >        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
909 >                                                                                       cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
910 >                                                                                       cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
911          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
912 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
913 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
914 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
915 <                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
916 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
917 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
918 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
919 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
920 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
921 <                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
922 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
923 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
924 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
925 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
926 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
927 <        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
928 <        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
929 <        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
930 <        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
931 <                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
932 <                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
933 <        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
934 <        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
935 <        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
936 <        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
937 <        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
938 <        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
912 >                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
913 >                                                                                           cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
914 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
915 >                                                                                           cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
916 >                                                                                           cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
917 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
918 >                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
919 >                                                                                           cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
920 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
921 >                                                                                            cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
922 >                                                                                            cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
923 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
924 >                                                                                        cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
925 >                                                                                        cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
926 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
927 >                                                                                      cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
928 >                                                                                      cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
929 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
930 >                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
931 >                                                                                     cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
932 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
933 >                                                                                     cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
934 >                                                                                     cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
935 >        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
936 >                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
937 >                                                                                              cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
938 >        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
939 >                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
940 >                                                                                          cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
941 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
942 >        else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
943 >        else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
944 >        else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
945 >        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
946 >                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
947 >                                                                                         cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
948 >        else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
949 >        else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
950 >        else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").at(currentDir),scaleFactor);
951 >        else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").at(currentDir),scaleFactor);
952 >        else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").at(currentDir),scaleFactor);
953 >        else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").at(currentDir),scaleFactor);
954 >        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").at(currentDir),scaleFactor);
955 >        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").at(currentDir),scaleFactor);
956        }
957      }
958  
959 +
960 +
961      //fills histograms with the sizes of collections
962      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
963  
964        string currentObject = objectsToPlot.at(currentObjectIndex);
965 +      string objectToPlot = "";
966  
967 <      string objectToPlot = "";  
968 <
969 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
970 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
971 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
972 <      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
973 <      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
974 <      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
975 <      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
976 <      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
977 <      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
967 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
968 >      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
969 >      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
970 >      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
971 >      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
972 >      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
973 >      else if(currentObject == "jet-jet pairs")            objectToPlot = "dijetPairs";
974 >      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
975 >      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
976 >      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
977 >      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
978 >      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
979 >      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
980 >      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
981 >      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
982 >      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
983 >      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
984 >      else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
985 >      else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
986        else objectToPlot = currentObject;
987 +
988        string tempCurrentObject = objectToPlot;
989 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
989 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
990        string histoName = "num" + tempCurrentObject;
991  
752
992        //set position of primary vertex in event, in order to calculate quantities relative to it
993 <      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
994 <        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
993 >      if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
994 >        vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
995          int numToPlot = 0;
996          for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
997            if(lastCutFlags.at(currentFlag)) numToPlot++;
998          }
999          if(objectToPlot == "primaryvertexs"){
1000 <          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1001 <          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1000 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1001 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1002          }
1003          else {
1004 <          oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
1005 <        }
1004 >          oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1005 >        }
1006        }
1007 <      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
1008 <      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
1009 <      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1010 <      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
1011 <      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1012 <      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1013 <      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1014 <      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
1015 <      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
1016 <      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
1017 <      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(tracks->size(),scaleFactor);
1018 <      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(genjets->size(),scaleFactor);
1019 <      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1020 <      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1021 <      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
1022 <      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
1007 >      else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(jets->size(),scaleFactor);
1008 >      else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1009 >      else if(objectToPlot == "secondaryMuons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size(),scaleFactor);
1010 >      else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1011 >      else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
1012 >      else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1013 >      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size(),scaleFactor);
1014 >      else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1015 >      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
1016 >      else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
1017 >      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
1018 >      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
1019 >      else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
1020 >      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
1021 >      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
1022 >      else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(events->size(),scaleFactor);
1023 >      else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(taus->size(),scaleFactor);
1024 >      else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mets->size(),scaleFactor);
1025 >      else if(objectToPlot == "tracks") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(tracks->size(),scaleFactor);
1026 >      else if(objectToPlot == "genjets") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(genjets->size(),scaleFactor);
1027 >      else if(objectToPlot == "mcparticles") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(mcparticles->size(),scaleFactor);
1028 >      else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(bxlumis->size(),scaleFactor);
1029 >      else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(photons->size(),scaleFactor);
1030 >      else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(superclusters->size(),scaleFactor);
1031 >      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(trigobjs->size(),scaleFactor);
1032        else if(objectToPlot == "primaryvertexs"){
1033 <        oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1034 <        oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1035 <      }
1036 <
789 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
1033 >        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
1034 >        oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1035 >      }
1036 >      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(stops->size(),scaleFactor);
1037  
1038 +     } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1039 +    }
1040 +  }
1041    } //end loop over channel
1042  
1043 <  masterCutFlow_->fillCutFlow(scaleFactor);
1043 >  masterCutFlow_->fillCutFlow(masterScaleFactor);
1044  
1045   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1046  
# Line 807 | Line 1057 | OSUAnalysis::evaluateComparison (double
1057    else if(comparison == "==") return testValue == cutValue;
1058    else if(comparison == "=") return testValue == cutValue;
1059    else if(comparison == "!=") return testValue != cutValue;
1060 <  else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1060 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1061 >
1062 > }
1063 >
1064 > bool
1065 > OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1066 >
1067 >
1068 >  if(comparison == ">")       return testValue >  cutValue;
1069 >  else if(comparison == ">=") return testValue >= cutValue;
1070 >  else if(comparison == "<")  return testValue <  cutValue;
1071 >  else if(comparison == "<=") return testValue <= cutValue;
1072 >  else if(comparison == "==") return testValue == cutValue;
1073 >  else if(comparison == "=") return testValue == cutValue;
1074 >  else if(comparison == "!=") return testValue != cutValue;
1075 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1076  
1077   }
1078  
# Line 821 | Line 1086 | OSUAnalysis::evaluateTriggers (vector<st
1086        if(trigger->pass != 1) continue;
1087        for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1088          {
1089 <          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
1089 >          if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){
1090              triggerDecision = true;
1091            }
1092          }
# Line 830 | Line 1095 | OSUAnalysis::evaluateTriggers (vector<st
1095  
1096   }
1097  
1098 < std::vector<std::string>
1098 > vector<string>
1099   OSUAnalysis::splitString (string inputString){
1100  
1101 <  std::stringstream stringStream(inputString);
1102 <  std::istream_iterator<std::string> begin(stringStream);
1103 <  std::istream_iterator<std::string> end;
1104 <  std::vector<std::string> stringVector(begin, end);
1101 >  stringstream stringStream(inputString);
1102 >  istream_iterator<string> begin(stringStream);
1103 >  istream_iterator<string> end;
1104 >  vector<string> stringVector(begin, end);
1105    return stringVector;
1106  
1107   }
1108  
1109 +
1110 + void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1111 +  // Set two object strings from the tempInputCollection string,
1112 +  // For example, if tempInputCollection is "electron-muon pairs",
1113 +  // then obj1 = "electrons" and obj2 = "muons".
1114 +  // Note that the objects have an "s" appended.
1115 +
1116 +  int dashIndex = tempInputCollection.find("-");
1117 +  int spaceIndex = tempInputCollection.find_last_of(" ");
1118 +  int secondWordLength = spaceIndex - dashIndex;
1119 +  obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1120 +  obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1121 +
1122 + }
1123 +
1124 +
1125 + string OSUAnalysis::getObjToGet(string obj) {
1126 +  // Return the string corresponding to the object to get for the given obj string.
1127 +  // Right now this only handles the case in which obj contains "secondary",
1128 +  // e.g, "secondary muons".
1129 +  // Note that "s" is NOT appended.
1130 +
1131 +  if (obj.find("secondary")==string::npos) return obj;  // "secondary" is not found
1132 +  int firstSpaceIndex = obj.find_first_of(" ");
1133 +  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1134 +
1135 + }
1136 +
1137 +
1138 + //!jet valueLookup
1139   double
1140 < OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1140 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1141  
1142    double value = 0.0;
1143    if(variable == "energy") value = object->energy;
# Line 962 | Line 1257 | OSUAnalysis::valueLookup (const BNjet* o
1257    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1258  
1259  
1260 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1260 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1261  
1262    value = applyFunction(function, value);
1263  
# Line 970 | Line 1265 | OSUAnalysis::valueLookup (const BNjet* o
1265   }
1266  
1267  
1268 <
1268 > //!muon valueLookup
1269   double
1270 < OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1270 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1271  
1272    double value = 0.0;
1273    if(variable == "energy") value = object->energy;
# Line 1133 | Line 1428 | OSUAnalysis::valueLookup (const BNmuon*
1428    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1429    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1430    else if(variable == "metMT") {
1431 <    const BNmet *met = chosenMET ();
1137 <    if (met)
1431 >    if (const BNmet *met = chosenMET ())
1432        {
1433 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1434 <          p2 (met->px, met->py, 0.0, met->pt);
1141 <
1142 <        value = (p1 + p2).Mt ();
1433 >        double dPhi = deltaPhi (object->phi, met->phi);
1434 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1435        }
1436      else
1437        value = -999;
# Line 1257 | Line 1549 | OSUAnalysis::valueLookup (const BNmuon*
1549      value = object->isGlobalMuon > 0                \
1550        && object->isPFMuon > 0                        \
1551        && object->normalizedChi2 < 10                \
1552 <                                  && object->numberOfValidMuonHits > 0        \
1552 >                                  && object->numberOfValidMuonHits > 0        \
1553        && object->numberOfMatchedStations > 1        \
1554        && fabs(object->correctedD0Vertex) < 0.2        \
1555        && fabs(object->correctedDZ) < 0.5        \
# Line 1267 | Line 1559 | OSUAnalysis::valueLookup (const BNmuon*
1559    else if(variable == "tightIDdisplaced"){
1560      value = object->isGlobalMuon > 0                \
1561        && object->normalizedChi2 < 10                \
1562 <                                  && object->numberOfValidMuonHits > 0        \
1562 >                                  && object->numberOfValidMuonHits > 0        \
1563        && object->numberOfMatchedStations > 1        \
1564        && object->numberOfValidPixelHits > 0        \
1565        && object->numberOfLayersWithMeasurement > 5;
1566    }
1567  
1568 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1568 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1569  
1570    else if(variable == "genMatchedPdgId"){
1571      int index = getGenMatchedParticleIndex(object);
# Line 1293 | Line 1585 | OSUAnalysis::valueLookup (const BNmuon*
1585    }
1586    else if(variable == "genMatchedMotherIdReverse"){
1587      int index = getGenMatchedParticleIndex(object);
1588 <    if(index == -1) value = 23;
1589 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1588 >    if(index == -1) value = 24;
1589 >    else value = 24 - getPdgIdBinValue(mcparticles->at(index).motherId);
1590    }
1591    else if(variable == "genMatchedGrandmotherId"){
1592      int index = getGenMatchedParticleIndex(object);
# Line 1306 | Line 1598 | OSUAnalysis::valueLookup (const BNmuon*
1598      }
1599      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1600    }
1601 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1602 +    int index = getGenMatchedParticleIndex(object);
1603 +    if(index == -1) value = 24;
1604 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1605 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1606 +      if(motherIndex == -1) value = 24;
1607 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1608 +    }
1609 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1610 +  }
1611 +  else if(variable == "pfMuonsFromVertex"){
1612 +    double d0Error, dzError;
1613  
1614 +    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1615 +    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
1616 +    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
1617 +         || fabs (object->correctedD0Vertex / d0Error) > 99.0
1618 +         || fabs (object->correctedDZ / dzError) > 99.0;
1619 +    value = (object->isStandAloneMuon && !object->isTrackerMuon && !object->isGlobalMuon) || !value;
1620 +  }
1621  
1622  
1623 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1623 >
1624 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1625  
1626    value = applyFunction(function, value);
1627  
1628    return value;
1629   }
1630  
1631 <
1631 > //!electron valueLookup
1632   double
1633 < OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1633 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
1634  
1635    double value = 0.0;
1636    if(variable == "energy") value = object->energy;
# Line 1484 | Line 1796 | OSUAnalysis::valueLookup (const BNelectr
1796    else if(variable == "detIso") value = (object->trackIso) / object->pt;
1797    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
1798    else if(variable == "metMT") {
1799 <    const BNmet *met = chosenMET ();
1488 <    if (met)
1799 >    if (const BNmet *met = chosenMET ())
1800        {
1801 <        TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1802 <          p2 (met->px, met->py, 0.0, met->pt);
1492 <
1493 <        value = (p1 + p2).Mt ();
1801 >        double dPhi = deltaPhi (object->phi, met->phi);
1802 >        value = sqrt (2 * object->pt * met->pt * (1 - cos (dPhi)));
1803        }
1804      else
1805        value = -999;
# Line 1655 | Line 1964 | OSUAnalysis::valueLookup (const BNelectr
1964    }
1965  
1966  
1967 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1967 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1968  
1969    else if(variable == "genMatchedPdgId"){
1970      int index = getGenMatchedParticleIndex(object);
# Line 1676 | Line 1985 | OSUAnalysis::valueLookup (const BNelectr
1985    }
1986    else if(variable == "genMatchedMotherIdReverse"){
1987      int index = getGenMatchedParticleIndex(object);
1988 <    if(index == -1) value = 23;
1989 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1988 >    if(index == -1) value = 24;
1989 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
1990    }
1991    else if(variable == "genMatchedGrandmotherId"){
1992      int index = getGenMatchedParticleIndex(object);
# Line 1689 | Line 1998 | OSUAnalysis::valueLookup (const BNelectr
1998      }
1999      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2000    }
2001 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2002 +    int index = getGenMatchedParticleIndex(object);
2003 +    if(index == -1) value = 24;
2004 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2005 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2006 +      if(motherIndex == -1) value = 24;
2007 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2008 +    }
2009 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2010 +  }
2011 +  else if(variable == "pfElectronsFromVertex"){
2012 +    double d0Error, dzError;
2013  
2014 +    d0Error = hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2015 +    dzError = hypot (object->tkDZerr, chosenVertex ()->zError);
2016 +    value = fabs (object->correctedD0Vertex) > 0.2 || fabs (object->correctedDZ) > 0.5
2017 +         || fabs (object->correctedD0Vertex / d0Error) > 99.0
2018 +         || fabs (object->correctedDZ / dzError) > 99.0;
2019 +    value = !value;
2020 +  }
2021  
2022  
2023 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2023 >
2024 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2025  
2026    value = applyFunction(function, value);
2027  
2028    return value;
2029   }
2030  
2031 <
2031 > //!event valueLookup
2032   double
2033 < OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
2033 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
2034  
2035    double value = 0.0;
2036  
# Line 1775 | Line 2104 | OSUAnalysis::valueLookup (const BNevent*
2104      else
2105        value = 1.0;
2106    }
2107 <  else if(variable == "muonScaleFactor"){
2108 <    if(datasetType_ != "data")
2109 <      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1781 <      value = 1.0;
1782 <    else
1783 <      value = 1.0;
1784 <  }
1785 <  else if(variable == "electronScaleFactor"){
1786 <    if(datasetType_ != "data")
1787 <      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1788 <      value = 1.0;
1789 <    else
1790 <      value = 1.0;
1791 <  }
2107 >  else if(variable == "muonScaleFactor") value = muonScaleFactor_;
2108 >  else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2109 >  else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2110  
2111 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2111 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2112  
2113    value = applyFunction(function, value);
2114  
2115    return value;
2116   }
2117  
2118 + //!tau valueLookup
2119   double
2120 < OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2120 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2121  
2122    double value = 0.0;
2123  
# Line 1844 | Line 2163 | OSUAnalysis::valueLookup (const BNtau* o
2163  
2164  
2165  
2166 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2166 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2167  
2168    else if(variable == "genMatchedPdgId"){
2169      int index = getGenMatchedParticleIndex(object);
# Line 1864 | Line 2183 | OSUAnalysis::valueLookup (const BNtau* o
2183    }
2184    else if(variable == "genMatchedMotherIdReverse"){
2185      int index = getGenMatchedParticleIndex(object);
2186 <    if(index == -1) value = 23;
2187 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2186 >    if(index == -1) value = 24;
2187 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2188    }
2189    else if(variable == "genMatchedGrandmotherId"){
2190      int index = getGenMatchedParticleIndex(object);
# Line 1877 | Line 2196 | OSUAnalysis::valueLookup (const BNtau* o
2196      }
2197      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2198    }
2199 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2200 +    int index = getGenMatchedParticleIndex(object);
2201 +    if(index == -1) value = 24;
2202 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2203 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2204 +      if(motherIndex == -1) value = 24;
2205 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2206 +    }
2207 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2208 +  }
2209  
2210  
2211 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2211 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2212  
2213    value = applyFunction(function, value);
2214  
2215    return value;
2216   }
2217  
2218 + //!met valueLookup
2219   double
2220 < OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2220 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2221  
2222    double value = 0.0;
2223  
# Line 1951 | Line 2281 | OSUAnalysis::valueLookup (const BNmet* o
2281    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2282    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2283  
2284 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2284 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2285  
2286    value = applyFunction(function, value);
2287  
2288    return value;
2289   }
2290  
2291 + //!track valueLookup
2292   double
2293 < OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2293 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2294  
2295    double value = 0.0;
2296    double pMag = sqrt(object->pt * object->pt +
2297 <                     object->pz * object->pz);
2298 <  
2297 >                     object->pz * object->pz);
2298 >
2299    if(variable == "pt") value = object->pt;
2300    else if(variable == "px") value = object->px;
2301    else if(variable == "py") value = object->py;
# Line 1985 | Line 2316 | OSUAnalysis::valueLookup (const BNtrack*
2316  
2317  
2318    //additional BNs info for disappTrks
1988  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2319    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2320    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2321    else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2322    else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2323    else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2324    else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2325 +  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2326    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2327    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2328    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2329 <  
2329 >  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2330  
2331    //user defined variables
2332    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;
2333    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2334 +  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2335    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2336    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2337 <  else if(variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object);  
2338 <  else if(variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object) / pMag;  
2337 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2338 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2339    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2340    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2341    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2342    else if(variable == "ptError")                    value = object->ptError;
2343    else if(variable == "ptRes")                      value = getTrkPtRes(object);
2344 <  else if (variable == "d0wrtPV"){      
2345 <    double vx = object->vx - chosenVertex ()->x,        
2346 <      vy = object->vy - chosenVertex ()->y,      
2347 <      px = object->px,  
2348 <      py = object->py,  
2349 <      pt = object->pt;  
2350 <    value = (-vx * py + vy * px) / pt;  
2351 <  }      
2352 <  else if (variable == "dZwrtPV"){      
2353 <    double vx = object->vx - chosenVertex ()->x,        
2354 <      vy = object->vy - chosenVertex ()->y,      
2355 <      vz = object->vz - chosenVertex ()->z,      
2356 <      px = object->px,  
2357 <      py = object->py,  
2358 <      pz = object->pz,  
2359 <      pt = object->pt;  
2360 <    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2361 <  }    
2362 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2344 >  else if (variable == "d0wrtPV"){
2345 >    double vx = object->vx - chosenVertex ()->x,
2346 >      vy = object->vy - chosenVertex ()->y,
2347 >      px = object->px,
2348 >      py = object->py,
2349 >      pt = object->pt;
2350 >    value = (-vx * py + vy * px) / pt;
2351 >  }
2352 >  else if (variable == "dZwrtPV"){
2353 >    double vx = object->vx - chosenVertex ()->x,
2354 >      vy = object->vy - chosenVertex ()->y,
2355 >      vz = object->vz - chosenVertex ()->z,
2356 >      px = object->px,
2357 >      py = object->py,
2358 >      pz = object->pz,
2359 >      pt = object->pt;
2360 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2361 >  }
2362 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2363  
2364    else if(variable == "genMatchedPdgId"){
2365      int index = getGenMatchedParticleIndex(object);
# Line 2048 | Line 2380 | OSUAnalysis::valueLookup (const BNtrack*
2380    }
2381    else if(variable == "genMatchedMotherIdReverse"){
2382      int index = getGenMatchedParticleIndex(object);
2383 <    if(index == -1) value = 23;
2384 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2383 >    if(index == -1) value = 24;
2384 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2385    }
2386    else if(variable == "genMatchedGrandmotherId"){
2387      int index = getGenMatchedParticleIndex(object);
# Line 2061 | Line 2393 | OSUAnalysis::valueLookup (const BNtrack*
2393      }
2394      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2395    }
2396 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2397 +    int index = getGenMatchedParticleIndex(object);
2398 +    if(index == -1) value = 24;
2399 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2400 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2401 +      if(motherIndex == -1) value = 24;
2402 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2403 +    }
2404 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2405 +  }
2406  
2407  
2408  
2409 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2409 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2410  
2411    value = applyFunction(function, value);
2412  
2413    return value;
2414   }
2415  
2416 + //!genjet valueLookup
2417   double
2418 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2418 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2419  
2420    double value = 0.0;
2421  
# Line 2092 | Line 2435 | OSUAnalysis::valueLookup (const BNgenjet
2435    else if(variable == "charge") value = object->charge;
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 + //!mcparticle valueLookup
2446   double
2447 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2447 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2448  
2449    double value = 0.0;
2450  
# Line 2225 | Line 2569 | OSUAnalysis::valueLookup (const BNmcpart
2569    }
2570  
2571  
2572 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2572 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2573  
2574    value = applyFunction(function, value);
2575  
2576    return value;
2577   }
2578  
2579 + //!primaryvertex valueLookup
2580   double
2581 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2581 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
2582  
2583    double value = 0.0;
2584  
# Line 2252 | Line 2597 | OSUAnalysis::valueLookup (const BNprimar
2597    else if(variable == "isGood") value = object->isGood;
2598  
2599  
2600 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2600 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2601  
2602    value = applyFunction(function, value);
2603  
2604    return value;
2605   }
2606  
2607 + //!bxlumi valueLookup
2608   double
2609 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2609 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
2610  
2611    double value = 0.0;
2612  
# Line 2269 | Line 2615 | OSUAnalysis::valueLookup (const BNbxlumi
2615    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2616  
2617  
2618 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2618 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2619  
2620    value = applyFunction(function, value);
2621  
2622    return value;
2623   }
2624  
2625 + //!photon valueLookup
2626   double
2627 < OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2627 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
2628  
2629    double value = 0.0;
2630  
# Line 2352 | Line 2699 | OSUAnalysis::valueLookup (const BNphoton
2699    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2700  
2701  
2355
2702  
2703 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2703 >
2704 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2705  
2706    else if(variable == "genMatchedPdgId"){
2707      int index = getGenMatchedParticleIndex(object);
# Line 2376 | Line 2723 | OSUAnalysis::valueLookup (const BNphoton
2723    }
2724    else if(variable == "genMatchedMotherIdReverse"){
2725      int index = getGenMatchedParticleIndex(object);
2726 <    if(index == -1) value = 23;
2727 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
2726 >    if(index == -1) value = 24;
2727 >    else value = 24 -getPdgIdBinValue(mcparticles->at(index).motherId);
2728    }
2729    else if(variable == "genMatchedGrandmotherId"){
2730      int index = getGenMatchedParticleIndex(object);
# Line 2389 | Line 2736 | OSUAnalysis::valueLookup (const BNphoton
2736      }
2737      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2738    }
2739 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2740 +    int index = getGenMatchedParticleIndex(object);
2741 +    if(index == -1) value = 24;
2742 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2743 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2744 +      if(motherIndex == -1) value = 24;
2745 +      else value = 24 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2746 +    }
2747 +    else value = 24 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2748 +  }
2749  
2750  
2751 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2751 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2752  
2753    value = applyFunction(function, value);
2754  
2755    return value;
2756   }
2757  
2758 + //!supercluster valueLookup
2759   double
2760 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2760 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
2761  
2762    double value = 0.0;
2763  
# Line 2413 | Line 2771 | OSUAnalysis::valueLookup (const BNsuperc
2771    else if(variable == "theta") value = object->theta;
2772  
2773  
2774 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2774 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2775  
2776    value = applyFunction(function, value);
2777  
2778    return value;
2779   }
2780  
2781 + //!trigobj valueLookup
2782 + double
2783 + OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
2784 +
2785 +  double value = 0.0;
2786 +
2787 +  if(variable == "pt") value = object->pt;
2788 +  else if(variable == "eta") value = object->eta;
2789 +  else if(variable == "phi") value = object->phi;
2790 +  else if(variable == "px") value = object->px;
2791 +  else if(variable == "py") value = object->py;
2792 +  else if(variable == "pz") value = object->pz;
2793 +  else if(variable == "et") value = object->et;
2794 +  else if(variable == "energy") value = object->energy;
2795 +  else if(variable == "etTotal") value = object->etTotal;
2796 +  else if(variable == "id") value = object->id;
2797 +  else if(variable == "charge") value = object->charge;
2798 +  else if(variable == "isIsolated") value = object->isIsolated;
2799 +  else if(variable == "isMip") value = object->isMip;
2800 +  else if(variable == "isForward") value = object->isForward;
2801 +  else if(variable == "isRPC") value = object->isRPC;
2802 +  else if(variable == "bx") value = object->bx;
2803 +  else if(variable == "filter") {
2804 +    if ((stringValue = object->filter) == "")
2805 +      stringValue = "none";  // stringValue should only be empty if value is filled
2806 +  }
2807 +
2808 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2809 +
2810 +  value = applyFunction(function, value);
2811 +
2812 +  return value;
2813 + }
2814  
2815 + //!muon-muon pair valueLookup
2816   double
2817 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2817 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2818  
2819    double value = 0.0;
2820  
2821    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2822 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2823    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2824    else if(variable == "invMass"){
2825      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2483 | Line 2876 | OSUAnalysis::valueLookup (const BNmuon*
2876        value = object2->correctedD0;
2877      }
2878  
2879 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2879 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2880  
2881    value = applyFunction(function, value);
2882  
2883    return value;
2884   }
2885  
2886 + //!electron-electron pair valueLookup
2887   double
2888 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2888 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
2889  
2890    double value = 0.0;
2891  
2892    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2893 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2894    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2895    else if(variable == "invMass"){
2896      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2537 | Line 2932 | OSUAnalysis::valueLookup (const BNelectr
2932      value = object2->correctedD0;
2933    }
2934  
2935 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2935 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2936  
2937    value = applyFunction(function, value);
2938  
2939    return value;
2940   }
2941 <
2941 > //!electron-muon pair valueLookup
2942   double
2943 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2943 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2944  
2945    double value = 0.0;
2946  
2947    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2948 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2949    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2950    else if(variable == "invMass"){
2951      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2596 | Line 2992 | OSUAnalysis::valueLookup (const BNelectr
2992    else if(variable == "muonDetIso"){
2993      value = (object2->trackIsoDR03) / object2->pt;
2994    }
2995 +  else if(variable == "electronRelPFrhoIso"){
2996 +    value = ( object1->chargedHadronIsoDR03 + max(0.0, object1->neutralHadronIsoDR03 + object1->photonIsoDR03 - object1->AEffDr03*object1->rhoPrime) ) / object1->pt;
2997 +  }
2998 +  else if(variable == "muonRelPFdBetaIso"){
2999 +    value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3000 +  }
3001 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3002 +  value = applyFunction(function, value);
3003  
3004 +  return value;
3005 + }
3006  
3007 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3007 > //!electron-jet pair valueLookup
3008 > double
3009 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
3010 >
3011 >  double value = 0.0;
3012 >
3013 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3014 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3015 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3016 >  else if(variable == "invMass"){
3017 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3018 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3019 >    value = (fourVector1 + fourVector2).M();
3020 >  }
3021 >  else if(variable == "pt"){
3022 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3023 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3024 >    value = (fourVector1 + fourVector2).Pt();
3025 >  }
3026 >  else if(variable == "threeDAngle")
3027 >    {
3028 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3029 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3030 >      value = (threeVector1.Angle(threeVector2));
3031 >    }
3032 >  else if(variable == "chargeProduct"){
3033 >    value = object1->charge*object2->charge;
3034 >  }
3035 >
3036 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3037 >  value = applyFunction(function, value);
3038 >
3039 >  return value;
3040 > }
3041 >
3042 > //!muon-jet pair valueLookup
3043 > double
3044 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
3045 >
3046 >  double value = 0.0;
3047 >
3048 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3049 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3050 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3051 >  else if(variable == "invMass"){
3052 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3053 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3054 >    value = (fourVector1 + fourVector2).M();
3055 >  }
3056 >  else if(variable == "pt"){
3057 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3058 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3059 >    value = (fourVector1 + fourVector2).Pt();
3060 >  }
3061 >  else if(variable == "threeDAngle")
3062 >    {
3063 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3064 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3065 >      value = (threeVector1.Angle(threeVector2));
3066 >    }
3067 >  else if(variable == "chargeProduct"){
3068 >    value = object1->charge*object2->charge;
3069 >  }
3070  
3071 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3072    value = applyFunction(function, value);
3073  
3074    return value;
3075   }
3076  
3077 + //!jet-jet pair valueLookup
3078 + double
3079 + OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3080  
3081 < double  
3082 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
3083 <  double electronMass = 0.000511;        
3084 <  double value = 0.0;    
3085 <  TLorentzVector fourVector1(0, 0, 0, 0);        
3086 <  TLorentzVector fourVector2(0, 0, 0, 0);        
3087 <  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
3088 <  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3089 <  else if(variable == "invMass"){        
3090 <    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);    
3091 <    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );    
3092 <        
3093 <    value = (fourVector1 + fourVector2).M();    
3081 >  double value = 0.0;
3082 >
3083 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3084 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3085 >  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3086 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3087 >  else if(variable == "invMass"){
3088 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3089 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3090 >    value = (fourVector1 + fourVector2).M();
3091 >  }
3092 >  else if(variable == "pt"){
3093 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3094 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3095 >    value = (fourVector1 + fourVector2).Pt();
3096    }
3097 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3098 <  value = applyFunction(function, value);        
3099 <  return value;  
3097 >  else if(variable == "threeDAngle")
3098 >    {
3099 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3100 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3101 >      value = (threeVector1.Angle(threeVector2));
3102 >    }
3103 >  else if(variable == "chargeProduct"){
3104 >    value = object1->charge*object2->charge;
3105 >  }
3106 >
3107 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3108 >  value = applyFunction(function, value);
3109 >
3110 >  return value;
3111   }
3112 + //!electron-track pair valueLookup
3113 + double
3114 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3115 +  double electronMass = 0.000511;
3116 +  double value = 0.0;
3117 +  TLorentzVector fourVector1(0, 0, 0, 0);
3118 +  TLorentzVector fourVector2(0, 0, 0, 0);
3119 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3120 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3121 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3122 +  else if(variable == "invMass"){
3123 +    fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
3124 +    fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
3125  
3126 +    value = (fourVector1 + fourVector2).M();
3127 +  }
3128 +  else if(variable == "chargeProduct"){
3129 +    value = object1->charge*object2->charge;
3130 +  }
3131 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3132 +  value = applyFunction(function, value);
3133 +  return value;
3134 +
3135 + }
3136  
3137  
3138 + //!muon-track pair valueLookup
3139   double
3140 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
3140 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3141    double pionMass = 0.140;
3142    double muonMass = 0.106;
3143    double value = 0.0;
3144    TLorentzVector fourVector1(0, 0, 0, 0);
3145    TLorentzVector fourVector2(0, 0, 0, 0);
3146    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3147 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3148    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3149    else if(variable == "invMass"){
3150      fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
# Line 2642 | Line 3152 | OSUAnalysis::valueLookup (const BNmuon*
3152  
3153      value = (fourVector1 + fourVector2).M();
3154    }
3155 +  else if(variable == "chargeProduct"){
3156 +    value = object1->charge*object2->charge;
3157 +  }
3158  
3159    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3160    value = applyFunction(function, value);
3161    return value;
3162   }
3163  
3164 <
3164 > //!tau-tau pair valueLookup
3165   double
3166 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
3166 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3167    double value = 0.0;
3168    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3169 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3170    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3171    else if(variable == "invMass"){
3172      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2660 | Line 3174 | OSUAnalysis::valueLookup (const BNtau* o
3174      value = (fourVector1 + fourVector2).M();
3175    }
3176  
3177 +  else if(variable == "chargeProduct"){
3178 +    value = object1->charge*object2->charge;
3179 +  }
3180 +
3181    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3182    value = applyFunction(function, value);
3183    return value;
3184   }
3185  
3186 <
3186 > //!muon-tau pair valueLookup
3187   double
3188 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
3188 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3189    double value = 0.0;
3190    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3191 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3192    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3193    else if(variable == "invMass"){
3194      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 2677 | Line 3196 | OSUAnalysis::valueLookup (const BNmuon*
3196      value = (fourVector1 + fourVector2).M();
3197    }
3198  
3199 +  else if(variable == "chargeProduct"){
3200 +    value = object1->charge*object2->charge;
3201 +  }
3202 +
3203 +  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3204 +  value = applyFunction(function, value);
3205 +  return value;
3206 + }
3207 +
3208 + //!tau-track pair valueLookup
3209 + double
3210 + OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3211 +  double value = 0.0;
3212 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3213 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3214 +  else if(variable == "chargeProduct"){
3215 +    value = object1->charge*object2->charge;
3216 +  }
3217 +
3218    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3219    value = applyFunction(function, value);
3220    return value;
3221   }
3222  
3223  
3224 + //!track-event pair valueLookup
3225   double
3226 < OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3226 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3227  
3228    double value = 0.0;
3229    double pMag = sqrt(object1->pt * object1->pt +
3230 <                     object1->pz * object1->pz);  
3230 >                     object1->pz * object1->pz);
3231  
3232    if      (variable == "numPV")                      value = object2->numPV;
3233    else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3234    else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3235 <  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3236 <  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3235 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3236 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3237 >
3238 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3239 >
3240 >  value = applyFunction(function, value);
3241 >
3242 >  return value;
3243 >
3244 > }
3245 >
3246 > //!electron-trigobj pair valueLookup
3247 > double
3248 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3249 >
3250 >  double value = 0.0;
3251 >
3252 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3253 >  else if (variable == "match"){
3254 >    if (deltaR(object1->eta,object1->phi,object2->eta,object2->phi) < 0.2 && abs(object2->id) == 11)
3255 >      stringValue = object2->filter;
3256 >    else
3257 >      stringValue = "none";
3258 >  }
3259 >
3260 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3261 >
3262 >  value = applyFunction(function, value);
3263 >
3264 >  return value;
3265 >
3266 > }
3267 >
3268 > //!muon-trigobj pair valueLookup
3269 > double
3270 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3271 >
3272 >  double value = 0.0;
3273 >
3274 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3275 >
3276 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3277 >
3278 >  value = applyFunction(function, value);
3279 >
3280 >  return value;
3281 >
3282 > }
3283 >
3284 > //!stop valueLookup
3285 > double
3286 > OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3287 >
3288 >
3289 >  double value = 0.0;
3290 >
3291 >  if(variable == "ctau") value = object->ctau;
3292 >
3293 >  else if (variable == "d0"){
3294 >    double vx = object->vx - chosenVertex ()->x,
3295 >      vy = object->vy - chosenVertex ()->y,
3296 >      px = object->px,
3297 >      py = object->py,
3298 >      pt = object->pt;
3299 >    value = (-vx * py + vy * px) / pt;
3300 >  }
3301 >
3302 >  else if (variable == "dz"){
3303 >    double vx = object->vx - chosenVertex ()->x,
3304 >      vy = object->vy - chosenVertex ()->y,
3305 >      vz = object->vz - chosenVertex ()->z,
3306 >      px = object->px,
3307 >      py = object->py,
3308 >      pz = object->pz,
3309 >      pt = object->pt;
3310 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3311 >  }
3312 >
3313 >  else if (variable == "minD0"){
3314 >    double minD0=999;
3315 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3316 >      double vx = object->vx - vertex->x,
3317 >        vy = object->vy - vertex->y,
3318 >        px = object->px,
3319 >        py = object->py,
3320 >        pt = object->pt;
3321 >      value = (-vx * py + vy * px) / pt;
3322 >      if(abs(value) < abs(minD0)) minD0 = value;
3323 >    }
3324 >    value = minD0;
3325 >  }
3326 >  else if (variable == "minDz"){
3327 >    double minDz=999;
3328 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3329 >      double vx = object->vx - vertex->x,
3330 >        vy = object->vy - vertex->y,
3331 >        vz = object->vz - vertex->z,
3332 >        px = object->px,
3333 >        py = object->py,
3334 >        pz = object->pz,
3335 >        pt = object->pt;
3336 >      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3337 >      if(abs(value) < abs(minDz)) minDz = value;
3338 >    }
3339 >    value = minDz;
3340 >  }
3341 >  else if(variable == "distToVertex"){
3342 >    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3343 >                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3344 >                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3345 >  }
3346 >  else if (variable == "minDistToVertex"){
3347 >    double minDistToVertex=999;
3348 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3349 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3350 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3351 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3352 >
3353 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3354 >    }
3355 >    value = minDistToVertex;
3356 >  }
3357 >  else if (variable == "distToVertexDifference"){
3358 >    double minDistToVertex=999;
3359 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3360 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3361 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3362 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3363 >
3364 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3365 >    }
3366 >    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3367 >                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3368 >                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3369 >
3370 >    value = distToChosenVertex - minDistToVertex;
3371 >  }
3372 >
3373 >  else if (variable == "closestVertexRank"){
3374 >    double minDistToVertex=999;
3375 >    int vertex_rank = 0;
3376 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3377 >      vertex_rank++;
3378 >      int dist = 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(dist) < abs(minDistToVertex)){
3383 >        value = vertex_rank;
3384 >        minDistToVertex = dist;
3385 >      }
3386 >    }
3387 >  }
3388 >
3389 >
3390  
3391 <  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3391 >
3392 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3393  
3394    value = applyFunction(function, value);
3395  
3396    return value;
3397  
3398 < }  
3398 > }
3399 >
3400 >
3401 >
3402  
3403   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3404   // Return true iff no other tracks are found in this cone.
# Line 2751 | Line 3447 | OSUAnalysis::getTrkPtTrue (const BNtrack
3447  
3448   double
3449   OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3450 <  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3451 <  if (!useTrackCaloRhoCorr_) return -99;  
3452 <  // if (!rhokt6CaloJetsHandle_) {
3453 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3454 <  //   return -99;  
3450 >  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
3451 >  if (!useTrackCaloRhoCorr_) return -99;
3452 >  // if (!rhokt6CaloJetsHandle_) {
3453 >  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
3454 >  //   return -99;
3455    // }
3456 <  double radDeltaRCone = 0.5;  
3457 <  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3458 <  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3459 <  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3460 <  return caloTotRhoCorrCalo;  
3461 <
3456 >  double radDeltaRCone = 0.5;
3457 >  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.
3458 >  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
3459 >  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
3460 >  return caloTotRhoCorrCalo;
3461 >
3462   }
3463  
3464  
# Line 2800 | Line 3496 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3496    double deltaRLowest = 999;
3497    int value = 0;
3498    if (DeadEcalVec.size() == 0) WriteDeadEcal();
3499 <  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3499 >  for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3500      double eta = ecal->etaEcal;
3501      double phi = ecal->phiEcal;
3502 <    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
3502 >    double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
3503      if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3504    }
3505    if (deltaRLowest<0.05) {value = 1;}
# Line 2811 | Line 3507 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3507    return value;
3508   }
3509  
3510 < // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3510 > // Returns the smallest DeltaR between the object and any generated true particle in the event.
3511   template <class InputObject>
3512   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3513    double genDeltaRLowest = 999.;
# Line 2831 | Line 3527 | OSUAnalysis::applyFunction(string functi
3527    else if(function == "log") value = log10(value);
3528  
3529    else if(function == "") value = value;
3530 <  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
3530 >  else{cout << "WARNING: invalid function '" << function << "'\n";}
3531  
3532    return value;
3533  
# Line 2841 | Line 3537 | OSUAnalysis::applyFunction(string functi
3537   template <class InputCollection>
3538   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3539  
3540 +  if (currentCut.inputCollection.find("pair")!=string::npos)  {
3541 +    string obj1, obj2;
3542 +    getTwoObjs(currentCut.inputCollection, obj1, obj2);
3543 +    if (inputType==obj1 ||
3544 +          inputType==obj2) {
3545 +      // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3546 +      // and the inputType is a member of the pair.
3547 +      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
3548 +      // For example, if currentCut.inputCollection==electron-muon pairs,
3549 +      // then the flags should not be set here when inputType==muons or inputType==electrons.
3550 +      return;
3551 +    }
3552 +  }
3553  
3554    for (uint object = 0; object != inputCollection->size(); object++){
3555  
2847
3556      bool decision = true;//object passes if this cut doesn't cut on that type of object
3557  
2850
3558      if(currentCut.inputCollection == inputType){
3559  
3560        vector<bool> subcutDecisions;
3561        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3562 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3563 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3562 >        string stringValue = "";
3563 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3564 >        if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3565 >        else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3566 >
3567        }
3568        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
3569        else{
# Line 2867 | Line 3577 | void OSUAnalysis::setObjectFlags(cut &cu
3577          decision = tempDecision;
3578        }
3579      }
2870    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3580  
3581 +    individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3582  
3583      //set flags for objects that pass each cut AND all the previous cuts
3584      bool previousCumulativeFlag = true;
# Line 2878 | Line 3588 | void OSUAnalysis::setObjectFlags(cut &cu
3588      }
3589      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(previousCumulativeFlag && decision);
3590  
2881
3591    }
3592  
3593   }
# Line 2892 | Line 3601 | void OSUAnalysis::setObjectFlags(cut &cu
3601    bool sameObjects = false;
3602    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3603  
3604 +  // Get the strings for the two objects that make up the pair.
3605 +  string obj1Type, obj2Type;
3606 +  getTwoObjs(inputType, obj1Type, obj2Type);
3607 +  bool isTwoTypesOfObject = true;
3608 +  if (obj1Type==obj2Type) isTwoTypesOfObject = false;
3609 +
3610 +  // Initialize the flags for individual objects to all be false, if the cut is on the pair.
3611 +  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
3612 +  if (currentCut.inputCollection == inputType) {
3613 +    for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3614 +      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3615 +      cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3616 +    }
3617 +    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
3618 +      for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3619 +        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3620 +        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3621 +      }
3622 +    }
3623 +  }
3624  
3625    int counter = 0;
3626 +
3627    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3628      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3629  
# Line 2906 | Line 3636 | void OSUAnalysis::setObjectFlags(cut &cu
3636  
3637          vector<bool> subcutDecisions;
3638          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3639 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3640 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3639 >          string stringValue = "";
3640 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3641 >          if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3642 >          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3643          }
3644  
3645          if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 2922 | Line 3654 | void OSUAnalysis::setObjectFlags(cut &cu
3654            decision = tempDecision;
3655          }
3656        }
3657 +      // if (decision) isPassObj1.at(object1) = true;
3658 +      // if (decision) isPassObj2.at(object2) = true;
3659        individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3660 +      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3661 +        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
3662 +        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
3663 +      }
3664  
3665        //set flags for objects that pass each cut AND all the previous cuts
3666        bool previousCumulativeFlag = true;
# Line 2937 | Line 3675 | void OSUAnalysis::setObjectFlags(cut &cu
3675        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3676        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3677        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3678 <
3678 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3679 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
3680 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
3681 >      }
3682        counter++;
2942    }
3683  
3684 <  }
3684 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
3685 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
3686  
3687 + }
3688  
3689 +
3690 + bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3691 +  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3692 +  // all cuts up to currentCutIndex
3693 +  bool previousCumulativeFlag = true;
3694 +  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
3695 +    if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3696 +    else {
3697 +      previousCumulativeFlag = false; break;
3698 +    }
3699 +  }
3700 +  return previousCumulativeFlag;
3701   }
3702  
3703  
# Line 2957 | Line 3711 | void OSUAnalysis::fill1DHistogram(TH1* h
3711      string currentString = parameters.inputVariables.at(0);
3712      string inputVariable = "";
3713      string function = "";
3714 <    if(currentString.find("(")==std::string::npos){
3714 >    if(currentString.find("(")==string::npos){
3715        inputVariable = currentString;// variable to cut on
3716      }
3717      else{
# Line 2966 | Line 3720 | void OSUAnalysis::fill1DHistogram(TH1* h
3720        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3721      }
3722  
3723 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3723 >    string stringValue = "";
3724 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3725      histo->Fill(value,scaleFactor);
2971
3726      if (printEventInfo_) {
3727 <      // Write information about event to screen, for testing purposes.  
3728 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3727 >      // Write information about event to screen, for testing purposes.
3728 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
3729      }
3730 <    
3730 >
3731    }
3732   }
3733  
# Line 2983 | Line 3737 | void OSUAnalysis::fill1DHistogram(TH1* h
3737    bool sameObjects = false;
3738    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3739  
3740 <  int pairCounter = 0;
3740 >  int pairCounter = -1;
3741    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3742      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3743  
3744        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3745  
3746 +      pairCounter++;
3747        //only take objects which have passed all cuts and pairs which have passed all cuts
3748        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3749        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
# Line 2997 | Line 3752 | void OSUAnalysis::fill1DHistogram(TH1* h
3752        string currentString = parameters.inputVariables.at(0);
3753        string inputVariable = "";
3754        string function = "";
3755 <      if(currentString.find("(")==std::string::npos){
3755 >      if(currentString.find("(")==string::npos){
3756          inputVariable = currentString;// variable to cut on
3757        }
3758        else{
# Line 3006 | Line 3761 | void OSUAnalysis::fill1DHistogram(TH1* h
3761          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3762        }
3763  
3764 <      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3764 >      string stringValue = "";
3765 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3766        histo->Fill(value,scaleFactor);
3767  
3012      pairCounter++;
3768      }
3769    }
3770  
# Line 3023 | Line 3778 | void OSUAnalysis::fill2DHistogram(TH2* h
3778  
3779      if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3780  
3781 +    string stringValue = "";
3782      string currentString = parameters.inputVariables.at(0);
3783      string inputVariable = "";
3784      string function = "";
3785 <    if(currentString.find("(")==std::string::npos){
3785 >    if(currentString.find("(")==string::npos){
3786        inputVariable = currentString;// variable to cut on
3787      }
3788      else{
# Line 3034 | Line 3790 | void OSUAnalysis::fill2DHistogram(TH2* h
3790        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3791        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3792      }
3793 <    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3793 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3794  
3795      currentString = parameters.inputVariables.at(1);
3796      inputVariable = "";
3797      function = "";
3798 <    if(currentString.find("(")==std::string::npos){
3798 >    if(currentString.find("(")==string::npos){
3799        inputVariable = currentString;// variable to cut on
3800      }
3801      else{
# Line 3048 | Line 3804 | void OSUAnalysis::fill2DHistogram(TH2* h
3804        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3805      }
3806  
3807 <    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3807 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3808  
3809      histo->Fill(valueX,valueY,scaleFactor);
3810  
# Line 3062 | Line 3818 | void OSUAnalysis::fill2DHistogram(TH2* h
3818    bool sameObjects = false;
3819    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3820  
3821 <  int pairCounter = 0;
3821 >  int pairCounter = -1;
3822    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3823      for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3824  
3825        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
3826  
3827 +      pairCounter++;
3828 +
3829        //only take objects which have passed all cuts and pairs which have passed all cuts
3830        if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1)) continue;
3831        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3832        if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3833  
3834 +      string stringValue = "";
3835        string currentString = parameters.inputVariables.at(0);
3836        string inputVariable = "";
3837        string function = "";
3838 <      if(currentString.find("(")==std::string::npos){
3838 >      if(currentString.find("(")==string::npos){
3839          inputVariable = currentString;// variable to cut on
3840        }
3841        else{
# Line 3084 | Line 3843 | void OSUAnalysis::fill2DHistogram(TH2* h
3843          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3844          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3845        }
3846 <      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3846 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3847  
3848        currentString = parameters.inputVariables.at(1);
3849        inputVariable = "";
3850        function = "";
3851 <      if(currentString.find("(")==std::string::npos){
3851 >      if(currentString.find("(")==string::npos){
3852          inputVariable = currentString;// variable to cut on
3853        }
3854        else{
# Line 3097 | Line 3856 | void OSUAnalysis::fill2DHistogram(TH2* h
3856          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3857          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3858        }
3859 <      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3859 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3860  
3861  
3862        histo->Fill(valueX,valueY,scaleFactor);
3863  
3105      pairCounter++;
3106
3864      }
3865    }
3866  
# Line 3120 | Line 3877 | int OSUAnalysis::getGenMatchedParticleIn
3877  
3878      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3879      if(currentDeltaR > 0.05) continue;
3880 <    //     cout << std::setprecision(3) << std::setw(20)
3880 >    //     cout << setprecision(3) << setw(20)
3881      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3882 <    //          << std::setw(20)
3882 >    //          << setw(20)
3883      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3884 <    //          << std::setw(20)
3884 >    //          << setw(20)
3885      //          << "\tdeltaR = " << currentDeltaR
3886 <    //          << std::setprecision(1)
3887 <    //          << std::setw(20)
3886 >    //          << setprecision(1)
3887 >    //          << setw(20)
3888      //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3889 <    //          << std::setw(20)
3889 >    //          << setw(20)
3890      //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3891 <    //          << std::setw(20)
3891 >    //          << setw(20)
3892      //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3893      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3894        bestMatchIndex = mcparticle - mcparticles->begin();
# Line 3194 | Line 3951 | int OSUAnalysis::findTauMotherIndex(cons
3951   // 20        strange baryon
3952   // 21        charm baryon
3953   // 22        bottom baryon
3954 < // 23        other
3954 > // 23        QCD string
3955 > // 24        other
3956  
3957   int OSUAnalysis::getPdgIdBinValue(int pdgId){
3958  
# Line 3218 | Line 3976 | int OSUAnalysis::getPdgIdBinValue(int pd
3976    else if(absPdgId > 3000 && absPdgId < 4000  ) binValue = 20;
3977    else if(absPdgId > 4000 && absPdgId < 5000  ) binValue = 21;
3978    else if(absPdgId > 5000 && absPdgId < 6000  ) binValue = 22;
3979 +  else if(absPdgId == 92  ) binValue = 23;
3980  
3981 <  else binValue = 23;
3981 >  else binValue = 24;
3982  
3983    return binValue;
3984  
# Line 3229 | Line 3988 | const BNprimaryvertex *
3988   OSUAnalysis::chosenVertex ()
3989   {
3990    const BNprimaryvertex *chosenVertex = 0;
3991 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3992 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3993 <      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3991 >  if(cumulativeFlags.find ("primaryvertexs") != cumulativeFlags.end ()){
3992 >    vector<bool> vertexFlags;
3993 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
3994 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
3995 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
3996 >        break;
3997 >      }
3998 >    }
3999      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
4000        if(!vertexFlags.at(vertexIndex)) continue;
4001        chosenVertex = & primaryvertexs->at(vertexIndex);
4002        break;
4003      }
4004    }
4005 <  else {
4006 <    chosenVertex = &primaryvertexs->at(0);
3243 <  }
4005 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "primaryvertexs") != objectsToGet.end ())
4006 >    chosenVertex = & primaryvertexs->at (0);
4007  
4008    return chosenVertex;
4009   }
# Line 3249 | Line 4012 | const BNmet *
4012   OSUAnalysis::chosenMET ()
4013   {
4014    const BNmet *chosenMET = 0;
4015 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
4016 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
4017 <      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
4015 >  if(cumulativeFlags.find ("mets") != cumulativeFlags.end ()){
4016 >    vector<bool> metFlags;
4017 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
4018 >      if (cumulativeFlags.at("mets").at(i).size()){
4019 >        metFlags = cumulativeFlags.at("mets").at(i);
4020 >        break;
4021 >      }
4022 >    }
4023      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
4024        if(!metFlags.at(metIndex)) continue;
4025        chosenMET = & mets->at(metIndex);
4026        break;
4027      }
4028    }
4029 <  else {
4030 <    chosenMET = &mets->at(0);
3263 <  }
4029 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "mets") != objectsToGet.end ())
4030 >    chosenMET = & mets->at (0);
4031  
4032    return chosenMET;
4033   }
# Line 3269 | Line 4036 | const BNelectron *
4036   OSUAnalysis::chosenElectron ()
4037   {
4038    const BNelectron *chosenElectron = 0;
4039 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
4040 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
4041 <      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
4039 >  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4040 >    vector<bool> electronFlags;
4041 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4042 >      if (cumulativeFlags.at("electrons").at(i).size()){
4043 >        electronFlags = cumulativeFlags.at("electrons").at(i);
4044 >        break;
4045 >      }
4046 >    }
4047      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
4048        if(!electronFlags.at(electronIndex)) continue;
4049        chosenElectron = & electrons->at(electronIndex);
4050        break;
4051      }
4052    }
4053 <  else {
4054 <    chosenElectron = &electrons->at(0);
3283 <  }
4053 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "electrons") != objectsToGet.end ())
4054 >    chosenElectron = & electrons->at (0);
4055  
4056    return chosenElectron;
4057   }
# Line 3289 | Line 4060 | const BNmuon *
4060   OSUAnalysis::chosenMuon ()
4061   {
4062    const BNmuon *chosenMuon = 0;
4063 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4064 <    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
4065 <      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
4063 >  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4064 >    vector<bool> muonFlags;
4065 >    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4066 >      if (cumulativeFlags.at("muons").at(i).size()){
4067 >        muonFlags = cumulativeFlags.at("muons").at(i);
4068 >        break;
4069 >      }
4070 >    }
4071      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4072        if(!muonFlags.at(muonIndex)) continue;
4073        chosenMuon = & muons->at(muonIndex);
4074        break;
4075      }
4076    }
4077 <  else {
4078 <    chosenMuon = &muons->at(0);
3303 <  }
4077 >  else if (find (objectsToGet.begin (), objectsToGet.end (), "muons") != objectsToGet.end ())
4078 >    chosenMuon = & muons->at (0);
4079  
4080    return chosenMuon;
4081   }
4082  
3308
4083   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines