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 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
00017
00018 #include "DQMServices/Core/interface/MonitorElement.h"
00019
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021
00022 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
00023 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00024
00025 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00026
00027 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
00028 #include "DataFormats/EcalDetId/interface/EcalDetIdCollections.h"
00029
00030 #include "DQM/EcalEndcapMonitorTasks/interface/EEHltTask.h"
00031
00032 EEHltTask::EEHltTask(const edm::ParameterSet& ps){
00033
00034 init_ = false;
00035
00036 initGeometry_ = false;
00037
00038 dqmStore_ = edm::Service<DQMStore>().operator->();
00039
00040 prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00041
00042 folderName_ = ps.getUntrackedParameter<std::string>("folderName", "FEDIntegrity");
00043
00044 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00045
00046 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00047
00048 EEDetIdCollection0_ = ps.getParameter<edm::InputTag>("EEDetIdCollection0");
00049 EEDetIdCollection1_ = ps.getParameter<edm::InputTag>("EEDetIdCollection1");
00050 EEDetIdCollection2_ = ps.getParameter<edm::InputTag>("EEDetIdCollection2");
00051 EEDetIdCollection3_ = ps.getParameter<edm::InputTag>("EEDetIdCollection3");
00052 EcalElectronicsIdCollection1_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection1");
00053 EcalElectronicsIdCollection2_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection2");
00054 EcalElectronicsIdCollection3_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection3");
00055 EcalElectronicsIdCollection4_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection4");
00056 EcalElectronicsIdCollection5_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection5");
00057 EcalElectronicsIdCollection6_ = ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection6");
00058 FEDRawDataCollection_ = ps.getParameter<edm::InputTag>("FEDRawDataCollection");
00059
00060 meEEFedsOccupancy_ = 0;
00061 meEEFedsSizeErrors_ = 0;
00062 meEEFedsIntegrityErrors_ = 0;
00063
00064 map = 0;
00065
00066 }
00067
00068 EEHltTask::~EEHltTask(){
00069
00070 }
00071
00072 void EEHltTask::beginJob(void){
00073
00074 ievt_ = 0;
00075
00076 if ( dqmStore_ ) {
00077 dqmStore_->setCurrentFolder(prefixME_ + "/" + folderName_);
00078 dqmStore_->rmdir(prefixME_ + "/" + folderName_);
00079 }
00080
00081 }
00082
00083 void EEHltTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00084
00085 initGeometry(c);
00086
00087 if ( ! mergeRuns_ ) this->reset();
00088
00089 }
00090
00091 void EEHltTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00092
00093 }
00094
00095 void EEHltTask::reset(void) {
00096
00097 if ( meEEFedsOccupancy_ ) meEEFedsOccupancy_->Reset();
00098 if ( meEEFedsSizeErrors_ ) meEEFedsSizeErrors_->Reset();
00099 if ( meEEFedsIntegrityErrors_ ) meEEFedsIntegrityErrors_->Reset();
00100
00101 }
00102
00103 void EEHltTask::setup(void){
00104
00105 init_ = true;
00106
00107 char histo[200];
00108
00109 if ( dqmStore_ ) {
00110 dqmStore_->setCurrentFolder(prefixME_ + "/" + folderName_);
00111
00112 sprintf(histo, "FEDEntries");
00113 meEEFedsOccupancy_ = dqmStore_->book1D(histo, histo, 54, 601, 655);
00114
00115 sprintf(histo, "FEDFatal");
00116 meEEFedsSizeErrors_ = dqmStore_->book1D(histo, histo, 54, 601, 655);
00117
00118 sprintf(histo, "FEDNonFatal");
00119 meEEFedsIntegrityErrors_ = dqmStore_->book1D(histo, histo, 54, 601, 655);
00120
00121 }
00122
00123 }
00124
00125 void EEHltTask::cleanup(void){
00126
00127 if ( ! init_ ) return;
00128
00129 if ( dqmStore_ ) {
00130 dqmStore_->setCurrentFolder(prefixME_ + "/" + folderName_);
00131
00132 if ( meEEFedsOccupancy_ ) dqmStore_->removeElement( meEEFedsOccupancy_->getName() );
00133 meEEFedsOccupancy_ = 0;
00134
00135 if ( meEEFedsSizeErrors_ ) dqmStore_->removeElement( meEEFedsSizeErrors_->getName() );
00136 meEEFedsSizeErrors_ = 0;
00137
00138 if ( meEEFedsIntegrityErrors_ ) dqmStore_->removeElement( meEEFedsIntegrityErrors_->getName() );
00139 meEEFedsIntegrityErrors_ = 0;
00140
00141 }
00142
00143 init_ = false;
00144
00145 }
00146
00147 void EEHltTask::endJob(void){
00148
00149 edm::LogInfo("EEHltTask") << "analyzed " << ievt_ << " events";
00150
00151 if ( enableCleanup_ ) this->cleanup();
00152
00153 }
00154
00155 void EEHltTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00156
00157 if ( ! init_ ) this->setup();
00158
00159 ievt_++;
00160
00161
00162 int EEFirstFED[2];
00163 EEFirstFED[0] = 601;
00164 EEFirstFED[1] = 646;
00165
00166 int FedsSizeErrors[18];
00167 for ( int i=0; i<18; i++ ) FedsSizeErrors[i]=0;
00168
00169 edm::Handle<EEDetIdCollection> ids0;
00170
00171 if ( e.getByLabel(EEDetIdCollection0_, ids0) ) {
00172
00173 for ( EEDetIdCollection::const_iterator idItr = ids0->begin(); idItr != ids0->end(); ++idItr ) {
00174
00175 int ism = iSM( *idItr );
00176
00177 if ( ism > -1 ) FedsSizeErrors[ism-1]++;
00178
00179 }
00180
00181 } else {
00182
00183
00184
00185 }
00186
00187 edm::Handle<FEDRawDataCollection> allFedRawData;
00188
00189 if ( e.getByLabel(FEDRawDataCollection_, allFedRawData) ) {
00190
00191 for(int zside=0; zside<2; zside++) {
00192
00193 int firstFedOnSide=EEFirstFED[zside];
00194
00195 for ( int ism=1; ism<=9; ism++ ) {
00196
00197 const FEDRawData& fedData = allFedRawData->FEDData( firstFedOnSide + ism - 1 );
00198
00199 int length = fedData.size()/sizeof(uint64_t);
00200
00201 if ( length > 0 ) {
00202
00203 if ( meEEFedsOccupancy_ ) meEEFedsOccupancy_->Fill( firstFedOnSide + ism - 1 );
00204
00205 uint64_t * pData = (uint64_t *)(fedData.data());
00206 uint64_t * fedTrailer = pData + (length - 1);
00207 bool crcError = (*fedTrailer >> 2 ) & 0x1;
00208
00209 if (crcError) FedsSizeErrors[ism-1]++;
00210
00211 }
00212
00213 }
00214
00215 }
00216
00217 } else {
00218 edm::LogWarning("EEHltTask") << FEDRawDataCollection_ << " not available";
00219 }
00220
00221
00222 for( int ism=1; ism<=18; ism++ ) {
00223
00224 if ( FedsSizeErrors[ism-1] != 0 ) {
00225
00226 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00227
00228 if ( meEEFedsSizeErrors_ ) meEEFedsSizeErrors_->Fill( fednumber );
00229
00230 }
00231
00232 }
00233
00234
00235
00236 edm::Handle<EEDetIdCollection> ids1;
00237
00238 if ( e.getByLabel(EEDetIdCollection1_, ids1) ) {
00239
00240 for ( EEDetIdCollection::const_iterator idItr = ids1->begin(); idItr != ids1->end(); ++idItr ) {
00241
00242 int ism = iSM( *idItr );
00243 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00244
00245 if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
00246
00247 }
00248
00249 } else {
00250
00251 edm::LogWarning("EEHltTask") << EEDetIdCollection1_ << " not available";
00252
00253 }
00254
00255 edm::Handle<EEDetIdCollection> ids2;
00256
00257 if ( e.getByLabel(EEDetIdCollection2_, ids2) ) {
00258
00259 for ( EEDetIdCollection::const_iterator idItr = ids2->begin(); idItr != ids2->end(); ++idItr ) {
00260
00261 int ism = iSM( *idItr );
00262 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00263
00264 if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
00265
00266 }
00267
00268 } else {
00269
00270 edm::LogWarning("EEHltTask") << EEDetIdCollection2_ << " not available";
00271
00272 }
00273
00274 edm::Handle<EEDetIdCollection> ids3;
00275
00276 if ( e.getByLabel(EEDetIdCollection3_, ids3) ) {
00277
00278 for ( EEDetIdCollection::const_iterator idItr = ids3->begin(); idItr != ids3->end(); ++idItr ) {
00279
00280 int ism = iSM( *idItr );
00281 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00282
00283 if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
00284
00285 }
00286
00287 } else {
00288
00289 edm::LogWarning("EEHltTask") << EEDetIdCollection3_ << " not available";
00290
00291 }
00292
00293 edm::Handle<EcalElectronicsIdCollection> ids4;
00294
00295 if ( e.getByLabel(EcalElectronicsIdCollection1_, ids4) ) {
00296
00297 for ( EcalElectronicsIdCollection::const_iterator idItr = ids4->begin(); idItr != ids4->end(); ++idItr ) {
00298
00299 if ( subDet( *idItr ) != EcalEndcap ) continue;
00300
00301 int ism = iSM( *idItr );
00302 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00303
00304 if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./34.);
00305
00306 }
00307
00308 } else {
00309
00310 edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection1_ << " not available";
00311
00312 }
00313
00314 edm::Handle<EcalElectronicsIdCollection> ids5;
00315
00316 if ( e.getByLabel(EcalElectronicsIdCollection2_, ids5) ) {
00317
00318 for ( EcalElectronicsIdCollection::const_iterator idItr = ids5->begin(); idItr != ids5->end(); ++idItr ) {
00319
00320 if ( subDet( *idItr ) != EcalEndcap ) continue;
00321
00322 int ism = iSM( *idItr );
00323 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00324
00325 if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
00326
00327 }
00328
00329 } else {
00330
00331 edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection2_ << " not available";
00332
00333 }
00334
00335 edm::Handle<EcalElectronicsIdCollection> ids6;
00336
00337 if ( e.getByLabel(EcalElectronicsIdCollection3_, ids6) ) {
00338
00339 for ( EcalElectronicsIdCollection::const_iterator idItr = ids6->begin(); idItr != ids6->end(); ++idItr ) {
00340
00341 if ( subDet( *idItr ) != EcalEndcap ) continue;
00342
00343 int ism = iSM( *idItr );
00344 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00345
00346 if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./34.);
00347
00348 }
00349
00350 } else {
00351
00352 edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection3_ << " not available";
00353
00354 }
00355
00356 edm::Handle<EcalElectronicsIdCollection> ids7;
00357
00358 if ( e.getByLabel(EcalElectronicsIdCollection4_, ids7) ) {
00359
00360 for ( EcalElectronicsIdCollection::const_iterator idItr = ids7->begin(); idItr != ids7->end(); ++idItr ) {
00361
00362 if ( subDet( *idItr ) != EcalEndcap ) continue;
00363
00364 int ism = iSM( *idItr );
00365 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00366
00367 if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
00368
00369 }
00370
00371 } else {
00372
00373 edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection4_ << " not available";
00374
00375 }
00376
00377 edm::Handle<EcalElectronicsIdCollection> ids8;
00378
00379 if ( e.getByLabel(EcalElectronicsIdCollection5_, ids8) ) {
00380
00381 for ( EcalElectronicsIdCollection::const_iterator idItr = ids8->begin(); idItr != ids8->end(); ++idItr ) {
00382
00383 if ( subDet( *idItr ) != EcalEndcap ) continue;
00384
00385 int ism = iSM( *idItr );
00386 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00387
00388 if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
00389
00390 }
00391
00392 } else {
00393
00394 edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection5_ << " not available";
00395
00396 }
00397
00398 edm::Handle<EcalElectronicsIdCollection> ids9;
00399
00400 if ( e.getByLabel(EcalElectronicsIdCollection6_, ids9) ) {
00401
00402 for ( EcalElectronicsIdCollection::const_iterator idItr = ids9->begin(); idItr != ids9->end(); ++idItr ) {
00403
00404 if ( subDet( *idItr ) != EcalEndcap ) continue;
00405
00406 int ism = iSM( *idItr );
00407 int fednumber = ( ism < 10 ) ? 600 + ism : 636 + ism;
00408
00409 if ( ism > -1 ) meEEFedsIntegrityErrors_->Fill( fednumber, 1./850.);
00410
00411 }
00412
00413 } else {
00414
00415 edm::LogWarning("EEHltTask") << EcalElectronicsIdCollection6_ << " not available";
00416
00417 }
00418
00419 }
00420
00421
00422
00423 void EEHltTask::initGeometry( const edm::EventSetup& setup ) {
00424
00425 if( initGeometry_ ) return;
00426
00427 initGeometry_ = true;
00428
00429 edm::ESHandle< EcalElectronicsMapping > handle;
00430 setup.get< EcalMappingRcd >().get(handle);
00431 map = handle.product();
00432
00433 if( ! map ) edm::LogWarning("EEHltTask") << "EcalElectronicsMapping not available";
00434
00435 }
00436
00437 int EEHltTask::iSM( const EEDetId& id ) {
00438
00439 if( ! map ) return -1;
00440
00441 EcalElectronicsId eid = map->getElectronicsId(id);
00442 int idcc = eid.dccId();
00443
00444
00445 if( idcc >= 1 && idcc <= 9 ) return( idcc );
00446
00447
00448 if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
00449
00450 edm::LogWarning("EEHltTask") << "Wrong DCC id: dcc = " << idcc;
00451 return -1;
00452
00453 }
00454
00455 int EEHltTask::iSM( const EcalElectronicsId& id ) {
00456
00457 int idcc = id.dccId();
00458
00459
00460 if( idcc >= 1 && idcc <= 9 ) return( idcc );
00461
00462
00463 if( idcc >= 46 && idcc <= 54 ) return( idcc - 45 + 9 );
00464
00465 edm::LogWarning("EEHltTask") << "Wrong DCC id: dcc = " << idcc;
00466 return -1;
00467
00468 }
00469