CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OccupancyTask.cc
Go to the documentation of this file.
9 
10 namespace ecaldqm {
11  OccupancyTask::OccupancyTask() : DQWorkerTask(), recHitThreshold_(0.), tpThreshold_(0.), m_iTime(0.) {}
12 
14  recHitThreshold_ = _params.getUntrackedParameter<double>("recHitThreshold");
15  tpThreshold_ = _params.getUntrackedParameter<double>("tpThreshold");
16  lumiTag = _params.getParameter<edm::InputTag>("scalers");
17  lumiCheck_ = _params.getUntrackedParameter<bool>("lumiCheck", false);
18  if (!onlineMode_) {
19  MEs_.erase(std::string("PU"));
20  MEs_.erase(std::string("NEvents"));
21  MEs_.erase(std::string("TrendEventsperLumi"));
22  MEs_.erase(std::string("TrendPUperLumi"));
23  MEs_.erase(std::string("AELoss"));
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(lumiScalersToken_, lumiScalers);
90  if (lumiScalers.isValid() and not lumiScalers->empty()) {
91  auto scalit = lumiScalers->begin();
92  scal_pu = scalit->pileup();
93  }
94  mePU.fill(getEcalDQMSetupObjects(), double(scal_pu));
95  FindPUinLS = false;
96  }
97  }
98 
100  MESet& meDCC(MEs_.at("DCC"));
101 
102  for (EcalRawDataCollection::const_iterator dcchItr(_dcchs.begin()); dcchItr != _dcchs.end(); ++dcchItr)
103  meDCC.fill(getEcalDQMSetupObjects(), dcchItr->id());
104  }
105 
107  if (onlineMode_) {
108  MESet& meNEvents(static_cast<MESet&>(MEs_.at("NEvents")));
109  MESet& meTrendEventsperLumi(MEs_.at("TrendEventsperLumi"));
110  MESet& meTrendPUperLumi(MEs_.at("TrendPUperLumi"));
111 
112  meNEvents.fill(getEcalDQMSetupObjects(), double(nEv));
113  meTrendEventsperLumi.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), double(nEv));
114  meTrendPUperLumi.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), double(scal_pu));
115  }
116  }
117 
118  template <typename DigiCollection>
119  void OccupancyTask::runOnDigis(DigiCollection const& _digis, Collections _collection) {
120  MESet& meDigi(MEs_.at("Digi"));
121  MESet& meDigiProjEta(MEs_.at("DigiProjEta"));
122  MESet& meDigiProjPhi(MEs_.at("DigiProjPhi"));
123  MESet& meDigiAll(MEs_.at("DigiAll"));
124  MESet& meDigiAllByLumi(MEs_.at("DigiAllByLumi"));
125  MESet& meDigiDCC(MEs_.at("DigiDCC"));
126  MESet& meDigi1D(MEs_.at("Digi1D"));
127  MESet& meTrendNDigi(MEs_.at("TrendNDigi"));
128  MESet* meAELoss = nullptr;
129  if (onlineMode_)
130  meAELoss = &MEs_.at("AELoss");
131 
132  std::for_each(_digis.begin(), _digis.end(), [&](typename DigiCollection::Digi const& digi) {
133  DetId id(digi.id());
134  meDigi.fill(getEcalDQMSetupObjects(), id);
135  meDigiProjEta.fill(getEcalDQMSetupObjects(), id);
136  meDigiProjPhi.fill(getEcalDQMSetupObjects(), id);
137  meDigiAll.fill(getEcalDQMSetupObjects(), id);
138  meDigiAllByLumi.fill(getEcalDQMSetupObjects(), id);
139  meDigiDCC.fill(getEcalDQMSetupObjects(), id);
140  if (onlineMode_)
141  meAELoss->fill(getEcalDQMSetupObjects(), id);
142  });
143 
144  int iSubdet(_collection == kEBDigi ? EcalBarrel : EcalEndcap);
145  meDigi1D.fill(getEcalDQMSetupObjects(), iSubdet, double(_digis.size()));
146  meTrendNDigi.fill(getEcalDQMSetupObjects(), iSubdet, double(timestamp_.iLumi), double(_digis.size()));
147  }
148 
150  // MESet& meTPDigiAll(MEs_.at("TPDigiAll"));
151  // MESet& meTPDigiProjEta(MEs_.at("TPDigiProjEta"));
152  // MESet& meTPDigiProjPhi(MEs_.at("TPDigiProjPhi"));
153  MESet& meTPDigiRCT(MEs_.at("TPDigiRCT"));
154  MESet& meTPDigiThrAll(MEs_.at("TPDigiThrAll"));
155  MESet& meTPDigiThrAllByLumi(MEs_.at("TPDigiThrAllByLumi"));
156  MESet& meTPDigiThrProjEta(MEs_.at("TPDigiThrProjEta"));
157  MESet& meTPDigiThrProjPhi(MEs_.at("TPDigiThrProjPhi"));
158  MESet& meTrendNTPDigi(MEs_.at("TrendNTPDigi"));
159 
160  double nFilteredEB(0.);
161  double nFilteredEE(0.);
162 
163  std::for_each(_digis.begin(), _digis.end(), [&](EcalTrigPrimDigiCollection::value_type const& digi) {
164  EcalTrigTowerDetId const& id(digi.id());
165  // meTPDigiProjEta.fill(id);
166  // meTPDigiProjPhi.fill(id);
167  // meTPDigiAll.fill(id);
168  if (digi.compressedEt() > tpThreshold_) {
169  meTPDigiThrProjEta.fill(getEcalDQMSetupObjects(), id);
170  meTPDigiThrProjPhi.fill(getEcalDQMSetupObjects(), id);
171  meTPDigiThrAll.fill(getEcalDQMSetupObjects(), id);
172  meTPDigiThrAllByLumi.fill(getEcalDQMSetupObjects(), id);
173  meTPDigiRCT.fill(getEcalDQMSetupObjects(), id);
174  if (id.subDet() == EcalBarrel)
175  nFilteredEB += 1.;
176  else
177  nFilteredEE += 1.;
178  }
179  });
180 
181  meTrendNTPDigi.fill(getEcalDQMSetupObjects(), EcalBarrel, double(timestamp_.iLumi), nFilteredEB);
182  meTrendNTPDigi.fill(getEcalDQMSetupObjects(), EcalEndcap, double(timestamp_.iLumi), nFilteredEE);
183  }
184 
186  MESet& meRecHitAll(MEs_.at("RecHitAll"));
187  MESet& meRecHitProjEta(MEs_.at("RecHitProjEta"));
188  MESet& meRecHitProjPhi(MEs_.at("RecHitProjPhi"));
189  MESet& meRecHitThrAll(MEs_.at("RecHitThrAll"));
190  MESet& meRecHitThrAllByLumi(MEs_.at("RecHitThrAllByLumi"));
191  MESet& meRecHitThrmvp(MEs_.at("RecHitThrmvp"));
192  MESet& meRecHitThrpm(MEs_.at("RecHitThrpm"));
193  MESet& meRecHitThrProjEta(MEs_.at("RecHitThrProjEta"));
194  MESet& meRecHitThrProjPhi(MEs_.at("RecHitThrProjPhi"));
195  MESet& meRecHitThr1D(MEs_.at("RecHitThr1D"));
196  MESet& meTrendNRecHitThr(MEs_.at("TrendNRecHitThr"));
197 
198  uint32_t mask(~(0x1 << EcalRecHit::kGood));
199  double nFiltered(0.);
200 
201  float nRHThrp(0), nRHThrm(0);
202  int iSubdet(_collection == kEBRecHit ? EcalBarrel : EcalEndcap);
203  std::for_each(_hits.begin(), _hits.end(), [&](EcalRecHitCollection::value_type const& hit) {
204  DetId id(hit.id());
205 
206  meRecHitAll.fill(getEcalDQMSetupObjects(), id);
207  meRecHitProjEta.fill(getEcalDQMSetupObjects(), id);
208  meRecHitProjPhi.fill(getEcalDQMSetupObjects(), id);
209 
210  if (!hit.checkFlagMask(mask) && hit.energy() > recHitThreshold_) {
211  meRecHitThrProjEta.fill(getEcalDQMSetupObjects(), id);
212  meRecHitThrProjPhi.fill(getEcalDQMSetupObjects(), id);
213  meRecHitThrAll.fill(getEcalDQMSetupObjects(), id);
214  meRecHitThrAllByLumi.fill(getEcalDQMSetupObjects(), id);
215  nFiltered += 1.;
216  bool isPlusFar(iSubdet == EcalBarrel ? (EBDetId(id).iphi() > 100 && EBDetId(id).iphi() < 280) : zside(id) > 0);
217  if (isPlusFar)
218  nRHThrp++;
219  else
220  nRHThrm++;
221  }
222  });
223 
224  meRecHitThr1D.fill(getEcalDQMSetupObjects(), iSubdet, nFiltered);
225  meTrendNRecHitThr.fill(getEcalDQMSetupObjects(), iSubdet, double(timestamp_.iLumi), nFiltered);
226  meRecHitThrmvp.fill(getEcalDQMSetupObjects(), iSubdet, nRHThrp, nRHThrm);
227  meRecHitThrpm.fill(getEcalDQMSetupObjects(), iSubdet, nRHThrp - nRHThrm);
228  }
229 
231 } // namespace ecaldqm
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:162
uint16_t *__restrict__ id
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:48
MESet & at(const std::string &key)
Definition: MESet.h:399
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void runOnRecHits(EcalRecHitCollection const &, Collections)
std::vector< T >::const_iterator const_iterator
void runOnRawData(EcalRawDataCollection const &)
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::InputTag lumiTag
Definition: OccupancyTask.h:43
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::TimeValue_t m_iTime
Definition: OccupancyTask.h:42
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
bool isValid() const
Definition: HandleBase.h:70
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
EcalDQMSetupObjects const getEcalDQMSetupObjects()
Definition: DQWorker.cc:142
Definition: DetId.h:17
edm::EDGetTokenT< LumiScalersCollection > lumiScalersToken_
Definition: OccupancyTask.h:44
Timestamp timestamp_
Definition: DQWorker.h:128
bool filterRunType(short const *) override
edm::ESGetToken< EcalLaserDbService, EcalLaserDbRecord > lasertoken_
Definition: OccupancyTask.h:38
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MESetCollection MEs_
Definition: DQWorker.h:125
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
std::vector< LumiScalers > LumiScalersCollection
Definition: LumiScalers.h:144
EcalElectronicsMapping const * GetElectronicsMap()
Definition: DQWorker.cc:118
virtual void reset(EcalElectronicsMapping const *, double=0., double=0., double=0.)
Definition: MESet.cc:98
TimeValue_t value() const
Definition: Timestamp.h:45
void erase(const std::string &key)
Definition: MESet.h:390
edm::Timestamp time() const
Definition: EventBase.h:60
static bool validDenseIndex(uint32_t din)
Definition: EBDetId.h:105
const_iterator begin() const
Definition: Run.h:45