CMS 3D CMS Logo

EgHLTOfflineClient.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Trigger/interface/EgHLTOfflineClient.h"
00002 
00003 #include "DQMOffline/Trigger/interface/EleHLTPathMon.h"
00004 #include "DQMOffline/Trigger/interface/EleHLTFilterMon.h"
00005 #include "DQMOffline/Trigger/interface/EgHLTOffData.h"
00006 
00007 
00008 #include "DataFormats/Common/interface/Handle.h"
00009 
00010 #include "DataFormats/HLTReco/interface/TriggerObject.h"
00011 #include "FWCore/Framework/interface/TriggerNames.h"
00012 #include "FWCore/Framework/interface/Run.h"
00013 
00014 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00015 #include "DataFormats/EgammaCandidates/interface/PhotonFwd.h"
00016 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00017 
00018 #include "PhysicsTools/Utilities/interface/deltaR.h"
00019 
00020 EgHLTOfflineClient::EgHLTOfflineClient(const edm::ParameterSet& iConfig)
00021 {
00022   dbe_ = edm::Service<DQMStore>().operator->();
00023   if (!dbe_) {
00024     edm::LogInfo("EgHLTOfflineClient") << "unable to get DQMStore service?";
00025   }
00026   if(iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
00027     dbe_->setVerbose(0);
00028   }
00029  
00030   eleHLTPathNames_ = iConfig.getParameter<std::vector<std::string> >("eleHLTPathNames");
00031   eleHLTFilterNames_ = iConfig.getParameter<std::vector<std::string> >("eleHLTFilterNames");
00032   eleHLTTightLooseFilters_ = iConfig.getParameter<std::vector<std::string> >("eleHLTTightLooseFilters");
00033   dirName_=iConfig.getParameter<std::string>("DQMDirName");//"HLT/EgHLTOfflineClient_" + iConfig.getParameter<std::string>("sourceModuleName");
00034 
00035   if(dbe_) dbe_->setCurrentFolder(dirName_);
00036  
00037 }
00038 
00039 
00040 EgHLTOfflineClient::~EgHLTOfflineClient()
00041 { 
00042   
00043 }
00044 
00045 void EgHLTOfflineClient::beginJob(const edm::EventSetup& iSetup)
00046 {
00047  
00048 
00049 }
00050 
00051 void EgHLTOfflineClient::endJob() 
00052 {
00053   LogDebug("EgHLTOfflineClient") << "ending job";
00054 }
00055 
00056 void EgHLTOfflineClient::beginRun(const edm::Run& run, const edm::EventSetup& c)
00057 {
00058   LogDebug("EgHLTOfflineClient") << "beginRun, run " << run.id();
00059 }
00060 
00061 
00062 void EgHLTOfflineClient::endRun(const edm::Run& run, const edm::EventSetup& c)
00063 {
00064   LogDebug("EgHLTOfflineClient") << "endRun, run " << run.id();
00065 }
00066 
00067 //dummy analysis function
00068 void EgHLTOfflineClient::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup)
00069 {
00070  
00071 }
00072 
00073 void EgHLTOfflineClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c)
00074 { 
00075   edm::LogInfo("EgHLTOfflineClient") << "end lumi block called";
00076   std::vector<std::string> regions;
00077   regions.push_back("eb");
00078   regions.push_back("ee");
00079   for(size_t pathNr=0;pathNr<eleHLTPathNames_.size();pathNr++){
00080     for(size_t filterNr=0;filterNr<eleHLTFilterNames_.size();filterNr++){
00081       for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00082         createTrigTagProbeEffHists(eleHLTPathNames_[pathNr]+eleHLTFilterNames_[filterNr],regions[regionNr]);
00083         createN1EffHists(eleHLTPathNames_[pathNr]+eleHLTFilterNames_[filterNr]+"_gsfEle_effVsEt_tagProbe",regions[regionNr]);
00084         createN1EffHists(eleHLTPathNames_[pathNr]+eleHLTFilterNames_[filterNr]+"_gsfEle_effVsEt",regions[regionNr]);
00085         createN1EffHists(eleHLTPathNames_[pathNr]+eleHLTFilterNames_[filterNr]+"_gsfEle_effVsEt_fakeRate",regions[regionNr]);
00086       }
00087     }
00088   }
00089 
00090   for(size_t filterNr=0;filterNr<eleHLTTightLooseFilters_.size();filterNr++){
00091     for(size_t regionNr=0;regionNr<regions.size();regionNr++){
00092       createLooseTightTrigEff(eleHLTTightLooseFilters_[filterNr],regions[regionNr]);
00093     }
00094   }
00095   
00096 }
00097 
00098 void EgHLTOfflineClient::createN1EffHists(const std::string& baseName,const std::string& region)
00099 { 
00100   std::vector<std::string> varNames;
00101   varNames.push_back("dEtaIn");
00102   varNames.push_back("dPhiIn");
00103   varNames.push_back("hOverE");
00104   varNames.push_back("sigmaEtaEta");
00105 
00106   MonitorElement* numer = dbe_->get(dirName_+"/"+baseName+"_allCuts_"+region);
00107   
00108   for(size_t varNr=0;varNr<varNames.size();varNr++){
00109     MonitorElement* denom = dbe_->get(dirName_+"/"+baseName+"_n1_"+varNames[varNr]+"_"+region);
00110     if(numer!=NULL && denom!=NULL){
00111       std::string effHistName(baseName+"_n1Eff_"+varNames[varNr]+"_"+region);
00112       makeEffMonElemFromPassAndAll(effHistName,numer,denom);   
00113     }
00114   }//end loop over varNames 
00115 }
00116 
00117 void EgHLTOfflineClient::createTrigTagProbeEffHists(const std::string& filterName,const std::string& region)
00118 {
00119   std::vector<std::string> vsVarNames;
00120   vsVarNames.push_back("et");
00121   vsVarNames.push_back("eta");
00122   vsVarNames.push_back("phi");
00123   vsVarNames.push_back("charge");
00124 
00125   for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00126     std::string allName(dirName_+"/"+filterName+"_trigTagProbe_all_"+vsVarNames[varNr]+"_"+region);
00127     MonitorElement* all = dbe_->get(allName); 
00128     if(all==NULL){
00129       edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<allName;
00130       continue;
00131     }
00132     std::string passName(dirName_+"/"+filterName+"_trigTagProbe_pass_"+vsVarNames[varNr]+"_"+region);
00133     MonitorElement* pass = dbe_->get(passName); 
00134     if(pass==NULL){
00135       edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<passName;
00136       continue;
00137     }
00138     
00139     makeEffMonElemFromPassAndAll(filterName+"_trigTagProbeEff_vs_"+vsVarNames[varNr]+"_"+region,pass,all);
00140   }//end loop over vsVarNames
00141 }
00142 
00143 MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndAll(const std::string& name,const MonitorElement* pass,const MonitorElement* all)
00144 {
00145   TH1F* passHist = pass->getTH1F();
00146   if(passHist->GetSumw2N()==0) passHist->Sumw2();
00147   TH1F* allHist = all->getTH1F();
00148   if(allHist->GetSumw2N()==0) allHist->Sumw2();
00149   TH1F* effHist = (TH1F*) passHist->Clone(name.c_str());
00150   effHist->Divide(passHist,allHist,1,1,"B");
00151   
00152   MonitorElement* eff = dbe_->get(dirName_+"/"+name);
00153   if(eff==NULL) eff= dbe_->book1D(name,effHist);
00154   else{ //I was having problems with collating the histograms, hence why I'm just reseting the histogram value
00155     *eff->getTH1F()=*effHist; 
00156     delete effHist;
00157   }
00158   return eff;
00159 }
00160 
00161 MonitorElement* EgHLTOfflineClient::makeEffMonElemFromPassAndFail(const std::string& name,const MonitorElement* pass,const MonitorElement* fail)
00162 {
00163   TH1F* failHist = fail->getTH1F();   
00164   if(failHist->GetSumw2N()==0) failHist->Sumw2();
00165   TH1F* passHist = pass->getTH1F();
00166   if(passHist->GetSumw2N()==0) passHist->Sumw2();
00167   
00168   TH1F* effHist = (TH1F*) passHist->Clone(name.c_str());
00169   effHist->Add(failHist);
00170   effHist->Divide(passHist,effHist,1,1,"B");
00171   
00172   MonitorElement* eff = dbe_->get(dirName_+"/"+name);
00173   if(eff==NULL) eff = dbe_->book1D(name,effHist);
00174   else{ //I was having problems with collating the histograms, hence why I'm just reseting the histogram value
00175     *eff->getTH1F()=*effHist; 
00176     delete effHist;
00177   }
00178   return eff;
00179 }
00180 
00181 void EgHLTOfflineClient::createLooseTightTrigEff(const std::string& filterName,const std::string& region)
00182 {
00183   std::vector<std::string> vsVarNames;
00184   vsVarNames.push_back("et");
00185   vsVarNames.push_back("eta");
00186   vsVarNames.push_back("charge");
00187 
00188   for(size_t varNr=0;varNr<vsVarNames.size();varNr++){
00189     MonitorElement* fail = dbe_->get(dirName_+"/"+filterName+"_passLooseTrig_failTightTrig_"+vsVarNames[varNr]+"_"+region); 
00190     if(fail==NULL){
00191       edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<dirName_+"/"+filterName+"_passLooseTrig_failTightTrig_"+vsVarNames[varNr]+"_"+region;
00192       continue;
00193     }
00194 
00195     MonitorElement* pass = dbe_->get(dirName_+"/"+filterName+"_passLooseTrig_passTightTrig_"+vsVarNames[varNr]+"_"+region); 
00196     if(pass==NULL){
00197       edm::LogInfo("EgHLTOfflineClient") <<" couldnt get hist "<<dirName_+"/"+filterName+"_passLooseTrig_passTightTrig_"+vsVarNames[varNr]+"_"+region;
00198       continue;
00199     } 
00200     const std::string newHistName(filterName+"_tightTrigEff_vs_"+vsVarNames[varNr]+"_"+region);
00201     makeEffMonElemFromPassAndFail(newHistName,pass,fail);
00202   } //end loop over vsVarNames
00203   
00204 }
00205   

Generated on Tue Jun 9 17:34:09 2009 for CMSSW by  doxygen 1.5.4