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