CMS 3D CMS Logo

EBPedestalOnlineTask.cc

Go to the documentation of this file.
00001 /*
00002  * \file EBPedestalOnlineTask.cc
00003  *
00004  * $Date: 2008/12/03 15:03:16 $
00005  * $Revision: 1.42 $
00006  * \author G. Della Ricca
00007  *
00008 */
00009 
00010 #include <iostream>
00011 #include <fstream>
00012 #include <vector>
00013 
00014 #include "FWCore/ServiceRegistry/interface/Service.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016 
00017 #include "DQMServices/Core/interface/MonitorElement.h"
00018 
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020 
00021 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00022 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
00023 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00024 
00025 #include <DQM/EcalCommon/interface/Numbers.h>
00026 
00027 #include <DQM/EcalBarrelMonitorTasks/interface/EBPedestalOnlineTask.h>
00028 
00029 using namespace cms;
00030 using namespace edm;
00031 using namespace std;
00032 
00033 EBPedestalOnlineTask::EBPedestalOnlineTask(const ParameterSet& ps){
00034 
00035   init_ = false;
00036 
00037   dqmStore_ = Service<DQMStore>().operator->();
00038 
00039   prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
00040 
00041   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00042 
00043   mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00044 
00045   EBDigiCollection_ = ps.getParameter<edm::InputTag>("EBDigiCollection");
00046 
00047   for (int i = 0; i < 36; i++) {
00048     mePedMapG12_[i] = 0;
00049   }
00050 
00051 }
00052 
00053 EBPedestalOnlineTask::~EBPedestalOnlineTask(){
00054 
00055 }
00056 
00057 void EBPedestalOnlineTask::beginJob(const EventSetup& c){
00058 
00059   ievt_ = 0;
00060 
00061   if ( dqmStore_ ) {
00062     dqmStore_->setCurrentFolder(prefixME_ + "/EBPedestalOnlineTask");
00063     dqmStore_->rmdir(prefixME_ + "/EBPedestalOnlineTask");
00064   }
00065 
00066   Numbers::initGeometry(c, false);
00067 
00068 }
00069 
00070 void EBPedestalOnlineTask::beginRun(const Run& r, const EventSetup& c) {
00071 
00072   if ( ! mergeRuns_ ) this->reset();
00073 
00074 }
00075 
00076 void EBPedestalOnlineTask::endRun(const Run& r, const EventSetup& c) {
00077 
00078 }
00079 
00080 void EBPedestalOnlineTask::reset(void) {
00081 
00082   for (int i = 0; i < 36; i++) {
00083     if ( mePedMapG12_[i] ) mePedMapG12_[i]->Reset();
00084   }
00085 
00086 }
00087 
00088 void EBPedestalOnlineTask::setup(void){
00089 
00090   init_ = true;
00091 
00092   char histo[200];
00093 
00094   if ( dqmStore_ ) {
00095     dqmStore_->setCurrentFolder(prefixME_ + "/EBPedestalOnlineTask");
00096 
00097     dqmStore_->setCurrentFolder(prefixME_ + "/EBPedestalOnlineTask/Gain12");
00098     for (int i = 0; i < 36; i++) {
00099       sprintf(histo, "EBPOT pedestal %s G12", Numbers::sEB(i+1).c_str());
00100       mePedMapG12_[i] = dqmStore_->bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 4096, 0., 4096., "s");
00101       mePedMapG12_[i]->setAxisTitle("ieta", 1);
00102       mePedMapG12_[i]->setAxisTitle("iphi", 2);
00103       dqmStore_->tag(mePedMapG12_[i], i+1);
00104     }
00105 
00106   }
00107 
00108 }
00109 
00110 void EBPedestalOnlineTask::cleanup(void){
00111 
00112   if ( ! init_ ) return;
00113 
00114   if ( dqmStore_ ) {
00115     dqmStore_->setCurrentFolder(prefixME_ + "/EBPedestalOnlineTask");
00116 
00117     dqmStore_->setCurrentFolder(prefixME_ + "/EBPedestalOnlineTask/Gain12");
00118     for ( int i = 0; i < 36; i++ ) {
00119       if ( mePedMapG12_[i] ) dqmStore_->removeElement( mePedMapG12_[i]->getName() );
00120       mePedMapG12_[i] = 0;
00121     }
00122 
00123   }
00124 
00125   init_ = false;
00126 
00127 }
00128 
00129 void EBPedestalOnlineTask::endJob(void){
00130 
00131   LogInfo("EBPedestalOnlineTask") << "analyzed " << ievt_ << " events";
00132 
00133   if ( enableCleanup_ ) this->cleanup();
00134 
00135 }
00136 
00137 void EBPedestalOnlineTask::analyze(const Event& e, const EventSetup& c){
00138 
00139   if ( ! init_ ) this->setup();
00140 
00141   ievt_++;
00142 
00143   Handle<EBDigiCollection> digis;
00144 
00145   if ( e.getByLabel(EBDigiCollection_, digis) ) {
00146 
00147     int nebd = digis->size();
00148     LogDebug("EBPedestalOnlineTask") << "event " << ievt_ << " digi collection size " << nebd;
00149 
00150     for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
00151 
00152       EBDetId id = digiItr->id();
00153 
00154       int ic = id.ic();
00155       int ie = (ic-1)/20 + 1;
00156       int ip = (ic-1)%20 + 1;
00157 
00158       int ism = Numbers::iSM( id );
00159 
00160       float xie = ie - 0.5;
00161       float xip = ip - 0.5;
00162 
00163       LogDebug("EBPedestalOnlineTask") << " det id = " << id;
00164       LogDebug("EBPedestalOnlineTask") << " sm, ieta, iphi " << ism << " " << ie << " " << ip;
00165 
00166       EBDataFrame dataframe = (*digiItr);
00167 
00168       for (int i = 0; i < 3; i++) {
00169 
00170         int adc = dataframe.sample(i).adc();
00171 
00172         MonitorElement* mePedMap = 0;
00173 
00174         if ( dataframe.sample(i).gainId() == 1 ) mePedMap = mePedMapG12_[ism-1];
00175         if ( dataframe.sample(i).gainId() == 2 ) mePedMap = 0;
00176         if ( dataframe.sample(i).gainId() == 3 ) mePedMap = 0;
00177 
00178         float xval = float(adc);
00179 
00180         if ( mePedMap ) mePedMap->Fill(xie, xip, xval);
00181 
00182       }
00183 
00184     }
00185 
00186   } else {
00187 
00188     LogWarning("EBPedestalOnlineTask") << EBDigiCollection_ << " not available";
00189 
00190   }
00191 
00192 }
00193 

Generated on Tue Jun 9 17:32:46 2009 for CMSSW by  doxygen 1.5.4