Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:23

0001 #include "DQMOffline/Trigger/interface/EgHLTOfflineClient.h"
0002 
0003 #include "FWCore/Framework/interface/Run.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ServiceRegistry/interface/Service.h"
0007 
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 
0010 #include "DQMServices/Core/interface/DQMStore.h"
0011 
0012 #include "DQMOffline/Trigger/interface/EgHLTTrigTools.h"
0013 
0014 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0015 
0016 #include <boost/algorithm/string.hpp>
0017 
0018 #include "TGraphAsymmErrors.h"
0019 
0020 EgHLTOfflineClient::EgHLTOfflineClient(const edm::ParameterSet& iConfig) : isSetup_(false) {
0021   eleHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames");
0022   eleHLTFilterNames2Leg_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames2Leg");
0023   eleTightLooseTrigNames_ = iConfig.getParameter<std::vector<std::string> >("eleTightLooseTrigNames");
0024   phoHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNames");
0025   phoHLTFilterNames2Leg_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNames2Leg");
0026   phoTightLooseTrigNames_ = iConfig.getParameter<std::vector<std::string> >("phoTightLooseTrigNames");
0027 
0028   eleN1EffVars_ = iConfig.getParameter<std::vector<std::string> >("eleN1EffVars");
0029   eleSingleEffVars_ = iConfig.getParameter<std::vector<std::string> >("eleSingleEffVars");
0030   eleEffTags_ = iConfig.getParameter<std::vector<std::string> >("eleEffTags");
0031   eleTrigTPEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("eleTrigTPEffVsVars");
0032   eleLooseTightTrigEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("eleLooseTightTrigEffVsVars");
0033   eleHLTvOfflineVars_ = iConfig.getParameter<std::vector<std::string> >("eleHLTvOfflineVars");
0034 
0035   phoN1EffVars_ = iConfig.getParameter<std::vector<std::string> >("phoN1EffVars");
0036   phoSingleEffVars_ = iConfig.getParameter<std::vector<std::string> >("phoSingleEffVars");
0037   phoEffTags_ = iConfig.getParameter<std::vector<std::string> >("phoEffTags");
0038   phoTrigTPEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("phoTrigTPEffVsVars");
0039   phoLooseTightTrigEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("phoLooseTightTrigEffVsVars");
0040   phoHLTvOfflineVars_ = iConfig.getParameter<std::vector<std::string> >("phoHLTvOfflineVars");
0041 
0042   runClientEndLumiBlock_ = iConfig.getParameter<bool>("runClientEndLumiBlock");
0043   runClientEndRun_ = iConfig.getParameter<bool>("runClientEndRun");
0044   runClientEndJob_ = iConfig.getParameter<bool>("runClientEndJob");
0045 
0046   dirName_ = iConfig.getParameter<std::string>("DQMDirName");
0047 
0048   filterInactiveTriggers_ = iConfig.getParameter<bool>("filterInactiveTriggers");
0049   hltTag_ = iConfig.getParameter<std::string>("hltTag");
0050 }
0051 
0052 EgHLTOfflineClient::~EgHLTOfflineClient() = default;
0053 
0054 void EgHLTOfflineClient::dqmEndJob(DQMStore::IBooker& ibooker_, DQMStore::IGetter& igetter_) {
0055   if (runClientEndJob_)
0056     runClient_(ibooker_, igetter_);
0057 }
0058 
0059 void EgHLTOfflineClient::beginRun(const edm::Run& run, const edm::EventSetup& c) {
0060   if (!isSetup_) {
0061     if (filterInactiveTriggers_) {
0062       HLTConfigProvider hltConfig;
0063       bool changed = false;
0064       hltConfig.init(run, c, hltTag_, changed);
0065       std::vector<std::string> activeFilters;
0066       std::vector<std::string> activeEleFilters;
0067       std::vector<std::string> activeEle2LegFilters;
0068       std::vector<std::string> activePhoFilters;
0069       std::vector<std::string> activePho2LegFilters;
0070       egHLT::trigTools::getActiveFilters(
0071           hltConfig, activeFilters, activeEleFilters, activeEle2LegFilters, activePhoFilters, activePho2LegFilters);
0072 
0073       egHLT::trigTools::filterInactiveTriggers(eleHLTFilterNames_, activeEleFilters);
0074       egHLT::trigTools::filterInactiveTriggers(eleHLTFilterNames2Leg_, activeEle2LegFilters);
0075       egHLT::trigTools::filterInactiveTriggers(phoHLTFilterNames_, activePhoFilters);
0076       egHLT::trigTools::filterInactiveTightLooseTriggers(eleTightLooseTrigNames_, activeEleFilters);
0077       egHLT::trigTools::filterInactiveTightLooseTriggers(phoTightLooseTrigNames_, activePhoFilters);
0078     }
0079     isSetup_ = true;
0080   }
0081 }
0082 
0083 void EgHLTOfflineClient::dqmEndLuminosityBlock(DQMStore::IBooker& ibooker_,
0084                                                DQMStore::IGetter& igetter_,
0085                                                edm::LuminosityBlock const& iLumi,
0086                                                edm::EventSetup const& iSetup) {
0087   if (runClientEndLumiBlock_)
0088     runClient_(ibooker_, igetter_);
0089 }
0090 
0091 void EgHLTOfflineClient::runClient_(DQMStore::IBooker& ibooker, DQMStore::IGetter& igetter) {
0092   ibooker.setCurrentFolder(dirName_ + "/Client_Histos");
0093 
0094   std::vector<std::string> regions;
0095   regions.emplace_back("eb");
0096   regions.emplace_back("ee");
0097 
0098   for (auto const& eleHLTFilterName : eleHLTFilterNames_) {
0099     //std::cout<<"FilterName: "<<eleHLTFilterNames_[filterNr]<<std::endl;
0100     for (auto const& region : regions) {
0101       for (auto const& eleEffTag : eleEffTags_) {
0102         //----Morse----
0103         ibooker.setCurrentFolder(dirName_ + "/Client_Histos/" + eleHLTFilterName);
0104         //--------------
0105         createN1EffHists(
0106             eleHLTFilterName, eleHLTFilterName + "_gsfEle_" + eleEffTag, region, eleN1EffVars_, ibooker, igetter);
0107 
0108         createSingleEffHists(
0109             eleHLTFilterName, eleHLTFilterName + "_gsfEle_" + eleEffTag, region, eleSingleEffVars_, ibooker, igetter);
0110 
0111         createTrigTagProbeEffHistsNewAlgo(eleHLTFilterName, region, eleTrigTPEffVsVars_, "gsfEle", ibooker, igetter);
0112 
0113         createHLTvsOfflineHists(
0114             eleHLTFilterName, eleHLTFilterName + "_gsfEle_passFilter", region, eleHLTvOfflineVars_, ibooker, igetter);
0115       }
0116     }
0117   }
0118   for (auto& filterNr : eleHLTFilterNames2Leg_) {
0119     for (auto const& region : regions) {
0120       for (size_t effNr = 0; effNr < eleEffTags_.size(); effNr++) {
0121         std::string trigNameLeg1 = filterNr.substr(0, filterNr.find("::"));
0122 
0123         std::string trigNameLeg2 = filterNr.substr(filterNr.find("::") + 2);
0124 
0125         ibooker.setCurrentFolder(dirName_ + "/Client_Histos/" + trigNameLeg2);
0126         createTrigTagProbeEffHists2Leg(
0127             trigNameLeg1, trigNameLeg2, region, eleTrigTPEffVsVars_, "gsfEle", ibooker, igetter);
0128       }
0129     }
0130   }
0131 
0132   for (auto const& phoHLTFilterName : phoHLTFilterNames_) {
0133     for (auto const& region : regions) {
0134       for (auto const& phoEffTag : phoEffTags_) {
0135         //----Morse----
0136         ibooker.setCurrentFolder(dirName_ + "/Client_Histos/" + phoHLTFilterName);
0137         createN1EffHists(
0138             phoHLTFilterName, phoHLTFilterName + "_pho_" + phoEffTag, region, phoN1EffVars_, ibooker, igetter);
0139 
0140         createSingleEffHists(
0141             phoHLTFilterName, phoHLTFilterName + "_pho_" + phoEffTag, region, phoSingleEffVars_, ibooker, igetter);
0142 
0143         createTrigTagProbeEffHistsNewAlgo(phoHLTFilterName, region, phoTrigTPEffVsVars_, "pho", ibooker, igetter);
0144 
0145         createHLTvsOfflineHists(
0146             phoHLTFilterName, phoHLTFilterName + "_pho_passFilter", region, phoHLTvOfflineVars_, ibooker, igetter);
0147 
0148         //--------------
0149       }
0150     }
0151   }
0152 
0153   for (auto const& region : regions) {
0154     createLooseTightTrigEff(eleTightLooseTrigNames_, region, eleLooseTightTrigEffVsVars_, "gsfEle", ibooker, igetter);
0155 
0156     createLooseTightTrigEff(
0157         eleTightLooseTrigNames_, region, eleLooseTightTrigEffVsVars_, "gsfEle_trigCuts", ibooker, igetter);
0158 
0159     createLooseTightTrigEff(phoTightLooseTrigNames_, region, phoLooseTightTrigEffVsVars_, "pho", ibooker, igetter);
0160 
0161     createLooseTightTrigEff(
0162         phoTightLooseTrigNames_, region, phoLooseTightTrigEffVsVars_, "pho_trigCuts", ibooker, igetter);
0163   }
0164   //----Morse-----
0165   ibooker.setCurrentFolder(dirName_);
0166   //----------
0167 }
0168 
0169 void EgHLTOfflineClient::createHLTvsOfflineHists(const std::string& filterName,
0170                                                  const std::string& baseName,
0171                                                  const std::string& region,
0172                                                  const std::vector<std::string>& varNames,
0173                                                  DQMStore::IBooker& ibooker,
0174                                                  DQMStore::IGetter& igetter) {
0175   //need to do Energy manually to get SC Energy
0176   /*
0177   MonitorElement* numer = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_HLTenergy"+"_"+region);
0178   MonitorElement* denom = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_energy"+"_"+region);
0179 
0180   if(numer!=NULL && denom!=NULL){
0181     std::string effHistName(baseName+"_HLToverOfflineSC_energy_"+region);//std::cout<<"hltVSoffline:  "<<effHistName<<std::endl;
0182     std::string effHistTitle(effHistName);
0183     if(region=="eb" || region=="ee"){
0184       if(region=="eb") effHistTitle = "Barrel "+baseName+" HLToverOfflineSC Energy";
0185       if(region=="ee") effHistTitle = "Endcap "+baseName+" HLToverOfflineSC Energy";
0186       FillHLTvsOfflineHist(filterName,effHistName,effHistTitle,numer,denom);    
0187     }
0188   }//end Et
0189   */
0190 
0191   //now eta, phi automatically
0192   for (auto const& varName : varNames) {
0193     MonitorElement* numer =
0194         igetter.get(dirName_ + "/Source_Histos/" + filterName + "/" + baseName + "_HLT" + varName + "_" + region);
0195     MonitorElement* denom =
0196         igetter.get(dirName_ + "/Source_Histos/" + filterName + "/" + baseName + "_" + varName + "_" + region);
0197     if (numer != nullptr && denom != nullptr) {
0198       std::string effHistName(baseName + "_HLToverOffline_" + varName + "_" +
0199                               region);  //std::cout<<"hltVSoffline:  "<<effHistName<<std::endl;
0200       std::string effHistTitle(effHistName);
0201       if (region == "eb" || region == "ee") {
0202         if (region == "eb")
0203           effHistTitle = "Barrel " + baseName + " HLToverOffline " + varName;
0204         if (region == "ee")
0205           effHistTitle = "Endcap " + baseName + " HLToverOffline " + varName;
0206         FillHLTvsOfflineHist(filterName, effHistName, effHistTitle, numer, denom, ibooker, igetter);
0207       }
0208     }
0209   }  //end loop over varNames
0210 }
0211 
0212 EgHLTOfflineClient::MonitorElement* EgHLTOfflineClient::FillHLTvsOfflineHist(const std::string& filter,
0213                                                                              const std::string& name,
0214                                                                              const std::string& title,
0215                                                                              const MonitorElement* numer,
0216                                                                              const MonitorElement* denom,
0217                                                                              DQMStore::IBooker& ibooker,
0218                                                                              DQMStore::IGetter& igetter) {
0219   TH1F* num = numer->getTH1F();
0220   if (num->GetSumw2N() == 0)
0221     num->Sumw2();
0222 
0223   TH1F* den = denom->getTH1F();
0224   if (den->GetSumw2N() == 0)
0225     den->Sumw2();
0226 
0227   auto* h_eff = (TH1F*)num->Clone(name.c_str());
0228   h_eff->Divide(num, den, 1, 1, "B");
0229   h_eff->SetTitle(title.c_str());
0230   MonitorElement* eff = igetter.get(dirName_ + "/Client_Histos/" + filter + "/" + name);
0231   if (eff == nullptr) {
0232     eff = ibooker.book1D(name, h_eff);
0233   } else {  //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
0234     *eff->getTH1F() = *h_eff;
0235     delete h_eff;
0236   }
0237   return eff;
0238 }
0239 
0240 void EgHLTOfflineClient::createN1EffHists(const std::string& filterName,
0241                                           const std::string& baseName,
0242                                           const std::string& region,
0243                                           const std::vector<std::string>& varNames,
0244                                           DQMStore::IBooker& ibooker,
0245                                           DQMStore::IGetter& igetter) {
0246   MonitorElement* numer =
0247       igetter.get(dirName_ + "/Source_Histos/" + filterName + "/" + baseName + "_allCuts_" + region);
0248 
0249   for (auto const& varName : varNames) {
0250     MonitorElement* denom =
0251         igetter.get(dirName_ + "/Source_Histos/" + filterName + "/" + baseName + "_n1_" + varName + "_" + region);
0252     if (numer != nullptr && denom != nullptr) {
0253       std::string effHistName(baseName + "_n1Eff_" + varName + "_" +
0254                               region);  //std::cout<<"N1:  "<<effHistName<<std::endl;
0255       //std::cout<<region<<"  ";
0256       //----Morse-----------
0257       std::string effHistTitle(effHistName);  //std::cout<<effHistTitle<<std::endl;
0258       if (region == "eb" || region == "ee") {
0259         if (region == "eb")
0260           effHistTitle = "Barrel " + baseName + " N1eff " + varName;
0261         if (region == "ee")
0262           effHistTitle = "Endcap " + baseName + " N1eff " + varName;
0263       }  //std::cout<<effHistTitle<<std::endl;
0264       makeEffMonElemFromPassAndAll(filterName, effHistName, effHistTitle, numer, denom, ibooker, igetter);
0265       //---------------------
0266     }
0267   }  //end loop over varNames
0268 }
0269 
0270 void EgHLTOfflineClient::createSingleEffHists(const std::string& filterName,
0271                                               const std::string& baseName,
0272                                               const std::string& region,
0273                                               const std::vector<std::string>& varNames,
0274                                               DQMStore::IBooker& ibooker,
0275                                               DQMStore::IGetter& igetter) {
0276   MonitorElement* denom = igetter.get(dirName_ + "/Source_Histos/" + filterName + "/" + baseName + "_noCuts_" + region);
0277 
0278   for (auto const& varName : varNames) {
0279     MonitorElement* numer =
0280         igetter.get(dirName_ + "/Source_Histos/" + filterName + "/" + baseName + "_single_" + varName + "_" + region);
0281     if (numer != nullptr && denom != nullptr) {
0282       std::string effHistName(baseName + "_singleEff_" + varName + "_" +
0283                               region);  //std::cout<<"Si:  "<<effHistName<<std::endl;
0284       //----Morse-----------
0285       std::string effHistTitle(effHistName);  //std::cout<<effHistTitle<<std::endl;
0286       if (region == "eb" || region == "ee") {
0287         if (region == "eb")
0288           effHistTitle = "Barrel " + baseName + " SingleEff " + varName;
0289         if (region == "ee")
0290           effHistTitle = "Endcap " + baseName + " SingleEff " + varName;
0291       }  //std::cout<<effHistTitle<<std::endl;
0292       makeEffMonElemFromPassAndAll(filterName, effHistName, effHistTitle, numer, denom, ibooker, igetter);
0293       //--------------------
0294     }
0295   }  //end loop over varNames
0296 }
0297 
0298 void EgHLTOfflineClient::createTrigTagProbeEffHists(const std::string& filterName,
0299                                                     const std::string& region,
0300                                                     const std::vector<std::string>& vsVarNames,
0301                                                     const std::string& objName,
0302                                                     DQMStore::IBooker& ibooker,
0303                                                     DQMStore::IGetter& igetter) {
0304   for (auto const& vsVarName : vsVarNames) {
0305     std::string allName(dirName_ + "/Source_Histos/" + filterName + "/" + filterName + "_trigTagProbe_" + objName +
0306                         "_all_" + vsVarName + "_" + region);
0307     MonitorElement* all = igetter.get(allName);
0308     if (all == nullptr) {
0309       continue;
0310     }
0311     std::string passName(dirName_ + "/Source_Histos/" + filterName + "/" + filterName + "_trigTagProbe_" + objName +
0312                          "_pass_" + vsVarName + "_" + region);
0313     MonitorElement* pass = igetter.get(passName);
0314     if (pass == nullptr) {
0315       continue;
0316     }
0317     //----Morse-----
0318     std::string effHistTitle(filterName + "_trigTagProbeEff_" + objName + "_vs_" + vsVarName + "_" +
0319                              region);  //std::cout<<effHistTitle<<std::endl;
0320     if (region == "eb" || region == "ee") {
0321       if (region == "eb")
0322         effHistTitle = "Barrel " + filterName + "_" + objName + " TrigTagProbeEff vs " + vsVarName;
0323       if (region == "ee")
0324         effHistTitle = "Endcap " + filterName + "_" + objName + " TrigTagProbeEff vs " + vsVarName;
0325     }
0326     //------------
0327     makeEffMonElemFromPassAndAll(filterName,
0328                                  filterName + "_trigTagProbeEff_" + objName + "_vs_" + vsVarName + "_" + region,
0329                                  effHistTitle,
0330                                  pass,
0331                                  all,
0332                                  ibooker,
0333                                  igetter);
0334 
0335   }  //end loop over vsVarNames
0336 }
0337 
0338 void EgHLTOfflineClient::createTrigTagProbeEffHistsNewAlgo(const std::string& filterName,
0339                                                            const std::string& region,
0340                                                            const std::vector<std::string>& vsVarNames,
0341                                                            const std::string& objName,
0342                                                            DQMStore::IBooker& ibooker,
0343                                                            DQMStore::IGetter& igetter) {
0344   for (auto const& vsVarName : vsVarNames) {
0345     /* 
0346        std::string allName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_all_"+vsVarNames[varNr]+"_"+region);
0347        MonitorElement* all = dbe_->get(allName); 
0348        if(all==NULL){
0349        //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<allName;
0350        continue;
0351        }*/
0352     std::string passName(dirName_ + "/Source_Histos/" + filterName + "/" + filterName + "_trigTagProbe_" + objName +
0353                          "_passNotTag_" + vsVarName + "_" + region);
0354     MonitorElement* passNotTag = igetter.get(passName);
0355     if (passNotTag == nullptr) {
0356       //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<passName;
0357       continue;
0358     }
0359     std::string passTagTagName(dirName_ + "/Source_Histos/" + filterName + "/" + filterName + "_trigTagProbe_" +
0360                                objName + "_passTagTag_" + vsVarName + "_" + region);
0361     MonitorElement* passTagTag = igetter.get(passTagTagName);
0362     if (passTagTag == nullptr) {
0363       //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<passTagTagName;
0364       continue;
0365     }
0366     std::string failName(dirName_ + "/Source_Histos/" + filterName + "/" + filterName + "_trigTagProbe_" + objName +
0367                          "_fail_" + vsVarName + "_" + region);
0368     MonitorElement* fail = igetter.get(failName);
0369     if (fail == nullptr) {
0370       //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<failName;
0371       continue;
0372     }
0373     //----Morse-----
0374     std::string effHistTitle(filterName + "_trigTagProbeEff_" + objName + "_vs_" + vsVarName + "_" +
0375                              region);  //std::cout<<effHistTitle<<std::endl;
0376     if (region == "eb" || region == "ee") {
0377       if (region == "eb")
0378         effHistTitle = "Barrel " + filterName + "_" + objName + " TrigTagProbeEff vs " + vsVarName;
0379       if (region == "ee")
0380         effHistTitle = "Endcap " + filterName + "_" + objName + " TrigTagProbeEff vs " + vsVarName;
0381     }  //std::cout<<effHistTitle<<std::endl;
0382     //------------
0383     makeEffMonElemFromPassAndFailAndTagTag(
0384         filterName,
0385         filterName + "_trigTagProbeEff_" + objName + "_vs_" + vsVarName + "_" + region,
0386         effHistTitle,
0387         passNotTag,
0388         fail,
0389         passTagTag,
0390         ibooker,
0391         igetter);
0392   }  //end loop over vsVarNames
0393 }
0394 
0395 void EgHLTOfflineClient::createTrigTagProbeEffHists2Leg(const std::string& filterNameLeg1,
0396                                                         const std::string& filterNameLeg2,
0397                                                         const std::string& region,
0398                                                         const std::vector<std::string>& vsVarNames,
0399                                                         const std::string& objName,
0400                                                         DQMStore::IBooker& ibooker,
0401                                                         DQMStore::IGetter& igetter) {
0402   for (auto const& vsVarName : vsVarNames) {
0403     std::string allName(dirName_ + "/Source_Histos/" + filterNameLeg2 + "/" + filterNameLeg2 + "_trigTagProbe_" +
0404                         objName + "_all_" + vsVarName + "_" + region);
0405     MonitorElement* all = igetter.get(allName);
0406     if (all == nullptr) {
0407       edm::LogInfo("EgHLTOfflineClient") << " couldnt get hist " << allName;
0408       continue;
0409     }
0410 
0411     std::string Leg2NotLeg1SourceName(dirName_ + "/Source_Histos/" + filterNameLeg2 + "/" + filterNameLeg2 +
0412                                       "_trigTagProbe_" + objName + "_passLeg2failLeg1_" + vsVarName + "_" + region);
0413     MonitorElement* Leg2NotLeg1Source = igetter.get(Leg2NotLeg1SourceName);
0414     if (Leg2NotLeg1Source == nullptr) {
0415       edm::LogInfo("EgHLTOfflineClient") << " couldnt get hist " << Leg2NotLeg1SourceName;
0416       continue;
0417     }
0418 
0419     std::string Leg1EffName(dirName_ + "/Client_Histos/" + filterNameLeg1 + "/" + filterNameLeg1 + "_trigTagProbeEff_" +
0420                             objName + "_vs_" + vsVarName + "_" + region);
0421     MonitorElement* Leg1Eff = igetter.get(Leg1EffName);
0422     if (Leg1Eff == nullptr) {
0423       edm::LogInfo("EgHLTOfflineClient") << " couldnt get hist " << Leg1EffName;
0424       continue;
0425     }
0426 
0427     std::string effHistTitle(filterNameLeg2 + "_trigTagProbeEff2Leg_" + objName + "_vs_" + vsVarName + "_" +
0428                              region);  //std::cout<<effHistTitle<<std::endl;
0429     if (region == "eb" || region == "ee") {
0430       if (region == "eb")
0431         effHistTitle = "Barrel " + filterNameLeg2 + "_" + objName + " TrigTagProbeEff2Leg vs " + vsVarName;
0432       if (region == "ee")
0433         effHistTitle = "Endcap " + filterNameLeg2 + "_" + objName + " TrigTagProbeEff2Leg vs " + vsVarName;
0434     }  //std::cout<<effHistTitle<<std::endl;
0435     makeEffMonElem2Leg(filterNameLeg2,
0436                        filterNameLeg2 + "_trigTagProbeEff2Leg_" + objName + "_vs_" + vsVarName + "_" + region,
0437                        effHistTitle,
0438                        Leg1Eff,
0439                        Leg2NotLeg1Source,
0440                        all,
0441                        ibooker,
0442                        igetter);
0443   }  //end loop over vsVarNames
0444 }
0445 
0446 void EgHLTOfflineClient::createLooseTightTrigEff(const std::vector<std::string>& tightLooseTrigNames,
0447                                                  const std::string& region,
0448                                                  const std::vector<std::string>& vsVarNames,
0449                                                  const std::string& objName,
0450                                                  DQMStore::IBooker& ibooker,
0451                                                  DQMStore::IGetter& igetter) {
0452   for (auto const& vsVarName : vsVarNames) {
0453     for (auto const& tightLooseTrigName : tightLooseTrigNames) {
0454       std::vector<std::string> splitString;
0455       boost::split(splitString, tightLooseTrigName, boost::is_any_of(std::string(":")));
0456       if (splitString.size() != 2) {
0457         continue;  //format incorrect
0458       }
0459 
0460       const std::string& tightTrig = splitString[0];
0461       const std::string& looseTrig = splitString[1];
0462       MonitorElement* fail = igetter.get(dirName_ + "/Source_Histos/" + tightTrig + "_" + looseTrig + "_" + objName +
0463                                          "_failTrig_" + vsVarName + "_" + region);
0464       if (fail == nullptr) {
0465         continue;
0466       }
0467 
0468       MonitorElement* pass = igetter.get(dirName_ + "/Source_Histos/" + tightTrig + "_" + looseTrig + "_" + objName +
0469                                          "_passTrig_" + vsVarName + "_" + region);
0470       if (pass == nullptr) {
0471         continue;
0472       }
0473 
0474       const std::string newHistName(tightTrig + "_trigEffTo_" + looseTrig + "_" + objName + "_vs_" + vsVarName + "_" +
0475                                     region);
0476       //----Morse-----
0477       std::string effHistTitle(newHistName);  //std::cout<<effHistTitle<<std::endl;
0478       if (region == "eb" || region == "ee") {
0479         if (region == "eb")
0480           effHistTitle = "Barrel " + tightTrig + "_TrigEffTo_" + looseTrig + "_" + objName + " vs " + vsVarName;
0481         if (region == "ee")
0482           effHistTitle = "Endcap " + tightTrig + "_TrigEffTo_" + looseTrig + "_" + objName + " vs " + vsVarName;
0483       }
0484       //------------
0485       makeEffMonElemFromPassAndFail("LooseTight", newHistName, effHistTitle, pass, fail, ibooker, igetter);
0486 
0487     }  //end loop over trigger pairs
0488   }    //end loop over vsVarNames
0489 }
0490 //-----Morse-------
0491 EgHLTOfflineClient::MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndAll(const std::string& filterName,
0492                                                                                      const std::string& name,
0493                                                                                      const std::string& title,
0494                                                                                      const MonitorElement* pass,
0495                                                                                      const MonitorElement* all,
0496                                                                                      DQMStore::IBooker& ibooker,
0497                                                                                      DQMStore::IGetter& igetter) {
0498   TH1F* passHist = pass->getTH1F();
0499   if (passHist->GetSumw2N() == 0)
0500     passHist->Sumw2();
0501   TH1F* allHist = all->getTH1F();
0502   if (allHist->GetSumw2N() == 0)
0503     allHist->Sumw2();
0504   auto* effHist = (TH1F*)passHist->Clone(name.c_str());
0505   effHist->Divide(passHist, allHist, 1, 1, "B");
0506   //----Morse---------
0507   effHist->SetTitle(title.c_str());
0508   //------------------
0509   MonitorElement* eff = igetter.get(dirName_ + "/Client_Histos/" + filterName + "/" + name);
0510   if (eff == nullptr) {
0511     eff = ibooker.book1D(name, effHist);
0512   } else {  //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
0513     *eff->getTH1F() = *effHist;
0514     delete effHist;
0515   }
0516   return eff;
0517 }
0518 
0519 EgHLTOfflineClient::MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndFailAndTagTag(
0520     const std::string& filter,
0521     const std::string& name,
0522     const std::string& title,
0523     const MonitorElement* passNotTag,
0524     const MonitorElement* fail,
0525     const MonitorElement* tagtag,
0526     DQMStore::IBooker& ibooker,
0527     DQMStore::IGetter& igetter) {
0528   TH1F* passHist = passNotTag->getTH1F();
0529   if (passHist->GetSumw2N() == 0)
0530     passHist->Sumw2();
0531   TH1F* failHist = fail->getTH1F();
0532   if (failHist->GetSumw2N() == 0)
0533     failHist->Sumw2();
0534   TH1F* tagtagHist = tagtag->getTH1F();
0535   if (tagtagHist->GetSumw2N() == 0)
0536     tagtagHist->Sumw2();
0537   auto* numer = (TH1F*)passHist->Clone(name.c_str());
0538   if (numer->GetSumw2N() == 0)
0539     numer->Sumw2();
0540   numer->Add(tagtagHist, passHist, 2, 1);
0541   auto* denom = (TH1F*)passHist->Clone(name.c_str());
0542   if (denom->GetSumw2N() == 0)
0543     denom->Sumw2();
0544   denom->Add(tagtagHist, passHist, 2, 1);
0545   denom->Add(failHist, 1);
0546   auto* effHist = (TH1F*)passHist->Clone(name.c_str());
0547   //TGraphAsymmErrors *effHist = new TGraphAsymmErrors(numer,denom,"cl=0.683 b(1,1) mode");
0548   effHist->Divide(numer, denom, 1, 1, "B");
0549   //effHist->Divide(numer,denom,"cl=0.683 b(1,1) mode");
0550   //----Morse---------
0551   effHist->SetTitle(title.c_str());
0552   //------------------
0553   MonitorElement* eff = igetter.get(dirName_ + "/Client_Histos/" + filter + "/" + name);
0554   if (eff == nullptr) {
0555     eff = ibooker.book1D(name, effHist);
0556   } else {  //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
0557     *eff->getTH1F() = *effHist;
0558     //*eff->getTGraphAsymmErrors()=*effHist;
0559     delete effHist;
0560   }
0561   return eff;
0562 }
0563 
0564 EgHLTOfflineClient::MonitorElement* EgHLTOfflineClient::makeEffMonElem2Leg(const std::string& filter,
0565                                                                            const std::string& name,
0566                                                                            const std::string& title,
0567                                                                            const MonitorElement* Leg1Eff,
0568                                                                            const MonitorElement* Leg2NotLeg1Source,
0569                                                                            const MonitorElement* all,
0570                                                                            DQMStore::IBooker& ibooker,
0571                                                                            DQMStore::IGetter& igetter) {
0572   TH1F* allHist = all->getTH1F();
0573   if (allHist->GetSumw2() == nullptr)
0574     allHist->Sumw2();
0575   TH1F* Leg2NotLeg1SourceHist = Leg2NotLeg1Source->getTH1F();
0576   if (Leg2NotLeg1SourceHist->GetSumw2() == nullptr)
0577     Leg2NotLeg1SourceHist->Sumw2();
0578 
0579   auto* effHistLeg2NotLeg1 = (TH1F*)allHist->Clone(name.c_str());
0580   if (effHistLeg2NotLeg1->GetSumw2() == nullptr)
0581     effHistLeg2NotLeg1->Sumw2();
0582   effHistLeg2NotLeg1->Divide(Leg2NotLeg1SourceHist, allHist, 1, 1, "B");
0583 
0584   TH1F* Leg1EffHist = Leg1Eff->getTH1F();
0585   if (Leg1EffHist->GetSumw2() == nullptr)
0586     Leg1EffHist->Sumw2();
0587 
0588   auto* effHistTerm1 = (TH1F*)allHist->Clone(name.c_str());
0589   if (effHistTerm1->GetSumw2() == nullptr)
0590     effHistTerm1->Sumw2();
0591   effHistTerm1->Multiply(Leg1EffHist, Leg1EffHist, 1, 1, "B");
0592 
0593   auto* effHistTerm2 = (TH1F*)allHist->Clone(name.c_str());
0594   if (effHistTerm2->GetSumw2() == nullptr)
0595     effHistTerm2->Sumw2();
0596   effHistTerm2->Multiply(Leg1EffHist, effHistLeg2NotLeg1, 1, 1, "B");
0597   effHistTerm2->Scale(2);
0598 
0599   auto* effHist = (TH1F*)allHist->Clone(name.c_str());
0600   if (effHist->GetSumw2() == nullptr)
0601     effHist->Sumw2();
0602   effHist->Add(effHistTerm1, effHistTerm2, 1, 1);
0603   effHist->SetTitle(title.c_str());
0604 
0605   MonitorElement* eff = igetter.get(dirName_ + "/Client_Histos/" + filter + "/" + name);
0606   if (eff == nullptr) {
0607     eff = ibooker.book1D(name, effHist);
0608   } else {  //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
0609     *eff->getTH1F() = *effHist;
0610     delete effHist;
0611   }
0612   return eff;
0613 }
0614 
0615 //-----Morse-------
0616 EgHLTOfflineClient::MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndFail(const std::string& filterName,
0617                                                                                       const std::string& name,
0618                                                                                       const std::string& title,
0619                                                                                       const MonitorElement* pass,
0620                                                                                       const MonitorElement* fail,
0621                                                                                       DQMStore::IBooker& ibooker,
0622                                                                                       DQMStore::IGetter& igetter) {
0623   TH1F* failHist = fail->getTH1F();
0624   if (failHist->GetSumw2N() == 0)
0625     failHist->Sumw2();
0626   TH1F* passHist = pass->getTH1F();
0627   if (passHist->GetSumw2N() == 0)
0628     passHist->Sumw2();
0629 
0630   auto* effHist = (TH1F*)passHist->Clone(name.c_str());
0631   effHist->Add(failHist);
0632   effHist->Divide(passHist, effHist, 1, 1, "B");
0633   //----Morse---------
0634   effHist->SetTitle(title.c_str());
0635   //------------------
0636   MonitorElement* eff = igetter.get(dirName_ + "/Client_Histos/" + filterName + "/" + name);
0637   if (eff == nullptr) {
0638     eff = ibooker.book1D(name, effHist);
0639   } else {  //I was having problems with collating the histograms, hence why I'm just reseting the histogram value
0640     *eff->getTH1F() = *effHist;
0641     delete effHist;
0642   }
0643   return eff;
0644 }