00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <iostream>
00012 #include <fstream>
00013 #include <vector>
00014 #include <math.h>
00015 #include <cassert>
00016
00017 #include "FWCore/ServiceRegistry/interface/Service.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "FWCore/Framework/interface/ESHandle.h"
00020
00021 #include "DQMServices/Core/interface/MonitorElement.h"
00022
00023 #include "DQMServices/Core/interface/DQMStore.h"
00024
00025 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00026 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00027 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
00028
00029 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00030 #include "DataFormats/EcalRawData/interface/EcalRawDataCollections.h"
00031 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
00032
00033 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
00034 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00035
00036 #include "DQM/EcalCommon/interface/Numbers.h"
00037
00038 #include "DQM/EcalEndcapMonitorTasks/interface/EESelectiveReadoutTask.h"
00039
00040 #include "CondFormats/EcalObjects/interface/EcalSRSettings.h"
00041 #include "CondFormats/DataRecord/interface/EcalSRSettingsRcd.h"
00042
00043
00044 EESelectiveReadoutTask::EESelectiveReadoutTask(const edm::ParameterSet& ps){
00045
00046 init_ = false;
00047
00048 dqmStore_ = edm::Service<DQMStore>().operator->();
00049
00050 prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00051
00052 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00053
00054 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00055
00056
00057 EEDigiCollection_ = ps.getParameter<edm::InputTag>("EEDigiCollection");
00058 EEUnsuppressedDigiCollection_ = ps.getParameter<edm::InputTag>("EEUsuppressedDigiCollection");
00059 EESRFlagCollection_ = ps.getParameter<edm::InputTag>("EESRFlagCollection");
00060 EcalTrigPrimDigiCollection_ = ps.getParameter<edm::InputTag>("EcalTrigPrimDigiCollection");
00061 FEDRawDataCollection_ = ps.getParameter<edm::InputTag>("FEDRawDataCollection");
00062 firstFIRSample_ = ps.getParameter<int>("ecalDccZs1stSample");
00063
00064 useCondDb_ = ps.getParameter<bool>("configFromCondDB");
00065 if(!useCondDb_) configFirWeights(ps.getParameter<std::vector<double> >("dccWeights"));
00066
00067
00068 EEDccEventSize_ = 0;
00069 EEDccEventSizeMap_ = 0;
00070
00071 for(int i=0; i<2; i++) {
00072 EETowerSize_[i] = 0;
00073 EETTFMismatch_[i] = 0;
00074 EEReadoutUnitForcedBitMap_[i] = 0;
00075 EEFullReadoutSRFlagMap_[i] = 0;
00076 EEFullReadoutSRFlagCount_[i] = 0;
00077 EEZeroSuppression1SRFlagMap_[i] = 0;
00078 EEHighInterestTriggerTowerFlagMap_[i] = 0;
00079 EEMediumInterestTriggerTowerFlagMap_[i] = 0;
00080 EELowInterestTriggerTowerFlagMap_[i] = 0;
00081 EETTFlags_[i] = 0;
00082 EECompleteZSMap_[i] = 0;
00083 EECompleteZSCount_[i] = 0;
00084 EEDroppedFRMap_[i] = 0;
00085 EEDroppedFRCount_[i] = 0;
00086 EEEventSize_[i] = 0;
00087 EEHighInterestPayload_[i] = 0;
00088 EELowInterestPayload_[i] = 0;
00089 EEHighInterestZsFIR_[i] = 0;
00090 EELowInterestZsFIR_[i] = 0;
00091 }
00092
00093
00094 float ZSthreshold = 0.608;
00095 float zeroBinSize = ZSthreshold / 20.;
00096 for(int i=0; i<20; i++) ybins[i] = i*zeroBinSize;
00097 for(int i=20; i<133; i++) ybins[i] = ZSthreshold * (i-19);
00098 for(int i=0; i<=18; i++) xbins[i] = i+1;
00099
00100 }
00101
00102 EESelectiveReadoutTask::~EESelectiveReadoutTask() {
00103
00104 }
00105
00106 void EESelectiveReadoutTask::beginJob(void) {
00107
00108 ievt_ = 0;
00109
00110 if ( dqmStore_ ) {
00111 dqmStore_->setCurrentFolder(prefixME_ + "/EESelectiveReadoutTask");
00112 dqmStore_->rmdir(prefixME_ + "/EESelectiveReadoutTask");
00113 }
00114
00115 }
00116
00117 void EESelectiveReadoutTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00118
00119 Numbers::initGeometry(c, false);
00120
00121 if ( ! mergeRuns_ ) this->reset();
00122
00123 for(int ix = 0; ix < 20; ix++ ) {
00124 for(int iy = 0; iy < 20; iy++ ) {
00125 for(int iz = 0; iz < 2; iz++) {
00126 nEvtFullReadout[ix][iy][iz] = 0;
00127 nEvtZS1Readout[ix][iy][iz] = 0;
00128 nEvtZSReadout[ix][iy][iz] = 0;
00129 nEvtCompleteReadoutIfZS[ix][iy][iz] = 0;
00130 nEvtDroppedReadoutIfFR[ix][iy][iz] = 0;
00131 nEvtRUForced[ix][iy][iz] = 0;
00132 nEvtAnyReadout[ix][iy][iz] = 0;
00133 }
00134 }
00135 }
00136 for(int ix = 0; ix < 100; ix++ ) {
00137 for(int iy = 0; iy < 100; iy++ ) {
00138 for(int iz = 0; iz < 2; iz++) {
00139 nEvtHighInterest[ix][iy][iz] = 0;
00140 nEvtMediumInterest[ix][iy][iz] = 0;
00141 nEvtLowInterest[ix][iy][iz] = 0;
00142 nEvtAnyInterest[ix][iy][iz] = 0;
00143 }
00144 }
00145 }
00146
00147
00148 if(useCondDb_) {
00149 edm::ESHandle<EcalSRSettings> hSr;
00150 c.get<EcalSRSettingsRcd>().get(hSr);
00151 settings_ = hSr.product();
00152 std::vector<double> wsFromDB;
00153
00154 std::vector<std::vector<float> > dccs = settings_->dccNormalizedWeights_;
00155 int nws = dccs.size();
00156 if(nws == 1) {
00157 for(std::vector<float>::const_iterator it = dccs[0].begin(); it != dccs[0].end(); it++) {
00158 wsFromDB.push_back(*it);
00159 }
00160 }
00161 else edm::LogWarning("EESelectiveReadoutTask") << "DCC weight set is not exactly 1.";
00162
00163 configFirWeights(wsFromDB);
00164 }
00165
00166 }
00167
00168 void EESelectiveReadoutTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00169
00170 }
00171
00172 void EESelectiveReadoutTask::reset(void) {
00173
00174 if ( EETowerSize_[0] ) EETowerSize_[0]->Reset();
00175 if ( EETowerSize_[1] ) EETowerSize_[1]->Reset();
00176
00177 if ( EETTFMismatch_[0] ) EETTFMismatch_[0]->Reset();
00178 if ( EETTFMismatch_[1] ) EETTFMismatch_[1]->Reset();
00179
00180 if ( EEDccEventSize_ ) EEDccEventSize_->Reset();
00181
00182 if ( EEDccEventSizeMap_ ) EEDccEventSizeMap_->Reset();
00183
00184 if ( EEReadoutUnitForcedBitMap_[0] ) EEReadoutUnitForcedBitMap_[0]->Reset();
00185 if ( EEReadoutUnitForcedBitMap_[1] ) EEReadoutUnitForcedBitMap_[1]->Reset();
00186
00187 if ( EEFullReadoutSRFlagMap_[0] ) EEFullReadoutSRFlagMap_[0]->Reset();
00188 if ( EEFullReadoutSRFlagMap_[1] ) EEFullReadoutSRFlagMap_[1]->Reset();
00189
00190 if ( EEFullReadoutSRFlagCount_[0] ) EEFullReadoutSRFlagCount_[0]->Reset();
00191 if ( EEFullReadoutSRFlagCount_[1] ) EEFullReadoutSRFlagCount_[1]->Reset();
00192
00193 if ( EEZeroSuppression1SRFlagMap_[0] ) EEZeroSuppression1SRFlagMap_[0]->Reset();
00194 if ( EEZeroSuppression1SRFlagMap_[1] ) EEZeroSuppression1SRFlagMap_[1]->Reset();
00195
00196 if ( EEHighInterestTriggerTowerFlagMap_[0] ) EEHighInterestTriggerTowerFlagMap_[0]->Reset();
00197 if ( EEHighInterestTriggerTowerFlagMap_[1] ) EEHighInterestTriggerTowerFlagMap_[1]->Reset();
00198
00199 if ( EEMediumInterestTriggerTowerFlagMap_[0] ) EEMediumInterestTriggerTowerFlagMap_[0]->Reset();
00200 if ( EEMediumInterestTriggerTowerFlagMap_[1] ) EEMediumInterestTriggerTowerFlagMap_[1]->Reset();
00201
00202 if ( EELowInterestTriggerTowerFlagMap_[0] ) EELowInterestTriggerTowerFlagMap_[0]->Reset();
00203 if ( EELowInterestTriggerTowerFlagMap_[1] ) EELowInterestTriggerTowerFlagMap_[1]->Reset();
00204
00205 if ( EETTFlags_[0] ) EETTFlags_[0]->Reset();
00206 if ( EETTFlags_[1] ) EETTFlags_[1]->Reset();
00207
00208 if ( EECompleteZSMap_[0] ) EECompleteZSMap_[0]->Reset();
00209 if ( EECompleteZSMap_[1] ) EECompleteZSMap_[1]->Reset();
00210
00211 if ( EECompleteZSCount_[0] ) EECompleteZSCount_[0]->Reset();
00212 if ( EECompleteZSCount_[1] ) EECompleteZSCount_[1]->Reset();
00213
00214 if ( EEDroppedFRMap_[0] ) EEDroppedFRMap_[0]->Reset();
00215 if ( EEDroppedFRMap_[1] ) EEDroppedFRMap_[1]->Reset();
00216
00217 if ( EEDroppedFRCount_[0] ) EEDroppedFRCount_[0]->Reset();
00218 if ( EEDroppedFRCount_[1] ) EEDroppedFRCount_[1]->Reset();
00219
00220 if ( EEEventSize_[0] ) EEEventSize_[0]->Reset();
00221 if ( EEEventSize_[1] ) EEEventSize_[1]->Reset();
00222
00223 if ( EEHighInterestPayload_[0] ) EEHighInterestPayload_[0]->Reset();
00224 if ( EEHighInterestPayload_[1] ) EEHighInterestPayload_[1]->Reset();
00225
00226 if ( EELowInterestPayload_[0] ) EELowInterestPayload_[0]->Reset();
00227 if ( EELowInterestPayload_[1] ) EELowInterestPayload_[1]->Reset();
00228
00229 if ( EEHighInterestZsFIR_[0] ) EEHighInterestZsFIR_[0]->Reset();
00230 if ( EEHighInterestZsFIR_[1] ) EEHighInterestZsFIR_[1]->Reset();
00231
00232 if ( EELowInterestZsFIR_[0] ) EELowInterestZsFIR_[0]->Reset();
00233 if ( EELowInterestZsFIR_[1] ) EELowInterestZsFIR_[1]->Reset();
00234
00235 }
00236
00237 void EESelectiveReadoutTask::setup(void) {
00238
00239 init_ = true;
00240
00241 std::string name;
00242
00243 if ( dqmStore_ ) {
00244 dqmStore_->setCurrentFolder(prefixME_ + "/EESelectiveReadoutTask");
00245
00246 name = "EESRT tower event size EE -";
00247 EETowerSize_[0] = dqmStore_->bookProfile2D(name, name, 20, 0., 20., 20, 0., 20., 100, 0., 200., "s");
00248 EETowerSize_[0]->setAxisTitle("jx", 1);
00249 EETowerSize_[0]->setAxisTitle("jy", 2);
00250
00251 name = "EESRT tower event size EE +";
00252 EETowerSize_[1] = dqmStore_->bookProfile2D(name, name, 20, 0., 20., 20, 0., 20., 100, 0., 200., "s");
00253 EETowerSize_[1]->setAxisTitle("jx", 1);
00254 EETowerSize_[1]->setAxisTitle("jy", 2);
00255
00256 name = "EESRT TT flag mismatch EE -";
00257 EETTFMismatch_[0] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
00258 EETTFMismatch_[0]->setAxisTitle("jx", 1);
00259 EETTFMismatch_[0]->setAxisTitle("jy", 2);
00260
00261 name = "EESRT TT flag mismatch EE +";
00262 EETTFMismatch_[1] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
00263 EETTFMismatch_[1]->setAxisTitle("jx", 1);
00264 EETTFMismatch_[1]->setAxisTitle("jy", 2);
00265
00266 name = "EESRT DCC event size";
00267 EEDccEventSize_ = dqmStore_->bookProfile(name, name, 18, 1, 19, 100, 0., 200., "s");
00268 EEDccEventSize_->setAxisTitle("event size (kB)", 2);
00269 for (int i = 0; i < 18; i++) {
00270 EEDccEventSize_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00271 }
00272
00273 name = "EESRT event size vs DCC";
00274 EEDccEventSizeMap_ = dqmStore_->book2D(name, name, 18, xbins, 132, ybins);
00275 EEDccEventSizeMap_->setAxisTitle("event size (kB)", 2);
00276 for (int i = 0; i < 18; i++) {
00277 EEDccEventSizeMap_->setBinLabel(i+1, Numbers::sEE(i+1).c_str(), 1);
00278 }
00279
00280 name = "EESRT readout unit with SR forced EE -";
00281 EEReadoutUnitForcedBitMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00282 EEReadoutUnitForcedBitMap_[0]->setAxisTitle("jx", 1);
00283 EEReadoutUnitForcedBitMap_[0]->setAxisTitle("jy", 2);
00284 EEReadoutUnitForcedBitMap_[0]->setAxisTitle("rate", 3);
00285
00286 name = "EESRT readout unit with SR forced EE +";
00287 EEReadoutUnitForcedBitMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00288 EEReadoutUnitForcedBitMap_[1]->setAxisTitle("jx", 1);
00289 EEReadoutUnitForcedBitMap_[1]->setAxisTitle("jy", 2);
00290 EEReadoutUnitForcedBitMap_[1]->setAxisTitle("rate", 3);
00291
00292 name = "EESRT full readout SR Flags EE -";
00293 EEFullReadoutSRFlagMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00294 EEFullReadoutSRFlagMap_[0]->setAxisTitle("jx", 1);
00295 EEFullReadoutSRFlagMap_[0]->setAxisTitle("jy", 2);
00296 EEFullReadoutSRFlagMap_[0]->setAxisTitle("rate", 3);
00297
00298 name = "EESRT full readout SR Flags EE +";
00299 EEFullReadoutSRFlagMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00300 EEFullReadoutSRFlagMap_[1]->setAxisTitle("jx", 1);
00301 EEFullReadoutSRFlagMap_[1]->setAxisTitle("jy", 2);
00302 EEFullReadoutSRFlagMap_[1]->setAxisTitle("rate", 3);
00303
00304 name = "EESRT full readout SR Flags Number EE -";
00305 EEFullReadoutSRFlagCount_[0] = dqmStore_->book1D(name, name, 200, 0., 200.);
00306 EEFullReadoutSRFlagCount_[0]->setAxisTitle("Readout Units number", 1);
00307
00308 name = "EESRT full readout SR Flags Number EE +";
00309 EEFullReadoutSRFlagCount_[1] = dqmStore_->book1D(name, name, 200, 0., 200.);
00310 EEFullReadoutSRFlagCount_[1]->setAxisTitle("Fully readout RU number", 1);
00311
00312 name = "EESRT zero suppression 1 SR Flags EE -";
00313 EEZeroSuppression1SRFlagMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00314 EEZeroSuppression1SRFlagMap_[0]->setAxisTitle("jx", 1);
00315 EEZeroSuppression1SRFlagMap_[0]->setAxisTitle("jy", 2);
00316 EEZeroSuppression1SRFlagMap_[0]->setAxisTitle("rate", 3);
00317
00318 name = "EESRT zero suppression 1 SR Flags EE +";
00319 EEZeroSuppression1SRFlagMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00320 EEZeroSuppression1SRFlagMap_[1]->setAxisTitle("jx", 1);
00321 EEZeroSuppression1SRFlagMap_[1]->setAxisTitle("jy", 2);
00322 EEZeroSuppression1SRFlagMap_[1]->setAxisTitle("rate", 3);
00323
00324 name = "EESRT high interest TT Flags EE -";
00325 EEHighInterestTriggerTowerFlagMap_[0] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
00326 EEHighInterestTriggerTowerFlagMap_[0]->setAxisTitle("jx", 1);
00327 EEHighInterestTriggerTowerFlagMap_[0]->setAxisTitle("jy", 2);
00328 EEHighInterestTriggerTowerFlagMap_[0]->setAxisTitle("rate", 3);
00329
00330 name = "EESRT high interest TT Flags EE +";
00331 EEHighInterestTriggerTowerFlagMap_[1] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
00332 EEHighInterestTriggerTowerFlagMap_[1]->setAxisTitle("jx", 1);
00333 EEHighInterestTriggerTowerFlagMap_[1]->setAxisTitle("jy", 2);
00334 EEHighInterestTriggerTowerFlagMap_[1]->setAxisTitle("rate", 3);
00335
00336 name = "EESRT medium interest TT Flags EE -";
00337 EEMediumInterestTriggerTowerFlagMap_[0] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
00338 EEMediumInterestTriggerTowerFlagMap_[0]->setAxisTitle("jx", 1);
00339 EEMediumInterestTriggerTowerFlagMap_[0]->setAxisTitle("jy", 2);
00340 EEMediumInterestTriggerTowerFlagMap_[0]->setAxisTitle("rate", 3);
00341
00342 name = "EESRT medium interest TT Flags EE +";
00343 EEMediumInterestTriggerTowerFlagMap_[1] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
00344 EEMediumInterestTriggerTowerFlagMap_[1]->setAxisTitle("jx", 1);
00345 EEMediumInterestTriggerTowerFlagMap_[1]->setAxisTitle("jy", 2);
00346 EEMediumInterestTriggerTowerFlagMap_[1]->setAxisTitle("rate", 3);
00347
00348 name = "EESRT low interest TT Flags EE -";
00349 EELowInterestTriggerTowerFlagMap_[0] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
00350 EELowInterestTriggerTowerFlagMap_[0]->setAxisTitle("jx", 1);
00351 EELowInterestTriggerTowerFlagMap_[0]->setAxisTitle("jy", 2);
00352 EELowInterestTriggerTowerFlagMap_[0]->setAxisTitle("rate", 3);
00353
00354 name = "EESRT low interest TT Flags EE +";
00355 EELowInterestTriggerTowerFlagMap_[1] = dqmStore_->book2D(name, name, 100, 0., 100., 100, 0., 100.);
00356 EELowInterestTriggerTowerFlagMap_[1]->setAxisTitle("jx", 1);
00357 EELowInterestTriggerTowerFlagMap_[1]->setAxisTitle("jy", 2);
00358 EELowInterestTriggerTowerFlagMap_[1]->setAxisTitle("rate", 3);
00359
00360 name = "EESRT TT Flags EE -";
00361 EETTFlags_[0] = dqmStore_->book1D(name, name, 8, 0., 8.);
00362 EETTFlags_[0]->setAxisTitle("TT Flag value", 1);
00363
00364 name = "EESRT TT Flags EE +";
00365 EETTFlags_[1] = dqmStore_->book1D(name, name, 8, 0., 8.);
00366 EETTFlags_[1]->setAxisTitle("TT Flag value", 1);
00367
00368 name = "EESRT ZS Flagged Fully Readout EE -";
00369 EECompleteZSMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00370 EECompleteZSMap_[0]->setAxisTitle("jphi", 1);
00371 EECompleteZSMap_[0]->setAxisTitle("jeta", 2);
00372 EECompleteZSMap_[0]->setAxisTitle("rate", 3);
00373
00374 name = "EESRT ZS Flagged Fully Readout EE +";
00375 EECompleteZSMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00376 EECompleteZSMap_[1]->setAxisTitle("jphi", 1);
00377 EECompleteZSMap_[1]->setAxisTitle("jeta", 2);
00378 EECompleteZSMap_[1]->setAxisTitle("rate", 3);
00379
00380 name = "EESRT ZS Flagged Fully Readout Number EE -";
00381 EECompleteZSCount_[0] = dqmStore_->book1D(name, name, 20, 0., 20.);
00382 EECompleteZSCount_[0]->setAxisTitle("Readout Units number", 1);
00383
00384 name = "EESRT ZS Flagged Fully Readout Number EE +";
00385 EECompleteZSCount_[1] = dqmStore_->book1D(name, name, 20, 0., 20.);
00386 EECompleteZSCount_[1]->setAxisTitle("Readout Units number", 1);
00387
00388 name = "EESRT FR Flagged Dropped Readout EE -";
00389 EEDroppedFRMap_[0] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00390 EEDroppedFRMap_[0]->setAxisTitle("jphi", 1);
00391 EEDroppedFRMap_[0]->setAxisTitle("jeta", 2);
00392 EEDroppedFRMap_[0]->setAxisTitle("rate", 3);
00393
00394 name = "EESRT FR Flagged Dropped Readout EE +";
00395 EEDroppedFRMap_[1] = dqmStore_->book2D(name, name, 20, 0., 20., 20, 0., 20.);
00396 EEDroppedFRMap_[1]->setAxisTitle("jphi", 1);
00397 EEDroppedFRMap_[1]->setAxisTitle("jeta", 2);
00398 EEDroppedFRMap_[1]->setAxisTitle("rate", 3);
00399
00400 name = "EESRT FR Flagged Dropped Readout Number EE -";
00401 EEDroppedFRCount_[0] = dqmStore_->book1D(name, name, 20, 0., 20.);
00402 EEDroppedFRCount_[0]->setAxisTitle("Readout Units number", 1);
00403
00404 name = "EESRT FR Flagged Dropped Readout Number EE +";
00405 EEDroppedFRCount_[1] = dqmStore_->book1D(name, name, 20, 0., 20.);
00406 EEDroppedFRCount_[1]->setAxisTitle("Readout Units number", 1);
00407
00408 name = "EESRT event size EE -";
00409 EEEventSize_[0] = dqmStore_->book1D(name, name, 100, 0, 200);
00410 EEEventSize_[0]->setAxisTitle("event size (kB)",1);
00411
00412 name = "EESRT event size EE +";
00413 EEEventSize_[1] = dqmStore_->book1D(name, name, 100, 0, 200);
00414 EEEventSize_[1]->setAxisTitle("event size (kB)",1);
00415
00416 name = "EESRT high interest payload EE -";
00417 EEHighInterestPayload_[0] = dqmStore_->book1D(name, name, 100, 0, 200);
00418 EEHighInterestPayload_[0]->setAxisTitle("event size (kB)",1);
00419
00420 name = "EESRT high interest payload EE +";
00421 EEHighInterestPayload_[1] = dqmStore_->book1D(name, name, 100, 0, 200);
00422 EEHighInterestPayload_[1]->setAxisTitle("event size (kB)",1);
00423
00424 name = "EESRT low interest payload EE -";
00425 EELowInterestPayload_[0] = dqmStore_->book1D(name, name, 100, 0, 200);
00426 EELowInterestPayload_[0]->setAxisTitle("event size (kB)",1);
00427
00428 name = "EESRT low interest payload EE +";
00429 EELowInterestPayload_[1] = dqmStore_->book1D(name, name, 100, 0, 200);
00430 EELowInterestPayload_[1]->setAxisTitle("event size (kB)",1);
00431
00432 name = "EESRT high interest ZS filter output EE -";
00433 EEHighInterestZsFIR_[0] = dqmStore_->book1D(name, name, 60, -30, 30);
00434 EEHighInterestZsFIR_[0]->setAxisTitle("ADC counts*4",1);
00435
00436 name = "EESRT high interest ZS filter output EE +";
00437 EEHighInterestZsFIR_[1] = dqmStore_->book1D(name, name, 60, -30, 30);
00438 EEHighInterestZsFIR_[1]->setAxisTitle("ADC counts*4",1);
00439
00440 name = "EESRT low interest ZS filter output EE -";
00441 EELowInterestZsFIR_[0] = dqmStore_->book1D(name, name, 60, -30, 30);
00442 EELowInterestZsFIR_[0]->setAxisTitle("ADC counts*4",1);
00443
00444 name = "EESRT low interest ZS filter output EE +";
00445 EELowInterestZsFIR_[1] = dqmStore_->book1D(name, name, 60, -30, 30);
00446 EELowInterestZsFIR_[1]->setAxisTitle("ADC counts*4",1);
00447
00448 }
00449
00450 }
00451
00452 void EESelectiveReadoutTask::cleanup(void){
00453
00454 if ( ! init_ ) return;
00455
00456 if ( dqmStore_ ) {
00457 dqmStore_->setCurrentFolder(prefixME_ + "/EESelectiveReadoutTask");
00458
00459 if ( EETowerSize_[0] ) dqmStore_->removeElement( EETowerSize_[0]->getName() );
00460 EETowerSize_[0] = 0;
00461
00462 if ( EETowerSize_[1] ) dqmStore_->removeElement( EETowerSize_[1]->getName() );
00463 EETowerSize_[1] = 0;
00464
00465 if ( EETTFMismatch_[0] ) dqmStore_->removeElement( EETTFMismatch_[0]->getName() );
00466 EETTFMismatch_[0] = 0;
00467
00468 if ( EETTFMismatch_[1] ) dqmStore_->removeElement( EETTFMismatch_[1]->getName() );
00469 EETTFMismatch_[1] = 0;
00470
00471 if ( EEDccEventSize_ ) dqmStore_->removeElement( EEDccEventSize_->getName() );
00472 EEDccEventSize_ = 0;
00473
00474 if ( EEDccEventSizeMap_ ) dqmStore_->removeElement( EEDccEventSizeMap_->getName() );
00475 EEDccEventSizeMap_ = 0;
00476
00477 if ( EEReadoutUnitForcedBitMap_[0] ) dqmStore_->removeElement( EEReadoutUnitForcedBitMap_[0]->getName() );
00478 EEReadoutUnitForcedBitMap_[0] = 0;
00479
00480 if ( EEReadoutUnitForcedBitMap_[1] ) dqmStore_->removeElement( EEReadoutUnitForcedBitMap_[1]->getName() );
00481 EEReadoutUnitForcedBitMap_[1] = 0;
00482
00483 if ( EEFullReadoutSRFlagMap_[0] ) dqmStore_->removeElement( EEFullReadoutSRFlagMap_[0]->getName() );
00484 EEFullReadoutSRFlagMap_[0] = 0;
00485
00486 if ( EEFullReadoutSRFlagMap_[1] ) dqmStore_->removeElement( EEFullReadoutSRFlagMap_[1]->getName() );
00487 EEFullReadoutSRFlagMap_[1] = 0;
00488
00489 if ( EEFullReadoutSRFlagCount_[0] ) dqmStore_->removeElement( EEFullReadoutSRFlagCount_[0]->getName() );
00490 EEFullReadoutSRFlagCount_[0] = 0;
00491
00492 if ( EEFullReadoutSRFlagCount_[1] ) dqmStore_->removeElement( EEFullReadoutSRFlagCount_[1]->getName() );
00493 EEFullReadoutSRFlagCount_[1] = 0;
00494
00495 if ( EEZeroSuppression1SRFlagMap_[0] ) dqmStore_->removeElement( EEZeroSuppression1SRFlagMap_[0]->getName() );
00496 EEZeroSuppression1SRFlagMap_[0] = 0;
00497
00498 if ( EEZeroSuppression1SRFlagMap_[1] ) dqmStore_->removeElement( EEZeroSuppression1SRFlagMap_[1]->getName() );
00499 EEZeroSuppression1SRFlagMap_[1] = 0;
00500
00501 if ( EEHighInterestTriggerTowerFlagMap_[0] ) dqmStore_->removeElement( EEHighInterestTriggerTowerFlagMap_[0]->getName() );
00502 EEHighInterestTriggerTowerFlagMap_[0] = 0;
00503
00504 if ( EEHighInterestTriggerTowerFlagMap_[1] ) dqmStore_->removeElement( EEHighInterestTriggerTowerFlagMap_[1]->getName() );
00505 EEHighInterestTriggerTowerFlagMap_[1] = 0;
00506
00507 if ( EELowInterestTriggerTowerFlagMap_[0] ) dqmStore_->removeElement( EELowInterestTriggerTowerFlagMap_[0]->getName() );
00508 EELowInterestTriggerTowerFlagMap_[0] = 0;
00509
00510 if ( EELowInterestTriggerTowerFlagMap_[1] ) dqmStore_->removeElement( EELowInterestTriggerTowerFlagMap_[1]->getName() );
00511 EELowInterestTriggerTowerFlagMap_[1] = 0;
00512
00513 if ( EETTFlags_[0] ) dqmStore_->removeElement( EETTFlags_[0]->getName() );
00514 EETTFlags_[0] = 0;
00515
00516 if ( EETTFlags_[1] ) dqmStore_->removeElement( EETTFlags_[1]->getName() );
00517 EETTFlags_[1] = 0;
00518
00519 if ( EECompleteZSMap_[0] ) dqmStore_->removeElement( EECompleteZSMap_[0]->getName() );
00520 EECompleteZSMap_[0] = 0;
00521
00522 if ( EECompleteZSMap_[1] ) dqmStore_->removeElement( EECompleteZSMap_[1]->getName() );
00523 EECompleteZSMap_[1] = 0;
00524
00525 if ( EECompleteZSCount_[0] ) dqmStore_->removeElement( EECompleteZSCount_[0]->getName() );
00526 EECompleteZSCount_[0] = 0;
00527
00528 if ( EECompleteZSCount_[1] ) dqmStore_->removeElement( EECompleteZSCount_[1]->getName() );
00529 EECompleteZSCount_[1] = 0;
00530
00531 if ( EEDroppedFRMap_[0] ) dqmStore_->removeElement( EEDroppedFRMap_[0]->getName() );
00532 EEDroppedFRMap_[0] = 0;
00533
00534 if ( EEDroppedFRMap_[1] ) dqmStore_->removeElement( EEDroppedFRMap_[1]->getName() );
00535 EEDroppedFRMap_[1] = 0;
00536
00537 if ( EEDroppedFRCount_[0] ) dqmStore_->removeElement( EEDroppedFRCount_[0]->getName() );
00538 EEDroppedFRCount_[0] = 0;
00539
00540 if ( EEDroppedFRCount_[1] ) dqmStore_->removeElement( EEDroppedFRCount_[1]->getName() );
00541 EEDroppedFRCount_[1] = 0;
00542
00543 if ( EEEventSize_[0] ) dqmStore_->removeElement( EEEventSize_[0]->getName() );
00544 EEEventSize_[0] = 0;
00545
00546 if ( EEEventSize_[1] ) dqmStore_->removeElement( EEEventSize_[1]->getName() );
00547 EEEventSize_[1] = 0;
00548
00549 if ( EEHighInterestPayload_[0] ) dqmStore_->removeElement( EEHighInterestPayload_[0]->getName() );
00550 EEHighInterestPayload_[0] = 0;
00551
00552 if ( EEHighInterestPayload_[1] ) dqmStore_->removeElement( EEHighInterestPayload_[1]->getName() );
00553 EEHighInterestPayload_[1] = 0;
00554
00555 if ( EELowInterestPayload_[0] ) dqmStore_->removeElement( EELowInterestPayload_[0]->getName() );
00556 EELowInterestPayload_[0] = 0;
00557
00558 if ( EELowInterestPayload_[1] ) dqmStore_->removeElement( EELowInterestPayload_[1]->getName() );
00559 EELowInterestPayload_[1] = 0;
00560
00561 if ( EEHighInterestZsFIR_[0] ) dqmStore_->removeElement( EEHighInterestZsFIR_[0]->getName() );
00562 EEHighInterestZsFIR_[0] = 0;
00563
00564 if ( EEHighInterestZsFIR_[1] ) dqmStore_->removeElement( EEHighInterestZsFIR_[1]->getName() );
00565 EEHighInterestZsFIR_[1] = 0;
00566
00567 if ( EELowInterestZsFIR_[0] ) dqmStore_->removeElement( EELowInterestZsFIR_[0]->getName() );
00568 EELowInterestZsFIR_[0] = 0;
00569
00570 if ( EELowInterestZsFIR_[1] ) dqmStore_->removeElement( EELowInterestZsFIR_[1]->getName() );
00571 EELowInterestZsFIR_[1] = 0;
00572
00573 }
00574
00575 init_ = false;
00576
00577 }
00578
00579 void EESelectiveReadoutTask::endJob(void){
00580
00581 edm::LogInfo("EESelectiveReadoutTask") << "analyzed " << ievt_ << " events";
00582
00583 if ( enableCleanup_ ) this->cleanup();
00584
00585 }
00586
00587 void EESelectiveReadoutTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00588
00589 if ( ! init_ ) this->setup();
00590
00591 ievt_++;
00592
00593 edm::Handle<FEDRawDataCollection> raw;
00594 if ( e.getByLabel(FEDRawDataCollection_, raw) ) {
00595
00596 int EEFirstFED[2];
00597 EEFirstFED[0] = 601;
00598 EEFirstFED[1] = 646;
00599 for(int zside=0; zside<2; zside++) {
00600
00601 int firstFedOnSide=EEFirstFED[zside];
00602
00603 for ( int iDcc = 0; iDcc < 9; ++iDcc ) {
00604
00605 int ism = 0;
00606 if ( zside == 0 ) ism = iDcc+1;
00607 else ism = 10+iDcc;
00608
00609 EEDccEventSize_->Fill( ism, ((double)raw->FEDData(firstFedOnSide+iDcc).size())/kByte );
00610 EEDccEventSizeMap_->Fill( ism, ((double)raw->FEDData(firstFedOnSide+iDcc).size())/kByte );
00611
00612 }
00613 }
00614
00615 } else {
00616 edm::LogWarning("EESelectiveReadoutTask") << FEDRawDataCollection_ << " not available";
00617 }
00618
00619
00620 int nFRO[2], nCompleteZS[2], nDroppedFRO[2];
00621 nFRO[0] = nFRO[1] = 0;
00622 nCompleteZS[0] = nCompleteZS[1] = 0;
00623 nDroppedFRO[0] = nDroppedFRO[1] = 0;
00624 edm::Handle<EESrFlagCollection> eeSrFlags;
00625 if ( e.getByLabel(EESRFlagCollection_,eeSrFlags) ) {
00626
00627
00628 double aLowInterest[2];
00629 double aHighInterest[2];
00630 double aAnyInterest[2];
00631
00632 aLowInterest[0]=0;
00633 aHighInterest[0]=0;
00634 aAnyInterest[0]=0;
00635 aLowInterest[1]=0;
00636 aHighInterest[1]=0;
00637 aAnyInterest[1]=0;
00638
00639 edm::Handle<EEDigiCollection> eeDigis;
00640 if ( e.getByLabel(EEDigiCollection_ , eeDigis) ) {
00641
00642 anaDigiInit();
00643
00644
00645 edm::ESHandle<EcalChannelStatus> pChannelStatus;
00646 c.get<EcalChannelStatusRcd>().get(pChannelStatus);
00647 const EcalChannelStatus* chStatus = pChannelStatus.product();
00648
00649 for (unsigned int digis=0; digis<eeDigis->size(); ++digis) {
00650 EEDataFrame eedf = (*eeDigis)[digis];
00651 EEDetId id = eedf.id();
00652 EcalChannelStatusMap::const_iterator chit;
00653 chit = chStatus->getMap().find(id.rawId());
00654 uint16_t statusCode = 0;
00655 if( chit != chStatus->getMap().end() ) {
00656 EcalChannelStatusCode ch_code = (*chit);
00657 statusCode = ch_code.getStatusCode();
00658 }
00659 anaDigi(eedf, *eeSrFlags, statusCode);
00660 }
00661
00662
00663 aLowInterest[0] = nEeLI_[0]*bytesPerCrystal/kByte;
00664 EELowInterestPayload_[0]->Fill(aLowInterest[0]);
00665 aLowInterest[1] = nEeLI_[1]*bytesPerCrystal/kByte;
00666 EELowInterestPayload_[1]->Fill(aLowInterest[1]);
00667
00668
00669 aHighInterest[0] = nEeHI_[0]*bytesPerCrystal/kByte;
00670 EEHighInterestPayload_[0]->Fill(aHighInterest[0]);
00671 aHighInterest[1] = nEeHI_[1]*bytesPerCrystal/kByte;
00672 EEHighInterestPayload_[1]->Fill(aHighInterest[1]);
00673
00674
00675 aAnyInterest[0] = getEeEventSize(nEe_[0])/kByte;
00676 EEEventSize_[0]->Fill(aAnyInterest[0]);
00677 aAnyInterest[1] = getEeEventSize(nEe_[1])/kByte;
00678 EEEventSize_[1]->Fill(aAnyInterest[1]);
00679
00680
00681 for(int ix = 0; ix < 20; ix++ ) {
00682 for(int iy = 0; iy < 20; iy++ ) {
00683 for(int iz = 0; iz < 2; iz++) {
00684
00685 double towerSize = nCrySC[ix][iy][iz] * bytesPerCrystal;
00686
00687 float xix = ix;
00688 if ( iz == 0 ) xix = 19 - xix;
00689 xix += 0.5;
00690
00691 float xiy = iy+0.5;
00692
00693 EETowerSize_[iz]->Fill(xix, xiy, towerSize);
00694
00695 }
00696 }
00697 }
00698
00699 } else {
00700 edm::LogWarning("EESelectiveReadoutTask") << EEDigiCollection_ << " not available";
00701 }
00702
00703
00704 std::map< int, std::vector<short> > towersStatus;
00705 edm::Handle<EcalRawDataCollection> dcchs;
00706
00707 if( e.getByLabel(FEDRawDataCollection_, dcchs) ) {
00708 for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
00709 if ( Numbers::subDet( *dcchItr ) != EcalEndcap ) continue;
00710 int ism = Numbers::iSM( *dcchItr, EcalEndcap );
00711 towersStatus.insert(std::make_pair(ism, dcchItr->getFEStatus()));
00712 }
00713 }
00714
00715 for ( EESrFlagCollection::const_iterator it = eeSrFlags->begin(); it != eeSrFlags->end(); ++it ) {
00716
00717 EcalScDetId id = it->id();
00718
00719 if ( Numbers::subDet( id ) != EcalEndcap ) continue;
00720
00721 int ix = id.ix();
00722 int iy = id.iy();
00723 int iDcc = dccNumOfRU(id);
00724 int ism = Numbers::iSM( id );
00725 int isc = Numbers::iSC( id );
00726
00727 int zside = id.zside();
00728
00729 int iz = ( zside < 0 ) ? 0 : 1;
00730
00731 if ( zside < 0 ) ix = 21 - ix;
00732
00733 nEvtAnyReadout[ix-1][iy-1][iz]++;
00734
00735 int flag = it->value() & ~EcalSrFlag::SRF_FORCED_MASK;
00736
00737 int status=0;
00738 if( towersStatus[ism].size() > 0 ) status = (towersStatus[ism])[isc];
00739
00740 if(flag == EcalSrFlag::SRF_FULL) {
00741 nEvtFullReadout[ix-1][iy-1][iz]++;
00742 nFRO[iz]++;
00743 if(nPerRu_[iDcc-1][isc] == 0) {
00744 if(status != 1) nEvtDroppedReadoutIfFR[ix-1][iy-1][iz]++;
00745 nDroppedFRO[iz]++;
00746 }
00747 }
00748
00749 if(flag == EcalSrFlag::SRF_ZS1) nEvtZS1Readout[ix-1][iy-1][iz]++;
00750
00751 if(it->value() & EcalSrFlag::SRF_FORCED_MASK) nEvtRUForced[ix-1][iy-1][iz]++;
00752
00753 if(flag == EcalSrFlag::SRF_ZS1 || flag == EcalSrFlag::SRF_ZS2) {
00754 nEvtZSReadout[ix-1][iy-1][iz]++;
00755 if(nPerRu_[iDcc-1][isc] == getCrystalCount(iDcc,isc)) {
00756 if(status != 1) nEvtCompleteReadoutIfZS[ix-1][iy-1][iz]++;
00757 nCompleteZS[iz]++;
00758 }
00759 }
00760
00761 }
00762 } else {
00763 edm::LogWarning("EESelectiveReadoutTask") << EESRFlagCollection_ << " not available";
00764 }
00765
00766 for(int ix = 0; ix < 20; ix++ ) {
00767 for(int iy = 0; iy < 20; iy++ ) {
00768 for(int iz = 0; iz < 2; iz++) {
00769
00770 if( nEvtAnyReadout[ix][iy][iz] ) {
00771
00772 float xix = ix;
00773 if ( iz == 0 ) xix = 19 - xix;
00774 xix += 0.5;
00775
00776 float xiy = iy+0.5;
00777
00778 float fraction = float(nEvtFullReadout[ix][iy][iz]) / float(nEvtAnyReadout[ix][iy][iz]);
00779 float error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
00780
00781 TH2F *h2d = EEFullReadoutSRFlagMap_[iz]->getTH2F();
00782
00783 int binx=0, biny=0;
00784
00785 if( h2d ) {
00786 binx = h2d->GetXaxis()->FindBin(xix);
00787 biny = h2d->GetYaxis()->FindBin(xiy);
00788 }
00789
00790 EEFullReadoutSRFlagMap_[iz]->setBinContent(binx, biny, fraction);
00791 EEFullReadoutSRFlagMap_[iz]->setBinError(binx, biny, error);
00792
00793
00794 fraction = float(nEvtZS1Readout[ix][iy][iz]) / float(nEvtAnyReadout[ix][iy][iz]);
00795 error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
00796
00797 h2d = EEZeroSuppression1SRFlagMap_[iz]->getTH2F();
00798
00799 if( h2d ) {
00800 binx = h2d->GetXaxis()->FindBin(xix);
00801 biny = h2d->GetYaxis()->FindBin(xiy);
00802 }
00803
00804 EEZeroSuppression1SRFlagMap_[iz]->setBinContent(binx, biny, fraction);
00805 EEZeroSuppression1SRFlagMap_[iz]->setBinError(binx, biny, error);
00806
00807
00808 fraction = float(nEvtRUForced[ix][iy][iz]) / float(nEvtAnyReadout[ix][iy][iz]);
00809 error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
00810
00811 h2d = EEReadoutUnitForcedBitMap_[iz]->getTH2F();
00812
00813 if( h2d ) {
00814 binx = h2d->GetXaxis()->FindBin(xix);
00815 biny = h2d->GetYaxis()->FindBin(xiy);
00816 }
00817
00818 EEReadoutUnitForcedBitMap_[iz]->setBinContent(binx, biny, fraction);
00819 EEReadoutUnitForcedBitMap_[iz]->setBinError(binx, biny, error);
00820
00821 if( nEvtZSReadout[ix][iy][iz] ) {
00822 fraction = float(nEvtCompleteReadoutIfZS[ix][iy][iz]) / float(nEvtZSReadout[ix][iy][iz]);
00823 error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
00824
00825 h2d = EECompleteZSMap_[iz]->getTH2F();
00826
00827 if( h2d ) {
00828 binx = h2d->GetXaxis()->FindBin(xix);
00829 biny = h2d->GetYaxis()->FindBin(xiy);
00830 }
00831
00832 EECompleteZSMap_[iz]->setBinContent(binx, biny, fraction);
00833 EECompleteZSMap_[iz]->setBinError(binx, biny, error);
00834 }
00835
00836 if( nEvtFullReadout[ix][iy][iz] ) {
00837 fraction = float(nEvtDroppedReadoutIfFR[ix][iy][iz]) / float(nEvtFullReadout[ix][iy][iz]);
00838 error = sqrt(fraction*(1-fraction)/float(nEvtAnyReadout[ix][iy][iz]));
00839
00840 h2d = EEDroppedFRMap_[iz]->getTH2F();
00841
00842 if( h2d ) {
00843 binx = h2d->GetXaxis()->FindBin(xix);
00844 biny = h2d->GetYaxis()->FindBin(xiy);
00845 }
00846
00847 EEDroppedFRMap_[iz]->setBinContent(binx, biny, fraction);
00848 EEDroppedFRMap_[iz]->setBinError(binx, biny, error);
00849 }
00850
00851 }
00852
00853 }
00854 }
00855 }
00856
00857 for(int iz = 0; iz < 2; iz++) {
00858 EEFullReadoutSRFlagCount_[iz]->Fill( nFRO[iz] );
00859 EECompleteZSCount_[iz]->Fill( nCompleteZS[iz] );
00860 EEDroppedFRCount_[iz]->Fill( nDroppedFRO[iz] );
00861 }
00862
00863 edm::Handle<EcalTrigPrimDigiCollection> TPCollection;
00864 if ( e.getByLabel(EcalTrigPrimDigiCollection_, TPCollection) ) {
00865
00866
00867 EcalTrigPrimDigiCollection::const_iterator TPdigi;
00868 for ( TPdigi = TPCollection->begin(); TPdigi != TPCollection->end(); ++TPdigi ) {
00869
00870 if ( Numbers::subDet( TPdigi->id() ) != EcalEndcap ) continue;
00871
00872 int ismt = Numbers::iSM( TPdigi->id() );
00873 int zside = TPdigi->id().zside();
00874 int iz = ( zside < 0 ) ? 0 : 1;
00875
00876 EETTFlags_[iz]->Fill( TPdigi->ttFlag() );
00877
00878 std::vector<DetId>* crystals = Numbers::crystals( TPdigi->id() );
00879
00880 for ( unsigned int i=0; i<crystals->size(); i++ ) {
00881
00882 EEDetId id = (*crystals)[i];
00883
00884 int ix = id.ix();
00885 int iy = id.iy();
00886 int ism = Numbers::iSM( id );
00887 int itcc = Numbers::iTCC( ism, EcalEndcap, ix, iy );
00888 int itt = Numbers::iTT( ism, EcalEndcap, ix, iy );
00889
00890 if ( ismt >= 1 && ismt <= 9 ) ix = 101 - ix;
00891
00892 nEvtAnyInterest[ix-1][iy-1][iz]++;
00893
00894 if ( (TPdigi->ttFlag() & 0x3) == 0 ) nEvtLowInterest[ix-1][iy-1][iz]++;
00895
00896 if ( (TPdigi->ttFlag() & 0x3) == 1 ) nEvtMediumInterest[ix-1][iy-1][iz]++;
00897
00898 if ( (TPdigi->ttFlag() & 0x3) == 3 ) nEvtHighInterest[ix-1][iy-1][iz]++;
00899
00900 float xix = ix-0.5;
00901 if ( iz == 0 ) xix = 100 - xix;
00902 float xiy = iy-0.5;
00903
00904 if ( ((TPdigi->ttFlag() & 0x3) == 1 || (TPdigi->ttFlag() & 0x3) == 3)
00905 && nCryTT[itcc-1][itt-1] != (int)crystals->size() ) EETTFMismatch_[iz]->Fill(xix, xiy);
00906
00907 }
00908
00909 }
00910 } else {
00911 edm::LogWarning("EESelectiveReadoutTask") << EcalTrigPrimDigiCollection_ << " not available";
00912 }
00913
00914 for(int ix = 0; ix < 100; ix++ ) {
00915 for(int iy = 0; iy < 100; iy++ ) {
00916 for(int iz = 0; iz < 2; iz++) {
00917
00918 if( nEvtAnyInterest[ix][iy][iz] ) {
00919
00920 float xix = ix;
00921 if ( iz == 0 ) xix = 99 - xix;
00922 xix += 0.5;
00923
00924 float xiy = iy+0.5;
00925
00926 float fraction = float(nEvtHighInterest[ix][iy][iz]) / float(nEvtAnyInterest[ix][iy][iz]);
00927 float error = sqrt(fraction*(1-fraction)/float(nEvtAnyInterest[ix][iy][iz]));
00928
00929 TH2F *h2d = EEHighInterestTriggerTowerFlagMap_[iz]->getTH2F();
00930
00931 int binx=0, biny=0;
00932
00933 if( h2d ) {
00934 binx = h2d->GetXaxis()->FindBin(xix);
00935 biny = h2d->GetYaxis()->FindBin(xiy);
00936 }
00937
00938 EEHighInterestTriggerTowerFlagMap_[iz]->setBinContent(binx, biny, fraction);
00939 EEHighInterestTriggerTowerFlagMap_[iz]->setBinError(binx, biny, error);
00940
00941
00942 fraction = float(nEvtMediumInterest[ix][iy][iz]) / float(nEvtAnyInterest[ix][iy][iz]);
00943 error = sqrt(fraction*(1-fraction)/float(nEvtAnyInterest[ix][iy][iz]));
00944
00945 h2d = EEMediumInterestTriggerTowerFlagMap_[iz]->getTH2F();
00946
00947 if( h2d ) {
00948 binx = h2d->GetXaxis()->FindBin(xix);
00949 biny = h2d->GetYaxis()->FindBin(xiy);
00950 }
00951
00952 EEMediumInterestTriggerTowerFlagMap_[iz]->setBinContent(binx, biny, fraction);
00953 EEMediumInterestTriggerTowerFlagMap_[iz]->setBinError(binx, biny, error);
00954
00955
00956 fraction = float(nEvtLowInterest[ix][iy][iz]) / float(nEvtAnyInterest[ix][iy][iz]);
00957 error = sqrt(fraction*(1-fraction)/float(nEvtAnyInterest[ix][iy][iz]));
00958
00959 h2d = EELowInterestTriggerTowerFlagMap_[iz]->getTH2F();
00960
00961 if( h2d ) {
00962 binx = h2d->GetXaxis()->FindBin(xix);
00963 biny = h2d->GetYaxis()->FindBin(xiy);
00964 }
00965
00966 EELowInterestTriggerTowerFlagMap_[iz]->setBinContent(binx, biny, fraction);
00967 EELowInterestTriggerTowerFlagMap_[iz]->setBinError(binx, biny, error);
00968
00969 }
00970
00971 }
00972 }
00973 }
00974
00975 }
00976
00977 void EESelectiveReadoutTask::anaDigi(const EEDataFrame& frame, const EESrFlagCollection& srFlagColl, uint16_t statusCode){
00978
00979 EEDetId id = frame.id();
00980 int ism = Numbers::iSM( id );
00981
00982 bool endcap = (id.subdetId()==EcalEndcap);
00983
00984 if(endcap) {
00985 if ( ism >= 1 && ism <= 9 ) {
00986 ++nEe_[0];
00987 } else {
00988 ++nEe_[1];
00989 }
00990
00991 int ix = id.ix();
00992 int iy = id.iy();
00993
00994 int iX0 = iXY2cIndex(ix);
00995 int iY0 = iXY2cIndex(iy);
00996 int iZ0 = id.zside()>0?1:0;
00997
00998 if(!eeRuActive_[iZ0][iX0/scEdge][iY0/scEdge]){
00999 ++nRuPerDcc_[dccNum(id)];
01000 eeRuActive_[iZ0][iX0/scEdge][iY0/scEdge] = true;
01001 }
01002
01003 EESrFlagCollection::const_iterator srf = srFlagColl.find(readOutUnitOf(id));
01004
01005 if(srf == srFlagColl.end()){
01006 return;
01007 }
01008
01009 int ttix = srf->id().ix();
01010 int ttiy = srf->id().iy();
01011
01012 int zside = srf->id().zside();
01013
01014 int ttiz = ( zside < 0 ) ? 0 : 1;
01015
01016 nCrySC[ttix-1][ttiy-1][ttiz]++;
01017
01018 int itcc = Numbers::iTCC( ism, EcalEndcap, ix, iy );
01019 int itt = Numbers::iTT( ism, EcalEndcap, ix, iy );
01020 nCryTT[itcc-1][itt-1]++;
01021
01022 bool highInterest = ((srf->value() & ~EcalSrFlag::SRF_FORCED_MASK)
01023 == EcalSrFlag::SRF_FULL);
01024
01025 int dccZsFIRval = dccZsFIR(frame, firWeights_, firstFIRSample_, 0);
01026
01027 if ( ism >= 1 && ism <= 9 ) {
01028 if(highInterest) {
01029 ++nEeHI_[0];
01030
01031 EEHighInterestZsFIR_[0]->Fill( dccZsFIRval );
01032 } else{
01033 ++nEeLI_[0];
01034
01035 EELowInterestZsFIR_[0]->Fill( dccZsFIRval );
01036 }
01037 } else {
01038 if(highInterest) {
01039 ++nEeHI_[1];
01040 EEHighInterestZsFIR_[1]->Fill( dccZsFIRval );
01041 } else{
01042 ++nEeLI_[1];
01043 EELowInterestZsFIR_[1]->Fill( dccZsFIRval );
01044 }
01045 }
01046 int isc = Numbers::iSC( ism, EcalEndcap, ix, iy );
01047 ++nPerDcc_[dccNum(id)-1];
01048 ++nPerRu_[dccNum(id)-1][isc];
01049 }
01050
01051 }
01052
01053 void EESelectiveReadoutTask::anaDigiInit(){
01054 nEe_[0] = 0;
01055 nEeLI_[0] = 0;
01056 nEeHI_[0] = 0;
01057 nEe_[1] = 0;
01058 nEeLI_[1] = 0;
01059 nEeHI_[1] = 0;
01060 bzero(nPerDcc_, sizeof(nPerDcc_));
01061 bzero(nRuPerDcc_, sizeof(nRuPerDcc_));
01062 bzero(eeRuActive_, sizeof(eeRuActive_));
01063
01064 for(int idcc=0; idcc<nECALDcc; idcc++) {
01065 for(int isc=0; isc<nDccChs; isc++) {
01066 nPerRu_[idcc][isc] = 0;
01067 }
01068 }
01069
01070 for(int iz = 0; iz<2; iz++) {
01071 for(int ix = 0; ix < 20; ix++ ) {
01072 for(int iy = 0; iy < 20; iy++ ) {
01073 nCrySC[ix][iy][iz] = 0;
01074 }
01075 }
01076 }
01077
01078 for (int itcc = 0; itcc < 108; itcc++) {
01079 for (int itt = 0; itt < 41; itt++) nCryTT[itcc][itt] = 0;
01080 }
01081
01082 }
01083
01084 const EcalScDetId
01085 EESelectiveReadoutTask::readOutUnitOf(const EEDetId& xtalId) const {
01086 if (xtalId.ix() > 40 && xtalId.ix() < 61 &&
01087 xtalId.iy() > 40 && xtalId.iy() < 61) {
01088
01089 return Numbers::getEcalScDetId(xtalId);
01090 } else {
01091 return EcalScDetId((xtalId.ix()-1)/5+1, (xtalId.iy()-1)/5+1, xtalId.zside());
01092 }
01093 }
01094
01095 unsigned EESelectiveReadoutTask::dccNum(const DetId& xtalId) const {
01096 int j;
01097 int k;
01098
01099 if ( xtalId.det()!=DetId::Ecal ) {
01100 throw cms::Exception("EESelectiveReadoutTask") << "Crystal does not belong to ECAL";
01101 }
01102
01103 int iDet = 0;
01104
01105 if(xtalId.subdetId()==EcalEndcap){
01106 EEDetId eeDetId(xtalId);
01107 j = iXY2cIndex(eeDetId.ix());
01108 k = iXY2cIndex(eeDetId.iy());
01109 int zside = eeDetId.zside();
01110 if ( zside < 0 ) iDet = 0;
01111 else iDet = 2;
01112 } else {
01113 throw cms::Exception("EESelectiveReadoutTask") << "Not ECAL endcap.";
01114 }
01115 int iDcc0 = dccIndex(iDet,j,k);
01116 assert(iDcc0>=0 && iDcc0<nECALDcc);
01117 return iDcc0+1;
01118 }
01119
01120 unsigned EESelectiveReadoutTask::dccNumOfRU(const EcalScDetId& scId) const {
01121 int j;
01122 int k;
01123
01124 if ( scId.det()!=DetId::Ecal ) {
01125 throw cms::Exception("EESelectiveReadoutTask") << "SuperCrystal does not belong to ECAL";
01126 }
01127
01128 int iDet = 0;
01129
01130 if(scId.subdetId()==EcalEndcap){
01131 j = scId.ix()-1;
01132 k = scId.iy()-1;
01133 int zside = scId.zside();
01134 if ( zside < 0 ) iDet = 0;
01135 else iDet = 2;
01136 } else {
01137 throw cms::Exception("EESelectiveReadoutTask") << "Not ECAL endcap.";
01138 }
01139 int iDcc0 = 0;
01140 int iPhi = dccPhiIndexOfRU(j,k);
01141 if(iPhi<0) iDcc0 = -1;
01142 else iDcc0 = iPhi+iDet/2*45;
01143 assert(iDcc0>=0 && iDcc0<nECALDcc);
01144 return iDcc0+1;
01145 }
01146
01147 double EESelectiveReadoutTask::getEeEventSize(double nReadXtals) const {
01148 double ruHeaderPayload = 0.;
01149 const int firstEbDcc0 = nEEDcc/2;
01150 for ( int iDcc0 = 0; iDcc0 < nECALDcc; ++iDcc0 ) {
01151
01152 if(iDcc0 == firstEbDcc0) iDcc0 += nEBDcc;
01153 ruHeaderPayload += nRuPerDcc_[iDcc0]*8.;
01154 }
01155 return getDccOverhead(EE)*nEEDcc +
01156 nReadXtals*bytesPerCrystal +
01157 ruHeaderPayload;
01158 }
01159
01160 int EESelectiveReadoutTask::dccPhiIndexOfRU(int i, int j) const {
01161 char flag=endcapDccMap[i+j*20];
01162 return (flag==' ')?-1:(flag-'0');
01163 }
01164
01165 int EESelectiveReadoutTask::dccIndex(int iDet, int i, int j) const {
01166 int iPhi = dccPhiIndex(i, j);
01167 if(iPhi<0) return -1;
01168
01169
01170 return iPhi+iDet/2*45;
01171 }
01172
01173
01174
01175 int
01176 EESelectiveReadoutTask::dccZsFIR(const EcalDataFrame& frame,
01177 const std::vector<int>& firWeights,
01178 int firstFIRSample,
01179 bool* saturated){
01180 const int nFIRTaps = 6;
01181
01182 const std::vector<int>& w = firWeights;
01183
01184
01185 int acc = 0;
01186 bool gain12saturated = false;
01187 const int gain12 = 0x01;
01188 const int lastFIRSample = firstFIRSample + nFIRTaps - 1;
01189
01190 int iWeight = 0;
01191 for(int iSample=firstFIRSample-1;
01192 iSample<lastFIRSample; ++iSample, ++iWeight){
01193 if(iSample>=0 && iSample < frame.size()){
01194 EcalMGPASample sample(frame[iSample]);
01195 if(sample.gainId()!=gain12) gain12saturated = true;
01196 LogTrace("DccFir") << (iSample>=firstFIRSample?"+":"") << sample.adc()
01197 << "*(" << w[iWeight] << ")";
01198 acc+=sample.adc()*w[iWeight];
01199 } else{
01200 edm::LogWarning("DccFir") << __FILE__ << ":" << __LINE__ <<
01201 ": Not enough samples in data frame or 'ecalDccZs1stSample' module "
01202 "parameter is not valid...";
01203 }
01204 }
01205 LogTrace("DccFir") << "\n";
01206
01207
01208
01209 acc = (acc>=0)?(acc >> 8):-(-acc >> 8);
01210
01211
01212
01213
01214 LogTrace("DccFir") << "acc: " << acc << "\n"
01215 << "saturated: " << (gain12saturated?"yes":"no") << "\n";
01216
01217 if(saturated){
01218 *saturated = gain12saturated;
01219 }
01220
01221 return gain12saturated?std::numeric_limits<int>::max():acc;
01222 }
01223
01224 std::vector<int>
01225 EESelectiveReadoutTask::getFIRWeights(const std::vector<double>&
01226 normalizedWeights){
01227 const int nFIRTaps = 6;
01228 std::vector<int> firWeights(nFIRTaps, 0);
01229 const static int maxWeight = 0xEFF;
01230 for(unsigned i=0; i < std::min((size_t)nFIRTaps,normalizedWeights.size()); ++i){
01231 firWeights[i] = lround(normalizedWeights[i] * (1<<10));
01232 if(std::abs(firWeights[i])>maxWeight){
01233 firWeights[i] = firWeights[i]<0?-maxWeight:maxWeight;
01234 }
01235 }
01236 return firWeights;
01237 }
01238
01239 void
01240 EESelectiveReadoutTask::configFirWeights(std::vector<double> weightsForZsFIR){
01241 bool notNormalized = false;
01242 bool notInt = false;
01243 for(unsigned i=0; i < weightsForZsFIR.size(); ++i){
01244 if(weightsForZsFIR[i] > 1.) notNormalized = true;
01245 if((int)weightsForZsFIR[i]!=weightsForZsFIR[i]) notInt = true;
01246 }
01247 if(notInt && notNormalized){
01248 throw cms::Exception("InvalidParameter")
01249 << "weigtsForZsFIR paramater values are not valid: they "
01250 << "must either be integer and uses the hardware representation "
01251 << "of the weights or less or equal than 1 and used the normalized "
01252 << "representation.";
01253 }
01254 edm::LogInfo log("DccFir");
01255 if(notNormalized){
01256 firWeights_ = std::vector<int>(weightsForZsFIR.size());
01257 for(unsigned i = 0; i< weightsForZsFIR.size(); ++i){
01258 firWeights_[i] = (int)weightsForZsFIR[i];
01259 }
01260 } else{
01261 firWeights_ = getFIRWeights(weightsForZsFIR);
01262 }
01263
01264 log << "Input weights for FIR: ";
01265 for(unsigned i = 0; i < weightsForZsFIR.size(); ++i){
01266 log << weightsForZsFIR[i] << "\t";
01267 }
01268
01269 double s2 = 0.;
01270 log << "\nActual FIR weights: ";
01271 for(unsigned i = 0; i < firWeights_.size(); ++i){
01272 log << firWeights_[i] << "\t";
01273 s2 += firWeights_[i]*firWeights_[i];
01274 }
01275
01276 s2 = sqrt(s2);
01277 log << "\nNormalized FIR weights after hw representation rounding: ";
01278 for(unsigned i = 0; i < firWeights_.size(); ++i){
01279 log << firWeights_[i] / (double)(1<<10) << "\t";
01280 }
01281
01282 log <<"\nFirst FIR sample: " << firstFIRSample_;
01283 }
01284
01285 int EESelectiveReadoutTask::getCrystalCount(int iDcc, int iDccCh) {
01286 if(iDcc<1 || iDcc>54) {
01287
01288 return 0;
01289 } else if (10 <= iDcc && iDcc <= 45) {
01290
01291 return 25;
01292 } else {
01293
01294 int iDccPhi;
01295 if(iDcc < 10) {
01296 iDccPhi = iDcc;
01297 } else {
01298 iDccPhi = iDcc - 45;
01299 }
01300 switch(iDccPhi*100+iDccCh){
01301 case 110:
01302 case 232:
01303 case 312:
01304 case 412:
01305 case 532:
01306 case 610:
01307 case 830:
01308 case 806:
01309
01310 return 20;
01311 case 134:
01312 case 634:
01313 case 827:
01314 case 803:
01315 return 10;
01316 case 330:
01317 case 430:
01318 return 20;
01319 case 203:
01320 case 503:
01321 case 721:
01322 case 921:
01323 return 21;
01324 default:
01325 return 25;
01326 }
01327 }
01328 }