ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc
(Generate patch)

Comparing UserCode/OSUT3Analysis/AnaTools/plugins/OSUAnalysis.cc (file contents):
Revision 1.49 by wulsin, Wed Apr 17 15:39:43 2013 UTC vs.
Revision 1.60 by jbrinson, Thu May 9 10:28:52 2013 UTC

# Line 17 | Line 17 | OSUAnalysis::OSUAnalysis (const edm::Par
17    photons_ (cfg.getParameter<edm::InputTag> ("photons")),
18    superclusters_ (cfg.getParameter<edm::InputTag> ("superclusters")),
19    triggers_ (cfg.getParameter<edm::InputTag> ("triggers")),
20 <  puFile_ (cfg.getParameter<std::string> ("puFile")),
21 <  deadEcalFile_ (cfg.getParameter<std::string> ("deadEcalFile")),
22 <  muonSFFile_ (cfg.getParameter<std::string> ("muonSFFile")),
23 <  dataPU_ (cfg.getParameter<std::string> ("dataPU")),
24 <  electronSFID_ (cfg.getParameter<std::string> ("electronSFID")),
25 <  muonSF_ (cfg.getParameter<std::string> ("muonSF")),
26 <  dataset_ (cfg.getParameter<std::string> ("dataset")),
27 <  datasetType_ (cfg.getParameter<std::string> ("datasetType")),
20 >  trigobjs_ (cfg.getParameter<edm::InputTag> ("trigobjs")),
21 >  puFile_ (cfg.getParameter<string> ("puFile")),
22 >  deadEcalFile_ (cfg.getParameter<string> ("deadEcalFile")),
23 >  muonSFFile_ (cfg.getParameter<string> ("muonSFFile")),
24 >  dataPU_ (cfg.getParameter<string> ("dataPU")),
25 >  electronSFID_ (cfg.getParameter<string> ("electronSFID")),
26 >  muonSF_ (cfg.getParameter<string> ("muonSF")),
27 >  dataset_ (cfg.getParameter<string> ("dataset")),
28 >  datasetType_ (cfg.getParameter<string> ("datasetType")),
29    channels_  (cfg.getParameter<vector<edm::ParameterSet> >("channels")),
30    histogramSets_ (cfg.getParameter<vector<edm::ParameterSet> >("histogramSets")),
31    plotAllObjectsInPassingEvents_ (cfg.getParameter<bool> ("plotAllObjectsInPassingEvents")),
32    doPileupReweighting_ (cfg.getParameter<bool> ("doPileupReweighting")),
33 <  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
33 >  applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
34 >  printEventInfo_ (cfg.getParameter<bool> ("printEventInfo")),
35    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
36    stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau"))
37  
# Line 40 | Line 42 | OSUAnalysis::OSUAnalysis (const edm::Par
42    //create pile-up reweighting object, if necessary
43    if(datasetType_ != "data") {
44      if(doPileupReweighting_) puWeight_ = new PUWeight (puFile_, dataPU_, dataset_);
45 <    //    muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
46 <    //    electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
45 >    if (applyLeptonSF_){
46 >      muonSFWeight_ = new MuonSFWeight (muonSFFile_, muonSF_);
47 >      electronSFWeight_ = new ElectronSFWeight ("53X", electronSFID_);
48 >    }
49    }
50 < #ifdef DISPLACED_SUSY
51 <  if (datasetType_ == "signalMC")
48 <    cTauWeight_ = new CTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
49 < #endif
50 >  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
51 >    stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
52  
53  
54    // Construct Cutflow Objects. These store the results of cut decisions and
55    // handle filling cut flow histograms.
56    masterCutFlow_ = new CutFlow (fs_);
57 <  std::vector<TFileDirectory> directories;
57 >  vector<TFileDirectory> directories;
58  
59    //always get vertex collection so we can assign the primary vertex in the event
60    objectsToGet.push_back("primaryvertexs");
# Line 71 | Line 73 | OSUAnalysis::OSUAnalysis (const edm::Par
73  
74      string tempInputCollection = histogramSets_.at(currentHistogramSet).getParameter<string> ("inputCollection");
75      if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
76 +    if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
77 +    if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
78      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
79      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
80 <    if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
81 <      if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
82 <        int spaceIndex = tempInputCollection.find(" ");
83 <        int secondWordLength = tempInputCollection.size() - spaceIndex;
84 <        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
80 >    if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
81 >    if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
82 >    if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
83 >    if(tempInputCollection.find("pairs")==string::npos){ //just a single object
84 >      if(tempInputCollection.find("secondary")!=string::npos){//secondary object
85 >        int spaceIndex = tempInputCollection.find(" ");
86 >        int secondWordLength = tempInputCollection.size() - spaceIndex;
87 >        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
88        }
89        else{
90 <        objectsToGet.push_back(tempInputCollection);
90 >        objectsToGet.push_back(tempInputCollection);
91        }
92        objectsToPlot.push_back(tempInputCollection);
93        objectsToCut.push_back(tempInputCollection);
94      }
95      else{//pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
96 <      string obj1;
96 >      string obj1;
97        string obj2;
98        getTwoObjs(tempInputCollection, obj1, obj2);
99 <      string obj2ToGet = getObjToGet(obj2);  
99 >      string obj2ToGet = getObjToGet(obj2);
100        objectsToCut.push_back(tempInputCollection);
101        objectsToCut.push_back(obj1);
102 <      objectsToCut.push_back(obj2);  
102 >      objectsToCut.push_back(obj2);
103        objectsToPlot.push_back(tempInputCollection);
104        objectsToPlot.push_back(obj1);
105 <      objectsToPlot.push_back(obj2);  
105 >      objectsToPlot.push_back(obj2);
106        objectsToGet.push_back(tempInputCollection);
107        objectsToGet.push_back(obj1);
108        objectsToGet.push_back(obj2ToGet);
# Line 106 | Line 113 | OSUAnalysis::OSUAnalysis (const edm::Par
113  
114      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
115  
116 +      vector<double> defaultValue;
117 +      defaultValue.push_back (-1.0);
118 +
119        histogram tempHistogram;
120        tempHistogram.inputCollection = tempInputCollection;
121        tempHistogram.name = histogramList_.at(currentHistogram).getParameter<string>("name");
122        tempHistogram.title = histogramList_.at(currentHistogram).getParameter<string>("title");
123 <      tempHistogram.bins = histogramList_.at(currentHistogram).getParameter<vector<double> >("bins");
123 >      tempHistogram.bins = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("bins", defaultValue);
124 >      tempHistogram.variableBinsX = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsX", defaultValue);
125 >      tempHistogram.variableBinsY = histogramList_.at(currentHistogram).getUntrackedParameter<vector<double> >("variableBinsY", defaultValue);
126        tempHistogram.inputVariables = histogramList_.at(currentHistogram).getParameter<vector<string> >("inputVariables");
127  
128        histograms.push_back(tempHistogram);
# Line 127 | Line 139 | OSUAnalysis::OSUAnalysis (const edm::Par
139    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
140  
141      string currentObject = objectsToPlot.at(currentObjectIndex);
142 <    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
142 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
143  
144      histogram tempIdHisto;
145      histogram tempMomIdHisto;
146      histogram tempGmaIdHisto;
147      histogram tempIdVsMomIdHisto;
148 +    histogram tempIdVsGmaIdHisto;
149  
150      tempIdHisto.inputCollection = currentObject;
151      tempMomIdHisto.inputCollection = currentObject;
152      tempGmaIdHisto.inputCollection = currentObject;
153      tempIdVsMomIdHisto.inputCollection = currentObject;
154 +    tempIdVsGmaIdHisto.inputCollection = currentObject;
155  
156      if(currentObject == "secondary muons") currentObject = "secondaryMuons";
157 +    if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
158  
159      currentObject = currentObject.substr(0, currentObject.size()-1);
160      tempIdHisto.name = currentObject+"GenMatchId";
161      tempMomIdHisto.name = currentObject+"GenMatchMotherId";
162      tempGmaIdHisto.name = currentObject+"GenMatchGrandmotherId";
163      tempIdVsMomIdHisto.name = currentObject+"GenMatchIdVsMotherId";
164 +    tempIdVsGmaIdHisto.name = currentObject+"GenMatchIdVsGrandmotherId";
165  
166      currentObject.at(0) = toupper(currentObject.at(0));
167      tempIdHisto.title = currentObject+" Gen-matched Particle";
168      tempMomIdHisto.title = currentObject+" Gen-matched Particle's Mother";
169      tempGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother";
170      tempIdVsMomIdHisto.title = currentObject+" Gen-matched Particle's Mother vs. Particle;Particle;Mother";
171 +    tempIdVsGmaIdHisto.title = currentObject+" Gen-matched Particle's Grandmother vs. Particle;Particle;Grandmother";
172 +
173  
174      int maxNum = 24;
175      vector<double> binVector;
# Line 171 | Line 189 | OSUAnalysis::OSUAnalysis (const edm::Par
189      tempIdVsMomIdHisto.bins = binVector;
190      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedId");
191      tempIdVsMomIdHisto.inputVariables.push_back("genMatchedMotherIdReverse");
192 +    tempIdVsGmaIdHisto.bins = binVector;
193 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedId");
194 +    tempIdVsGmaIdHisto.inputVariables.push_back("genMatchedGrandmotherIdReverse");
195  
196      histograms.push_back(tempIdHisto);
197      histograms.push_back(tempMomIdHisto);
198      histograms.push_back(tempGmaIdHisto);
199      histograms.push_back(tempIdVsMomIdHisto);
200 +    histograms.push_back(tempIdVsGmaIdHisto);
201    }
202  
203  
# Line 209 | Line 231 | OSUAnalysis::OSUAnalysis (const edm::Par
231      TFileDirectory subDir = fs_->mkdir( channelName );
232      directories.push_back(subDir);
233  
234 <    std::map<std::string, TH1D*> oneDhistoMap;
234 >    map<string, TH1D*> oneDhistoMap;
235      oneDHists_.push_back(oneDhistoMap);
236 <    std::map<std::string, TH2D*> twoDhistoMap;
236 >    map<string, TH2D*> twoDhistoMap;
237      twoDHists_.push_back(twoDhistoMap);
238  
239  
# Line 221 | Line 243 | OSUAnalysis::OSUAnalysis (const edm::Par
243        histogram currentHistogram = histograms.at(currentHistogramIndex);
244        int numBinsElements = currentHistogram.bins.size();
245        int numInputVariables = currentHistogram.inputVariables.size();
246 +      int numBinEdgesX = currentHistogram.variableBinsX.size();
247 +      int numBinEdgesY = currentHistogram.variableBinsY.size();
248  
249 <      if(numBinsElements != 3 && numBinsElements !=6) {
250 <        std::cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
249 >      if(numBinsElements == 1){
250 >        if(numBinEdgesX > 1){
251 >          if(numBinEdgesY > 1)
252 >            numBinsElements = 6;
253 >          else
254 >            numBinsElements = 3;
255 >        }
256 >      }
257 >      if(numBinsElements != 3 && numBinsElements !=6){
258 >        cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
259          exit(0);
260        }
261        else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
262 <        std::cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
262 >        cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
263          exit(0);
264        }
265        else if(numBinsElements == 3){
266 <        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));
266 >        if (currentHistogram.bins.size () == 3)
267 >          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));
268 >        else
269 >          {
270 >            oneDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH1D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data ());
271 >          }
272        }
273        else if(numBinsElements == 6){
274 <        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));
275 <
274 >        if (currentHistogram.bins.size () == 6)
275 >          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));
276 >        else
277 >          twoDHists_.at(currentChannel)[currentHistogram.name] = directories.at(currentChannel).make<TH2D> (TString(currentHistogram.name),channelLabel+" channel: "+currentHistogram.title, numBinEdgesX - 1, currentHistogram.variableBinsX.data (), numBinEdgesY - 1, currentHistogram.variableBinsY.data ());
278        }
279  
280  
281 <      if(currentHistogram.name.find("GenMatch")==std::string::npos) continue;
281 >      if(currentHistogram.name.find("GenMatch")==string::npos) continue;
282  
283        // bin      particle type
284        // ---      -------------
# Line 295 | Line 334 | OSUAnalysis::OSUAnalysis (const edm::Par
334        labelArray.push_back("other");
335  
336        for(int bin = 0; bin !=currentHistogram.bins.at(0); bin++){
337 <        if(currentHistogram.name.find("GenMatchIdVsMotherId")==std::string::npos) {
338 <          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
339 <        }
340 <        else {
341 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
342 <          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
343 <        }
337 >        if(currentHistogram.name.find("GenMatchIdVsMotherId")==string::npos && currentHistogram.name.find("GenMatchIdVsGrandmotherId")==string::npos) {
338 >          oneDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
339 >        }
340 >        else {
341 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->SetBinLabel(bin+1,labelArray.at(currentHistogram.bins.at(0)-bin-1));
342 >          twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->SetBinLabel(bin+1,labelArray.at(bin));
343 >        }
344        }
345 <      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=std::string::npos) {
346 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
347 <        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
345 >      if(currentHistogram.name.find("GenMatchIdVsMotherId")!=string::npos || currentHistogram.name.find("GenMatchIdVsGrandmotherId")!=string::npos) {
346 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetXaxis()->CenterTitle();
347 >        twoDHists_.at(currentChannel)[currentHistogram.name]->GetYaxis()->CenterTitle();
348        }
349  
350      }
351  
352 <    // Book a histogram for the number of each object type to be plotted.  
353 <    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().  
352 >    // Book a histogram for the number of each object type to be plotted.
353 >    // Name of objectToPlot here must match the name specified in OSUAnalysis::analyze().
354      for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
355        string currentObject = objectsToPlot.at(currentObjectIndex);
356        int maxNum = 10;
# Line 321 | Line 360 | OSUAnalysis::OSUAnalysis (const edm::Par
360        if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
361        else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
362        else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
363 +      else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
364 +      else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
365 +      else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
366        else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
367 <      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";        
368 <      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";    
369 <      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";      
367 >      else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
368 >      else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
369 >      else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
370        else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
371        else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
372        else if(currentObject == "muon-secondary muon pairs") currentObject = "muonSecondaryMuonPairs";
373        else if(currentObject == "secondary muons")           currentObject = "secondaryMuons";
374 +      else if(currentObject == "electron-secondary electron pairs") currentObject = "electronSecondaryElectronPairs";
375 +      else if(currentObject == "secondary electrons")           currentObject = "secondaryElectrons";
376 +      else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
377 +      else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
378  
379 <      currentObject.at(0) = toupper(currentObject.at(0));  
379 >      currentObject.at(0) = toupper(currentObject.at(0));
380        string histoName = "num" + currentObject;
381  
382        if(histoName == "numPrimaryvertexs"){
# Line 355 | Line 401 | OSUAnalysis::OSUAnalysis (const edm::Par
401        //store input collection for cut
402        string tempInputCollection = cuts_.at(currentCut).getParameter<string> ("inputCollection");
403        if(tempInputCollection == "muon-electron pairs") tempInputCollection = "electron-muon pairs";
404 +      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
405 +      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
406        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
407        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
408 +      if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
409 +      if(tempInputCollection == "trigobj-electron pairs")   tempInputCollection = "electron-trigobj pairs";
410 +      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
411        tempCut.inputCollection = tempInputCollection;
412 <      if(tempInputCollection.find("pairs")==std::string::npos){ //just a single object
413 <        if(tempInputCollection.find("secondary")!=std::string::npos){//secondary object
414 <          int spaceIndex = tempInputCollection.find(" ");
415 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
416 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
417 <        }
418 <        else{
419 <          objectsToGet.push_back(tempInputCollection);
420 <        }
421 <        objectsToCut.push_back(tempInputCollection);
412 >      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
413 >        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
414 >          int spaceIndex = tempInputCollection.find(" ");
415 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
416 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
417 >        }
418 >        else{
419 >          objectsToGet.push_back(tempInputCollection);
420 >        }
421 >        objectsToCut.push_back(tempInputCollection);
422        }
423        else{//pair of objects, need to add them both to objectsToGet
424 <        string obj1;
425 <        string obj2;
426 <        getTwoObjs(tempInputCollection, obj1, obj2);
427 <        string obj2ToGet = getObjToGet(obj2);  
424 >        string obj1;
425 >        string obj2;
426 >        getTwoObjs(tempInputCollection, obj1, obj2);
427 >        string obj2ToGet = getObjToGet(obj2);
428          objectsToCut.push_back(tempInputCollection);
429          objectsToCut.push_back(obj1);
430 <        objectsToCut.push_back(obj2);  
430 >        objectsToCut.push_back(obj2);
431          objectsToGet.push_back(tempInputCollection);
432          objectsToGet.push_back(obj1);
433          objectsToGet.push_back(obj2ToGet);
# Line 387 | Line 438 | OSUAnalysis::OSUAnalysis (const edm::Par
438  
439        //split cut string into parts and store them
440        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
441 <      std::vector<string> cutStringVector = splitString(cutString);
441 >      vector<string> cutStringVector = splitString(cutString);
442        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
443 <        std::cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
443 >        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
444          exit(0);
445        }
446        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
447        for(int subcutIndex = 0; subcutIndex != tempCut.numSubcuts; subcutIndex++){//loop over all the pieces of the cut combined using &,|
448          int indexOffset = 4 * subcutIndex;
449          string currentVariableString = cutStringVector.at(indexOffset);
450 <        if(currentVariableString.find("(")==std::string::npos){
450 >        if(currentVariableString.find("(")==string::npos){
451            tempCut.functions.push_back("");//no function was specified
452            tempCut.variables.push_back(currentVariableString);// variable to cut on
453          }
# Line 407 | Line 458 | OSUAnalysis::OSUAnalysis (const edm::Par
458          }
459          tempCut.comparativeOperators.push_back(cutStringVector.at(indexOffset+1));// comparison to make
460          tempCut.cutValues.push_back(atof(cutStringVector.at(indexOffset+2).c_str()));// threshold value to pass cut
461 +        tempCut.cutStringValues.push_back(cutStringVector.at(indexOffset+2));// string value to pass cut
462          if(subcutIndex != 0) tempCut.logicalOperators.push_back(cutStringVector.at(indexOffset-1)); // logical comparison (and, or)
463        }
464  
465        //get number of objects required to pass cut for event to pass
466        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
467 <      std::vector<string> numberRequiredVector = splitString(numberRequiredString);
467 >      vector<string> numberRequiredVector = splitString(numberRequiredString);
468        if(numberRequiredVector.size()!=2){
469 <        std::cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
469 >        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
470          exit(0);
471        }
472  
# Line 472 | Line 524 | OSUAnalysis::analyze (const edm::Event &
524  
525    // Retrieve necessary collections from the event.
526  
527 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
527 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
528      event.getByLabel (triggers_, triggers);
529  
530 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
530 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
531 >    event.getByLabel (trigobjs_, trigobjs);
532 >
533 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
534      event.getByLabel (jets_, jets);
535  
536 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
536 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
537      event.getByLabel (muons_, muons);
538  
539 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
539 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
540      event.getByLabel (electrons_, electrons);
541  
542 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
542 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
543      event.getByLabel (events_, events);
544  
545 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
545 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
546      event.getByLabel (taus_, taus);
547  
548 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
548 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
549      event.getByLabel (mets_, mets);
550  
551 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
551 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
552      event.getByLabel (tracks_, tracks);
553  
554 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
554 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
555      event.getByLabel (genjets_, genjets);
556  
557 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
557 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
558      event.getByLabel (mcparticles_, mcparticles);
559  
560 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
560 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
561      event.getByLabel (primaryvertexs_, primaryvertexs);
562  
563 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
563 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
564      event.getByLabel (bxlumis_, bxlumis);
565  
566 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
566 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
567      event.getByLabel (photons_, photons);
568  
569 <  if (std::find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
569 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
570      event.getByLabel (superclusters_, superclusters);
571  
572 <  if (useTrackCaloRhoCorr_) {  
573 <    // Used only for pile-up correction of by-hand calculation of isolation energy.  
574 <    // This rho collection is not available in all BEANs.  
572 >  if (datasetType_ == "signalMC"){
573 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
574 >      event.getByLabel (stops_, stops);
575 >  }
576 >
577 >  if (useTrackCaloRhoCorr_) {
578 >    // Used only for pile-up correction of by-hand calculation of isolation energy.
579 >    // This rho collection is not available in all BEANs.
580      // For description of rho values for different jet reconstruction algorithms, see
581 <    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms  
582 <    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
581 >    // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
582 >    event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
583    }
584  
585 +  double masterScaleFactor = 1.0;
586  
587    //get pile-up event weight
588 <  double scaleFactor = 1.00;
589 <  if(doPileupReweighting_ && datasetType_ != "data")
590 <    scaleFactor = puWeight_->at (events->at (0).numTruePV);
591 <
592 <  cTauScaleFactor_ = 1.0;
593 < #ifdef DISPLACED_SUSY
533 <  if (datasetType_ == "signalMC")
534 <    cTauScaleFactor_ = cTauWeight_->at (event);
535 < #endif
536 <  scaleFactor *= cTauScaleFactor_;
588 >  if(doPileupReweighting_ && datasetType_ != "data") masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
589 >
590 >  stopCTauScaleFactor_ = 1.0;
591 >  if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
592 >    stopCTauScaleFactor_ = stopCTauWeight_->at (event);
593 >  masterScaleFactor *= stopCTauScaleFactor_;
594  
595    //loop over all channels
596  
# Line 552 | Line 609 | OSUAnalysis::analyze (const edm::Event &
609  
610      //loop over all cuts
611  
555
556
612      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
613        cut currentCut = currentChannel.cuts.at(currentCutIndex);
614  
# Line 576 | Line 631 | OSUAnalysis::analyze (const edm::Event &
631          else if(currentObject == "muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
632  
633          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
634 +        else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
635          else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
636          else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
637          else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
# Line 587 | Line 643 | OSUAnalysis::analyze (const edm::Event &
643          else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
644          else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
645          else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
646 +        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
647 +
648  
649  
650          else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
# Line 599 | Line 657 | OSUAnalysis::analyze (const edm::Event &
657                                                                     cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
658                                                                     "muon-secondary muon pairs");
659  
660 +        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
661 +                                                                   cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
662 +                                                                   cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
663 +                                                                   "electron-secondary electron pairs");
664 +
665          else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
666                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
667                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
# Line 607 | Line 670 | OSUAnalysis::analyze (const edm::Event &
670                                                                         cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
671                                                                         cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
672                                                                         "electron-muon pairs");
673 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
674 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
675 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
676 <                                                                     "track-event pairs");
677 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
678 <                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
679 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
680 <                                                                        "electron-track pairs");
681 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
682 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
683 <                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
684 <                                                                    "muon-track pairs");
685 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
686 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
687 <                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
688 <                                                                  "muon-tau pairs");
689 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
690 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
691 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
692 <                                                                 "tau-tau pairs");
693 <        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
673 >        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
674 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
675 >                                                                           cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
676 >                                                                           "jet-jet pairs");
677 >        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
678 >                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
679 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
680 >                                                                       "electron-jet pairs");
681 >        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
682 >                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
683 >                                                                       cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
684 >                                                                       "muon-jet pairs");
685 >        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
686 >                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
687 >                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
688 >                                                                     "track-event pairs");
689 >        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
690 >                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
691 >                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
692 >                                                                        "electron-track pairs");
693 >        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
694 >                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
695 >                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
696 >                                                                    "muon-track pairs");
697 >        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
698 >                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
699 >                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
700 >                                                                  "muon-tau pairs");
701 >        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
702 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
703 >                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
704 >                                                                 "tau-tau pairs");
705 >        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
706                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
707                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
708                                                                   "tau-track pairs");
709 <        
710 <        
709 >        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
710 >                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
711 >                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
712 >                                                                          "electron-trigobj pairs");
713 >        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
714 >                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
715 >                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
716 >                                                                      "muon-trigobj pairs");
717 >
718 >        if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
719        }
720  
721  
# Line 655 | Line 738 | OSUAnalysis::analyze (const edm::Event &
738        int numberPassing = 0;
739  
740        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
741 <        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
741 >        if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object)) numberPassing++;
742        }
743        bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
744        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
# Line 663 | Line 746 | OSUAnalysis::analyze (const edm::Event &
746  
747      }
748  
749 <    //     if(datasetType_ != "data") {
667 <    //       scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
668 <    //       scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
669 <    //     }
670 <
671 <    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
749 >    double scaleFactor = masterScaleFactor;
750  
751 +    if(applyLeptonSF_ && datasetType_ != "data"){
752 +      if (chosenMuon ()) scaleFactor *= muonSFWeight_->at (chosenMuon ()->eta);
753 +      if (chosenElectron ()) scaleFactor *= electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
754 +    }
755  
756 +    cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
757  
758      if(!eventPassedAllCuts)continue;
759  
760      if (printEventInfo_) {
761 <      // Write information about event to screen, for testing purposes.  
762 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
763 <           << ": run="  << events->at(0).run
764 <           << "  lumi=" << events->at(0).lumi
765 <           << "  event=" << events->at(0).evt
766 <           << endl;  
761 >      // Write information about event to screen, for testing purposes.
762 >      cout << "Event passed all cuts in channel " <<  currentChannel.name
763 >           << ": run="  << events->at(0).run
764 >           << "  lumi=" << events->at(0).lumi
765 >           << "  event=" << events->at(0).evt
766 >           << endl;
767      }
768  
686
769      //filling histograms
770      for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
771        histogram currentHistogram = histograms.at(histogramIndex);
# Line 693 | Line 775 | OSUAnalysis::analyze (const edm::Event &
775          histo = oneDHists_.at(currentChannelIndex).at(currentHistogram.name);
776  
777          if(currentHistogram.inputCollection == "jets") fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").back(),scaleFactor);
778 <        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
779 <        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
778 >        else if(currentHistogram.inputCollection == "muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").back(),scaleFactor);
779 >        else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").back(),scaleFactor);
780 >        else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
781          else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
782                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
783                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
# Line 705 | Line 788 | OSUAnalysis::analyze (const edm::Event &
788          else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
789                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(),\
790                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
791 +        else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
792 +                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(),\
793 +                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
794 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
795 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
796 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
797          else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
798 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
799 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
800 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),        
801 <                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),  
802 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
803 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),        
804 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),  
805 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
806 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),    
807 <                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
808 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
809 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),      
810 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
811 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
812 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
798 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(),
799 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
800 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
801 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(),
802 >                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
803 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
804 >                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(),
805 >                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
806 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
807 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
808 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
809 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
810 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
811 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
812 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
813 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
814 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
815 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
816 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
817 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
818 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
819                                                                                       cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
820                                                                                       cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
821 +        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
822 +                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(),
823 +                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
824 +        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
825 +                                                                                          cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(),
826 +                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
827  
828          else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
829          else if(currentHistogram.inputCollection == "taus") fill1DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
# Line 734 | Line 835 | OSUAnalysis::analyze (const edm::Event &
835          else if(currentHistogram.inputCollection == "bxlumis") fill1DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
836          else if(currentHistogram.inputCollection == "photons") fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
837          else if(currentHistogram.inputCollection == "superclusters") fill1DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
838 +        else if(currentHistogram.inputCollection == "trigobjs") fill1DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
839 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill1DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
840        }
841        else if(currentHistogram.inputVariables.size() == 2){
842          TH2D* histo;
# Line 745 | Line 848 | OSUAnalysis::analyze (const edm::Event &
848          else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
849                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("muons").back(), \
850                                                                                         cumulativeFlags.at("muon-muon pairs").back(),scaleFactor);
851 <        else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
851 >        else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
852                                                                                         cumulativeFlags.at("muons").back(),cumulativeFlags.at("secondary muons").back(), \
853                                                                                         cumulativeFlags.at("muon-secondary muon pairs").back(),scaleFactor);
854          else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").back(),scaleFactor);
855 +        else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").back(),scaleFactor);
856          else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
857                                                                                                 cumulativeFlags.at("electrons").back(),cumulativeFlags.at("electrons").back(), \
858                                                                                                 cumulativeFlags.at("electron-electron pairs").back(),scaleFactor);
859 +        else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
860 +                                                                                               cumulativeFlags.at("jets").back(),cumulativeFlags.at("jets").back(), \
861 +                                                                                               cumulativeFlags.at("jet-jet pairs").back(),scaleFactor);
862 +        else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
863 +                                                                                       cumulativeFlags.at("electrons").back(),cumulativeFlags.at("secondary electrons").back(), \
864 +                                                                                       cumulativeFlags.at("electron-secondary electron pairs").back(),scaleFactor);
865          else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
866 <                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
867 <                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
868 <        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),        
869 <                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),          
870 <                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);      
871 <        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),        
872 <                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),          
873 <                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);      
874 <        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),    
875 <                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),      
876 <                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);  
877 <        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),      
878 <                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),        
879 <                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);    
880 <        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
866 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("muons").back(), \
867 >                                                                                           cumulativeFlags.at("electron-muon pairs").back(),scaleFactor);
868 >        else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
869 >                                                                                           cumulativeFlags.at("electrons").back(),cumulativeFlags.at("jets").back(), \
870 >                                                                                           cumulativeFlags.at("electron-jet pairs").back(),scaleFactor);
871 >        else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
872 >                                                                                           cumulativeFlags.at("muons").back(),cumulativeFlags.at("jets").back(), \
873 >                                                                                           cumulativeFlags.at("muon-jet pairs").back(),scaleFactor);
874 >        else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
875 >                                                                                            cumulativeFlags.at("electrons").back(),cumulativeFlags.at("tracks").back(),
876 >                                                                                            cumulativeFlags.at("electron-track pairs").back(),scaleFactor);
877 >        else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
878 >                                                                                        cumulativeFlags.at("muons").back(),cumulativeFlags.at("tracks").back(),
879 >                                                                                        cumulativeFlags.at("muon-track pairs").back(),scaleFactor);
880 >        else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
881 >                                                                                      cumulativeFlags.at("muons").back(),cumulativeFlags.at("taus").back(),
882 >                                                                                      cumulativeFlags.at("muon-tau pairs").back(),scaleFactor);
883 >        else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
884 >                                                                                     cumulativeFlags.at("taus").back(),cumulativeFlags.at("taus").back(),
885 >                                                                                     cumulativeFlags.at("tau-tau pairs").back(),scaleFactor);
886 >        else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
887                                                                                       cumulativeFlags.at("taus").back(),cumulativeFlags.at("tracks").back(),
888                                                                                       cumulativeFlags.at("tau-track pairs").back(),scaleFactor);
889 <        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
889 >        else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
890 >                                                                                              cumulativeFlags.at("electrons").back(),cumulativeFlags.at("trigobjs").back(),
891 >                                                                                              cumulativeFlags.at("electron-trigobj pairs").back(),scaleFactor);
892 >        else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
893 >                                                                                          cumulativeFlags.at("muons").back(),cumulativeFlags.at("trigobjs").back(),
894 >                                                                                          cumulativeFlags.at("muon-trigobj pairs").back(),scaleFactor);
895 >        else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").back(),scaleFactor);
896          else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").back(),scaleFactor);
897          else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").back(),scaleFactor);
898          else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").back(),scaleFactor);
899 <        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
900 <                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
901 <                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);  
899 >        else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
900 >                                                                                         cumulativeFlags.at("tracks").back(),cumulativeFlags.at("events").back(),
901 >                                                                                         cumulativeFlags.at("track-event pairs").back(),scaleFactor);
902          else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").back(),scaleFactor);
903          else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").back(),scaleFactor);
904          else if(currentHistogram.inputCollection == "primaryvertexs") fill2DHistogram(histo,currentHistogram,primaryvertexs.product(),cumulativeFlags.at("primaryvertexs").back(),scaleFactor);
905          else if(currentHistogram.inputCollection == "bxlumis") fill2DHistogram(histo,currentHistogram,bxlumis.product(),cumulativeFlags.at("bxlumis").back(),scaleFactor);
906          else if(currentHistogram.inputCollection == "photons") fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("photons").back(),scaleFactor);
907          else if(currentHistogram.inputCollection == "superclusters") fill2DHistogram(histo,currentHistogram,superclusters.product(),cumulativeFlags.at("superclusters").back(),scaleFactor);
908 +        else if(currentHistogram.inputCollection == "trigobjs") fill2DHistogram(histo,currentHistogram,trigobjs.product(),cumulativeFlags.at("trigobjs").back(),scaleFactor);
909 +        else if(currentHistogram.inputCollection == "stops" && datasetType_ == "signalMC") fill2DHistogram(histo,currentHistogram,stops.product(),cumulativeFlags.at("stops").back(),scaleFactor);
910        }
911      }
912  
# Line 793 | Line 917 | OSUAnalysis::analyze (const edm::Event &
917  
918        string currentObject = objectsToPlot.at(currentObjectIndex);
919  
920 <      string objectToPlot = "";  
920 >      string objectToPlot = "";
921  
922 <      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().  
923 <      if(currentObject == "muon-muon pairs") objectToPlot = "dimuonPairs";
924 <      else if(currentObject == "electron-electron pairs") objectToPlot = "dielectronPairs";
925 <      else if(currentObject == "electron-muon pairs")     objectToPlot = "electronMuonPairs";
926 <      else if(currentObject == "electron-track pairs")    objectToPlot = "electronTrackPairs";
927 <      else if(currentObject == "muon-track pairs")        objectToPlot = "muonTrackPairs";      
928 <      else if(currentObject == "muon-tau pairs")          objectToPlot = "muonTauPairs";        
929 <      else if(currentObject == "tau-tau pairs")           objectToPlot = "ditauPairs";
930 <      else if(currentObject == "tau-track pairs")         objectToPlot = "tauTrackPairs";
931 <      else if(currentObject == "track-event pairs")       objectToPlot = "trackEventPairs";  
932 <      else if(currentObject == "muon-secondary muon pairs")       objectToPlot = "muonSecondaryMuonPairs";  
933 <      else if(currentObject == "secondary muons")         objectToPlot = "secondaryMuons";  
922 >      // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
923 >      if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
924 >      else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
925 >      else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
926 >      else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
927 >      else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
928 >      else if(currentObject == "jet-jet pairs")            objectToPlot = "dijetPairs";
929 >      else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
930 >      else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
931 >      else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
932 >      else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
933 >      else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
934 >      else if(currentObject == "track-event pairs")                  objectToPlot = "trackEventPairs";
935 >      else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
936 >      else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
937 >      else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
938 >      else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
939 >      else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
940 >      else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
941        else objectToPlot = currentObject;
942  
943        string tempCurrentObject = objectToPlot;
944 <      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));  
944 >      tempCurrentObject.at(0) = toupper(tempCurrentObject.at(0));
945        string histoName = "num" + tempCurrentObject;
946  
947        //set position of primary vertex in event, in order to calculate quantities relative to it
948 <      if(std::find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
948 >      if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
949          vector<bool> lastCutFlags = cumulativeFlags.at(currentObject).back();
950 <        int numToPlot = 0;
950 >        int numToPlot = 0;
951          for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
952            if(lastCutFlags.at(currentFlag)) numToPlot++;
953          }
# Line 826 | Line 957 | OSUAnalysis::analyze (const edm::Event &
957          }
958          else {
959            oneDHists_.at(currentChannelIndex).at(histoName)->Fill(numToPlot,scaleFactor);
960 <        }
960 >        }
961        }
962        else if(objectToPlot == "jets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(jets->size(),scaleFactor);
963        else if(objectToPlot == "muons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size(),scaleFactor);
# Line 834 | Line 965 | OSUAnalysis::analyze (const edm::Event &
965        else if(objectToPlot == "dimuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
966        else if(objectToPlot == "muonSecondaryMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*(muons->size()-1)/2,scaleFactor);
967        else if(objectToPlot == "electrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
968 +      else if(objectToPlot == "secondaryElectrons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size(),scaleFactor);
969        else if(objectToPlot == "dielectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
970 +      else if(objectToPlot == "electronSecondaryElectronPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*(electrons->size()-1)/2,scaleFactor);
971        else if(objectToPlot == "electronMuonPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*muons->size(),scaleFactor);
972 +      else if(objectToPlot == "electronJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*jets->size(),scaleFactor);
973 +      else if(objectToPlot == "muonJetPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*jets->size(),scaleFactor);
974        else if(objectToPlot == "electronTrackPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*tracks->size(),scaleFactor);
975 +      else if(objectToPlot == "electronTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(electrons->size()*trigobjs->size(),scaleFactor);
976 +      else if(objectToPlot == "muonTrigobjPairs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(muons->size()*trigobjs->size(),scaleFactor);
977        else if(objectToPlot == "events") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(events->size(),scaleFactor);
978        else if(objectToPlot == "taus") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(taus->size(),scaleFactor);
979        else if(objectToPlot == "mets") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(mets->size(),scaleFactor);
# Line 846 | Line 983 | OSUAnalysis::analyze (const edm::Event &
983        else if(objectToPlot == "bxlumis") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(bxlumis->size(),scaleFactor);
984        else if(objectToPlot == "photons") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(photons->size(),scaleFactor);
985        else if(objectToPlot == "superclusters") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(superclusters->size(),scaleFactor);
986 +      else if(objectToPlot == "trigobjs") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(trigobjs->size(),scaleFactor);
987        else if(objectToPlot == "primaryvertexs"){
988          oneDHists_.at(currentChannelIndex).at(histoName+"BeforePileupCorrection")->Fill(primaryvertexs->size());
989          oneDHists_.at(currentChannelIndex).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
990 <      }
990 >      }
991 >      if(objectToPlot == "stops" && datasetType_ == "signalMC") oneDHists_.at(currentChannelIndex).at(histoName)->Fill(stops->size(),scaleFactor);
992  
993 <    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
993 >    } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
994  
995    } //end loop over channel
996  
997 <  masterCutFlow_->fillCutFlow(scaleFactor);
997 >  masterCutFlow_->fillCutFlow(masterScaleFactor);
998  
999   } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1000  
# Line 872 | Line 1011 | OSUAnalysis::evaluateComparison (double
1011    else if(comparison == "==") return testValue == cutValue;
1012    else if(comparison == "=") return testValue == cutValue;
1013    else if(comparison == "!=") return testValue != cutValue;
1014 <  else {std::cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1014 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1015 >
1016 > }
1017 >
1018 > bool
1019 > OSUAnalysis::evaluateComparison (string testValue, string comparison, string cutValue){
1020 >
1021 >
1022 >  if(comparison == ">")       return testValue >  cutValue;
1023 >  else if(comparison == ">=") return testValue >= cutValue;
1024 >  else if(comparison == "<")  return testValue <  cutValue;
1025 >  else if(comparison == "<=") return testValue <= cutValue;
1026 >  else if(comparison == "==") return testValue == cutValue;
1027 >  else if(comparison == "=") return testValue == cutValue;
1028 >  else if(comparison == "!=") return testValue != cutValue;
1029 >  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1030  
1031   }
1032  
# Line 886 | Line 1040 | OSUAnalysis::evaluateTriggers (vector<st
1040        if(trigger->pass != 1) continue;
1041        for(uint triggerName = 0; triggerName != triggersToTest.size(); triggerName++)
1042          {
1043 <          if(trigger->name.find(triggersToTest.at(triggerName))!=std::string::npos){
1043 >          if(trigger->name.find(triggersToTest.at(triggerName))!=string::npos){
1044              triggerDecision = true;
1045            }
1046          }
# Line 895 | Line 1049 | OSUAnalysis::evaluateTriggers (vector<st
1049  
1050   }
1051  
1052 < std::vector<std::string>
1052 > vector<string>
1053   OSUAnalysis::splitString (string inputString){
1054  
1055 <  std::stringstream stringStream(inputString);
1056 <  std::istream_iterator<std::string> begin(stringStream);
1057 <  std::istream_iterator<std::string> end;
1058 <  std::vector<std::string> stringVector(begin, end);
1055 >  stringstream stringStream(inputString);
1056 >  istream_iterator<string> begin(stringStream);
1057 >  istream_iterator<string> end;
1058 >  vector<string> stringVector(begin, end);
1059    return stringVector;
1060  
1061   }
1062  
1063  
1064   void OSUAnalysis::getTwoObjs(string tempInputCollection, string& obj1, string& obj2) {
1065 <  // Set two object strings from the tempInputCollection string,
1066 <  // For example, if tempInputCollection is "electron-muon pairs",
1067 <  // then obj1 = "electrons" and obj2 = "muons".  
1068 <  // Note that the objects have an "s" appended.  
1065 >  // Set two object strings from the tempInputCollection string,
1066 >  // For example, if tempInputCollection is "electron-muon pairs",
1067 >  // then obj1 = "electrons" and obj2 = "muons".
1068 >  // Note that the objects have an "s" appended.
1069  
1070    int dashIndex = tempInputCollection.find("-");
1071    int spaceIndex = tempInputCollection.find_last_of(" ");
1072    int secondWordLength = spaceIndex - dashIndex;
1073 <  obj1 = tempInputCollection.substr(0,dashIndex) + "s";  
1073 >  obj1 = tempInputCollection.substr(0,dashIndex) + "s";
1074    obj2 = tempInputCollection.substr(dashIndex+1,secondWordLength-1)+"s";
1075 <  
1076 < }
1075 >
1076 > }
1077  
1078  
1079   string OSUAnalysis::getObjToGet(string obj) {
1080    // Return the string corresponding to the object to get for the given obj string.
1081 <  // Right now this only handles the case in which obj contains "secondary",
1082 <  // e.g, "secondary muons".  
1083 <  // Note that "s" is NOT appended.  
930 <  
931 <  if (obj.find("secondary")==std::string::npos) return obj;  // "secondary" is not found  
932 <  int firstSpaceIndex = obj.find_first_of(" ");  
933 <  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1081 >  // Right now this only handles the case in which obj contains "secondary",
1082 >  // e.g, "secondary muons".
1083 >  // Note that "s" is NOT appended.
1084  
1085 < }  
1085 >  if (obj.find("secondary")==string::npos) return obj;  // "secondary" is not found
1086 >  int firstSpaceIndex = obj.find_first_of(" ");
1087 >  return obj.substr(firstSpaceIndex+1,obj.length()-1);
1088  
1089 + }
1090  
1091  
1092 + //!jet valueLookup
1093   double
1094 < OSUAnalysis::valueLookup (const BNjet* object, string variable, string function){
1094 > OSUAnalysis::valueLookup (const BNjet* object, string variable, string function, string &stringValue){
1095  
1096    double value = 0.0;
1097    if(variable == "energy") value = object->energy;
# Line 1057 | Line 1211 | OSUAnalysis::valueLookup (const BNjet* o
1211    else if(variable == "puJetId_loose_cutbased") value = object->puJetId_loose_cutbased;
1212  
1213  
1214 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1214 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1215  
1216    value = applyFunction(function, value);
1217  
# Line 1065 | Line 1219 | OSUAnalysis::valueLookup (const BNjet* o
1219   }
1220  
1221  
1222 <
1222 > //!muon valueLookup
1223   double
1224 < OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function){
1224 > OSUAnalysis::valueLookup (const BNmuon* object, string variable, string function, string &stringValue){
1225  
1226    double value = 0.0;
1227    if(variable == "energy") value = object->energy;
# Line 1232 | Line 1386 | OSUAnalysis::valueLookup (const BNmuon*
1386      if (met)
1387        {
1388          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1389 <          p2 (met->px, met->py, 0.0, met->pt);
1389 >          p2 (met->px, met->py, 0.0, met->pt);
1390  
1391          value = (p1 + p2).Mt ();
1392        }
# Line 1352 | Line 1506 | OSUAnalysis::valueLookup (const BNmuon*
1506      value = object->isGlobalMuon > 0                \
1507        && object->isPFMuon > 0                        \
1508        && object->normalizedChi2 < 10                \
1509 <                                  && object->numberOfValidMuonHits > 0        \
1509 >                                  && object->numberOfValidMuonHits > 0        \
1510        && object->numberOfMatchedStations > 1        \
1511        && fabs(object->correctedD0Vertex) < 0.2        \
1512        && fabs(object->correctedDZ) < 0.5        \
# Line 1362 | Line 1516 | OSUAnalysis::valueLookup (const BNmuon*
1516    else if(variable == "tightIDdisplaced"){
1517      value = object->isGlobalMuon > 0                \
1518        && object->normalizedChi2 < 10                \
1519 <                                  && object->numberOfValidMuonHits > 0        \
1519 >                                  && object->numberOfValidMuonHits > 0        \
1520        && object->numberOfMatchedStations > 1        \
1521        && object->numberOfValidPixelHits > 0        \
1522        && object->numberOfLayersWithMeasurement > 5;
1523    }
1524  
1525 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1525 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1526  
1527    else if(variable == "genMatchedPdgId"){
1528      int index = getGenMatchedParticleIndex(object);
# Line 1389 | Line 1543 | OSUAnalysis::valueLookup (const BNmuon*
1543    else if(variable == "genMatchedMotherIdReverse"){
1544      int index = getGenMatchedParticleIndex(object);
1545      if(index == -1) value = 23;
1546 <    else value = 23 -getPdgIdBinValue(mcparticles->at(index).motherId);
1546 >    else value = 23 - getPdgIdBinValue(mcparticles->at(index).motherId);
1547    }
1548    else if(variable == "genMatchedGrandmotherId"){
1549      int index = getGenMatchedParticleIndex(object);
# Line 1401 | Line 1555 | OSUAnalysis::valueLookup (const BNmuon*
1555      }
1556      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1557    }
1558 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1559 +    int index = getGenMatchedParticleIndex(object);
1560 +    if(index == -1) value = 23;
1561 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1562 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1563 +      if(motherIndex == -1) value = 23;
1564 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1565 +    }
1566 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1567 +  }
1568  
1569  
1570  
1571 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1571 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1572  
1573    value = applyFunction(function, value);
1574  
1575    return value;
1576   }
1577  
1578 <
1578 > //!electron valueLookup
1579   double
1580 < OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function){
1580 > OSUAnalysis::valueLookup (const BNelectron* object, string variable, string function, string &stringValue){
1581  
1582    double value = 0.0;
1583    if(variable == "energy") value = object->energy;
# Line 1583 | Line 1747 | OSUAnalysis::valueLookup (const BNelectr
1747      if (met)
1748        {
1749          TLorentzVector p1 (object->px, object->py, object->pz, object->energy),
1750 <          p2 (met->px, met->py, 0.0, met->pt);
1750 >          p2 (met->px, met->py, 0.0, met->pt);
1751  
1752          value = (p1 + p2).Mt ();
1753        }
# Line 1750 | Line 1914 | OSUAnalysis::valueLookup (const BNelectr
1914    }
1915  
1916  
1917 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1917 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
1918  
1919    else if(variable == "genMatchedPdgId"){
1920      int index = getGenMatchedParticleIndex(object);
# Line 1784 | Line 1948 | OSUAnalysis::valueLookup (const BNelectr
1948      }
1949      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1950    }
1951 +  else if(variable == "genMatchedGrandmotherIdReverse"){
1952 +    int index = getGenMatchedParticleIndex(object);
1953 +    if(index == -1) value = 23;
1954 +    else if(fabs(mcparticles->at(index).motherId) == 15){
1955 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
1956 +      if(motherIndex == -1) value = 23;
1957 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
1958 +    }
1959 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
1960 +  }
1961  
1962  
1963  
1964 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1964 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1965  
1966    value = applyFunction(function, value);
1967  
1968    return value;
1969   }
1970  
1971 <
1971 > //!event valueLookup
1972   double
1973 < OSUAnalysis::valueLookup (const BNevent* object, string variable, string function){
1973 > OSUAnalysis::valueLookup (const BNevent* object, string variable, string function, string &stringValue){
1974  
1975    double value = 0.0;
1976  
# Line 1871 | Line 2045 | OSUAnalysis::valueLookup (const BNevent*
2045        value = 1.0;
2046    }
2047    else if(variable == "muonScaleFactor"){
2048 <    if(datasetType_ != "data")
2049 <      //      value = muonSFWeight_->at (chosenMuon ()->eta);
1876 <      value = 1.0;
2048 >    if(datasetType_ != "data" && applyLeptonSF_)
2049 >      value = muonSFWeight_->at (chosenMuon ()->eta);
2050      else
2051        value = 1.0;
2052    }
2053    else if(variable == "electronScaleFactor"){
2054 <    if(datasetType_ != "data")
2055 <      //      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
1883 <      value = 1.0;
2054 >    if(datasetType_ != "data" && applyLeptonSF_)
2055 >      value = electronSFWeight_->at (chosenElectron ()->eta, chosenElectron ()->pt);
2056      else
2057        value = 1.0;
2058    }
2059 <  else if(variable == "cTauScaleFactor")
2060 <    value = cTauScaleFactor_;
2059 >  else if(variable == "stopCTauScaleFactor")
2060 >    value = stopCTauScaleFactor_;
2061  
2062 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2062 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2063  
2064    value = applyFunction(function, value);
2065  
2066    return value;
2067   }
2068  
2069 + //!tau valueLookup
2070   double
2071 < OSUAnalysis::valueLookup (const BNtau* object, string variable, string function){
2071 > OSUAnalysis::valueLookup (const BNtau* object, string variable, string function, string &stringValue){
2072  
2073    double value = 0.0;
2074  
# Line 1941 | Line 2114 | OSUAnalysis::valueLookup (const BNtau* o
2114  
2115  
2116  
2117 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2117 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2118  
2119    else if(variable == "genMatchedPdgId"){
2120      int index = getGenMatchedParticleIndex(object);
# Line 1974 | Line 2147 | OSUAnalysis::valueLookup (const BNtau* o
2147      }
2148      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2149    }
2150 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2151 +    int index = getGenMatchedParticleIndex(object);
2152 +    if(index == -1) value = 23;
2153 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2154 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2155 +      if(motherIndex == -1) value = 23;
2156 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2157 +    }
2158 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2159 +  }
2160  
2161  
2162 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2162 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2163  
2164    value = applyFunction(function, value);
2165  
2166    return value;
2167   }
2168  
2169 + //!met valueLookup
2170   double
2171 < OSUAnalysis::valueLookup (const BNmet* object, string variable, string function){
2171 > OSUAnalysis::valueLookup (const BNmet* object, string variable, string function, string &stringValue){
2172  
2173    double value = 0.0;
2174  
# Line 2048 | Line 2232 | OSUAnalysis::valueLookup (const BNmet* o
2232    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2233    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2234  
2235 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2235 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2236  
2237    value = applyFunction(function, value);
2238  
2239    return value;
2240   }
2241  
2242 + //!track valueLookup
2243   double
2244 < OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function){
2244 > OSUAnalysis::valueLookup (const BNtrack* object, string variable, string function, string &stringValue){
2245  
2246    double value = 0.0;
2247    double pMag = sqrt(object->pt * object->pt +
2248 <                     object->pz * object->pz);
2249 <  
2248 >                     object->pz * object->pz);
2249 >
2250    if(variable == "pt") value = object->pt;
2251    else if(variable == "px") value = object->px;
2252    else if(variable == "py") value = object->py;
# Line 2082 | Line 2267 | OSUAnalysis::valueLookup (const BNtrack*
2267  
2268  
2269    //additional BNs info for disappTrks
2085  else if(variable == "isGoodPtResolution") value = object->isGoodPtResolution;
2270    else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2271    else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2272    else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2273    else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2274    else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2275    else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2276 +  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2277    else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2278    else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2279    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2280 <  
2280 >  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2281  
2282    //user defined variables
2283    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;
2284    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2285 +  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2286    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2287    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2288 <  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);  
2289 <  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;  
2288 >  else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2289 >  else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2290    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2291    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2292    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
2293    else if(variable == "ptError")                    value = object->ptError;
2294    else if(variable == "ptRes")                      value = getTrkPtRes(object);
2295 <  else if (variable == "d0wrtPV"){      
2296 <    double vx = object->vx - chosenVertex ()->x,        
2297 <      vy = object->vy - chosenVertex ()->y,      
2298 <      px = object->px,  
2299 <      py = object->py,  
2300 <      pt = object->pt;  
2301 <    value = (-vx * py + vy * px) / pt;  
2302 <  }      
2303 <  else if (variable == "dZwrtPV"){      
2304 <    double vx = object->vx - chosenVertex ()->x,        
2305 <      vy = object->vy - chosenVertex ()->y,      
2306 <      vz = object->vz - chosenVertex ()->z,      
2307 <      px = object->px,  
2308 <      py = object->py,  
2309 <      pz = object->pz,  
2310 <      pt = object->pt;  
2311 <    value = vz - (vx * px + vy * py)/pt * (pz/pt);      
2312 <  }    
2313 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2295 >  else if (variable == "d0wrtPV"){
2296 >    double vx = object->vx - chosenVertex ()->x,
2297 >      vy = object->vy - chosenVertex ()->y,
2298 >      px = object->px,
2299 >      py = object->py,
2300 >      pt = object->pt;
2301 >    value = (-vx * py + vy * px) / pt;
2302 >  }
2303 >  else if (variable == "dZwrtPV"){
2304 >    double vx = object->vx - chosenVertex ()->x,
2305 >      vy = object->vy - chosenVertex ()->y,
2306 >      vz = object->vz - chosenVertex ()->z,
2307 >      px = object->px,
2308 >      py = object->py,
2309 >      pz = object->pz,
2310 >      pt = object->pt;
2311 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
2312 >  }
2313 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2314  
2315    else if(variable == "genMatchedPdgId"){
2316      int index = getGenMatchedParticleIndex(object);
# Line 2158 | Line 2344 | OSUAnalysis::valueLookup (const BNtrack*
2344      }
2345      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2346    }
2347 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2348 +    int index = getGenMatchedParticleIndex(object);
2349 +    if(index == -1) value = 23;
2350 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2351 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2352 +      if(motherIndex == -1) value = 23;
2353 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2354 +    }
2355 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2356 +  }
2357  
2358  
2359  
2360 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2360 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2361  
2362    value = applyFunction(function, value);
2363  
2364    return value;
2365   }
2366  
2367 + //!genjet valueLookup
2368   double
2369 < OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function){
2369 > OSUAnalysis::valueLookup (const BNgenjet* object, string variable, string function, string &stringValue){
2370  
2371    double value = 0.0;
2372  
# Line 2189 | Line 2386 | OSUAnalysis::valueLookup (const BNgenjet
2386    else if(variable == "charge") value = object->charge;
2387  
2388  
2389 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2389 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2390  
2391    value = applyFunction(function, value);
2392  
2393    return value;
2394   }
2395  
2396 + //!mcparticle valueLookup
2397   double
2398 < OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function){
2398 > OSUAnalysis::valueLookup (const BNmcparticle* object, string variable, string function, string &stringValue){
2399  
2400    double value = 0.0;
2401  
# Line 2322 | Line 2520 | OSUAnalysis::valueLookup (const BNmcpart
2520    }
2521  
2522  
2523 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2523 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2524  
2525    value = applyFunction(function, value);
2526  
2527    return value;
2528   }
2529  
2530 + //!primaryvertex valueLookup
2531   double
2532 < OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function){
2532 > OSUAnalysis::valueLookup (const BNprimaryvertex* object, string variable, string function, string &stringValue){
2533  
2534    double value = 0.0;
2535  
# Line 2349 | Line 2548 | OSUAnalysis::valueLookup (const BNprimar
2548    else if(variable == "isGood") value = object->isGood;
2549  
2550  
2551 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2551 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2552  
2553    value = applyFunction(function, value);
2554  
2555    return value;
2556   }
2557  
2558 + //!bxlumi valueLookup
2559   double
2560 < OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function){
2560 > OSUAnalysis::valueLookup (const BNbxlumi* object, string variable, string function, string &stringValue){
2561  
2562    double value = 0.0;
2563  
# Line 2366 | Line 2566 | OSUAnalysis::valueLookup (const BNbxlumi
2566    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
2567  
2568  
2569 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2569 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2570  
2571    value = applyFunction(function, value);
2572  
2573    return value;
2574   }
2575  
2576 + //!photon valueLookup
2577   double
2578 < OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function){
2578 > OSUAnalysis::valueLookup (const BNphoton* object, string variable, string function, string &stringValue){
2579  
2580    double value = 0.0;
2581  
# Line 2449 | Line 2650 | OSUAnalysis::valueLookup (const BNphoton
2650    else if(variable == "seedRecoFlag") value = object->seedRecoFlag;
2651  
2652  
2452
2653  
2654 <  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2654 >
2655 >  else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
2656  
2657    else if(variable == "genMatchedPdgId"){
2658      int index = getGenMatchedParticleIndex(object);
# Line 2486 | Line 2687 | OSUAnalysis::valueLookup (const BNphoton
2687      }
2688      else value = getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2689    }
2690 +  else if(variable == "genMatchedGrandmotherIdReverse"){
2691 +    int index = getGenMatchedParticleIndex(object);
2692 +    if(index == -1) value = 23;
2693 +    else if(fabs(mcparticles->at(index).motherId) == 15){
2694 +      int motherIndex = findTauMotherIndex(&mcparticles->at(index));
2695 +      if(motherIndex == -1) value = 23;
2696 +      else value = 23 - getPdgIdBinValue(mcparticles->at(motherIndex).motherId);
2697 +    }
2698 +    else value = 23 - getPdgIdBinValue(mcparticles->at(index).grandMotherId);
2699 +  }
2700  
2701  
2702 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2702 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2703  
2704    value = applyFunction(function, value);
2705  
2706    return value;
2707   }
2708  
2709 + //!supercluster valueLookup
2710   double
2711 < OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function){
2711 > OSUAnalysis::valueLookup (const BNsupercluster* object, string variable, string function, string &stringValue){
2712  
2713    double value = 0.0;
2714  
# Line 2510 | Line 2722 | OSUAnalysis::valueLookup (const BNsuperc
2722    else if(variable == "theta") value = object->theta;
2723  
2724  
2725 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2725 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2726  
2727    value = applyFunction(function, value);
2728  
2729    return value;
2730   }
2731  
2732 + //!trigobj valueLookup
2733 + double
2734 + OSUAnalysis::valueLookup (const BNtrigobj* object, string variable, string function, string &stringValue){
2735 +
2736 +  double value = 0.0;
2737 +
2738 +  if(variable == "pt") value = object->pt;
2739 +  else if(variable == "eta") value = object->eta;
2740 +  else if(variable == "phi") value = object->phi;
2741 +  else if(variable == "px") value = object->px;
2742 +  else if(variable == "py") value = object->py;
2743 +  else if(variable == "pz") value = object->pz;
2744 +  else if(variable == "et") value = object->et;
2745 +  else if(variable == "energy") value = object->energy;
2746 +  else if(variable == "etTotal") value = object->etTotal;
2747 +  else if(variable == "id") value = object->id;
2748 +  else if(variable == "charge") value = object->charge;
2749 +  else if(variable == "isIsolated") value = object->isIsolated;
2750 +  else if(variable == "isMip") value = object->isMip;
2751 +  else if(variable == "isForward") value = object->isForward;
2752 +  else if(variable == "isRPC") value = object->isRPC;
2753 +  else if(variable == "bx") value = object->bx;
2754 +  else if(variable == "filter") {
2755 +    if ((stringValue = object->filter) == "")
2756 +      stringValue = "none";  // stringValue should only be empty if value is filled
2757 +  }
2758  
2759 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2760 +
2761 +  value = applyFunction(function, value);
2762 +
2763 +  return value;
2764 + }
2765 +
2766 + //!muon-muon pair valueLookup
2767   double
2768 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function){
2768 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2769  
2770    double value = 0.0;
2771  
# Line 2581 | Line 2827 | OSUAnalysis::valueLookup (const BNmuon*
2827        value = object2->correctedD0;
2828      }
2829  
2830 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2830 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2831  
2832    value = applyFunction(function, value);
2833  
2834    return value;
2835   }
2836  
2837 + //!electron-electron pair valueLookup
2838   double
2839 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function){
2839 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNelectron* object2, string variable, string function, string &stringValue){
2840  
2841    double value = 0.0;
2842  
# Line 2636 | Line 2883 | OSUAnalysis::valueLookup (const BNelectr
2883      value = object2->correctedD0;
2884    }
2885  
2886 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2886 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2887  
2888    value = applyFunction(function, value);
2889  
2890    return value;
2891   }
2892 <
2892 > //!electron-muon pair valueLookup
2893   double
2894 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function){
2894 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
2895  
2896    double value = 0.0;
2897  
# Line 2702 | Line 2949 | OSUAnalysis::valueLookup (const BNelectr
2949    else if(variable == "muonRelPFdBetaIso"){
2950      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
2951    }
2952 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2953 +  value = applyFunction(function, value);
2954  
2955 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2955 >  return value;
2956 > }
2957 >
2958 > //!electron-jet pair valueLookup
2959 > double
2960 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
2961 >
2962 >  double value = 0.0;
2963 >
2964 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
2965 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
2966 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
2967 >  else if(variable == "invMass"){
2968 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2969 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2970 >    value = (fourVector1 + fourVector2).M();
2971 >  }
2972 >  else if(variable == "pt"){
2973 >    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
2974 >    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
2975 >    value = (fourVector1 + fourVector2).Pt();
2976 >  }
2977 >  else if(variable == "threeDAngle")
2978 >    {
2979 >      TVector3 threeVector1(object1->px, object1->py, object1->pz);
2980 >      TVector3 threeVector2(object2->px, object2->py, object2->pz);
2981 >      value = (threeVector1.Angle(threeVector2));
2982 >    }
2983 >  else if(variable == "chargeProduct"){
2984 >    value = object1->charge*object2->charge;
2985 >  }
2986 >
2987 >  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2988 >  value = applyFunction(function, value);
2989 >
2990 >  return value;
2991 > }
2992  
2993 + //!muon-jet pair valueLookup
2994 + double
2995 + OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
2996 +
2997 +  double value = 0.0;
2998 +
2999 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3000 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3001 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3002 +  else if(variable == "invMass"){
3003 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3004 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3005 +    value = (fourVector1 + fourVector2).M();
3006 +  }
3007 +  else if(variable == "pt"){
3008 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3009 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3010 +    value = (fourVector1 + fourVector2).Pt();
3011 +  }
3012 +  else if(variable == "threeDAngle")
3013 +    {
3014 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3015 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3016 +      value = (threeVector1.Angle(threeVector2));
3017 +    }
3018 +  else if(variable == "chargeProduct"){
3019 +    value = object1->charge*object2->charge;
3020 +  }
3021 +
3022 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3023    value = applyFunction(function, value);
3024  
3025    return value;
3026   }
3027  
3028 + //!jet-jet pair valueLookup
3029 + double
3030 + OSUAnalysis::valueLookup (const BNjet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3031 +
3032 +  double value = 0.0;
3033 +
3034 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3035 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3036 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3037 +  else if(variable == "invMass"){
3038 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3039 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3040 +    value = (fourVector1 + fourVector2).M();
3041 +  }
3042 +  else if(variable == "pt"){
3043 +    TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
3044 +    TLorentzVector fourVector2(object2->px, object2->py, object2->pz, object2->energy);
3045 +    value = (fourVector1 + fourVector2).Pt();
3046 +  }
3047 +  else if(variable == "threeDAngle")
3048 +    {
3049 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3050 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3051 +      value = (threeVector1.Angle(threeVector2));
3052 +    }
3053 +  else if(variable == "chargeProduct"){
3054 +    value = object1->charge*object2->charge;
3055 +  }
3056 +
3057 +  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3058 +  value = applyFunction(function, value);
3059  
3060 < double  
3061 < OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function){  
3062 <  double electronMass = 0.000511;        
3063 <  double value = 0.0;    
3064 <  TLorentzVector fourVector1(0, 0, 0, 0);        
3065 <  TLorentzVector fourVector2(0, 0, 0, 0);        
3066 <  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));  
3060 >  return value;
3061 > }
3062 > //!electron-track pair valueLookup
3063 > double
3064 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3065 >  double electronMass = 0.000511;
3066 >  double value = 0.0;
3067 >  TLorentzVector fourVector1(0, 0, 0, 0);
3068 >  TLorentzVector fourVector2(0, 0, 0, 0);
3069 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3070    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3071    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);    
3072    else if(variable == "invMass"){        
# Line 2726 | Line 3075 | OSUAnalysis::valueLookup (const BNelectr
3075          
3076      value = (fourVector1 + fourVector2).M();    
3077    }
3078 +  else if(variable == "chargeProduct"){
3079 +    value = object1->charge*object2->charge;
3080 +  }
3081    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}  
3082    value = applyFunction(function, value);        
3083    return value;  
2732 }
3084  
3085 + }
3086  
3087  
3088 + //!muon-track pair valueLookup
3089   double
3090 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function){
3090 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3091    double pionMass = 0.140;
3092    double muonMass = 0.106;
3093    double value = 0.0;
# Line 2749 | Line 3102 | OSUAnalysis::valueLookup (const BNmuon*
3102  
3103      value = (fourVector1 + fourVector2).M();
3104    }
3105 +  else if(variable == "chargeProduct"){
3106 +    value = object1->charge*object2->charge;
3107 +  }
3108  
3109    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3110    value = applyFunction(function, value);
3111    return value;
3112   }
3113  
3114 <
3114 > //!tau-tau pair valueLookup
3115   double
3116 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function){
3116 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtau* object2, string variable, string function, string &stringValue){
3117    double value = 0.0;
3118    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3119    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 2768 | Line 3124 | OSUAnalysis::valueLookup (const BNtau* o
3124      value = (fourVector1 + fourVector2).M();
3125    }
3126  
3127 +  else if(variable == "chargeProduct"){
3128 +    value = object1->charge*object2->charge;
3129 +  }
3130 +
3131    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3132    value = applyFunction(function, value);
3133    return value;
3134   }
3135  
3136 <
3136 > //!muon-tau pair valueLookup
3137   double
3138 < OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function){
3138 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtau* object2, string variable, string function, string &stringValue){
3139    double value = 0.0;
3140    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3141    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
# Line 2786 | Line 3146 | OSUAnalysis::valueLookup (const BNmuon*
3146      value = (fourVector1 + fourVector2).M();
3147    }
3148  
3149 +  else if(variable == "chargeProduct"){
3150 +    value = object1->charge*object2->charge;
3151 +  }
3152 +
3153    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3154    value = applyFunction(function, value);
3155    return value;
3156   }
3157  
3158 + //!tau-track pair valueLookup
3159   double
3160 < OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function){
3160 > OSUAnalysis::valueLookup (const BNtau* object1, const BNtrack* object2, string variable, string function, string &stringValue){
3161    double value = 0.0;
3162    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3163    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3164 +  else if(variable == "chargeProduct"){
3165 +    value = object1->charge*object2->charge;
3166 +  }
3167  
3168    else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3169    value = applyFunction(function, value);
# Line 2803 | Line 3171 | OSUAnalysis::valueLookup (const BNtau* o
3171   }
3172  
3173  
3174 <
3174 > //!track-event pair valueLookup
3175   double
3176 < OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function){
3176 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNevent* object2, string variable, string function, string &stringValue){
3177  
3178    double value = 0.0;
3179    double pMag = sqrt(object1->pt * object1->pt +
3180 <                     object1->pz * object1->pz);  
3180 >                     object1->pz * object1->pz);
3181  
3182    if      (variable == "numPV")                      value = object2->numPV;
3183    else if (variable == "caloTotDeltaRp5")            value =  (object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5);
3184    else if (variable == "caloTotDeltaRp5ByP")         value = ((object1->caloHadDeltaRp5 + object1->caloEMDeltaRp5)/pMag);
3185 <  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);  
3186 <  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;  
3185 >  else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3186 >  else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3187  
3188 <  else { std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3188 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3189  
3190    value = applyFunction(function, value);
3191  
3192    return value;
3193  
3194 < }  
3194 > }
3195 >
3196 > //!electron-trigobj pair valueLookup
3197 > double
3198 > OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3199 >
3200 >  double value = 0.0;
3201 >
3202 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3203 >
3204 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3205 >
3206 >  value = applyFunction(function, value);
3207 >
3208 >  return value;
3209 >
3210 > }
3211 >
3212 > //!muon-trigobj pair valueLookup
3213 > double
3214 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNtrigobj* object2, string variable, string function, string &stringValue){
3215 >
3216 >  double value = 0.0;
3217 >
3218 >  if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3219 >
3220 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3221 >
3222 >  value = applyFunction(function, value);
3223 >
3224 >  return value;
3225 >
3226 > }
3227 >
3228 > //!stop valueLookup
3229 > double
3230 > OSUAnalysis::valueLookup (const BNstop* object, string variable, string function, string &stringValue){
3231 >
3232 >
3233 >  double value = 0.0;
3234 >
3235 >  if(variable == "ctau") value = object->ctau;
3236 >
3237 >  else if (variable == "d0"){
3238 >    double vx = object->vx - chosenVertex ()->x,
3239 >      vy = object->vy - chosenVertex ()->y,
3240 >      px = object->px,
3241 >      py = object->py,
3242 >      pt = object->pt;
3243 >    value = (-vx * py + vy * px) / pt;
3244 >  }
3245 >
3246 >  else if (variable == "dz"){
3247 >    double vx = object->vx - chosenVertex ()->x,
3248 >      vy = object->vy - chosenVertex ()->y,
3249 >      vz = object->vz - chosenVertex ()->z,
3250 >      px = object->px,
3251 >      py = object->py,
3252 >      pz = object->pz,
3253 >      pt = object->pt;
3254 >    value = vz - (vx * px + vy * py)/pt * (pz/pt);
3255 >  }
3256 >
3257 >  else if (variable == "minD0"){
3258 >    double minD0=999;
3259 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3260 >      double vx = object->vx - vertex->x,
3261 >        vy = object->vy - vertex->y,
3262 >        px = object->px,
3263 >        py = object->py,
3264 >        pt = object->pt;
3265 >      value = (-vx * py + vy * px) / pt;
3266 >      if(abs(value) < abs(minD0)) minD0 = value;
3267 >    }
3268 >    value = minD0;
3269 >  }
3270 >  else if (variable == "minDz"){
3271 >    double minDz=999;
3272 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3273 >      double vx = object->vx - vertex->x,
3274 >        vy = object->vy - vertex->y,
3275 >        vz = object->vz - vertex->z,
3276 >        px = object->px,
3277 >        py = object->py,
3278 >        pz = object->pz,
3279 >        pt = object->pt;
3280 >      value = vz - (vx * px + vy * py)/pt * (pz/pt);
3281 >      if(abs(value) < abs(minDz)) minDz = value;
3282 >    }
3283 >    value = minDz;
3284 >  }
3285 >  else if(variable == "distToVertex"){
3286 >    value = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3287 >                 (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3288 >                 (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3289 >  }
3290 >  else if (variable == "minDistToVertex"){
3291 >    double minDistToVertex=999;
3292 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3293 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3294 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3295 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3296 >
3297 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3298 >    }
3299 >    value = minDistToVertex;
3300 >  }
3301 >  else if (variable == "distToVertexDifference"){
3302 >    double minDistToVertex=999;
3303 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3304 >      value = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3305 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3306 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3307 >
3308 >      if(abs(value) < abs(minDistToVertex)) minDistToVertex = value;
3309 >    }
3310 >    double distToChosenVertex = sqrt((object->vx-chosenVertex()->x)*(object->vx-chosenVertex()->x) + \
3311 >                                     (object->vy-chosenVertex()->y)*(object->vy-chosenVertex()->y) + \
3312 >                                     (object->vz-chosenVertex()->z)*(object->vz-chosenVertex()->z));
3313 >
3314 >    value = distToChosenVertex - minDistToVertex;
3315 >  }
3316 >
3317 >  else if (variable == "closestVertexRank"){
3318 >    double minDistToVertex=999;
3319 >    int vertex_rank = 0;
3320 >    for(BNprimaryvertexCollection::const_iterator vertex = primaryvertexs->begin (); vertex != primaryvertexs->end (); vertex++){
3321 >      vertex_rank++;
3322 >      int dist = sqrt((object->vx-vertex->x)*(object->vx-vertex->x) + \
3323 >                   (object->vy-vertex->y)*(object->vy-vertex->y) + \
3324 >                   (object->vz-vertex->z)*(object->vz-vertex->z));
3325 >
3326 >      if(abs(dist) < abs(minDistToVertex)){
3327 >        value = vertex_rank;
3328 >        minDistToVertex = dist;
3329 >      }
3330 >    }
3331 >  }
3332 >
3333 >
3334 >
3335 >
3336 >  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3337 >
3338 >  value = applyFunction(function, value);
3339 >
3340 >  return value;
3341 >
3342 > }
3343 >
3344 >
3345 >
3346  
3347   // Calculate the number of tracks in cone of DeltaR<0.5 around track1.
3348   // Return true iff no other tracks are found in this cone.
# Line 2872 | Line 3391 | OSUAnalysis::getTrkPtTrue (const BNtrack
3391  
3392   double
3393   OSUAnalysis::getTrkCaloTotRhoCorr(const BNtrack* track) {
3394 <  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.  
3395 <  if (!useTrackCaloRhoCorr_) return -99;  
3396 <  // if (!rhokt6CaloJetsHandle_) {
3397 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;  
3398 <  //   return -99;  
3394 >  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
3395 >  if (!useTrackCaloRhoCorr_) return -99;
3396 >  // if (!rhokt6CaloJetsHandle_) {
3397 >  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
3398 >  //   return -99;
3399    // }
3400 <  double radDeltaRCone = 0.5;  
3401 <  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.  
3402 <  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;  
3403 <  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);  
3404 <  return caloTotRhoCorrCalo;  
3405 <
3400 >  double radDeltaRCone = 0.5;
3401 >  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.
3402 >  double rawCaloTot = track->caloHadDeltaRp5 + track->caloEMDeltaRp5;
3403 >  double caloTotRhoCorrCalo = TMath::Max(0., rawCaloTot - rhoCorr_kt6CaloJets);
3404 >  return caloTotRhoCorrCalo;
3405 >
3406   }
3407  
3408  
# Line 2921 | Line 3440 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3440    double deltaRLowest = 999;
3441    int value = 0;
3442    if (DeadEcalVec.size() == 0) WriteDeadEcal();
3443 <  for(std::vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3443 >  for(vector<DeadEcal>::const_iterator ecal = DeadEcalVec.begin(); ecal != DeadEcalVec.end(); ++ecal){
3444      double eta = ecal->etaEcal;
3445      double phi = ecal->phiEcal;
3446 <    double deltaRtemp = deltaR(eta, track1->eta, phi, track1->phi);
3446 >    double deltaRtemp = deltaR(eta, phi, track1->eta, track1->phi);
3447      if(deltaRtemp < deltaRLowest) deltaRLowest = deltaRtemp;
3448    }
3449    if (deltaRLowest<0.05) {value = 1;}
# Line 2932 | Line 3451 | OSUAnalysis::getTrkIsMatchedDeadEcal (co
3451    return value;
3452   }
3453  
3454 < // Returns the smallest DeltaR between the object and any generated true particle in the event.  
3454 > // Returns the smallest DeltaR between the object and any generated true particle in the event.
3455   template <class InputObject>
3456   double OSUAnalysis::getGenDeltaRLowest(InputObject object){
3457    double genDeltaRLowest = 999.;
# Line 2952 | Line 3471 | OSUAnalysis::applyFunction(string functi
3471    else if(function == "log") value = log10(value);
3472  
3473    else if(function == "") value = value;
3474 <  else{std::cout << "WARNING: invalid function '" << function << "'\n";}
3474 >  else{cout << "WARNING: invalid function '" << function << "'\n";}
3475  
3476    return value;
3477  
# Line 2961 | Line 3480 | OSUAnalysis::applyFunction(string functi
3480  
3481   template <class InputCollection>
3482   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
3483 <
3484 <  if (currentCut.inputCollection.find("pair")!=std::string::npos)  {
3485 <    string obj1, obj2;
3483 >
3484 >  if (currentCut.inputCollection.find("pair")!=string::npos)  {
3485 >    string obj1, obj2;
3486      getTwoObjs(currentCut.inputCollection, obj1, obj2);
3487      if (inputType==obj1 ||
3488 <        inputType==obj2) {
3488 >          inputType==obj2) {
3489        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
3490 <      // and the inputType is a member of the pair.  
3491 <      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.  
3492 <      // For example, if currentCut.inputCollection==electron-muon pairs,
3493 <      // then the flags should not be set here when inputType==muons or inputType==electrons.  
3494 <      return;
3495 <    }  
3496 <  }    
3490 >      // and the inputType is a member of the pair.
3491 >      // The cut will instead be applied when the setObjectFlags() is called for the paired collection.
3492 >      // For example, if currentCut.inputCollection==electron-muon pairs,
3493 >      // then the flags should not be set here when inputType==muons or inputType==electrons.
3494 >      return;
3495 >    }
3496 >  }
3497  
3498    for (uint object = 0; object != inputCollection->size(); object++){
3499  
# Line 2984 | Line 3503 | void OSUAnalysis::setObjectFlags(cut &cu
3503  
3504        vector<bool> subcutDecisions;
3505        for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3506 <        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3507 <        subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3506 >        string stringValue = "";
3507 >        double value = valueLookup(&inputCollection->at(object), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3508 >        if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3509 >        else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3510  
3511        }
3512        if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 3024 | Line 3545 | void OSUAnalysis::setObjectFlags(cut &cu
3545    bool sameObjects = false;
3546    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
3547  
3548 <  // Get the strings for the two objects that make up the pair.  
3549 <  string obj1Type, obj2Type;
3548 >  // Get the strings for the two objects that make up the pair.
3549 >  string obj1Type, obj2Type;
3550    getTwoObjs(inputType, obj1Type, obj2Type);
3551    bool isTwoTypesOfObject = true;
3552 <  if (obj1Type==obj2Type) isTwoTypesOfObject = false;  
3552 >  if (obj1Type==obj2Type) isTwoTypesOfObject = false;
3553  
3554 <  // Initialize the flags for individual objects to all be false, if the cut is on the pair.  
3555 <  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).  
3556 <  if (currentCut.inputCollection == inputType) {    
3554 >  // Initialize the flags for individual objects to all be false, if the cut is on the pair.
3555 >  // Set them to true later, if any paired object passes (in which case both of its constituents should pass).
3556 >  if (currentCut.inputCollection == inputType) {
3557      for (uint object1 = 0; object1 != inputCollection1->size(); object1++) {
3558 <      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3558 >      individualFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3559        cumulativeFlags.at(obj1Type).at(currentCutIndex).push_back(false);
3560      }
3561 <    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.  
3561 >    if (isTwoTypesOfObject) { // Only initialize the second object if it is different from the first.
3562        for (uint object2 = 0; object2 != inputCollection2->size(); object2++)  {
3563 <        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3564 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3563 >        individualFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3564 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).push_back(false);
3565        }
3566      }
3567    }
3568 <  
3568 >
3569    int counter = 0;
3570  
3571    for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
# Line 3059 | Line 3580 | void OSUAnalysis::setObjectFlags(cut &cu
3580  
3581          vector<bool> subcutDecisions;
3582          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
3583 <          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex));
3584 <          subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3583 >          string stringValue = "";
3584 >          double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
3585 >          if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
3586 >          else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
3587          }
3588  
3589          if(currentCut.numSubcuts == 1) decision = subcutDecisions.at(0);
# Line 3075 | Line 3598 | void OSUAnalysis::setObjectFlags(cut &cu
3598            decision = tempDecision;
3599          }
3600        }
3601 <      // if (decision) isPassObj1.at(object1) = true;
3602 <      // if (decision) isPassObj2.at(object2) = true;
3603 <      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);  
3604 <      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3605 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;  
3606 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;  
3607 <      }  
3601 >      // if (decision) isPassObj1.at(object1) = true;
3602 >      // if (decision) isPassObj2.at(object2) = true;
3603 >      individualFlags.at(inputType).at(currentCutIndex).push_back(decision);
3604 >      if (decision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3605 >        individualFlags.at(obj1Type).at(currentCutIndex).at(object1) = true;
3606 >        individualFlags.at(obj2Type).at(currentCutIndex).at(object2) = true;
3607 >      }
3608  
3609        //set flags for objects that pass each cut AND all the previous cuts
3610        bool previousCumulativeFlag = true;
# Line 3096 | Line 3619 | void OSUAnalysis::setObjectFlags(cut &cu
3619        else if(flags2.size() == 0) currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1);
3620        else currentCumulativeFlag = previousCumulativeFlag && decision && flags1.at(object1) && flags2.at(object2);
3621        cumulativeFlags.at(inputType).at(currentCutIndex).push_back(currentCumulativeFlag);
3622 <      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on  
3623 <        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);  
3624 <        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);  
3622 >      if (currentCumulativeFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
3623 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1);
3624 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2) = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2);
3625        }
3626        counter++;
3627  
3628 <    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++){
3629 <  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++){
3628 >    } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
3629 >  }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
3630  
3631   }
3632  
3633  
3634   bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1) {
3635 <  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3636 <  // all cuts up to currentCutIndex  
3637 <  bool previousCumulativeFlag = true;  
3638 <  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {  
3635 >  // Return true iff for the collection obj1Type, the element with index object1 has individal flags set to true for
3636 >  // all cuts up to currentCutIndex
3637 >  bool previousCumulativeFlag = true;
3638 >  for (uint previousCutIndex = 0; previousCutIndex < currentCutIndex; previousCutIndex++) {
3639      if (previousCumulativeFlag && individualFlags.at(obj1Type).at(previousCutIndex).at(object1)) previousCumulativeFlag = true;
3640 <    else {  
3641 <      previousCumulativeFlag = false; break;  
3640 >    else {
3641 >      previousCumulativeFlag = false; break;
3642      }
3643    }
3644 <  return previousCumulativeFlag;  
3645 < }  
3644 >  return previousCumulativeFlag;
3645 > }
3646  
3647  
3648   template <class InputCollection>
# Line 3132 | Line 3655 | void OSUAnalysis::fill1DHistogram(TH1* h
3655      string currentString = parameters.inputVariables.at(0);
3656      string inputVariable = "";
3657      string function = "";
3658 <    if(currentString.find("(")==std::string::npos){
3658 >    if(currentString.find("(")==string::npos){
3659        inputVariable = currentString;// variable to cut on
3660      }
3661      else{
# Line 3141 | Line 3664 | void OSUAnalysis::fill1DHistogram(TH1* h
3664        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3665      }
3666  
3667 <    double value = valueLookup(&inputCollection->at(object), inputVariable, function);
3667 >    string stringValue = "";
3668 >    double value = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3669      histo->Fill(value,scaleFactor);
3670  
3671      if (printEventInfo_) {
3672 <      // Write information about event to screen, for testing purposes.  
3673 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;  
3672 >      // Write information about event to screen, for testing purposes.
3673 >      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
3674      }
3675 <    
3675 >
3676    }
3677   }
3678  
# Line 3173 | Line 3697 | void OSUAnalysis::fill1DHistogram(TH1* h
3697        string currentString = parameters.inputVariables.at(0);
3698        string inputVariable = "";
3699        string function = "";
3700 <      if(currentString.find("(")==std::string::npos){
3700 >      if(currentString.find("(")==string::npos){
3701          inputVariable = currentString;// variable to cut on
3702        }
3703        else{
# Line 3182 | Line 3706 | void OSUAnalysis::fill1DHistogram(TH1* h
3706          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3707        }
3708  
3709 <      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3709 >      string stringValue = "";
3710 >      double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3711        histo->Fill(value,scaleFactor);
3712  
3713      }
# Line 3198 | Line 3723 | void OSUAnalysis::fill2DHistogram(TH2* h
3723  
3724      if(!plotAllObjectsInPassingEvents_ && !flags.at(object)) continue;
3725  
3726 +    string stringValue = "";
3727      string currentString = parameters.inputVariables.at(0);
3728      string inputVariable = "";
3729      string function = "";
3730 <    if(currentString.find("(")==std::string::npos){
3730 >    if(currentString.find("(")==string::npos){
3731        inputVariable = currentString;// variable to cut on
3732      }
3733      else{
# Line 3209 | Line 3735 | void OSUAnalysis::fill2DHistogram(TH2* h
3735        inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3736        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3737      }
3738 <    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function);
3738 >    double valueX = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3739  
3740      currentString = parameters.inputVariables.at(1);
3741      inputVariable = "";
3742      function = "";
3743 <    if(currentString.find("(")==std::string::npos){
3743 >    if(currentString.find("(")==string::npos){
3744        inputVariable = currentString;// variable to cut on
3745      }
3746      else{
# Line 3223 | Line 3749 | void OSUAnalysis::fill2DHistogram(TH2* h
3749        inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3750      }
3751  
3752 <    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function);
3752 >    double valueY = valueLookup(&inputCollection->at(object), inputVariable, function, stringValue);
3753  
3754      histo->Fill(valueX,valueY,scaleFactor);
3755  
# Line 3250 | Line 3776 | void OSUAnalysis::fill2DHistogram(TH2* h
3776        if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2)) continue;
3777        if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter)) continue;
3778  
3779 +      string stringValue = "";
3780        string currentString = parameters.inputVariables.at(0);
3781        string inputVariable = "";
3782        string function = "";
3783 <      if(currentString.find("(")==std::string::npos){
3783 >      if(currentString.find("(")==string::npos){
3784          inputVariable = currentString;// variable to cut on
3785        }
3786        else{
# Line 3261 | Line 3788 | void OSUAnalysis::fill2DHistogram(TH2* h
3788          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3789          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3790        }
3791 <      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3791 >      double valueX = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3792  
3793        currentString = parameters.inputVariables.at(1);
3794        inputVariable = "";
3795        function = "";
3796 <      if(currentString.find("(")==std::string::npos){
3796 >      if(currentString.find("(")==string::npos){
3797          inputVariable = currentString;// variable to cut on
3798        }
3799        else{
# Line 3274 | Line 3801 | void OSUAnalysis::fill2DHistogram(TH2* h
3801          inputVariable = currentString.substr(currentString.find("(")+1);//get rest of string
3802          inputVariable = inputVariable.substr(0,inputVariable.size()-1);//remove trailing ")"
3803        }
3804 <      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function);
3804 >      double valueY = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
3805  
3806  
3807        histo->Fill(valueX,valueY,scaleFactor);
# Line 3295 | Line 3822 | int OSUAnalysis::getGenMatchedParticleIn
3822  
3823      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
3824      if(currentDeltaR > 0.05) continue;
3825 <    //     cout << std::setprecision(3) << std::setw(20)
3825 >    //     cout << setprecision(3) << setw(20)
3826      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
3827 <    //          << std::setw(20)
3827 >    //          << setw(20)
3828      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
3829 <    //          << std::setw(20)
3829 >    //          << setw(20)
3830      //          << "\tdeltaR = " << currentDeltaR
3831 <    //          << std::setprecision(1)
3832 <    //          << std::setw(20)
3831 >    //          << setprecision(1)
3832 >    //          << setw(20)
3833      //          << "\tid = " << mcparticles->at(mcparticle - mcparticles->begin()).id
3834 <    //          << std::setw(20)
3834 >    //          << setw(20)
3835      //          << "\tmotherId = " << mcparticles->at(mcparticle - mcparticles->begin()).motherId
3836 <    //          << std::setw(20)
3836 >    //          << setw(20)
3837      //          << "\tstatus = " << mcparticles->at(mcparticle - mcparticles->begin()).status<< endl;
3838      if(currentDeltaR < bestMatchDeltaR && mcparticles->at(mcparticle - mcparticles->begin()).id != mcparticles->at(mcparticle - mcparticles->begin()).motherId){
3839        bestMatchIndex = mcparticle - mcparticles->begin();
# Line 3404 | Line 3931 | const BNprimaryvertex *
3931   OSUAnalysis::chosenVertex ()
3932   {
3933    const BNprimaryvertex *chosenVertex = 0;
3934 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3935 <    vector<bool> vertexFlags = cumulativeFlags.at("primaryvertexs").back().size() ? cumulativeFlags.at("primaryvertexs").back() :
3936 <      cumulativeFlags.at("primaryvertexs").at(cumulativeFlags.at("primaryvertexs").size() - 2);
3934 >  if(find(objectsToCut.begin(), objectsToCut.end(), "primaryvertexs") != objectsToCut.end()) {
3935 >    vector<bool> vertexFlags;
3936 >    for (int i = cumulativeFlags.at("primaryvertexs").size() - 1; i >= 0; i--){
3937 >      if (cumulativeFlags.at("primaryvertexs").at(i).size()){
3938 >        vertexFlags = cumulativeFlags.at("primaryvertexs").at(i);
3939 >        break;
3940 >      }
3941 >    }
3942      for (uint vertexIndex = 0; vertexIndex != vertexFlags.size(); vertexIndex++){
3943        if(!vertexFlags.at(vertexIndex)) continue;
3944        chosenVertex = & primaryvertexs->at(vertexIndex);
# Line 3424 | Line 3956 | const BNmet *
3956   OSUAnalysis::chosenMET ()
3957   {
3958    const BNmet *chosenMET = 0;
3959 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3960 <    vector<bool> metFlags = cumulativeFlags.at("mets").back().size() ? cumulativeFlags.at("mets").back() :
3961 <      cumulativeFlags.at("mets").at(cumulativeFlags.at("mets").size() - 2);
3959 >  if(find(objectsToCut.begin(), objectsToCut.end(), "mets") != objectsToCut.end()) {
3960 >    vector<bool> metFlags;
3961 >    for (int i = cumulativeFlags.at("mets").size() - 1; i >= 0; i--){
3962 >      if (cumulativeFlags.at("mets").at(i).size()){
3963 >        metFlags = cumulativeFlags.at("mets").at(i);
3964 >        break;
3965 >      }
3966 >    }
3967      for (uint metIndex = 0; metIndex != metFlags.size(); metIndex++){
3968        if(!metFlags.at(metIndex)) continue;
3969        chosenMET = & mets->at(metIndex);
# Line 3444 | Line 3981 | const BNelectron *
3981   OSUAnalysis::chosenElectron ()
3982   {
3983    const BNelectron *chosenElectron = 0;
3984 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3985 <    vector<bool> electronFlags = cumulativeFlags.at("electrons").back().size() ? cumulativeFlags.at("electrons").back() :
3986 <      cumulativeFlags.at("electrons").at(cumulativeFlags.at("electrons").size() - 2);
3984 >  if(find(objectsToCut.begin(), objectsToCut.end(), "electrons") != objectsToCut.end()) {
3985 >    vector<bool> electronFlags;
3986 >    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
3987 >      if (cumulativeFlags.at("electrons").at(i).size()){
3988 >        electronFlags = cumulativeFlags.at("electrons").at(i);
3989 >        break;
3990 >      }
3991 >    }
3992      for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
3993        if(!electronFlags.at(electronIndex)) continue;
3994        chosenElectron = & electrons->at(electronIndex);
# Line 3464 | Line 4006 | const BNmuon *
4006   OSUAnalysis::chosenMuon ()
4007   {
4008    const BNmuon *chosenMuon = 0;
4009 <  if(std::find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4010 <    vector<bool> muonFlags = cumulativeFlags.at("muons").back().size() ? cumulativeFlags.at("muons").back() :
4011 <      cumulativeFlags.at("muons").at(cumulativeFlags.at("muons").size() - 2);
4009 >  if(find(objectsToCut.begin(), objectsToCut.end(), "muons") != objectsToCut.end()) {
4010 >    vector<bool> muonFlags;
4011 >    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4012 >      if (cumulativeFlags.at("muons").at(i).size()){
4013 >        muonFlags = cumulativeFlags.at("muons").at(i);
4014 >        break;
4015 >      }
4016 >    }
4017      for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
4018        if(!muonFlags.at(muonIndex)) continue;
4019        chosenMuon = & muons->at(muonIndex);
# Line 3480 | Line 4027 | OSUAnalysis::chosenMuon ()
4027    return chosenMuon;
4028   }
4029  
3483
4030   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines