CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/L1TMonitor/src/L1TECALTPG.cc

Go to the documentation of this file.
00001 /*
00002  * \file L1TECALTPG.cc
00003  *
00004  * $Date: 2009/11/19 14:38:47 $
00005  * $Revision: 1.14 $
00006  * \author J. Berryhill
00007  *
00008  * - initial version stolen from GCTMonnitor (thanks!) (wittich 02/07)
00009  *
00010  * $Log: L1TECALTPG.cc,v $
00011  * Revision 1.14  2009/11/19 14:38:47  puigh
00012  * modify beginJob
00013  *
00014  * Revision 1.13  2008/03/20 19:38:25  berryhil
00015  *
00016  *
00017  * organized message logger
00018  *
00019  * Revision 1.12  2008/03/18 20:31:20  berryhil
00020  *
00021  *
00022  * update of ecal tpg dqm
00023  *
00024  * Revision 1.11  2008/03/14 20:35:46  berryhil
00025  *
00026  *
00027  * stripped out obsolete parameter settings
00028  *
00029  * rpc tpg restored with correct dn access and dbe handling
00030  *
00031  * Revision 1.10  2008/03/12 17:24:24  berryhil
00032  *
00033  *
00034  * eliminated log files, truncated HCALTPGXana histo output
00035  *
00036  * Revision 1.9  2008/03/01 00:40:00  lat
00037  * DQM core migration.
00038  *
00039  * Revision 1.8  2007/12/21 17:41:20  berryhil
00040  *
00041  *
00042  * try/catch removal
00043  *
00044  * Revision 1.7  2007/11/19 15:08:22  lorenzo
00045  * changed top folder name
00046  *
00047  * Revision 1.6  2007/08/29 14:02:47  wittich
00048  * split into barrel and endcap
00049  *
00050  * Revision 1.5  2007/05/25 15:45:48  berryhil
00051  *
00052  *
00053  *
00054  * added exception handling for each edm Handle
00055  * updated cfg and cff to reflect recent usage at point 5
00056  *
00057  * Revision 1.4  2007/02/22 19:43:53  berryhil
00058  *
00059  *
00060  *
00061  * InputTag parameters added for all modules
00062  *
00063  * Revision 1.3  2007/02/20 22:49:00  wittich
00064  * - change from getByType to getByLabel in ECAL TPG,
00065  *   and make it configurable.
00066  * - fix problem in the GCT with incorrect labels. Not the ultimate
00067  *   solution - will probably have to go to many labels.
00068  *
00069  * Revision 1.2  2007/02/19 22:07:26  wittich
00070  * - Added three monitorables to the ECAL TPG monitoring (from GCTMonitor)
00071  * - other minor tweaks in GCT, etc
00072  *
00073  */
00074 
00075 #include "DQM/L1TMonitor/interface/L1TECALTPG.h"
00076 
00077 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00078 #include "DQMServices/Core/interface/DQMStore.h"
00079 
00080 // end of header files 
00081 using namespace edm;
00082 
00083 // Local definitions for the limits of the histograms
00084 const unsigned int RTPBINS = 101;
00085 const float RTPMIN = -0.5;
00086 const float RTPMAX = 100.5;
00087 
00088 const unsigned int TPPHIBINS = 72;
00089 const float TPPHIMIN = 0.5;
00090 const float TPPHIMAX = 72.5;
00091 
00092 const unsigned int TPETABINS = 65;
00093 const float TPETAMIN = -32.5;
00094 const float TPETAMAX = 32.5;
00095 
00096 
00097 L1TECALTPG::L1TECALTPG(const ParameterSet & ps):
00098   ecaltpgSourceB_(ps.getParameter<edm::InputTag>("ecaltpgSourceB")),
00099   ecaltpgSourceE_(ps.getParameter<edm::InputTag>("ecaltpgSourceE"))
00100 {
00101 
00102   // verbosity switch
00103   verbose_ = ps.getUntrackedParameter < bool > ("verbose", false);
00104 
00105   // ecal endcap switch
00106   enableEE_ = ps.getUntrackedParameter < bool > ("enableEE", false);
00107 
00108   if (verbose_)
00109     std::cout << "L1TECALTPG: constructor...." << std::endl;
00110 
00111 
00112   dbe = NULL;
00113   if (ps.getUntrackedParameter < bool > ("DQMStore", false)) {
00114     dbe = Service < DQMStore > ().operator->();
00115     dbe->setVerbose(0);
00116   }
00117 
00118   outputFile_ =
00119       ps.getUntrackedParameter < std::string > ("outputFile", "");
00120   if (outputFile_.size() != 0) {
00121     std::cout << "L1T Monitoring histograms will be saved to " 
00122               << outputFile_ << std::endl;
00123   }
00124 
00125   bool disable =
00126       ps.getUntrackedParameter < bool > ("disableROOToutput", false);
00127   if (disable) {
00128     outputFile_ = "";
00129   }
00130 
00131 
00132   if (dbe != NULL) {
00133     dbe->setCurrentFolder("L1T/L1TECALTPG");
00134   }
00135 
00136 
00137 }
00138 
00139 L1TECALTPG::~L1TECALTPG()
00140 {
00141 }
00142 
00143 void L1TECALTPG::beginJob(void)
00144 {
00145 
00146   nev_ = 0;
00147 
00148   // get hold of back-end interface
00149   DQMStore *dbe = 0;
00150   dbe = Service < DQMStore > ().operator->();
00151 
00152   if (dbe) {
00153     dbe->setCurrentFolder("L1T/L1TECALTPG");
00154     dbe->rmdir("L1T/L1TECALTPG");
00155   }
00156 
00157 
00158   if (dbe) {
00159     dbe->setCurrentFolder("L1T/L1TECALTPG");
00160     ecalTpEtEtaPhiB_ = 
00161       dbe->book2D("EcalTpEtEtaPhiB", "ECAL TP E_{T} Barrel", TPPHIBINS, 
00162                   TPPHIMIN, TPPHIMAX, TPETABINS, TPETAMIN, TPETAMAX);
00163     ecalTpOccEtaPhiB_ =
00164         dbe->book2D("EcalTpOccEtaPhiB", "ECAL TP OCCUPANCY Barrel", TPPHIBINS,
00165                     TPPHIMIN, TPPHIMAX, TPETABINS, TPETAMIN, TPETAMAX);
00166     ecalTpRankB_ =
00167       dbe->book1D("EcalTpRankB", "ECAL TP RANK Barrel", RTPBINS, RTPMIN,
00168                   RTPMAX);
00169 
00170     ecalTpEtEtaPhiE_ = 
00171       dbe->book2D("EcalTpEtEtaPhiE", "ECAL TP E_{T} Endcap", TPPHIBINS, 
00172                   TPPHIMIN, TPPHIMAX, TPETABINS, TPETAMIN, TPETAMAX);
00173     ecalTpOccEtaPhiE_ =
00174         dbe->book2D("EcalTpOccEtaPhiE", "ECAL TP OCCUPANCY Endcap", TPPHIBINS,
00175                     TPPHIMIN, TPPHIMAX, TPETABINS, TPETAMIN, TPETAMAX);
00176     ecalTpRankE_ =
00177       dbe->book1D("EcalTpRankE", "ECAL TP RANK Endcap", RTPBINS, RTPMIN,
00178                   RTPMAX);
00179 
00180   }
00181 }
00182 
00183 
00184 void L1TECALTPG::endJob(void)
00185 {
00186   if (verbose_)
00187     std::cout << "L1TECALTPG: end job...." << std::endl;
00188   LogInfo("EndJob") << "analyzed " << nev_ << " events";
00189 
00190   if (outputFile_.size() != 0 && dbe)
00191     dbe->save(outputFile_);
00192 
00193   return;
00194 }
00195 
00196 void L1TECALTPG::analyze(const Event & e, const EventSetup & c)
00197 {
00198   nev_++;
00199   if (verbose_) {
00200     std::cout << "L1TECALTPG: analyze...." << std::endl;
00201   }
00202 
00203   // Get the ECAL TPGs
00204   edm::Handle < EcalTrigPrimDigiCollection > eeTP;
00205   edm::Handle < EcalTrigPrimDigiCollection > ebTP;
00206   //  e.getByType(ebTP);
00207   e.getByLabel(ecaltpgSourceB_,ebTP);
00208   e.getByLabel(ecaltpgSourceE_,eeTP);
00209   
00210   if (!eeTP.isValid() && enableEE_) 
00211   {
00212     edm::LogInfo("DataNotFound") << "can't find EcalTrigPrimCollection with "
00213       " endcap label " << ecaltpgSourceE_.label() ;
00214     return;
00215   }  
00216   if (!ebTP.isValid()) 
00217   {
00218     edm::LogInfo("DataNotFound") << "can't find EcalTrigPrimCollection with "
00219       " barrel label " << ecaltpgSourceB_.label() ;
00220     return;
00221   }
00222 
00223   // Fill the ECAL TPG histograms
00224   if ( verbose_ ) {
00225     std::cout << "L1TECALTPG: barrel size is " << ebTP->size() << std::endl;
00226     std::cout << "L1TECALTPG: endcap size is " << eeTP->size() << std::endl;
00227   }
00228   
00229   for (EcalTrigPrimDigiCollection::const_iterator iebTP = ebTP->begin();
00230        iebTP != ebTP->end(); iebTP++) {
00231     if ( verbose_ ) {
00232       std::cout << "barrel: " << iebTP->id().iphi() << ", " 
00233                 << iebTP->id().ieta()
00234                 << std::endl;
00235     }
00236     ecalTpEtEtaPhiB_->Fill(iebTP->id().iphi(), iebTP->id().ieta(),
00237                           iebTP->compressedEt());
00238     ecalTpOccEtaPhiB_->Fill(iebTP->id().iphi(), iebTP->id().ieta());
00239     ecalTpRankB_->Fill(iebTP->compressedEt());
00240 
00241   }
00242   
00243   if (enableEE_){
00244   // endcap
00245   for (EcalTrigPrimDigiCollection::const_iterator ieeTP = eeTP->begin();
00246        ieeTP != eeTP->end(); ieeTP++) {
00247     if ( verbose_ ) {
00248       std::cout << "endcap: " << ieeTP->id().iphi() << ", " 
00249                 << ieeTP->id().ieta()
00250                 << std::endl;
00251     }
00252     ecalTpEtEtaPhiE_->Fill(ieeTP->id().iphi(), ieeTP->id().ieta(),
00253                           ieeTP->compressedEt());
00254     ecalTpOccEtaPhiE_->Fill(ieeTP->id().iphi(), ieeTP->id().ieta());
00255     ecalTpRankE_->Fill(ieeTP->compressedEt());
00256 
00257   }
00258   }
00259 
00260 }