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.88 by jbrinson, Mon Jun 24 15:52:58 2013 UTC vs.
Revision 1.102 by wulsin, Mon Jul 22 15:22:57 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")),
# Line 35 | Line 34 | OSUAnalysis::OSUAnalysis (const edm::Par
34    applyLeptonSF_ (cfg.getParameter<bool> ("applyLeptonSF")),
35    applyBtagSF_ (cfg.getParameter<bool> ("applyBtagSF")),
36    minBtag_ (cfg.getParameter<int> ("minBtag")),
38  maxBtag_ (cfg.getParameter<int> ("maxBtag")),
37    printEventInfo_      (cfg.getParameter<bool> ("printEventInfo")),
38    printAllTriggers_    (cfg.getParameter<bool> ("printAllTriggers")),
39    useTrackCaloRhoCorr_ (cfg.getParameter<bool> ("useTrackCaloRhoCorr")),
# Line 67 | Line 65 | OSUAnalysis::OSUAnalysis (const edm::Par
65    //always get vertex collection so we can assign the primary vertex in the event
66    objectsToGet.push_back("primaryvertexs");
67    objectsToPlot.push_back("primaryvertexs");
68 <  objectsToCut.push_back("primaryvertexs");
68 >  objectsToFlag.push_back("primaryvertexs");
69  
70  
71    //always get the MC particles to do GEN-matching
# Line 80 | Line 78 | OSUAnalysis::OSUAnalysis (const edm::Par
78    // Parse the tree variable definitions.
79    for (uint iBranchSet = 0; !useEDMFormat_ && iBranchSet<treeBranchSets_.size(); iBranchSet++) {
80      string tempInputCollection = treeBranchSets_.at(iBranchSet).getParameter<string> ("inputCollection");
81 <    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; }
81 >    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; }
82      objectsToGet.push_back(tempInputCollection);
83 <    objectsToCut.push_back(tempInputCollection);
83 >    objectsToFlag.push_back(tempInputCollection);
84  
85      vector<string> branchList(treeBranchSets_.at(iBranchSet).getParameter<vector<string> >("branches"));
86  
# Line 108 | Line 106 | OSUAnalysis::OSUAnalysis (const edm::Par
106      if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
107      if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
108      if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
109 +    if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
110 +    if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
111 +    if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
112      if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
113      if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
114      if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
115 +    if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
116      if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
117      if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
118      if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
# Line 127 | Line 129 | OSUAnalysis::OSUAnalysis (const edm::Par
129          objectsToGet.push_back(tempInputCollection);
130        }
131        objectsToPlot.push_back(tempInputCollection);
132 <      objectsToCut.push_back(tempInputCollection);
132 >      objectsToFlag.push_back(tempInputCollection);
133      } else { //pair of objects, need to add the pair and the individual objects to the lists of things to Get/Plot/Cut
134        string obj1;
135        string obj2;
136        getTwoObjs(tempInputCollection, obj1, obj2);
137        string obj2ToGet = getObjToGet(obj2);
138 <      objectsToCut.push_back(tempInputCollection);
139 <      objectsToCut.push_back(obj1);
140 <      objectsToCut.push_back(obj2);
138 >      objectsToFlag.push_back(tempInputCollection);
139 >      objectsToFlag.push_back(obj1);
140 >      objectsToFlag.push_back(obj2);
141        objectsToPlot.push_back(tempInputCollection);
142        objectsToPlot.push_back(obj1);
143        objectsToPlot.push_back(obj2);
# Line 143 | Line 145 | OSUAnalysis::OSUAnalysis (const edm::Par
145        objectsToGet.push_back(obj1);
146        objectsToGet.push_back(obj2ToGet);
147      } // end else
148 <
148 >      if (find(objectsToPlot.begin(), objectsToPlot.end(), "events") != objectsToPlot.end())
149 >        objectsToGet.push_back("jets");
150  
151  
152      vector<edm::ParameterSet> histogramList_  (histogramSets_.at(currentHistogramSet).getParameter<vector<edm::ParameterSet> >("histograms"));
# Line 177 | Line 180 | OSUAnalysis::OSUAnalysis (const edm::Par
180    for(uint currentObjectIndex = 0; currentObjectIndex != objectsToPlot.size(); currentObjectIndex++){
181  
182      string currentObject = objectsToPlot.at(currentObjectIndex);
183 <    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "superclusters") continue;
183 >    if(currentObject != "muons" && currentObject != "secondary muons" && currentObject != "secondary electrons" && currentObject != "electrons" && currentObject != "taus" && currentObject != "tracks" && currentObject != "photons" && currentObject != "secondary photons"&& currentObject != "superclusters") continue;
184  
185      histogram tempIdHisto;
186      histogram tempMomIdHisto;
# Line 192 | Line 195 | OSUAnalysis::OSUAnalysis (const edm::Par
195      tempIdVsGmaIdHisto.inputCollection = currentObject;
196  
197      if(currentObject == "secondary muons") currentObject = "secondaryMuons";
198 +    if(currentObject == "secondary photons") currentObject = "secondaryPhotons";
199      if(currentObject == "secondary electrons") currentObject = "secondaryElectrons";
200  
201      currentObject = currentObject.substr(0, currentObject.size()-1);
# Line 290 | Line 294 | OSUAnalysis::OSUAnalysis (const edm::Par
294        if(tempInputCollection == "photon-muon pairs") tempInputCollection = "muon-photon pairs";
295        if(tempInputCollection == "jet-electron pairs") tempInputCollection = "electron-jet pairs";
296        if(tempInputCollection == "jet-muon pairs") tempInputCollection = "muon-jet pairs";
297 +      if(tempInputCollection == "event-muon pairs") tempInputCollection = "muon-event pairs";
298 +      if(tempInputCollection == "jet-met pairs")  tempInputCollection = "met-jet pairs";
299 +      if(tempInputCollection == "track-jet pairs")  tempInputCollection = "track-jet pairs";
300        if(tempInputCollection == "jet-photon pairs") tempInputCollection = "photon-jet pairs";
301        if(tempInputCollection == "event-track pairs")   tempInputCollection = "track-event pairs";
302        if(tempInputCollection == "secondary muon-muon pairs")   tempInputCollection = "muon-secondary muon pairs";
303        if(tempInputCollection == "secondary jet-jet pairs")   tempInputCollection = "jet-secondary jet pairs";
304        if(tempInputCollection == "secondary jet-muon pairs")   tempInputCollection = "muon-secondary jet pairs";
305 +      if(tempInputCollection == "secondary photon-muon pairs")   tempInputCollection = "muon-secondary photon pairs";
306        if(tempInputCollection == "secondary jet-photon pairs")   tempInputCollection = "photon-secondary jet pairs";
307        if(tempInputCollection == "secondary jet-electron pairs")   tempInputCollection = "electron-secondary jet pairs";
308        if(tempInputCollection == "secondary electron-electron pairs")   tempInputCollection = "electron-secondary electron pairs";
# Line 311 | Line 319 | OSUAnalysis::OSUAnalysis (const edm::Par
319            objectsToGet.push_back(tempInputCollection);
320          }
321          objectsToCut.push_back(tempInputCollection);
322 +        objectsToFlag.push_back(tempInputCollection);
323        }
324        else{//pair of objects, need to add them both to objectsToGet
325          string obj1;
# Line 320 | Line 329 | OSUAnalysis::OSUAnalysis (const edm::Par
329          objectsToCut.push_back(tempInputCollection);
330          objectsToCut.push_back(obj1);
331          objectsToCut.push_back(obj2);
332 +        objectsToFlag.push_back(tempInputCollection);
333 +        objectsToFlag.push_back(obj1);
334 +        objectsToFlag.push_back(obj2);
335          objectsToGet.push_back(tempInputCollection);
336          objectsToGet.push_back(obj1);
337          objectsToGet.push_back(obj2ToGet);
# Line 332 | Line 344 | OSUAnalysis::OSUAnalysis (const edm::Par
344        string cutString = cuts_.at(currentCut).getParameter<string> ("cutString");
345        vector<string> cutStringVector = splitString(cutString);
346        if(cutStringVector.size()!=3 && cutStringVector.size() % 4 !=3){
347 <        cout << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
347 >        clog << "Error: Didn't find the expected number elements in the following cut string: '" << cutString << "'\n";
348          exit(0);
349        }
350        tempCut.numSubcuts = (cutStringVector.size()+1)/4;
# Line 358 | Line 370 | OSUAnalysis::OSUAnalysis (const edm::Par
370        string numberRequiredString = cuts_.at(currentCut).getParameter<string> ("numberRequired");
371        vector<string> numberRequiredVector = splitString(numberRequiredString);
372        if(numberRequiredVector.size()!=2){
373 <        cout << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
373 >        clog << "Error: Didn't find two elements in the following number requirement string: '" << numberRequiredString << "'\n";
374          exit(0);
375        }
376  
# Line 457 | Line 469 | OSUAnalysis::OSUAnalysis (const edm::Par
469            }
470          }
471          if(numBinsElements != 3 && numBinsElements !=6){
472 <          cout << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
472 >          clog << "Error: Didn't find correct number of bin specifications for histogram named '" << currentHistogram.name << "'\n";
473            exit(0);
474          }
475          else if((numBinsElements == 3 && numInputVariables !=1) || (numBinsElements == 6 && numInputVariables!=2)){
476 <          cout << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
476 >          clog << "Error: Didn't find correct number of input variables for histogram named '" << currentHistogram.name << "'\n";
477            exit(0);
478          }
479          else if(numBinsElements == 3){
# Line 565 | Line 577 | OSUAnalysis::OSUAnalysis (const edm::Par
577          if(currentObject == "muon-muon pairs")                currentObject = "dimuonPairs";
578          else if(currentObject == "electron-electron pairs")   currentObject = "dielectronPairs";
579          else if(currentObject == "electron-muon pairs")       currentObject = "electronMuonPairs";
580 <        else if(currentObject == "electron-photon pairs")       currentObject = "electronPhotonPairs";
581 <        else if(currentObject == "muon-photon pairs")       currentObject = "muonPhotonPairs";
580 >        else if(currentObject == "electron-photon pairs")     currentObject = "electronPhotonPairs";
581 >        else if(currentObject == "muon-photon pairs")         currentObject = "muonPhotonPairs";
582          else if(currentObject == "secondary jets")            currentObject = "secondaryJets";
583 +        else if(currentObject == "secondary photons")            currentObject = "secondaryPhotons";
584          else if(currentObject == "jet-jet pairs")             currentObject = "dijetPairs";
585          else if(currentObject == "jet-secondary jet pairs")   currentObject = "jetSecondaryJetPairs";
586          else if(currentObject == "electron-jet pairs")        currentObject = "electronJetPairs";
587          else if(currentObject == "muon-jet pairs")            currentObject = "muonJetPairs";
588 +        else if(currentObject == "muon-event pairs")            currentObject = "muonEventPairs";
589          else if(currentObject == "photon-jet pairs")            currentObject = "photonJetPairs";
590 +        else if(currentObject == "met-jet pairs")             currentObject = "metJetPairs";
591 +        else if(currentObject == "track-jet pairs")           currentObject = "trackJetPairs";
592          else if(currentObject == "muon-secondary jet pairs")  currentObject = "muonSecondaryJetPairs";
593 +        else if(currentObject == "muon-secondary photon pairs")  currentObject = "muonSecondaryPhotonPairs";
594          else if(currentObject == "photon-secondary jet pairs")  currentObject = "photonSecondaryJetPairs";
595          else if(currentObject == "electron-secondary jet pairs")  currentObject = "electronSecondaryJetPairs";
596          else if(currentObject == "track-event pairs")         currentObject = "trackEventPairs";
# Line 613 | Line 630 | OSUAnalysis::OSUAnalysis (const edm::Par
630    //make unique vector of objects we need to cut on
631    sort( objectsToCut.begin(), objectsToCut.end() );
632    objectsToCut.erase( unique( objectsToCut.begin(), objectsToCut.end() ), objectsToCut.end() );
633 +  //make unique vector of objects we need to set flags for
634 +  sort( objectsToFlag.begin(), objectsToFlag.end() );
635 +  objectsToFlag.erase( unique( objectsToFlag.begin(), objectsToFlag.end() ), objectsToFlag.end() );
636  
637    produces<map<string, bool> > ("channelDecisions");
638  
639 +  if (printEventInfo_) {
640 +    findEventsLog = new ofstream();  
641 +    findEventsLog->open("findEvents.txt");  
642 +    clog << "Listing run:lumi:event in file findEvents.txt for events that pass full selection (of any channel)." << endl;  
643 +  }
644 +
645   } // end constructor OSUAnalysis::OSUAnalysis()
646  
647  
# Line 627 | Line 653 | OSUAnalysis::~OSUAnalysis ()
653    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
654      delete cutFlows_.at(currentChannel);
655    }
656 +
657 +  if (findEventsLog) findEventsLog->close();  
658 +
659 +  clog << "=============================================" << endl;  
660 +  clog << "Successfully completed OSUAnalysis." << endl;  
661 +  clog << "=============================================" << endl;  
662 +
663   }
664  
665   void
666   OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
667   {
635  //cout << "**********************\n\n\n";
668    // Retrieve necessary collections from the event.
669  
670    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 698 | Line 730 | OSUAnalysis::produce (edm::Event &event,
730    //get pile-up event weight
731    if (doPileupReweighting_ && datasetType_ != "data") {
732      //for "data" datasets, the numTruePV is always set to -1
733 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
733 >    if (events->at(0).numTruePV < 0) clog << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
734      else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
735    }
736  
# Line 731 | Line 763 | OSUAnalysis::produce (edm::Event &event,
763      //loop over all cuts
764      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
765        cut currentCut = currentChannel.cuts.at(currentCutIndex);
766 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
767 <        string currentObject = objectsToCut.at(currentObjectIndex);
766 >
767 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
768 >        string currentObject = objectsToFlag.at(currentObjectIndex);
769  
770          //initialize maps to get ready to set cuts
771          individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
772          cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
773  
774        }
775 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
776 <        string currentObject = objectsToCut.at(currentObjectIndex);
775 >
776 >      //set flags for all relevant objects
777 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
778 >        string currentObject = objectsToFlag.at(currentObjectIndex);
779  
780          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
781  
782  
783          if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
784          else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
785 +        else if(currentObject == "secondary photons")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"secondary photons");
786          else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
787          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
788          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
# Line 775 | Line 811 | OSUAnalysis::produce (edm::Event &event,
811                                                                               cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
812                                                                               "muon-secondary muon pairs");
813  
814 +        else if(currentObject == "muon-secondary photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
815 +                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
816 +                                                                             cumulativeFlags.at("secondary photons").at(flagsForPairCutsIndex), \
817 +                                                                             "muon-secondary photon pairs");
818          else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
819                                                                               cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
820                                                                               cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
# Line 826 | Line 866 | OSUAnalysis::produce (edm::Event &event,
866                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
867                                                                    cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
868                                                                    "muon-jet pairs");
869 +        else if(currentObject == "muon-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),events.product(), \
870 +                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
871 +                                                                  cumulativeFlags.at("events").at(flagsForPairCutsIndex), \
872 +                                                                  "muon-event pairs");
873 +        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
874 +                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
875 +                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
876 +                                                                  "met-jet pairs");
877 +        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
878 +                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
879 +                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
880 +                                                                 "track-jet pairs");
881          else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
882                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
883                                                                    cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
# Line 891 | Line 943 | OSUAnalysis::produce (edm::Event &event,
943        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
944        eventPassedPreviousCuts.push_back(eventPassedAllCuts);
945      }
946 +    //applying all appropriate scale factors
947      double scaleFactor = masterScaleFactor;
895
948      muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
949 +
950      if(applyLeptonSF_ && datasetType_ != "data"){
951 <      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
951 >      //only apply SFs if we've cut on this object
952 >      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
953          flagPair muonFlags;
954 +        //get the last valid flags in the flag map
955          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
956            if (cumulativeFlags.at("muons").at(i).size()){
957              muonFlags = cumulativeFlags.at("muons").at(i);
958              break;
959            }
960          }
961 +        //apply the weight for each of those objects
962          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
963            if(!muonFlags.at(muonIndex).second) continue;
964            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
965          }
966        }
967 <      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
967 >      //only apply SFs if we've cut on this object
968 >      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
969          flagPair electronFlags;
970 +        //get the last valid flags in the flag map
971          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
972            if (cumulativeFlags.at("electrons").at(i).size()){
973              electronFlags = cumulativeFlags.at("electrons").at(i);
974              break;
975            }
976          }
977 +        //apply the weight for each of those objects
978          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
979            if(!electronFlags.at(electronIndex).second) continue;
980            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
# Line 923 | Line 982 | OSUAnalysis::produce (edm::Event &event,
982        }
983      }
984      if(applyBtagSF_ && datasetType_ != "data"){
985 <     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
986 <       flagPair jetFlags;
985 >      //only apply SFs if we've cut on this object
986 >      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
987 >        flagPair jetFlags;
988          vector<double> jetSFs;
989 +        //get the last valid flags in the flag map
990          for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
991            if (cumulativeFlags.at("jets").at(i).size()){
992              jetFlags = cumulativeFlags.at("jets").at(i);
993              break;
994            }
995          }
996 +        //apply the weight for each of those objects
997          for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
998            if(!jetFlags.at(jetIndex).second) continue;
999 <          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
999 >          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour, jets->at(jetIndex).eta);
1000            jetSFs.push_back(jetSFTmp);
1001          }
1002 <        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
1002 >        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_);
1003        }
1004      }
1005      scaleFactor *= muonScaleFactor_;
# Line 945 | Line 1007 | OSUAnalysis::produce (edm::Event &event,
1007      scaleFactor *= bTagScaleFactor_;
1008      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
1009  
1010 <    if (printEventInfo_) {
1010 >    if (printEventInfo_ && eventPassedAllCuts) {
1011        // Write information about event to screen, for testing purposes.
1012 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
1013 <           << ": run="  << events->at(0).run
1014 <           << "  lumi=" << events->at(0).lumi
1015 <           << "  event=" << events->at(0).evt
1012 >      clog << "Event passed all cuts in channel " <<  currentChannel.name
1013 >           << ":  run:lumi:evt=  "  << events->at(0).run
1014 >           << ":" << events->at(0).lumi
1015 >           << ":" << events->at(0).evt
1016             << endl;
1017 +      if (findEventsLog) {
1018 +        (*findEventsLog) << events->at(0).run
1019 +                         << ":" << events->at(0).lumi
1020 +                         << ":" << events->at(0).evt << endl;
1021 +      }
1022 +
1023      }
1024  
1025  
# Line 969 | Line 1037 | OSUAnalysis::produce (edm::Event &event,
1037          for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1038            histogram currentHistogram = histograms.at(histogramIndex);
1039  
1040 <          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1040 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) clog << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1041  
1042            if(currentHistogram.inputVariables.size() == 1){
1043              TH1D* histo;
1044              histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1045              if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1046              else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1047 +            else if(currentHistogram.inputCollection == "secondary photons")  fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1048              else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1049              else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1050              else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
# Line 985 | Line 1054 | OSUAnalysis::produce (edm::Event &event,
1054              else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1055                                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1056                                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1057 +             else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1058 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1059 +                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1060               else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1061                                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1062                                                                                                       cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
# Line 1021 | Line 1093 | OSUAnalysis::produce (edm::Event &event,
1093              else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1094                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1095                                                                                            cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1096 +            else if(currentHistogram.inputCollection == "muon-event pairs") fill1DHistogram(histo,currentHistogram, muons.product(),events.product(), \
1097 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1098 +                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1099 +            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1100 +                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1101 +                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1102 +            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1103 +                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1104 +                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1105              else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1106                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1107                                                                                            cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
# Line 1067 | Line 1148 | OSUAnalysis::produce (edm::Event &event,
1148              histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1149              if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1150              else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1151 +            else if(currentHistogram.inputCollection == "secondary photons")  fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1152              else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1153              else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1154              else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
# Line 1075 | Line 1157 | OSUAnalysis::produce (edm::Event &event,
1157              else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1158                                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1159                                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1160 +            else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1161 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1162 +                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1163              else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1164                                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1165                                                                                                       cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
# Line 1107 | Line 1192 | OSUAnalysis::produce (edm::Event &event,
1192              else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1193                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1194                                                                                            cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1195 +            else if(currentHistogram.inputCollection == "muon-event pairs") fill2DHistogram(histo,currentHistogram,muons.product(),events.product(), \
1196 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir), \
1197 +                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1198 +            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1199 +                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1200 +                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1201 +            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1202 +                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1203 +                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1204              else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1205                                                                                            cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1206                                                                                            cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
# Line 1164 | Line 1258 | OSUAnalysis::produce (edm::Event &event,
1258            if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1259            else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1260            else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1261 <          else if(currentObject == "electron-photon pairs")                objectToPlot = "electronPhotonPairs";
1261 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1262            else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1263            else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1264 +          else if(currentObject == "muon-event pairs")                     objectToPlot = "muonEventPairs";
1265            else if(currentObject == "muon-photon pairs")                     objectToPlot = "muonPhotonPairs";
1266            else if(currentObject == "photon-jet pairs")                     objectToPlot = "photonJetPairs";
1267 +          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1268 +          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1269            else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1270            else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1271            else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1272 +          else if(currentObject == "secondary photons")                     objectToPlot = "secondaryPhotons";
1273            else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1274            else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1275            else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
# Line 1181 | Line 1279 | OSUAnalysis::produce (edm::Event &event,
1279            else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1280            else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1281            else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1282 +          else if(currentObject == "muon-secondary photon pairs")           objectToPlot = "muonSecondaryJetPairs";
1283            else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1284 <          else if(currentObject == "photon-secondary jet pairs")       objectToPlot = "photonSecondaryJetPairs";
1284 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1285            else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1286            else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1287            else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
# Line 1220 | Line 1319 | OSUAnalysis::produce (edm::Event &event,
1319        for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1320          BranchSpecs brSpecs = treeBranches_.at(iBranch);
1321          string coll = brSpecs.inputCollection;
1322 <        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1322 >        if (cumulativeFlags.count(coll) == 0) clog << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1323  
1324          if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1325          else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1326 +        else if(coll == "secondary photons")      assignTreeBranch(brSpecs,photons.product(),          cumulativeFlags.at(coll).back());
1327          else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1328          else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1329          else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
# Line 1243 | Line 1343 | OSUAnalysis::produce (edm::Event &event,
1343                  && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1344        } // end loop over branches
1345  
1346 <      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1346 >      if (!BNTrees_.at(currentChannelIndex)) { clog << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1347        BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1348      }
1349  
# Line 1270 | Line 1370 | OSUAnalysis::evaluateComparison (double
1370    else if(comparison == "==") return testValue == cutValue;
1371    else if(comparison == "=") return testValue == cutValue;
1372    else if(comparison == "!=") return testValue != cutValue;
1373 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1373 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1374  
1375   }
1376  
# Line 1285 | Line 1385 | OSUAnalysis::evaluateComparison (string
1385    else if(comparison == "==") return testValue == cutValue;
1386    else if(comparison == "=") return testValue == cutValue;
1387    else if(comparison == "!=") return testValue != cutValue;
1388 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1388 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1389  
1390   }
1391  
# Line 1295 | Line 1395 | OSUAnalysis::evaluateTriggers (vector<st
1395    //initialize to false until a chosen trigger is passed
1396    bool triggerDecision = false;
1397  
1398 <  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1398 >  if (printAllTriggers_) clog << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1399    //loop over all triggers defined in the event
1400    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1401  
1402 <    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1402 >    if (printAllTriggers_) clog << "   " << trigger->name << endl;
1403  
1404      //we're only interested in triggers that actually passed
1405      if(trigger->pass != 1) continue;
# Line 1502 | Line 1602 | OSUAnalysis::valueLookup (const BNjet* o
1602        && object->chargedEmEnergyFraction < 0.5;
1603    }
1604  
1605 +  else if(variable == "dPhiMet") {
1606 +    if (const BNmet *met = chosenMET ()) {
1607 +      value = deltaPhi (object->phi, met->phi);
1608 +    } else value = -999;
1609 +  }
1610 +
1611  
1612 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1612 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1613  
1614    value = applyFunction(function, value);
1615  
1616    return value;
1617 < }
1617 > } // end jet valueLookup
1618  
1619  
1620   //!muon valueLookup
# Line 1605 | Line 1711 | OSUAnalysis::valueLookup (const BNmuon*
1711    else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1712    else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1713    else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1714 +  else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1715 +  else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1716 +  else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1717 +  else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1718    else if(variable == "rhoPrime") value = object->rhoPrime;
1719    else if(variable == "AEffDr03") value = object->AEffDr03;
1720    else if(variable == "AEffDr04") value = object->AEffDr04;
# Line 1612 | Line 1722 | OSUAnalysis::valueLookup (const BNmuon*
1722    else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1723    else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1724    else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1725 +  else if(variable == "relpfIsoR04SumExceptChargedHad") value = (object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)/ object->pt;
1726 +  else if(variable == "relpfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt/object->pt;
1727 +  else if(variable == "relpfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt/object->pt;
1728 +  else if(variable == "relpfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt/object->pt;
1729 +  else if(variable == "relpfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt/object->pt;
1730    else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1731    else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1732    else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
# Line 1669 | Line 1784 | OSUAnalysis::valueLookup (const BNmuon*
1784  
1785    //user-defined variables
1786    else if(variable == "looseID") {
1787 <    value = object->pt > 10
1788 <      && object->isGlobalMuon > 0
1789 <      && object->isTrackerMuon > 0;
1790 <      }
1787 >    value = object->pt > 10 &&
1788 >      (object->isGlobalMuon  > 0 ||
1789 >       object->isTrackerMuon > 0);
1790 >  }
1791    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1792    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1793    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1794    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1795 +  else if(variable == "relPFdBetaIsoPseudo") value = (object->pfIsoR04SumChargedHadronPt + object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt) / object->pt;
1796    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1797    else if(variable == "metMT") {
1798      if (const BNmet *met = chosenMET ())
# Line 1873 | Line 1989 | OSUAnalysis::valueLookup (const BNmuon*
1989  
1990  
1991  
1992 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1992 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1993  
1994    value = applyFunction(function, value);
1995  
1996    return value;
1997 < }
1997 > } // end muon valueLookup
1998 >
1999  
2000   //!electron valueLookup
2001   double
# Line 2047 | Line 2164 | OSUAnalysis::valueLookup (const BNelectr
2164    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2165    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2166    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2167 +  else if(variable == "relPFrhoIsoEB") value = object->isEB ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2168 +  else if(variable == "relPFrhoIsoEE") value = object->isEE ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2169    else if(variable == "metMT") {
2170      if (const BNmet *met = chosenMET ())
2171        {
# Line 2118 | Line 2237 | OSUAnalysis::valueLookup (const BNelectr
2237      else value = -999;
2238    }
2239  
2240 +  else if(variable == "looseID"){
2241 +    if (object->isEB)
2242 +      {
2243 +        value = fabs(object->delEtaIn) < 0.007 \
2244 +          && fabs (object->delPhiIn) < 0.15 \
2245 +          && object->scSigmaIEtaIEta < 0.01 \
2246 +          && object->hadOverEm < 0.12 \
2247 +          && fabs (object->correctedD0Vertex) < 0.02 \
2248 +          && fabs (object->correctedDZ) < 0.2 \
2249 +          && object->absInvEMinusInvPin < 0.05 \
2250 +          && object->passConvVeto;
2251 +      }
2252 +    else
2253 +      {
2254 +        value = fabs(object->delEtaIn) < 0.009 \
2255 +          && fabs (object->delPhiIn) < 0.10 \
2256 +          && object->scSigmaIEtaIEta < 0.03 \
2257 +          && object->hadOverEm < 0.10 \
2258 +          && fabs (object->correctedD0Vertex) < 0.02 \
2259 +          && fabs (object->correctedDZ) < 0.2 \
2260 +          && object->absInvEMinusInvPin < 0.05 \
2261 +          && object->passConvVeto;
2262 +      }
2263 +  }
2264 +
2265    else if(variable == "tightID"){
2266      if (object->isEB)
2267        {
# Line 2277 | Line 2421 | OSUAnalysis::valueLookup (const BNelectr
2421  
2422  
2423  
2424 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2424 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2425  
2426    value = applyFunction(function, value);
2427  
2428    return value;
2429 < }
2429 > } // end electron valueLookup
2430 >
2431  
2432   //!event valueLookup
2433   double
# Line 2294 | Line 2439 | OSUAnalysis::valueLookup (const BNevent*
2439    else if(variable == "pthat") value = object->pthat;
2440    else if(variable == "qScale") value = object->qScale;
2441    else if(variable == "alphaQCD") value = object->alphaQCD;
2442 +  else if(variable == "Ht") value = getHt(jets.product());
2443    else if(variable == "alphaQED") value = object->alphaQED;
2444    else if(variable == "scalePDF") value = object->scalePDF;
2445    else if(variable == "x1") value = object->x1;
# Line 2364 | Line 2510 | OSUAnalysis::valueLookup (const BNevent*
2510    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2511    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2512    else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2513 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2513 >  else if(variable == "ht") value = chosenHT ();
2514 >  else if(variable == "leadMuPairInvMass"){
2515 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2516 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2517 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2518 >    value = (p0 + p1).M ();
2519 >  }
2520 >  else if(variable == "leadMuPairPt"){
2521 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2522 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2523 >             pt1 (muPair.second->px, muPair.second->py);
2524 >    pt0 += pt1;
2525 >    value = pt0.Mod ();
2526 >  }
2527 >  else if(variable == "leadElPairInvMass"){
2528 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2529 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2530 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2531 >    value = (p0 + p1).M ();
2532 >  }
2533 >  else if(variable == "leadElPairPt"){
2534 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2535 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2536 >             pt1 (muPair.second->px, muPair.second->py);
2537 >    pt0 += pt1;
2538 >    value = pt0.Mod ();
2539 >  }
2540 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2541  
2542    value = applyFunction(function, value);
2543  
2544    return value;
2545 < }
2545 > } // end event valueLookup
2546 >
2547  
2548   //!tau valueLookup
2549   double
# Line 2471 | Line 2645 | OSUAnalysis::valueLookup (const BNtau* o
2645    }
2646  
2647  
2648 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2648 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2649  
2650    value = applyFunction(function, value);
2651  
2652    return value;
2653 < }
2653 > } // end tau valueLookup
2654 >
2655  
2656   //!met valueLookup
2657   double
# Line 2544 | Line 2719 | OSUAnalysis::valueLookup (const BNmet* o
2719    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2720    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2721  
2722 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2722 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2723  
2724    value = applyFunction(function, value);
2725  
2726    return value;
2727 < }
2727 > } // end met valueLookup
2728 >
2729  
2730   //!track valueLookup
2731   double
# Line 2577 | Line 2753 | OSUAnalysis::valueLookup (const BNtrack*
2753    else if(variable == "numValidHits") value = object->numValidHits;
2754    else if(variable == "isHighPurity") value = object->isHighPurity;
2755  
2580
2756    //additional BNs info for disappTrks
2757 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2758 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2759 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2760 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2761 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2762 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2763 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2764 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2590 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2757 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2758 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2759 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2760 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2761 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2762 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2763 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2764 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2765    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2766 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2766 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2767 >  else if(variable == "trkRelIsoRp3")       value = (object->depTrkRp3 - object->pt) / object->pt;
2768 >  else if(variable == "trkRelIsoRp5")       value = (object->depTrkRp5 - object->pt) / object->pt;
2769 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2770 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2771 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2772 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2773 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2774 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2775 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2776 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2777 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2778 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2779 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2780 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2781 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2782 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2783 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2784 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2785 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2786  
2787    //user defined variables
2788    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;
2789    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2790 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2790 >  else if(variable == "depTrkRp5MinusPt"){
2791 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2792 >           value = 0;
2793 >         }
2794 >         else value =  (object->depTrkRp5 - object->pt);
2795 >  }
2796 >  else if(variable == "depTrkRp3MinusPt"){
2797 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2798 >      value = 0;
2799 >    }
2800 >    else value =  (object->depTrkRp3 - object->pt);
2801 >  }
2802 >
2803 >  else if(variable == "dPhiMet") {
2804 >    if (const BNmet *met = chosenMET ()) {
2805 >      value = deltaPhi (object->phi, met->phi);
2806 >    } else value = -999;
2807 >  }
2808 >  
2809 >  
2810    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2811    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2812    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
# Line 2671 | Line 2883 | OSUAnalysis::valueLookup (const BNtrack*
2883  
2884  
2885  
2886 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2886 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2887  
2888    value = applyFunction(function, value);
2889  
2890    return value;
2891 < }
2891 > } // end track valueLookup
2892 >
2893  
2894   //!genjet valueLookup
2895   double
# Line 2700 | Line 2913 | OSUAnalysis::valueLookup (const BNgenjet
2913    else if(variable == "charge") value = object->charge;
2914  
2915  
2916 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2916 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2917  
2918    value = applyFunction(function, value);
2919  
# Line 2834 | Line 3047 | OSUAnalysis::valueLookup (const BNmcpart
3047    }
3048  
3049  
3050 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3050 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3051  
3052    value = applyFunction(function, value);
3053  
3054    return value;
3055 < }
3055 > } // end mcparticle valueLookup
3056 >
3057  
3058   //!primaryvertex valueLookup
3059   double
# Line 2862 | Line 3076 | OSUAnalysis::valueLookup (const BNprimar
3076    else if(variable == "isGood") value = object->isGood;
3077  
3078  
3079 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3079 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3080  
3081    value = applyFunction(function, value);
3082  
# Line 2880 | Line 3094 | OSUAnalysis::valueLookup (const BNbxlumi
3094    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
3095  
3096  
3097 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3097 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3098  
3099    value = applyFunction(function, value);
3100  
# Line 3013 | Line 3227 | OSUAnalysis::valueLookup (const BNphoton
3227    }
3228  
3229  
3230 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3230 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3231  
3232    value = applyFunction(function, value);
3233  
3234    return value;
3235 < }
3235 > } // end photon valueLookup
3236 >
3237  
3238   //!supercluster valueLookup
3239   double
# Line 3036 | Line 3251 | OSUAnalysis::valueLookup (const BNsuperc
3251    else if(variable == "theta") value = object->theta;
3252  
3253  
3254 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3254 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3255  
3256    value = applyFunction(function, value);
3257  
# Line 3070 | Line 3285 | OSUAnalysis::valueLookup (const BNtrigob
3285        stringValue = "none";  // stringValue should only be empty if value is filled
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 3141 | Line 3356 | OSUAnalysis::valueLookup (const BNmuon*
3356        value = object2->correctedD0;
3357      }
3358  
3359 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3359 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3360  
3361    value = applyFunction(function, value);
3362  
3363    return value;
3364 < }
3364 > } // end muon-muon pair valueLookup
3365 >
3366  
3367   //!muon-photon pair valueLookup
3368   double
# Line 3157 | Line 3373 | OSUAnalysis::valueLookup (const BNmuon*
3373    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3374    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3375    else if(variable == "photonEta") value = object2->eta;
3376 +  else if(variable == "photonPt") value = object2->pt;
3377    else if(variable == "muonEta") value = object1->eta;
3378    else if(variable == "photonPhi") value = object2->phi;
3379    else if(variable == "muonPhi") value = object1->phi;
# Line 3186 | Line 3403 | OSUAnalysis::valueLookup (const BNmuon*
3403        TVector3 threeVector2(object2->px, object2->py, object2->pz);
3404        value = (pi-threeVector1.Angle(threeVector2));
3405      }
3406 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3406 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3407  
3408    value = applyFunction(function, value);
3409  
# Line 3202 | Line 3419 | OSUAnalysis::valueLookup (const BNelectr
3419    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3420    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3421    else if(variable == "photonEta") value = object2->eta;
3422 +  else if(variable == "photonPt") value = object2->pt;
3423    else if(variable == "electronEta") value = object1->eta;
3424    else if(variable == "photonPhi") value = object2->phi;
3425    else if(variable == "electronPhi") value = object1->phi;
# Line 3231 | Line 3449 | OSUAnalysis::valueLookup (const BNelectr
3449        TVector3 threeVector2(object2->px, object2->py, object2->pz);
3450        value = (pi-threeVector1.Angle(threeVector2));
3451      }
3452 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3452 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3453  
3454    value = applyFunction(function, value);
3455  
# Line 3287 | Line 3505 | OSUAnalysis::valueLookup (const BNelectr
3505      value = object2->correctedD0;
3506    }
3507  
3508 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3508 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3509  
3510    value = applyFunction(function, value);
3511  
3512    return value;
3513   }
3514 +
3515   //!electron-muon pair valueLookup
3516   double
3517   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3353 | Line 3572 | OSUAnalysis::valueLookup (const BNelectr
3572    else if(variable == "muonRelPFdBetaIso"){
3573      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3574    }
3575 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3575 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3576    value = applyFunction(function, value);
3577  
3578    return value;
3579 < }
3579 > } // end electron-muon pair valueLookup
3580 >
3581  
3582   //!electron-jet pair valueLookup
3583   double
# Line 3392 | Line 3612 | OSUAnalysis::valueLookup (const BNelectr
3612      value = object1->charge*object2->charge;
3613    }
3614  
3615 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3615 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3616    value = applyFunction(function, value);
3617  
3618    return value;
# Line 3428 | Line 3648 | OSUAnalysis::valueLookup (const BNphoton
3648        TVector3 threeVector2(object2->px, object2->py, object2->pz);
3649        value = (threeVector1.Angle(threeVector2));
3650      }
3651 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3651 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3652    value = applyFunction(function, value);
3653  
3654    return value;
3655   }
3656  
3657 + // track-jet pair valueLookup
3658 + double
3659 + OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3660 +
3661 +  double value = 0.0;
3662 +
3663 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3664 +  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3665 +
3666 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3667 +  value = applyFunction(function, value);
3668 +
3669 +  return value;
3670 +
3671 + }
3672 +
3673 +
3674 +
3675 + // met-jet pair valueLookup
3676 + double
3677 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3678 +
3679 +  double value = 0.0;
3680 +
3681 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3682 +
3683 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3684 +  value = applyFunction(function, value);
3685 +
3686 +  return value;
3687 +
3688 + }  
3689 +
3690 +
3691 +
3692   //!muon-jet pair valueLookup
3693   double
3694   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3442 | Line 3697 | OSUAnalysis::valueLookup (const BNmuon*
3697  
3698    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3699    else if(variable == "jetEta") value = object2->eta;
3700 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3701 +  else if(variable == "jetPt") value = object2->pt;
3702    else if(variable == "jetPhi") value = object2->phi;
3703 +  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3704    else if(variable == "muonEta") value = object1->eta;
3705 +  else if(variable == "muonPt") value = object1->pt;
3706    else if(variable == "muonPhi") value = object1->phi;
3707 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3707 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3708    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3709    else if(variable == "invMass"){
3710      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3467 | Line 3726 | OSUAnalysis::valueLookup (const BNmuon*
3726      value = object1->charge*object2->charge;
3727    }
3728  
3729 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3729 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3730 >  value = applyFunction(function, value);
3731 >
3732 >  return value;
3733 > }
3734 >
3735 > //!muon-event valueLookup
3736 > double
3737 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue){
3738 >
3739 >  double value = 0.0;
3740 >
3741 >  if(variable == "muonEta") value = object1->eta;
3742 >  else if(variable == "muonPt") value = object1->pt;
3743 >  else if(variable == "muonPhi") value = object1->phi;
3744 >  else if(variable == "Ht") value = getHt(jets.product());
3745 >  else if(variable == "pthat")   value = object2->pthat;
3746 >  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3747 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3748    value = applyFunction(function, value);
3749  
3750    return value;
# Line 3480 | Line 3757 | OSUAnalysis::valueLookup (const BNjet* o
3757  
3758    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3759    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3760 <  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3760 >  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3761    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3762    else if(variable == "invMass"){
3763      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3502 | Line 3779 | OSUAnalysis::valueLookup (const BNjet* o
3779      value = object1->charge*object2->charge;
3780    }
3781  
3782 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3782 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3783    value = applyFunction(function, value);
3784  
3785    return value;
3786   }
3787 +
3788   //!electron-track pair valueLookup
3789   double
3790   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3526 | Line 3804 | OSUAnalysis::valueLookup (const BNelectr
3804    else if(variable == "chargeProduct"){
3805      value = object1->charge*object2->charge;
3806    }
3807 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3807 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3808    value = applyFunction(function, value);
3809    return value;
3810  
# Line 3554 | Line 3832 | OSUAnalysis::valueLookup (const BNmuon*
3832      value = object1->charge*object2->charge;
3833    }
3834  
3835 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3835 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3836    value = applyFunction(function, value);
3837    return value;
3838   }
# Line 3576 | Line 3854 | OSUAnalysis::valueLookup (const BNtau* o
3854      value = object1->charge*object2->charge;
3855    }
3856  
3857 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3857 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3858    value = applyFunction(function, value);
3859    return value;
3860   }
# Line 3598 | Line 3876 | OSUAnalysis::valueLookup (const BNmuon*
3876      value = object1->charge*object2->charge;
3877    }
3878  
3879 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3879 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3880    value = applyFunction(function, value);
3881    return value;
3882   }
# Line 3613 | Line 3891 | OSUAnalysis::valueLookup (const BNtau* o
3891      value = object1->charge*object2->charge;
3892    }
3893  
3894 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3894 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3895    value = applyFunction(function, value);
3896    return value;
3897   }
# Line 3633 | Line 3911 | OSUAnalysis::valueLookup (const BNtrack*
3911    else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3912    else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3913  
3914 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3914 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3915  
3916    value = applyFunction(function, value);
3917  
# Line 3655 | Line 3933 | OSUAnalysis::valueLookup (const BNelectr
3933        stringValue = "none";
3934    }
3935  
3936 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3936 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3937  
3938    value = applyFunction(function, value);
3939  
# Line 3671 | Line 3949 | OSUAnalysis::valueLookup (const BNmuon*
3949  
3950    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3951  
3952 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3952 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3953  
3954    value = applyFunction(function, value);
3955  
# Line 3784 | Line 4062 | OSUAnalysis::valueLookup (const BNstop*
4062      }
4063    }
4064  
4065 +  else if (variable == "decaysToTau"){
4066 +    value = abs (object->daughter0Id) == 15 || abs (object->daughter1Id) == 15;
4067 +  }
4068 +
4069  
4070  
4071  
4072 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4072 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4073  
4074    value = applyFunction(function, value);
4075  
4076    return value;
4077  
4078 < }
4078 > } // end stop valueLookup
4079 >
4080  
4081  
4082  
# Line 3811 | Line 4094 | OSUAnalysis::getTrkIsIso (const BNtrack*
4094  
4095   }
4096  
4097 + //calculate the scalar sum of Jet Pt in the event.
4098 + double
4099 + OSUAnalysis::getHt (const BNjetCollection* jetColl){
4100 +  double Ht = 0;
4101 +  for(BNjetCollection::const_iterator jet = jetColl->begin(); jet !=jetColl->end(); jet++){
4102 +    Ht += abs(jet->pt);
4103 +  }
4104 +  return Ht;
4105 + }
4106  
4107   double
4108   OSUAnalysis::getTrkPtRes (const BNtrack* track1){
# Line 3848 | Line 4140 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4140    // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
4141    if (!useTrackCaloRhoCorr_) return -99;
4142    // if (!rhokt6CaloJetsHandle_) {
4143 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4143 >  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4144    //   return -99;
4145    // }
4146    double radDeltaRCone = 0.5;
# Line 3870 | Line 4162 | OSUAnalysis::WriteDeadEcal (){
4162    double etaEcal, phiEcal;
4163    ifstream DeadEcalFile(deadEcalFile_);
4164    if(!DeadEcalFile) {
4165 <    cout << "Error: DeadEcalFile has not been found." << endl;
4165 >    clog << "Error: DeadEcalFile has not been found." << endl;
4166      return;
4167    }
4168    if(DeadEcalVec.size()!= 0){
4169 <    cout << "Error: DeadEcalVec has a nonzero size" << endl;
4169 >    clog << "Error: DeadEcalVec has a nonzero size" << endl;
4170      return;
4171    }
4172    while(!DeadEcalFile.eof())
# Line 3885 | Line 4177 | OSUAnalysis::WriteDeadEcal (){
4177        newChan.phiEcal = phiEcal;
4178        DeadEcalVec.push_back(newChan);
4179      }
4180 <  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
4180 >  if(DeadEcalVec.size() == 0) clog << "Warning: No dead Ecal channels have been found." << endl;
4181   }
4182  
4183   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
# Line 3925 | Line 4217 | OSUAnalysis::applyFunction(string functi
4217    else if(function == "log") value = log10(value);
4218  
4219    else if(function == "") value = value;
4220 <  else{cout << "WARNING: invalid function '" << function << "'\n";}
4220 >  else{clog << "WARNING: invalid function '" << function << "'\n";}
4221  
4222    return value;
4223  
# Line 3980 | Line 4272 | void OSUAnalysis::setObjectFlags(cut &cu
4272        else plotDecision = cutDecision;
4273      }
4274  
3983    //if(cutDecision != plotDecision && currentCut.variables.at(0) == "pt") cout << "---------------\n" << cutDecision << " " << plotDecision << endl;
4275      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4276  
4277      //set flags for objects that pass this cut AND all the previous cuts
# Line 3997 | Line 4288 | void OSUAnalysis::setObjectFlags(cut &cu
4288      }
4289      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4290  
4000    //if(inputType == "muons") cout << previousCumulativeCutFlag << " " << previousCumulativePlotFlag << " " << currentCut.variables.at(0) << "\n---------------\n\n";
4291      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4292  
4293    }
# Line 4153 | Line 4443 | template <class InputCollection>
4443   void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4444    // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4445  
4446 <  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;
4446 >  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;
4447    for (uint object = 0; object != inputCollection->size(); object++) {
4448  
4449      if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
# Line 4174 | Line 4464 | void OSUAnalysis::fill1DHistogram(TH1* h
4464  
4465    for (uint object = 0; object != inputCollection->size(); object++){
4466  
4177    //cout << "flags.at(object).second: " << flags.at(object).second << endl;
4178
4467      if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4468  
4469      string currentString = parameters.inputVariables.at(0);
# Line 4196 | Line 4484 | void OSUAnalysis::fill1DHistogram(TH1* h
4484  
4485      if (printEventInfo_) {
4486        // Write information about event to screen, for testing purposes.
4487 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4487 >      clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4488      }
4489  
4490    }
# Line 4348 | Line 4636 | int OSUAnalysis::getGenMatchedParticleIn
4636  
4637      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4638      if(currentDeltaR > 0.05) continue;
4639 <    //     cout << setprecision(3) << setw(20)
4639 >    //     clog << setprecision(3) << setw(20)
4640      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4641      //          << setw(20)
4642      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
# Line 4367 | Line 4655 | int OSUAnalysis::getGenMatchedParticleIn
4655      }
4656  
4657    }
4658 <  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4659 <  //   else cout << "no match found..." << endl;
4658 >  //   if(bestMatchDeltaR != 999)  clog << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4659 >  //   else clog << "no match found..." << endl;
4660    return bestMatchIndex;
4661  
4662   }
# Line 4552 | Line 4840 | OSUAnalysis::chosenMuon ()
4840    return chosenMuon;
4841   }
4842  
4843 + double
4844 + OSUAnalysis::chosenHT ()
4845 + {
4846 +  double chosenHT = 0.0;
4847 +  if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
4848 +    flagPair jetFlags;
4849 +    for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
4850 +      if (cumulativeFlags.at("jets").at(i).size()){
4851 +        jetFlags = cumulativeFlags.at("jets").at(i);
4852 +        break;
4853 +      }
4854 +    }
4855 +    for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
4856 +      if(!jetFlags.at(jetIndex).first) continue;
4857 +      chosenHT += jets->at(jetIndex).pt;
4858 +    }
4859 +  }
4860 +
4861 +  return chosenHT;
4862 + }
4863 +
4864 + pair<const BNmuon *, const BNmuon *>
4865 + OSUAnalysis::leadMuonPair ()
4866 + {
4867 +  pair<const BNmuon *, const BNmuon *> leadMuonPair;
4868 +  leadMuonPair.first = leadMuonPair.second = 0;
4869 +
4870 +  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4871 +    flagPair muonFlags;
4872 +    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4873 +      if (cumulativeFlags.at("muons").at(i).size()){
4874 +        muonFlags = cumulativeFlags.at("muons").at(i);
4875 +        break;
4876 +      }
4877 +    }
4878 +    for (uint muonIndex0 = 0; muonIndex0 != muonFlags.size(); muonIndex0++){
4879 +      if(!muonFlags.at(muonIndex0).first) continue;
4880 +      for (uint muonIndex1 = muonIndex0 + 1; muonIndex1 < muonFlags.size(); muonIndex1++){
4881 +        if(!muonFlags.at(muonIndex1).first) continue;
4882 +        const BNmuon *mu0 = & muons->at(muonIndex0);
4883 +        const BNmuon *mu1 = & muons->at(muonIndex1);
4884 +        if(leadMuonPair.first == 0 || leadMuonPair.second == 0){
4885 +          leadMuonPair.first = mu0;
4886 +          leadMuonPair.second = mu1;
4887 +        }
4888 +        else{
4889 +          TVector2 newPt0 (mu0->px, mu0->py),
4890 +                   newPt1 (mu1->px, mu1->py),
4891 +                   oldPt0 (leadMuonPair.first->px, leadMuonPair.first->py),
4892 +                   oldPt1 (leadMuonPair.second->px, leadMuonPair.second->py);
4893 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4894 +            {
4895 +              leadMuonPair.first = mu0;
4896 +              leadMuonPair.second = mu1;
4897 +            }
4898 +        }
4899 +      }
4900 +    }
4901 +  }
4902 +
4903 +  return leadMuonPair;
4904 + }
4905 +
4906 + pair<const BNelectron *, const BNelectron *>
4907 + OSUAnalysis::leadElectronPair ()
4908 + {
4909 +  pair<const BNelectron *, const BNelectron *> leadElectronPair;
4910 +  leadElectronPair.first = leadElectronPair.second = 0;
4911 +  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4912 +    flagPair electronFlags;
4913 +    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4914 +      if (cumulativeFlags.at("electrons").at(i).size()){
4915 +        electronFlags = cumulativeFlags.at("electrons").at(i);
4916 +        break;
4917 +      }
4918 +    }
4919 +    for (uint electronIndex0 = 0; electronIndex0 != electronFlags.size(); electronIndex0++){
4920 +      if(!electronFlags.at(electronIndex0).first) continue;
4921 +      for (uint electronIndex1 = electronIndex0 + 1; electronIndex1 < electronFlags.size(); electronIndex1++){
4922 +        if(!electronFlags.at(electronIndex1).first) continue;
4923 +        const BNelectron *el0 = & electrons->at(electronIndex0);
4924 +        const BNelectron *el1 = & electrons->at(electronIndex1);
4925 +        if(leadElectronPair.first == 0 || leadElectronPair.second == 0){
4926 +          leadElectronPair.first = el0;
4927 +          leadElectronPair.second = el1;
4928 +        }
4929 +        else{
4930 +          TVector2 newPt0 (el0->px, el0->py),
4931 +                   newPt1 (el1->px, el1->py),
4932 +                   oldPt0 (leadElectronPair.first->px, leadElectronPair.first->py),
4933 +                   oldPt1 (leadElectronPair.second->px, leadElectronPair.second->py);
4934 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4935 +            {
4936 +              leadElectronPair.first = el0;
4937 +              leadElectronPair.second = el1;
4938 +            }
4939 +        }
4940 +      }
4941 +    }
4942 +  }
4943 +
4944 +  return leadElectronPair;
4945 + }
4946 +
4947   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines