CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQMOffline/Trigger/src/JetMETHLTOfflineClient.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Trigger/interface/JetMETHLTOfflineClient.h"
00002 
00003 #include "FWCore/Framework/interface/Run.h"
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00006 #include "FWCore/ServiceRegistry/interface/Service.h"
00007 
00008 #include "DQMServices/Core/interface/DQMStore.h"
00009 #include "DQMServices/Core/interface/MonitorElement.h"
00010 
00011 JetMETHLTOfflineClient::JetMETHLTOfflineClient(const edm::ParameterSet& iConfig):conf_(iConfig)
00012 {
00013   dbe_ = edm::Service<DQMStore>().operator->();
00014   if (!dbe_) {
00015     edm::LogError("JetMETHLTOfflineClient") << "unable to get DQMStore service, upshot is no client histograms will be made";
00016   }
00017   if(iConfig.getUntrackedParameter<bool>("DQMStore", false)) {
00018     if(dbe_) dbe_->setVerbose(0);
00019   }
00020  
00021   debug_ = false;
00022   verbose_ = false;
00023 
00024   processname_ = iConfig.getParameter<std::string>("processname");
00025 
00026   hltTag_ = iConfig.getParameter<std::string>("hltTag");
00027   if (debug_) std::cout << hltTag_ << std::endl;
00028   
00029   dirName_=iConfig.getParameter<std::string>("DQMDirName");
00030   if(dbe_) dbe_->setCurrentFolder(dirName_);
00031  
00032 }
00033 
00034 
00035 JetMETHLTOfflineClient::~JetMETHLTOfflineClient()
00036 { 
00037   
00038 }
00039 
00040 void JetMETHLTOfflineClient::beginJob()
00041 {
00042  
00043 
00044 }
00045 
00046 void JetMETHLTOfflineClient::endJob() 
00047 {
00048 
00049 }
00050 
00051 void JetMETHLTOfflineClient::beginRun(const edm::Run& run, const edm::EventSetup& c)
00052 {
00053  
00054 }
00055 
00056 
00057 void JetMETHLTOfflineClient::endRun(const edm::Run& run, const edm::EventSetup& c)
00058 {
00059   runClient_();
00060 }
00061 
00062 //dummy analysis function
00063 void JetMETHLTOfflineClient::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup)
00064 {
00065   
00066 }
00067 
00068 void JetMETHLTOfflineClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c)
00069 { 
00070   runClient_();
00071 }
00072 
00073 void JetMETHLTOfflineClient::runClient_()
00074 {
00075   if(!dbe_) return; //we dont have the DQMStore so we cant do anything
00076   dbe_->setCurrentFolder(dirName_);
00077 
00078   LogDebug("JetMETHLTOfflineClient") << "runClient" << std::endl;
00079   if (debug_) std::cout << "runClient" << std::endl; 
00080 
00081   std::vector<MonitorElement*> hltMEs;
00082 
00083   // Look at all folders, go to the subfolder which includes the string "Eff"
00084   std::vector<std::string> fullPathHLTFolders = dbe_->getSubdirs();
00085   for(unsigned int i=0;i<fullPathHLTFolders.size();i++) {
00086 
00087     // Move on only if the folder name contains "Eff" Or "Trigger Summary"
00088     if (debug_) std::cout << fullPathHLTFolders[i] << std::endl;
00089     if ((fullPathHLTFolders[i].find("Eff")!=std::string::npos)) {
00090       dbe_->setCurrentFolder(fullPathHLTFolders[i]);
00091        } else {
00092       continue;
00093     }
00094 
00095     // Look at all subfolders, go to the subfolder which includes the string "Eff"
00096     std::vector<std::string> fullSubPathHLTFolders = dbe_->getSubdirs();
00097     for(unsigned int j=0;j<fullSubPathHLTFolders.size();j++) {
00098 
00099       if (debug_) std::cout << fullSubPathHLTFolders[j] << std::endl;      
00100       dbe_->setCurrentFolder(fullSubPathHLTFolders[j]);
00101     
00102       // Look at all MonitorElements in this folder
00103       hltMEs = dbe_->getContents(fullSubPathHLTFolders[j]);
00104       LogDebug("JetMETHLTOfflineClient")<< "Number of MEs for this HLT path = " << hltMEs.size() << std::endl;
00105       
00106       for(unsigned int k=0;k<hltMEs.size();k++) {
00107         if (debug_) std::cout << hltMEs[k]->getName() << std::endl;
00108 
00109         //-----
00110         if ((hltMEs[k]->getName().find("ME_Numerator")!=std::string::npos) && hltMEs[k]->getName().find("ME_Numerator")==0){
00111 
00112           std::string name = hltMEs[k]->getName();
00113           name.erase(0,12); // Removed "ME_Numerator"
00114           if (debug_) std::cout <<"==name=="<< name << std::endl;
00115 //        if( name.find("EtaPhi") !=std::string::npos ) continue; // do not consider EtaPhi 2D plots
00116 
00117 //        MonitorElement* eff ;
00118 
00119           for(unsigned int l=0;l<hltMEs.size();l++) {
00120             if (hltMEs[l]->getName() == "ME_Denominator"+name){
00121               // found denominator too
00122               if(name.find("EtaPhi") !=std::string::npos) 
00123               {
00124               MonitorElement* eff ;   
00125               TH2F* tNumerator   = hltMEs[k]->getTH2F();
00126               TH2F* tDenominator = hltMEs[l]->getTH2F();
00127 
00128               std::string title = "Eff_"+hltMEs[k]->getTitle();
00129                 
00130               TH2F *teff = (TH2F*) tNumerator->Clone(title.c_str());
00131               teff->Divide(tNumerator,tDenominator,1,1);
00132               eff= dbe_->book2D("ME_Eff_"+name,teff);
00133               delete teff;                      
00134               }else{
00135               MonitorElement* eff ;
00136               TH1F* tNumerator   = hltMEs[k]->getTH1F();
00137               TH1F* tDenominator = hltMEs[l]->getTH1F();
00138 
00139               std::string title = "Eff_"+hltMEs[k]->getTitle();
00140 
00141               TH1F *teff = (TH1F*) tNumerator->Clone(title.c_str());
00142               teff->Divide(tNumerator,tDenominator,1,1);
00143               eff= dbe_->book1D("ME_Eff_"+name,teff);
00144               delete teff;
00145              }
00146             } // Denominator
00147           }   // Loop-l
00148         }     // Numerator
00149 
00150         
00151       }       // Loop-k
00152     }         // fullSubPath
00153   }           // fullPath
00154 }
00155