CMS 3D CMS Logo

EEStatusFlagsTask.cc

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

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