00001
00002
00003
00004
00005
00006
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/EcalRawData/interface/EcalRawDataCollections.h"
00022
00023 #include <DQM/EcalCommon/interface/Numbers.h>
00024
00025 #include <DQM/EcalBarrelMonitorTasks/interface/EBStatusFlagsTask.h>
00026
00027 using namespace cms;
00028 using namespace edm;
00029 using namespace std;
00030
00031 EBStatusFlagsTask::EBStatusFlagsTask(const ParameterSet& ps){
00032
00033 init_ = false;
00034
00035 dqmStore_ = Service<DQMStore>().operator->();
00036
00037 prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
00038
00039 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00040
00041 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00042
00043 EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
00044
00045 for (int i = 0; i < 36; i++) {
00046 meEvtType_[i] = 0;
00047
00048 meFEchErrors_[i][0] = 0;
00049 meFEchErrors_[i][1] = 0;
00050 }
00051
00052 }
00053
00054 EBStatusFlagsTask::~EBStatusFlagsTask(){
00055
00056 }
00057
00058 void EBStatusFlagsTask::beginJob(const EventSetup& c){
00059
00060 ievt_ = 0;
00061
00062 if ( dqmStore_ ) {
00063 dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask");
00064 dqmStore_->rmdir(prefixME_ + "/EBStatusFlagsTask");
00065 }
00066
00067 Numbers::initGeometry(c, false);
00068
00069 }
00070
00071 void EBStatusFlagsTask::beginRun(const Run& r, const EventSetup& c) {
00072
00073 if ( ! mergeRuns_ ) this->reset();
00074
00075 }
00076
00077 void EBStatusFlagsTask::endRun(const Run& r, const EventSetup& c) {
00078
00079 }
00080
00081 void EBStatusFlagsTask::reset(void) {
00082
00083 for (int i = 0; i < 36; i++) {
00084 if ( meEvtType_[i] ) meEvtType_[i]->Reset();
00085
00086 if ( meFEchErrors_[i][0] ) meFEchErrors_[i][0]->Reset();
00087 if ( meFEchErrors_[i][1] ) meFEchErrors_[i][1]->Reset();
00088 }
00089
00090 }
00091
00092 void EBStatusFlagsTask::setup(void){
00093
00094 init_ = true;
00095
00096 char histo[200];
00097
00098 if ( dqmStore_ ) {
00099 dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask");
00100
00101 dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask/EvtType");
00102 for (int i = 0; i < 36; i++) {
00103 sprintf(histo, "EBSFT EVTTYPE %s", Numbers::sEB(i+1).c_str());
00104 meEvtType_[i] = dqmStore_->book1D(histo, histo, 31, -1., 30.);
00105 meEvtType_[i]->setBinLabel(1, "UNKNOWN", 1);
00106 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::COSMIC, "COSMIC", 1);
00107 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::BEAMH4, "BEAMH4", 1);
00108 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::BEAMH2, "BEAMH2", 1);
00109 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::MTCC, "MTCC", 1);
00110 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_STD, "LASER_STD", 1);
00111 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
00112 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
00113 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
00114 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_MGPA, "TESTPULSE_MGPA", 1);
00115 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_STD, "PEDESTAL_STD", 1);
00116 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
00117 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
00118 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LED_STD, "LED_STD", 1);
00119 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL, "PHYSICS_GLOBAL", 1);
00120 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_GLOBAL, "COSMICS_GLOBAL", 1);
00121 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::HALO_GLOBAL, "HALO_GLOBAL", 1);
00122 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LASER_GAP, "LASER_GAP", 1);
00123 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_GAP, "TESTPULSE_GAP");
00124 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_GAP, "PEDESTAL_GAP");
00125 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::LED_GAP, "LED_GAP", 1);
00126 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_LOCAL, "PHYSICS_LOCAL", 1);
00127 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_LOCAL, "COSMICS_LOCAL", 1);
00128 meEvtType_[i]->setBinLabel(2+EcalDCCHeaderBlock::HALO_LOCAL, "HALO_LOCAL", 1);
00129 dqmStore_->tag(meEvtType_[i], i+1);
00130 }
00131
00132 dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask/FEStatus");
00133 for (int i = 0; i < 36; i++) {
00134 sprintf(histo, "EBSFT front-end status %s", Numbers::sEB(i+1).c_str());
00135 meFEchErrors_[i][0] = dqmStore_->book2D(histo, histo, 17, 0., 17., 4, 0., 4.);
00136 meFEchErrors_[i][0]->setAxisTitle("ieta'", 1);
00137 meFEchErrors_[i][0]->setAxisTitle("iphi'", 2);
00138 dqmStore_->tag(meFEchErrors_[i][0], i+1);
00139
00140 for ( int ie = 1; ie <= 17; ie++ ) {
00141 for ( int ip = 1; ip <= 4; ip++ ) {
00142 meFEchErrors_[i][0]->setBinContent( ie, ip, -1. );
00143 }
00144 }
00145 meFEchErrors_[i][0]->setEntries( 0 );
00146
00147 sprintf(histo, "EBSFT front-end status bits %s", Numbers::sEB(i+1).c_str());
00148 meFEchErrors_[i][1] = dqmStore_->book1D(histo, histo, 16, 0., 16.);
00149 meFEchErrors_[i][1]->setBinLabel(1+0, "ACTIVE", 1);
00150 meFEchErrors_[i][1]->setBinLabel(1+1, "DISABLED", 1);
00151 meFEchErrors_[i][1]->setBinLabel(1+2, "TIMEOUT", 1);
00152 meFEchErrors_[i][1]->setBinLabel(1+3, "HEADER", 1);
00153 meFEchErrors_[i][1]->setBinLabel(1+4, "CHANNEL ID", 1);
00154 meFEchErrors_[i][1]->setBinLabel(1+5, "LINK", 1);
00155 meFEchErrors_[i][1]->setBinLabel(1+6, "BLOCKSIZE", 1);
00156 meFEchErrors_[i][1]->setBinLabel(1+7, "SUPPRESSED", 1);
00157 meFEchErrors_[i][1]->setBinLabel(1+8, "FIFO FULL", 1);
00158 meFEchErrors_[i][1]->setBinLabel(1+9, "L1A SYNC", 1);
00159 meFEchErrors_[i][1]->setBinLabel(1+10, "BX SYNC", 1);
00160 meFEchErrors_[i][1]->setBinLabel(1+11, "L1A+BX SYNC", 1);
00161 meFEchErrors_[i][1]->setBinLabel(1+12, "FIFO+L1A", 1);
00162 meFEchErrors_[i][1]->setBinLabel(1+13, "H PARITY", 1);
00163 meFEchErrors_[i][1]->setBinLabel(1+14, "V PARITY", 1);
00164 meFEchErrors_[i][1]->setBinLabel(1+15, "H+V PARITY", 1);
00165 dqmStore_->tag(meFEchErrors_[i][1], i+1);
00166 }
00167
00168 }
00169
00170 }
00171
00172 void EBStatusFlagsTask::cleanup(void){
00173
00174 if ( ! init_ ) return;
00175
00176 if ( dqmStore_ ) {
00177 dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask");
00178
00179 dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask/EvtType");
00180 for (int i = 0; i < 36; i++) {
00181 if ( meEvtType_[i] ) dqmStore_->removeElement( meEvtType_[i]->getName() );
00182 meEvtType_[i] = 0;
00183 }
00184
00185 dqmStore_->setCurrentFolder(prefixME_ + "/EBStatusFlagsTask/FEStatus");
00186 for (int i = 0; i < 36; i++) {
00187 if ( meFEchErrors_[i][0] ) dqmStore_->removeElement( meFEchErrors_[i][0]->getName() );
00188 meFEchErrors_[i][0] = 0;
00189 if ( meFEchErrors_[i][1] ) dqmStore_->removeElement( meFEchErrors_[i][1]->getName() );
00190 meFEchErrors_[i][1] = 0;
00191 }
00192
00193 }
00194
00195 init_ = false;
00196
00197 }
00198
00199 void EBStatusFlagsTask::endJob(void){
00200
00201 LogInfo("EBStatusFlagsTask") << "analyzed " << ievt_ << " events";
00202
00203 if ( enableCleanup_ ) this->cleanup();
00204
00205 }
00206
00207 void EBStatusFlagsTask::analyze(const Event& e, const EventSetup& c){
00208
00209 if ( ! init_ ) this->setup();
00210
00211 ievt_++;
00212
00213 Handle<EcalRawDataCollection> dcchs;
00214
00215 if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00216
00217 for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00218
00219 if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
00220
00221 int ism = Numbers::iSM( *dcchItr, EcalBarrel );
00222
00223 if ( meEvtType_[ism-1] ) meEvtType_[ism-1]->Fill(dcchItr->getRunType()+0.5);
00224
00225 const vector<short> status = dcchItr->getFEStatus();
00226
00227 for ( unsigned int itt=1; itt<=status.size(); itt++ ) {
00228
00229 if ( itt > 68 ) continue;
00230
00231 int iet = (itt-1)/4 + 1;
00232 int ipt = (itt-1)%4 + 1;
00233
00234 float xiet = iet - 0.5;
00235 float xipt = ipt - 0.5;
00236
00237 if ( meFEchErrors_[ism-1][0] ) {
00238 if ( meFEchErrors_[ism-1][0]->getBinContent(iet, ipt) == -1 ) {
00239 meFEchErrors_[ism-1][0]->setBinContent(iet, ipt, 0);
00240 }
00241 }
00242
00243 if ( ! ( status[itt-1] == 0 || status[itt-1] == 1 || status[itt-1] == 7 ) ) {
00244 if ( meFEchErrors_[ism-1][0] ) meFEchErrors_[ism-1][0]->Fill(xiet, xipt);
00245 }
00246
00247 if ( meFEchErrors_[ism-1][1] ) meFEchErrors_[ism-1][1]->Fill(status[itt-1]+0.5);
00248
00249 }
00250
00251 }
00252
00253 } else {
00254
00255 LogWarning("EBStatusFlagsTask") << EcalRawDataCollection_ << " not available";
00256
00257 }
00258
00259 }
00260