CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DQM/EcalEndcapMonitorTasks/src/EERawDataTask.cc

Go to the documentation of this file.
00001 /*
00002  * \file EERawDataTask.cc
00003  *
00004  * $Date: 2012/03/20 20:26:50 $
00005  * $Revision: 1.38.2.1 $
00006  * \author E. Di Marco
00007  *
00008 */
00009 
00010 #include <iostream>
00011 #include <vector>
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/FEDRawData/interface/FEDRawData.h"
00021 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00022 #include "DataFormats/FEDRawData/interface/FEDHeader.h"
00023 #include "DataFormats/FEDRawData/interface/FEDTrailer.h"
00024 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00025 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
00026 #include "DataFormats/FEDRawData/src/fed_header.h"
00027 
00028 #include "DQM/EcalCommon/interface/Numbers.h"
00029 
00030 #include "DQM/EcalEndcapMonitorTasks/interface/EERawDataTask.h"
00031 
00032 EERawDataTask::EERawDataTask(const edm::ParameterSet& ps) {
00033 
00034   init_ = false;
00035 
00036   dqmStore_ = edm::Service<DQMStore>().operator->();
00037 
00038   prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00039 
00040   subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
00041 
00042   enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00043 
00044   mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00045 
00046   FEDRawDataCollection_ = ps.getParameter<edm::InputTag>("FEDRawDataCollection");
00047   EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
00048 
00049   meEEEventTypePreCalibrationBX_ = 0;
00050   meEEEventTypeCalibrationBX_ = 0;
00051   meEEEventTypePostCalibrationBX_ = 0;
00052   meEECRCErrors_ = 0;
00053   meEERunNumberErrors_ = 0;
00054   meEEOrbitNumberErrors_ = 0;
00055   meEETriggerTypeErrors_ = 0;
00056   meEECalibrationEventErrors_ = 0;
00057   meEEL1ADCCErrors_ = 0;
00058   meEEBunchCrossingDCCErrors_ = 0;
00059   meEEL1AFEErrors_ = 0;
00060   meEEBunchCrossingFEErrors_ = 0;
00061   meEEL1ATCCErrors_ = 0;
00062   meEEBunchCrossingTCCErrors_ = 0;
00063   meEEL1ASRPErrors_ = 0;
00064   meEEBunchCrossingSRPErrors_ = 0;
00065 
00066   meEESynchronizationErrorsByLumi_ = 0;
00067 
00068   calibrationBX_ = 3490;
00069 
00070 }
00071 
00072 EERawDataTask::~EERawDataTask() {
00073 }
00074 
00075 void EERawDataTask::beginJob(void){
00076 
00077   ievt_ = 0;
00078 
00079   if ( dqmStore_ ) {
00080     dqmStore_->setCurrentFolder(prefixME_ + "/EERawDataTask");
00081     if(subfolder_.size())
00082       dqmStore_->setCurrentFolder(prefixME_ + "/EERawDataTask/" + subfolder_);
00083     dqmStore_->rmdir(prefixME_ + "/EERawDataTask");
00084   }
00085 
00086 }
00087 
00088 void EERawDataTask::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const  edm::EventSetup& iSetup) {
00089 
00090   if ( meEESynchronizationErrorsByLumi_ ) meEESynchronizationErrorsByLumi_->Reset();
00091 
00092 }
00093 
00094 void EERawDataTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00095 
00096   Numbers::initGeometry(c, false);
00097 
00098   if ( ! mergeRuns_ ) this->reset();
00099 
00100 }
00101 
00102 void EERawDataTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00103 
00104 }
00105 
00106 void EERawDataTask::reset(void) {
00107 
00108   if ( meEEEventTypePreCalibrationBX_ ) meEEEventTypePreCalibrationBX_->Reset();
00109   if ( meEEEventTypeCalibrationBX_ ) meEEEventTypeCalibrationBX_->Reset();
00110   if ( meEEEventTypePostCalibrationBX_ ) meEEEventTypePostCalibrationBX_->Reset();
00111   if ( meEECRCErrors_ ) meEECRCErrors_->Reset();
00112   if ( meEERunNumberErrors_ ) meEERunNumberErrors_->Reset();
00113   if ( meEEOrbitNumberErrors_ ) meEEOrbitNumberErrors_->Reset();
00114   if ( meEETriggerTypeErrors_ ) meEETriggerTypeErrors_->Reset();
00115   if ( meEECalibrationEventErrors_ ) meEECalibrationEventErrors_->Reset();
00116   if ( meEEL1ADCCErrors_ ) meEEL1ADCCErrors_->Reset();
00117   if ( meEEBunchCrossingDCCErrors_ ) meEEBunchCrossingDCCErrors_->Reset();
00118   if ( meEEL1AFEErrors_ ) meEEL1AFEErrors_->Reset();
00119   if ( meEEBunchCrossingFEErrors_ ) meEEBunchCrossingFEErrors_->Reset();
00120   if ( meEEL1ATCCErrors_ ) meEEL1ATCCErrors_->Reset();
00121   if ( meEEBunchCrossingTCCErrors_ ) meEEBunchCrossingTCCErrors_->Reset();
00122   if ( meEEL1ASRPErrors_ ) meEEL1ASRPErrors_->Reset();
00123   if ( meEEBunchCrossingSRPErrors_ ) meEEBunchCrossingSRPErrors_->Reset();
00124   if ( meEESynchronizationErrorsByLumi_ ) meEESynchronizationErrorsByLumi_->Reset();
00125 
00126 }
00127 
00128 void EERawDataTask::setup(void){
00129 
00130   init_ = true;
00131 
00132   std::string name;
00133 
00134   if ( dqmStore_ ) {
00135     dqmStore_->setCurrentFolder(prefixME_ + "/EERawDataTask");
00136     if(subfolder_.size())
00137       dqmStore_->setCurrentFolder(prefixME_ + "/EERawDataTask/" + subfolder_);
00138 
00139     name = "EERDT event type pre calibration BX";
00140     meEEEventTypePreCalibrationBX_ = dqmStore_->book1D(name, name, 31, -1., 30.);
00141     meEEEventTypePreCalibrationBX_->setBinLabel(1, "UNKNOWN", 1);
00142     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMIC, "COSMIC", 1);
00143     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH4, "BEAMH4", 1);
00144     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH2, "BEAMH2", 1);
00145     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::MTCC, "MTCC", 1);
00146     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_STD, "LASER_STD", 1);
00147     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
00148     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
00149     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
00150     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_MGPA, "TESTPULSE_MGPA", 1);
00151     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_STD, "PEDESTAL_STD", 1);
00152     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
00153     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
00154     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_STD, "LED_STD", 1);
00155     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL, "PHYSICS_GLOBAL", 1);
00156     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_GLOBAL, "COSMICS_GLOBAL", 1);
00157     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_GLOBAL, "HALO_GLOBAL", 1);
00158     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_GAP, "LASER_GAP", 1);
00159     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_GAP, "TESTPULSE_GAP");
00160     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_GAP, "PEDESTAL_GAP");
00161     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_GAP, "LED_GAP", 1);
00162     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_LOCAL, "PHYSICS_LOCAL", 1);
00163     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_LOCAL, "COSMICS_LOCAL", 1);
00164     meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_LOCAL, "HALO_LOCAL", 1);
00165 
00166     name = "EERDT event type calibration BX";
00167     meEEEventTypeCalibrationBX_ = dqmStore_->book1D(name, name, 31, -1., 30.);
00168     meEEEventTypeCalibrationBX_->setBinLabel(1, "UNKNOWN", 1);
00169     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMIC, "COSMIC", 1);
00170     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH4, "BEAMH4", 1);
00171     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH2, "BEAMH2", 1);
00172     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::MTCC, "MTCC", 1);
00173     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_STD, "LASER_STD", 1);
00174     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
00175     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
00176     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
00177     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_MGPA, "TESTPULSE_MGPA", 1);
00178     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_STD, "PEDESTAL_STD", 1);
00179     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
00180     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
00181     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_STD, "LED_STD", 1);
00182     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL, "PHYSICS_GLOBAL", 1);
00183     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_GLOBAL, "COSMICS_GLOBAL", 1);
00184     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_GLOBAL, "HALO_GLOBAL", 1);
00185     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_GAP, "LASER_GAP", 1);
00186     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_GAP, "TESTPULSE_GAP");
00187     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_GAP, "PEDESTAL_GAP");
00188     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_GAP, "LED_GAP", 1);
00189     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_LOCAL, "PHYSICS_LOCAL", 1);
00190     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_LOCAL, "COSMICS_LOCAL", 1);
00191     meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_LOCAL, "HALO_LOCAL", 1);
00192 
00193     name = "EERDT event type post calibration BX";
00194     meEEEventTypePostCalibrationBX_ = dqmStore_->book1D(name, name, 31, -1., 30.);
00195     meEEEventTypePostCalibrationBX_->setBinLabel(1, "UNKNOWN", 1);
00196     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMIC, "COSMIC", 1);
00197     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH4, "BEAMH4", 1);
00198     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH2, "BEAMH2", 1);
00199     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::MTCC, "MTCC", 1);
00200     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_STD, "LASER_STD", 1);
00201     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
00202     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
00203     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
00204     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_MGPA, "TESTPULSE_MGPA", 1);
00205     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_STD, "PEDESTAL_STD", 1);
00206     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
00207     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
00208     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_STD, "LED_STD", 1);
00209     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL, "PHYSICS_GLOBAL", 1);
00210     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_GLOBAL, "COSMICS_GLOBAL", 1);
00211     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_GLOBAL, "HALO_GLOBAL", 1);
00212     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_GAP, "LASER_GAP", 1);
00213     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_GAP, "TESTPULSE_GAP");
00214     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_GAP, "PEDESTAL_GAP");
00215     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_GAP, "LED_GAP", 1);
00216     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_LOCAL, "PHYSICS_LOCAL", 1);
00217     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_LOCAL, "COSMICS_LOCAL", 1);
00218     meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_LOCAL, "HALO_LOCAL", 1);
00219 
00220     name = "EERDT CRC errors";
00221     meEECRCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00222     for (int i = 0; i < 18; i++) {
00223       meEECRCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00224     }
00225 
00226     name = "EERDT run number errors";
00227     meEERunNumberErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00228     for (int i = 0; i < 18; i++) {
00229       meEERunNumberErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00230     }
00231 
00232     name = "EERDT orbit number errors";
00233     meEEOrbitNumberErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00234     for (int i = 0; i < 18; i++) {
00235       meEEOrbitNumberErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00236     }
00237 
00238     name = "EERDT trigger type errors";
00239     meEETriggerTypeErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00240     for (int i = 0; i < 18; i++) {
00241       meEETriggerTypeErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00242     }
00243 
00244     name = "EERDT calibration event errors";
00245     meEECalibrationEventErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00246     for (int i = 0; i < 18; i++) {
00247       meEECalibrationEventErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00248     }
00249 
00250     name = "EERDT L1A DCC errors";
00251     meEEL1ADCCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00252     for (int i = 0; i < 18; i++) {
00253       meEEL1ADCCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00254     }
00255 
00256     name = "EERDT bunch crossing DCC errors";
00257     meEEBunchCrossingDCCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00258     for (int i = 0; i < 18; i++) {
00259       meEEBunchCrossingDCCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00260     }
00261 
00262     name = "EERDT L1A FE errors";
00263     meEEL1AFEErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00264     for (int i = 0; i < 18; i++) {
00265       meEEL1AFEErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00266     }
00267 
00268     name = "EERDT bunch crossing FE errors";
00269     meEEBunchCrossingFEErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00270     for (int i = 0; i < 18; i++) {
00271       meEEBunchCrossingFEErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00272     }
00273 
00274     name = "EERDT L1A TCC errors";
00275     meEEL1ATCCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00276     for (int i = 0; i < 18; i++) {
00277       meEEL1ATCCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00278     }
00279 
00280     name = "EERDT bunch crossing TCC errors";
00281     meEEBunchCrossingTCCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00282     for (int i = 0; i < 18; i++) {
00283       meEEBunchCrossingTCCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00284     }
00285 
00286     name = "EERDT L1A SRP errors";
00287     meEEL1ASRPErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00288     for (int i = 0; i < 18; i++) {
00289       meEEL1ASRPErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00290     }
00291 
00292     name = "EERDT bunch crossing SRP errors";
00293     meEEBunchCrossingSRPErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00294     for (int i = 0; i < 18; i++) {
00295       meEEBunchCrossingSRPErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00296     }
00297 
00298     name = "EERDT FE synchronization errors by lumi";
00299     meEESynchronizationErrorsByLumi_ = dqmStore_->book1D(name, name, 18, 1, 19);
00300     meEESynchronizationErrorsByLumi_->setLumiFlag();
00301     for (int i = 0; i < 18; i++) {
00302       meEESynchronizationErrorsByLumi_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00303     }
00304 
00305   }
00306 
00307 }
00308 
00309 void EERawDataTask::cleanup(void){
00310 
00311   if ( ! init_ ) return;
00312 
00313   if ( dqmStore_ ) {
00314     dqmStore_->setCurrentFolder(prefixME_ + "/EERawDataTask");
00315     if(subfolder_.size())
00316       dqmStore_->setCurrentFolder(prefixME_ + "/EERawDataTask/" + subfolder_);
00317 
00318     if ( meEEEventTypePreCalibrationBX_ ) dqmStore_->removeElement( meEEEventTypePreCalibrationBX_->getName() );
00319     meEEEventTypePreCalibrationBX_ = 0;
00320 
00321     if ( meEEEventTypeCalibrationBX_ ) dqmStore_->removeElement( meEEEventTypeCalibrationBX_->getName() );
00322     meEEEventTypeCalibrationBX_ = 0;
00323 
00324     if ( meEEEventTypePostCalibrationBX_ ) dqmStore_->removeElement( meEEEventTypePostCalibrationBX_->getName() );
00325     meEEEventTypePostCalibrationBX_ = 0;
00326 
00327     if ( meEECRCErrors_ ) dqmStore_->removeElement( meEECRCErrors_->getName() );
00328     meEECRCErrors_ = 0;
00329 
00330     if ( meEERunNumberErrors_ ) dqmStore_->removeElement( meEERunNumberErrors_->getName() );
00331     meEERunNumberErrors_ = 0;
00332 
00333     if ( meEEOrbitNumberErrors_ ) dqmStore_->removeElement( meEEOrbitNumberErrors_->getName() );
00334     meEEOrbitNumberErrors_ = 0;
00335 
00336     if ( meEETriggerTypeErrors_ ) dqmStore_->removeElement( meEETriggerTypeErrors_->getName() );
00337     meEETriggerTypeErrors_ = 0;
00338 
00339     if ( meEECalibrationEventErrors_ ) dqmStore_->removeElement( meEECalibrationEventErrors_->getName() );
00340     meEECalibrationEventErrors_ = 0;
00341 
00342     if ( meEEL1ADCCErrors_ ) dqmStore_->removeElement( meEEL1ADCCErrors_->getName() );
00343     meEEL1ADCCErrors_ = 0;
00344 
00345     if ( meEEBunchCrossingDCCErrors_ ) dqmStore_->removeElement( meEEBunchCrossingDCCErrors_->getName() );
00346     meEEBunchCrossingDCCErrors_ = 0;
00347 
00348     if ( meEEL1AFEErrors_ ) dqmStore_->removeElement( meEEL1AFEErrors_->getName() );
00349     meEEL1AFEErrors_ = 0;
00350 
00351     if ( meEEBunchCrossingFEErrors_ ) dqmStore_->removeElement( meEEBunchCrossingFEErrors_->getName() );
00352     meEEBunchCrossingFEErrors_ = 0;
00353 
00354     if ( meEEL1ATCCErrors_ ) dqmStore_->removeElement( meEEL1ATCCErrors_->getName() );
00355     meEEL1ATCCErrors_ = 0;
00356 
00357     if ( meEEBunchCrossingTCCErrors_ ) dqmStore_->removeElement( meEEBunchCrossingTCCErrors_->getName() );
00358     meEEBunchCrossingTCCErrors_ = 0;
00359 
00360     if ( meEEL1ASRPErrors_ ) dqmStore_->removeElement( meEEL1ASRPErrors_->getName() );
00361     meEEL1ASRPErrors_ = 0;
00362 
00363     if ( meEEBunchCrossingSRPErrors_ ) dqmStore_->removeElement( meEEBunchCrossingSRPErrors_->getName() );
00364     meEEBunchCrossingSRPErrors_ = 0;
00365 
00366     if ( meEESynchronizationErrorsByLumi_ ) dqmStore_->removeElement( meEESynchronizationErrorsByLumi_->getName() );
00367     meEESynchronizationErrorsByLumi_ = 0;
00368 
00369   }
00370 
00371   init_ = false;
00372 
00373 }
00374 
00375 void EERawDataTask::endLuminosityBlock(const edm::LuminosityBlock&  lumiBlock, const  edm::EventSetup& iSetup) {
00376 }
00377 
00378 void EERawDataTask::endJob(void) {
00379 
00380   edm::LogInfo("EERawDataTask") << "analyzed " << ievt_ << " events";
00381 
00382   if ( enableCleanup_ ) this->cleanup();
00383 
00384 }
00385 
00386 void EERawDataTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00387 
00388   if ( ! init_ ) this->setup();
00389 
00390   ievt_++;
00391 
00392   // fill bin 0 with number of events in the lumi
00393   if ( meEESynchronizationErrorsByLumi_ ) meEESynchronizationErrorsByLumi_->Fill(0.);
00394 
00395   int evt_runNumber = e.id().run();
00396 
00397   int GT_L1A=0, GT_OrbitNumber=0, GT_BunchCrossing=0, GT_TriggerType=0;
00398 
00399   edm::Handle<FEDRawDataCollection> allFedRawData;
00400 
00401   int gtFedDataSize = 0;
00402 
00403   int ECALDCC_L1A_MostFreqId = -1;
00404   int ECALDCC_OrbitNumber_MostFreqId = -1;
00405   int ECALDCC_BunchCrossing_MostFreqId = -1;
00406   int ECALDCC_TriggerType_MostFreqId = -1;
00407 
00408   if ( e.getByLabel(FEDRawDataCollection_, allFedRawData) ) {
00409 
00410     // GT FED data
00411     const FEDRawData& gtFedData = allFedRawData->FEDData(812);
00412 
00413     gtFedDataSize = gtFedData.size()/sizeof(uint64_t);
00414 
00415     if ( gtFedDataSize > 0 ) {
00416 
00417       FEDHeader header(gtFedData.data());
00418 
00419 #define  H_L1_MASK           0xFFFFFF
00420 #define  H_ORBITCOUNTER_MASK 0xFFFFFFFF
00421 #define  H_BX_MASK           0xFFF
00422 #define  H_TTYPE_MASK        0xF
00423 
00424       GT_L1A           = header.lvl1ID()    & H_L1_MASK;
00425       GT_OrbitNumber   = e.orbitNumber()    & H_ORBITCOUNTER_MASK;
00426       GT_BunchCrossing = e.bunchCrossing()  & H_BX_MASK;
00427       GT_TriggerType   = e.experimentType() & H_TTYPE_MASK;
00428 
00429     } else {
00430 
00431       // use the most frequent among the ECAL FEDs
00432 
00433       std::map<int,int> ECALDCC_L1A_FreqMap;
00434       std::map<int,int> ECALDCC_OrbitNumber_FreqMap;
00435       std::map<int,int> ECALDCC_BunchCrossing_FreqMap;
00436       std::map<int,int> ECALDCC_TriggerType_FreqMap;
00437 
00438       int ECALDCC_L1A_MostFreqCounts = 0;
00439       int ECALDCC_OrbitNumber_MostFreqCounts = 0;
00440       int ECALDCC_BunchCrossing_MostFreqCounts = 0;
00441       int ECALDCC_TriggerType_MostFreqCounts = 0;
00442 
00443       edm::Handle<EcalRawDataCollection> dcchs;
00444 
00445       if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00446 
00447         for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00448 
00449           if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
00450 
00451           int ECALDCC_L1A = dcchItr->getLV1();
00452           int ECALDCC_OrbitNumber = dcchItr->getOrbit();
00453           int ECALDCC_BunchCrossing = dcchItr->getBX();
00454           int ECALDCC_TriggerType = dcchItr->getBasicTriggerType();
00455 
00456           ++ECALDCC_L1A_FreqMap[ECALDCC_L1A];
00457           ++ECALDCC_OrbitNumber_FreqMap[ECALDCC_OrbitNumber];
00458           ++ECALDCC_BunchCrossing_FreqMap[ECALDCC_BunchCrossing];
00459           ++ECALDCC_TriggerType_FreqMap[ECALDCC_TriggerType];
00460 
00461           if ( ECALDCC_L1A_FreqMap[ECALDCC_L1A] > ECALDCC_L1A_MostFreqCounts ) {
00462             ECALDCC_L1A_MostFreqCounts = ECALDCC_L1A_FreqMap[ECALDCC_L1A];
00463             ECALDCC_L1A_MostFreqId = ECALDCC_L1A;
00464           }
00465 
00466           if ( ECALDCC_OrbitNumber_FreqMap[ECALDCC_OrbitNumber] > ECALDCC_OrbitNumber_MostFreqCounts ) {
00467             ECALDCC_OrbitNumber_MostFreqCounts = ECALDCC_OrbitNumber_FreqMap[ECALDCC_OrbitNumber];
00468             ECALDCC_OrbitNumber_MostFreqId = ECALDCC_OrbitNumber;
00469           }
00470 
00471           if ( ECALDCC_BunchCrossing_FreqMap[ECALDCC_BunchCrossing] > ECALDCC_BunchCrossing_MostFreqCounts ) {
00472             ECALDCC_BunchCrossing_MostFreqCounts = ECALDCC_BunchCrossing_FreqMap[ECALDCC_BunchCrossing];
00473             ECALDCC_BunchCrossing_MostFreqId = ECALDCC_BunchCrossing;
00474           }
00475 
00476           if ( ECALDCC_TriggerType_FreqMap[ECALDCC_TriggerType] > ECALDCC_TriggerType_MostFreqCounts ) {
00477             ECALDCC_TriggerType_MostFreqCounts = ECALDCC_TriggerType_FreqMap[ECALDCC_TriggerType];
00478             ECALDCC_TriggerType_MostFreqId = ECALDCC_TriggerType;
00479           }
00480 
00481         }
00482 
00483       } else {
00484         edm::LogWarning("EERawDataTask") << EcalRawDataCollection_ << " not available";
00485       }
00486 
00487     }
00488 
00489     // ECAL endcap FEDs
00490     int EEFirstFED[2];
00491     EEFirstFED[0] = 601; // EE-
00492     EEFirstFED[1] = 646; // EE+
00493     for(int zside=0; zside<2; zside++) {
00494 
00495       int firstFedOnSide=EEFirstFED[zside];
00496 
00497       for(int i=0; i<9; i++) {
00498 
00499         const FEDRawData& fedData = allFedRawData->FEDData(firstFedOnSide+i);
00500 
00501         int length = fedData.size()/sizeof(uint64_t);
00502 
00503         if ( length > 0 ) {
00504 
00505           uint64_t * pData = (uint64_t *)(fedData.data());
00506           uint64_t * fedTrailer = pData + (length - 1);
00507           bool crcError = (*fedTrailer >> 2 ) & 0x1;
00508 
00509           if (crcError) meEECRCErrors_->Fill( i+1 );
00510 
00511         }
00512 
00513       }
00514 
00515     }
00516 
00517   } else {
00518     edm::LogWarning("EERawDataTask") << FEDRawDataCollection_ << " not available";
00519   }
00520 
00521   edm::Handle<EcalRawDataCollection> dcchs;
00522 
00523   if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00524 
00525     for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00526 
00527       if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
00528 
00529       int ism = Numbers::iSM( *dcchItr, EcalEndcap );
00530       float xism = ism+0.5;
00531 
00532       int ECALDCC_runNumber     = dcchItr->getRunNumber();
00533 
00534       int ECALDCC_L1A           = dcchItr->getLV1();
00535       int ECALDCC_OrbitNumber   = dcchItr->getOrbit();
00536       int ECALDCC_BunchCrossing = dcchItr->getBX();
00537       int ECALDCC_TriggerType   = dcchItr->getBasicTriggerType();
00538 
00539       if ( evt_runNumber != ECALDCC_runNumber ) meEERunNumberErrors_->Fill( xism );
00540 
00541       if ( gtFedDataSize > 0 ) {
00542 
00543         if ( GT_L1A != ECALDCC_L1A ) meEEL1ADCCErrors_->Fill( xism );
00544 
00545         if ( GT_BunchCrossing != ECALDCC_BunchCrossing ) meEEBunchCrossingDCCErrors_->Fill( xism );
00546 
00547         if ( GT_TriggerType != ECALDCC_TriggerType ) meEETriggerTypeErrors_->Fill ( xism );
00548 
00549       } else {
00550 
00551         if ( ECALDCC_L1A_MostFreqId != ECALDCC_L1A ) meEEL1ADCCErrors_->Fill( xism );
00552 
00553         if ( ECALDCC_BunchCrossing_MostFreqId != ECALDCC_BunchCrossing ) meEEBunchCrossingDCCErrors_->Fill( xism );
00554 
00555         if ( ECALDCC_TriggerType_MostFreqId != ECALDCC_TriggerType ) meEETriggerTypeErrors_->Fill ( xism );
00556 
00557       }
00558 
00559       if ( gtFedDataSize > 0 ) {
00560 
00561         if ( GT_OrbitNumber != ECALDCC_OrbitNumber ) meEEOrbitNumberErrors_->Fill ( xism );
00562 
00563       } else {
00564 
00565         if ( ECALDCC_OrbitNumber_MostFreqId != ECALDCC_OrbitNumber ) meEEOrbitNumberErrors_->Fill ( xism );
00566 
00567       }
00568 
00569       // DCC vs. FE,TCC, SRP syncronization
00570       const std::vector<short> feBxs = dcchItr->getFEBxs();
00571       const std::vector<short> tccBx = dcchItr->getTCCBx();
00572       const short srpBx = dcchItr->getSRPBx();
00573       const std::vector<short> status = dcchItr->getFEStatus();
00574 
00575       std::vector<int> BxSynchStatus;
00576       BxSynchStatus.reserve((int)feBxs.size());
00577 
00578       for(int fe=0; fe<(int)feBxs.size(); fe++) {
00579         // do not consider desynch errors if the DCC detected them
00580         if( ( status[fe] == 10 || status[fe] == 11 )) continue;
00581         if(feBxs[fe] != ECALDCC_BunchCrossing && feBxs[fe] != -1 && ECALDCC_BunchCrossing != -1) {
00582           meEEBunchCrossingFEErrors_->Fill( xism, 1/(float)feBxs.size());
00583           BxSynchStatus[fe] = 0;
00584         } else BxSynchStatus[fe] = 1;
00585       }
00586 
00587       // vector of TCC channels has 4 elements for both EB and EE.
00588       // EB uses [0], EE uses [0-3].
00589       if(tccBx.size() == MAX_TCC_SIZE) {
00590         for(int tcc=0; tcc<MAX_TCC_SIZE; tcc++) {
00591           if(tccBx[tcc] != ECALDCC_BunchCrossing && tccBx[tcc] != -1 && ECALDCC_BunchCrossing != -1) meEEBunchCrossingTCCErrors_->Fill( xism, 1/(float)tccBx.size());
00592         }
00593       }
00594 
00595       if(srpBx != ECALDCC_BunchCrossing && srpBx != -1 && ECALDCC_BunchCrossing != -1) meEEBunchCrossingSRPErrors_->Fill( xism );
00596 
00597       const std::vector<short> feLv1 = dcchItr->getFELv1();
00598       const std::vector<short> tccLv1 = dcchItr->getTCCLv1();
00599       const short srpLv1 = dcchItr->getSRPLv1();
00600 
00601       // Lv1 in TCC,SRP,FE are limited to 12 bits(LSB), while in the DCC Lv1 has 24 bits
00602       int ECALDCC_L1A_12bit = ECALDCC_L1A & 0xfff;
00603       int feLv1Offset = ( e.isRealData() ) ? 1 : 0; // in MC FE Lv1A counter starts from 1, in data from 0
00604 
00605       for(int fe=0; fe<(int)feLv1.size(); fe++) {
00606         // do not consider desynch errors if the DCC detected them
00607         if( ( status[fe] == 9 || status[fe] == 11 )) continue;
00608         if(feLv1[fe]+feLv1Offset != ECALDCC_L1A_12bit && feLv1[fe] != -1 && ECALDCC_L1A_12bit - 1 != -1) {
00609           meEEL1AFEErrors_->Fill( xism, 1/(float)feLv1.size());
00610           meEESynchronizationErrorsByLumi_->Fill( xism, 1/(float)feLv1.size() );
00611         } else if( BxSynchStatus[fe]==0 ) meEESynchronizationErrorsByLumi_->Fill( xism, 1/(float)feLv1.size() );
00612       }
00613 
00614       // vector of TCC channels has 4 elements for both EB and EE.
00615       // EB uses [0], EE uses [0-3].
00616       if(tccLv1.size() == MAX_TCC_SIZE) {
00617         for(int tcc=0; tcc<MAX_TCC_SIZE; tcc++) {
00618           if(tccLv1[tcc] != ECALDCC_L1A_12bit && tccLv1[tcc] != -1 && ECALDCC_L1A_12bit - 1 != -1) meEEL1ATCCErrors_->Fill( xism, 1/(float)tccLv1.size());
00619         }
00620       }
00621 
00622       if(srpLv1 != ECALDCC_L1A_12bit && srpLv1 != -1 && ECALDCC_L1A_12bit - 1 != -1) meEEL1ASRPErrors_->Fill( xism );
00623 
00624       if ( gtFedDataSize > 0 ) {
00625 
00626         if ( GT_OrbitNumber != ECALDCC_OrbitNumber ) meEEOrbitNumberErrors_->Fill ( xism );
00627 
00628       } else {
00629 
00630         if ( ECALDCC_OrbitNumber_MostFreqId != ECALDCC_OrbitNumber ) meEEOrbitNumberErrors_->Fill ( xism );
00631 
00632       }
00633 
00634       float evtType = dcchItr->getRunType();
00635 
00636       if ( evtType < 0 || evtType > 22 ) evtType = -1;
00637 
00638       if ( ECALDCC_BunchCrossing < calibrationBX_ ) meEEEventTypePreCalibrationBX_->Fill( evtType+0.5, 1./18. );
00639       if ( ECALDCC_BunchCrossing == calibrationBX_ ) meEEEventTypeCalibrationBX_->Fill( evtType+0.5, 1./18. );
00640       if ( ECALDCC_BunchCrossing > calibrationBX_ ) meEEEventTypePostCalibrationBX_->Fill ( evtType+0.5, 1./18. );
00641 
00642       if ( ECALDCC_BunchCrossing != calibrationBX_ ) {
00643         if ( evtType != EcalDCCHeaderBlock::COSMIC &&
00644              evtType != EcalDCCHeaderBlock::MTCC &&
00645              evtType != EcalDCCHeaderBlock::COSMICS_GLOBAL &&
00646              evtType != EcalDCCHeaderBlock::PHYSICS_GLOBAL &&
00647              evtType != EcalDCCHeaderBlock::COSMICS_LOCAL &&
00648              evtType != EcalDCCHeaderBlock::PHYSICS_LOCAL &&
00649              evtType != -1 ) meEECalibrationEventErrors_->Fill( xism );
00650       } else {
00651         if ( evtType == EcalDCCHeaderBlock::COSMIC ||
00652              evtType == EcalDCCHeaderBlock::MTCC ||
00653              evtType == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
00654              evtType == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
00655              evtType == EcalDCCHeaderBlock::COSMICS_LOCAL ||
00656              evtType == EcalDCCHeaderBlock::PHYSICS_LOCAL ) meEECalibrationEventErrors_->Fill( xism );
00657       }
00658 
00659     }
00660 
00661   } else {
00662     edm::LogWarning("EERawDataTask") << EcalRawDataCollection_ << " not available";
00663   }
00664 
00665 }
00666