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