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.94 by jbrinson, Wed Jul 3 09:30:38 2013 UTC vs.
Revision 1.118 by wulsin, Mon Aug 5 22:00:12 2013 UTC

# Line 1 | Line 1
1   #include "OSUT3Analysis/AnaTools/plugins/OSUAnalysis.h"
2
2   OSUAnalysis::OSUAnalysis (const edm::ParameterSet &cfg) :
3    // Retrieve parameters from the configuration file.
4    jets_ (cfg.getParameter<edm::InputTag> ("jets")),
5    muons_ (cfg.getParameter<edm::InputTag> ("muons")),
6 +  secMuons_ (cfg.getParameter<edm::InputTag> ("secMuons")),
7    electrons_ (cfg.getParameter<edm::InputTag> ("electrons")),
8    events_ (cfg.getParameter<edm::InputTag> ("events")),
9    taus_ (cfg.getParameter<edm::InputTag> ("taus")),
# Line 35 | Line 35 | OSUAnalysis::OSUAnalysis (const edm::Par
35    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
36    applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
37    minBtag_ (cfg.getParameter<int> ("minBtag")),
38  maxBtag_ (cfg.getParameter<int> ("maxBtag")),
38    printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
39    printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
40    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
41    stopCTau_ (cfg.getParameter<vector<double> > ("stopCTau")),
42 <  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut"))
42 >  GetPlotsAfterEachCut_ (cfg.getParameter<bool> ("GetPlotsAfterEachCut")),
43 >  verbose_ (cfg.getParameter<int> ("verbose"))
44   {
45  
46 <  TH1::SetDefaultSumw2 ();
46 >  if (verbose_) printEventInfo_ = true;  
47 >  if (verbose_) clog << "Beginning OSUAnalysis::OSUAnalysis constructor." << endl;  
48 >
49 >  TH1::SetDefaultSumw2();
50  
51    //create pile-up reweighting object, if necessary
52    if(datasetType_ != "data") {
# Line 57 | Line 60 | OSUAnalysis::OSUAnalysis (const edm::Par
60      }
61    }
62    if (datasetType_ == "signalMC" && regex_match (dataset_, regex ("stop.*to.*_.*mm.*")))
63 <    stopCTauWeight_ = new StopCTauWeight (stopCTau_.at (0), stopCTau_.at (1), stops_);
63 >    stopCTauWeight_ = new StopCTauWeight (stopCTau_.at(0), stopCTau_.at(1), stops_);
64  
65  
66    // Construct Cutflow Objects. These store the results of cut decisions and
# Line 67 | Line 70 | OSUAnalysis::OSUAnalysis (const edm::Par
70    //always get vertex collection so we can assign the primary vertex in the event
71    objectsToGet.push_back("primaryvertexs");
72    objectsToPlot.push_back("primaryvertexs");
73 <  objectsToCut.push_back("primaryvertexs");
73 >  objectsToFlag.push_back("primaryvertexs");
74  
75  
76    //always get the MC particles to do GEN-matching
# Line 80 | Line 83 | OSUAnalysis::OSUAnalysis (const edm::Par
83    // Parse the tree variable definitions.
84    for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
85      string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
86 <    if(tempInputCollection.find("pairs")!=string::npos) { cout << "Warning:  tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }
86 >    if(tempInputCollection.find("pairs")!=string::npos) { clog << "Warning:  tree filling is not configured for pairs of objects, so will not work for collection: " << tempInputCollection << endl; }
87      objectsToGet.push_back(tempInputCollection);
88 <    objectsToCut.push_back(tempInputCollection);
88 >    objectsToFlag.push_back(tempInputCollection);
89  
90      vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
91  
# Line 93 | Line 96 | OSUAnalysis::OSUAnalysis (const edm::Par
96        TString newName = TString(br.inputCollection) + "_" + TString(br.inputVariable);
97        br.name = string(newName.Data());
98        treeBranches_.push_back(br);
99 +      if (verbose_>3) clog << "   Adding branch to BNTree: " << br.name << endl;  
100      }
101  
102    } // end   for (uint iBranchSet = 0; iBranchSet<treeBranchSets_.size(); iBranchSet++)
# Line 108 | Line 112 | OSUAnalysis::OSUAnalysis (const edm::Par
112      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
113      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
114      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
115 +    if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
116      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
117      if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
118      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
119      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
120      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
121 +    if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
122      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
123      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
124      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
# Line 121 | Line 127 | OSUAnalysis::OSUAnalysis (const edm::Par
127      if(tempInputCollection == "trigobj-muon pairs")   tempInputCollection = "muon-trigobj pairs";
128      if(tempInputCollection.find("pairs")==string::npos){ //just a single object
129        if(tempInputCollection.find("secondary")!=string::npos){//secondary object
130 <        int spaceIndex = tempInputCollection.find(" ");
131 <        int secondWordLength = tempInputCollection.size() - spaceIndex;
132 <        objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
133 <      }
134 <      else{
130 >        if(tempInputCollection.find("secondary muons")!=string::npos){//treat secondary muons differently; allow for a different input collection
131 >          objectsToGet.push_back("secondary muons");  
132 >        } else {
133 >          int spaceIndex = tempInputCollection.find(" ");
134 >          int secondWordLength = tempInputCollection.size() - spaceIndex;
135 >          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
136 >        }
137 >      } else{
138          objectsToGet.push_back(tempInputCollection);
139        }
140        objectsToPlot.push_back(tempInputCollection);
141 <      objectsToCut.push_back(tempInputCollection);
141 >      objectsToFlag.push_back(tempInputCollection);
142      } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
143        string obj1;
144        string obj2;
145        getTwoObjs(tempInputCollection, obj1, obj2);
146        string obj2ToGet = getObjToGet(obj2);
147 <      objectsToCut.push_back(tempInputCollection);
148 <      objectsToCut.push_back(obj1);
149 <      objectsToCut.push_back(obj2);
147 >      objectsToFlag.push_back(tempInputCollection);
148 >      objectsToFlag.push_back(obj1);
149 >      objectsToFlag.push_back(obj2);
150        objectsToPlot.push_back(tempInputCollection);
151        objectsToPlot.push_back(obj1);
152        objectsToPlot.push_back(obj2);
# Line 145 | Line 154 | OSUAnalysis::OSUAnalysis (const edm::Par
154        objectsToGet.push_back(obj1);
155        objectsToGet.push_back(obj2ToGet);
156      } // end else
157 <
158 <
159 <
157 >    if (find(objectsToPlot.begin(), objectsToPlot.end(), "events") != objectsToPlot.end())
158 >      objectsToGet.push_back("jets");
159 >    
160 >    
161      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
162  
163      for(uint currentHistogram = 0; currentHistogram != histogramList_.size(); currentHistogram++){
# Line 179 | Line 189 | OSUAnalysis::OSUAnalysis (const edm::Par
189    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
190  
191      string currentObject = objectsToPlot.at(currentObjectIndex);
192 <    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
192 >    if(currentObject != "muons" &&
193 >       currentObject != "secondary muons" &&
194 >       currentObject != "secondary electrons" &&
195 >       currentObject != "electrons" &&
196 >       currentObject != "taus" &&
197 >       currentObject != "tracks" &&
198 >       currentObject != "photons" &&
199 >       currentObject != "secondary photons"&&
200 >       currentObject != "superclusters")
201 >      continue;
202  
203      histogram tempIdHisto;
204      histogram tempMomIdHisto;
# Line 194 | Line 213 | OSUAnalysis::OSUAnalysis (const edm::Par
213      tempIdVsGmaIdHisto.inputCollection = currentObject;
214  
215      if(currentObject == "secondary muons") currentObject = "secondaryMuons";
216 +    if(currentObject == "secondary photons") currentObject = "secondaryPhotons";
217      if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
218  
219      currentObject = currentObject.substr(0, currentObject.size()-1);
# Line 249 | Line 269 | OSUAnalysis::OSUAnalysis (const edm::Par
269      string channelName  (channels_.at(currentChannel).getParameter<string>("name"));
270      tempChannel.name = channelName;
271      TString channelLabel = channelName;
272 +    if (verbose_) clog << "Processing channel:  " << channelName << endl;  
273  
274      //set triggers for this channel
275      vector<string> triggerNames;
# Line 292 | Line 313 | OSUAnalysis::OSUAnalysis (const edm::Par
313        if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
314        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
315        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
316 +      if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
317        if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
318        if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
319        if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
# Line 299 | Line 321 | OSUAnalysis::OSUAnalysis (const edm::Par
321        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
322        if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
323        if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
324 +      if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
325        if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
326        if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
327        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
# Line 307 | Line 330 | OSUAnalysis::OSUAnalysis (const edm::Par
330        tempCut.inputCollection = tempInputCollection;
331        if(tempInputCollection.find("pairs")==string::npos){ //just a single object
332          if(tempInputCollection.find("secondary")!=string::npos){//secondary object
333 <          int spaceIndex = tempInputCollection.find(" ");
334 <          int secondWordLength = tempInputCollection.size() - spaceIndex;
335 <          objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
333 >          if(tempInputCollection.find("secondary muons")!=string::npos){//treat secondary muons differently; allow for a different input collection
334 >            objectsToGet.push_back("secondary muons");  
335 >          } else {
336 >            int spaceIndex = tempInputCollection.find(" ");
337 >            int secondWordLength = tempInputCollection.size() - spaceIndex;
338 >            objectsToGet.push_back(tempInputCollection.substr(spaceIndex+1,secondWordLength));
339 >          }
340          }
341          else{
342            objectsToGet.push_back(tempInputCollection);
343          }
344          objectsToCut.push_back(tempInputCollection);
345 +        objectsToFlag.push_back(tempInputCollection);
346        }
347        else{//pair of objects, need to add them both to objectsToGet
348          string obj1;
# Line 324 | Line 352 | OSUAnalysis::OSUAnalysis (const edm::Par
352          objectsToCut.push_back(tempInputCollection);
353          objectsToCut.push_back(obj1);
354          objectsToCut.push_back(obj2);
355 +        objectsToFlag.push_back(tempInputCollection);
356 +        objectsToFlag.push_back(obj1);
357 +        objectsToFlag.push_back(obj2);
358          objectsToGet.push_back(tempInputCollection);
359          objectsToGet.push_back(obj1);
360          objectsToGet.push_back(obj2ToGet);
# Line 336 | Line 367 | OSUAnalysis::OSUAnalysis (const edm::Par
367        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
368        vector<string> cutStringVector = splitString(cutString);
369        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
370 <        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
370 >        clog << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
371          exit(0);
372        }
373        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
# Line 362 | Line 393 | OSUAnalysis::OSUAnalysis (const edm::Par
393        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
394        vector<string> numberRequiredVector = splitString(numberRequiredString);
395        if(numberRequiredVector.size()!=2){
396 <        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
396 >        clog << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
397          exit(0);
398        }
399  
# Line 393 | Line 424 | OSUAnalysis::OSUAnalysis (const edm::Par
424        }
425        subSubDirNames.push_back(subSubDirName);
426        tempCut.name = tempCutName;
427 +      if (verbose_) clog << "Setting up cut, index: " << currentCut << ", input collection: " << tempInputCollection<< ", name: " << tempCut.name << endl;  
428  
429        tempChannel.cuts.push_back(tempCut);
430  
# Line 433 | Line 465 | OSUAnalysis::OSUAnalysis (const edm::Par
465      for(uint currentDir = 0; !useEDMFormat_ && currentDir != treeDirectories.size(); currentDir++){
466        TTree* newTree = treeDirectories.at(currentDir).make<TTree> (TString("BNTree_"+channelLabel), TString("BNTree_"+channelLabel));
467        BNTrees_.push_back(newTree);
468 +      BNTrees_.back()->Branch("event_runInt",  &BNTreeBranchVals_runInt_,  "event_runInt/I");      
469 +      BNTrees_.back()->Branch("event_lumiInt", &BNTreeBranchVals_lumiInt_, "event_lumiInt/I");      
470 +      BNTrees_.back()->Branch("event_evtLong", &BNTreeBranchVals_evtLong_, "event_evtLong/L");      
471        for (uint iBranch = 0; iBranch < treeBranches_.size(); iBranch++){
472          BranchSpecs currentVar = treeBranches_.at(iBranch);
473          vector<float> newVec;
# Line 461 | Line 496 | OSUAnalysis::OSUAnalysis (const edm::Par
496            }
497          }
498          if(numBinsElements != 3 && numBinsElements !=6){
499 <          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
499 >          clog << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
500            exit(0);
501          }
502          else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
503 <          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
503 >          clog << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
504            exit(0);
505          }
506          else if(numBinsElements == 3){
# Line 572 | Line 607 | OSUAnalysis::OSUAnalysis (const edm::Par
607          else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
608          else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
609          else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
610 +        else if(currentObject == "secondary photons")            currentObject = "secondaryPhotons";
611          else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
612          else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
613          else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
614          else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
615 <        else if(currentObject == "photon-jet pairs")          currentObject = "photonJetPairs";
615 >        else if(currentObject == "muon-event pairs")            currentObject = "muonEventPairs";
616 >        else if(currentObject == "photon-jet pairs")            currentObject = "photonJetPairs";
617          else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
618          else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
619          else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
620 +        else if(currentObject == "muon-secondary photon pairs")  currentObject = "muonSecondaryPhotonPairs";
621          else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
622          else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
623          else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
624          else if(currentObject == "electron-track pairs")      currentObject = "electronTrackPairs";
625          else if(currentObject == "muon-track pairs")          currentObject = "muonTrackPairs";
626 +        else if(currentObject == "secondary muon-track pairs") currentObject = "secondaryMuonTrackPairs";
627          else if(currentObject == "muon-tau pairs")            currentObject = "muonTauPairs";
628          else if(currentObject == "tau-tau pairs")             currentObject = "ditauPairs";
629          else if(currentObject == "tau-track pairs")           currentObject = "tauTrackPairs";
# Line 594 | Line 633 | OSUAnalysis::OSUAnalysis (const edm::Par
633          else if(currentObject == "secondary electrons")       currentObject = "secondaryElectrons";
634          else if(currentObject == "electron-trigobj pairs")    currentObject = "electronTrigobjPairs";
635          else if(currentObject == "muon-trigobj pairs")        currentObject = "muonTrigobjPairs";
636 +        else if(currentObject == "electron-mcparticle pairs")   currentObject = "electronMCparticlePairs";
637 +
638  
639          currentObject.at(0) = toupper(currentObject.at(0));
640          string histoName = "num" + currentObject;
# Line 607 | Line 648 | OSUAnalysis::OSUAnalysis (const edm::Par
648          else
649            oneDHists_.at(currentChannel).at(currentDir)[histoName] = directories.at(currentDir).make<TH1D> (TString(histoName),channelLabel+" channel: Number of Selected "+currentObject+"; # "+currentObject, maxNum, 0, maxNum);
650        }
651 +
652 +      if (verbose_) {
653 +        clog << "List of 1D histograms booked for channel " << channelName << " and directory " << currentDir << ":" << endl;
654 +        for(map<string, TH1D*>::iterator
655 +              iter = oneDHists_.at(currentChannel).at(currentDir).begin();
656 +            iter  != oneDHists_.at(currentChannel).at(currentDir).end();
657 +            iter++) {
658 +          clog << " " << iter->first
659 +               << ":  name=" << iter->second->GetName()
660 +               << ", title=" << iter->second->GetTitle()
661 +               << ", bins=(" << iter->second->GetNbinsX()
662 +               << "," << iter->second->GetXaxis()->GetXmin()
663 +               << "," << iter->second->GetXaxis()->GetXmax()
664 +               << ")" << endl;
665 +        }  
666 +        clog << "List of 2D histograms booked for channel " << channelName << " and directory " << currentDir << ":" << endl;
667 +        for(map<string, TH2D*>::iterator
668 +              iter = twoDHists_.at(currentChannel).at(currentDir).begin();
669 +            iter  != twoDHists_.at(currentChannel).at(currentDir).end();
670 +            iter++) {
671 +          clog << " " << iter->first
672 +               << ":  name=" << iter->second->GetName()
673 +               << ", title=" << iter->second->GetTitle()
674 +               << ", binsX=(" << iter->second->GetNbinsX()
675 +               << "," << iter->second->GetXaxis()->GetXmin()
676 +               << "," << iter->second->GetXaxis()->GetXmax()
677 +               << ")"
678 +               << ", binsY=(" << iter->second->GetNbinsY()
679 +               << "," << iter->second->GetYaxis()->GetXmin()
680 +               << "," << iter->second->GetYaxis()->GetXmax()
681 +               << ")"
682 +               << endl;
683 +        }  
684 +      }
685 +
686      }//end of loop over directories
687      channels.push_back(tempChannel);
688      tempChannel.cuts.clear();
689    }//end loop over channels
690  
691  
692 +  // Create the cutflow histogram and fill with 0 weight, in case no events are found in the input file.  
693 +  for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
694 +    channel currentChannel = channels.at(currentChannelIndex);
695 +    if(currentChannel.triggers.size() != 0 || currentChannel.triggersToVeto.size() != 0){  //triggers specified
696 +      cutFlows_.at(currentChannelIndex)->at("trigger") = true;  
697 +    }
698 +    for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
699 +      cut currentCut = currentChannel.cuts.at(currentCutIndex);
700 +      cutFlows_.at(currentChannelIndex)->at (currentCut.name) = true;
701 +    }
702 +    cutFlows_.at(currentChannelIndex)->fillCutFlow(0);  // fill cutflow with 0 weight, just to create the cutflow histograms  
703 +  }
704 +
705    //make unique vector of objects we need to get from the event
706    sort( objectsToGet.begin(), objectsToGet.end() );
707    objectsToGet.erase( unique( objectsToGet.begin(), objectsToGet.end() ), objectsToGet.end() );
708    //make unique vector of objects we need to cut on
709    sort( objectsToCut.begin(), objectsToCut.end() );
710    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
711 +  //make unique vector of objects we need to set flags for
712 +  sort( objectsToFlag.begin(), objectsToFlag.end() );
713 +  objectsToFlag.erase( unique( objectsToFlag.begin(), objectsToFlag.end() ), objectsToFlag.end() );
714 +
715 +  // Move all paired objects to the end of the list, so that the flags for single objects are always set before those of paired objects.  
716 +  for (uint i=0; i<objectsToFlag.size(); i++) {
717 +    if (objectsToFlag.at(i).find("pairs")!=string::npos) { // if it contains "pairs"
718 +      objectsToFlag.push_back(objectsToFlag.at(i));  
719 +      objectsToFlag.erase(objectsToFlag.begin()+i);  
720 +    }
721 +  }
722 +
723 +  if (verbose_) {
724 +    clog << "List of channels:" << endl;
725 +    for (uint i=0; i<channels.size(); i++) {
726 +      clog << " " << channels.at(i).name << endl;
727 +    }
728 +    clog << "List of objects to get:" << endl;
729 +    for (uint i=0; i<objectsToGet.size(); i++) {
730 +      clog << " " << objectsToGet.at(i) << endl;
731 +    }
732 +    clog << "List of objects to plot:" << endl;
733 +    for (uint i=0; i<objectsToPlot.size(); i++) {
734 +      clog << " " << objectsToPlot.at(i) << endl;
735 +    }
736 +    clog << "List of objects to cut:" << endl;
737 +    for (uint i=0; i<objectsToCut.size(); i++) {
738 +      clog << " " << objectsToCut.at(i) << endl;
739 +    }
740 +    clog << "List of objects to flag:" << endl;
741 +    for (uint i=0; i<objectsToFlag.size(); i++) {
742 +      clog << " " << objectsToFlag.at(i) << endl;
743 +    }
744 +  }
745  
746    produces<map<string, bool> > ("channelDecisions");
747  
748 < } // end constructor OSUAnalysis::OSUAnalysis()
748 >  if (printEventInfo_) {
749 >    findEventsLog = new ofstream();  
750 >    findEventsLog->open("findEvents.txt");  
751 >    clog << "Listing run:lumi:event in file findEvents.txt for events that pass full selection (of any channel)." << endl;  
752 >  } else {
753 >    findEventsLog = 0;
754 >  }  
755 >
756 >  isFirstEvent_ = true;  
757 >
758 >  if (verbose_) clog << "Finished OSUAnalysis::OSUAnalysis constructor." << endl;  
759 >
760 >
761 >  } // end constructor OSUAnalysis::OSUAnalysis()
762  
763  
764   OSUAnalysis::~OSUAnalysis ()
765   {
766  
767 +  if (verbose_) clog << "Beginning OSUAnalysis::OSUAnalysis destructor." << endl;  
768 +
769    // Destroying the CutFlow objects causes the cut flow numbers and time
770    // information to be printed to standard output.
771    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
772      delete cutFlows_.at(currentChannel);
773    }
774  
775 <  cout << "=============================================" << endl;  
776 <  cout << "Successfully completed OSUAnalysis." << endl;  
777 <  cout << "=============================================" << endl;  
775 >  if (printEventInfo_ && findEventsLog) findEventsLog->close();  
776 >
777 >  clog << "=============================================" << endl;  
778 >  clog << "Successfully completed OSUAnalysis." << endl;  
779 >  clog << "=============================================" << endl;  
780 >
781 >  if (verbose_) clog << "Finished OSUAnalysis::OSUAnalysis destructor." << endl;  
782  
783   }
784  
# Line 645 | Line 787 | OSUAnalysis::produce (edm::Event &event,
787   {
788    // Retrieve necessary collections from the event.
789  
790 <  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
790 >  if (verbose_) clog << "Beginning OSUAnalysis::produce." << endl;  
791 >
792 >  if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end()) {
793      event.getByLabel (triggers_, triggers);
794 +    if (!triggers.product()) cout << "ERROR:  could not get triggers input collection" << endl;  
795 +  }
796  
797 <  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end())
797 >  if (find(objectsToGet.begin(), objectsToGet.end(), "trigobjs") != objectsToGet.end()) {
798      event.getByLabel (trigobjs_, trigobjs);
799 +    if (!trigobjs.product()) cout << "ERROR:  could not get trigobjs input collection" << endl;  
800 +  }
801  
802 <  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end())
802 >  if (find(objectsToGet.begin(), objectsToGet.end(), "jets") != objectsToGet.end()) {
803      event.getByLabel (jets_, jets);
804 +    if (!jets.product()) cout << "ERROR:  could not get jets input collection" << endl;  
805 +  }
806  
807 <  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end())
807 >  if (find(objectsToGet.begin(), objectsToGet.end(), "muons") != objectsToGet.end()) {
808      event.getByLabel (muons_, muons);
809 +    if (!muons.product()) cout << "ERROR:  could not get muons input collection" << endl;  
810 +  }
811  
812 <  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end())
812 >  if (find(objectsToGet.begin(), objectsToGet.end(), "secondary muons") != objectsToGet.end()) {
813 >    event.getByLabel (secMuons_, secMuons);
814 >    if (!secMuons.product()) cout << "ERROR:  could not get secMuons input collection" << endl;  
815 >  }
816 >
817 >  if (find(objectsToGet.begin(), objectsToGet.end(), "electrons") != objectsToGet.end()) {
818      event.getByLabel (electrons_, electrons);
819 +    if (!electrons.product()) cout << "ERROR:  could not get electrons input collection" << endl;  
820 +  }
821  
822 <  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end())
822 >  if (find(objectsToGet.begin(), objectsToGet.end(), "events") != objectsToGet.end()) {
823      event.getByLabel (events_, events);
824 +    if (!events.product()) cout << "ERROR:  could not get events input collection" << endl;  
825 +  }
826  
827 <  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end())
827 >  if (find(objectsToGet.begin(), objectsToGet.end(), "taus") != objectsToGet.end()) {
828      event.getByLabel (taus_, taus);
829 +    if (!taus.product()) cout << "ERROR:  could not get taus input collection" << endl;  
830 +  }
831  
832 <  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end())
832 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mets") != objectsToGet.end()) {
833      event.getByLabel (mets_, mets);
834 +    if (!mets.product()) cout << "ERROR:  could not get mets input collection" << endl;  
835 +  }
836  
837 <  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end())
837 >  if (find(objectsToGet.begin(), objectsToGet.end(), "tracks") != objectsToGet.end()) {
838      event.getByLabel (tracks_, tracks);
839 +    if (!tracks.product()) cout << "ERROR:  could not get tracks input collection" << endl;  
840 +  }
841  
842 <  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end())
842 >  if (find(objectsToGet.begin(), objectsToGet.end(), "genjets") != objectsToGet.end()) {
843      event.getByLabel (genjets_, genjets);
844 +    if (!genjets.product()) cout << "ERROR:  could not get genjets input collection" << endl;  
845 +  }
846  
847 <  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end())
847 >  if (find(objectsToGet.begin(), objectsToGet.end(), "mcparticles") != objectsToGet.end()) {
848      event.getByLabel (mcparticles_, mcparticles);
849 +    if (!mcparticles.product()) cout << "ERROR:  could not get mcparticles input collection" << endl;  
850 +  }
851  
852 <  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end())
852 >  if (find(objectsToGet.begin(), objectsToGet.end(), "primaryvertexs") != objectsToGet.end()) {
853      event.getByLabel (primaryvertexs_, primaryvertexs);
854 +    if (!primaryvertexs.product()) cout << "ERROR:  could not get primaryvertexs input collection" << endl;  
855 +  }
856  
857 <  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end())
857 >  if (find(objectsToGet.begin(), objectsToGet.end(), "bxlumis") != objectsToGet.end()) {
858      event.getByLabel (bxlumis_, bxlumis);
859 +    if (!bxlumis.product()) cout << "ERROR:  could not get bxlumis input collection" << endl;  
860 +  }
861  
862 <  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end())
862 >  if (find(objectsToGet.begin(), objectsToGet.end(), "photons") != objectsToGet.end()) {
863      event.getByLabel (photons_, photons);
864 +    if (!photons.product()) cout << "ERROR:  could not get photons input collection" << endl;  
865 +  }
866  
867 <  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end())
867 >  if (find(objectsToGet.begin(), objectsToGet.end(), "superclusters") != objectsToGet.end()) {
868      event.getByLabel (superclusters_, superclusters);
869 +    if (!superclusters.product()) cout << "ERROR:  could not get superclusters input collection" << endl;  
870 +  }
871  
872    if (datasetType_ == "signalMC"){
873 <    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end())
873 >    if (find(objectsToGet.begin(), objectsToGet.end(), "stops") != objectsToGet.end()) {
874        event.getByLabel (stops_, stops);
875 +      if (!stops.product()) cout << "ERROR:  could not get stops input collection" << endl;  
876 +    }
877    }
878  
879    if (useTrackCaloRhoCorr_) {
# Line 701 | Line 882 | OSUAnalysis::produce (edm::Event &event,
882      // For description of rho values for different jet reconstruction algorithms, see
883      // https://twiki.cern.ch/twiki/bin/view/CMS/JetAlgorithms#Algorithms
884      event.getByLabel ("kt6CaloJets","rho", rhokt6CaloJetsHandle_);
885 +    if (!rhokt6CaloJetsHandle_.product()) cout << "ERROR:  could not get kt6CaloJets input collection" << endl;  
886    }
887  
888    double masterScaleFactor = 1.0;
# Line 708 | Line 890 | OSUAnalysis::produce (edm::Event &event,
890    //get pile-up event weight
891    if (doPileupReweighting_ && datasetType_ != "data") {
892      //for "data" datasets, the numTruePV is always set to -1
893 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
893 >    if (events->at(0).numTruePV < 0 && isFirstEvent_) clog << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
894      else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
895    }
896  
# Line 722 | Line 904 | OSUAnalysis::produce (edm::Event &event,
904    auto_ptr<map<string, bool> > channelDecisions (new map<string, bool>);
905    for(uint currentChannelIndex = 0; currentChannelIndex != channels.size(); currentChannelIndex++){
906      channel currentChannel = channels.at(currentChannelIndex);
907 +    if (verbose_>1) clog << " Processing channel " << currentChannel.name << endl;
908  
909      flagMap individualFlags;
910      counterMap passingCounter;
# Line 741 | Line 924 | OSUAnalysis::produce (edm::Event &event,
924      //loop over all cuts
925      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
926        cut currentCut = currentChannel.cuts.at(currentCutIndex);
927 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
928 <        string currentObject = objectsToCut.at(currentObjectIndex);
927 >      if (verbose_>2) clog << "  Processing cut, index: " << currentCutIndex << ", input collection: " << currentCut.inputCollection << ", name: " << currentCut.name << endl;  
928 >
929 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
930 >        string currentObject = objectsToFlag.at(currentObjectIndex);
931  
932          //initialize maps to get ready to set cuts
933          individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
934          cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
935  
936        }
752      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
753        string currentObject = objectsToCut.at(currentObjectIndex);
754
755        int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
756
937  
938 <        if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
939 <        else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
940 <        else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
941 <        else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
938 >      //set flags for all relevant objects
939 >      for(int currentObjectIndex = -1; currentObjectIndex != int(objectsToFlag.size()); currentObjectIndex++){
940 >        string currentObject;  
941 >        if (currentObjectIndex < 0) currentObject = currentCut.inputCollection;  // In the first loop, set the flags for the collection that the cut is acting on.  That way other paired collections can access the correct flag for the current cut.  
942 >        else currentObject = objectsToFlag.at(currentObjectIndex);
943 >        if (currentObjectIndex >= 0 && currentObject == currentCut.inputCollection) continue;  // Flags have already been set for the inputCollection object, so should not be set again.  
944 >
945 >        // single object collections
946 >        if     (currentObject == "jets")                setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
947 >        else if(currentObject == "secondary jets")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
948 >        else if(currentObject == "secondary photons")   setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"secondary photons");
949 >        else if(currentObject == "muons")               setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
950 >        else if(currentObject == "secondary muons")     setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,secMuons.product(),"secondary muons");
951          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
952 <        else if(currentObject == "electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
953 <        else if(currentObject == "events") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
954 <        else if(currentObject == "taus") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
955 <        else if(currentObject == "mets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
956 <        else if(currentObject == "tracks") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
957 <        else if(currentObject == "genjets") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
958 <        else if(currentObject == "mcparticles") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
959 <        else if(currentObject == "primaryvertexs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
960 <        else if(currentObject == "bxlumis") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
961 <        else if(currentObject == "photons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
962 <        else if(currentObject == "superclusters") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
963 <        else if(currentObject == "trigobjs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
964 <
965 <
966 <
967 <        else if(currentObject == "muon-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
968 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
969 <                                                                   cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
970 <                                                                   "muon-muon pairs");
971 <
972 <        else if(currentObject == "muon-secondary muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), \
973 <                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
974 <                                                                             cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
975 <                                                                             "muon-secondary muon pairs");
976 <
977 <        else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
978 <                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
979 <                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
980 <                                                                             "muon-secondary jet pairs");
981 <        else if(currentObject == "photon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
982 <                                                                             cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
983 <                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
984 <                                                                             "photon-secondary jet pairs");
985 <
986 <        else if(currentObject == "electron-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
987 <                                                                             cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
988 <                                                                             cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
989 <                                                                             "electron-secondary jet pairs");
990 <
991 <        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
992 <                                                                                     cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
993 <                                                                                     cumulativeFlags.at("secondary electrons").at(flagsForPairCutsIndex), \
994 <                                                                                     "electron-secondary electron pairs");
995 <
996 <        else if(currentObject == "electron-electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), \
997 <                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
809 <                                                                           cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
810 <                                                                           "electron-electron pairs");
811 <        else if(currentObject == "electron-muon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), \
812 <                                                                       cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
813 <                                                                       cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
814 <                                                                       "electron-muon pairs");
815 <        else if(currentObject == "jet-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
816 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
817 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
818 <                                                                 "jet-jet pairs");
819 <        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), \
820 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
821 <                                                                 cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex),\
822 <                                                                 "jet-secondary jet pairs");
823 <        else if(currentObject == "electron-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), \
824 <                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
825 <                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
826 <                                                                      "electron-jet pairs");
827 <        else if(currentObject == "electron-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), \
828 <                                                                      cumulativeFlags.at("electrons").at(flagsForPairCutsIndex), \
829 <                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
830 <                                                                      "electron-photon pairs");
831 <        else if(currentObject == "photon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), \
832 <                                                                      cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
833 <                                                                      cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
834 <                                                                      "photon-jet pairs");
835 <        else if(currentObject == "muon-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
836 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
837 <                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
838 <                                                                  "muon-jet pairs");
839 <        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
840 <                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
841 <                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
842 <                                                                  "met-jet pairs");
843 <        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
844 <                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
845 <                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
846 <                                                                 "track-jet pairs");
847 <        else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
848 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
849 <                                                                  cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
850 <                                                                  "muon-photon pairs");
851 <        else if(currentObject == "track-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(),
852 <                                                                     cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
853 <                                                                     cumulativeFlags.at("events").at(flagsForPairCutsIndex),
854 <                                                                     "track-event pairs");
855 <        else if(currentObject == "electron-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),
856 <                                                                        cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
857 <                                                                        cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
858 <                                                                        "electron-track pairs");
859 <        else if(currentObject == "muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),
860 <                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
861 <                                                                    cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
862 <                                                                    "muon-track pairs");
863 <        else if(currentObject == "muon-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),
864 <                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
865 <                                                                  cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
866 <                                                                  "muon-tau pairs");
867 <        else if(currentObject == "tau-tau pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),
868 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
869 <                                                                 cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
870 <                                                                 "tau-tau pairs");
871 <        else if(currentObject == "tau-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),
872 <                                                                   cumulativeFlags.at("taus").at(flagsForPairCutsIndex),
873 <                                                                   cumulativeFlags.at("tracks").at(flagsForPairCutsIndex),
874 <                                                                   "tau-track pairs");
875 <        else if(currentObject == "electron-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),
876 <                                                                          cumulativeFlags.at("electrons").at(flagsForPairCutsIndex),
877 <                                                                          cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
878 <                                                                          "electron-trigobj pairs");
879 <        else if(currentObject == "muon-trigobj pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),
880 <                                                                      cumulativeFlags.at("muons").at(flagsForPairCutsIndex),
881 <                                                                      cumulativeFlags.at("trigobjs").at(flagsForPairCutsIndex),
882 <                                                                      "muon-trigobj pairs");
952 >        else if(currentObject == "electrons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"electrons");
953 >        else if(currentObject == "events")              setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,events.product(),"events");
954 >        else if(currentObject == "taus")                setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),"taus");
955 >        else if(currentObject == "mets")                setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),"mets");
956 >        else if(currentObject == "tracks")              setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),"tracks");
957 >        else if(currentObject == "genjets")             setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,genjets.product(),"genjets");
958 >        else if(currentObject == "mcparticles")         setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mcparticles.product(),"mcparticles");
959 >        else if(currentObject == "primaryvertexs")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,primaryvertexs.product(),"primaryvertexs");
960 >        else if(currentObject == "bxlumis")             setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,bxlumis.product(),"bxlumis");
961 >        else if(currentObject == "photons")             setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"photons");
962 >        else if(currentObject == "superclusters")       setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,superclusters.product(),"superclusters");
963 >        else if(currentObject == "trigobjs")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,trigobjs.product(),"trigobjs");
964 >
965 >
966 >        // paired object collections  
967 >        else if(currentObject == "muon-muon pairs")                   setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),muons.product(), "muon-muon pairs");
968 >        else if(currentObject == "muon-secondary muon pairs")         setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),secMuons.product(), "muon-secondary muon pairs");
969 >
970 >        else if(currentObject == "muon-secondary photon pairs")       setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), "muon-secondary photon pairs");
971 >        else if(currentObject == "muon-secondary jet pairs")          setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), "muon-secondary jet pairs");
972 >        else if(currentObject == "photon-secondary jet pairs")        setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), "photon-secondary jet pairs");
973 >        else if(currentObject == "electron-secondary jet pairs")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), "electron-secondary jet pairs");
974 >        else if(currentObject == "electron-secondary electron pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), "electron-secondary electron pairs");
975 >
976 >        else if(currentObject == "electron-electron pairs")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),electrons.product(), "electron-electron pairs");
977 >        else if(currentObject == "electron-muon pairs")     setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),muons.product(), "electron-muon pairs");
978 >        else if(currentObject == "jet-jet pairs")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), "jet-jet pairs");
979 >        else if(currentObject == "jet-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),jets.product(), "jet-secondary jet pairs");
980 >        else if(currentObject == "electron-jet pairs")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),jets.product(), "electron-jet pairs");
981 >        else if(currentObject == "electron-photon pairs")   setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),photons.product(), "electron-photon pairs");
982 >        else if(currentObject == "photon-jet pairs")        setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),jets.product(), "photon-jet pairs");
983 >        else if(currentObject == "muon-jet pairs")          setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), "muon-jet pairs");
984 >        else if(currentObject == "muon-event pairs")        setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),events.product(), "muon-event pairs");
985 >        else if(currentObject == "met-jet pairs")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), "met-jet pairs");
986 >        else if(currentObject == "track-jet pairs")         setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), "track-jet pairs");
987 >        else if(currentObject == "muon-photon pairs")       setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), "muon-photon pairs");
988 >        else if(currentObject == "track-event pairs")       setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),events.product(), "track-event pairs");
989 >        else if(currentObject == "electron-track pairs")    setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),tracks.product(),"electron-track pairs");
990 >        else if(currentObject == "muon-track pairs")        setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),tracks.product(),"muon-track pairs");
991 >        else if(currentObject == "secondary muon-track pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,secMuons.product(),tracks.product(),"secondary muon-track pairs");
992 >        else if(currentObject == "muon-tau pairs")          setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),taus.product(),"muon-tau pairs");
993 >        else if(currentObject == "tau-tau pairs")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus.product(),taus.product(),"tau-tau pairs");
994 >        else if(currentObject == "tau-track pairs")         setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,taus .product(),tracks.product(),"tau-track pairs");
995 >        else if(currentObject == "electron-trigobj pairs")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),trigobjs.product(),"electron-trigobj pairs");
996 >        else if(currentObject == "muon-trigobj pairs")      setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),trigobjs.product(),"muon-trigobj pairs");
997 >        else if(currentObject == "electron-mcparticle pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),mcparticles.product(),"electron-mcparticle pairs");
998  
999          if(currentObject == "stops" && datasetType_ == "signalMC") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,stops.product(),"stops");
1000        }
1001  
1002 +    }//end loop over all cuts
1003  
1004  
889    }//end loop over all cuts
890    //use cumulative flags to apply cuts at event level
1005  
1006 <    //a vector to store cumulative cut descisions after each cut.
1007 <    vector<bool> eventPassedPreviousCuts;
1006 >    //use cumulative flags to apply cuts at event level
1007 >    vector<bool> eventPassedPreviousCuts;    //a vector to store cumulative cut descisions after each cut.
1008      bool eventPassedAllCuts = true;
1009 <    //apply trigger (true if none were specified)
896 <    eventPassedAllCuts = eventPassedAllCuts && triggerDecision;
1009 >    eventPassedAllCuts = eventPassedAllCuts && triggerDecision;    //apply trigger (true if none were specified)
1010  
1011      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
1012  
1013        //loop over all objects and count how many passed the cumulative selection up to this point
1014        cut currentCut = currentChannel.cuts.at(currentCutIndex);
1015        int numberPassing = 0;
1016 +      int numberPassingPrev = 0;  // number of objects that pass cuts up to the previous one
1017  
1018        for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size() ; object++){
1019          if(cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).at(object).first) numberPassing++;
1020        }
1021 <      bool cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
1021 >      bool cutDecision;
1022 >      if (!currentCut.isVeto) {
1023 >        cutDecision = evaluateComparison(numberPassing,currentCut.eventComparativeOperator,currentCut.numberRequired);
1024 >      } else {
1025 >        int prevCutIndex = currentCutIndex - 1;
1026 >        if (prevCutIndex<0) {
1027 >          numberPassingPrev = cumulativeFlags.at(currentCut.inputCollection).at(currentCutIndex).size();  // count all objects in collection if cut is the first
1028 >        } else {
1029 >          for (uint object = 0; object != cumulativeFlags.at(currentCut.inputCollection).at(prevCutIndex).size() ; object++){
1030 >            if (cumulativeFlags.at(currentCut.inputCollection).at(prevCutIndex).at(object).first) {
1031 >              numberPassingPrev++;
1032 >              if (verbose_>1) clog << " object passed previous cut" << endl;  
1033 >            }
1034 >          }  
1035 >        }  
1036 >        int numberFailCut = numberPassingPrev - numberPassing;
1037 >        cutDecision = evaluateComparison(numberFailCut,currentCut.eventComparativeOperator,currentCut.numberRequired);  
1038 >      }
1039 >
1040        cutFlows_.at(currentChannelIndex)->at (currentCut.name) = cutDecision;
1041        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
1042        eventPassedPreviousCuts.push_back(eventPassedAllCuts);
1043 +      if (verbose_>1) clog << " Event passed cuts up to cut index " << currentCutIndex << endl;  
1044 +
1045      }
1046 +    //applying all appropriate scale factors
1047      double scaleFactor = masterScaleFactor;
913
1048      muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
1049 +
1050      if(applyLeptonSF_ && datasetType_ != "data"){
1051 <      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
1051 >      //only apply SFs if we've cut on this object
1052 >      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
1053          flagPair muonFlags;
1054 +        //get the last valid flags in the flag map
1055          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
1056            if (cumulativeFlags.at("muons").at(i).size()){
1057              muonFlags = cumulativeFlags.at("muons").at(i);
1058              break;
1059            }
1060          }
1061 +        //apply the weight for each of those objects
1062          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
1063            if(!muonFlags.at(muonIndex).second) continue;
1064            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
1065          }
1066        }
1067 <      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
1067 >      //only apply SFs if we've cut on this object
1068 >      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
1069          flagPair electronFlags;
1070 +        //get the last valid flags in the flag map
1071          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
1072            if (cumulativeFlags.at("electrons").at(i).size()){
1073              electronFlags = cumulativeFlags.at("electrons").at(i);
1074              break;
1075            }
1076          }
1077 +        //apply the weight for each of those objects
1078          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
1079            if(!electronFlags.at(electronIndex).second) continue;
1080            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
# Line 941 | Line 1082 | OSUAnalysis::produce (edm::Event &event,
1082        }
1083      }
1084      if(applyBtagSF_ && datasetType_ != "data"){
1085 <     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
1086 <       flagPair jetFlags;
1085 >      //only apply SFs if we've cut on this object
1086 >      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
1087 >        flagPair jetFlags;
1088          vector<double> jetSFs;
1089 +        //get the last valid flags in the flag map
1090          for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
1091            if (cumulativeFlags.at("jets").at(i).size()){
1092              jetFlags = cumulativeFlags.at("jets").at(i);
1093              break;
1094            }
1095          }
1096 +        //apply the weight for each of those objects
1097          for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
1098            if(!jetFlags.at(jetIndex).second) continue;
1099 <          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
1099 >          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour, jets->at(jetIndex).eta);
1100            jetSFs.push_back(jetSFTmp);
1101          }
1102 <        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
1102 >        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_);
1103        }
1104      }
1105      scaleFactor *= muonScaleFactor_;
1106      scaleFactor *= electronScaleFactor_;
1107      scaleFactor *= bTagScaleFactor_;
1108      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
1109 +    if (verbose_>1) clog << " Scale factors applied:  "
1110 +                         << " muonScaleFactor_ = " << muonScaleFactor_
1111 +                         << ", electronScaleFactor_ = " << electronScaleFactor_
1112 +                         << ", bTagScaleFactor_ = " << bTagScaleFactor_
1113 +                         << ", total scale factor = " << scaleFactor
1114 +                         << endl;  
1115  
1116 <    if (printEventInfo_) {
1116 >
1117 >    if (printEventInfo_ && eventPassedAllCuts) {
1118        // Write information about event to screen, for testing purposes.
1119 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
1120 <           << ": run="  << events->at(0).run
1121 <           << "  lumi=" << events->at(0).lumi
1122 <           << "  event=" << events->at(0).evt
1119 >      clog << "Event passed all cuts in channel " <<  currentChannel.name
1120 >           << ":  run:lumi:evt=  "  << events->at(0).run
1121 >           << ":" << events->at(0).lumi
1122 >           << ":" << events->at(0).evt
1123             << endl;
1124 +      if (findEventsLog) {
1125 +        (*findEventsLog) << events->at(0).run
1126 +                         << ":" << events->at(0).lumi
1127 +                         << ":" << events->at(0).evt << endl;
1128 +      }
1129 +
1130      }
1131  
1132  
1133      //filling histograms
1134 <    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the directories in each channel.
1134 >    for(uint currentCut = 0; currentCut != oneDHists_.at(currentChannelIndex).size(); currentCut++){//loop over all the cuts in each channel; if GetPlotsAfterEachCut_ is false, only the last cut will be used.
1135 >
1136 >      if (verbose_>2) clog << "  Filling histograms for currentcut = " << currentCut << endl;  
1137 >
1138        uint currentDir;
1139        if (!GetPlotsAfterEachCut_) { currentDir =  currentChannel.cuts.size() - oneDHists_.at(currentChannelIndex).size(); } //if GetPlotsAfterEachCut_ is false, set currentDir point to the last cut.
1140        else{
# Line 987 | Line 1147 | OSUAnalysis::produce (edm::Event &event,
1147          for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1148            histogram currentHistogram = histograms.at(histogramIndex);
1149  
1150 <          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1150 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) clog << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1151 >
1152 >          if (verbose_>1) clog << " Filling histogram " << currentHistogram.name << " for collection " << currentHistogram.inputCollection << endl;  
1153  
1154            if(currentHistogram.inputVariables.size() == 1){
1155              TH1D* histo;
1156              histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1157 <            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1157 >            if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1158              else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1159 +            else if(currentHistogram.inputCollection == "secondary photons")  fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1160              else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1161 <            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1161 >            else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,secMuons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1162              else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1163 <            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1001 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1163 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(),
1164                                                                                             cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1165 <            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1004 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1165 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),secMuons.product(),
1166                                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1167 <             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1168 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1167 >             else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),photons.product(),
1168 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1169 >             else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(),
1170                                                                                                       cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1171 <             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1010 <                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1171 >             else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,photons.product(),jets.product(),
1172                                                                                                       cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1173 <             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1013 <                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1173 >             else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),jets.product(),
1174                                                                                                       cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1175  
1176              else if(currentHistogram.inputCollection == "electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1177 <            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),\
1018 <                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir),\
1177 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),
1178                                                                                                     cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1179 <            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),\
1021 <                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),\
1179 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),
1180                                                                                           cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1181 <             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1024 <                                                                                                     cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1181 >             else if(currentHistogram.inputCollection == "jet-secondary jet pairs") fill1DHistogram(histo,currentHistogram,jets.product(),jets.product(),
1182                                                                                                       cumulativeFlags.at("jet-secondary jet pairs").at(currentDir),scaleFactor);
1183  
1184 <            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1028 <                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1184 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill1DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),
1185                                                                                                               cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1186 <            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(), \
1031 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir),
1186 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),muons.product(),
1187                                                                                                 cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1188 <            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(), \
1034 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1188 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),jets.product(),
1189                                                                                                cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1190 <            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(), \
1037 <                                                                                              cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1190 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill1DHistogram(histo,currentHistogram, photons.product(),jets.product(),
1191                                                                                                cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1192 <            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1040 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1192 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(),
1193                                                                                            cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1194 <            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1195 <                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1194 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill1DHistogram(histo,currentHistogram, muons.product(),events.product(),
1195 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1196 >            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(),
1197                                                                                            cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1198 <            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1046 <                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1198 >            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1199                                                                                            cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1200 <            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1049 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1200 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(),
1201                                                                                            cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1202 <            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(), \
1052 <                                                                                          cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1202 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),photons.product(),
1203                                                                                            cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1204              else if(currentHistogram.inputCollection == "electron-track pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),tracks.product(),
1055                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1205                                                                                                  cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1206              else if(currentHistogram.inputCollection == "muon-track pairs") fill1DHistogram(histo,currentHistogram, muons.product(),tracks.product(),
1058                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1207                                                                                              cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1208 +            else if(currentHistogram.inputCollection == "secondary muon-track pairs") fill1DHistogram(histo,currentHistogram, secMuons.product(),tracks.product(),
1209 +                                                                                            cumulativeFlags.at("secondary muon-track pairs").at(currentDir),scaleFactor);
1210              else if(currentHistogram.inputCollection == "muon-tau pairs") fill1DHistogram(histo,currentHistogram, muons.product(),taus.product(),
1061                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1211                                                                                            cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1212              else if(currentHistogram.inputCollection == "tau-tau pairs") fill1DHistogram(histo,currentHistogram, taus.product(),taus.product(),
1064                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1213                                                                                           cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1214              else if(currentHistogram.inputCollection == "tau-track pairs") fill1DHistogram(histo,currentHistogram, taus.product(),tracks.product(),
1067                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1215                                                                                             cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1216              else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill1DHistogram(histo,currentHistogram, electrons.product(),trigobjs.product(),
1070                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1217                                                                                                    cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1218              else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill1DHistogram(histo,currentHistogram, muons.product(),trigobjs.product(),
1073                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1219                                                                                                cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1220  
1221              else if(currentHistogram.inputCollection == "events") fill1DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
# Line 1091 | Line 1236 | OSUAnalysis::produce (edm::Event &event,
1236              histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1237              if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1238              else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1239 +            else if(currentHistogram.inputCollection == "secondary photons")  fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1240              else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1241 <            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1242 <            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1097 <                                                                                           cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1241 >            else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,secMuons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1242 >            else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(),
1243                                                                                             cumulativeFlags.at("muon-muon pairs").at(currentDir),scaleFactor);
1244 <            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1100 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1244 >            else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),secMuons.product(),
1245                                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1246 <            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1247 <                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1246 >            else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(),
1247 >                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1248 >            else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(),
1249                                                                                                       cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
1250 <            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1106 <                                                                                                     cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1250 >            else if(currentHistogram.inputCollection == "electron-secondary jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(),
1251                                                                                                       cumulativeFlags.at("electron-secondary jet pairs").at(currentDir),scaleFactor);
1252 <            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1109 <                                                                                                     cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1252 >            else if(currentHistogram.inputCollection == "photon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(),
1253                                                                                                       cumulativeFlags.at("photon-secondary jet pairs").at(currentDir),scaleFactor);
1254              else if(currentHistogram.inputCollection == "electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("electrons").at(currentDir),scaleFactor);
1255              else if(currentHistogram.inputCollection == "secondary electrons") fill2DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
1256 <            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1114 <                                                                                                   cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("electrons").at(currentDir), \
1256 >            else if(currentHistogram.inputCollection == "electron-electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),
1257                                                                                                     cumulativeFlags.at("electron-electron pairs").at(currentDir),scaleFactor);
1258 <            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(), \
1117 <                                                                                         cumulativeFlags.at("jets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1258 >            else if(currentHistogram.inputCollection == "jet-jet pairs") fill2DHistogram(histo,currentHistogram,jets.product(),jets.product(),
1259                                                                                           cumulativeFlags.at("jet-jet pairs").at(currentDir),scaleFactor);
1260 <            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(), \
1120 <                                                                                                             cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("secondary electrons").at(currentDir), \
1260 >            else if(currentHistogram.inputCollection == "electron-secondary electron pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),electrons.product(),
1261                                                                                                               cumulativeFlags.at("electron-secondary electron pairs").at(currentDir),scaleFactor);
1262 <            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(), \
1123 <                                                                                               cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("muons").at(currentDir), \
1262 >            else if(currentHistogram.inputCollection == "electron-muon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),muons.product(),
1263                                                                                                 cumulativeFlags.at("electron-muon pairs").at(currentDir),scaleFactor);
1264 <            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(), \
1126 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1264 >            else if(currentHistogram.inputCollection == "electron-jet pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),jets.product(),
1265                                                                                                cumulativeFlags.at("electron-jet pairs").at(currentDir),scaleFactor);
1266 <            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(), \
1129 <                                                                                              cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1266 >            else if(currentHistogram.inputCollection == "electron-photon pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),photons.product(),
1267                                                                                                cumulativeFlags.at("electron-photon pairs").at(currentDir),scaleFactor);
1268 <            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1132 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1268 >            else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(),
1269                                                                                            cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1270 <            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1271 <                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1270 >            else if(currentHistogram.inputCollection == "muon-event pairs") fill2DHistogram(histo,currentHistogram,muons.product(),events.product(),
1271 >                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1272 >            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(),
1273                                                                                           cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1274              else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1138                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1275                                                                                           cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1276 <            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1141 <                                                                                          cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1276 >            else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(),
1277                                                                                            cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
1278 <            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1144 <                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir), \
1278 >            else if(currentHistogram.inputCollection == "muon-photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(),
1279                                                                                            cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
1280              else if(currentHistogram.inputCollection == "electron-track pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),tracks.product(),
1147                                                                                                cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1281                                                                                                  cumulativeFlags.at("electron-track pairs").at(currentDir),scaleFactor);
1282              else if(currentHistogram.inputCollection == "muon-track pairs") fill2DHistogram(histo,currentHistogram,muons.product(),tracks.product(),
1283 <                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1283 >                                                                                            cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1284 >            else if(currentHistogram.inputCollection == "secondary muon-track pairs") fill2DHistogram(histo,currentHistogram,secMuons.product(),tracks.product(),
1285                                                                                              cumulativeFlags.at("muon-track pairs").at(currentDir),scaleFactor);
1286              else if(currentHistogram.inputCollection == "muon-tau pairs") fill2DHistogram(histo,currentHistogram,muons.product(),taus.product(),
1153                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1287                                                                                            cumulativeFlags.at("muon-tau pairs").at(currentDir),scaleFactor);
1288              else if(currentHistogram.inputCollection == "tau-tau pairs") fill2DHistogram(histo,currentHistogram,taus.product(),taus.product(),
1156                                                                                         cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("taus").at(currentDir),
1289                                                                                           cumulativeFlags.at("tau-tau pairs").at(currentDir),scaleFactor);
1290              else if(currentHistogram.inputCollection == "tau-track pairs") fill2DHistogram(histo,currentHistogram,taus.product(),tracks.product(),
1159                                                                                           cumulativeFlags.at("taus").at(currentDir),cumulativeFlags.at("tracks").at(currentDir),
1291                                                                                             cumulativeFlags.at("tau-track pairs").at(currentDir),scaleFactor);
1292              else if(currentHistogram.inputCollection == "electron-trigobj pairs") fill2DHistogram(histo,currentHistogram,electrons.product(),trigobjs.product(),
1162                                                                                                  cumulativeFlags.at("electrons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1293                                                                                                    cumulativeFlags.at("electron-trigobj pairs").at(currentDir),scaleFactor);
1294              else if(currentHistogram.inputCollection == "muon-trigobj pairs") fill2DHistogram(histo,currentHistogram,muons.product(),trigobjs.product(),
1165                                                                                              cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("trigobjs").at(currentDir),
1295                                                                                                cumulativeFlags.at("muon-trigobj pairs").at(currentDir),scaleFactor);
1296              else if(currentHistogram.inputCollection == "events") fill2DHistogram(histo,currentHistogram,events.product(),cumulativeFlags.at("events").at(currentDir),scaleFactor);
1297              else if(currentHistogram.inputCollection == "taus") fill2DHistogram(histo,currentHistogram,taus.product(),cumulativeFlags.at("taus").at(currentDir),scaleFactor);
1298              else if(currentHistogram.inputCollection == "mets") fill2DHistogram(histo,currentHistogram,mets.product(),cumulativeFlags.at("mets").at(currentDir),scaleFactor);
1299              else if(currentHistogram.inputCollection == "tracks") fill2DHistogram(histo,currentHistogram,tracks.product(),cumulativeFlags.at("tracks").at(currentDir),scaleFactor);
1300              else if(currentHistogram.inputCollection == "track-event pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),events.product(),
1172                                                                                             cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1301                                                                                               cumulativeFlags.at("track-event pairs").at(currentDir),scaleFactor);
1302              else if(currentHistogram.inputCollection == "genjets") fill2DHistogram(histo,currentHistogram,genjets.product(),cumulativeFlags.at("genjets").at(currentDir),scaleFactor);
1303              else if(currentHistogram.inputCollection == "mcparticles") fill2DHistogram(histo,currentHistogram,mcparticles.product(),cumulativeFlags.at("mcparticles").at(currentDir),scaleFactor);
# Line 1190 | Line 1318 | OSUAnalysis::produce (edm::Event &event,
1318            string currentObject = objectsToPlot.at(currentObjectIndex);
1319            string objectToPlot = "";
1320  
1321 +          if (verbose_) clog << "Filling histogram of number of selected objects in collection: " << currentObject << endl;  
1322 +
1323            // Name of objectToPlot here must match the name specified in OSUAnalysis::OSUAnalysis().
1324            if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1325            else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
# Line 1197 | Line 1327 | OSUAnalysis::produce (edm::Event &event,
1327            else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1328            else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1329            else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1330 <          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1201 <          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1330 >          else if(currentObject == "muon-event pairs")                   objectToPlot = "muonEventPairs";
1331            else if(currentObject == "muon-photon pairs")                  objectToPlot = "muonPhotonPairs";
1332            else if(currentObject == "photon-jet pairs")                   objectToPlot = "photonJetPairs";
1333 +          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1334 +          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1335            else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1336            else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1337            else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1338 +          else if(currentObject == "secondary photons")                  objectToPlot = "secondaryPhotons";
1339            else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1340            else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1341 +          else if(currentObject == "secondary muon-track pairs")         objectToPlot = "secondaryMuonTrackPairs";
1342            else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
1343            else if(currentObject == "tau-tau pairs")                      objectToPlot = "ditauPairs";
1344            else if(currentObject == "tau-track pairs")                    objectToPlot = "tauTrackPairs";
# Line 1213 | Line 1346 | OSUAnalysis::produce (edm::Event &event,
1346            else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1347            else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1348            else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1349 +          else if(currentObject == "muon-secondary photon pairs")        objectToPlot = "muonSecondaryJetPairs";
1350            else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1351            else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1352            else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1353            else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1354            else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
1355            else if(currentObject == "muon-trigobj pairs")                 objectToPlot = "muonTrigobjPairs";
1356 +          else if(currentObject == "electron-mcparticle pairs")          objectToPlot = "electronMCparticlePairs";
1357            else objectToPlot = currentObject;
1358  
1359            string tempCurrentObject = objectToPlot;
# Line 1226 | Line 1361 | OSUAnalysis::produce (edm::Event &event,
1361            string histoName = "num" + tempCurrentObject;
1362  
1363  
1364 <          if(find(objectsToCut.begin(), objectsToCut.end(), currentObject) != objectsToCut.end()) {
1364 >          if(find(objectsToPlot.begin(), objectsToPlot.end(), currentObject) != objectsToPlot.end()) {
1365              flagPair lastCutFlags = cumulativeFlags.at(currentObject).at(currentDir);
1366              int numToPlot = 0;
1367 <            for (uint currentFlag = 0; currentFlag != lastCutFlags.size(); currentFlag++){
1368 <              if(lastCutFlags.at(currentFlag).second) numToPlot++;
1367 >            for (uint iObj = 0; iObj != lastCutFlags.size(); iObj++){  // loop over all the objects  
1368 >              if(lastCutFlags.at(iObj).second) {
1369 >                numToPlot++;  
1370 >                if (verbose_>3) clog << "   Found object " << iObj << " in collection " << currentObject << " to plot." << endl;
1371 >              }
1372              }
1373  
1374              if(objectToPlot == "primaryvertexs"){
# Line 1238 | Line 1376 | OSUAnalysis::produce (edm::Event &event,
1376                oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName+"AfterPileupCorrection")->Fill(primaryvertexs->size(),scaleFactor);
1377              }
1378              else {
1379 +              if (printEventInfo_) clog << "Number of selected " << objectToPlot << " to plot:  " << numToPlot << endl;  
1380                oneDHists_.at(currentChannelIndex).at(currentCut).at(histoName)->Fill(numToPlot,scaleFactor);
1381              }
1382            }
1383 +
1384          } // end for (uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++)
1385  
1386  
# Line 1252 | Line 1392 | OSUAnalysis::produce (edm::Event &event,
1392        for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1393          BranchSpecs brSpecs = treeBranches_.at(iBranch);
1394          string coll = brSpecs.inputCollection;
1395 <        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1395 >        if (cumulativeFlags.count(coll) == 0) clog << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1396  
1397          if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1398          else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1399 +        else if(coll == "secondary photons")   assignTreeBranch(brSpecs,photons.product(),       cumulativeFlags.at(coll).back());
1400          else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1401 <        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1401 >        else if(coll == "secondary muons")     assignTreeBranch(brSpecs,secMuons.product(),      cumulativeFlags.at(coll).back());
1402          else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1403          else if(coll == "secondary electrons") assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
1404          else if(coll == "events")              assignTreeBranch(brSpecs,events.product(),        cumulativeFlags.at(coll).back());
# Line 1274 | Line 1415 | OSUAnalysis::produce (edm::Event &event,
1415          else if(coll == "stops"
1416                  && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1417        } // end loop over branches
1418 +      // set the evtLong, runInt, and lumiInt variables separately, since they are not type float  
1419 +      BNTreeBranchVals_evtLong_ = events->at(0).evt;
1420 +      BNTreeBranchVals_runInt_  = events->at(0).run;
1421 +      BNTreeBranchVals_lumiInt_ = events->at(0).lumi;
1422  
1423 <      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1423 >      if (!BNTrees_.at(currentChannelIndex)) { clog << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1424        BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1425      }
1426  
# Line 1287 | Line 1432 | OSUAnalysis::produce (edm::Event &event,
1432  
1433    event.put (channelDecisions, "channelDecisions");
1434  
1435 < } // end void OSUAnalysis::analyze (const edm::Event &event, const edm::EventSetup &setup)
1435 >  isFirstEvent_ = false;  
1436 >
1437 >  if (verbose_) clog << "Finished OSUAnalysis::produce." << endl;  
1438 >
1439 > } // end void OSUAnalysis::produce (const edm::Event &event, const edm::EventSetup &setup)
1440  
1441  
1442  
# Line 1302 | Line 1451 | OSUAnalysis::evaluateComparison (double
1451    else if(comparison == "==") return testValue == cutValue;
1452    else if(comparison == "=") return testValue == cutValue;
1453    else if(comparison == "!=") return testValue != cutValue;
1454 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1454 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1455  
1456   }
1457  
# Line 1315 | Line 1464 | OSUAnalysis::evaluateComparison (string
1464    else if(comparison == "<")  return testValue <  cutValue;
1465    else if(comparison == "<=") return testValue <= cutValue;
1466    else if(comparison == "==") return testValue == cutValue;
1467 <  else if(comparison == "=") return testValue == cutValue;
1467 >  else if(comparison == "=")  return testValue == cutValue;
1468    else if(comparison == "!=") return testValue != cutValue;
1469 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1469 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1470  
1471   }
1472  
# Line 1327 | Line 1476 | OSUAnalysis::evaluateTriggers (vector<st
1476    //initialize to false until a chosen trigger is passed
1477    bool triggerDecision = false;
1478  
1479 <  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1479 >  if (printAllTriggers_) clog << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1480    //loop over all triggers defined in the event
1481    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1482  
1483 <    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1483 >    if (printAllTriggers_) clog << "   " << trigger->name << endl;
1484  
1485      //we're only interested in triggers that actually passed
1486      if(trigger->pass != 1) continue;
# Line 1541 | Line 1690 | OSUAnalysis::valueLookup (const BNjet* o
1690    }
1691  
1692  
1693 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1693 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1694  
1695    value = applyFunction(function, value);
1696  
# Line 1643 | Line 1792 | OSUAnalysis::valueLookup (const BNmuon*
1792    else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1793    else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1794    else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1795 +  else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1796 +  else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1797 +  else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1798 +  else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1799    else if(variable == "rhoPrime") value = object->rhoPrime;
1800    else if(variable == "AEffDr03") value = object->AEffDr03;
1801    else if(variable == "AEffDr04") value = object->AEffDr04;
# Line 1650 | Line 1803 | OSUAnalysis::valueLookup (const BNmuon*
1803    else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1804    else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1805    else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1806 +  else if(variable == "relpfIsoR04SumExceptChargedHad") value = (object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)/ object->pt;
1807 +  else if(variable == "relpfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt/object->pt;
1808 +  else if(variable == "relpfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt/object->pt;
1809 +  else if(variable == "relpfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt/object->pt;
1810 +  else if(variable == "relpfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt/object->pt;
1811    else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1812    else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1813    else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
# Line 1711 | Line 1869 | OSUAnalysis::valueLookup (const BNmuon*
1869        (object->isGlobalMuon  > 0 ||
1870         object->isTrackerMuon > 0);
1871    }
1872 +  else if(variable == "looseIDGlobalMuon") {
1873 +    value = object->pt > 10 &&
1874 +      object->isGlobalMuon  > 0;
1875 +  }
1876    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1877    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1878    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1879    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1880 +  else if(variable == "relPFdBetaIsoPseudo") value = (object->pfIsoR04SumChargedHadronPt + object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt) / object->pt;
1881    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1882    else if(variable == "metMT") {
1883      if (const BNmet *met = chosenMET ())
# Line 1725 | Line 1888 | OSUAnalysis::valueLookup (const BNmuon*
1888      else
1889        value = -999;
1890    }
1891 <
1892 <
1891 >  else if(variable == "ptPlusMet") {
1892 >    // Calculate the magnitude of the vector sum of the muon pT and the Met.  
1893 >    if (const BNmet *met = chosenMET ())
1894 >      {
1895 >        TVector2 p2Met;
1896 >        TVector2 p2Muon;
1897 >        p2Met. SetMagPhi(   met->pt,    met->phi);
1898 >        p2Muon.SetMagPhi(object->pt, object->phi);  
1899 >        TVector2 p2MetElec = p2Met + p2Muon;
1900 >        value = p2MetElec.Mod();  
1901 >      }
1902 >    else
1903 >      value = -999;
1904 >  }
1905  
1906    else if(variable == "correctedD0VertexInEBPlus"){
1907      if(fabs(object->eta) < 0.8 && object->eta > 0) value = object->correctedD0Vertex;
# Line 1911 | Line 2086 | OSUAnalysis::valueLookup (const BNmuon*
2086  
2087  
2088  
2089 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2089 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2090  
2091    value = applyFunction(function, value);
2092  
# Line 2086 | Line 2261 | OSUAnalysis::valueLookup (const BNelectr
2261    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2262    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2263    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2264 +  else if(variable == "relPFrhoIsoEB") value = object->isEB ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2265 +  else if(variable == "relPFrhoIsoEE") value = object->isEE ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2266    else if(variable == "metMT") {
2267      if (const BNmet *met = chosenMET ())
2268        {
# Line 2096 | Line 2273 | OSUAnalysis::valueLookup (const BNelectr
2273        value = -999;
2274    }
2275  
2276 +  else if(variable == "ptPlusMet") {
2277 +    // Calculate the magnitude of the vector sum of the electron pT and the Met.  
2278 +    if (const BNmet *met = chosenMET ())
2279 +      {
2280 +        TVector2 p2Met;
2281 +        TVector2 p2Elec;
2282 +        p2Met. SetMagPhi(   met->pt,    met->phi);
2283 +        p2Elec.SetMagPhi(object->pt, object->phi);  
2284 +        TVector2 p2MetElec = p2Met + p2Elec;
2285 +        value = p2MetElec.Mod();  
2286 +      }
2287 +    else
2288 +      value = -999;
2289 +  }
2290 +
2291    else if(variable == "correctedD0VertexEEPositiveChargeLowPt"){
2292      if(fabs(object->eta) > 1.479 && object->charge > 0 && object->pt > 45) value = object->correctedD0Vertex;
2293      else value = -999;
# Line 2157 | Line 2349 | OSUAnalysis::valueLookup (const BNelectr
2349      else value = -999;
2350    }
2351  
2352 +  else if(variable == "looseID"){
2353 +    if (object->isEB)
2354 +      {
2355 +        value = fabs(object->delEtaIn) < 0.007 \
2356 +          && fabs (object->delPhiIn) < 0.15 \
2357 +          && object->scSigmaIEtaIEta < 0.01 \
2358 +          && object->hadOverEm < 0.12 \
2359 +          && fabs (object->correctedD0Vertex) < 0.02 \
2360 +          && fabs (object->correctedDZ) < 0.2 \
2361 +          && object->absInvEMinusInvPin < 0.05 \
2362 +          && object->passConvVeto;
2363 +      }
2364 +    else
2365 +      {
2366 +        value = fabs(object->delEtaIn) < 0.009 \
2367 +          && fabs (object->delPhiIn) < 0.10 \
2368 +          && object->scSigmaIEtaIEta < 0.03 \
2369 +          && object->hadOverEm < 0.10 \
2370 +          && fabs (object->correctedD0Vertex) < 0.02 \
2371 +          && fabs (object->correctedDZ) < 0.2 \
2372 +          && object->absInvEMinusInvPin < 0.05 \
2373 +          && object->passConvVeto;
2374 +      }
2375 +  }
2376 +
2377    else if(variable == "tightID"){
2378      if (object->isEB)
2379        {
# Line 2182 | Line 2399 | OSUAnalysis::valueLookup (const BNelectr
2399        }
2400    }
2401  
2402 <  else if(variable == "looseID"){
2402 >  else if(variable == "looseID_MVA"){
2403      value = object->pt > 10
2404        && object->mvaNonTrigV0 > 0;
2405        }
# Line 2316 | Line 2533 | OSUAnalysis::valueLookup (const BNelectr
2533  
2534  
2535  
2536 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2536 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2537  
2538    value = applyFunction(function, value);
2539  
# Line 2404 | Line 2621 | OSUAnalysis::valueLookup (const BNevent*
2621    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2622    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2623    else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2624 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2624 >
2625 >  else if(variable == "unfilteredHt") value = getHt(jets.product());
2626 >  else if(variable == "ht") value = chosenHT ();
2627 >
2628 >  else if(variable == "leadMuPairInvMass"){
2629 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2630 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2631 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2632 >    value = (p0 + p1).M ();
2633 >  }
2634 >  else if(variable == "leadMuPairPt"){
2635 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2636 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2637 >             pt1 (muPair.second->px, muPair.second->py);
2638 >    pt0 += pt1;
2639 >    value = pt0.Mod ();
2640 >  }
2641 >  else if(variable == "leadElPairInvMass"){
2642 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2643 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2644 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2645 >    value = (p0 + p1).M ();
2646 >  }
2647 >  else if(variable == "leadElPairPt"){
2648 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2649 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2650 >             pt1 (muPair.second->px, muPair.second->py);
2651 >    pt0 += pt1;
2652 >    value = pt0.Mod ();
2653 >  }
2654 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2655  
2656    value = applyFunction(function, value);
2657  
# Line 2512 | Line 2759 | OSUAnalysis::valueLookup (const BNtau* o
2759    }
2760  
2761  
2762 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2762 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2763  
2764    value = applyFunction(function, value);
2765  
# Line 2586 | Line 2833 | OSUAnalysis::valueLookup (const BNmet* o
2833    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2834    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2835  
2836 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2836 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2837  
2838    value = applyFunction(function, value);
2839  
# Line 2631 | Line 2878 | OSUAnalysis::valueLookup (const BNtrack*
2878    else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2879    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2880    else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2881 +  else if(variable == "trkRelIsoRp3")     { value = (object->depTrkRp3 - object->pt) / object->pt; if (value<0) value = 0; }
2882 +  else if(variable == "trkRelIsoRp5")     { value = (object->depTrkRp5 - object->pt) / object->pt; if (value<0) value = 0; }
2883    else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2884    else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2885    else if(variable == "depHoRp3")           value = object->depHoRp3;
# Line 2652 | Line 2901 | OSUAnalysis::valueLookup (const BNtrack*
2901    //user defined variables
2902    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;
2903    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2904 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2904 >  else if(variable == "depTrkRp5MinusPt"){
2905 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2906 > //       clog << "Warning:  found track with depTrkRp5 < pt:  depTrkRp5=" << object->depTrkRp5
2907 > //         << "; pt=" << object->pt
2908 > //         << "; object->depTrkRp5 - object->pt = " << object->depTrkRp5 - object->pt
2909 > //         << endl;  
2910 >           value = 0;
2911 >         }
2912 >         else value =  (object->depTrkRp5 - object->pt);
2913 >  }
2914 >  else if(variable == "depTrkRp3MinusPt"){
2915 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2916 >      value = 0;
2917 >    }
2918 >    else value =  (object->depTrkRp3 - object->pt);
2919 >  }
2920 >
2921 >  else if(variable == "dPhiMet") {
2922 >    if (const BNmet *met = chosenMET ()) {
2923 >      value = deltaPhi (object->phi, met->phi);
2924 >    } else value = -999;
2925 >  }
2926 >  
2927 >  
2928    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2929    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2930    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
2931    else if(variable == "caloTotDeltaRp5ByPRhoCorr")  value = getTrkCaloTotRhoCorr(object) / pMag;
2932 +  else if(variable == "depTrkRp5RhoCorr")           value = getTrkDepTrkRp5RhoCorr(object);
2933 +  else if(variable == "depTrkRp3RhoCorr")           value = getTrkDepTrkRp3RhoCorr(object);
2934 +
2935 +  else if(variable == "depTrkRp5MinusPtRhoCorr")    {
2936 +    if ( (getTrkDepTrkRp5RhoCorr(object) - object->pt) < 0 ) value = 0;
2937 +    else {value = (getTrkDepTrkRp5RhoCorr(object) - object->pt );}
2938 +  }
2939 +  
2940 +  else if(variable == "depTrkRp3MinusPtRhoCorr")    
2941 +    {
2942 +      if ( (getTrkDepTrkRp3RhoCorr(object) - object->pt) < 0 ) value = 0;
2943 +      else {value = (getTrkDepTrkRp3RhoCorr(object) - object->pt );}
2944 +    }
2945 +
2946    else if(variable == "isIso")                      value = getTrkIsIso(object, tracks.product());
2947    else if(variable == "isMatchedDeadEcal")          value = getTrkIsMatchedDeadEcal(object);
2948    else if(variable == "ptErrorByPt")                value = (object->ptError/object->pt);
# Line 2681 | Line 2967 | OSUAnalysis::valueLookup (const BNtrack*
2967      value = vz - (vx * px + vy * py)/pt * (pz/pt);
2968    }
2969  
2970 +  else if(variable == "deltaRMinSubLeadJet") {
2971 +    // calculate minimum deltaR between track and any other subleading jet  
2972 +    double trkJetDeltaRMin = 99.;  
2973 +    for (uint ijet = 0; ijet<jets->size(); ijet++) {
2974 +      string empty = "";  
2975 +      double isSubLeadingJet = valueLookup(&jets->at(ijet), "disappTrkSubLeadingJetID", "", empty);  
2976 +      if (!isSubLeadingJet) continue;  // only consider jets that pass the subleading jet ID criteria  
2977 +      double jetEta = valueLookup(&jets->at(ijet), "eta", "", empty);
2978 +      double jetPhi = valueLookup(&jets->at(ijet), "phi", "", empty);
2979 +      double trkJetDeltaR = deltaR(object->eta, object->phi, jetEta, jetPhi);  
2980 +      if (trkJetDeltaR < trkJetDeltaRMin) trkJetDeltaRMin = trkJetDeltaR;
2981 +    }
2982 +    value = trkJetDeltaRMin;  
2983 +  }  
2984 +  
2985 +  else if(variable == "deltaRMinElecLooseMvaId") {
2986 +    // calculate minimum deltaR between track and any other electron passing loose mva ID, i.e., mvaNonTrigV0 > 0
2987 +    double trkElecDeltaRMin = 99.;  
2988 +    for (uint ielec = 0; ielec<electrons->size(); ielec++) {
2989 +      string empty = "";  
2990 +      double mvaNonTrigV0 = valueLookup(&electrons->at(ielec), "mvaNonTrigV0", "", empty);  
2991 +      if (mvaNonTrigV0 < 0) continue;  // only consider electrons with mvaNonTrigV0 > 0  
2992 +      double elecEta = valueLookup(&electrons->at(ielec), "eta", "", empty);
2993 +      double elecPhi = valueLookup(&electrons->at(ielec), "phi", "", empty);
2994 +      double trkElecDeltaR = deltaR(object->eta, object->phi, elecEta, elecPhi);  
2995 +      if (trkElecDeltaR < trkElecDeltaRMin) trkElecDeltaRMin = trkElecDeltaR;
2996 +    }
2997 +    value = trkElecDeltaRMin;  
2998 +  }  
2999 +
3000 +  else if(variable == "deltaRMinMuonLooseId") {
3001 +    // calculate minimum deltaR between track and any other loose-Id muon
3002 +    double trkMuonDeltaRMin = 99.;  
3003 +    //    if (!muons) cout << "ERROR:  could not find muon collection for calculation of deltaRMinMuonLooseId" << endl;  
3004 +    for (uint imuon = 0; imuon<muons->size(); imuon++) {
3005 +      string empty = "";  
3006 +      double isLooseIdMuon = valueLookup(&muons->at(imuon), "looseID", "", empty);  
3007 +      if (!isLooseIdMuon) continue;  // only consider muons that pass the looseID criteria  
3008 +      double muonEta = valueLookup(&muons->at(imuon), "eta", "", empty);
3009 +      double muonPhi = valueLookup(&muons->at(imuon), "phi", "", empty);
3010 +      double trkMuonDeltaR = deltaR(object->eta, object->phi, muonEta, muonPhi);  
3011 +      if (trkMuonDeltaR < trkMuonDeltaRMin) trkMuonDeltaRMin = trkMuonDeltaR;
3012 +    }
3013 +    value = trkMuonDeltaRMin;  
3014 +  }  
3015 +  
3016 +  else if(variable == "deltaRMinSecMuonLooseIdGlobal") {
3017 +    // calculate minimum deltaR between track and any other loose-Id muon
3018 +    double trkMuonDeltaRMin = 99.;  
3019 +    //    if (!secMuons) cout << "ERROR:  could not find secondary muon collection for calculation of deltaRMinSecMuonLooseIdGlobal" << endl;  
3020 +    for (uint imuon = 0; imuon<secMuons->size(); imuon++) {  
3021 +      string empty = "";  
3022 +      double isLooseIdMuon = valueLookup(&secMuons->at(imuon), "looseIDGlobalMuon", "", empty);  
3023 +      if (!isLooseIdMuon) continue;  // only consider muons that pass the looseIDGlobal criteria  
3024 +      double muonEta = valueLookup(&secMuons->at(imuon), "eta", "", empty);
3025 +      double muonPhi = valueLookup(&secMuons->at(imuon), "phi", "", empty);
3026 +      double trkMuonDeltaR = deltaR(object->eta, object->phi, muonEta, muonPhi);  
3027 +      if (trkMuonDeltaR < trkMuonDeltaRMin) trkMuonDeltaRMin = trkMuonDeltaR;
3028 +    }
3029 +    value = trkMuonDeltaRMin;  
3030 +  }  
3031 +  
3032 +  else if(variable == "deltaRMinTauLooseHadronicId") {
3033 +    // calculate minimum deltaR between track and any other tau passing loose hadronic ID  
3034 +    double trkTauDeltaRMin = 99.;  
3035 +    //    if (!taus) cout << "ERROR:  could not find tau collection for calculation of deltaRMinTauLooseHadronicId" << endl;  
3036 +    for (uint itau = 0; itau<taus->size(); itau++) {
3037 +      string empty = "";  
3038 +      double isIdTau = valueLookup(&taus->at(itau), "looseHadronicID", "", empty);  
3039 +      if (!isIdTau) continue;  // only consider taus that pass the loose hadronic ID criteria  
3040 +      double tauEta = valueLookup(&taus->at(itau), "eta", "", empty);
3041 +      double tauPhi = valueLookup(&taus->at(itau), "phi", "", empty);
3042 +      double trkTauDeltaR = deltaR(object->eta, object->phi, tauEta, tauPhi);  
3043 +      if (trkTauDeltaR < trkTauDeltaRMin) trkTauDeltaRMin = trkTauDeltaR;
3044 +    }
3045 +    value = trkTauDeltaRMin;  
3046 +  }  
3047  
3048    else if(variable == "genDeltaRLowest") value = getGenDeltaRLowest(object);
3049  
# Line 2729 | Line 3092 | OSUAnalysis::valueLookup (const BNtrack*
3092  
3093  
3094  
3095 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3095 >  else{clog << "WARNING: invalid variable '" << variable << "' for BNtrack collection.\n"; value = -999;}
3096  
3097    value = applyFunction(function, value);
3098  
# Line 2759 | Line 3122 | OSUAnalysis::valueLookup (const BNgenjet
3122    else if(variable == "charge") value = object->charge;
3123  
3124  
3125 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3125 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3126  
3127    value = applyFunction(function, value);
3128  
# Line 2893 | Line 3256 | OSUAnalysis::valueLookup (const BNmcpart
3256    }
3257  
3258  
3259 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3259 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3260  
3261    value = applyFunction(function, value);
3262  
# Line 2922 | Line 3285 | OSUAnalysis::valueLookup (const BNprimar
3285    else if(variable == "isGood") value = object->isGood;
3286  
3287  
3288 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3288 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3289  
3290    value = applyFunction(function, value);
3291  
# Line 2940 | Line 3303 | OSUAnalysis::valueLookup (const BNbxlumi
3303    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
3304  
3305  
3306 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3306 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3307  
3308    value = applyFunction(function, value);
3309  
# Line 3073 | Line 3436 | OSUAnalysis::valueLookup (const BNphoton
3436    }
3437  
3438  
3439 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3439 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3440  
3441    value = applyFunction(function, value);
3442  
# Line 3097 | Line 3460 | OSUAnalysis::valueLookup (const BNsuperc
3460    else if(variable == "theta") value = object->theta;
3461  
3462  
3463 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3463 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3464  
3465    value = applyFunction(function, value);
3466  
# Line 3131 | Line 3494 | OSUAnalysis::valueLookup (const BNtrigob
3494        stringValue = "none";  // stringValue should only be empty if value is filled
3495    }
3496  
3497 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3497 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3498  
3499    value = applyFunction(function, value);
3500  
# Line 3202 | Line 3565 | OSUAnalysis::valueLookup (const BNmuon*
3565        value = object2->correctedD0;
3566      }
3567  
3568 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3568 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3569  
3570    value = applyFunction(function, value);
3571  
# Line 3219 | Line 3582 | OSUAnalysis::valueLookup (const BNmuon*
3582    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3583    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3584    else if(variable == "photonEta") value = object2->eta;
3585 +  else if(variable == "photonPt") value = object2->pt;
3586    else if(variable == "muonEta") value = object1->eta;
3587    else if(variable == "photonPhi") value = object2->phi;
3588    else if(variable == "muonPhi") value = object1->phi;
# Line 3248 | Line 3612 | OSUAnalysis::valueLookup (const BNmuon*
3612        TVector3 threeVector2(object2->px, object2->py, object2->pz);
3613        value = (pi-threeVector1.Angle(threeVector2));
3614      }
3615 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3615 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3616  
3617    value = applyFunction(function, value);
3618  
# Line 3264 | Line 3628 | OSUAnalysis::valueLookup (const BNelectr
3628    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3629    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3630    else if(variable == "photonEta") value = object2->eta;
3631 +  else if(variable == "photonPt") value = object2->pt;
3632    else if(variable == "electronEta") value = object1->eta;
3633    else if(variable == "photonPhi") value = object2->phi;
3634    else if(variable == "electronPhi") value = object1->phi;
# Line 3293 | Line 3658 | OSUAnalysis::valueLookup (const BNelectr
3658        TVector3 threeVector2(object2->px, object2->py, object2->pz);
3659        value = (pi-threeVector1.Angle(threeVector2));
3660      }
3661 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3661 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3662  
3663    value = applyFunction(function, value);
3664  
# Line 3349 | Line 3714 | OSUAnalysis::valueLookup (const BNelectr
3714      value = object2->correctedD0;
3715    }
3716  
3717 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3717 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3718  
3719    value = applyFunction(function, value);
3720  
# Line 3416 | Line 3781 | OSUAnalysis::valueLookup (const BNelectr
3781    else if(variable == "muonRelPFdBetaIso"){
3782      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3783    }
3784 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3784 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3785    value = applyFunction(function, value);
3786  
3787    return value;
3788   } // end electron-muon pair valueLookup
3789  
3790 <
3790 >
3791   //!electron-jet pair valueLookup
3792   double
3793   OSUAnalysis::valueLookup (const BNelectron* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3456 | Line 3821 | OSUAnalysis::valueLookup (const BNelectr
3821      value = object1->charge*object2->charge;
3822    }
3823  
3824 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3824 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3825    value = applyFunction(function, value);
3826  
3827    return value;
3828   }
3829  
3830 + //!electron-mcparticle pair valueLookup
3831 + double
3832 + OSUAnalysis::valueLookup (const BNelectron* object1, const BNmcparticle* object2, string variable, string function, string &stringValue){
3833 +
3834 +  double value = 0.0;
3835 +
3836 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3837 +  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3838 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3839 +  else if(variable == "threeDAngle")
3840 +    {
3841 +      TVector3 threeVector1(object1->px, object1->py, object1->pz);
3842 +      TVector3 threeVector2(object2->px, object2->py, object2->pz);
3843 +      value = (threeVector1.Angle(threeVector2));
3844 +    }
3845 +  else if(variable == "chargeProduct"){
3846 +    value = object1->charge*object2->charge;
3847 +  }
3848 +
3849 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3850 +  value = applyFunction(function, value);
3851 +
3852 +  return value;
3853 + }
3854 +
3855 +
3856   //!photon-jet pair valueLookup
3857   double
3858   OSUAnalysis::valueLookup (const BNphoton* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3492 | Line 3883 | OSUAnalysis::valueLookup (const BNphoton
3883        TVector3 threeVector2(object2->px, object2->py, object2->pz);
3884        value = (threeVector1.Angle(threeVector2));
3885      }
3886 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3886 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3887    value = applyFunction(function, value);
3888  
3889    return value;
# Line 3507 | Line 3898 | OSUAnalysis::valueLookup (const BNtrack*
3898    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3899    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3900  
3901 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3901 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3902    value = applyFunction(function, value);
3903  
3904    return value;
# Line 3524 | Line 3915 | OSUAnalysis::valueLookup (const BNmet* o
3915  
3916    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3917  
3918 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3918 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3919    value = applyFunction(function, value);
3920  
3921    return value;
# Line 3541 | Line 3932 | OSUAnalysis::valueLookup (const BNmuon*
3932  
3933    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3934    else if(variable == "jetEta") value = object2->eta;
3935 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3936 +  else if(variable == "jetPt") value = object2->pt;
3937    else if(variable == "jetPhi") value = object2->phi;
3938 +  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3939    else if(variable == "muonEta") value = object1->eta;
3940 +  else if(variable == "muonPt") value = object1->pt;
3941    else if(variable == "muonPhi") value = object1->phi;
3942    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3943    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
# Line 3566 | Line 3961 | OSUAnalysis::valueLookup (const BNmuon*
3961      value = object1->charge*object2->charge;
3962    }
3963  
3964 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3964 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3965 >  value = applyFunction(function, value);
3966 >
3967 >  return value;
3968 > }
3969 >
3970 > //!muon-event valueLookup
3971 > double
3972 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue){
3973 >
3974 >  double value = 0.0;
3975 >
3976 >  if(variable == "muonEta") value = object1->eta;
3977 >  else if(variable == "muonPt") value = object1->pt;
3978 >  else if(variable == "muonPhi") value = object1->phi;
3979 >  else if(variable == "Ht") value = getHt(jets.product());
3980 >  else if(variable == "pthat")   value = object2->pthat;
3981 >  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3982 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3983    value = applyFunction(function, value);
3984  
3985    return value;
# Line 3579 | Line 3992 | OSUAnalysis::valueLookup (const BNjet* o
3992  
3993    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3994    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3995 <  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3995 >  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3996    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3997    else if(variable == "invMass"){
3998      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3601 | Line 4014 | OSUAnalysis::valueLookup (const BNjet* o
4014      value = object1->charge*object2->charge;
4015    }
4016  
4017 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4017 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4018    value = applyFunction(function, value);
4019  
4020    return value;
# Line 3617 | Line 4030 | OSUAnalysis::valueLookup (const BNelectr
4030    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
4031    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
4032    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
4033 +  else if(variable == "deltaRLooseMvaId") {
4034 +    // only consider electrons that pass "loose MVA id", i.e., mvaNonTrigV0 > 0;
4035 +    // otherwise return very large value (99)  
4036 +    if (object1->mvaNonTrigV0>0) value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
4037 +    else                         value = 99.;  
4038 +  }
4039    else if(variable == "invMass"){
4040      fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, electronMass);
4041      fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, electronMass );
# Line 3626 | Line 4045 | OSUAnalysis::valueLookup (const BNelectr
4045    else if(variable == "chargeProduct"){
4046      value = object1->charge*object2->charge;
4047    }
4048 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4048 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4049    value = applyFunction(function, value);
4050    return value;
4051  
# Line 3644 | Line 4063 | OSUAnalysis::valueLookup (const BNmuon*
4063    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
4064    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
4065    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
4066 +  else if(variable == "deltaRLooseID") {
4067 +    // only consider muons that pass looseId criteria; otherwise return very large value (99.)  
4068 +    string empty = "";  
4069 +    double isLooseId = valueLookup(object1, "looseID", "", empty);    
4070 +    if (isLooseId) value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
4071 +    else           value = 99.;  
4072 +  }
4073 +  else if(variable == "deltaRGlobalMuon") {
4074 +    // only consider muons that pass looseId criteria; otherwise return very large value (99.)  
4075 +    if (object1->isGlobalMuon) value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
4076 +    else                       value = 99.;  
4077 +  }
4078    else if(variable == "invMass"){
4079      fourVector1.SetPtEtaPhiM(object1->pt, object1->eta, object1->phi, muonMass);
4080      fourVector2.SetPtEtaPhiM(object2->pt, object2->eta, object2->phi, pionMass );
# Line 3654 | Line 4085 | OSUAnalysis::valueLookup (const BNmuon*
4085      value = object1->charge*object2->charge;
4086    }
4087  
4088 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4088 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4089    value = applyFunction(function, value);
4090    return value;
4091   }
# Line 3676 | Line 4107 | OSUAnalysis::valueLookup (const BNtau* o
4107      value = object1->charge*object2->charge;
4108    }
4109  
4110 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4110 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4111    value = applyFunction(function, value);
4112    return value;
4113   }
# Line 3698 | Line 4129 | OSUAnalysis::valueLookup (const BNmuon*
4129      value = object1->charge*object2->charge;
4130    }
4131  
4132 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4132 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4133    value = applyFunction(function, value);
4134    return value;
4135   }
# Line 3709 | Line 4140 | OSUAnalysis::valueLookup (const BNtau* o
4140    double value = 0.0;
4141    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
4142    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
4143 +  else if(variable == "deltaRLooseHadronicID") {
4144 +    // only consider tau's that pass the loose hadronic ID criteria; otherwise return very large value (99)  
4145 +    string empty = "";  
4146 +    double isLooseHadronicID = valueLookup(object1, "looseHadronicID", "", empty);    
4147 +  
4148 +    if (isLooseHadronicID) value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
4149 +    else                   value = 99.;  
4150 +  }
4151    else if(variable == "chargeProduct"){
4152      value = object1->charge*object2->charge;
4153    }
4154  
4155 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4155 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
4156    value = applyFunction(function, value);
4157    return value;
4158   }
# Line 3733 | Line 4172 | OSUAnalysis::valueLookup (const BNtrack*
4172    else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
4173    else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
4174  
4175 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4175 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4176  
4177    value = applyFunction(function, value);
4178  
# Line 3755 | Line 4194 | OSUAnalysis::valueLookup (const BNelectr
4194        stringValue = "none";
4195    }
4196  
4197 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4197 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4198  
4199    value = applyFunction(function, value);
4200  
# Line 3771 | Line 4210 | OSUAnalysis::valueLookup (const BNmuon*
4210  
4211    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
4212  
4213 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4213 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4214  
4215    value = applyFunction(function, value);
4216  
# Line 3884 | Line 4323 | OSUAnalysis::valueLookup (const BNstop*
4323      }
4324    }
4325  
4326 +  else if (variable == "decaysToTau"){
4327 +    value = abs (object->daughter0Id) == 15 || abs (object->daughter1Id) == 15;
4328 +  }
4329 +
4330  
4331  
4332  
4333 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4333 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4334  
4335    value = applyFunction(function, value);
4336  
# Line 3912 | Line 4355 | OSUAnalysis::getTrkIsIso (const BNtrack*
4355  
4356   }
4357  
4358 + //calculate the scalar sum of Jet Pt in the event.
4359 + double
4360 + OSUAnalysis::getHt (const BNjetCollection* jetColl){
4361 +  double Ht = 0;
4362 +  for(BNjetCollection::const_iterator jet = jetColl->begin(); jet !=jetColl->end(); jet++){
4363 +    Ht += abs(jet->pt);
4364 +  }
4365 +  return Ht;
4366 + }
4367  
4368   double
4369   OSUAnalysis::getTrkPtRes (const BNtrack* track1){
# Line 3949 | Line 4401 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4401    // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
4402    if (!useTrackCaloRhoCorr_) return -99;
4403    // if (!rhokt6CaloJetsHandle_) {
4404 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4404 >  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4405    //   return -99;
4406    // }
4407    double radDeltaRCone = 0.5;
# Line 3960 | Line 4412 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4412  
4413   }
4414  
4415 + double
4416 + OSUAnalysis::getTrkDepTrkRp5RhoCorr(const BNtrack* track) {
4417 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.              
4418 +  if (!useTrackCaloRhoCorr_) return -99;
4419 +  // if (!rhokt6CaloJetsHandle_) {                                                                                                    
4420 +  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;                        
4421 +  //   return -99;                                                                                                                    
4422 +  // }                                                                                                                                
4423 +  double radDeltaRCone = 0.5;
4424 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  // Define effective area as pi*r^2, where r is radius of DeltaR cone.                                                                                                          
4425 +  double rawDepTrkRp5 = track->depTrkRp5;
4426 + double depTrkRp5RhoCorr = TMath::Max(0., rawDepTrkRp5 - rhoCorr_kt6CaloJets);
4427 + return depTrkRp5RhoCorr;
4428 +
4429 + }
4430 +
4431 + double
4432 + OSUAnalysis::getTrkDepTrkRp3RhoCorr(const BNtrack* track) {
4433 +  // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.                                                
4434 +  if (!useTrackCaloRhoCorr_) return -99;
4435 +  // if (!rhokt6CaloJetsHandle_) {                                                                                                                                      
4436 +  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;                                                          
4437 +  //   return -99;                                                                                                                                                      
4438 +  // }                                                                                                                                                                  
4439 +  double radDeltaRCone = 0.3;
4440 + // Define effective area as pi*r^2, where r is radius of DeltaR cone
4441 +  double rhoCorr_kt6CaloJets = *rhokt6CaloJetsHandle_ * TMath::Pi() * pow(radDeltaRCone, 2);  
4442 +  double rawDepTrkRp3 = track->depTrkRp3;
4443 +  double depTrkRp3RhoCorr = TMath::Max(0., rawDepTrkRp3 - rhoCorr_kt6CaloJets);
4444 +  return depTrkRp3RhoCorr;
4445 +  
4446 + }
4447 +
4448  
4449  
4450  
# Line 3971 | Line 4456 | OSUAnalysis::WriteDeadEcal (){
4456    double etaEcal, phiEcal;
4457    ifstream DeadEcalFile(deadEcalFile_);
4458    if(!DeadEcalFile) {
4459 <    cout << "Error: DeadEcalFile has not been found." << endl;
4459 >    clog << "Error: DeadEcalFile has not been found." << endl;
4460      return;
4461    }
4462    if(DeadEcalVec.size()!= 0){
4463 <    cout << "Error: DeadEcalVec has a nonzero size" << endl;
4463 >    clog << "Error: DeadEcalVec has a nonzero size" << endl;
4464      return;
4465    }
4466    while(!DeadEcalFile.eof())
# Line 3986 | Line 4471 | OSUAnalysis::WriteDeadEcal (){
4471        newChan.phiEcal = phiEcal;
4472        DeadEcalVec.push_back(newChan);
4473      }
4474 <  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
4474 >  if(DeadEcalVec.size() == 0) clog << "Warning: No dead Ecal channels have been found." << endl;
4475   }
4476  
4477   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
# Line 4026 | Line 4511 | OSUAnalysis::applyFunction(string functi
4511    else if(function == "log") value = log10(value);
4512  
4513    else if(function == "") value = value;
4514 <  else{cout << "WARNING: invalid function '" << function << "'\n";}
4514 >  else{clog << "WARNING: invalid function '" << function << "'\n";}
4515  
4516    return value;
4517  
# Line 4036 | Line 4521 | OSUAnalysis::applyFunction(string functi
4521   template <class InputCollection>
4522   void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, InputCollection inputCollection, string inputType){
4523  
4524 +  if (verbose_>2) clog << "  Beginning setObjectFlags for cut " << currentCutIndex << ": " << currentCut.name
4525 +                       << ", inputType=" << inputType
4526 +                       << endl;  
4527    if (currentCut.inputCollection.find("pair")!=string::npos)  {
4528      string obj1, obj2;
4529      getTwoObjs(currentCut.inputCollection, obj1, obj2);
4530 +    if (verbose_>2) clog << "  Two object types:  " << obj1 << ", " << obj2 << endl;
4531      if (inputType==obj1 ||
4532          inputType==obj2) {
4533        // Do not add a cut to individualFlags or cumulativeFlags, if the cut is on a paired collection,
# Line 4050 | Line 4539 | void OSUAnalysis::setObjectFlags(cut &cu
4539      }
4540    }
4541  
4542 +  if (!inputCollection) cout << "ERROR:  invalid input collection for inputType=" << inputType << endl;  
4543 +
4544 +  if (verbose_>3) clog << "   Collection size:  " << inputCollection->size() << endl;
4545 +
4546    for (uint object = 0; object != inputCollection->size(); object++){
4547  
4548 +    if (verbose_>4) clog << "    Setting flags for object " << object << endl;
4549 +
4550      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4551      bool plotDecision = true;
4552  
# Line 4076 | Line 4571 | void OSUAnalysis::setObjectFlags(cut &cu
4571          }
4572          cutDecision = tempDecision;
4573        }
4574 <      //invert the cut for plotting if this cut is a veto
4575 <      if(currentCut.isVeto) plotDecision = !cutDecision;
4576 <      else plotDecision = cutDecision;
4574 >      //invert the cut if this cut is a veto
4575 >      if(currentCut.isVeto) cutDecision = !cutDecision;
4576 >      plotDecision = cutDecision;
4577      }
4578  
4579      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
# Line 4099 | Line 4594 | void OSUAnalysis::setObjectFlags(cut &cu
4594  
4595      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4596  
4597 <  }
4597 >  }  //   for (uint object = 0; object != inputCollection->size(); object++){
4598  
4599 < }
4599 > } // end void OSUAnalysis::setObjectFlags
4600  
4601  
4602   template <class InputCollection1, class InputCollection2>
4603 < void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags, \
4604 <                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, string inputType){
4605 <
4603 > void OSUAnalysis::setObjectFlags(cut &currentCut, uint currentCutIndex, flagMap &individualFlags, flagMap &cumulativeFlags,
4604 >                                 InputCollection1 inputCollection1, InputCollection2 inputCollection2, string inputType){
4605 >  // This function sets the flags for the paired object collection.  
4606 >  // If the cut is applying on the given paired object collection, then the flags for the single object collections are also set.
4607 >  // If not, then the flags for the paired object collection are taken as the AND of the flags for each single object collection.  
4608 >
4609 >  if (verbose_>2) clog << "  Beginning setObjectFlags for cut=" << currentCut.name
4610 >                       << ", inputType=" << inputType
4611 >                       << endl;  
4612  
4613    bool sameObjects = false;
4614 <  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
4614 >  if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;  // FIXME:  is sameObjects just the not of isTwoTypesOfObject?  If so, it's redundant.  
4615  
4616    // Get the strings for the two objects that make up the pair.
4617    string obj1Type, obj2Type;
# Line 4141 | Line 4642 | void OSUAnalysis::setObjectFlags(cut &cu
4642        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4643  
4644  
4645 <      bool cutDecision = true;//object passes if this cut doesn't cut on that type of object
4645 >      bool cutDecision  = true;//object passes if this cut doesn't cut on that type of object
4646        bool plotDecision = true;
4647  
4648 +      // Determine whether each pair passes the cut, only if inputCollection is the same as the inputType.  
4649        if(currentCut.inputCollection == inputType){
4650  
4651          vector<bool> subcutDecisions;
4652          for( int subcutIndex = 0; subcutIndex != currentCut.numSubcuts; subcutIndex++){
4653            string stringValue = "";
4654            double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), currentCut.variables.at(subcutIndex), currentCut.functions.at(subcutIndex), stringValue);
4655 +          if (verbose_>1) clog << currentCut.variables.at(subcutIndex) << " = " << value
4656 +                               << endl;  
4657            if (stringValue == "") subcutDecisions.push_back(evaluateComparison(value,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutValues.at(subcutIndex)));
4658            else subcutDecisions.push_back(evaluateComparison(stringValue,currentCut.comparativeOperators.at(subcutIndex),currentCut.cutStringValues.at(subcutIndex)));
4659          }
# Line 4165 | Line 4669 | void OSUAnalysis::setObjectFlags(cut &cu
4669            }
4670            cutDecision = tempDecision;
4671          }
4672 <        //invert the cut for plotting if this cut is a veto
4673 <        if(currentCut.isVeto) plotDecision = !cutDecision;
4674 <        else plotDecision = cutDecision;
4675 <      }
4676 <      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4677 <      if (cutDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4678 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4679 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4680 <      }
4681 <      if (plotDecision && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4682 <        individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4683 <        individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4684 <      }
4672 >        //invert the cut if this cut is a veto
4673 >        if (currentCut.isVeto) cutDecision = !cutDecision;
4674 >        plotDecision = cutDecision;
4675 >
4676 >        if (verbose_>1) clog << " cutDecision = " << cutDecision
4677 >                             << "; for currentCut.inputCollection = " << currentCut.inputCollection
4678 >                             << "; object1 (" << obj1Type << ") = " << object1
4679 >                             << "; object2 (" << obj2Type << ") = " << object2
4680 >                             << endl;  
4681 >        
4682 >        if (cutDecision) {  // only set the flags for the individual objects if the pair object is being cut on
4683 >          individualFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true;
4684 >          individualFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true;
4685 >        }
4686 >        if (plotDecision) {  // only set the flags for the individual objects if the pair object is being cut on
4687 >          individualFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true;
4688 >          individualFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true;
4689 >        }
4690 >        
4691 >
4692 >      } // if(currentCut.inputCollection == inputType){
4693 >
4694 >      // The individualFlags will be true if the inputCollection is not the same as the inputType.
4695 >      // They are also independent of the previous flags on the single objects.  
4696 >      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));  
4697 >
4698  
4699 <      //set flags for objects that pass this cut AND all the previous cuts
4699 >
4700 >      // ************************************
4701 >      // Determine cumulative flags
4702 >      // ************************************
4703 >      // determine whether this paired object passes this cut AND all previous cuts
4704        bool previousCumulativeCutFlag = true;
4705        for(uint previousCutIndex = 0; previousCutIndex != currentCutIndex; previousCutIndex++){
4706 <        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4707 <        else{ previousCumulativeCutFlag = false; break;}
4706 >        if(previousCumulativeCutFlag && individualFlags.at(inputType).at(previousCutIndex).at(counter).first) previousCumulativeCutFlag = true;
4707 >        else{ previousCumulativeCutFlag = false; break;}
4708        }
4709        previousCumulativeCutFlag = previousCumulativeCutFlag && cutDecision;
4710  
# Line 4194 | Line 4715 | void OSUAnalysis::setObjectFlags(cut &cu
4715        }
4716        previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4717        
4718 <      //apply flags for the components of the composite object as well
4718 >      // Get the index for the flags of each of the single objects in the pair.  Usually this is the index of the previous cut, i.e., currentCutIndex-1.    
4719 >      int cutIdxFlagsObj1 = max(int(currentCutIndex-1),0);
4720 >      int cutIdxFlagsObj2 = max(int(currentCutIndex-1),0);
4721 >      // If the inputCollection of the cut is not equal to the inputType but the inputCollection includes objects that are contained in inputType, then use the currentCutIndex for those collections.
4722 >      // For example, if the inputType is jet-jet pairs, and the inputCollection is track-jet pairs, then use currentCutIndex for cutIdxFlagsObj{1,2}, i.e., for both jets.  
4723 >      // For example, if the inputType is jets, and the inputCollection is track-jet pairs, then use currentCutIndex for cutIdxFlagsObj2 (jets) and currentCutIndex-1 for cutIdxFlagsObj1 (tracks).  
4724 >      if (currentCut.inputCollection != inputType) {  
4725 >        if (currentCut.inputCollection.find(obj1Type)!=string::npos) cutIdxFlagsObj1 = currentCutIndex;
4726 >        if (currentCut.inputCollection.find(obj2Type)!=string::npos) cutIdxFlagsObj2 = currentCutIndex;
4727 >      }  
4728 >      flagPair flags1 = cumulativeFlags.at(obj1Type).at(cutIdxFlagsObj1);  // flag for input collection 1
4729 >      flagPair flags2 = cumulativeFlags.at(obj2Type).at(cutIdxFlagsObj2);  // flag for input collection 2
4730 >      
4731 >      // The cumulative flag is only true if the paired object cumulative flag is true, and if the single object cumulative flags are true.  
4732        bool currentCumulativeCutFlag = true;
4733        bool currentCumulativePlotFlag = true;
4200
4734        if(flags1.size() == 0 && flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag;
4735        else if(flags1.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags2.at(object2).first;
4736        else if(flags2.size() == 0) currentCumulativeCutFlag = previousCumulativeCutFlag && flags1.at(object1).first;
# Line 4208 | Line 4741 | void OSUAnalysis::setObjectFlags(cut &cu
4741        else if(flags2.size() == 0) currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).second;
4742        else currentCumulativePlotFlag = previousCumulativePlotFlag && flags1.at(object1).first && flags2.at(object2).second;
4743  
4744 <      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));
4744 >      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(currentCumulativeCutFlag,currentCumulativePlotFlag));  // Set the flag for the paired object
4745  
4213      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4214        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4215        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4216      }
4746  
4747 <      if (currentCumulativePlotFlag && currentCut.inputCollection == inputType) {  // only set the flags for the individual objects if the pair object is being cut on
4747 >      if (currentCumulativeCutFlag && currentCut.inputCollection == inputType) {  // Set the flags for the individual objects if the paired object is being cut on.  
4748 >        cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).first  = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "cut");
4749 >        cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).first  = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut");
4750          cumulativeFlags.at(obj1Type).at(currentCutIndex).at(object1).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj1Type, object1, "plot");
4751          cumulativeFlags.at(obj2Type).at(currentCutIndex).at(object2).second = true && getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "plot");
4752 +
4753 +        if (verbose_>1) clog << " previousCumulativeCutFlag for object1 = " << getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object1, "cut") << endl;  
4754 +        if (verbose_>1) clog << " previousCumulativeCutFlag for object2 = " << getPreviousCumulativeFlags(currentCutIndex, individualFlags, obj2Type, object2, "cut") << endl;  
4755 +
4756        }
4757  
4758        counter++;
# Line 4225 | Line 4760 | void OSUAnalysis::setObjectFlags(cut &cu
4760      } // end   for (uint object2 = 0; object2 != inputCollection2->size(); object2++)
4761    }  // end   for (uint object1 = 0; object1 != inputCollection1->size(); object1++)
4762  
4763 < }
4763 > } // end void OSUAnalysis::setObjectFlags
4764  
4765  
4766   bool OSUAnalysis::getPreviousCumulativeFlags(uint currentCutIndex, flagMap &individualFlags, string obj1Type, uint object1, string flagType) {
# Line 4252 | Line 4787 | template <class InputCollection>
4787   void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4788    // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4789  
4790 <  if (BNTreeBranchVals_.count(parameters.name)==0) cout << "Error[assignTreeBranch]:  trying to assign value to " << parameters.name << " that does not have a branch set up.  Will likely seg fault." << endl;
4790 >  if (BNTreeBranchVals_.count(parameters.name)==0) clog << "Error[assignTreeBranch]:  trying to assign value to " << parameters.name << " that does not have a branch set up.  Will likely seg fault." << endl;
4791    for (uint object = 0; object != inputCollection->size(); object++) {
4792  
4793      if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
# Line 4270 | Line 4805 | void OSUAnalysis::assignTreeBranch(Branc
4805   template <class InputCollection>
4806   void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection inputCollection, flagPair flags, double scaleFactor){
4807  
4808 +  if (verbose_>2) clog << "  Filling histogram for " << parameters.name << endl;  
4809  
4810    for (uint object = 0; object != inputCollection->size(); object++){
4811  
# Line 4293 | Line 4829 | void OSUAnalysis::fill1DHistogram(TH1* h
4829  
4830      if (printEventInfo_) {
4831        // Write information about event to screen, for testing purposes.
4832 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4832 >      clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << " (object number " << object << ")" << endl;
4833      }
4834  
4835    }
4836   }
4837  
4838   template <class InputCollection1, class InputCollection2>
4839 < void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4839 > void OSUAnalysis::fill1DHistogram(TH1* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2,
4840 >                                  flagPair pairFlags, double scaleFactor){
4841  
4842    bool sameObjects = false;
4843    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 4312 | Line 4849 | void OSUAnalysis::fill1DHistogram(TH1* h
4849        if(sameObjects && object1 >= object2) continue;//account for duplicate pairs if both collections are the same
4850  
4851        pairCounter++;
4315      //only take objects which have passed all cuts and pairs which have passed all cuts
4316      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4317      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4852        if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4853  
4854        string currentString = parameters.inputVariables.at(0);
# Line 4333 | Line 4867 | void OSUAnalysis::fill1DHistogram(TH1* h
4867        double value = valueLookup(&inputCollection1->at(object1), &inputCollection2->at(object2), inputVariable, function, stringValue);
4868        histo->Fill(value,scaleFactor);
4869  
4870 +      if (printEventInfo_) {
4871 +        // Write information about event to screen, for testing purposes.
4872 +        clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value
4873 +             << " (object1 number " << object1 << "), "
4874 +             << " (object2 number " << object2 << ")"
4875 +             << endl;
4876 +      }
4877 +      
4878      }
4879    }
4880  
# Line 4381 | Line 4923 | void OSUAnalysis::fill2DHistogram(TH2* h
4923   }
4924  
4925   template <class InputCollection1, class InputCollection2>
4926 < void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2, flagPair flags1, flagPair flags2, flagPair pairFlags, double scaleFactor){
4926 > void OSUAnalysis::fill2DHistogram(TH2* histo, histogram parameters, InputCollection1 inputCollection1, InputCollection2 inputCollection2,
4927 >                                  flagPair pairFlags, double scaleFactor){
4928  
4929    bool sameObjects = false;
4930    if(typeid(InputCollection1).name() == typeid(InputCollection2).name()) sameObjects = true;
# Line 4394 | Line 4937 | void OSUAnalysis::fill2DHistogram(TH2* h
4937  
4938        pairCounter++;
4939  
4397      //only take objects which have passed all cuts and pairs which have passed all cuts
4398      if(!plotAllObjectsInPassingEvents_ && !flags1.at(object1).second) continue;
4399      if(!plotAllObjectsInPassingEvents_ && !flags2.at(object2).second) continue;
4940        if(!plotAllObjectsInPassingEvents_ && !pairFlags.at(pairCounter).second) continue;
4941  
4942        string stringValue = "";
# Line 4445 | Line 4985 | int OSUAnalysis::getGenMatchedParticleIn
4985  
4986      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4987      if(currentDeltaR > 0.05) continue;
4988 <    //     cout << setprecision(3) << setw(20)
4988 >    //     clog << setprecision(3) << setw(20)
4989      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4990      //          << setw(20)
4991      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
# Line 4464 | Line 5004 | int OSUAnalysis::getGenMatchedParticleIn
5004      }
5005  
5006    }
5007 <  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
5008 <  //   else cout << "no match found..." << endl;
5007 >  //   if(bestMatchDeltaR != 999)  clog << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
5008 >  //   else clog << "no match found..." << endl;
5009    return bestMatchIndex;
5010  
5011   }
# Line 4649 | Line 5189 | OSUAnalysis::chosenMuon ()
5189    return chosenMuon;
5190   }
5191  
5192 + double
5193 + OSUAnalysis::chosenHT ()
5194 + {
5195 +  double chosenHT = 0.0;
5196 +  if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
5197 +    flagPair jetFlags;
5198 +    for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
5199 +      if (cumulativeFlags.at("jets").at(i).size()){
5200 +        jetFlags = cumulativeFlags.at("jets").at(i);
5201 +        break;
5202 +      }
5203 +    }
5204 +    for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
5205 +      if(!jetFlags.at(jetIndex).first) continue;
5206 +      chosenHT += jets->at(jetIndex).pt;
5207 +    }
5208 +  }
5209 +
5210 +  return chosenHT;
5211 + }
5212 +
5213 + pair<const BNmuon *, const BNmuon *>
5214 + OSUAnalysis::leadMuonPair ()
5215 + {
5216 +  pair<const BNmuon *, const BNmuon *> leadMuonPair;
5217 +  leadMuonPair.first = leadMuonPair.second = 0;
5218 +
5219 +  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
5220 +    flagPair muonFlags;
5221 +    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
5222 +      if (cumulativeFlags.at("muons").at(i).size()){
5223 +        muonFlags = cumulativeFlags.at("muons").at(i);
5224 +        break;
5225 +      }
5226 +    }
5227 +    for (uint muonIndex0 = 0; muonIndex0 != muonFlags.size(); muonIndex0++){
5228 +      if(!muonFlags.at(muonIndex0).first) continue;
5229 +      for (uint muonIndex1 = muonIndex0 + 1; muonIndex1 < muonFlags.size(); muonIndex1++){
5230 +        if(!muonFlags.at(muonIndex1).first) continue;
5231 +        const BNmuon *mu0 = & muons->at(muonIndex0);
5232 +        const BNmuon *mu1 = & muons->at(muonIndex1);
5233 +        if(leadMuonPair.first == 0 || leadMuonPair.second == 0){
5234 +          leadMuonPair.first = mu0;
5235 +          leadMuonPair.second = mu1;
5236 +        }
5237 +        else{
5238 +          TVector2 newPt0 (mu0->px, mu0->py),
5239 +                   newPt1 (mu1->px, mu1->py),
5240 +                   oldPt0 (leadMuonPair.first->px, leadMuonPair.first->py),
5241 +                   oldPt1 (leadMuonPair.second->px, leadMuonPair.second->py);
5242 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
5243 +            {
5244 +              leadMuonPair.first = mu0;
5245 +              leadMuonPair.second = mu1;
5246 +            }
5247 +        }
5248 +      }
5249 +    }
5250 +  }
5251 +
5252 +  return leadMuonPair;
5253 + }
5254 +
5255 + pair<const BNelectron *, const BNelectron *>
5256 + OSUAnalysis::leadElectronPair ()
5257 + {
5258 +  pair<const BNelectron *, const BNelectron *> leadElectronPair;
5259 +  leadElectronPair.first = leadElectronPair.second = 0;
5260 +  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
5261 +    flagPair electronFlags;
5262 +    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
5263 +      if (cumulativeFlags.at("electrons").at(i).size()){
5264 +        electronFlags = cumulativeFlags.at("electrons").at(i);
5265 +        break;
5266 +      }
5267 +    }
5268 +    for (uint electronIndex0 = 0; electronIndex0 != electronFlags.size(); electronIndex0++){
5269 +      if(!electronFlags.at(electronIndex0).first) continue;
5270 +      for (uint electronIndex1 = electronIndex0 + 1; electronIndex1 < electronFlags.size(); electronIndex1++){
5271 +        if(!electronFlags.at(electronIndex1).first) continue;
5272 +        const BNelectron *el0 = & electrons->at(electronIndex0);
5273 +        const BNelectron *el1 = & electrons->at(electronIndex1);
5274 +        if(leadElectronPair.first == 0 || leadElectronPair.second == 0){
5275 +          leadElectronPair.first = el0;
5276 +          leadElectronPair.second = el1;
5277 +        }
5278 +        else{
5279 +          TVector2 newPt0 (el0->px, el0->py),
5280 +                   newPt1 (el1->px, el1->py),
5281 +                   oldPt0 (leadElectronPair.first->px, leadElectronPair.first->py),
5282 +                   oldPt1 (leadElectronPair.second->px, leadElectronPair.second->py);
5283 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
5284 +            {
5285 +              leadElectronPair.first = el0;
5286 +              leadElectronPair.second = el1;
5287 +            }
5288 +        }
5289 +      }
5290 +    }
5291 +  }
5292 +
5293 +  return leadElectronPair;
5294 + }
5295 +
5296   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines