CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DQM/L1TMonitorClient/src/L1TGCTClient.cc

Go to the documentation of this file.
00001 #include "DQM/L1TMonitorClient/interface/L1TGCTClient.h"
00002 
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "DQMServices/Core/interface/QReport.h"
00009 #include "DQMServices/Core/interface/DQMStore.h"
00010 #include "DQMServices/Core/interface/MonitorElement.h"
00011 
00012 using namespace edm;
00013 using namespace std;
00014 
00015 // Define statics for bins etc.
00016 const unsigned int ETABINS = 22;
00017 const float ETAMIN = -0.5;
00018 const float ETAMAX = 21.5;
00019 
00020 const unsigned int PHIBINS = 18;
00021 const float PHIMIN = -0.5;
00022 const float PHIMAX = 17.5;
00023 
00024 L1TGCTClient::L1TGCTClient(const edm::ParameterSet& ps):
00025   monitorDir_(ps.getUntrackedParameter<string>("monitorDir","")),
00026   counterLS_(0), 
00027   counterEvt_(0), 
00028   prescaleLS_(ps.getUntrackedParameter<int>("prescaleLS", -1)),
00029   prescaleEvt_(ps.getUntrackedParameter<int>("prescaleEvt", -1)),
00030   m_runInEventLoop(ps.getUntrackedParameter<bool>("runInEventLoop", false)),
00031   m_runInEndLumi(ps.getUntrackedParameter<bool>("runInEndLumi", false)),
00032   m_runInEndRun(ps.getUntrackedParameter<bool>("runInEndRun", false)),
00033   m_runInEndJob(ps.getUntrackedParameter<bool>("runInEndJob", false))
00034 
00035 {
00036 }
00037 
00038 L1TGCTClient::~L1TGCTClient(){}
00039 
00040 void L1TGCTClient::beginJob(void)
00041 {
00042   // Get backendinterface  
00043   dbe_ = Service<DQMStore>().operator->();
00044 
00045   // Set to directory with ME in
00046   dbe_->setCurrentFolder(monitorDir_);
00047   
00048   l1GctIsoEmOccEta_ = dbe_->book1D("IsoEmOccEta","ISO EM  #eta OCCUPANCY", ETABINS, ETAMIN, ETAMAX);
00049   l1GctIsoEmOccPhi_ = dbe_->book1D("IsoEmOccPhi","ISO EM  #phi OCCUPANCY", PHIBINS, PHIMIN, PHIMAX);
00050   l1GctNonIsoEmOccEta_ = dbe_->book1D("NonIsoEmOccEta","NON-ISO EM  #eta OCCUPANCY", ETABINS, ETAMIN, ETAMAX);
00051   l1GctNonIsoEmOccPhi_ = dbe_->book1D("NonIsoEmOccPhi","NON-ISO EM  #phi OCCUPANCY", PHIBINS, PHIMIN, PHIMAX);
00052   l1GctAllJetsOccEta_ = dbe_->book1D("AllJetsOccEta","CENTRAL AND FORWARD JET  #eta OCCUPANCY", ETABINS, ETAMIN, ETAMAX);
00053   l1GctAllJetsOccPhi_ = dbe_->book1D("AllJetsOccPhi","CENTRAL AND FORWARD JET  #phi OCCUPANCY", PHIBINS, PHIMIN, PHIMAX);
00054   l1GctCenJetsOccEta_ = dbe_->book1D("CenJetsOccEta","CENTRAL JET  #eta OCCUPANCY", ETABINS, ETAMIN, ETAMAX);
00055   l1GctCenJetsOccPhi_ = dbe_->book1D("CenJetsOccPhi","CENTRAL JET  #phi OCCUPANCY", PHIBINS, PHIMIN, PHIMAX);
00056   l1GctForJetsOccEta_ = dbe_->book1D("ForJetsOccEta","FORWARD JET  #eta OCCUPANCY", ETABINS, ETAMIN, ETAMAX);
00057   l1GctForJetsOccPhi_ = dbe_->book1D("ForJetsOccPhi","FORWARD JET  #phi OCCUPANCY", PHIBINS, PHIMIN, PHIMAX);
00058   l1GctTauJetsOccEta_ = dbe_->book1D("TauJetsOccEta","TAU JET  #eta OCCUPANCY", ETABINS, ETAMIN, ETAMAX);
00059   l1GctTauJetsOccPhi_ = dbe_->book1D("TauJetsOccPhi","TAU JET  #phi OCCUPANCY", PHIBINS, PHIMIN, PHIMAX);
00060 }
00061 
00062 void L1TGCTClient::beginRun(const Run& r, const EventSetup& context) {}
00063 
00064 void L1TGCTClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {}
00065 
00066 void L1TGCTClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c) 
00067 {
00068 
00069     if (m_runInEndLumi) {
00070 
00071         processHistograms();
00072     }
00073 
00074 }
00075 
00076 void L1TGCTClient::analyze(const Event& e, const EventSetup& context){
00077 
00078     // there is no loop on events in the offline harvesting step
00079     // code here will not be executed offline
00080 
00081     if (m_runInEventLoop) {
00082 
00083         processHistograms();
00084     }
00085 
00086 }
00087 
00088 void L1TGCTClient::endRun(const Run& r, const EventSetup& context) {
00089 
00090     if (m_runInEndRun) {
00091 
00092         processHistograms();
00093     }
00094 
00095 }
00096 
00097 void L1TGCTClient::endJob() {
00098 
00099     if (m_runInEndJob) {
00100 
00101         processHistograms();
00102     }
00103 }
00104 
00105 void L1TGCTClient::processHistograms() {
00106 
00107     MonitorElement* Input;
00108 
00109     Input = dbe_->get("L1T/L1TGCT/IsoEmOccEtaPhi");
00110     if (Input!=NULL){
00111       makeXProjection(Input->getTH2F(),l1GctIsoEmOccEta_);
00112       makeYProjection(Input->getTH2F(),l1GctIsoEmOccPhi_);
00113     }
00114 
00115     Input = dbe_->get("L1T/L1TGCT/NonIsoEmOccEtaPhi");
00116     if (Input!=NULL){
00117       makeXProjection(Input->getTH2F(),l1GctNonIsoEmOccEta_);
00118       makeYProjection(Input->getTH2F(),l1GctNonIsoEmOccPhi_);
00119     }
00120 
00121     Input = dbe_->get("L1T/L1TGCT/AllJetsOccEtaPhi");
00122     if (Input!=NULL){
00123       makeXProjection(Input->getTH2F(),l1GctAllJetsOccEta_);
00124       makeYProjection(Input->getTH2F(),l1GctAllJetsOccPhi_);
00125     }
00126 
00127     Input = dbe_->get("L1T/L1TGCT/CenJetsOccEtaPhi");
00128     if (Input!=NULL){
00129       makeXProjection(Input->getTH2F(),l1GctCenJetsOccEta_);
00130       makeYProjection(Input->getTH2F(),l1GctCenJetsOccPhi_);
00131     }
00132 
00133     Input = dbe_->get("L1T/L1TGCT/ForJetsOccEtaPhi");
00134     if (Input!=NULL){
00135       makeXProjection(Input->getTH2F(),l1GctForJetsOccEta_);
00136       makeYProjection(Input->getTH2F(),l1GctForJetsOccPhi_);
00137     }
00138 
00139     Input = dbe_->get("L1T/L1TGCT/TauJetsOccEtaPhi");
00140     if (Input!=NULL){
00141       makeXProjection(Input->getTH2F(),l1GctTauJetsOccEta_);
00142       makeYProjection(Input->getTH2F(),l1GctTauJetsOccPhi_);
00143     }
00144 
00145 }
00146 
00147 
00148 void L1TGCTClient::makeXProjection(TH2F* input, MonitorElement* output)
00149 {
00150   // Are the provided input and output consistent
00151   if (input->GetNbinsX() != output->getNbinsX()) return;
00152   
00153   // Make the projection
00154   TH1D* projX = input->ProjectionX();
00155   
00156   for (Int_t i=0; i<projX->GetNbinsX(); i++) {
00157     output->setBinContent(i+1,projX->GetBinContent(i+1));
00158   }
00159   delete projX;
00160 }
00161 
00162 void L1TGCTClient::makeYProjection(TH2F* input, MonitorElement* output)
00163 {
00164   // Are the provided input and output consistent
00165   if (input->GetNbinsY() != output->getNbinsX()) return;
00166   
00167   // Make the projection
00168   TH1D* projY = input->ProjectionY();
00169   
00170   for (Int_t i=0; i<projY->GetNbinsX(); i++) {
00171     output->setBinContent(i+1,projY->GetBinContent(i+1));
00172   }
00173   delete projY;
00174 }
00175 
00176