CMS 3D CMS Logo

OccupancyTask.cc
Go to the documentation of this file.
8 
9 namespace ecaldqm {
10  OccupancyTask::OccupancyTask() : DQWorkerTask(), recHitThreshold_(0.), tpThreshold_(0.), m_iTime(0.) {}
11 
13  recHitThreshold_ = _params.getUntrackedParameter<double>("recHitThreshold");
14  tpThreshold_ = _params.getUntrackedParameter<double>("tpThreshold");
15  metadataTag = _params.getParameter<edm::InputTag>("metadata");
16  lumiCheck_ = _params.getUntrackedParameter<bool>("lumiCheck", false);
17  if (!onlineMode_) {
18  MEs_.erase(std::string("PU"));
19  MEs_.erase(std::string("NEvents"));
20  MEs_.erase(std::string("TrendEventsperLumi"));
21  MEs_.erase(std::string("TrendPUperLumi"));
22  MEs_.erase(std::string("AELoss"));
23  }
24  }
25 
27  lasertoken_ = _collector.esConsumes();
29  }
30 
31  bool OccupancyTask::filterRunType(short const* _runType) {
32  for (int iFED(0); iFED < 54; iFED++) {
33  if (_runType[iFED] == EcalDCCHeaderBlock::COSMIC || _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
34  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
35  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_GLOBAL || _runType[iFED] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
36  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_LOCAL)
37  return true;
38  }
39 
40  return false;
41  }
42 
43  void OccupancyTask::beginRun(edm::Run const&, edm::EventSetup const& _es) { FillLaser = true; }
45  edm::EventSetup const& _es,
46  bool const& ByLumiResetSwitch,
47  bool&) {
48  if (ByLumiResetSwitch) {
49  MEs_.at("DigiAllByLumi").reset(GetElectronicsMap());
50  MEs_.at("TPDigiThrAllByLumi").reset(GetElectronicsMap());
51  MEs_.at("RecHitThrAllByLumi").reset(GetElectronicsMap());
52  nEv = 0;
53  if (onlineMode_) {
54  MEs_.at("PU").reset(GetElectronicsMap(), -1);
55  MEs_.at("NEvents").reset(GetElectronicsMap(), -1);
56  FindPUinLS = true;
57  }
58  }
59  nEv++;
60  MESet& meLaserCorrProjEta(MEs_.at("LaserCorrProjEta"));
61  m_iTime = _evt.time().value();
62  if (FillLaser) {
63  float lasercalib = 1.;
64  auto const& laser = &_es.getData(lasertoken_);
65  const edm::Timestamp& evtTimeStamp = edm::Timestamp(m_iTime);
66 
67  for (int i = 0; i < EBDetId::kSizeForDenseIndexing; i++) {
69  continue;
71  lasercalib = laser->getLaserCorrection(ebid, evtTimeStamp);
72  meLaserCorrProjEta.fill(getEcalDQMSetupObjects(), ebid, lasercalib);
73  }
74 
75  for (int i = 0; i < EEDetId::kSizeForDenseIndexing; i++) {
77  continue;
79  lasercalib = laser->getLaserCorrection(eeid, evtTimeStamp);
80  meLaserCorrProjEta.fill(getEcalDQMSetupObjects(), eeid, lasercalib);
81  }
82  FillLaser = false;
83  }
84  if (lumiCheck_ && FindPUinLS) {
85  scal_pu = -1.;
86  MESet& mePU(static_cast<MESet&>(MEs_.at("PU")));
88  _evt.getByToken(metaDataToken_, metaData);
89 
90  if (metaData.isValid())
91  scal_pu = metaData->avgPileUp();
92  mePU.fill(getEcalDQMSetupObjects(), double(scal_pu));
93  FindPUinLS = false;
94  }
95  }
96 
98  MESet& meDCC(MEs_.at("DCC"));
99 
100  for (EcalRawDataCollection::const_iterator dcchItr(_dcchs.begin()); dcchItr != _dcchs.end(); ++dcchItr)
101  meDCC.fill(getEcalDQMSetupObjects(), dcchItr->id());
102  }
103 
105  if (onlineMode_) {
106  MESet& meNEvents(static_cast<MESet&>(MEs_.at("NEvents")));
107  MESet& meTrendEventsperLumi(MEs_.at("TrendEventsperLumi"));
108  MESet& meTrendPUperLumi(MEs_.at("TrendPUperLumi"));
109 
110  meNEvents.fill(getEcalDQMSetupObjects(), double(nEv));
111  meTrendEventsperLumi.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), double(nEv));
112  meTrendPUperLumi.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), double(scal_pu));
113  }
114  }
115 
116  template <typename DigiCollection>
117  void OccupancyTask::runOnDigis(DigiCollection const& _digis, Collections _collection) {
118  MESet& meDigi(MEs_.at("Digi"));
119  MESet& meDigiProjEta(MEs_.at("DigiProjEta"));
120  MESet& meDigiProjPhi(MEs_.at("DigiProjPhi"));
121  MESet& meDigiAll(MEs_.at("DigiAll"));
122  MESet& meDigiAllByLumi(MEs_.at("DigiAllByLumi"));
123  MESet& meDigiDCC(MEs_.at("DigiDCC"));
124  MESet& meDigi1D(MEs_.at("Digi1D"));
125  MESet& meTrendNDigi(MEs_.at("TrendNDigi"));
126  MESet* meAELoss = nullptr;
127  if (onlineMode_)
128  meAELoss = &MEs_.at("AELoss");
129 
130  std::for_each(_digis.begin(), _digis.end(), [&](typename DigiCollection::Digi const& digi) {
131  DetId id(digi.id());
132  meDigi.fill(getEcalDQMSetupObjects(), id);
133  meDigiProjEta.fill(getEcalDQMSetupObjects(), id);
134  meDigiProjPhi.fill(getEcalDQMSetupObjects(), id);
135  meDigiAll.fill(getEcalDQMSetupObjects(), id);
136  meDigiAllByLumi.fill(getEcalDQMSetupObjects(), id);
137  meDigiDCC.fill(getEcalDQMSetupObjects(), id);
138  if (onlineMode_)
139  meAELoss->fill(getEcalDQMSetupObjects(), id);
140  });
141 
142  int iSubdet(_collection == kEBDigi ? EcalBarrel : EcalEndcap);
143  meDigi1D.fill(getEcalDQMSetupObjects(), iSubdet, double(_digis.size()));
144  meTrendNDigi.fill(getEcalDQMSetupObjects(), iSubdet, double(timestamp_.iLumi), double(_digis.size()));
145  }
146 
148  // MESet& meTPDigiAll(MEs_.at("TPDigiAll"));
149  // MESet& meTPDigiProjEta(MEs_.at("TPDigiProjEta"));
150  // MESet& meTPDigiProjPhi(MEs_.at("TPDigiProjPhi"));
151  MESet& meTPDigiRCT(MEs_.at("TPDigiRCT"));
152  MESet& meTPDigiThrAll(MEs_.at("TPDigiThrAll"));
153  MESet& meTPDigiThrAllByLumi(MEs_.at("TPDigiThrAllByLumi"));
154  MESet& meTPDigiThrProjEta(MEs_.at("TPDigiThrProjEta"));
155  MESet& meTPDigiThrProjPhi(MEs_.at("TPDigiThrProjPhi"));
156  MESet& meTrendNTPDigi(MEs_.at("TrendNTPDigi"));
157 
158  double nFilteredEB(0.);
159  double nFilteredEE(0.);
160 
161  std::for_each(_digis.begin(), _digis.end(), [&](EcalTrigPrimDigiCollection::value_type const& digi) {
162  EcalTrigTowerDetId const& id(digi.id());
163  // meTPDigiProjEta.fill(id);
164  // meTPDigiProjPhi.fill(id);
165  // meTPDigiAll.fill(id);
166  if (digi.compressedEt() > tpThreshold_) {
167  meTPDigiThrProjEta.fill(getEcalDQMSetupObjects(), id);
168  meTPDigiThrProjPhi.fill(getEcalDQMSetupObjects(), id);
169  meTPDigiThrAll.fill(getEcalDQMSetupObjects(), id);
170  meTPDigiThrAllByLumi.fill(getEcalDQMSetupObjects(), id);
171  meTPDigiRCT.fill(getEcalDQMSetupObjects(), id);
172  if (id.subDet() == EcalBarrel)
173  nFilteredEB += 1.;
174  else
175  nFilteredEE += 1.;
176  }
177  });
178 
179  meTrendNTPDigi.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), nFilteredEB);
180  meTrendNTPDigi.fill(getEcalDQMSetupObjects(), EcalEndcap, double(timestamp_.iLumi), nFilteredEE);
181  }
182 
184  MESet& meRecHitAll(MEs_.at("RecHitAll"));
185  MESet& meRecHitProjEta(MEs_.at("RecHitProjEta"));
186  MESet& meRecHitProjPhi(MEs_.at("RecHitProjPhi"));
187  MESet& meRecHitThrAll(MEs_.at("RecHitThrAll"));
188  MESet& meRecHitThrAllByLumi(MEs_.at("RecHitThrAllByLumi"));
189  MESet& meRecHitThrmvp(MEs_.at("RecHitThrmvp"));
190  MESet& meRecHitThrpm(MEs_.at("RecHitThrpm"));
191  MESet& meRecHitThrProjEta(MEs_.at("RecHitThrProjEta"));
192  MESet& meRecHitThrProjPhi(MEs_.at("RecHitThrProjPhi"));
193  MESet& meRecHitThr1D(MEs_.at("RecHitThr1D"));
194  MESet& meTrendNRecHitThr(MEs_.at("TrendNRecHitThr"));
195 
196  uint32_t mask(~(0x1 << EcalRecHit::kGood));
197  double nFiltered(0.);
198 
199  float nRHThrp(0), nRHThrm(0);
200  int iSubdet(_collection == kEBRecHit ? EcalBarrel : EcalEndcap);
201  std::for_each(_hits.begin(), _hits.end(), [&](EcalRecHitCollection::value_type const& hit) {
202  DetId id(hit.id());
203 
204  meRecHitAll.fill(getEcalDQMSetupObjects(), id);
205  meRecHitProjEta.fill(getEcalDQMSetupObjects(), id);
206  meRecHitProjPhi.fill(getEcalDQMSetupObjects(), id);
207 
208  if (!hit.checkFlagMask(mask) && hit.energy() > recHitThreshold_) {
209  meRecHitThrProjEta.fill(getEcalDQMSetupObjects(), id);
210  meRecHitThrProjPhi.fill(getEcalDQMSetupObjects(), id);
211  meRecHitThrAll.fill(getEcalDQMSetupObjects(), id);
212  meRecHitThrAllByLumi.fill(getEcalDQMSetupObjects(), id);
213  nFiltered += 1.;
214  bool isPlusFar(iSubdet == EcalBarrel ? (EBDetId(id).iphi() > 100 && EBDetId(id).iphi() < 280) : zside(id) > 0);
215  if (isPlusFar)
216  nRHThrp++;
217  else
218  nRHThrm++;
219  }
220  });
221 
222  meRecHitThr1D.fill(getEcalDQMSetupObjects(), iSubdet, nFiltered);
223  meTrendNRecHitThr.fill(getEcalDQMSetupObjects(), iSubdet, double(timestamp_.iLumi), nFiltered);
224  meRecHitThrmvp.fill(getEcalDQMSetupObjects(), iSubdet, nRHThrp, nRHThrm);
225  meRecHitThrpm.fill(getEcalDQMSetupObjects(), iSubdet, nRHThrp - nRHThrm);
226  }
227 
229 } // namespace ecaldqm
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:168
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:48
MESet & at(const std::string &key)
Definition: MESet.h:399
void runOnRecHits(EcalRecHitCollection const &, Collections)
Class to contain the online luminosity from soft FED 1022.
std::vector< T >::const_iterator const_iterator
edm::InputTag metadataTag
Definition: OccupancyTask.h:43
void runOnRawData(EcalRawDataCollection const &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
void runOnDigis(DigiCollection const &, Collections)
int zside(DetId const &)
void beginRun(edm::Run const &, edm::EventSetup const &) override
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
constexpr uint32_t mask
Definition: gpuClustering.h:26
edm::TimeValue_t m_iTime
Definition: OccupancyTask.h:42
edm::Timestamp time() const
Definition: EventBase.h:64
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
void runOnTPDigis(EcalTrigPrimDigiCollection const &)
virtual void fill(EcalDQMSetupObjects const, DetId const &, double=1., double=1., double=1.)
Definition: MESet.h:74
const_iterator begin() const
void setTokens(edm::ConsumesCollector &) override
void setParams(edm::ParameterSet const &) override
unsigned int id
const_iterator end() const
void beginEvent(edm::Event const &, edm::EventSetup const &, bool const &, bool &) override
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:150
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:170
Definition: DetId.h:17
Timestamp timestamp_
Definition: DQWorker.h:134
bool filterRunType(short const *) override
edm::ESGetToken< EcalLaserDbService, EcalLaserDbRecord > lasertoken_
Definition: OccupancyTask.h:38
TimeValue_t value() const
Definition: Timestamp.h:38
MESetCollection MEs_
Definition: DQWorker.h:131
bool isValid() const
Definition: HandleBase.h:70
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
static bool validDenseIndex(uint32_t din)
Definition: EEDetId.h:213
edm::EDGetTokenT< OnlineLuminosityRecord > metaDataToken_
Definition: OccupancyTask.h:44
virtual void reset(EcalElectronicsMapping const *, double=0., double=0., double=0.)
Definition: MESet.cc:98
void erase(const std::string &key)
Definition: MESet.h:390
float avgPileUp() const
Return the average pileup for th current nibble.
static bool validDenseIndex(uint32_t din)
Definition: EBDetId.h:105
Definition: Run.h:45