CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DQMOffline/Trigger/src/EgHLTOfflineClient.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Trigger/interface/EgHLTOfflineClient.h"
00002 
00003 
00004 #include "FWCore/Framework/interface/Run.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "FWCore/ServiceRegistry/interface/Service.h"
00008 
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 #include "DQMServices/Core/interface/MonitorElement.h"
00013 
00014 #include "DQMOffline/Trigger/interface/EgHLTTrigTools.h"
00015 
00016 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00017 
00018 #include <boost/algorithm/string.hpp>
00019 
00020 #include "TGraphAsymmErrors.h"
00021 
00022 EgHLTOfflineClient::EgHLTOfflineClient(const edm::ParameterSet& iConfig):dbe_(NULL),isSetup_(false)
00023 {
00024   dbe_ = edm::Service<DQMStore>().operator->(); //only one chance to get this, if we every have another shot, remember to check isSetup is okay
00025   if (!dbe_) {
00026     edm::LogError("EgHLTOfflineClient") << "unable to get DQMStore service, upshot is no client histograms will be made";
00027   }
00028   if(iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
00029     if(dbe_) dbe_->setVerbose(0);
00030   }
00031  
00032 
00033   eleHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames");
00034   eleHLTFilterNames2Leg_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames2Leg");
00035   eleTightLooseTrigNames_ = iConfig.getParameter<std::vector<std::string> >("eleTightLooseTrigNames");
00036   phoHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNames");
00037   phoHLTFilterNames2Leg_ = iConfig.getParameter<std::vector<std::string> >("phoHLTFilterNames2Leg");
00038   phoTightLooseTrigNames_ = iConfig.getParameter<std::vector<std::string> >("phoTightLooseTrigNames");
00039 
00040   eleN1EffVars_=iConfig.getParameter<std::vector<std::string> >("eleN1EffVars");
00041   eleSingleEffVars_ = iConfig.getParameter<std::vector<std::string> >("eleSingleEffVars");
00042   eleEffTags_ = iConfig.getParameter<std::vector<std::string> >("eleEffTags");
00043   eleTrigTPEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("eleTrigTPEffVsVars");
00044   eleLooseTightTrigEffVsVars_ =  iConfig.getParameter<std::vector<std::string> >("eleLooseTightTrigEffVsVars");
00045 
00046   phoN1EffVars_=iConfig.getParameter<std::vector<std::string> >("phoN1EffVars");
00047   phoSingleEffVars_ = iConfig.getParameter<std::vector<std::string> >("phoSingleEffVars");
00048   phoEffTags_ = iConfig.getParameter<std::vector<std::string> >("phoEffTags");
00049   phoTrigTPEffVsVars_ = iConfig.getParameter<std::vector<std::string> >("phoTrigTPEffVsVars");
00050   phoLooseTightTrigEffVsVars_ =  iConfig.getParameter<std::vector<std::string> >("phoLooseTightTrigEffVsVars");
00051   
00052   runClientEndLumiBlock_ = iConfig.getParameter<bool>("runClientEndLumiBlock");
00053   runClientEndRun_ = iConfig.getParameter<bool>("runClientEndRun");
00054   runClientEndJob_ = iConfig.getParameter<bool>("runClientEndJob");
00055 
00056   
00057 
00058   dirName_=iConfig.getParameter<std::string>("DQMDirName");
00059   if(dbe_) dbe_->setCurrentFolder(dirName_);
00060  
00061 
00062   filterInactiveTriggers_ =iConfig.getParameter<bool>("filterInactiveTriggers");
00063   hltTag_ = iConfig.getParameter<std::string>("hltTag");
00064  
00065 
00066 }
00067 
00068 
00069 EgHLTOfflineClient::~EgHLTOfflineClient()
00070 { 
00071   
00072 }
00073 
00074 void EgHLTOfflineClient::beginJob()
00075 {
00076   
00077 
00078 }
00079 
00080 void EgHLTOfflineClient::endJob() 
00081 {
00082   if(runClientEndJob_) runClient_();
00083 }
00084 
00085 void EgHLTOfflineClient::beginRun(const edm::Run& run, const edm::EventSetup& c)
00086 {
00087   if(!isSetup_){
00088     if(filterInactiveTriggers_){
00089       HLTConfigProvider hltConfig;
00090       bool changed=false;
00091       hltConfig.init(run,c,hltTag_,changed);
00092       std::vector<std::string> activeFilters;
00093       std::vector<std::string> activeEleFilters;
00094       std::vector<std::string> activeEle2LegFilters;
00095       std::vector<std::string> activePhoFilters;
00096       std::vector<std::string> activePho2LegFilters;
00097       egHLT::trigTools::getActiveFilters(hltConfig,activeFilters,activeEleFilters,activeEle2LegFilters,activePhoFilters,activePho2LegFilters);
00098       
00099       egHLT::trigTools::filterInactiveTriggers(eleHLTFilterNames_,activeFilters);
00100       egHLT::trigTools::filterInactiveTriggers(eleHLTFilterNames2Leg_,activeEle2LegFilters);
00101       egHLT::trigTools::filterInactiveTriggers(phoHLTFilterNames_,activePhoFilters);
00102       egHLT::trigTools::filterInactiveTightLooseTriggers(eleTightLooseTrigNames_,activeEleFilters);
00103       egHLT::trigTools::filterInactiveTightLooseTriggers(phoTightLooseTrigNames_,activePhoFilters);
00104     }
00105     isSetup_=true;
00106   }
00107 }
00108 
00109 
00110 void EgHLTOfflineClient::endRun(const edm::Run& run, const edm::EventSetup& c)
00111 {
00112   if(runClientEndRun_) runClient_();
00113 }
00114 
00115 //dummy analysis function
00116 void EgHLTOfflineClient::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup)
00117 {
00118   
00119 }
00120 
00121 void EgHLTOfflineClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c)
00122 { 
00123   if(runClientEndLumiBlock_)  runClient_();
00124 }
00125 
00126 void EgHLTOfflineClient::runClient_()
00127 {
00128   if(!dbe_) return; //we dont have the DQMStore so we cant do anything
00129   dbe_->setCurrentFolder(dirName_+"/Client_Histos");
00130  
00131 
00132   std::vector<std::string> regions;
00133   regions.push_back("eb");
00134   regions.push_back("ee");
00135 
00136   for(size_t filterNr=0;filterNr<eleHLTFilterNames_.size();filterNr++){
00137     //std::cout<<"FilterName: "<<eleHLTFilterNames_[filterNr]<<std::endl;
00138     for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00139       for(size_t effNr=0;effNr<eleEffTags_.size();effNr++){
00140         //----Morse----
00141         dbe_->setCurrentFolder(dirName_+"/Client_Histos/"+eleHLTFilterNames_[filterNr]);
00142         //--------------
00143         createN1EffHists(eleHLTFilterNames_[filterNr],eleHLTFilterNames_[filterNr]+"_gsfEle_"+eleEffTags_[effNr],regions[regionNr],eleN1EffVars_);
00144         createSingleEffHists(eleHLTFilterNames_[filterNr],eleHLTFilterNames_[filterNr]+"_gsfEle_"+eleEffTags_[effNr],regions[regionNr],eleSingleEffVars_);
00145         createTrigTagProbeEffHistsNewAlgo(eleHLTFilterNames_[filterNr],regions[regionNr],eleTrigTPEffVsVars_,"gsfEle");
00146       }
00147     }
00148   }
00149   for(size_t filterNr=0;filterNr<eleHLTFilterNames2Leg_.size();filterNr++){
00150     //std::cout<<"FilterName: "<<eleHLTFilterNames2Leg_[filterNr]<<std::endl;
00151     for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00152       for(size_t effNr=0;effNr<eleEffTags_.size();effNr++){
00153         std::string trigNameLeg1 = eleHLTFilterNames2Leg_[filterNr].substr(0,eleHLTFilterNames2Leg_[filterNr].find("::")); 
00154         std::string trigNameLeg2 = eleHLTFilterNames2Leg_[filterNr].substr(eleHLTFilterNames2Leg_[filterNr].find("::")+2);
00155         dbe_->setCurrentFolder(dirName_+"/Client_Histos/"+trigNameLeg2);
00156         createTrigTagProbeEffHists2Leg(trigNameLeg1,trigNameLeg2,regions[regionNr],eleTrigTPEffVsVars_,"gsfEle");
00157       }
00158     }
00159   }
00160   //------Morse
00161   //  dbe_->setCurrentFolder(dirName_);
00162   //--------------
00163   
00164   for(size_t filterNr=0;filterNr<phoHLTFilterNames_.size();filterNr++){
00165     for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00166       for(size_t effNr=0;effNr<phoEffTags_.size();effNr++){
00167         //----Morse----
00168         dbe_->setCurrentFolder(dirName_+"/Client_Histos/"+phoHLTFilterNames_[filterNr]);
00169         //createN1EffHists(eleHLTFilterNames_[filterNr]+"_pho_"+phoEffTags_[effNr],regions[regionNr],phoN1EffVars_);
00170         //createSingleEffHists(eleHLTFilterNames_[filterNr]+"_gsfEle_"+phoEffTags_[effNr],regions[regionNr],phoSingleEffVars_);
00171         createN1EffHists(phoHLTFilterNames_[filterNr],phoHLTFilterNames_[filterNr]+"_pho_"+phoEffTags_[effNr],regions[regionNr],phoN1EffVars_);
00172         createSingleEffHists(phoHLTFilterNames_[filterNr],phoHLTFilterNames_[filterNr]+"_pho_"+phoEffTags_[effNr],regions[regionNr],phoSingleEffVars_);
00173         createTrigTagProbeEffHistsNewAlgo(phoHLTFilterNames_[filterNr],regions[regionNr],phoTrigTPEffVsVars_,"pho");
00174         //--------------
00175       }
00176     }
00177   }
00178   //------Morse
00179   //  dbe_->setCurrentFolder(dirName_);
00180   //--------------
00181   for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00182     createLooseTightTrigEff(eleTightLooseTrigNames_,regions[regionNr],eleLooseTightTrigEffVsVars_,"gsfEle");   
00183     createLooseTightTrigEff(eleTightLooseTrigNames_,regions[regionNr],eleLooseTightTrigEffVsVars_,"gsfEle_trigCuts");
00184     createLooseTightTrigEff(phoTightLooseTrigNames_,regions[regionNr],phoLooseTightTrigEffVsVars_,"pho"); 
00185     createLooseTightTrigEff(phoTightLooseTrigNames_,regions[regionNr],phoLooseTightTrigEffVsVars_,"pho_trigCuts");
00186   }
00187   //----Morse-----
00188   dbe_->setCurrentFolder(dirName_);
00189   //----------
00190 }
00191 
00192 void EgHLTOfflineClient::createN1EffHists(const std::string& filterName,const std::string& baseName,const std::string& region,const std::vector<std::string>& varNames)
00193 { 
00194   MonitorElement* numer = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_allCuts_"+region);
00195   
00196   for(size_t varNr=0;varNr<varNames.size();varNr++){
00197     MonitorElement* denom = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_n1_"+varNames[varNr]+"_"+region);
00198     if(numer!=NULL && denom!=NULL){
00199       std::string effHistName(baseName+"_n1Eff_"+varNames[varNr]+"_"+region);//std::cout<<"N1:  "<<effHistName<<std::endl;
00200       //std::cout<<region<<"  ";
00201       //----Morse-----------
00202       std::string effHistTitle(effHistName);//std::cout<<effHistTitle<<std::endl;
00203       if(region=="eb" || region=="ee"){
00204         if(region=="eb") effHistTitle = "Barrel "+baseName+" N1eff "+varNames[varNr];
00205         if(region=="ee") effHistTitle = "Endcap "+baseName+" N1eff "+varNames[varNr];
00206       }//std::cout<<effHistTitle<<std::endl;
00207       //makeEffMonElemFromPassAndAll(effHistName,numer,denom);
00208       makeEffMonElemFromPassAndAll(filterName,effHistName,effHistTitle,numer,denom);
00209       //---------------------
00210     }
00211   }//end loop over varNames 
00212 }
00213 
00214 void EgHLTOfflineClient::createSingleEffHists(const std::string& filterName,const std::string& baseName,const std::string& region,const std::vector<std::string>& varNames)
00215 { 
00216   MonitorElement* denom = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_noCuts_"+region);
00217   
00218   for(size_t varNr=0;varNr<varNames.size();varNr++){
00219     MonitorElement* numer = dbe_->get(dirName_+"/Source_Histos/"+filterName+"/"+baseName+"_single_"+varNames[varNr]+"_"+region);
00220     if(numer!=NULL && denom!=NULL){
00221       std::string effHistName(baseName+"_singleEff_"+varNames[varNr]+"_"+region);//std::cout<<"Si:  "<<effHistName<<std::endl;
00222       //----Morse-----------
00223       std::string effHistTitle(effHistName);//std::cout<<effHistTitle<<std::endl;
00224       if(region=="eb" || region=="ee"){
00225         if(region=="eb") effHistTitle = "Barrel "+baseName+" SingleEff "+varNames[varNr];
00226         if(region=="ee") effHistTitle = "Endcap "+baseName+" SingleEff "+varNames[varNr];
00227       }//std::cout<<effHistTitle<<std::endl;
00228       //makeEffMonElemFromPassAndAll(effHistName,numer,denom);   
00229       makeEffMonElemFromPassAndAll(filterName,effHistName,effHistTitle,numer,denom);   
00230       //--------------------
00231     }
00232   }//end loop over varNames 
00233 }
00234 
00235 void EgHLTOfflineClient::createTrigTagProbeEffHists(const std::string& filterName,const std::string& region,const std::vector<std::string>& vsVarNames,const std::string& objName)
00236 {
00237   for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00238     std::string allName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_all_"+vsVarNames[varNr]+"_"+region);
00239     MonitorElement* all = dbe_->get(allName); 
00240     if(all==NULL){
00241       //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<allName;
00242       continue;
00243     }
00244     std::string passName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_pass_"+vsVarNames[varNr]+"_"+region);
00245     MonitorElement* pass = dbe_->get(passName); 
00246     if(pass==NULL){
00247       //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<passName;
00248       continue;
00249     }
00250     //----Morse-----
00251     std::string effHistTitle(filterName+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);//std::cout<<effHistTitle<<std::endl;
00252     if(region=="eb" || region=="ee"){
00253       if(region=="eb") effHistTitle = "Barrel "+filterName+"_"+objName+" TrigTagProbeEff vs "+vsVarNames[varNr];
00254       if(region=="ee") effHistTitle = "Endcap "+filterName+"_"+objName+" TrigTagProbeEff vs "+vsVarNames[varNr];
00255     }//std::cout<<effHistTitle<<std::endl;
00256     //------------
00257     makeEffMonElemFromPassAndAll(filterName,filterName+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region,effHistTitle,pass,all);
00258   }//end loop over vsVarNames
00259 }
00260 
00261 void EgHLTOfflineClient::createTrigTagProbeEffHistsNewAlgo(const std::string& filterName,const std::string& region,const std::vector<std::string>& vsVarNames,const std::string& objName)
00262 {
00263   for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00264     /* 
00265        std::string allName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_all_"+vsVarNames[varNr]+"_"+region);
00266        MonitorElement* all = dbe_->get(allName); 
00267        if(all==NULL){
00268        //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<allName;
00269        continue;
00270        }*/
00271     std::string passName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_passNotTag_"+vsVarNames[varNr]+"_"+region);
00272     MonitorElement* passNotTag = dbe_->get(passName); 
00273     if(passNotTag==NULL){
00274       //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<passName;
00275       continue;
00276     }
00277     std::string passTagTagName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_passTagTag_"+vsVarNames[varNr]+"_"+region);
00278     MonitorElement* passTagTag = dbe_->get(passTagTagName); 
00279     if(passTagTag==NULL){
00280       //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<passTagTagName;
00281       continue;
00282     }
00283     std::string failName(dirName_+"/Source_Histos/"+filterName+"/"+filterName+"_trigTagProbe_"+objName+"_fail_"+vsVarNames[varNr]+"_"+region);
00284     MonitorElement* fail = dbe_->get(failName); 
00285     if(fail==NULL){
00286       //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<failName;
00287       continue;
00288     }
00289     //----Morse-----
00290     std::string effHistTitle(filterName+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);//std::cout<<effHistTitle<<std::endl;
00291     if(region=="eb" || region=="ee"){
00292       if(region=="eb") effHistTitle = "Barrel "+filterName+"_"+objName+" TrigTagProbeEff vs "+vsVarNames[varNr];
00293       if(region=="ee") effHistTitle = "Endcap "+filterName+"_"+objName+" TrigTagProbeEff vs "+vsVarNames[varNr];
00294     }//std::cout<<effHistTitle<<std::endl;
00295     //------------
00296     makeEffMonElemFromPassAndFailAndTagTag(filterName,filterName+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region,effHistTitle,passNotTag,fail,passTagTag);
00297   }//end loop over vsVarNames
00298 }
00299 
00300 void EgHLTOfflineClient::createTrigTagProbeEffHists2Leg(const std::string& filterNameLeg1,const std::string& filterNameLeg2,const std::string& region,const std::vector<std::string>& vsVarNames,const std::string& objName)
00301 {
00302   for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00303     
00304     std::string allName(dirName_+"/Source_Histos/"+filterNameLeg2+"/"+filterNameLeg2+"_trigTagProbe_"+objName+"_all_"+vsVarNames[varNr]+"_"+region);
00305     MonitorElement* all = dbe_->get(allName); 
00306     if(all==NULL){
00307       edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<allName;
00308       continue;
00309     }
00310     std::string Leg2NotLeg1SourceName(dirName_+"/Source_Histos/"+filterNameLeg2+"/"+filterNameLeg2+"_trigTagProbe_"+objName+"_passLeg2failLeg1_"+vsVarNames[varNr]+"_"+region);
00311     MonitorElement* Leg2NotLeg1Source = dbe_->get(Leg2NotLeg1SourceName); 
00312     if(Leg2NotLeg1Source==NULL){
00313       edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<Leg2NotLeg1SourceName;
00314       continue;
00315     }
00316 
00317     std::string Leg1EffName(dirName_+"/Client_Histos/"+filterNameLeg1+"/"+filterNameLeg1+"_trigTagProbeEff_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);
00318     MonitorElement *Leg1Eff = dbe_->get(Leg1EffName);
00319     if(Leg1Eff==NULL){
00320       edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<Leg1EffName;
00321       continue;
00322     }
00323     std::string effHistTitle(filterNameLeg2+"_trigTagProbeEff2Leg_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);//std::cout<<effHistTitle<<std::endl;
00324     if(region=="eb" || region=="ee"){
00325       if(region=="eb") effHistTitle = "Barrel "+filterNameLeg2+"_"+objName+" TrigTagProbeEff2Leg vs "+vsVarNames[varNr];
00326       if(region=="ee") effHistTitle = "Endcap "+filterNameLeg2+"_"+objName+" TrigTagProbeEff2Leg vs "+vsVarNames[varNr];
00327     }//std::cout<<effHistTitle<<std::endl;
00328     makeEffMonElem2Leg(filterNameLeg2,filterNameLeg2+"_trigTagProbeEff2Leg_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region,effHistTitle,Leg1Eff,Leg2NotLeg1Source,all);
00329   }//end loop over vsVarNames
00330 }
00331 
00332 
00333 void EgHLTOfflineClient::createLooseTightTrigEff(const std::vector<std::string>&  tightLooseTrigNames,const std::string& region,const std::vector<std::string>& vsVarNames,const std::string& objName)
00334 {
00335   for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00336     for(size_t trigNr=0;trigNr<tightLooseTrigNames.size();trigNr++){
00337       std::vector<std::string> splitString;
00338       boost::split(splitString,tightLooseTrigNames[trigNr],boost::is_any_of(std::string(":")));
00339       if(splitString.size()!=2) continue; //format incorrect
00340       const std::string& tightTrig = splitString[0];
00341       const std::string& looseTrig = splitString[1];
00342       MonitorElement* fail = dbe_->get(dirName_+"/Source_Histos/"+tightTrig+"_"+looseTrig+"_"+objName+"_failTrig_"+vsVarNames[varNr]+"_"+region); 
00343       if(fail==NULL){
00344         //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<dirName_+"/"+tightTrig+"_"+looseTrig+"_"+objName+"_failTrig_"+vsVarNames[varNr]+"_"+region;
00345 
00346         continue;
00347       }
00348 
00349       MonitorElement* pass = dbe_->get(dirName_+"/Source_Histos/"+tightTrig+"_"+looseTrig+"_"+objName+"_passTrig_"+vsVarNames[varNr]+"_"+region); 
00350       if(pass==NULL){
00351 
00352         //edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<dirName_+"/"+tightTrig+"_"+looseTrig+"_"+objName+"_passTrig_"+vsVarNames[varNr]+"_"+region;
00353         continue;
00354       } 
00355       const std::string newHistName(tightTrig+"_trigEffTo_"+looseTrig+"_"+objName+"_vs_"+vsVarNames[varNr]+"_"+region);
00356       //----Morse-----
00357       std::string effHistTitle(newHistName);//std::cout<<effHistTitle<<std::endl;
00358       if(region=="eb" || region=="ee"){
00359         if(region=="eb") effHistTitle = "Barrel "+tightTrig+"_TrigEffTo_"+looseTrig+"_"+objName+" vs "+vsVarNames[varNr];
00360         if(region=="ee") effHistTitle = "Endcap "+tightTrig+"_TrigEffTo_"+looseTrig+"_"+objName+" vs "+vsVarNames[varNr];
00361       }
00362       //std::cout<<effHistTitle<<std::endl;
00363       //dbe_->setCurrentFolder(dirName_+"/"+tightTrig+"_"+looseTrig);
00364       //------------
00365       makeEffMonElemFromPassAndFail("LooseTight",newHistName,effHistTitle,pass,fail);
00366     }//end loop over trigger pairs
00367   } //end loop over vsVarNames
00368   
00369 }
00370 //-----Morse-------
00371 //MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndAll(const std::string& name,const MonitorElement* pass,const MonitorElement* all)
00372 MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndAll(const std::string& filterName,const std::string& name,const std::string& title,const MonitorElement* pass,const MonitorElement* all)
00373 //-----------------
00374 {
00375   TH1F* passHist = pass->getTH1F();
00376   if(passHist->GetSumw2N()==0) passHist->Sumw2();
00377   TH1F* allHist = all->getTH1F();
00378   if(allHist->GetSumw2N()==0) allHist->Sumw2();
00379   TH1F* effHist = (TH1F*) passHist->Clone(name.c_str());
00380   effHist->Divide(passHist,allHist,1,1,"B");
00381   //----Morse---------
00382   effHist->SetTitle(title.c_str());
00383   //------------------
00384   MonitorElement* eff = dbe_->get(dirName_+"/Client_Histos/"+filterName+"/"+name);
00385   if(eff==NULL) eff= dbe_->book1D(name,effHist);
00386   else{ //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
00387     *eff->getTH1F()=*effHist; 
00388     delete effHist;
00389   }
00390   return eff;
00391 }
00392 
00393 MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndFailAndTagTag(const std::string& filter,const std::string& name,const std::string& title,const MonitorElement* passNotTag,const MonitorElement* fail, const MonitorElement* tagtag)
00394 //-----------------
00395 {
00396   TH1F* passHist = passNotTag->getTH1F();
00397   if(passHist->GetSumw2N()==0) passHist->Sumw2();
00398   TH1F* failHist = fail->getTH1F();
00399   if(failHist->GetSumw2N()==0) failHist->Sumw2();
00400   TH1F* tagtagHist = tagtag->getTH1F();
00401   if(tagtagHist->GetSumw2N()==0) tagtagHist->Sumw2();
00402   TH1F* numer = (TH1F*) passHist->Clone(name.c_str());if(numer->GetSumw2N()==0) numer->Sumw2();
00403   numer->Add(tagtagHist,passHist,2,1);
00404   TH1F* denom = (TH1F*) passHist->Clone(name.c_str());if(denom->GetSumw2N()==0) denom->Sumw2();
00405   denom->Add(tagtagHist,passHist,2,1);
00406   denom->Add(failHist,1);
00407   TH1F* effHist = (TH1F*) passHist->Clone(name.c_str());
00408   //TGraphAsymmErrors *effHist = new TGraphAsymmErrors(numer,denom,"cl=0.683 b(1,1) mode");
00409   effHist->Divide(numer,denom,1,1,"B");
00410   //effHist->Divide(numer,denom,"cl=0.683 b(1,1) mode");
00411   //----Morse---------
00412   effHist->SetTitle(title.c_str());
00413   //------------------
00414   MonitorElement* eff = dbe_->get(dirName_+"/Client_Histos/"+filter+"/"+name);
00415   if(eff==NULL) eff= dbe_->book1D(name,effHist);
00416   //if(eff==NULL) eff = dbe_->bookGraphAsymmErrors(name,effHist);
00417   else{ //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
00418     *eff->getTH1F()=*effHist; 
00419     //*eff->getTGraphAsymmErrors()=*effHist;
00420     delete effHist;
00421   }
00422   return eff;
00423 }
00424 MonitorElement* EgHLTOfflineClient::makeEffMonElem2Leg(const std::string& filter,const std::string& name,const std::string& title,const MonitorElement* Leg1Eff,const MonitorElement* Leg2NotLeg1Source,const MonitorElement* all)
00425 {
00426   TH1F* allHist = all->getTH1F();
00427   if(allHist->GetSumw2()==0)allHist->Sumw2();
00428   TH1F* Leg2NotLeg1SourceHist = Leg2NotLeg1Source->getTH1F();
00429   if(Leg2NotLeg1SourceHist->GetSumw2()==0)Leg2NotLeg1SourceHist->Sumw2();
00430 
00431   TH1F* effHistLeg2NotLeg1 = (TH1F*)allHist->Clone(name.c_str());
00432   if(effHistLeg2NotLeg1->GetSumw2()==0)effHistLeg2NotLeg1->Sumw2();
00433   effHistLeg2NotLeg1->Divide(Leg2NotLeg1SourceHist, allHist, 1, 1, "B");
00434   
00435   TH1F* Leg1EffHist = Leg1Eff->getTH1F();
00436   if(Leg1EffHist->GetSumw2()==0)Leg1EffHist->Sumw2();
00437 
00438   TH1F* effHistTerm1 = (TH1F*)allHist->Clone(name.c_str());
00439   if(effHistTerm1->GetSumw2()==0)effHistTerm1->Sumw2();
00440   effHistTerm1->Multiply(Leg1EffHist, Leg1EffHist, 1, 1, "B");
00441 
00442   TH1F* effHistTerm2 = (TH1F*)allHist->Clone(name.c_str());
00443   if(effHistTerm2->GetSumw2()==0)effHistTerm2->Sumw2();
00444   effHistTerm2->Multiply(Leg1EffHist, effHistLeg2NotLeg1, 1, 1, "B");
00445   effHistTerm2->Scale(2);
00446 
00447   TH1F* effHist = (TH1F*)allHist->Clone(name.c_str());
00448   if(effHist->GetSumw2()==0)effHist->Sumw2();
00449   effHist->Add(effHistTerm1, effHistTerm2, 1, 1);
00450   effHist->SetTitle(title.c_str());
00451   
00452   MonitorElement* eff = dbe_->get(dirName_+"/Client_Histos/"+filter+"/"+name);
00453   if(eff==NULL) eff= dbe_->book1D(name,effHist);
00454   else{ //I was having problems with collating the histograms, hence why I'm just resetting the histogram value
00455     *eff->getTH1F()=*effHist; 
00456     delete effHist;
00457   }
00458   return eff;
00459 }
00460 
00461 //-----Morse-------
00462 //MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndFail(const std::string& name,const MonitorElement* pass,const MonitorElement* fail)
00463 MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndFail(const std::string& filterName,const std::string& name,const std::string& title,const MonitorElement* pass,const MonitorElement* fail)
00464 //-------------
00465 {
00466   TH1F* failHist = fail->getTH1F();   
00467   if(failHist->GetSumw2N()==0) failHist->Sumw2();
00468   TH1F* passHist = pass->getTH1F();
00469   if(passHist->GetSumw2N()==0) passHist->Sumw2();
00470   
00471   TH1F* effHist = (TH1F*) passHist->Clone(name.c_str());
00472   effHist->Add(failHist);
00473   effHist->Divide(passHist,effHist,1,1,"B");
00474   //----Morse---------
00475   effHist->SetTitle(title.c_str());
00476   //------------------  
00477   MonitorElement* eff = dbe_->get(dirName_+"/Client_Histos/"+filterName+"/"+name);
00478   if(eff==NULL) eff = dbe_->book1D(name,effHist);
00479   else{ //I was having problems with collating the histograms, hence why I'm just reseting the histogram value
00480     *eff->getTH1F()=*effHist; 
00481     delete effHist;
00482   }
00483   return eff;
00484 }