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/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 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 meEEEventTypePreCalibrationBX_ = 0;
00048 meEEEventTypeCalibrationBX_ = 0;
00049 meEEEventTypePostCalibrationBX_ = 0;
00050 meEECRCErrors_ = 0;
00051 meEERunNumberErrors_ = 0;
00052 meEEOrbitNumberErrors_ = 0;
00053 meEETriggerTypeErrors_ = 0;
00054 meEECalibrationEventErrors_ = 0;
00055 meEEL1ADCCErrors_ = 0;
00056 meEEBunchCrossingDCCErrors_ = 0;
00057 meEEL1AFEErrors_ = 0;
00058 meEEBunchCrossingFEErrors_ = 0;
00059 meEEL1ATCCErrors_ = 0;
00060 meEEBunchCrossingTCCErrors_ = 0;
00061 meEEL1ASRPErrors_ = 0;
00062 meEEBunchCrossingSRPErrors_ = 0;
00063
00064 meEESynchronizationErrorsByLumi_ = 0;
00065
00066 calibrationBX_ = 3490;
00067
00068 }
00069
00070 EERawDataTask::~EERawDataTask() {
00071 }
00072
00073 void EERawDataTask::beginJob(void){
00074
00075 ievt_ = 0;
00076
00077 if ( dqmStore_ ) {
00078 dqmStore_->setCurrentFolder(prefixME_ + "/EERawDataTask");
00079 dqmStore_->rmdir(prefixME_ + "/EERawDataTask");
00080 }
00081
00082 }
00083
00084 void EERawDataTask::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup) {
00085
00086 if ( meEESynchronizationErrorsByLumi_ ) meEESynchronizationErrorsByLumi_->Reset();
00087
00088 }
00089
00090 void EERawDataTask::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 EERawDataTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00099
00100 }
00101
00102 void EERawDataTask::reset(void) {
00103
00104 if ( meEEEventTypePreCalibrationBX_ ) meEEEventTypePreCalibrationBX_->Reset();
00105 if ( meEEEventTypeCalibrationBX_ ) meEEEventTypeCalibrationBX_->Reset();
00106 if ( meEEEventTypePostCalibrationBX_ ) meEEEventTypePostCalibrationBX_->Reset();
00107 if ( meEECRCErrors_ ) meEECRCErrors_->Reset();
00108 if ( meEERunNumberErrors_ ) meEERunNumberErrors_->Reset();
00109 if ( meEEOrbitNumberErrors_ ) meEEOrbitNumberErrors_->Reset();
00110 if ( meEETriggerTypeErrors_ ) meEETriggerTypeErrors_->Reset();
00111 if ( meEECalibrationEventErrors_ ) meEECalibrationEventErrors_->Reset();
00112 if ( meEEL1ADCCErrors_ ) meEEL1ADCCErrors_->Reset();
00113 if ( meEEBunchCrossingDCCErrors_ ) meEEBunchCrossingDCCErrors_->Reset();
00114 if ( meEEL1AFEErrors_ ) meEEL1AFEErrors_->Reset();
00115 if ( meEEBunchCrossingFEErrors_ ) meEEBunchCrossingFEErrors_->Reset();
00116 if ( meEEL1ATCCErrors_ ) meEEL1ATCCErrors_->Reset();
00117 if ( meEEBunchCrossingTCCErrors_ ) meEEBunchCrossingTCCErrors_->Reset();
00118 if ( meEEL1ASRPErrors_ ) meEEL1ASRPErrors_->Reset();
00119 if ( meEEBunchCrossingSRPErrors_ ) meEEBunchCrossingSRPErrors_->Reset();
00120 if ( meEESynchronizationErrorsByLumi_ ) meEESynchronizationErrorsByLumi_->Reset();
00121
00122 }
00123
00124 void EERawDataTask::setup(void){
00125
00126 init_ = true;
00127
00128 std::string name;
00129
00130 if ( dqmStore_ ) {
00131 dqmStore_->setCurrentFolder(prefixME_ + "/EERawDataTask");
00132
00133 name = "EERDT event type pre calibration BX";
00134 meEEEventTypePreCalibrationBX_ = dqmStore_->book1D(name, name, 31, -1., 30.);
00135 meEEEventTypePreCalibrationBX_->setBinLabel(1, "UNKNOWN", 1);
00136 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMIC, "COSMIC", 1);
00137 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH4, "BEAMH4", 1);
00138 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH2, "BEAMH2", 1);
00139 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::MTCC, "MTCC", 1);
00140 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_STD, "LASER_STD", 1);
00141 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
00142 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
00143 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
00144 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_MGPA, "TESTPULSE_MGPA", 1);
00145 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_STD, "PEDESTAL_STD", 1);
00146 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
00147 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
00148 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_STD, "LED_STD", 1);
00149 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL, "PHYSICS_GLOBAL", 1);
00150 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_GLOBAL, "COSMICS_GLOBAL", 1);
00151 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_GLOBAL, "HALO_GLOBAL", 1);
00152 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_GAP, "LASER_GAP", 1);
00153 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_GAP, "TESTPULSE_GAP");
00154 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_GAP, "PEDESTAL_GAP");
00155 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_GAP, "LED_GAP", 1);
00156 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_LOCAL, "PHYSICS_LOCAL", 1);
00157 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_LOCAL, "COSMICS_LOCAL", 1);
00158 meEEEventTypePreCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_LOCAL, "HALO_LOCAL", 1);
00159
00160 name = "EERDT event type calibration BX";
00161 meEEEventTypeCalibrationBX_ = dqmStore_->book1D(name, name, 31, -1., 30.);
00162 meEEEventTypeCalibrationBX_->setBinLabel(1, "UNKNOWN", 1);
00163 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMIC, "COSMIC", 1);
00164 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH4, "BEAMH4", 1);
00165 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH2, "BEAMH2", 1);
00166 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::MTCC, "MTCC", 1);
00167 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_STD, "LASER_STD", 1);
00168 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
00169 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
00170 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
00171 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_MGPA, "TESTPULSE_MGPA", 1);
00172 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_STD, "PEDESTAL_STD", 1);
00173 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
00174 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
00175 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_STD, "LED_STD", 1);
00176 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL, "PHYSICS_GLOBAL", 1);
00177 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_GLOBAL, "COSMICS_GLOBAL", 1);
00178 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_GLOBAL, "HALO_GLOBAL", 1);
00179 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_GAP, "LASER_GAP", 1);
00180 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_GAP, "TESTPULSE_GAP");
00181 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_GAP, "PEDESTAL_GAP");
00182 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_GAP, "LED_GAP", 1);
00183 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_LOCAL, "PHYSICS_LOCAL", 1);
00184 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_LOCAL, "COSMICS_LOCAL", 1);
00185 meEEEventTypeCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_LOCAL, "HALO_LOCAL", 1);
00186
00187 name = "EERDT event type post calibration BX";
00188 meEEEventTypePostCalibrationBX_ = dqmStore_->book1D(name, name, 31, -1., 30.);
00189 meEEEventTypePostCalibrationBX_->setBinLabel(1, "UNKNOWN", 1);
00190 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMIC, "COSMIC", 1);
00191 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH4, "BEAMH4", 1);
00192 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::BEAMH2, "BEAMH2", 1);
00193 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::MTCC, "MTCC", 1);
00194 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_STD, "LASER_STD", 1);
00195 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_POWER_SCAN, "LASER_POWER_SCAN", 1);
00196 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_DELAY_SCAN, "LASER_DELAY_SCAN", 1);
00197 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM, "TESTPULSE_SCAN_MEM", 1);
00198 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_MGPA, "TESTPULSE_MGPA", 1);
00199 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_STD, "PEDESTAL_STD", 1);
00200 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN, "PEDESTAL_OFFSET_SCAN", 1);
00201 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN, "PEDESTAL_25NS_SCAN", 1);
00202 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_STD, "LED_STD", 1);
00203 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL, "PHYSICS_GLOBAL", 1);
00204 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_GLOBAL, "COSMICS_GLOBAL", 1);
00205 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_GLOBAL, "HALO_GLOBAL", 1);
00206 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LASER_GAP, "LASER_GAP", 1);
00207 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::TESTPULSE_GAP, "TESTPULSE_GAP");
00208 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PEDESTAL_GAP, "PEDESTAL_GAP");
00209 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::LED_GAP, "LED_GAP", 1);
00210 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::PHYSICS_LOCAL, "PHYSICS_LOCAL", 1);
00211 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::COSMICS_LOCAL, "COSMICS_LOCAL", 1);
00212 meEEEventTypePostCalibrationBX_->setBinLabel(2+EcalDCCHeaderBlock::HALO_LOCAL, "HALO_LOCAL", 1);
00213
00214 name = "EERDT CRC errors";
00215 meEECRCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00216 for (int i = 0; i < 18; i++) {
00217 meEECRCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00218 }
00219
00220 name = "EERDT run number errors";
00221 meEERunNumberErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00222 for (int i = 0; i < 18; i++) {
00223 meEERunNumberErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00224 }
00225
00226 name = "EERDT orbit number errors";
00227 meEEOrbitNumberErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00228 for (int i = 0; i < 18; i++) {
00229 meEEOrbitNumberErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00230 }
00231
00232 name = "EERDT trigger type errors";
00233 meEETriggerTypeErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00234 for (int i = 0; i < 18; i++) {
00235 meEETriggerTypeErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00236 }
00237
00238 name = "EERDT calibration event errors";
00239 meEECalibrationEventErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00240 for (int i = 0; i < 18; i++) {
00241 meEECalibrationEventErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00242 }
00243
00244 name = "EERDT L1A DCC errors";
00245 meEEL1ADCCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00246 for (int i = 0; i < 18; i++) {
00247 meEEL1ADCCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00248 }
00249
00250 name = "EERDT bunch crossing DCC errors";
00251 meEEBunchCrossingDCCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00252 for (int i = 0; i < 18; i++) {
00253 meEEBunchCrossingDCCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00254 }
00255
00256 name = "EERDT L1A FE errors";
00257 meEEL1AFEErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00258 for (int i = 0; i < 18; i++) {
00259 meEEL1AFEErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00260 }
00261
00262 name = "EERDT bunch crossing FE errors";
00263 meEEBunchCrossingFEErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00264 for (int i = 0; i < 18; i++) {
00265 meEEBunchCrossingFEErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00266 }
00267
00268 name = "EERDT L1A TCC errors";
00269 meEEL1ATCCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00270 for (int i = 0; i < 18; i++) {
00271 meEEL1ATCCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00272 }
00273
00274 name = "EERDT bunch crossing TCC errors";
00275 meEEBunchCrossingTCCErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00276 for (int i = 0; i < 18; i++) {
00277 meEEBunchCrossingTCCErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00278 }
00279
00280 name = "EERDT L1A SRP errors";
00281 meEEL1ASRPErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00282 for (int i = 0; i < 18; i++) {
00283 meEEL1ASRPErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00284 }
00285
00286 name = "EERDT bunch crossing SRP errors";
00287 meEEBunchCrossingSRPErrors_ = dqmStore_->book1D(name, name, 18, 1, 19);
00288 for (int i = 0; i < 18; i++) {
00289 meEEBunchCrossingSRPErrors_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00290 }
00291
00292 name = "EERDT FE synchronization errors by lumi";
00293 meEESynchronizationErrorsByLumi_ = dqmStore_->book1D(name, name, 18, 1, 19);
00294 meEESynchronizationErrorsByLumi_->setLumiFlag();
00295 for (int i = 0; i < 18; i++) {
00296 meEESynchronizationErrorsByLumi_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00297 }
00298
00299 }
00300
00301 }
00302
00303 void EERawDataTask::cleanup(void){
00304
00305 if ( ! init_ ) return;
00306
00307 if ( dqmStore_ ) {
00308 dqmStore_->setCurrentFolder(prefixME_ + "/EERawDataTask");
00309
00310 if ( meEEEventTypePreCalibrationBX_ ) dqmStore_->removeElement( meEEEventTypePreCalibrationBX_->getName() );
00311 meEEEventTypePreCalibrationBX_ = 0;
00312
00313 if ( meEEEventTypeCalibrationBX_ ) dqmStore_->removeElement( meEEEventTypeCalibrationBX_->getName() );
00314 meEEEventTypeCalibrationBX_ = 0;
00315
00316 if ( meEEEventTypePostCalibrationBX_ ) dqmStore_->removeElement( meEEEventTypePostCalibrationBX_->getName() );
00317 meEEEventTypePostCalibrationBX_ = 0;
00318
00319 if ( meEECRCErrors_ ) dqmStore_->removeElement( meEECRCErrors_->getName() );
00320 meEECRCErrors_ = 0;
00321
00322 if ( meEERunNumberErrors_ ) dqmStore_->removeElement( meEERunNumberErrors_->getName() );
00323 meEERunNumberErrors_ = 0;
00324
00325 if ( meEEOrbitNumberErrors_ ) dqmStore_->removeElement( meEEOrbitNumberErrors_->getName() );
00326 meEEOrbitNumberErrors_ = 0;
00327
00328 if ( meEETriggerTypeErrors_ ) dqmStore_->removeElement( meEETriggerTypeErrors_->getName() );
00329 meEETriggerTypeErrors_ = 0;
00330
00331 if ( meEECalibrationEventErrors_ ) dqmStore_->removeElement( meEECalibrationEventErrors_->getName() );
00332 meEECalibrationEventErrors_ = 0;
00333
00334 if ( meEEL1ADCCErrors_ ) dqmStore_->removeElement( meEEL1ADCCErrors_->getName() );
00335 meEEL1ADCCErrors_ = 0;
00336
00337 if ( meEEBunchCrossingDCCErrors_ ) dqmStore_->removeElement( meEEBunchCrossingDCCErrors_->getName() );
00338 meEEBunchCrossingDCCErrors_ = 0;
00339
00340 if ( meEEL1AFEErrors_ ) dqmStore_->removeElement( meEEL1AFEErrors_->getName() );
00341 meEEL1AFEErrors_ = 0;
00342
00343 if ( meEEBunchCrossingFEErrors_ ) dqmStore_->removeElement( meEEBunchCrossingFEErrors_->getName() );
00344 meEEBunchCrossingFEErrors_ = 0;
00345
00346 if ( meEEL1ATCCErrors_ ) dqmStore_->removeElement( meEEL1ATCCErrors_->getName() );
00347 meEEL1ATCCErrors_ = 0;
00348
00349 if ( meEEBunchCrossingTCCErrors_ ) dqmStore_->removeElement( meEEBunchCrossingTCCErrors_->getName() );
00350 meEEBunchCrossingTCCErrors_ = 0;
00351
00352 if ( meEEL1ASRPErrors_ ) dqmStore_->removeElement( meEEL1ASRPErrors_->getName() );
00353 meEEL1ASRPErrors_ = 0;
00354
00355 if ( meEEBunchCrossingSRPErrors_ ) dqmStore_->removeElement( meEEBunchCrossingSRPErrors_->getName() );
00356 meEEBunchCrossingSRPErrors_ = 0;
00357
00358 if ( meEESynchronizationErrorsByLumi_ ) dqmStore_->removeElement( meEESynchronizationErrorsByLumi_->getName() );
00359 meEESynchronizationErrorsByLumi_ = 0;
00360
00361 }
00362
00363 init_ = false;
00364
00365 }
00366
00367 void EERawDataTask::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup) {
00368 }
00369
00370 void EERawDataTask::endJob(void) {
00371
00372 edm::LogInfo("EERawDataTask") << "analyzed " << ievt_ << " events";
00373
00374 if ( enableCleanup_ ) this->cleanup();
00375
00376 }
00377
00378 void EERawDataTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00379
00380 if ( ! init_ ) this->setup();
00381
00382 ievt_++;
00383
00384
00385 if ( meEESynchronizationErrorsByLumi_ ) meEESynchronizationErrorsByLumi_->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 ) != EcalEndcap ) 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("EERawDataTask") << EcalRawDataCollection_ << " not available";
00477 }
00478
00479 }
00480
00481
00482 int EEFirstFED[2];
00483 EEFirstFED[0] = 601;
00484 EEFirstFED[1] = 646;
00485 for(int zside=0; zside<2; zside++) {
00486
00487 int firstFedOnSide=EEFirstFED[zside];
00488
00489 for(int i=0; i<9; i++) {
00490
00491 const FEDRawData& fedData = allFedRawData->FEDData(firstFedOnSide+i);
00492
00493 int length = fedData.size()/sizeof(uint64_t);
00494
00495 if ( length > 0 ) {
00496
00497 uint64_t * pData = (uint64_t *)(fedData.data());
00498 uint64_t * fedTrailer = pData + (length - 1);
00499 bool crcError = (*fedTrailer >> 2 ) & 0x1;
00500
00501 if (crcError) meEECRCErrors_->Fill( i+1 );
00502
00503 }
00504
00505 }
00506
00507 }
00508
00509 } else {
00510 edm::LogWarning("EERawDataTask") << FEDRawDataCollection_ << " not available";
00511 }
00512
00513 edm::Handle<EcalRawDataCollection> dcchs;
00514
00515 if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
00516
00517 for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00518
00519 if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
00520
00521 int ism = Numbers::iSM( *dcchItr, EcalEndcap );
00522 float xism = ism+0.5;
00523
00524 int ECALDCC_runNumber = dcchItr->getRunNumber();
00525
00526 int ECALDCC_L1A = dcchItr->getLV1();
00527 int ECALDCC_OrbitNumber = dcchItr->getOrbit();
00528 int ECALDCC_BunchCrossing = dcchItr->getBX();
00529 int ECALDCC_TriggerType = dcchItr->getBasicTriggerType();
00530
00531 if ( evt_runNumber != ECALDCC_runNumber ) meEERunNumberErrors_->Fill( xism );
00532
00533 if ( gtFedDataSize > 0 ) {
00534
00535 if ( GT_L1A != ECALDCC_L1A ) meEEL1ADCCErrors_->Fill( xism );
00536
00537 if ( GT_BunchCrossing != ECALDCC_BunchCrossing ) meEEBunchCrossingDCCErrors_->Fill( xism );
00538
00539 if ( GT_TriggerType != ECALDCC_TriggerType ) meEETriggerTypeErrors_->Fill ( xism );
00540
00541 } else {
00542
00543 if ( ECALDCC_L1A_MostFreqId != ECALDCC_L1A ) meEEL1ADCCErrors_->Fill( xism );
00544
00545 if ( ECALDCC_BunchCrossing_MostFreqId != ECALDCC_BunchCrossing ) meEEBunchCrossingDCCErrors_->Fill( xism );
00546
00547 if ( ECALDCC_TriggerType_MostFreqId != ECALDCC_TriggerType ) meEETriggerTypeErrors_->Fill ( xism );
00548
00549 }
00550
00551 if ( gtFedDataSize > 0 ) {
00552
00553 if ( GT_OrbitNumber != ECALDCC_OrbitNumber ) meEEOrbitNumberErrors_->Fill ( xism );
00554
00555 } else {
00556
00557 if ( ECALDCC_OrbitNumber_MostFreqId != ECALDCC_OrbitNumber ) meEEOrbitNumberErrors_->Fill ( xism );
00558
00559 }
00560
00561
00562 const std::vector<short> feBxs = dcchItr->getFEBxs();
00563 const std::vector<short> tccBx = dcchItr->getTCCBx();
00564 const short srpBx = dcchItr->getSRPBx();
00565 const std::vector<short> status = dcchItr->getFEStatus();
00566
00567 std::vector<int> BxSynchStatus;
00568 BxSynchStatus.reserve((int)feBxs.size());
00569
00570 for(int fe=0; fe<(int)feBxs.size(); fe++) {
00571
00572 if( ( status[fe] == 10 || status[fe] == 11 )) continue;
00573 if(feBxs[fe] != ECALDCC_BunchCrossing && feBxs[fe] != -1 && ECALDCC_BunchCrossing != -1) {
00574 meEEBunchCrossingFEErrors_->Fill( xism, 1/(float)feBxs.size());
00575 BxSynchStatus[fe] = 0;
00576 } else BxSynchStatus[fe] = 1;
00577 }
00578
00579
00580
00581 if(tccBx.size() == MAX_TCC_SIZE) {
00582 for(int tcc=0; tcc<MAX_TCC_SIZE; tcc++) {
00583 if(tccBx[tcc] != ECALDCC_BunchCrossing && tccBx[tcc] != -1 && ECALDCC_BunchCrossing != -1) meEEBunchCrossingTCCErrors_->Fill( xism, 1/(float)tccBx.size());
00584 }
00585 }
00586
00587 if(srpBx != ECALDCC_BunchCrossing && srpBx != -1 && ECALDCC_BunchCrossing != -1) meEEBunchCrossingSRPErrors_->Fill( xism );
00588
00589 const std::vector<short> feLv1 = dcchItr->getFELv1();
00590 const std::vector<short> tccLv1 = dcchItr->getTCCLv1();
00591 const short srpLv1 = dcchItr->getSRPLv1();
00592
00593
00594 int ECALDCC_L1A_12bit = ECALDCC_L1A & 0xfff;
00595 int feLv1Offset = ( e.isRealData() ) ? 1 : 0;
00596
00597 for(int fe=0; fe<(int)feLv1.size(); fe++) {
00598
00599 if( ( status[fe] == 9 || status[fe] == 11 )) continue;
00600 if(feLv1[fe]+feLv1Offset != ECALDCC_L1A_12bit && feLv1[fe] != -1 && ECALDCC_L1A_12bit - 1 != -1) {
00601 meEEL1AFEErrors_->Fill( xism, 1/(float)feLv1.size());
00602 meEESynchronizationErrorsByLumi_->Fill( xism, 1/(float)feLv1.size() );
00603 } else if( BxSynchStatus[fe]==0 ) meEESynchronizationErrorsByLumi_->Fill( xism, 1/(float)feLv1.size() );
00604 }
00605
00606
00607
00608 if(tccLv1.size() == MAX_TCC_SIZE) {
00609 for(int tcc=0; tcc<MAX_TCC_SIZE; tcc++) {
00610 if(tccLv1[tcc] != ECALDCC_L1A_12bit && tccLv1[tcc] != -1 && ECALDCC_L1A_12bit - 1 != -1) meEEL1ATCCErrors_->Fill( xism, 1/(float)tccLv1.size());
00611 }
00612 }
00613
00614 if(srpLv1 != ECALDCC_L1A_12bit && srpLv1 != -1 && ECALDCC_L1A_12bit - 1 != -1) meEEL1ASRPErrors_->Fill( xism );
00615
00616 if ( gtFedDataSize > 0 ) {
00617
00618 if ( GT_OrbitNumber != ECALDCC_OrbitNumber ) meEEOrbitNumberErrors_->Fill ( xism );
00619
00620 } else {
00621
00622 if ( ECALDCC_OrbitNumber_MostFreqId != ECALDCC_OrbitNumber ) meEEOrbitNumberErrors_->Fill ( xism );
00623
00624 }
00625
00626 float evtType = dcchItr->getRunType();
00627
00628 if ( evtType < 0 || evtType > 22 ) evtType = -1;
00629
00630 if ( ECALDCC_BunchCrossing < calibrationBX_ ) meEEEventTypePreCalibrationBX_->Fill( evtType+0.5, 1./18. );
00631 if ( ECALDCC_BunchCrossing == calibrationBX_ ) meEEEventTypeCalibrationBX_->Fill( evtType+0.5, 1./18. );
00632 if ( ECALDCC_BunchCrossing > calibrationBX_ ) meEEEventTypePostCalibrationBX_->Fill ( evtType+0.5, 1./18. );
00633
00634 if ( ECALDCC_BunchCrossing != calibrationBX_ ) {
00635 if ( evtType != EcalDCCHeaderBlock::COSMIC &&
00636 evtType != EcalDCCHeaderBlock::MTCC &&
00637 evtType != EcalDCCHeaderBlock::COSMICS_GLOBAL &&
00638 evtType != EcalDCCHeaderBlock::PHYSICS_GLOBAL &&
00639 evtType != EcalDCCHeaderBlock::COSMICS_LOCAL &&
00640 evtType != EcalDCCHeaderBlock::PHYSICS_LOCAL &&
00641 evtType != -1 ) meEECalibrationEventErrors_->Fill( xism );
00642 } else {
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 ) meEECalibrationEventErrors_->Fill( xism );
00649 }
00650
00651 }
00652
00653 } else {
00654 edm::LogWarning("EERawDataTask") << EcalRawDataCollection_ << " not available";
00655 }
00656
00657 }
00658