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  MEs_.erase(std::string("AEReco"));
24  }
25  }
26 
28  lasertoken_ = _collector.esConsumes();
30  }
31 
32  bool OccupancyTask::filterRunType(short const* _runType) {
33  for (int iFED(0); iFED < 54; iFED++) {
34  if (_runType[iFED] == EcalDCCHeaderBlock::COSMIC || _runType[iFED] == EcalDCCHeaderBlock::MTCC ||
35  _runType[iFED] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
36  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_GLOBAL || _runType[iFED] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
37  _runType[iFED] == EcalDCCHeaderBlock::PHYSICS_LOCAL)
38  return true;
39  }
40 
41  return false;
42  }
43 
44  void OccupancyTask::beginRun(edm::Run const&, edm::EventSetup const& _es) { FillLaser = true; }
46  edm::EventSetup const& _es,
47  bool const& ByLumiResetSwitch,
48  bool&) {
49  if (ByLumiResetSwitch) {
50  MEs_.at("DigiAllByLumi").reset(GetElectronicsMap());
51  MEs_.at("TPDigiThrAllByLumi").reset(GetElectronicsMap());
52  MEs_.at("RecHitThrAllByLumi").reset(GetElectronicsMap());
53  nEv = 0;
54  if (onlineMode_) {
55  MEs_.at("PU").reset(GetElectronicsMap(), -1);
56  MEs_.at("NEvents").reset(GetElectronicsMap(), -1);
57  FindPUinLS = true;
58  }
59  }
60  nEv++;
61  MESet& meLaserCorrProjEta(MEs_.at("LaserCorrProjEta"));
62  m_iTime = _evt.time().value();
63  if (FillLaser) {
64  float lasercalib = 1.;
65  auto const& laser = &_es.getData(lasertoken_);
66  const edm::Timestamp& evtTimeStamp = edm::Timestamp(m_iTime);
67 
68  for (int i = 0; i < EBDetId::kSizeForDenseIndexing; i++) {
70  continue;
72  lasercalib = laser->getLaserCorrection(ebid, evtTimeStamp);
73  meLaserCorrProjEta.fill(getEcalDQMSetupObjects(), ebid, lasercalib);
74  }
75 
76  for (int i = 0; i < EEDetId::kSizeForDenseIndexing; i++) {
78  continue;
80  lasercalib = laser->getLaserCorrection(eeid, evtTimeStamp);
81  meLaserCorrProjEta.fill(getEcalDQMSetupObjects(), eeid, lasercalib);
82  }
83  FillLaser = false;
84  }
85  if (lumiCheck_ && FindPUinLS) {
86  scal_pu = -1.;
87  MESet& mePU(static_cast<MESet&>(MEs_.at("PU")));
89  _evt.getByToken(metaDataToken_, metaData);
90 
91  if (metaData.isValid())
92  scal_pu = metaData->avgPileUp();
93  mePU.fill(getEcalDQMSetupObjects(), double(scal_pu));
94  FindPUinLS = false;
95  }
96  }
97 
99  MESet& meDCC(MEs_.at("DCC"));
100 
101  for (EcalRawDataCollection::const_iterator dcchItr(_dcchs.begin()); dcchItr != _dcchs.end(); ++dcchItr)
102  meDCC.fill(getEcalDQMSetupObjects(), dcchItr->id());
103  }
104 
106  if (onlineMode_) {
107  MESet& meNEvents(static_cast<MESet&>(MEs_.at("NEvents")));
108  MESet& meTrendEventsperLumi(MEs_.at("TrendEventsperLumi"));
109  MESet& meTrendPUperLumi(MEs_.at("TrendPUperLumi"));
110 
111  meNEvents.fill(getEcalDQMSetupObjects(), double(nEv));
112  meTrendEventsperLumi.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), double(nEv));
113  meTrendPUperLumi.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), double(scal_pu));
114  }
115  }
116 
117  template <typename DigiCollection>
118  void OccupancyTask::runOnDigis(DigiCollection const& _digis, Collections _collection) {
119  MESet& meDigi(MEs_.at("Digi"));
120  MESet& meDigiProjEta(MEs_.at("DigiProjEta"));
121  MESet& meDigiProjPhi(MEs_.at("DigiProjPhi"));
122  MESet& meDigiAll(MEs_.at("DigiAll"));
123  MESet& meDigiAllByLumi(MEs_.at("DigiAllByLumi"));
124  MESet& meDigiDCC(MEs_.at("DigiDCC"));
125  MESet& meDigi1D(MEs_.at("Digi1D"));
126  MESet& meTrendNDigi(MEs_.at("TrendNDigi"));
127  MESet* meAELoss = nullptr;
128  MESet* meAEReco = nullptr;
129  if (onlineMode_) {
130  meAELoss = &MEs_.at("AELoss");
131  meAEReco = &MEs_.at("AEReco");
132  }
133  std::for_each(_digis.begin(), _digis.end(), [&](typename DigiCollection::Digi const& digi) {
134  DetId id(digi.id());
135  meDigi.fill(getEcalDQMSetupObjects(), id);
136  meDigiProjEta.fill(getEcalDQMSetupObjects(), id);
137  meDigiProjPhi.fill(getEcalDQMSetupObjects(), id);
138  meDigiAll.fill(getEcalDQMSetupObjects(), id);
139  meDigiAllByLumi.fill(getEcalDQMSetupObjects(), id);
140  meDigiDCC.fill(getEcalDQMSetupObjects(), id);
141  if (onlineMode_) {
142  meAELoss->fill(getEcalDQMSetupObjects(), id);
143  meAEReco->fill(getEcalDQMSetupObjects(), id);
144  }
145  });
146 
147  int iSubdet(_collection == kEBDigi ? EcalBarrel : EcalEndcap);
148  meDigi1D.fill(getEcalDQMSetupObjects(), iSubdet, double(_digis.size()));
149  meTrendNDigi.fill(getEcalDQMSetupObjects(), iSubdet, double(timestamp_.iLumi), double(_digis.size()));
150  }
151 
153  // MESet& meTPDigiAll(MEs_.at("TPDigiAll"));
154  // MESet& meTPDigiProjEta(MEs_.at("TPDigiProjEta"));
155  // MESet& meTPDigiProjPhi(MEs_.at("TPDigiProjPhi"));
156  MESet& meTPDigiRCT(MEs_.at("TPDigiRCT"));
157  MESet& meTPDigiThrAll(MEs_.at("TPDigiThrAll"));
158  MESet& meTPDigiThrAllByLumi(MEs_.at("TPDigiThrAllByLumi"));
159  MESet& meTPDigiThrProjEta(MEs_.at("TPDigiThrProjEta"));
160  MESet& meTPDigiThrProjPhi(MEs_.at("TPDigiThrProjPhi"));
161  MESet& meTrendNTPDigi(MEs_.at("TrendNTPDigi"));
162 
163  double nFilteredEB(0.);
164  double nFilteredEE(0.);
165 
166  std::for_each(_digis.begin(), _digis.end(), [&](EcalTrigPrimDigiCollection::value_type const& digi) {
167  EcalTrigTowerDetId const& id(digi.id());
168  // meTPDigiProjEta.fill(id);
169  // meTPDigiProjPhi.fill(id);
170  // meTPDigiAll.fill(id);
171  if (digi.compressedEt() > tpThreshold_) {
172  meTPDigiThrProjEta.fill(getEcalDQMSetupObjects(), id);
173  meTPDigiThrProjPhi.fill(getEcalDQMSetupObjects(), id);
174  meTPDigiThrAll.fill(getEcalDQMSetupObjects(), id);
175  meTPDigiThrAllByLumi.fill(getEcalDQMSetupObjects(), id);
176  meTPDigiRCT.fill(getEcalDQMSetupObjects(), id);
177  if (id.subDet() == EcalBarrel)
178  nFilteredEB += 1.;
179  else
180  nFilteredEE += 1.;
181  }
182  });
183 
184  meTrendNTPDigi.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), nFilteredEB);
185  meTrendNTPDigi.fill(getEcalDQMSetupObjects(), EcalEndcap, double(timestamp_.iLumi), nFilteredEE);
186  }
187 
189  MESet& meRecHitAll(MEs_.at("RecHitAll"));
190  MESet& meRecHitProjEta(MEs_.at("RecHitProjEta"));
191  MESet& meRecHitProjPhi(MEs_.at("RecHitProjPhi"));
192  MESet& meRecHitThrAll(MEs_.at("RecHitThrAll"));
193  MESet& meRecHitThrAllByLumi(MEs_.at("RecHitThrAllByLumi"));
194  MESet& meRecHitThrmvp(MEs_.at("RecHitThrmvp"));
195  MESet& meRecHitThrpm(MEs_.at("RecHitThrpm"));
196  MESet& meRecHitThrProjEta(MEs_.at("RecHitThrProjEta"));
197  MESet& meRecHitThrProjPhi(MEs_.at("RecHitThrProjPhi"));
198  MESet& meRecHitThr1D(MEs_.at("RecHitThr1D"));
199  MESet& meTrendNRecHitThr(MEs_.at("TrendNRecHitThr"));
200 
201  uint32_t goodBits(0x1 << EcalRecHit::kGood);
202  double nFiltered(0.);
203 
204  float nRHThrp(0), nRHThrm(0);
205  int iSubdet(_collection == kEBRecHit ? EcalBarrel : EcalEndcap);
206  std::for_each(_hits.begin(), _hits.end(), [&](EcalRecHitCollection::value_type const& hit) {
207  DetId id(hit.id());
208 
209  meRecHitAll.fill(getEcalDQMSetupObjects(), id);
210  meRecHitProjEta.fill(getEcalDQMSetupObjects(), id);
211  meRecHitProjPhi.fill(getEcalDQMSetupObjects(), id);
212 
213  if (hit.checkFlagMask(goodBits) && hit.energy() > recHitThreshold_) {
214  meRecHitThrProjEta.fill(getEcalDQMSetupObjects(), id);
215  meRecHitThrProjPhi.fill(getEcalDQMSetupObjects(), id);
216  meRecHitThrAll.fill(getEcalDQMSetupObjects(), id);
217  meRecHitThrAllByLumi.fill(getEcalDQMSetupObjects(), id);
218  nFiltered += 1.;
219  bool isPlusFar(iSubdet == EcalBarrel ? (EBDetId(id).iphi() > 100 && EBDetId(id).iphi() < 280) : zside(id) > 0);
220  if (isPlusFar)
221  nRHThrp++;
222  else
223  nRHThrm++;
224  }
225  });
226 
227  meRecHitThr1D.fill(getEcalDQMSetupObjects(), iSubdet, nFiltered);
228  meTrendNRecHitThr.fill(getEcalDQMSetupObjects(), iSubdet, double(timestamp_.iLumi), nFiltered);
229  meRecHitThrmvp.fill(getEcalDQMSetupObjects(), iSubdet, nRHThrp, nRHThrm);
230  meRecHitThrpm.fill(getEcalDQMSetupObjects(), iSubdet, nRHThrp - nRHThrm);
231  }
232 
234 } // namespace ecaldqm
static constexpr int kSizeForDenseIndexing
Definition: EEDetId.h:328
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:526
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
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
static constexpr int kSizeForDenseIndexing
Definition: EBDetId.h:155
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