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.101 by wulsin, Thu Jul 18 09:11:51 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  
# Line 627 | Line 647 | OSUAnalysis::~OSUAnalysis ()
647    for(uint currentChannel = 0; currentChannel != channels_.size(); currentChannel++){
648      delete cutFlows_.at(currentChannel);
649    }
650 +
651 +  clog << "=============================================" << endl;  
652 +  clog << "Successfully completed OSUAnalysis." << endl;  
653 +  clog << "=============================================" << endl;  
654 +
655   }
656  
657   void
658   OSUAnalysis::produce (edm::Event &event, const edm::EventSetup &setup)
659   {
635  //cout << "**********************\n\n\n";
660    // Retrieve necessary collections from the event.
661  
662    if (find(objectsToGet.begin(), objectsToGet.end(), "triggers") != objectsToGet.end())
# Line 698 | Line 722 | OSUAnalysis::produce (edm::Event &event,
722    //get pile-up event weight
723    if (doPileupReweighting_ && datasetType_ != "data") {
724      //for "data" datasets, the numTruePV is always set to -1
725 <    if (events->at(0).numTruePV < 0) cout << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
725 >    if (events->at(0).numTruePV < 0) clog << "WARNING[OSUAnalysis::analyze]: Event has numTruePV<0.  Turning off pile-up reweighting." << endl;
726      else masterScaleFactor *= puWeight_->at (events->at (0).numTruePV);
727    }
728  
# Line 731 | Line 755 | OSUAnalysis::produce (edm::Event &event,
755      //loop over all cuts
756      for(uint currentCutIndex = 0; currentCutIndex != currentChannel.cuts.size(); currentCutIndex++){
757        cut currentCut = currentChannel.cuts.at(currentCutIndex);
758 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
759 <        string currentObject = objectsToCut.at(currentObjectIndex);
758 >
759 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
760 >        string currentObject = objectsToFlag.at(currentObjectIndex);
761  
762          //initialize maps to get ready to set cuts
763          individualFlags[currentObject].push_back (vector<pair<bool,bool> > ());
764          cumulativeFlags[currentObject].push_back (vector<pair<bool,bool> > ());
765  
766        }
767 <      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToCut.size(); currentObjectIndex++){
768 <        string currentObject = objectsToCut.at(currentObjectIndex);
767 >
768 >      //set flags for all relevant objects
769 >      for(uint currentObjectIndex = 0; currentObjectIndex != objectsToFlag.size(); currentObjectIndex++){
770 >        string currentObject = objectsToFlag.at(currentObjectIndex);
771  
772          int flagsForPairCutsIndex = max(int(currentCutIndex-1),0);
773  
774  
775          if     (currentObject == "jets")            setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"jets");
776          else if(currentObject == "secondary jets")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,jets.product(),"secondary jets");
777 +        else if(currentObject == "secondary photons")  setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,photons.product(),"secondary photons");
778          else if(currentObject == "muons")           setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"muons");
779          else if(currentObject == "secondary muons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),"secondary muons");
780          else if(currentObject == "secondary electrons") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,electrons.product(),"secondary electrons");
# Line 775 | Line 803 | OSUAnalysis::produce (edm::Event &event,
803                                                                               cumulativeFlags.at("secondary muons").at(flagsForPairCutsIndex), \
804                                                                               "muon-secondary muon pairs");
805  
806 +        else if(currentObject == "muon-secondary photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
807 +                                                                             cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
808 +                                                                             cumulativeFlags.at("secondary photons").at(flagsForPairCutsIndex), \
809 +                                                                             "muon-secondary photon pairs");
810          else if(currentObject == "muon-secondary jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),jets.product(), \
811                                                                               cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
812                                                                               cumulativeFlags.at("secondary jets").at(flagsForPairCutsIndex), \
# Line 826 | Line 858 | OSUAnalysis::produce (edm::Event &event,
858                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
859                                                                    cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
860                                                                    "muon-jet pairs");
861 +        else if(currentObject == "muon-event pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),events.product(), \
862 +                                                                  cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
863 +                                                                  cumulativeFlags.at("events").at(flagsForPairCutsIndex), \
864 +                                                                  "muon-event pairs");
865 +        else if(currentObject == "met-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,mets.product(),jets.product(), \
866 +                                                                  cumulativeFlags.at("mets").at(flagsForPairCutsIndex), \
867 +                                                                  cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
868 +                                                                  "met-jet pairs");
869 +        else if(currentObject == "track-jet pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,tracks.product(),jets.product(), \
870 +                                                                 cumulativeFlags.at("tracks").at(flagsForPairCutsIndex), \
871 +                                                                 cumulativeFlags.at("jets").at(flagsForPairCutsIndex), \
872 +                                                                 "track-jet pairs");
873          else if(currentObject == "muon-photon pairs") setObjectFlags(currentCut,currentCutIndex,individualFlags,cumulativeFlags,muons.product(),photons.product(), \
874                                                                    cumulativeFlags.at("muons").at(flagsForPairCutsIndex), \
875                                                                    cumulativeFlags.at("photons").at(flagsForPairCutsIndex), \
# Line 891 | Line 935 | OSUAnalysis::produce (edm::Event &event,
935        eventPassedAllCuts = eventPassedAllCuts && cutDecision;
936        eventPassedPreviousCuts.push_back(eventPassedAllCuts);
937      }
938 +    //applying all appropriate scale factors
939      double scaleFactor = masterScaleFactor;
895
940      muonScaleFactor_ = electronScaleFactor_ = bTagScaleFactor_ = 1.0;
941 +
942      if(applyLeptonSF_ && datasetType_ != "data"){
943 <      if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
943 >      //only apply SFs if we've cut on this object
944 >      if(find(objectsToCut.begin(),objectsToCut.end(),"muons") != objectsToCut.end ()){
945          flagPair muonFlags;
946 +        //get the last valid flags in the flag map
947          for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
948            if (cumulativeFlags.at("muons").at(i).size()){
949              muonFlags = cumulativeFlags.at("muons").at(i);
950              break;
951            }
952          }
953 +        //apply the weight for each of those objects
954          for (uint muonIndex = 0; muonIndex != muonFlags.size(); muonIndex++){
955            if(!muonFlags.at(muonIndex).second) continue;
956            muonScaleFactor_ *= muonSFWeight_->at (muons->at(muonIndex).eta);
957          }
958        }
959 <      if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
959 >      //only apply SFs if we've cut on this object
960 >      if(find(objectsToCut.begin(),objectsToCut.end(),"electrons") != objectsToCut.end ()){
961          flagPair electronFlags;
962 +        //get the last valid flags in the flag map
963          for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
964            if (cumulativeFlags.at("electrons").at(i).size()){
965              electronFlags = cumulativeFlags.at("electrons").at(i);
966              break;
967            }
968          }
969 +        //apply the weight for each of those objects
970          for (uint electronIndex = 0; electronIndex != electronFlags.size(); electronIndex++){
971            if(!electronFlags.at(electronIndex).second) continue;
972            electronScaleFactor_ *= electronSFWeight_->at (electrons->at(electronIndex).eta, electrons->at(electronIndex).pt);
# Line 923 | Line 974 | OSUAnalysis::produce (edm::Event &event,
974        }
975      }
976      if(applyBtagSF_ && datasetType_ != "data"){
977 <     if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
978 <       flagPair jetFlags;
977 >      //only apply SFs if we've cut on this object
978 >      if(find(objectsToCut.begin(),objectsToCut.end(),"jets") != objectsToCut.end ()){
979 >        flagPair jetFlags;
980          vector<double> jetSFs;
981 +        //get the last valid flags in the flag map
982          for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
983            if (cumulativeFlags.at("jets").at(i).size()){
984              jetFlags = cumulativeFlags.at("jets").at(i);
985              break;
986            }
987          }
988 +        //apply the weight for each of those objects
989          for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
990            if(!jetFlags.at(jetIndex).second) continue;
991 <          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour);
991 >          double jetSFTmp = bTagSFWeight_->sflookup(jets->at(jetIndex).btagCombinedSecVertex, jets->at(jetIndex).pt, jets->at(jetIndex).flavour, jets->at(jetIndex).eta);
992            jetSFs.push_back(jetSFTmp);
993          }
994 <        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_, maxBtag_ );
994 >        bTagScaleFactor_ *= bTagSFWeight_->weight( jetSFs, minBtag_);
995        }
996      }
997      scaleFactor *= muonScaleFactor_;
# Line 945 | Line 999 | OSUAnalysis::produce (edm::Event &event,
999      scaleFactor *= bTagScaleFactor_;
1000      cutFlows_.at(currentChannelIndex)->fillCutFlow(scaleFactor);
1001  
1002 <    if (printEventInfo_) {
1002 >    if (printEventInfo_ && eventPassedAllCuts) {
1003        // Write information about event to screen, for testing purposes.
1004 <      cout << "Event passed all cuts in channel " <<  currentChannel.name
1005 <           << ": run="  << events->at(0).run
1006 <           << "  lumi=" << events->at(0).lumi
1007 <           << "  event=" << events->at(0).evt
1004 >      clog << "Event passed all cuts in channel " <<  currentChannel.name
1005 >           << ":  run:lumi:evt=  "  << events->at(0).run
1006 >           << ":" << events->at(0).lumi
1007 >           << ":" << events->at(0).evt
1008             << endl;
1009      }
1010  
# Line 969 | Line 1023 | OSUAnalysis::produce (edm::Event &event,
1023          for (uint histogramIndex = 0; histogramIndex != histograms.size(); histogramIndex++){
1024            histogram currentHistogram = histograms.at(histogramIndex);
1025  
1026 <          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) cout << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1026 >          if (cumulativeFlags.count(currentHistogram.inputCollection) == 0) clog << "Error: no flags found for collection:  " << currentHistogram.inputCollection << ", will cause a seg fault" << endl;
1027  
1028            if(currentHistogram.inputVariables.size() == 1){
1029              TH1D* histo;
1030              histo = oneDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1031              if     (currentHistogram.inputCollection == "jets")            fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1032              else if(currentHistogram.inputCollection == "secondary jets")  fill1DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1033 +            else if(currentHistogram.inputCollection == "secondary photons")  fill1DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1034              else if(currentHistogram.inputCollection == "muons")           fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1035              else if(currentHistogram.inputCollection == "secondary muons") fill1DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1036              else if(currentHistogram.inputCollection == "secondary electrons") fill1DHistogram(histo,currentHistogram,electrons.product(),cumulativeFlags.at("secondary electrons").at(currentDir),scaleFactor);
# Line 985 | Line 1040 | OSUAnalysis::produce (edm::Event &event,
1040              else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1041                                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1042                                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1043 +             else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill1DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1044 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1045 +                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1046               else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill1DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1047                                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1048                                                                                                       cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
# Line 1021 | Line 1079 | OSUAnalysis::produce (edm::Event &event,
1079              else if(currentHistogram.inputCollection == "muon-jet pairs") fill1DHistogram(histo,currentHistogram, muons.product(),jets.product(), \
1080                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1081                                                                                            cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1082 +            else if(currentHistogram.inputCollection == "muon-event pairs") fill1DHistogram(histo,currentHistogram, muons.product(),events.product(), \
1083 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir),
1084 +                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1085 +            else if(currentHistogram.inputCollection == "met-jet pairs")  fill1DHistogram(histo,currentHistogram, mets.product(),jets.product(), \
1086 +                                                                                          cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1087 +                                                                                          cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1088 +            else if(currentHistogram.inputCollection == "track-jet pairs")  fill1DHistogram(histo,currentHistogram,tracks.product(),jets.product(), \
1089 +                                                                                          cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir),
1090 +                                                                                          cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1091              else if(currentHistogram.inputCollection == "muon-photon pairs") fill1DHistogram(histo,currentHistogram, muons.product(),photons.product(), \
1092                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("photons").at(currentDir),
1093                                                                                            cumulativeFlags.at("muon-photon pairs").at(currentDir),scaleFactor);
# Line 1067 | Line 1134 | OSUAnalysis::produce (edm::Event &event,
1134              histo = twoDHists_.at(currentChannelIndex).at(currentCut).at(currentHistogram.name);
1135              if     (currentHistogram.inputCollection == "jets")            fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("jets").at(currentDir),scaleFactor);
1136              else if(currentHistogram.inputCollection == "secondary jets")  fill2DHistogram(histo,currentHistogram,jets.product(),cumulativeFlags.at("secondary jets").at(currentDir),scaleFactor);
1137 +            else if(currentHistogram.inputCollection == "secondary photons")  fill2DHistogram(histo,currentHistogram,photons.product(),cumulativeFlags.at("secondary photons").at(currentDir),scaleFactor);
1138              else if(currentHistogram.inputCollection == "muons")           fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("muons").at(currentDir),scaleFactor);
1139              else if(currentHistogram.inputCollection == "secondary muons") fill2DHistogram(histo,currentHistogram,muons.product(),cumulativeFlags.at("secondary muons").at(currentDir),scaleFactor);
1140              else if(currentHistogram.inputCollection == "muon-muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
# Line 1075 | Line 1143 | OSUAnalysis::produce (edm::Event &event,
1143              else if(currentHistogram.inputCollection == "muon-secondary muon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),muons.product(), \
1144                                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary muons").at(currentDir), \
1145                                                                                                       cumulativeFlags.at("muon-secondary muon pairs").at(currentDir),scaleFactor);
1146 +            else if(currentHistogram.inputCollection == "muon-secondary photon pairs") fill2DHistogram(histo,currentHistogram,muons.product(),photons.product(), \
1147 +                                                                                                     cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary photons").at(currentDir), \
1148 +                                                                                                     cumulativeFlags.at("muon-secondary photon pairs").at(currentDir),scaleFactor);
1149              else if(currentHistogram.inputCollection == "muon-secondary jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1150                                                                                                       cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("secondary jets").at(currentDir), \
1151                                                                                                       cumulativeFlags.at("muon-secondary jet pairs").at(currentDir),scaleFactor);
# Line 1107 | Line 1178 | OSUAnalysis::produce (edm::Event &event,
1178              else if(currentHistogram.inputCollection == "muon-jet pairs") fill2DHistogram(histo,currentHistogram,muons.product(),jets.product(), \
1179                                                                                            cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1180                                                                                            cumulativeFlags.at("muon-jet pairs").at(currentDir),scaleFactor);
1181 +            else if(currentHistogram.inputCollection == "muon-event pairs") fill2DHistogram(histo,currentHistogram,muons.product(),events.product(), \
1182 +                                                                                          cumulativeFlags.at("muons").at(currentDir),cumulativeFlags.at("events").at(currentDir), \
1183 +                                                                                          cumulativeFlags.at("muon-event pairs").at(currentDir),scaleFactor);
1184 +            else if(currentHistogram.inputCollection == "met-jet pairs") fill2DHistogram(histo,currentHistogram,mets.product(),jets.product(), \
1185 +                                                                                         cumulativeFlags.at("mets").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1186 +                                                                                         cumulativeFlags.at("met-jet pairs").at(currentDir),scaleFactor);
1187 +            else if(currentHistogram.inputCollection == "track-jet pairs") fill2DHistogram(histo,currentHistogram,tracks.product(),jets.product(),
1188 +                                                                                         cumulativeFlags.at("tracks").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1189 +                                                                                         cumulativeFlags.at("track-jet pairs").at(currentDir),scaleFactor);
1190              else if(currentHistogram.inputCollection == "photon-jet pairs") fill2DHistogram(histo,currentHistogram,photons.product(),jets.product(), \
1191                                                                                            cumulativeFlags.at("photons").at(currentDir),cumulativeFlags.at("jets").at(currentDir), \
1192                                                                                            cumulativeFlags.at("photon-jet pairs").at(currentDir),scaleFactor);
# Line 1164 | Line 1244 | OSUAnalysis::produce (edm::Event &event,
1244            if(currentObject == "muon-muon pairs")                         objectToPlot = "dimuonPairs";
1245            else if(currentObject == "electron-electron pairs")            objectToPlot = "dielectronPairs";
1246            else if(currentObject == "electron-muon pairs")                objectToPlot = "electronMuonPairs";
1247 <          else if(currentObject == "electron-photon pairs")                objectToPlot = "electronPhotonPairs";
1247 >          else if(currentObject == "electron-photon pairs")              objectToPlot = "electronPhotonPairs";
1248            else if(currentObject == "electron-jet pairs")                 objectToPlot = "electronJetPairs";
1249            else if(currentObject == "muon-jet pairs")                     objectToPlot = "muonJetPairs";
1250 +          else if(currentObject == "muon-event pairs")                     objectToPlot = "muonEventPairs";
1251            else if(currentObject == "muon-photon pairs")                     objectToPlot = "muonPhotonPairs";
1252            else if(currentObject == "photon-jet pairs")                     objectToPlot = "photonJetPairs";
1253 +          else if(currentObject == "met-jet pairs")                      objectToPlot = "metJetPairs";
1254 +          else if(currentObject == "track-jet pairs")                    objectToPlot = "trackJetPairs";
1255            else if(currentObject == "jet-jet pairs")                      objectToPlot = "dijetPairs";
1256            else if(currentObject == "jet-secondary jet pairs")            objectToPlot = "jetSecondaryJetPairs";
1257            else if(currentObject == "secondary jets")                     objectToPlot = "secondaryJets";
1258 +          else if(currentObject == "secondary photons")                     objectToPlot = "secondaryPhotons";
1259            else if(currentObject == "electron-track pairs")               objectToPlot = "electronTrackPairs";
1260            else if(currentObject == "muon-track pairs")                   objectToPlot = "muonTrackPairs";
1261            else if(currentObject == "muon-tau pairs")                     objectToPlot = "muonTauPairs";
# Line 1181 | Line 1265 | OSUAnalysis::produce (edm::Event &event,
1265            else if(currentObject == "muon-secondary muon pairs")          objectToPlot = "muonSecondaryMuonPairs";
1266            else if(currentObject == "secondary muons")                    objectToPlot = "secondaryMuons";
1267            else if(currentObject == "muon-secondary jet pairs")           objectToPlot = "muonSecondaryJetPairs";
1268 +          else if(currentObject == "muon-secondary photon pairs")           objectToPlot = "muonSecondaryJetPairs";
1269            else if(currentObject == "electron-secondary jet pairs")       objectToPlot = "electronSecondaryJetPairs";
1270 <          else if(currentObject == "photon-secondary jet pairs")       objectToPlot = "photonSecondaryJetPairs";
1270 >          else if(currentObject == "photon-secondary jet pairs")         objectToPlot = "photonSecondaryJetPairs";
1271            else if(currentObject == "electron-secondary electron pairs")  objectToPlot = "electronSecondaryElectronPairs";
1272            else if(currentObject == "secondary electrons")                objectToPlot = "secondaryElectrons";
1273            else if(currentObject == "electron-trigobj pairs")             objectToPlot = "electronTrigobjPairs";
# Line 1220 | Line 1305 | OSUAnalysis::produce (edm::Event &event,
1305        for (uint iBranch = 0; iBranch != treeBranches_.size(); iBranch++) {
1306          BranchSpecs brSpecs = treeBranches_.at(iBranch);
1307          string coll = brSpecs.inputCollection;
1308 <        if (cumulativeFlags.count(coll) == 0) cout << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1308 >        if (cumulativeFlags.count(coll) == 0) clog << "Error: no flags found for collection:  " << coll << ", will cause a seg fault" << endl;
1309  
1310          if     (coll == "jets")                assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1311          else if(coll == "secondary jets")      assignTreeBranch(brSpecs,jets.product(),          cumulativeFlags.at(coll).back());
1312 +        else if(coll == "secondary photons")      assignTreeBranch(brSpecs,photons.product(),          cumulativeFlags.at(coll).back());
1313          else if(coll == "muons")               assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1314          else if(coll == "secondary muons")     assignTreeBranch(brSpecs,muons.product(),         cumulativeFlags.at(coll).back());
1315          else if(coll == "electrons")           assignTreeBranch(brSpecs,electrons.product(),     cumulativeFlags.at(coll).back());
# Line 1243 | Line 1329 | OSUAnalysis::produce (edm::Event &event,
1329                  && datasetType_ == "signalMC") assignTreeBranch(brSpecs,stops.product(),         cumulativeFlags.at(coll).back());
1330        } // end loop over branches
1331  
1332 <      if (!BNTrees_.at(currentChannelIndex)) { cout << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1332 >      if (!BNTrees_.at(currentChannelIndex)) { clog << "ERROR:  Undefined BNTree.  Will likely seg fault." << endl; }
1333        BNTrees_.at(currentChannelIndex)->Fill();  // only fill if event has passed cuts
1334      }
1335  
# Line 1270 | Line 1356 | OSUAnalysis::evaluateComparison (double
1356    else if(comparison == "==") return testValue == cutValue;
1357    else if(comparison == "=") return testValue == cutValue;
1358    else if(comparison == "!=") return testValue != cutValue;
1359 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1359 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1360  
1361   }
1362  
# Line 1285 | Line 1371 | OSUAnalysis::evaluateComparison (string
1371    else if(comparison == "==") return testValue == cutValue;
1372    else if(comparison == "=") return testValue == cutValue;
1373    else if(comparison == "!=") return testValue != cutValue;
1374 <  else {cout << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1374 >  else {clog << "WARNING: invalid comparison operator '" << comparison << "'\n"; return false;}
1375  
1376   }
1377  
# Line 1295 | Line 1381 | OSUAnalysis::evaluateTriggers (vector<st
1381    //initialize to false until a chosen trigger is passed
1382    bool triggerDecision = false;
1383  
1384 <  if (printAllTriggers_) cout << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1384 >  if (printAllTriggers_) clog << "Printing list of all available triggers (which this event may or may not pass):" << endl;
1385    //loop over all triggers defined in the event
1386    for (BNtriggerCollection::const_iterator trigger = triggerCollection->begin (); trigger != triggerCollection->end (); trigger++){
1387  
1388 <    if (printAllTriggers_) cout << "   " << trigger->name << endl;
1388 >    if (printAllTriggers_) clog << "   " << trigger->name << endl;
1389  
1390      //we're only interested in triggers that actually passed
1391      if(trigger->pass != 1) continue;
# Line 1502 | Line 1588 | OSUAnalysis::valueLookup (const BNjet* o
1588        && object->chargedEmEnergyFraction < 0.5;
1589    }
1590  
1591 +  else if(variable == "dPhiMet") {
1592 +    if (const BNmet *met = chosenMET ()) {
1593 +      value = deltaPhi (object->phi, met->phi);
1594 +    } else value = -999;
1595 +  }
1596 +
1597  
1598 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1598 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1599  
1600    value = applyFunction(function, value);
1601  
1602    return value;
1603 < }
1603 > } // end jet valueLookup
1604  
1605  
1606   //!muon valueLookup
# Line 1605 | Line 1697 | OSUAnalysis::valueLookup (const BNmuon*
1697    else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1698    else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1699    else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1700 +  else if(variable == "chargedHadronIsoDR04") value = object->chargedHadronIsoDR04;
1701 +  else if(variable == "neutralHadronIsoDR04") value = object->neutralHadronIsoDR04;
1702 +  else if(variable == "photonIsoDR04") value = object->photonIsoDR04;
1703 +  else if(variable == "puChargedHadronIsoDR04") value = object->puChargedHadronIsoDR04;
1704    else if(variable == "rhoPrime") value = object->rhoPrime;
1705    else if(variable == "AEffDr03") value = object->AEffDr03;
1706    else if(variable == "AEffDr04") value = object->AEffDr04;
# Line 1612 | Line 1708 | OSUAnalysis::valueLookup (const BNmuon*
1708    else if(variable == "pfIsoR03SumNeutralHadronEt") value = object->pfIsoR03SumNeutralHadronEt;
1709    else if(variable == "pfIsoR03SumPhotonEt") value = object->pfIsoR03SumPhotonEt;
1710    else if(variable == "pfIsoR03SumPUPt") value = object->pfIsoR03SumPUPt;
1711 +  else if(variable == "relpfIsoR04SumExceptChargedHad") value = (object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)/ object->pt;
1712 +  else if(variable == "relpfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt/object->pt;
1713 +  else if(variable == "relpfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt/object->pt;
1714 +  else if(variable == "relpfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt/object->pt;
1715 +  else if(variable == "relpfIsoR04SumPUPt") value = object->pfIsoR04SumPUPt/object->pt;
1716    else if(variable == "pfIsoR04SumChargedHadronPt") value = object->pfIsoR04SumChargedHadronPt;
1717    else if(variable == "pfIsoR04SumNeutralHadronEt") value = object->pfIsoR04SumNeutralHadronEt;
1718    else if(variable == "pfIsoR04SumPhotonEt") value = object->pfIsoR04SumPhotonEt;
# Line 1669 | Line 1770 | OSUAnalysis::valueLookup (const BNmuon*
1770  
1771    //user-defined variables
1772    else if(variable == "looseID") {
1773 <    value = object->pt > 10
1774 <      && object->isGlobalMuon > 0
1775 <      && object->isTrackerMuon > 0;
1776 <      }
1773 >    value = object->pt > 10 &&
1774 >      (object->isGlobalMuon  > 0 ||
1775 >       object->isTrackerMuon > 0);
1776 >  }
1777    else if(variable == "correctedD0VertexErr") value =  hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1778    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
1779    else if(variable == "detIso") value = (object->trackIsoDR03) / object->pt;
1780    else if(variable == "relPFdBetaIso") value = (object->pfIsoR04SumChargedHadronPt + max(0.0, object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt)) / object->pt;
1781 +  else if(variable == "relPFdBetaIsoPseudo") value = (object->pfIsoR04SumChargedHadronPt + object->pfIsoR04SumNeutralHadronEt + object->pfIsoR04SumPhotonEt - 0.5*object->pfIsoR04SumPUPt) / object->pt;
1782    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIso + max(0.0, object->neutralHadronIso + object->photonIso - object->AEffDr03*object->rhoPrime) ) / object->pt;
1783    else if(variable == "metMT") {
1784      if (const BNmet *met = chosenMET ())
# Line 1873 | Line 1975 | OSUAnalysis::valueLookup (const BNmuon*
1975  
1976  
1977  
1978 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1978 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
1979  
1980    value = applyFunction(function, value);
1981  
1982    return value;
1983 < }
1983 > } // end muon valueLookup
1984 >
1985  
1986   //!electron valueLookup
1987   double
# Line 2047 | Line 2150 | OSUAnalysis::valueLookup (const BNelectr
2150    else if(variable == "correctedD0VertexSig") value =  object->correctedD0Vertex / hypot (object->tkD0err, hypot (chosenVertex ()->xError, chosenVertex ()->yError));
2151    else if(variable == "detIso") value = (object->trackIso) / object->pt;
2152    else if(variable == "relPFrhoIso") value = ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt;
2153 +  else if(variable == "relPFrhoIsoEB") value = object->isEB ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2154 +  else if(variable == "relPFrhoIsoEE") value = object->isEE ? ( object->chargedHadronIsoDR03 + max(0.0, object->neutralHadronIsoDR03 + object->photonIsoDR03 - object->AEffDr03*object->rhoPrime) ) / object->pt : -999;
2155    else if(variable == "metMT") {
2156      if (const BNmet *met = chosenMET ())
2157        {
# Line 2118 | Line 2223 | OSUAnalysis::valueLookup (const BNelectr
2223      else value = -999;
2224    }
2225  
2226 +  else if(variable == "looseID"){
2227 +    if (object->isEB)
2228 +      {
2229 +        value = fabs(object->delEtaIn) < 0.007 \
2230 +          && fabs (object->delPhiIn) < 0.15 \
2231 +          && object->scSigmaIEtaIEta < 0.01 \
2232 +          && object->hadOverEm < 0.12 \
2233 +          && fabs (object->correctedD0Vertex) < 0.02 \
2234 +          && fabs (object->correctedDZ) < 0.2 \
2235 +          && object->absInvEMinusInvPin < 0.05 \
2236 +          && object->passConvVeto;
2237 +      }
2238 +    else
2239 +      {
2240 +        value = fabs(object->delEtaIn) < 0.009 \
2241 +          && fabs (object->delPhiIn) < 0.10 \
2242 +          && object->scSigmaIEtaIEta < 0.03 \
2243 +          && object->hadOverEm < 0.10 \
2244 +          && fabs (object->correctedD0Vertex) < 0.02 \
2245 +          && fabs (object->correctedDZ) < 0.2 \
2246 +          && object->absInvEMinusInvPin < 0.05 \
2247 +          && object->passConvVeto;
2248 +      }
2249 +  }
2250 +
2251    else if(variable == "tightID"){
2252      if (object->isEB)
2253        {
# Line 2277 | Line 2407 | OSUAnalysis::valueLookup (const BNelectr
2407  
2408  
2409  
2410 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2410 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2411  
2412    value = applyFunction(function, value);
2413  
2414    return value;
2415 < }
2415 > } // end electron valueLookup
2416 >
2417  
2418   //!event valueLookup
2419   double
# Line 2294 | Line 2425 | OSUAnalysis::valueLookup (const BNevent*
2425    else if(variable == "pthat") value = object->pthat;
2426    else if(variable == "qScale") value = object->qScale;
2427    else if(variable == "alphaQCD") value = object->alphaQCD;
2428 +  else if(variable == "Ht") value = getHt(jets.product());
2429    else if(variable == "alphaQED") value = object->alphaQED;
2430    else if(variable == "scalePDF") value = object->scalePDF;
2431    else if(variable == "x1") value = object->x1;
# Line 2364 | Line 2496 | OSUAnalysis::valueLookup (const BNevent*
2496    else if(variable == "electronScaleFactor") value = electronScaleFactor_;
2497    else if(variable == "stopCTauScaleFactor") value = stopCTauScaleFactor_;
2498    else if(variable == "bTagScaleFactor") value = bTagScaleFactor_;
2499 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2499 >  else if(variable == "ht") value = chosenHT ();
2500 >  else if(variable == "leadMuPairInvMass"){
2501 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2502 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2503 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2504 >    value = (p0 + p1).M ();
2505 >  }
2506 >  else if(variable == "leadMuPairPt"){
2507 >    pair<const BNmuon *, const BNmuon *> muPair = leadMuonPair ();
2508 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2509 >             pt1 (muPair.second->px, muPair.second->py);
2510 >    pt0 += pt1;
2511 >    value = pt0.Mod ();
2512 >  }
2513 >  else if(variable == "leadElPairInvMass"){
2514 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2515 >    TLorentzVector p0 (muPair.first->px, muPair.first->py, muPair.first->pz, muPair.first->energy),
2516 >                   p1 (muPair.second->px, muPair.second->py, muPair.second->pz, muPair.second->energy);
2517 >    value = (p0 + p1).M ();
2518 >  }
2519 >  else if(variable == "leadElPairPt"){
2520 >    pair<const BNelectron *, const BNelectron *> muPair = leadElectronPair ();
2521 >    TVector2 pt0 (muPair.first->px, muPair.first->py),
2522 >             pt1 (muPair.second->px, muPair.second->py);
2523 >    pt0 += pt1;
2524 >    value = pt0.Mod ();
2525 >  }
2526 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2527  
2528    value = applyFunction(function, value);
2529  
2530    return value;
2531 < }
2531 > } // end event valueLookup
2532 >
2533  
2534   //!tau valueLookup
2535   double
# Line 2471 | Line 2631 | OSUAnalysis::valueLookup (const BNtau* o
2631    }
2632  
2633  
2634 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2634 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2635  
2636    value = applyFunction(function, value);
2637  
2638    return value;
2639 < }
2639 > } // end tau valueLookup
2640 >
2641  
2642   //!met valueLookup
2643   double
# Line 2544 | Line 2705 | OSUAnalysis::valueLookup (const BNmet* o
2705    else if(variable == "pfT1jet10pt") value = object->pfT1jet10pt;
2706    else if(variable == "pfT1jet10phi") value = object->pfT1jet10phi;
2707  
2708 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2708 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2709  
2710    value = applyFunction(function, value);
2711  
2712    return value;
2713 < }
2713 > } // end met valueLookup
2714 >
2715  
2716   //!track valueLookup
2717   double
# Line 2577 | Line 2739 | OSUAnalysis::valueLookup (const BNtrack*
2739    else if(variable == "numValidHits") value = object->numValidHits;
2740    else if(variable == "isHighPurity") value = object->isHighPurity;
2741  
2580
2742    //additional BNs info for disappTrks
2743 <  else if(variable == "caloEMDeltaRp3") value = object->caloEMDeltaRp3;
2744 <  else if(variable == "caloHadDeltaRp3") value = object->caloHadDeltaRp3;
2745 <  else if(variable == "caloEMDeltaRp4") value = object->caloEMDeltaRp4;
2746 <  else if(variable == "caloHadDeltaRp4") value = object->caloHadDeltaRp4;
2747 <  else if(variable == "caloEMDeltaRp5") value = object->caloEMDeltaRp5;
2748 <  else if(variable == "caloHadDeltaRp5") value = object->caloHadDeltaRp5;
2749 <  else if(variable == "nTracksRp5") value = object->nTracksRp5;
2750 <  else if(variable == "nHitsMissingOuter") value = object->nHitsMissingOuter;
2590 <  else if(variable == "nHitsMissingInner") value = object->nHitsMissingInner;
2743 >  else if(variable == "caloEMDeltaRp3")     value = object->caloEMDeltaRp3;
2744 >  else if(variable == "caloHadDeltaRp3")    value = object->caloHadDeltaRp3;
2745 >  else if(variable == "caloEMDeltaRp4")     value = object->caloEMDeltaRp4;
2746 >  else if(variable == "caloHadDeltaRp4")    value = object->caloHadDeltaRp4;
2747 >  else if(variable == "caloEMDeltaRp5")     value = object->caloEMDeltaRp5;
2748 >  else if(variable == "caloHadDeltaRp5")    value = object->caloHadDeltaRp5;
2749 >  else if(variable == "nHitsMissingOuter")  value = object->nHitsMissingOuter;
2750 >  else if(variable == "nHitsMissingInner")  value = object->nHitsMissingInner;
2751    else if(variable == "nHitsMissingMiddle") value = object->nHitsMissingMiddle;
2752 <  else if(variable == "depTrkRp5") value = object->depTrkRp5;
2752 >  else if(variable == "depTrkRp3")          value = object->depTrkRp3;
2753 >  else if(variable == "depEcalRp3")         value = object->depEcalRp3;
2754 >  else if(variable == "depHcalRp3")         value = object->depHcalRp3;
2755 >  else if(variable == "depHoRp3")           value = object->depHoRp3;
2756 >  else if(variable == "nTracksRp3")         value = object->nTracksRp3;
2757 >  else if(variable == "trackerVetoPtRp3")   value = object->trackerVetoPtRp3;
2758 >  else if(variable == "emVetoEtRp3")        value = object->emVetoEtRp3;
2759 >  else if(variable == "hadVetoEtRp3")       value = object->hadVetoEtRp3;
2760 >  else if(variable == "hoVetoEtRp3")        value = object->hoVetoEtRp3;
2761 >  else if(variable == "depTrkRp5")          value = object->depTrkRp5;
2762 >  else if(variable == "depEcalRp5")         value = object->depEcalRp5;
2763 >  else if(variable == "depHcalRp5")         value = object->depHcalRp5;
2764 >  else if(variable == "depHoRp5")           value = object->depHoRp5;
2765 >  else if(variable == "nTracksRp5")         value = object->nTracksRp5;
2766 >  else if(variable == "trackerVetoPtRp5")   value = object->trackerVetoPtRp5;
2767 >  else if(variable == "emVetoEtRp5")        value = object->emVetoEtRp5;
2768 >  else if(variable == "hadVetoEtRp5")       value = object->hadVetoEtRp5;
2769 >  else if(variable == "hoVetoEtRp5")        value = object->hoVetoEtRp5;
2770  
2771    //user defined variables
2772    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;
2773    else if(variable == "dZwrtBS") value = object->dZ - events->at(0).BSz;
2774 <  else if(variable == "depTrkRp5MinusPt")           value =  (object->depTrkRp5 - object->pt);
2774 >  else if(variable == "depTrkRp5MinusPt"){
2775 >    if ( (object->depTrkRp5 - object->pt) < 0 ) {
2776 >           value = 0;
2777 >         }
2778 >         else value =  (object->depTrkRp5 - object->pt);
2779 >  }
2780 >  else if(variable == "depTrkRp3MinusPt"){
2781 >    if ( (object->depTrkRp3 - object->pt) < 0 ) {
2782 >      value = 0;
2783 >    }
2784 >    else value =  (object->depTrkRp3 - object->pt);
2785 >  }
2786 >
2787 >  else if(variable == "dPhiMet") {
2788 >    if (const BNmet *met = chosenMET ()) {
2789 >      value = deltaPhi (object->phi, met->phi);
2790 >    } else value = -999;
2791 >  }
2792 >  
2793 >  
2794    else if(variable == "caloTotDeltaRp5")            value =  (object->caloHadDeltaRp5 + object->caloEMDeltaRp5);
2795    else if(variable == "caloTotDeltaRp5ByP")         value = ((object->caloHadDeltaRp5 + object->caloEMDeltaRp5)/pMag);
2796    else if(variable == "caloTotDeltaRp5RhoCorr")     value = getTrkCaloTotRhoCorr(object);
# Line 2671 | Line 2867 | OSUAnalysis::valueLookup (const BNtrack*
2867  
2868  
2869  
2870 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2870 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2871  
2872    value = applyFunction(function, value);
2873  
2874    return value;
2875 < }
2875 > } // end track valueLookup
2876 >
2877  
2878   //!genjet valueLookup
2879   double
# Line 2700 | Line 2897 | OSUAnalysis::valueLookup (const BNgenjet
2897    else if(variable == "charge") value = object->charge;
2898  
2899  
2900 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2900 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
2901  
2902    value = applyFunction(function, value);
2903  
# Line 2834 | Line 3031 | OSUAnalysis::valueLookup (const BNmcpart
3031    }
3032  
3033  
3034 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3034 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3035  
3036    value = applyFunction(function, value);
3037  
3038    return value;
3039 < }
3039 > } // end mcparticle valueLookup
3040 >
3041  
3042   //!primaryvertex valueLookup
3043   double
# Line 2862 | Line 3060 | OSUAnalysis::valueLookup (const BNprimar
3060    else if(variable == "isGood") value = object->isGood;
3061  
3062  
3063 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3063 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3064  
3065    value = applyFunction(function, value);
3066  
# Line 2880 | Line 3078 | OSUAnalysis::valueLookup (const BNbxlumi
3078    else if(variable == "bx_LUMI_now") value = object->bx_LUMI_now;
3079  
3080  
3081 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3081 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3082  
3083    value = applyFunction(function, value);
3084  
# Line 3013 | Line 3211 | OSUAnalysis::valueLookup (const BNphoton
3211    }
3212  
3213  
3214 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3214 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3215  
3216    value = applyFunction(function, value);
3217  
3218    return value;
3219 < }
3219 > } // end photon valueLookup
3220 >
3221  
3222   //!supercluster valueLookup
3223   double
# Line 3036 | Line 3235 | OSUAnalysis::valueLookup (const BNsuperc
3235    else if(variable == "theta") value = object->theta;
3236  
3237  
3238 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3238 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3239  
3240    value = applyFunction(function, value);
3241  
# Line 3070 | Line 3269 | OSUAnalysis::valueLookup (const BNtrigob
3269        stringValue = "none";  // stringValue should only be empty if value is filled
3270    }
3271  
3272 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3272 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3273  
3274    value = applyFunction(function, value);
3275  
# Line 3141 | Line 3340 | OSUAnalysis::valueLookup (const BNmuon*
3340        value = object2->correctedD0;
3341      }
3342  
3343 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3343 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3344  
3345    value = applyFunction(function, value);
3346  
3347    return value;
3348 < }
3348 > } // end muon-muon pair valueLookup
3349 >
3350  
3351   //!muon-photon pair valueLookup
3352   double
# Line 3157 | Line 3357 | OSUAnalysis::valueLookup (const BNmuon*
3357    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3358    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3359    else if(variable == "photonEta") value = object2->eta;
3360 +  else if(variable == "photonPt") value = object2->pt;
3361    else if(variable == "muonEta") value = object1->eta;
3362    else if(variable == "photonPhi") value = object2->phi;
3363    else if(variable == "muonPhi") value = object1->phi;
# Line 3186 | Line 3387 | OSUAnalysis::valueLookup (const BNmuon*
3387        TVector3 threeVector2(object2->px, object2->py, object2->pz);
3388        value = (pi-threeVector1.Angle(threeVector2));
3389      }
3390 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3390 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3391  
3392    value = applyFunction(function, value);
3393  
# Line 3202 | Line 3403 | OSUAnalysis::valueLookup (const BNelectr
3403    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3404    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3405    else if(variable == "photonEta") value = object2->eta;
3406 +  else if(variable == "photonPt") value = object2->pt;
3407    else if(variable == "electronEta") value = object1->eta;
3408    else if(variable == "photonPhi") value = object2->phi;
3409    else if(variable == "electronPhi") value = object1->phi;
# Line 3231 | Line 3433 | OSUAnalysis::valueLookup (const BNelectr
3433        TVector3 threeVector2(object2->px, object2->py, object2->pz);
3434        value = (pi-threeVector1.Angle(threeVector2));
3435      }
3436 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3436 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3437  
3438    value = applyFunction(function, value);
3439  
# Line 3287 | Line 3489 | OSUAnalysis::valueLookup (const BNelectr
3489      value = object2->correctedD0;
3490    }
3491  
3492 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3492 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3493  
3494    value = applyFunction(function, value);
3495  
3496    return value;
3497   }
3498 +
3499   //!electron-muon pair valueLookup
3500   double
3501   OSUAnalysis::valueLookup (const BNelectron* object1, const BNmuon* object2, string variable, string function, string &stringValue){
# Line 3353 | Line 3556 | OSUAnalysis::valueLookup (const BNelectr
3556    else if(variable == "muonRelPFdBetaIso"){
3557      value = (object2->pfIsoR04SumChargedHadronPt + max(0.0, object2->pfIsoR04SumNeutralHadronEt + object2->pfIsoR04SumPhotonEt - 0.5*object2->pfIsoR04SumPUPt)) / object2->pt;
3558    }
3559 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3559 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3560    value = applyFunction(function, value);
3561  
3562    return value;
3563 < }
3563 > } // end electron-muon pair valueLookup
3564 >
3565  
3566   //!electron-jet pair valueLookup
3567   double
# Line 3392 | Line 3596 | OSUAnalysis::valueLookup (const BNelectr
3596      value = object1->charge*object2->charge;
3597    }
3598  
3599 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3599 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3600    value = applyFunction(function, value);
3601  
3602    return value;
# Line 3428 | Line 3632 | OSUAnalysis::valueLookup (const BNphoton
3632        TVector3 threeVector2(object2->px, object2->py, object2->pz);
3633        value = (threeVector1.Angle(threeVector2));
3634      }
3635 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3635 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3636 >  value = applyFunction(function, value);
3637 >
3638 >  return value;
3639 > }
3640 >
3641 > // track-jet pair valueLookup
3642 > double
3643 > OSUAnalysis::valueLookup (const BNtrack* object1, const BNjet* object2, string variable, string function, string &stringValue){
3644 >
3645 >  double value = 0.0;
3646 >
3647 >  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3648 >  else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3649 >
3650 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3651    value = applyFunction(function, value);
3652  
3653    return value;
3654 +
3655   }
3656  
3657 +
3658 +
3659 + // met-jet pair valueLookup
3660 + double
3661 + OSUAnalysis::valueLookup (const BNmet* object1, const BNjet* object2, string variable, string function, string &stringValue){
3662 +
3663 +  double value = 0.0;
3664 +
3665 +  if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3666 +
3667 +  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3668 +  value = applyFunction(function, value);
3669 +
3670 +  return value;
3671 +
3672 + }  
3673 +
3674 +
3675 +
3676   //!muon-jet pair valueLookup
3677   double
3678   OSUAnalysis::valueLookup (const BNmuon* object1, const BNjet* object2, string variable, string function, string &stringValue){
# Line 3442 | Line 3681 | OSUAnalysis::valueLookup (const BNmuon*
3681  
3682    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3683    else if(variable == "jetEta") value = object2->eta;
3684 +  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3685 +  else if(variable == "jetPt") value = object2->pt;
3686    else if(variable == "jetPhi") value = object2->phi;
3687 +  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3688    else if(variable == "muonEta") value = object1->eta;
3689 +  else if(variable == "muonPt") value = object1->pt;
3690    else if(variable == "muonPhi") value = object1->phi;
3691 <  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3691 >  else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);          
3692    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3693    else if(variable == "invMass"){
3694      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3467 | Line 3710 | OSUAnalysis::valueLookup (const BNmuon*
3710      value = object1->charge*object2->charge;
3711    }
3712  
3713 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3713 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3714 >  value = applyFunction(function, value);
3715 >
3716 >  return value;
3717 > }
3718 >
3719 > //!muon-event valueLookup
3720 > double
3721 > OSUAnalysis::valueLookup (const BNmuon* object1, const BNevent* object2, string variable, string function, string &stringValue){
3722 >
3723 >  double value = 0.0;
3724 >
3725 >  if(variable == "muonEta") value = object1->eta;
3726 >  else if(variable == "muonPt") value = object1->pt;
3727 >  else if(variable == "muonPhi") value = object1->phi;
3728 >  else if(variable == "Ht") value = getHt(jets.product());
3729 >  else if(variable == "pthat")   value = object2->pthat;
3730 >  else if(variable == "relPFdBetaIso") value = (object1->pfIsoR04SumChargedHadronPt + max(0.0, object1->pfIsoR04SumNeutralHadronEt + object1->pfIsoR04SumPhotonEt - 0.5*object1->pfIsoR04SumPUPt)) / object1->pt;
3731 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3732    value = applyFunction(function, value);
3733  
3734    return value;
# Line 3480 | Line 3741 | OSUAnalysis::valueLookup (const BNjet* o
3741  
3742    if(variable == "deltaPhi") value = fabs(deltaPhi(object1->phi,object2->phi));
3743    else if(variable == "deltaEta") value = fabs(object1->eta - object2->eta);
3744 <  else if(variable == "absDeltaPt") value = fabs(object1->pt - object2->pt);
3744 >  else if(variable == "deltaPt") value = object1->pt - object2->pt;
3745    else if(variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
3746    else if(variable == "invMass"){
3747      TLorentzVector fourVector1(object1->px, object1->py, object1->pz, object1->energy);
# Line 3502 | Line 3763 | OSUAnalysis::valueLookup (const BNjet* o
3763      value = object1->charge*object2->charge;
3764    }
3765  
3766 <  else{cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3766 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3767    value = applyFunction(function, value);
3768  
3769    return value;
3770   }
3771 +
3772   //!electron-track pair valueLookup
3773   double
3774   OSUAnalysis::valueLookup (const BNelectron* object1, const BNtrack* object2, string variable, string function, string &stringValue){
# Line 3526 | Line 3788 | OSUAnalysis::valueLookup (const BNelectr
3788    else if(variable == "chargeProduct"){
3789      value = object1->charge*object2->charge;
3790    }
3791 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3791 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3792    value = applyFunction(function, value);
3793    return value;
3794  
# Line 3554 | Line 3816 | OSUAnalysis::valueLookup (const BNmuon*
3816      value = object1->charge*object2->charge;
3817    }
3818  
3819 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3819 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3820    value = applyFunction(function, value);
3821    return value;
3822   }
# Line 3576 | Line 3838 | OSUAnalysis::valueLookup (const BNtau* o
3838      value = object1->charge*object2->charge;
3839    }
3840  
3841 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3841 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3842    value = applyFunction(function, value);
3843    return value;
3844   }
# Line 3598 | Line 3860 | OSUAnalysis::valueLookup (const BNmuon*
3860      value = object1->charge*object2->charge;
3861    }
3862  
3863 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3863 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3864    value = applyFunction(function, value);
3865    return value;
3866   }
# Line 3613 | Line 3875 | OSUAnalysis::valueLookup (const BNtau* o
3875      value = object1->charge*object2->charge;
3876    }
3877  
3878 <  else{std::cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3878 >  else{clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999;}
3879    value = applyFunction(function, value);
3880    return value;
3881   }
# Line 3633 | Line 3895 | OSUAnalysis::valueLookup (const BNtrack*
3895    else if (variable == "caloTotDeltaRp5_RhoCorr")    value = getTrkCaloTotRhoCorr(object1);
3896    else if (variable == "caloTotDeltaRp5ByP_RhoCorr") value = getTrkCaloTotRhoCorr(object1) / pMag;
3897  
3898 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3898 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3899  
3900    value = applyFunction(function, value);
3901  
# Line 3655 | Line 3917 | OSUAnalysis::valueLookup (const BNelectr
3917        stringValue = "none";
3918    }
3919  
3920 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3920 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
3921  
3922    value = applyFunction(function, value);
3923  
# Line 3671 | Line 3933 | OSUAnalysis::valueLookup (const BNmuon*
3933  
3934    if (variable == "deltaR") value = deltaR(object1->eta,object1->phi,object2->eta,object2->phi);
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 3784 | Line 4046 | OSUAnalysis::valueLookup (const BNstop*
4046      }
4047    }
4048  
4049 +  else if (variable == "decaysToTau"){
4050 +    value = abs (object->daughter0Id) == 15 || abs (object->daughter1Id) == 15;
4051 +  }
4052 +
4053  
4054  
4055  
4056 <  else { cout << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4056 >  else { clog << "WARNING: invalid variable '" << variable << "'\n"; value = -999; }
4057  
4058    value = applyFunction(function, value);
4059  
4060    return value;
4061  
4062 < }
4062 > } // end stop valueLookup
4063 >
4064  
4065  
4066  
# Line 3811 | Line 4078 | OSUAnalysis::getTrkIsIso (const BNtrack*
4078  
4079   }
4080  
4081 + //calculate the scalar sum of Jet Pt in the event.
4082 + double
4083 + OSUAnalysis::getHt (const BNjetCollection* jetColl){
4084 +  double Ht = 0;
4085 +  for(BNjetCollection::const_iterator jet = jetColl->begin(); jet !=jetColl->end(); jet++){
4086 +    Ht += abs(jet->pt);
4087 +  }
4088 +  return Ht;
4089 + }
4090  
4091   double
4092   OSUAnalysis::getTrkPtRes (const BNtrack* track1){
# Line 3848 | Line 4124 | OSUAnalysis::getTrkCaloTotRhoCorr(const
4124    // Return the pile-up (rho) corrected isolation energy, i.e., the total calorimeter energy around the candidate track.
4125    if (!useTrackCaloRhoCorr_) return -99;
4126    // if (!rhokt6CaloJetsHandle_) {
4127 <  //   cout << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4127 >  //   clog << "ERROR [getTrkCaloTotRhoCorr]:  The collection rhokt6CaloJetsHandle is not available!" << endl;
4128    //   return -99;
4129    // }
4130    double radDeltaRCone = 0.5;
# Line 3870 | Line 4146 | OSUAnalysis::WriteDeadEcal (){
4146    double etaEcal, phiEcal;
4147    ifstream DeadEcalFile(deadEcalFile_);
4148    if(!DeadEcalFile) {
4149 <    cout << "Error: DeadEcalFile has not been found." << endl;
4149 >    clog << "Error: DeadEcalFile has not been found." << endl;
4150      return;
4151    }
4152    if(DeadEcalVec.size()!= 0){
4153 <    cout << "Error: DeadEcalVec has a nonzero size" << endl;
4153 >    clog << "Error: DeadEcalVec has a nonzero size" << endl;
4154      return;
4155    }
4156    while(!DeadEcalFile.eof())
# Line 3885 | Line 4161 | OSUAnalysis::WriteDeadEcal (){
4161        newChan.phiEcal = phiEcal;
4162        DeadEcalVec.push_back(newChan);
4163      }
4164 <  if(DeadEcalVec.size() == 0) cout << "Warning: No dead Ecal channels have been found." << endl;
4164 >  if(DeadEcalVec.size() == 0) clog << "Warning: No dead Ecal channels have been found." << endl;
4165   }
4166  
4167   //if a track is found within dR<0.05 of a dead Ecal channel value = 1, otherwise value = 0
# Line 3925 | Line 4201 | OSUAnalysis::applyFunction(string functi
4201    else if(function == "log") value = log10(value);
4202  
4203    else if(function == "") value = value;
4204 <  else{cout << "WARNING: invalid function '" << function << "'\n";}
4204 >  else{clog << "WARNING: invalid function '" << function << "'\n";}
4205  
4206    return value;
4207  
# Line 3980 | Line 4256 | void OSUAnalysis::setObjectFlags(cut &cu
4256        else plotDecision = cutDecision;
4257      }
4258  
3983    //if(cutDecision != plotDecision && currentCut.variables.at(0) == "pt") cout << "---------------\n" << cutDecision << " " << plotDecision << endl;
4259      individualFlags.at(inputType).at(currentCutIndex).push_back(make_pair(cutDecision,plotDecision));
4260  
4261      //set flags for objects that pass this cut AND all the previous cuts
# Line 3997 | Line 4272 | void OSUAnalysis::setObjectFlags(cut &cu
4272      }
4273      previousCumulativePlotFlag = previousCumulativePlotFlag && plotDecision;
4274  
4000    //if(inputType == "muons") cout << previousCumulativeCutFlag << " " << previousCumulativePlotFlag << " " << currentCut.variables.at(0) << "\n---------------\n\n";
4275      cumulativeFlags.at(inputType).at(currentCutIndex).push_back(make_pair(previousCumulativeCutFlag,previousCumulativePlotFlag));
4276  
4277    }
# Line 4153 | Line 4427 | template <class InputCollection>
4427   void OSUAnalysis::assignTreeBranch(BranchSpecs parameters, InputCollection inputCollection, flagPair flags){
4428    // This function is similar to fill1DHistogram(), but instead of filling a histogram it assigns a value to a variable for the BNTree
4429  
4430 <  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;
4430 >  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;
4431    for (uint object = 0; object != inputCollection->size(); object++) {
4432  
4433      if (!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
# Line 4174 | Line 4448 | void OSUAnalysis::fill1DHistogram(TH1* h
4448  
4449    for (uint object = 0; object != inputCollection->size(); object++){
4450  
4177    //cout << "flags.at(object).second: " << flags.at(object).second << endl;
4178
4451      if(!plotAllObjectsInPassingEvents_ && !flags.at(object).second) continue;
4452  
4453      string currentString = parameters.inputVariables.at(0);
# Line 4196 | Line 4468 | void OSUAnalysis::fill1DHistogram(TH1* h
4468  
4469      if (printEventInfo_) {
4470        // Write information about event to screen, for testing purposes.
4471 <      cout << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4471 >      clog << "  Info for event:  value for histogram " << histo->GetName() << ":  " << value << endl;
4472      }
4473  
4474    }
# Line 4348 | Line 4620 | int OSUAnalysis::getGenMatchedParticleIn
4620  
4621      double currentDeltaR = deltaR(object->eta,object->phi,mcparticle->eta,mcparticle->phi);
4622      if(currentDeltaR > 0.05) continue;
4623 <    //     cout << setprecision(3) << setw(20)
4623 >    //     clog << setprecision(3) << setw(20)
4624      //          << "\tcurrentParticle:  eta = " << mcparticles->at(mcparticle - mcparticles->begin()).eta
4625      //          << setw(20)
4626      //          << "\tphi = " << mcparticles->at(mcparticle - mcparticles->begin()).phi
# Line 4367 | Line 4639 | int OSUAnalysis::getGenMatchedParticleIn
4639      }
4640  
4641    }
4642 <  //   if(bestMatchDeltaR != 999)  cout << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4643 <  //   else cout << "no match found..." << endl;
4642 >  //   if(bestMatchDeltaR != 999)  clog << "bestMatch:  deltaR = " << bestMatchDeltaR << "   id = " << mcparticles->at(bestMatchIndex).id << "   motherId = " << mcparticles->at(bestMatchIndex).motherId << endl;
4643 >  //   else clog << "no match found..." << endl;
4644    return bestMatchIndex;
4645  
4646   }
# Line 4552 | Line 4824 | OSUAnalysis::chosenMuon ()
4824    return chosenMuon;
4825   }
4826  
4827 + double
4828 + OSUAnalysis::chosenHT ()
4829 + {
4830 +  double chosenHT = 0.0;
4831 +  if(cumulativeFlags.find ("jets") != cumulativeFlags.end ()){
4832 +    flagPair jetFlags;
4833 +    for (int i = cumulativeFlags.at("jets").size() - 1; i >= 0; i--){
4834 +      if (cumulativeFlags.at("jets").at(i).size()){
4835 +        jetFlags = cumulativeFlags.at("jets").at(i);
4836 +        break;
4837 +      }
4838 +    }
4839 +    for (uint jetIndex = 0; jetIndex != jetFlags.size(); jetIndex++){
4840 +      if(!jetFlags.at(jetIndex).first) continue;
4841 +      chosenHT += jets->at(jetIndex).pt;
4842 +    }
4843 +  }
4844 +
4845 +  return chosenHT;
4846 + }
4847 +
4848 + pair<const BNmuon *, const BNmuon *>
4849 + OSUAnalysis::leadMuonPair ()
4850 + {
4851 +  pair<const BNmuon *, const BNmuon *> leadMuonPair;
4852 +  leadMuonPair.first = leadMuonPair.second = 0;
4853 +
4854 +  if(cumulativeFlags.find ("muons") != cumulativeFlags.end ()){
4855 +    flagPair muonFlags;
4856 +    for (int i = cumulativeFlags.at("muons").size() - 1; i >= 0; i--){
4857 +      if (cumulativeFlags.at("muons").at(i).size()){
4858 +        muonFlags = cumulativeFlags.at("muons").at(i);
4859 +        break;
4860 +      }
4861 +    }
4862 +    for (uint muonIndex0 = 0; muonIndex0 != muonFlags.size(); muonIndex0++){
4863 +      if(!muonFlags.at(muonIndex0).first) continue;
4864 +      for (uint muonIndex1 = muonIndex0 + 1; muonIndex1 < muonFlags.size(); muonIndex1++){
4865 +        if(!muonFlags.at(muonIndex1).first) continue;
4866 +        const BNmuon *mu0 = & muons->at(muonIndex0);
4867 +        const BNmuon *mu1 = & muons->at(muonIndex1);
4868 +        if(leadMuonPair.first == 0 || leadMuonPair.second == 0){
4869 +          leadMuonPair.first = mu0;
4870 +          leadMuonPair.second = mu1;
4871 +        }
4872 +        else{
4873 +          TVector2 newPt0 (mu0->px, mu0->py),
4874 +                   newPt1 (mu1->px, mu1->py),
4875 +                   oldPt0 (leadMuonPair.first->px, leadMuonPair.first->py),
4876 +                   oldPt1 (leadMuonPair.second->px, leadMuonPair.second->py);
4877 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4878 +            {
4879 +              leadMuonPair.first = mu0;
4880 +              leadMuonPair.second = mu1;
4881 +            }
4882 +        }
4883 +      }
4884 +    }
4885 +  }
4886 +
4887 +  return leadMuonPair;
4888 + }
4889 +
4890 + pair<const BNelectron *, const BNelectron *>
4891 + OSUAnalysis::leadElectronPair ()
4892 + {
4893 +  pair<const BNelectron *, const BNelectron *> leadElectronPair;
4894 +  leadElectronPair.first = leadElectronPair.second = 0;
4895 +  if(cumulativeFlags.find ("electrons") != cumulativeFlags.end ()){
4896 +    flagPair electronFlags;
4897 +    for (int i = cumulativeFlags.at("electrons").size() - 1; i >= 0; i--){
4898 +      if (cumulativeFlags.at("electrons").at(i).size()){
4899 +        electronFlags = cumulativeFlags.at("electrons").at(i);
4900 +        break;
4901 +      }
4902 +    }
4903 +    for (uint electronIndex0 = 0; electronIndex0 != electronFlags.size(); electronIndex0++){
4904 +      if(!electronFlags.at(electronIndex0).first) continue;
4905 +      for (uint electronIndex1 = electronIndex0 + 1; electronIndex1 < electronFlags.size(); electronIndex1++){
4906 +        if(!electronFlags.at(electronIndex1).first) continue;
4907 +        const BNelectron *el0 = & electrons->at(electronIndex0);
4908 +        const BNelectron *el1 = & electrons->at(electronIndex1);
4909 +        if(leadElectronPair.first == 0 || leadElectronPair.second == 0){
4910 +          leadElectronPair.first = el0;
4911 +          leadElectronPair.second = el1;
4912 +        }
4913 +        else{
4914 +          TVector2 newPt0 (el0->px, el0->py),
4915 +                   newPt1 (el1->px, el1->py),
4916 +                   oldPt0 (leadElectronPair.first->px, leadElectronPair.first->py),
4917 +                   oldPt1 (leadElectronPair.second->px, leadElectronPair.second->py);
4918 +          if(newPt0.Mod () + newPt1.Mod () > oldPt0.Mod() + oldPt1.Mod ())
4919 +            {
4920 +              leadElectronPair.first = el0;
4921 +              leadElectronPair.second = el1;
4922 +            }
4923 +        }
4924 +      }
4925 +    }
4926 +  }
4927 +
4928 +  return leadElectronPair;
4929 + }
4930 +
4931   DEFINE_FWK_MODULE(OSUAnalysis);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines