CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/DQM/EcalBarrelMonitorTasks/src/EBOccupancyTask.cc

Go to the documentation of this file.
00001 /*
00002  * \file EBOccupancyTask.cc
00003  *
00004  * $Date: 2012/04/27 13:46:02 $
00005  * $Revision: 1.101 $
00006  * \author G. Della Ricca
00007  * \author G. Franzoni
00008  *
00009 */
00010 
00011 #include <iostream>
00012 #include <fstream>
00013 
00014 #include "FWCore/ServiceRegistry/interface/Service.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016 #include "FWCore/Framework/interface/ESHandle.h"
00017 
00018 #include "DQMServices/Core/interface/MonitorElement.h"
00019 
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 
00022 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
00023 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00024 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
00025 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00026 #include "DataFormats/EcalRecHit/interface/EcalUncalibratedRecHit.h"
00027 #include "DataFormats/EcalRecHit/interface/EcalRecHit.h"
00028 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00029 
00030 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00031 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
00032 
00033 #include "DQM/EcalCommon/interface/Numbers.h"
00034 
00035 #include "DQM/EcalBarrelMonitorTasks/interface/EBOccupancyTask.h"
00036 
00037 EBOccupancyTask::EBOccupancyTask(const edm::ParameterSet& ps){
00038 
00039   init_ = false;
00040 
00041   dqmStore_ = edm::Service<DQMStore>().operator->();
00042 
00043   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00044 
00045   subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
00046 
00047   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00048 
00049   mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00050 
00051   EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
00052   EBDigiCollection_ = ps.getParameter<edm::InputTag>("EBDigiCollection");
00053   EcalPnDiodeDigiCollection_ = ps.getParameter<edm::InputTag>("EcalPnDiodeDigiCollection");
00054   EcalRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalRecHitCollection");
00055   EcalTrigPrimDigiCollection_ = ps.getParameter<edm::InputTag>("EcalTrigPrimDigiCollection");
00056 
00057   for (int i = 0; i < 36; i++) {
00058     meOccupancy_[i]    = 0;
00059     meOccupancyMem_[i] = 0;
00060     meEBRecHitEnergy_[i] = 0;
00061     meSpectrum_[i] = 0;
00062   }
00063 
00064   meEBRecHitSpectrum_ = 0;
00065 
00066   meEBDigiOccupancy_ = 0;
00067   meEBDigiOccupancyProjEta_ = 0;
00068   meEBDigiOccupancyProjPhi_ = 0;
00069 
00070   meEBRecHitOccupancy_ = 0;
00071   meEBRecHitOccupancyProjEta_ = 0;
00072   meEBRecHitOccupancyProjPhi_ = 0;
00073 
00074   meEBRecHitOccupancyThr_ = 0;
00075   meEBRecHitOccupancyProjEtaThr_ = 0;
00076   meEBRecHitOccupancyProjPhiThr_ = 0;
00077 
00078   meEBTrigPrimDigiOccupancy_ = 0;
00079   meEBTrigPrimDigiOccupancyProjEta_ = 0;
00080   meEBTrigPrimDigiOccupancyProjPhi_ = 0;
00081 
00082   meEBTrigPrimDigiOccupancyThr_ = 0;
00083   meEBTrigPrimDigiOccupancyProjEtaThr_ = 0;
00084   meEBTrigPrimDigiOccupancyProjPhiThr_ = 0;
00085 
00086   meEBTestPulseDigiOccupancy_ = 0;
00087   meEBLaserDigiOccupancy_ = 0;
00088   meEBPedestalDigiOccupancy_ = 0;
00089 
00090   recHitEnergyMin_ = 0.300; // GeV
00091   trigPrimEtMin_ = 4.; // 4 ADCs == 1 GeV
00092 
00093 }
00094 
00095 EBOccupancyTask::~EBOccupancyTask(){
00096 
00097 }
00098 
00099 void EBOccupancyTask::beginJob(void){
00100 
00101   ievt_ = 0;
00102 
00103   if ( dqmStore_ ) {
00104     dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask");
00105     if(subfolder_.size())
00106       dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask/" + subfolder_);
00107     dqmStore_->rmdir(prefixME_ + "/EBOccupancyTask");
00108   }
00109 
00110 }
00111 
00112 void EBOccupancyTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00113 
00114   Numbers::initGeometry(c, false);
00115 
00116   if ( ! mergeRuns_ ) this->reset();
00117 
00118 }
00119 
00120 void EBOccupancyTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00121 
00122 }
00123 
00124 void EBOccupancyTask::reset(void) {
00125 
00126   for (int i = 0; i < 36; i++) {
00127     if ( meOccupancy_[i] ) meOccupancy_[i]->Reset();
00128     if ( meOccupancyMem_[i] ) meOccupancyMem_[i]->Reset();
00129     if ( meEBRecHitEnergy_[i] ) meEBRecHitEnergy_[i]->Reset();
00130     if ( meSpectrum_[i] ) meSpectrum_[i]->Reset();
00131   }
00132 
00133   if ( meEBRecHitSpectrum_ ) meEBRecHitSpectrum_->Reset();
00134 
00135   if ( meEBDigiOccupancy_ ) meEBDigiOccupancy_->Reset();
00136   if ( meEBDigiOccupancyProjEta_ ) meEBDigiOccupancyProjEta_->Reset();
00137   if ( meEBDigiOccupancyProjPhi_ ) meEBDigiOccupancyProjPhi_->Reset();
00138 
00139   if ( meEBRecHitOccupancy_ ) meEBRecHitOccupancy_->Reset();
00140   if ( meEBRecHitOccupancyProjEta_ ) meEBRecHitOccupancyProjEta_->Reset();
00141   if ( meEBRecHitOccupancyProjPhi_ ) meEBRecHitOccupancyProjPhi_->Reset();
00142 
00143   if ( meEBRecHitOccupancyThr_ ) meEBRecHitOccupancyThr_->Reset();
00144   if ( meEBRecHitOccupancyProjEtaThr_ ) meEBRecHitOccupancyProjEtaThr_->Reset();
00145   if ( meEBRecHitOccupancyProjPhiThr_ ) meEBRecHitOccupancyProjPhiThr_->Reset();
00146 
00147   if ( meEBTrigPrimDigiOccupancy_ ) meEBTrigPrimDigiOccupancy_->Reset();
00148   if ( meEBTrigPrimDigiOccupancyProjEta_ ) meEBTrigPrimDigiOccupancyProjEta_->Reset();
00149   if ( meEBTrigPrimDigiOccupancyProjPhi_ ) meEBTrigPrimDigiOccupancyProjPhi_->Reset();
00150 
00151   if ( meEBTrigPrimDigiOccupancyThr_ ) meEBTrigPrimDigiOccupancyThr_->Reset();
00152   if ( meEBTrigPrimDigiOccupancyProjEtaThr_ ) meEBTrigPrimDigiOccupancyProjEtaThr_->Reset();
00153   if ( meEBTrigPrimDigiOccupancyProjPhiThr_ ) meEBTrigPrimDigiOccupancyProjPhiThr_->Reset();
00154 
00155   if ( meEBTestPulseDigiOccupancy_ ) meEBTestPulseDigiOccupancy_->Reset();
00156   if ( meEBLaserDigiOccupancy_ ) meEBLaserDigiOccupancy_->Reset();
00157   if ( meEBPedestalDigiOccupancy_ ) meEBPedestalDigiOccupancy_->Reset();
00158 
00159 }
00160 
00161 void EBOccupancyTask::setup(void){
00162 
00163   init_ = true;
00164 
00165   std::string name;
00166 
00167   if ( dqmStore_ ) {
00168     dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask");
00169     if(subfolder_.size())
00170       dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask/" + subfolder_);
00171 
00172     for (int i = 0; i < 36; i++) {
00173       name = "EBOT digi occupancy " + Numbers::sEB(i+1);
00174       meOccupancy_[i] = dqmStore_->book2D(name, name, 85, 0., 85., 20, 0., 20.);
00175       meOccupancy_[i]->setAxisTitle("ieta", 1);
00176       meOccupancy_[i]->setAxisTitle("iphi", 2);
00177       dqmStore_->tag(meOccupancy_[i], i+1);
00178 
00179       name = "EBOT MEM digi occupancy " + Numbers::sEB(i+1);
00180       meOccupancyMem_[i] = dqmStore_->book2D(name, name, 10, 0., 10., 5, 0., 5.);
00181       meOccupancyMem_[i]->setAxisTitle("pseudo-strip", 1);
00182       meOccupancyMem_[i]->setAxisTitle("channel", 2);
00183       dqmStore_->tag(meOccupancyMem_[i], i+1);
00184 
00185       name = "EBOT rec hit energy " + Numbers::sEB(i+1);
00186       meEBRecHitEnergy_[i] = dqmStore_->bookProfile2D(name, name, 85, 0., 85., 20, 0., 20., 100, 0., 100., "s");
00187       meEBRecHitEnergy_[i]->setAxisTitle("ieta", 1);
00188       meEBRecHitEnergy_[i]->setAxisTitle("iphi", 2);
00189       meEBRecHitEnergy_[i]->setAxisTitle("energy (GeV)", 3);
00190       dqmStore_->tag(meEBRecHitEnergy_[i], i+1);
00191 
00192       name = "EBOT energy spectrum " + Numbers::sEB(i+1);
00193       meSpectrum_[i] = dqmStore_->book1D(name, name, 100, 0., 1.5);
00194       meSpectrum_[i]->setAxisTitle("energy (GeV)", 1);
00195       dqmStore_->tag(meSpectrum_[i], i+1);
00196     }
00197 
00198     name = "EBOT rec hit spectrum";
00199     meEBRecHitSpectrum_ = dqmStore_->book1D(name, name, 100, 0., 10.);
00200     meEBRecHitSpectrum_->setAxisTitle("energy (GeV)", 1);
00201 
00202     name = "EBOT digi occupancy";
00203     meEBDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
00204     meEBDigiOccupancy_->setAxisTitle("jphi", 1);
00205     meEBDigiOccupancy_->setAxisTitle("jeta", 2);
00206     name = "EBOT digi occupancy projection eta";
00207     meEBDigiOccupancyProjEta_ = dqmStore_->book1DD(name, name, 34, -85., 85.);
00208     meEBDigiOccupancyProjEta_->setAxisTitle("jeta", 1);
00209     meEBDigiOccupancyProjEta_->setAxisTitle("number of digis", 2);
00210     name = "EBOT digi occupancy projection phi";
00211     meEBDigiOccupancyProjPhi_ = dqmStore_->book1DD(name, name, 72, 0., 360.);
00212     meEBDigiOccupancyProjPhi_->setAxisTitle("jphi", 1);
00213     meEBDigiOccupancyProjPhi_->setAxisTitle("number of digis", 2);
00214 
00215     name = "EBOT rec hit occupancy";
00216     meEBRecHitOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
00217     meEBRecHitOccupancy_->setAxisTitle("jphi", 1);
00218     meEBRecHitOccupancy_->setAxisTitle("jeta", 2);
00219     name = "EBOT rec hit occupancy projection eta";
00220     meEBRecHitOccupancyProjEta_ = dqmStore_->book1DD(name, name, 34, -85., 85.);
00221     meEBRecHitOccupancyProjEta_->setAxisTitle("jeta", 1);
00222     meEBRecHitOccupancyProjEta_->setAxisTitle("number of hits", 2);
00223     name = "EBOT rec hit occupancy projection phi";
00224     meEBRecHitOccupancyProjPhi_ = dqmStore_->book1DD(name, name, 72, 0., 360.);
00225     meEBRecHitOccupancyProjPhi_->setAxisTitle("jphi", 1);
00226     meEBRecHitOccupancyProjPhi_->setAxisTitle("number of hits", 2);
00227 
00228     name = "EBOT rec hit thr occupancy";
00229     meEBRecHitOccupancyThr_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
00230     meEBRecHitOccupancyThr_->setAxisTitle("jphi", 1);
00231     meEBRecHitOccupancyThr_->setAxisTitle("jeta", 2);
00232     name = "EBOT rec hit thr occupancy projection eta";
00233     meEBRecHitOccupancyProjEtaThr_ = dqmStore_->book1DD(name, name, 34, -85., 85.);
00234     meEBRecHitOccupancyProjEtaThr_->setAxisTitle("jeta", 1);
00235     meEBRecHitOccupancyProjEtaThr_->setAxisTitle("number of hits", 2);
00236     name = "EBOT rec hit thr occupancy projection phi";
00237     meEBRecHitOccupancyProjPhiThr_ = dqmStore_->book1DD(name, name, 72, 0., 360.);
00238     meEBRecHitOccupancyProjPhiThr_->setAxisTitle("jphi", 1);
00239     meEBRecHitOccupancyProjPhiThr_->setAxisTitle("number of hits", 2);
00240 
00241     name = "EBOT TP digi occupancy";
00242     meEBTrigPrimDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, -17., 17.);
00243     meEBTrigPrimDigiOccupancy_->setAxisTitle("jphi'", 1);
00244     meEBTrigPrimDigiOccupancy_->setAxisTitle("jeta'", 2);
00245     name = "EBOT TP digi occupancy projection eta";
00246     meEBTrigPrimDigiOccupancyProjEta_ = dqmStore_->book1DD(name, name, 34, -17., 17.);
00247     meEBTrigPrimDigiOccupancyProjEta_->setAxisTitle("jeta'", 1);
00248     meEBTrigPrimDigiOccupancyProjEta_->setAxisTitle("number of TP digis", 2);
00249     name = "EBOT TP digi occupancy projection phi";
00250     meEBTrigPrimDigiOccupancyProjPhi_ = dqmStore_->book1DD(name, name, 72, 0., 72.);
00251     meEBTrigPrimDigiOccupancyProjPhi_->setAxisTitle("jphi'", 1);
00252     meEBTrigPrimDigiOccupancyProjPhi_->setAxisTitle("number of TP digis", 2);
00253 
00254     name = "EBOT TP digi thr occupancy";
00255     meEBTrigPrimDigiOccupancyThr_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, -17., 17.);
00256     meEBTrigPrimDigiOccupancyThr_->setAxisTitle("jphi'", 1);
00257     meEBTrigPrimDigiOccupancyThr_->setAxisTitle("jeta'", 2);
00258     name = "EBOT TP digi thr occupancy projection eta";
00259     meEBTrigPrimDigiOccupancyProjEtaThr_ = dqmStore_->book1DD(name, name, 34, -17., 17.);
00260     meEBTrigPrimDigiOccupancyProjEtaThr_->setAxisTitle("jeta'", 1);
00261     meEBTrigPrimDigiOccupancyProjEtaThr_->setAxisTitle("number of TP digis", 2);
00262     name = "EBOT TP digi thr occupancy projection phi";
00263     meEBTrigPrimDigiOccupancyProjPhiThr_ = dqmStore_->book1DD(name, name, 72, 0., 72.);
00264     meEBTrigPrimDigiOccupancyProjPhiThr_->setAxisTitle("jphi'", 1);
00265     meEBTrigPrimDigiOccupancyProjPhiThr_->setAxisTitle("number of TP digis", 2);
00266 
00267     name = "EBOT test pulse digi occupancy";
00268     meEBTestPulseDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
00269     meEBTestPulseDigiOccupancy_->setAxisTitle("jphi'", 1);
00270     meEBTestPulseDigiOccupancy_->setAxisTitle("jeta'", 2);
00271 
00272     name = "EBOT laser digi occupancy";
00273     meEBLaserDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
00274     meEBLaserDigiOccupancy_->setAxisTitle("jphi'", 1);
00275     meEBLaserDigiOccupancy_->setAxisTitle("jeta'", 2);
00276 
00277     name = "EBOT pedestal digi occupancy";
00278     meEBPedestalDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
00279     meEBPedestalDigiOccupancy_->setAxisTitle("jphi'", 1);
00280     meEBPedestalDigiOccupancy_->setAxisTitle("jeta'", 2);
00281 
00282   }
00283 
00284 }
00285 
00286 void EBOccupancyTask::cleanup(void){
00287 
00288   if ( ! init_ ) return;
00289 
00290   if ( dqmStore_ ) {
00291     dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask");
00292     if(subfolder_.size())
00293       dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask/" + subfolder_);
00294 
00295     for (int i = 0; i < 36; i++) {
00296       if ( meOccupancy_[i] ) dqmStore_->removeElement( meOccupancy_[i]->getName() );
00297       meOccupancy_[i] = 0;
00298       if ( meOccupancyMem_[i] ) dqmStore_->removeElement( meOccupancyMem_[i]->getName() );
00299       meOccupancyMem_[i] = 0;
00300       if ( meEBRecHitEnergy_[i] ) dqmStore_->removeElement( meEBRecHitEnergy_[i]->getName() );
00301       meEBRecHitEnergy_[i] = 0;
00302       if ( meSpectrum_[i] ) dqmStore_->removeElement( meSpectrum_[i]->getName() );
00303       meSpectrum_[i] = 0;
00304     }
00305 
00306     if ( meEBRecHitSpectrum_ ) dqmStore_->removeElement( meEBRecHitSpectrum_->getName() );
00307     meEBRecHitSpectrum_ = 0;
00308 
00309     if ( meEBDigiOccupancy_ ) dqmStore_->removeElement( meEBDigiOccupancy_->getName() );
00310     meEBDigiOccupancy_ = 0;
00311     if ( meEBDigiOccupancyProjEta_ ) dqmStore_->removeElement( meEBDigiOccupancyProjEta_->getName() );
00312     meEBDigiOccupancyProjEta_ = 0;
00313     if ( meEBDigiOccupancyProjPhi_ ) dqmStore_->removeElement( meEBDigiOccupancyProjPhi_->getName() );
00314     meEBDigiOccupancyProjPhi_ = 0;
00315 
00316     if ( meEBRecHitOccupancy_ ) dqmStore_->removeElement( meEBRecHitOccupancy_->getName() );
00317     meEBRecHitOccupancy_ = 0;
00318     if ( meEBRecHitOccupancyProjEta_ ) dqmStore_->removeElement( meEBRecHitOccupancyProjEta_->getName() );
00319     meEBRecHitOccupancyProjEta_ = 0;
00320     if ( meEBRecHitOccupancyProjPhi_ ) dqmStore_->removeElement( meEBRecHitOccupancyProjPhi_->getName() );
00321     meEBRecHitOccupancyProjPhi_ = 0;
00322 
00323     if ( meEBRecHitOccupancyThr_ ) dqmStore_->removeElement( meEBRecHitOccupancyThr_->getName() );
00324     meEBRecHitOccupancyThr_ = 0;
00325     if ( meEBRecHitOccupancyProjEtaThr_ ) dqmStore_->removeElement( meEBRecHitOccupancyProjEtaThr_->getName() );
00326     meEBRecHitOccupancyProjEtaThr_ = 0;
00327     if ( meEBRecHitOccupancyProjPhiThr_ ) dqmStore_->removeElement( meEBRecHitOccupancyProjPhiThr_->getName() );
00328     meEBRecHitOccupancyProjPhiThr_ = 0;
00329 
00330     if ( meEBTrigPrimDigiOccupancy_ ) dqmStore_->removeElement( meEBTrigPrimDigiOccupancy_->getName() );
00331     meEBTrigPrimDigiOccupancy_ = 0;
00332     if ( meEBTrigPrimDigiOccupancyProjEta_ ) dqmStore_->removeElement( meEBTrigPrimDigiOccupancyProjEta_->getName() );
00333     meEBTrigPrimDigiOccupancyProjEta_ = 0;
00334     if ( meEBTrigPrimDigiOccupancyProjPhi_ ) dqmStore_->removeElement( meEBTrigPrimDigiOccupancyProjPhi_->getName() );
00335     meEBTrigPrimDigiOccupancyProjPhi_ = 0;
00336 
00337     if ( meEBTrigPrimDigiOccupancyThr_ ) dqmStore_->removeElement( meEBTrigPrimDigiOccupancyThr_->getName() );
00338     meEBTrigPrimDigiOccupancyThr_ = 0;
00339     if ( meEBTrigPrimDigiOccupancyProjEtaThr_ ) dqmStore_->removeElement( meEBTrigPrimDigiOccupancyProjEtaThr_->getName() );
00340     meEBTrigPrimDigiOccupancyProjEtaThr_ = 0;
00341     if ( meEBTrigPrimDigiOccupancyProjPhiThr_ ) dqmStore_->removeElement( meEBTrigPrimDigiOccupancyProjPhiThr_->getName() );
00342     meEBTrigPrimDigiOccupancyProjPhiThr_ = 0;
00343 
00344     if ( meEBTestPulseDigiOccupancy_ ) dqmStore_->removeElement( meEBTestPulseDigiOccupancy_->getName() );
00345     meEBTestPulseDigiOccupancy_ = 0;
00346 
00347     if ( meEBLaserDigiOccupancy_ ) dqmStore_->removeElement( meEBLaserDigiOccupancy_->getName() );
00348     meEBLaserDigiOccupancy_ = 0;
00349 
00350     if ( meEBPedestalDigiOccupancy_ ) dqmStore_->removeElement( meEBPedestalDigiOccupancy_->getName() );
00351     meEBPedestalDigiOccupancy_ = 0;
00352 
00353   }
00354 
00355   init_ = false;
00356 
00357 }
00358 
00359 void EBOccupancyTask::endJob(void) {
00360 
00361   edm::LogInfo("EBOccupancyTask") << "analyzed " << ievt_ << " events";
00362 
00363   if ( enableCleanup_ ) this->cleanup();
00364 
00365 }
00366 
00367 void EBOccupancyTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00368 
00369   if ( ! init_ ) this->setup();
00370 
00371   ievt_++;
00372 
00373   int runType[36] = { notdata };
00374 
00375   edm::Handle<EcalRawDataCollection> dcchs;
00376 
00377   if (  e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00378 
00379     for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00380 
00381       if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
00382 
00383       int ism = Numbers::iSM( *dcchItr, EcalBarrel );
00384 
00385       int runtype = dcchItr->getRunType();
00386 
00387       if ( runtype == EcalDCCHeaderBlock::COSMIC ||
00388            runtype == EcalDCCHeaderBlock::MTCC ||
00389            runtype == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
00390            runtype == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
00391            runtype == EcalDCCHeaderBlock::COSMICS_LOCAL ||
00392            runtype == EcalDCCHeaderBlock::PHYSICS_LOCAL ) runType[ism-1] = physics;
00393       if ( runtype == EcalDCCHeaderBlock::TESTPULSE_MGPA ||
00394            runtype == EcalDCCHeaderBlock::TESTPULSE_GAP ) runType[ism-1] = testpulse;
00395       if ( runtype == EcalDCCHeaderBlock::LASER_STD ||
00396            runtype == EcalDCCHeaderBlock::LASER_GAP ) runType[ism-1] = laser;
00397       if ( runtype == EcalDCCHeaderBlock::PEDESTAL_STD ||
00398            runtype == EcalDCCHeaderBlock::PEDESTAL_GAP ) runType[ism-1] = pedestal;
00399 
00400     }
00401 
00402   } else {
00403     edm::LogWarning("EBOccupancyTask") << EcalRawDataCollection_ << " not available";
00404   }
00405 
00406   edm::Handle<EBDigiCollection> digis;
00407 
00408   if ( e.getByLabel(EBDigiCollection_, digis) ) {
00409 
00410     int nebd = digis->size();
00411     LogDebug("EBOccupancyTask") << "event " << ievt_ << " digi collection size " << nebd;
00412 
00413     for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
00414 
00415       EBDetId id = digiItr->id();
00416 
00417       int ic = id.ic();
00418       int ie = (ic-1)/20 + 1;
00419       int ip = (ic-1)%20 + 1;
00420 
00421       int ism = Numbers::iSM( id );
00422 
00423       float xie = ie - 0.5;
00424       float xip = ip - 0.5;
00425 
00426       if ( xie <= 0. || xie >= 85. || xip <= 0. || xip >= 20. ) {
00427         edm::LogWarning("EBOccupancyTask") << " det id = " << id;
00428         edm::LogWarning("EBOccupancyTask") << " sm, ieta, iphi " << ism << " " << ie << " " << ip;
00429         edm::LogWarning("EBOccupancyTask") << " xie, xip " << xie << " " << xip;
00430       }
00431 
00432       if ( meOccupancy_[ism-1] ) meOccupancy_[ism-1]->Fill(xie, xip);
00433 
00434       int ebeta = id.ieta();
00435       int ebphi = id.iphi();
00436 
00437       float xebeta = ebeta - 0.5*id.zside();
00438       float xebphi = ebphi - 0.5;
00439 
00440       if ( runType[ism-1] == physics || runType[ism-1] == notdata ) {
00441 
00442         if ( meEBDigiOccupancy_ ) meEBDigiOccupancy_->Fill( xebphi, xebeta );
00443         if ( meEBDigiOccupancyProjEta_ ) meEBDigiOccupancyProjEta_->Fill( xebeta );
00444         if ( meEBDigiOccupancyProjPhi_ ) meEBDigiOccupancyProjPhi_->Fill( xebphi );
00445 
00446       }
00447 
00448       if ( runType[ism-1] == testpulse ) {
00449 
00450         if ( meEBTestPulseDigiOccupancy_ ) meEBTestPulseDigiOccupancy_->Fill( xebphi, xebeta );
00451 
00452       }
00453 
00454       if ( runType[ism-1] == laser ) {
00455 
00456         if ( meEBLaserDigiOccupancy_ ) meEBLaserDigiOccupancy_->Fill( xebphi, xebeta );
00457 
00458       }
00459 
00460       if ( runType[ism-1] == pedestal ) {
00461 
00462         if ( meEBPedestalDigiOccupancy_ ) meEBPedestalDigiOccupancy_->Fill( xebphi, xebeta );
00463 
00464       }
00465 
00466     }
00467 
00468   } else {
00469 
00470     edm::LogWarning("EBOccupancyTask") << EBDigiCollection_ << " not available";
00471 
00472   }
00473 
00474   edm::Handle<EcalPnDiodeDigiCollection> PNs;
00475 
00476   if ( e.getByLabel(EcalPnDiodeDigiCollection_, PNs) ) {
00477 
00478     // filling mem occupancy only for the 5 channels belonging
00479     // to a fully reconstructed PN's
00480 
00481     for ( EcalPnDiodeDigiCollection::const_iterator pnItr = PNs->begin(); pnItr != PNs->end(); ++pnItr ) {
00482 
00483       if ( Numbers::subDet( pnItr->id() ) != EcalBarrel ) continue;
00484 
00485       int   ism   = Numbers::iSM( pnItr->id() );
00486 
00487       float PnId  = pnItr->id().iPnId();
00488 
00489       PnId        = PnId - 0.5;
00490       float st    = 0.0;
00491 
00492       for (int chInStrip = 1; chInStrip <= 5; chInStrip++){
00493         if ( meOccupancyMem_[ism-1] ) {
00494           st = chInStrip - 0.5;
00495           meOccupancyMem_[ism-1]->Fill(PnId, st);
00496         }
00497       }
00498 
00499     }
00500 
00501   } else {
00502 
00503     edm::LogWarning("EBOccupancyTask") << EcalPnDiodeDigiCollection_ << " not available";
00504 
00505   }
00506 
00507   edm::ESHandle<EcalSeverityLevelAlgo> sevlv;
00508   c.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
00509 
00510   edm::Handle<EcalRecHitCollection> rechits;
00511 
00512   if ( e.getByLabel(EcalRecHitCollection_, rechits) ) {
00513 
00514     int nebrh = rechits->size();
00515     LogDebug("EBOccupancyTask") << "event " << ievt_ << " rec hits collection size " << nebrh;
00516 
00517     for ( EcalRecHitCollection::const_iterator rechitItr = rechits->begin(); rechitItr != rechits->end(); ++rechitItr ) {
00518 
00519       EBDetId id = rechitItr->id();
00520 
00521       // global coordinates
00522       int ebeta = id.ieta();
00523       int ebphi = id.iphi();
00524 
00525       float xebeta = ebeta - 0.5*id.zside();
00526       float xebphi = ebphi - 0.5;
00527 
00528       int ism = Numbers::iSM( id );
00529 
00530       // local coordinates
00531       int ic = id.ic();
00532       int ie = (ic-1)/20 + 1;
00533       int ip = (ic-1)%20 + 1;
00534 
00535       float xie = ie - 0.5;
00536       float xip = ip - 0.5;
00537 
00538       if ( runType[ism-1] == physics || runType[ism-1] == notdata ) {
00539 
00540         if ( meEBRecHitOccupancy_ ) meEBRecHitOccupancy_->Fill( xebphi, xebeta );
00541         if ( meEBRecHitOccupancyProjEta_ ) meEBRecHitOccupancyProjEta_->Fill( xebeta );
00542         if ( meEBRecHitOccupancyProjPhi_ ) meEBRecHitOccupancyProjPhi_->Fill( xebphi );
00543 
00544         uint32_t flag = rechitItr->recoFlag();
00545         
00546         uint32_t sev = sevlv->severityLevel( id, *rechits);
00547 
00548         if ( rechitItr->energy() > recHitEnergyMin_ && flag == EcalRecHit::kGood && sev == EcalSeverityLevel::kGood ) {
00549 
00550           if ( meEBRecHitOccupancyThr_ ) meEBRecHitOccupancyThr_->Fill( xebphi, xebeta );
00551           if ( meEBRecHitOccupancyProjEtaThr_ ) meEBRecHitOccupancyProjEtaThr_->Fill( xebeta );
00552           if ( meEBRecHitOccupancyProjPhiThr_ ) meEBRecHitOccupancyProjPhiThr_->Fill( xebphi );
00553 
00554         }
00555 
00556         if ( flag == EcalRecHit::kGood && sev == EcalSeverityLevel::kGood ) {
00557           if ( meEBRecHitEnergy_[ism-1] ) meEBRecHitEnergy_[ism-1]->Fill( xie, xip, rechitItr->energy() );
00558           if ( meSpectrum_[ism-1] ) meSpectrum_[ism-1]->Fill( rechitItr->energy() );
00559           if ( meEBRecHitSpectrum_ ) meEBRecHitSpectrum_->Fill( rechitItr->energy() );
00560         }
00561 
00562       }
00563     }
00564 
00565   } else {
00566 
00567     edm::LogWarning("EBOccupancyTask") << EcalRecHitCollection_ << " not available";
00568 
00569   }
00570 
00571   edm::Handle<EcalTrigPrimDigiCollection> trigPrimDigis;
00572 
00573   if ( e.getByLabel(EcalTrigPrimDigiCollection_, trigPrimDigis) ) {
00574 
00575     int nebtpg = trigPrimDigis->size();
00576     LogDebug("EBOccupancyTask") << "event " << ievt_ << " trigger primitives digis collection size " << nebtpg;
00577 
00578     for ( EcalTrigPrimDigiCollection::const_iterator tpdigiItr = trigPrimDigis->begin(); tpdigiItr != trigPrimDigis->end(); ++tpdigiItr ) {
00579 
00580       if ( Numbers::subDet( tpdigiItr->id() ) != EcalBarrel ) continue;
00581 
00582       int ebeta = tpdigiItr->id().ieta();
00583       int ebphi = tpdigiItr->id().iphi();
00584 
00585       // phi_tower: change the range from global to SM-local
00586       // phi==0 is in the middle of a SM
00587       ebphi = ebphi + 2;
00588       if ( ebphi > 72 ) ebphi = ebphi - 72;
00589 
00590       float xebeta = ebeta-0.5*tpdigiItr->id().zside();
00591       float xebphi = ebphi-0.5;
00592 
00593       int ism = Numbers::iSM( tpdigiItr->id() );
00594 
00595       if ( runType[ism-1] == physics || runType[ism-1] == notdata ) {
00596 
00597         if ( meEBTrigPrimDigiOccupancy_ ) meEBTrigPrimDigiOccupancy_->Fill( xebphi, xebeta );
00598         if ( meEBTrigPrimDigiOccupancyProjEta_ ) meEBTrigPrimDigiOccupancyProjEta_->Fill( xebeta );
00599         if ( meEBTrigPrimDigiOccupancyProjPhi_ ) meEBTrigPrimDigiOccupancyProjPhi_->Fill( xebphi );
00600 
00601         if ( tpdigiItr->compressedEt() > trigPrimEtMin_ ) {
00602 
00603           if ( meEBTrigPrimDigiOccupancyThr_ ) meEBTrigPrimDigiOccupancyThr_->Fill( xebphi, xebeta );
00604           if ( meEBTrigPrimDigiOccupancyProjEtaThr_ ) meEBTrigPrimDigiOccupancyProjEtaThr_->Fill( xebeta );
00605           if ( meEBTrigPrimDigiOccupancyProjPhiThr_ ) meEBTrigPrimDigiOccupancyProjPhiThr_->Fill( xebphi );
00606 
00607         }
00608       }
00609     }
00610 
00611   } else {
00612 
00613     edm::LogWarning("EBOccupancyTask") << EcalTrigPrimDigiCollection_ << " not available";
00614 
00615   }
00616 
00617 }
00618