CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DQM/EcalEndcapMonitorModule/src/EcalEndcapMonitorModule.cc

Go to the documentation of this file.
00001 /*
00002  * \file EcalEndcapMonitorModule.cc
00003  *
00004  * $Date: 2012/04/26 07:45:15 $
00005  * $Revision: 1.88 $
00006  * \author G. Della Ricca
00007  * \author G. Franzoni
00008  *
00009 */
00010 
00011 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
00012 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00013 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
00014 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00015 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00016 
00017 #include "DQMServices/Core/interface/MonitorElement.h"
00018 
00019 #include "FWCore/ServiceRegistry/interface/Service.h"
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 
00022 #include "DQM/EcalCommon/interface/Numbers.h"
00023 
00024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00025 
00026 #include <memory>
00027 #include <iostream>
00028 #include <fstream>
00029 
00030 #include "DQM/EcalEndcapMonitorModule/interface/EcalEndcapMonitorModule.h"
00031 
00032 EcalEndcapMonitorModule::EcalEndcapMonitorModule(const edm::ParameterSet& ps){
00033 
00034   // verbose switch
00035   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00036 
00037   if ( verbose_ ) {
00038     std::cout << std::endl;
00039     std::cout << " *** Ecal Endcap Generic Monitor ***" << std::endl;
00040     std::cout << std::endl;
00041   }
00042 
00043   init_ = false;
00044 
00045   EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
00046   EEDigiCollection_ = ps.getParameter<edm::InputTag>("EEDigiCollection");
00047   EcalRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalRecHitCollection");
00048   EcalTrigPrimDigiCollection_ = ps.getParameter<edm::InputTag>("EcalTrigPrimDigiCollection");
00049 
00050   // this should come from the event header
00051   runNumber_ = ps.getUntrackedParameter<int>("runNumber", 0);
00052 
00053   fixedRunNumber_ = false;
00054   if ( runNumber_ != 0 ) fixedRunNumber_ = true;
00055 
00056   if ( fixedRunNumber_ ) {
00057     if ( verbose_ ) {
00058       std::cout << " fixed Run Number = " << runNumber_ << std::endl;
00059     }
00060   }
00061 
00062   // this should come from the event header
00063   evtNumber_ = 0;
00064 
00065   // this should come from the EcalEndcap event header
00066   runType_ = ps.getUntrackedParameter<int>("runType", -1);
00067   evtType_ = runType_;
00068 
00069   fixedRunType_ = false;
00070   if ( runType_ != -1 ) fixedRunType_ = true;
00071 
00072   if ( fixedRunType_) {
00073     if ( verbose_ ) {
00074       std::cout << " fixed Run Type = " << runType_ << std::endl;
00075     }
00076   }
00077 
00078   // debug switch
00079   debug_ = ps.getUntrackedParameter<bool>("debug", false);
00080 
00081   if ( debug_ ) {
00082     if ( verbose_ ) {
00083       std::cout << " debug switch is ON" << std::endl;
00084     }
00085   } else {
00086     if ( verbose_ ) {
00087       std::cout << " debug switch is OFF" << std::endl;
00088     }
00089   }
00090 
00091   // prefixME path
00092   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00093 
00094   // enableCleanup switch
00095   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00096 
00097   // mergeRuns switch
00098   mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00099 
00100   if ( enableCleanup_ ) {
00101     if ( verbose_ ) {
00102       std::cout << " enableCleanup switch is ON" << std::endl;
00103     }
00104   } else {
00105     if ( verbose_ ) {
00106       std::cout << " enableCleanup switch is OFF" << std::endl;
00107     }
00108   }
00109 
00110   // EventDisplay switch
00111   enableEventDisplay_ = ps.getUntrackedParameter<bool>("enableEventDisplay", false);
00112 
00113   meStatus_ = 0;
00114   meRun_ = 0;
00115   meEvt_ = 0;
00116   meRunType_ = 0;
00117   meEvtType_ = 0;
00118 
00119   meEEDCC_ = 0;
00120 
00121   for (int i = 0; i < 2; i++) {
00122     meEEdigis_[i] = 0;
00123     meEEhits_[i] = 0;
00124     meEEtpdigis_[i] = 0;
00125   }
00126 
00127   for (int i = 0; i < 18; i++) {
00128     meEvent_[i] = 0;
00129   }
00130 
00131 }
00132 
00133 EcalEndcapMonitorModule::~EcalEndcapMonitorModule(){
00134 
00135 }
00136 
00137 void EcalEndcapMonitorModule::beginJob(void){
00138 
00139   if ( debug_ ) std::cout << "EcalEndcapMonitorModule: beginJob" << std::endl;
00140 
00141   ievt_ = 0;
00142 
00143   dqmStore_ = edm::Service<DQMStore>().operator->();
00144 
00145   if ( dqmStore_ ) {
00146     dqmStore_->setCurrentFolder(prefixME_ + "/EcalInfo");
00147     dqmStore_->rmdir(prefixME_ + "/EcalInfo");
00148     if ( enableEventDisplay_ ) {
00149       dqmStore_->setCurrentFolder(prefixME_ + "/EcalEvent");
00150       dqmStore_->rmdir(prefixME_ + "/EcalEvent");
00151     }
00152   }
00153 
00154 }
00155 
00156 void EcalEndcapMonitorModule::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00157 
00158   if ( debug_ ) std::cout << "EcalEndcapMonitorModule: beginRun" << std::endl;
00159 
00160   if ( ! mergeRuns_ ) this->reset();
00161 
00162 }
00163 
00164 void EcalEndcapMonitorModule::endRun(const edm::Run& r, const edm::EventSetup& c) {
00165 
00166   if ( debug_ ) std::cout << "EcalEndcapMonitorModule: endRun" << std::endl;
00167 
00168   // end-of-run
00169   if ( meStatus_ ) meStatus_->Fill(2);
00170 
00171   if ( meRun_ ) meRun_->Fill(runNumber_);
00172   if ( meEvt_ ) meEvt_->Fill(evtNumber_);
00173 
00174 }
00175 
00176 void EcalEndcapMonitorModule::reset(void) {
00177 
00178   if ( meEvtType_ ) meEvtType_->Reset();
00179 
00180   if ( meEEDCC_ ) meEEDCC_->Reset();
00181 
00182   for (int i = 0; i < 2; i++) {
00183     if ( meEEdigis_[i] ) meEEdigis_[i]->Reset();
00184 
00185     if ( meEEhits_[i] ) meEEdigis_[i]->Reset();
00186 
00187     if ( meEEtpdigis_[i] ) meEEtpdigis_[i]->Reset();
00188   }
00189 
00190   if ( enableEventDisplay_ ) {
00191     for (int i = 0; i < 18; i++) {
00192       if ( meEvent_[i] ) meEvent_[i]->Reset();
00193     }
00194   }
00195 
00196 }
00197 
00198 void EcalEndcapMonitorModule::setup(void){
00199 
00200   init_ = true;
00201 
00202   if ( dqmStore_ ) {
00203     dqmStore_->setCurrentFolder(prefixME_ + "/EcalInfo");
00204 
00205     meStatus_ = dqmStore_->bookInt("STATUS");
00206 
00207     meRun_ = dqmStore_->bookInt("RUN");
00208     meEvt_ = dqmStore_->bookInt("EVT");
00209 
00210     meRunType_ = dqmStore_->bookInt("RUNTYPE");
00211     meEvtType_ = dqmStore_->book1D("EVTTYPE", "EVTTYPE", 31, -1., 30.);
00212     meEvtType_->setAxisTitle("number of events", 2);
00213     meEvtType_->setBinLabel(1, "UNKNOWN", 1);
00214     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::COSMIC, "COSMIC", 1);
00215     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH4, "BEAMH4", 1);
00216     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH2, "BEAMH2", 1);
00217     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::MTCC, "MTCC", 1);
00218     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::LASER_STD, "LASER_STD", 1);
00219     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
00220     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
00221     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
00222     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_MGPA, "TESTPULSE_MGPA", 1);
00223     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_STD, "PEDESTAL_STD", 1);
00224     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
00225     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
00226     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::LED_STD, "LED_STD", 1);
00227     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL, "PHYSICS_GLOBAL", 1);
00228     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_GLOBAL, "COSMICS_GLOBAL", 1);
00229     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::HALO_GLOBAL, "HALO_GLOBAL", 1);
00230     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::LASER_GAP, "LASER_GAP", 1);
00231     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_GAP, "TESTPULSE_GAP");
00232     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_GAP, "PEDESTAL_GAP");
00233     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::LED_GAP, "LED_GAP", 1);
00234     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_LOCAL, "PHYSICS_LOCAL", 1);
00235     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_LOCAL, "COSMICS_LOCAL", 1);
00236     meEvtType_->setBinLabel(2+EcalDCCHeaderBlock::HALO_LOCAL, "HALO_LOCAL", 1);
00237   }
00238 
00239   // unknown
00240   if ( meStatus_ ) meStatus_->Fill(-1);
00241 
00242   if ( meRun_ ) meRun_->Fill(-1);
00243   if ( meEvt_ ) meEvt_->Fill(-1);
00244 
00245   if ( meRunType_ ) meRunType_->Fill(-1);
00246 
00247   std::string name;
00248 
00249   if ( dqmStore_ ) {
00250     dqmStore_->setCurrentFolder(prefixME_ + "/EcalInfo");
00251 
00252     meEEDCC_ = dqmStore_->book1D("EEMM DCC", "EEMM DCC", 18, 1, 19.);
00253     for (int i = 0; i < 18; i++) {
00254       meEEDCC_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00255     }
00256 
00257     meEEdigis_[0] = dqmStore_->book1D("EEMM digi number", "EEMM digi number", 100, 0., 3000.);
00258 
00259     meEEdigis_[1] = dqmStore_->bookProfile("EEMM digi number profile", "EEMM digi number profile", 18, 1, 19., 850, 0., 851., "s");
00260     for (int i = 0; i < 18; i++) {
00261       meEEdigis_[1]->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00262     }
00263 
00264     meEEhits_[0] = dqmStore_->book1D("EEMM hit number", "EEMM hit number", 100, 0., 3000.);
00265 
00266     meEEhits_[1] = dqmStore_->bookProfile("EEMM hit number profile", "EEMM hit number profile", 18, 1, 19., 850, 0., 851., "s");
00267     for (int i = 0; i < 18; i++) {
00268       meEEhits_[1]->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00269     }
00270 
00271     meEEtpdigis_[0] = dqmStore_->book1D("EEMM TP digi number", "EEMM TP digi number", 100, 0., 1585.);
00272 
00273     meEEtpdigis_[1] = dqmStore_->bookProfile("EEMM TP digi number profile", "EEMM TP digi number profile", 18, 1, 19., 34, 0., 35., "s");
00274     for (int i = 0; i < 18; i++) {
00275       meEEtpdigis_[1]->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00276     }
00277 
00278     if ( enableEventDisplay_ ) {
00279       dqmStore_->setCurrentFolder(prefixME_ + "/EcalEvent");
00280       for (int i = 0; i < 18; i++) {
00281         name = "EEMM event " + Numbers::sEE(i+1);
00282         meEvent_[i] = dqmStore_->book2D(name, name, 50, Numbers::ix0EE(i+1)+0., Numbers::ix0EE(i+1)+50., 50, Numbers::iy0EE(i+1)+0., Numbers::iy0EE(i+1)+50.);
00283         meEvent_[i]->setAxisTitle("ix", 1);
00284         if ( i+1 >= 1 && i+1 <= 9 ) meEvent_[i]->setAxisTitle("101-ix", 1);
00285         meEvent_[i]->setAxisTitle("iy", 2);
00286         dqmStore_->tag(meEvent_[i], i+1);
00287         if ( meEvent_[i] ) meEvent_[i]->setResetMe(true);
00288       }
00289     }
00290 
00291   }
00292 
00293 }
00294 
00295 void EcalEndcapMonitorModule::cleanup(void){
00296 
00297   if ( ! enableCleanup_ ) return;
00298 
00299   if ( dqmStore_ ) {
00300 
00301     dqmStore_->setCurrentFolder(prefixME_ + "/EcalInfo");
00302 
00303     if ( meStatus_ ) dqmStore_->removeElement( meStatus_->getName() );
00304     meStatus_ = 0;
00305 
00306     if ( meRun_ ) dqmStore_->removeElement( meRun_->getName() );
00307     meRun_ = 0;
00308 
00309     if ( meEvt_ ) dqmStore_->removeElement( meEvt_->getName() );
00310     meEvt_ = 0;
00311 
00312     if ( meRunType_ ) dqmStore_->removeElement( meRunType_->getName() );
00313     meRunType_ = 0;
00314 
00315     if ( meEvtType_ ) dqmStore_->removeElement( meEvtType_->getName() );
00316     meEvtType_ = 0;
00317 
00318     if ( meEEDCC_ ) dqmStore_->removeElement( meEEDCC_->getName() );
00319     meEEDCC_ = 0;
00320 
00321     for (int i = 0; i < 2; i++) {
00322 
00323       if ( meEEdigis_[i] ) dqmStore_->removeElement( meEEdigis_[i]->getName() );
00324       meEEdigis_[i] = 0;
00325 
00326       if ( meEEhits_[i] ) dqmStore_->removeElement( meEEhits_[i]->getName() );
00327       meEEhits_[i] = 0;
00328 
00329       if ( meEEtpdigis_[i] ) dqmStore_->removeElement( meEEtpdigis_[i]->getName() );
00330       meEEtpdigis_[i] = 0;
00331 
00332     }
00333 
00334     if ( enableEventDisplay_ ) {
00335 
00336       dqmStore_->setCurrentFolder(prefixME_ + "/EcalEvent");
00337 
00338       for (int i = 0; i < 18; i++) {
00339 
00340         if ( meEvent_[i] ) dqmStore_->removeElement( meEvent_[i]->getName() );
00341         meEvent_[i] = 0;
00342 
00343       }
00344 
00345     }
00346 
00347   }
00348 
00349   init_ = false;
00350 
00351 }
00352 
00353 void EcalEndcapMonitorModule::endJob(void) {
00354 
00355   if ( debug_ ) std::cout << "EcalEndcapMonitorModule: endJob, ievt = " << ievt_ << std::endl;
00356 
00357   if ( dqmStore_ ) {
00358     meStatus_ = dqmStore_->get(prefixME_ + "/EcalInfo/STATUS");
00359     meRun_ = dqmStore_->get(prefixME_ + "/EcalInfo/RUN");
00360     meEvt_ = dqmStore_->get(prefixME_ + "/EcalInfo/EVT");
00361   }
00362 
00363   // end-of-run
00364   if ( meStatus_ ) meStatus_->Fill(2);
00365 
00366   if ( meRun_ ) meRun_->Fill(runNumber_);
00367   if ( meEvt_ ) meEvt_->Fill(evtNumber_);
00368 
00369   if ( init_ ) this->cleanup();
00370 
00371 }
00372 
00373 void EcalEndcapMonitorModule::analyze(const edm::Event& e, const edm::EventSetup& c){
00374 
00375   Numbers::initGeometry(c, verbose_);
00376 
00377   if ( ! init_ ) this->setup();
00378 
00379   ievt_++;
00380 
00381   LogDebug("EcalEndcapMonitorModule") << "processing event " << ievt_;
00382 
00383   if ( ! fixedRunNumber_ ) runNumber_ = e.id().run();
00384 
00385   evtNumber_ = e.id().event();
00386 
00387   edm::Handle<EcalRawDataCollection> dcchs;
00388 
00389   if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00390 
00391     if ( dcchs->size() == 0 ) {
00392       LogDebug("EcalEndcapMonitorModule") << EcalRawDataCollection_ << " is empty";
00393       return;
00394     }
00395 
00396     int neec = 0;
00397 
00398     for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00399 
00400       if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
00401 
00402       neec++;
00403 
00404     }
00405 
00406     for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00407 
00408       if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
00409 
00410       if ( meEEDCC_ ) meEEDCC_->Fill(Numbers::iSM( *dcchItr, EcalEndcap )+0.5);
00411 
00412       if ( ! fixedRunNumber_ ) {
00413         runNumber_ = dcchItr->getRunNumber();
00414       }
00415 
00416       evtNumber_ = dcchItr->getLV1();
00417 
00418       if ( ! fixedRunType_ ) {
00419         runType_ = dcchItr->getRunType();
00420         evtType_ = runType_;
00421       }
00422 
00423       if ( evtType_ < 0 || evtType_ > 22 ) evtType_ = -1;
00424       if ( meEvtType_ ) meEvtType_->Fill(evtType_+0.5, 1./neec);
00425 
00426     }
00427 
00428     LogDebug("EcalEndcapMonitorModule") << "event: " << ievt_ << " DCC headers collection size: " << neec;
00429 
00430   } else {
00431 
00432     if ( evtType_ < 0 || evtType_ > 22 ) evtType_ = -1;
00433     if ( meEvtType_ ) meEvtType_->Fill(evtType_+0.5, 1./18.);
00434 
00435     edm::LogWarning("EcalEndcapMonitorModule") << EcalRawDataCollection_ << " not available";
00436 
00437   }
00438 
00439   isPhysics_ = false;
00440   if ( evtType_ == EcalDCCHeaderBlock::COSMIC ||
00441        evtType_ == EcalDCCHeaderBlock::MTCC ||
00442        evtType_ == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
00443        evtType_ == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
00444        evtType_ == EcalDCCHeaderBlock::COSMICS_LOCAL ||
00445        evtType_ == EcalDCCHeaderBlock::PHYSICS_LOCAL ) isPhysics_ = true;
00446 
00447   if ( meRunType_ ) meRunType_->Fill(runType_);
00448 
00449   if ( ievt_ == 1 ) {
00450     LogDebug("EcalEndcapMonitorModule") << "processing run " << runNumber_;
00451     // begin-of-run
00452     if ( meStatus_ ) meStatus_->Fill(0);
00453   } else {
00454     // running
00455     if ( meStatus_ ) meStatus_->Fill(1);
00456   }
00457 
00458   if ( meRun_ ) meRun_->Fill(runNumber_);
00459   if ( meEvt_ ) meEvt_->Fill(evtNumber_);
00460 
00461   edm::Handle<EEDigiCollection> digis;
00462 
00463   if ( e.getByLabel(EEDigiCollection_, digis) ) {
00464 
00465     int need = digis->size();
00466     LogDebug("EcalEndcapMonitorModule") << "event " << ievt_ << " digi collection size " << need;
00467 
00468     int counter[18] = { 0 };
00469 
00470     if ( meEEdigis_[0] ) {
00471       if ( isPhysics_ ) meEEdigis_[0]->Fill(float(need));
00472     }
00473 
00474     for ( EEDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
00475 
00476       EEDetId id = digiItr->id();
00477 
00478       int ism = Numbers::iSM( id );
00479 
00480       counter[ism-1]++;
00481 
00482     }
00483 
00484     for (int i = 0; i < 18; i++) {
00485 
00486       if ( meEEdigis_[1] ) {
00487         if ( isPhysics_ ) meEEdigis_[1]->Fill(i+1+0.5, counter[i]);
00488       }
00489 
00490     }
00491 
00492   } else {
00493 
00494     edm::LogWarning("EcalEndcapMonitorModule") << EEDigiCollection_ << " not available";
00495 
00496   }
00497 
00498   edm::Handle<EcalRecHitCollection> hits;
00499 
00500   if ( e.getByLabel(EcalRecHitCollection_, hits) ) {
00501 
00502     int neeh = hits->size();
00503     LogDebug("EcalEndcapMonitorModule") << "event " << ievt_ << " hits collection size " << neeh;
00504 
00505     if ( meEEhits_[0] ) {
00506       if ( isPhysics_ ) meEEhits_[0]->Fill(float(neeh));
00507     }
00508 
00509     int counter[18] = { 0 };
00510 
00511     for ( EcalRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {
00512 
00513       EEDetId id = hitItr->id();
00514 
00515       int ix = id.ix();
00516       int iy = id.iy();
00517 
00518       int ism = Numbers::iSM( id );
00519 
00520       counter[ism-1]++;
00521 
00522       if ( ism >= 1 && ism <= 9 ) ix = 101 - ix;
00523 
00524       float xix = ix - 0.5;
00525       float xiy = iy - 0.5;
00526 
00527       float xval = hitItr->energy();
00528 
00529       if ( enableEventDisplay_ ) {
00530 
00531         if ( xval >= 10 ) {
00532           if ( meEvent_[ism-1] ) meEvent_[ism-1]->Fill(xix, xiy, xval);
00533         }
00534 
00535       }
00536 
00537     }
00538 
00539     for (int i = 0; i < 18; i++) {
00540 
00541       if ( meEEhits_[1] ) {
00542         if ( isPhysics_ ) meEEhits_[1]->Fill(i+1+0.5, counter[i]);
00543       }
00544 
00545     }
00546 
00547   } else {
00548 
00549     edm::LogWarning("EcalEndcapMonitorModule") << EcalRecHitCollection_ << " not available";
00550 
00551   }
00552 
00553   edm::Handle<EcalTrigPrimDigiCollection> tpdigis;
00554 
00555   if ( e.getByLabel(EcalTrigPrimDigiCollection_, tpdigis) ) {
00556 
00557     int neetpd = 0;
00558     int counter[18] = { 0 };
00559 
00560     for ( EcalTrigPrimDigiCollection::const_iterator tpdigiItr = tpdigis->begin(); tpdigiItr != tpdigis->end(); ++tpdigiItr ) {
00561 
00562       EcalTrigTowerDetId idt = tpdigiItr->id();
00563 
00564       if ( Numbers::subDet( idt ) != EcalEndcap ) continue;
00565 
00566       int ismt = Numbers::iSM( idt );
00567 
00568       neetpd++;
00569       counter[ismt-1]++;
00570 
00571     }
00572 
00573     LogDebug("EcalEndcapMonitorModule") << "event " << ievt_ << " TP digi collection size " << neetpd;
00574     if ( meEEtpdigis_[0] ) {
00575       if ( isPhysics_ ) meEEtpdigis_[0]->Fill(float(neetpd));
00576     }
00577 
00578     for (int i = 0; i < 18; i++) {
00579 
00580       if ( meEEtpdigis_[1] ) {
00581         if ( isPhysics_ ) meEEtpdigis_[1]->Fill(i+1+0.5, counter[i]);
00582       }
00583 
00584     }
00585 
00586   } else {
00587 
00588     edm::LogWarning("EcalEndcapMonitorModule") << EcalTrigPrimDigiCollection_ << " not available";
00589 
00590   }
00591 
00592 }
00593