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