CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DQM/EcalBarrelMonitorModule/src/EcalBarrelMonitorModule.cc

Go to the documentation of this file.
00001 /*
00002  * \file EcalBarrelMonitorModule.cc
00003  *
00004  * $Date: 2012/04/26 07:44:01 $
00005  * $Revision: 1.206 $
00006  * \author G. Della Ricca
00007  * \author G. Franzoni
00008  *
00009 */
00010 
00011 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
00012 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00013 #include "DataFormats/EcalDigi/interface/EBDataFrame.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/EcalBarrelMonitorModule/interface/EcalBarrelMonitorModule.h"
00031 
00032 EcalBarrelMonitorModule::EcalBarrelMonitorModule(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 Barrel Generic Monitor ***" << std::endl;
00040     std::cout << std::endl;
00041   }
00042 
00043   init_ = false;
00044 
00045   EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
00046   EBDigiCollection_ = ps.getParameter<edm::InputTag>("EBDigiCollection");
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 EcalBarrel 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   meEBDCC_ = 0;
00120 
00121   for (int i = 0; i < 2; i++) {
00122     meEBdigis_[i] = 0;
00123     meEBhits_[i] = 0;
00124     meEBtpdigis_[i] = 0;
00125   }
00126 
00127   for (int i = 0; i < 36; i++) {
00128     meEvent_[i] = 0;
00129   }
00130 
00131 }
00132 
00133 EcalBarrelMonitorModule::~EcalBarrelMonitorModule(){
00134 
00135 }
00136 
00137 void EcalBarrelMonitorModule::beginJob(void){
00138 
00139   if ( debug_ ) std::cout << "EcalBarrelMonitorModule: 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 EcalBarrelMonitorModule::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00157 
00158   if ( debug_ ) std::cout << "EcalBarrelMonitorModule: beginRun" << std::endl;
00159 
00160   if ( ! mergeRuns_ ) this->reset();
00161 
00162 }
00163 
00164 void EcalBarrelMonitorModule::endRun(const edm::Run& r, const edm::EventSetup& c) {
00165 
00166   if ( debug_ ) std::cout << "EcalBarrelMonitorModule: 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 EcalBarrelMonitorModule::reset(void) {
00177 
00178   if ( meEvtType_ ) meEvtType_->Reset();
00179 
00180   if ( meEBDCC_ ) meEBDCC_->Reset();
00181 
00182   for (int i = 0; i < 2; i++) {
00183     if ( meEBdigis_[i] ) meEBdigis_[i]->Reset();
00184 
00185     if ( meEBhits_[i] ) meEBdigis_[i]->Reset();
00186 
00187     if ( meEBtpdigis_[i] ) meEBtpdigis_[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 EcalBarrelMonitorModule::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     meEBDCC_ = dqmStore_->book1D("EBMM DCC", "EBMM DCC", 36, 1, 37.);
00253     for (int i = 0; i < 36; i++) {
00254       meEBDCC_->setBinLabel(i+1, Numbers::sEB(i+1).c_str(), 1);
00255     }
00256 
00257     meEBdigis_[0] = dqmStore_->book1D("EBMM digi number", "EBMM digi number", 100, 0., 3000.);
00258 
00259     meEBdigis_[1] = dqmStore_->bookProfile("EBMM digi number profile", "EBMM digi number profile", 36, 1, 37., 1700, 0., 1701., "s");
00260     for (int i = 0; i < 36; i++) {
00261       meEBdigis_[1]->setBinLabel(i+1, Numbers::sEB(i+1).c_str(), 1);
00262     }
00263 
00264     meEBhits_[0] = dqmStore_->book1D("EBMM hit number", "EBMM hit number", 100, 0., 3000.);
00265 
00266     meEBhits_[1] = dqmStore_->bookProfile("EBMM hit number profile", "EBMM hit number profile", 36, 1, 37., 1700, 0., 1701., "s");
00267     for (int i = 0; i < 36; i++) {
00268       meEBhits_[1]->setBinLabel(i+1, Numbers::sEB(i+1).c_str(), 1);
00269     }
00270 
00271     meEBtpdigis_[0] = dqmStore_->book1D("EBMM TP digi number", "EBMM TP digi number", 100, 0., 2449.);
00272 
00273     meEBtpdigis_[1] = dqmStore_->bookProfile("EBMM TP digi number profile", "EBMM TP digi number profile", 36, 1, 37., 68, 0., 69., "s");
00274     for (int i = 0; i < 36; i++) {
00275       meEBtpdigis_[1]->setBinLabel(i+1, Numbers::sEB(i+1).c_str(), 1);
00276     }
00277 
00278     if ( enableEventDisplay_ ) {
00279       dqmStore_->setCurrentFolder(prefixME_ + "/EcalEvent");
00280       for (int i = 0; i < 36; i++) {
00281         name = "EBMM event " + Numbers::sEB(i+1);
00282         meEvent_[i] = dqmStore_->book2D(name, name, 85, 0., 85., 20, 0., 20.);
00283         meEvent_[i]->setAxisTitle("ieta", 1);
00284         meEvent_[i]->setAxisTitle("iphi", 2);
00285         dqmStore_->tag(meEvent_[i], i+1);
00286         if ( meEvent_[i] ) meEvent_[i]->setResetMe(true);
00287       }
00288     }
00289 
00290   }
00291 
00292 }
00293 
00294 void EcalBarrelMonitorModule::cleanup(void){
00295 
00296   if ( ! enableCleanup_ ) return;
00297 
00298   if ( dqmStore_ ) {
00299 
00300     dqmStore_->setCurrentFolder(prefixME_ + "/EcalInfo");
00301 
00302     if ( meStatus_ ) dqmStore_->removeElement( meStatus_->getName() );
00303     meStatus_ = 0;
00304 
00305     if ( meRun_ ) dqmStore_->removeElement( meRun_->getName() );
00306     meRun_ = 0;
00307 
00308     if ( meEvt_ ) dqmStore_->removeElement( meEvt_->getName() );
00309     meEvt_ = 0;
00310 
00311     if ( meRunType_ ) dqmStore_->removeElement( meRunType_->getName() );
00312     meRunType_ = 0;
00313 
00314     if ( meEvtType_ ) dqmStore_->removeElement( meEvtType_->getName() );
00315     meEvtType_ = 0;
00316 
00317     if ( meEBDCC_ ) dqmStore_->removeElement( meEBDCC_->getName() );
00318     meEBDCC_ = 0;
00319 
00320     for (int i = 0; i < 2; i++) {
00321 
00322       if ( meEBdigis_[i] ) dqmStore_->removeElement( meEBdigis_[i]->getName() );
00323       meEBdigis_[i] = 0;
00324 
00325       if ( meEBhits_[i] ) dqmStore_->removeElement( meEBhits_[i]->getName() );
00326       meEBhits_[i] = 0;
00327 
00328       if ( meEBtpdigis_[i] ) dqmStore_->removeElement( meEBtpdigis_[i]->getName() );
00329       meEBtpdigis_[i] = 0;
00330 
00331     }
00332 
00333     if ( enableEventDisplay_ ) {
00334 
00335       dqmStore_->setCurrentFolder(prefixME_ + "/EcalEvent");
00336 
00337       for (int i = 0; i < 36; i++) {
00338 
00339         if ( meEvent_[i] ) dqmStore_->removeElement( meEvent_[i]->getName() );
00340         meEvent_[i] = 0;
00341 
00342       }
00343 
00344     }
00345 
00346   }
00347 
00348   init_ = false;
00349 
00350 }
00351 
00352 void EcalBarrelMonitorModule::endJob(void) {
00353 
00354   if ( debug_ ) std::cout << "EcalBarrelMonitorModule: endJob, ievt = " << ievt_ << std::endl;
00355 
00356   if ( dqmStore_ ) {
00357     meStatus_ = dqmStore_->get(prefixME_ + "/EcalInfo/STATUS");
00358     meRun_ = dqmStore_->get(prefixME_ + "/EcalInfo/RUN");
00359     meEvt_ = dqmStore_->get(prefixME_ + "/EcalInfo/EVT");
00360   }
00361 
00362   // end-of-run
00363   if ( meStatus_ ) meStatus_->Fill(2);
00364 
00365   if ( meRun_ ) meRun_->Fill(runNumber_);
00366   if ( meEvt_ ) meEvt_->Fill(evtNumber_);
00367 
00368   if ( init_ ) this->cleanup();
00369 
00370 }
00371 
00372 void EcalBarrelMonitorModule::analyze(const edm::Event& e, const edm::EventSetup& c){
00373 
00374   Numbers::initGeometry(c, verbose_);
00375 
00376   if ( ! init_ ) this->setup();
00377 
00378   ievt_++;
00379 
00380   LogDebug("EcalBarrelMonitorModule") << "processing event " << ievt_;
00381 
00382   if ( ! fixedRunNumber_ ) runNumber_ = e.id().run();
00383 
00384   evtNumber_ = e.id().event();
00385 
00386   edm::Handle<EcalRawDataCollection> dcchs;
00387 
00388   if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00389 
00390     if ( dcchs->size() == 0 ) {
00391       LogDebug("EcalBarrelMonitorModule") << EcalRawDataCollection_ << " is empty";
00392       return;
00393     }
00394 
00395     int nebc = 0;
00396 
00397     for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00398 
00399       if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
00400 
00401       nebc++;
00402 
00403     }
00404 
00405     for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00406 
00407       if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
00408 
00409       if ( meEBDCC_ ) meEBDCC_->Fill(Numbers::iSM( *dcchItr, EcalBarrel )+0.5);
00410 
00411       if ( ! fixedRunNumber_ ) {
00412         runNumber_ = dcchItr->getRunNumber();
00413       }
00414 
00415       evtNumber_ = dcchItr->getLV1();
00416 
00417       if ( ! fixedRunType_ ) {
00418         runType_ = dcchItr->getRunType();
00419         evtType_ = runType_;
00420       }
00421 
00422       if ( evtType_ < 0 || evtType_ > 22 ) evtType_ = -1;
00423       if ( meEvtType_ ) meEvtType_->Fill(evtType_+0.5, 1./nebc);
00424 
00425     }
00426 
00427     LogDebug("EcalBarrelMonitorModule") << "event: " << ievt_ << " DCC headers collection size: " << nebc;
00428 
00429   } else {
00430 
00431     if ( evtType_ < 0 || evtType_ > 22 ) evtType_ = -1;
00432     if ( meEvtType_ ) meEvtType_->Fill(evtType_+0.5, 1./36.);
00433 
00434     edm::LogWarning("EcalBarrelMonitorModule") << EcalRawDataCollection_ << " not available";
00435 
00436   }
00437 
00438   isPhysics_ = false;
00439   if ( evtType_ == EcalDCCHeaderBlock::COSMIC ||
00440        evtType_ == EcalDCCHeaderBlock::MTCC ||
00441        evtType_ == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
00442        evtType_ == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
00443        evtType_ == EcalDCCHeaderBlock::COSMICS_LOCAL ||
00444        evtType_ == EcalDCCHeaderBlock::PHYSICS_LOCAL ) isPhysics_ = true;
00445 
00446   if ( meRunType_ ) meRunType_->Fill(runType_);
00447 
00448   if ( ievt_ == 1 ) {
00449     LogDebug("EcalBarrelMonitorModule") << "processing run " << runNumber_;
00450     // begin-of-run
00451     if ( meStatus_ ) meStatus_->Fill(0);
00452   } else {
00453     // running
00454     if ( meStatus_ ) meStatus_->Fill(1);
00455   }
00456 
00457   if ( meRun_ ) meRun_->Fill(runNumber_);
00458   if ( meEvt_ ) meEvt_->Fill(evtNumber_);
00459 
00460   edm::Handle<EBDigiCollection> digis;
00461 
00462   if ( e.getByLabel(EBDigiCollection_, digis) ) {
00463 
00464     int nebd = digis->size();
00465     LogDebug("EcalBarrelMonitorModule") << "event " << ievt_ << " digi collection size " << nebd;
00466 
00467     int counter[36] = { 0 };
00468 
00469     if ( meEBdigis_[0] ) {
00470       if ( isPhysics_ ) meEBdigis_[0]->Fill(float(nebd));
00471     }
00472 
00473     for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
00474 
00475       EBDetId id = digiItr->id();
00476 
00477       int ism = Numbers::iSM( id );
00478 
00479       counter[ism-1]++;
00480 
00481     }
00482 
00483     for (int i = 0; i < 36; i++) {
00484 
00485       if ( meEBdigis_[1] ) {
00486         if ( isPhysics_ ) meEBdigis_[1]->Fill(i+1+0.5, counter[i]);
00487       }
00488 
00489     }
00490 
00491   } else {
00492 
00493     edm::LogWarning("EcalBarrelMonitorModule") << EBDigiCollection_ << " not available";
00494 
00495   }
00496 
00497   edm::Handle<EcalRecHitCollection> hits;
00498 
00499   if ( e.getByLabel(EcalRecHitCollection_, hits) ) {
00500 
00501     int nebh = hits->size();
00502     LogDebug("EcalBarrelMonitorModule") << "event " << ievt_ << " hits collection size " << nebh;
00503 
00504     if ( meEBhits_[0] ) {
00505       if ( isPhysics_ ) meEBhits_[0]->Fill(float(nebh));
00506     }
00507 
00508     int counter[36] = { 0 };
00509 
00510     for ( EcalRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {
00511 
00512       EBDetId id = hitItr->id();
00513 
00514       int ic = id.ic();
00515       int ie = (ic-1)/20 + 1;
00516       int ip = (ic-1)%20 + 1;
00517 
00518       int ism = Numbers::iSM( id );
00519 
00520       counter[ism-1]++;
00521 
00522       float xie = ie - 0.5;
00523       float xip = ip - 0.5;
00524 
00525       float xval = hitItr->energy();
00526 
00527       if ( enableEventDisplay_ ) {
00528 
00529         if ( xval >= 10 ) {
00530           if ( meEvent_[ism-1] ) meEvent_[ism-1]->Fill(xie, xip, xval);
00531         }
00532 
00533       }
00534 
00535     }
00536 
00537     for (int i = 0; i < 36; i++) {
00538 
00539       if ( meEBhits_[1] ) {
00540         if ( isPhysics_ ) meEBhits_[1]->Fill(i+1+0.5, counter[i]);
00541       }
00542 
00543     }
00544 
00545   } else {
00546 
00547     edm::LogWarning("EcalBarrelMonitorModule") << EcalRecHitCollection_ << " not available";
00548 
00549   }
00550 
00551   edm::Handle<EcalTrigPrimDigiCollection> tpdigis;
00552 
00553   if ( e.getByLabel(EcalTrigPrimDigiCollection_, tpdigis) ) {
00554 
00555     int nebtpd = 0;
00556     int counter[36] = { 0 };
00557 
00558     for ( EcalTrigPrimDigiCollection::const_iterator tpdigiItr = tpdigis->begin(); tpdigiItr != tpdigis->end(); ++tpdigiItr ) {
00559 
00560       EcalTrigTowerDetId idt = tpdigiItr->id();
00561 
00562       if ( Numbers::subDet( idt ) != EcalBarrel ) continue;
00563 
00564       int ismt = Numbers::iSM( idt );
00565 
00566       nebtpd++;
00567       counter[ismt-1]++;
00568 
00569     }
00570 
00571     LogDebug("EcalBarrelMonitorModule") << "event " << ievt_ << " TP digi collection size " << nebtpd;
00572     if ( meEBtpdigis_[0] ) {
00573       if ( isPhysics_ ) meEBtpdigis_[0]->Fill(float(nebtpd));
00574     }
00575 
00576     for (int i = 0; i < 36; i++) {
00577 
00578       if ( meEBtpdigis_[1] ) {
00579         if ( isPhysics_ ) meEBtpdigis_[1]->Fill(i+1+0.5, counter[i]);
00580       }
00581 
00582     }
00583 
00584   } else {
00585 
00586     edm::LogWarning("EcalBarrelMonitorModule") << EcalTrigPrimDigiCollection_ << " not available";
00587 
00588   }
00589 
00590 }
00591