CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Attributes
ESTrendTask Class Reference

#include <ESTrendTask.h>

Inheritance diagram for ESTrendTask:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Public Member Functions

 ESTrendTask (const edm::ParameterSet &ps)
 
 ~ESTrendTask () override
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
void dqmBeginRun (const edm::Run &r, const edm::EventSetup &c) override
 
void shift2Left (TProfile *p, int bins=1)
 
void shift2Right (TProfile *p, int bins=1)
 
void updateTime (const edm::Event &)
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 

Private Attributes

long int current_time_
 
edm::EDGetTokenT< ESRawDataCollectiondccCollections_
 
MonitorElementhESFiberErrTrend_
 
MonitorElementhESFiberErrTrendHr_
 
MonitorElementhESRecHitTrend_ [2][2]
 
MonitorElementhESRecHitTrendHr_ [2][2]
 
MonitorElementhESSLinkErrTrend_
 
MonitorElementhESSLinkErrTrendHr_
 
int ievt_
 
long int last_time_
 
std::string prefixME_
 
edm::EDGetTokenT< ESRecHitCollectionrechittoken_
 
long int start_time_
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr< DQMEDAnalyzerGlobalCacheinitializeGlobalCache (edm::ParameterSet const &)
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 16 of file ESTrendTask.h.

Constructor & Destructor Documentation

◆ ESTrendTask()

ESTrendTask::ESTrendTask ( const edm::ParameterSet ps)

Definition at line 22 of file ESTrendTask.cc.

22  {
23  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "EcalPreshower");
24  rechittoken_ = consumes<ESRecHitCollection>(ps.getParameter<InputTag>("RecHitLabel"));
25  dccCollections_ = consumes<ESRawDataCollection>(ps.getParameter<InputTag>("ESDCCCollections"));
26 
27  for (int i = 0; i < 2; ++i)
28  for (int j = 0; j < 2; ++j) {
29  hESRecHitTrend_[i][j] = nullptr;
30  hESRecHitTrendHr_[i][j] = nullptr;
31  }
32 
33  hESSLinkErrTrend_ = nullptr;
34  hESFiberErrTrend_ = nullptr;
35  hESSLinkErrTrendHr_ = nullptr;
36  hESFiberErrTrendHr_ = nullptr;
37 
38  start_time_ = 0;
39  current_time_ = 0;
40  last_time_ = 0;
41 
42  ievt_ = 0;
43 }

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, and dqmiolumiharvest::j.

◆ ~ESTrendTask()

ESTrendTask::~ESTrendTask ( )
inlineoverride

Definition at line 22 of file ESTrendTask.h.

22 {}

Member Function Documentation

◆ analyze()

void ESTrendTask::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotectedvirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 91 of file ESTrendTask.cc.

91  {
92  ievt_++;
93 
94  // Collect time information
95  updateTime(e);
96 
97  long int diff_current_start = current_time_ - start_time_;
98  long int diff_last_start = last_time_ - start_time_;
99  //LogInfo("ESTrendTask") << "time difference is negative in " << ievt_ << " events\n"
100  //<< "\tcurrent - start time = " << diff_current_start
101  //<< ", \tlast - start time = " << diff_last_start << endl;
102 
103  // std::cout << "current_time : " << current_time_ << ", diff : " << diff_current_start << std::endl;
104 
105  // Calculate time interval and bin width
106  // int minuteBinWidth = int(nBasicClusterMinutely_->getTProfile()->GetXaxis()->GetBinWidth(1));
107  int minuteBinWidth = 5;
108  long int minuteBinDiff = diff_current_start / 60 / minuteBinWidth - diff_last_start / 60 / minuteBinWidth;
109  long int minuteDiff = (current_time_ - last_time_) / 60;
110 
111  // int hourBinWidth = int(nBasicClusterHourly_->getTProfile()->GetXaxis()->GetBinWidth(1));
112  int hourBinWidth = 1;
113  long int hourBinDiff = diff_current_start / 3600 / hourBinWidth - diff_last_start / 3600 / hourBinWidth;
114  long int hourDiff = (current_time_ - last_time_) / 3600;
115 
116  if (minuteDiff >= minuteBinWidth) {
117  while (minuteDiff >= minuteBinWidth)
118  minuteDiff -= minuteBinWidth;
119  }
120  if (hourDiff >= hourBinWidth) {
121  while (hourDiff >= hourBinWidth)
122  hourDiff -= hourBinWidth;
123  }
124 
125  // ES DCC
126  Int_t slinkCRCErr = 0;
127  Int_t fiberErr = 0;
128  vector<int> fiberStatus;
130  if (e.getByToken(dccCollections_, dccs)) {
131  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
132  ESDCCHeaderBlock dcc = (*dccItr);
133 
134  if (dcc.getDCCErrors() == 101)
135  slinkCRCErr++;
136 
137  fiberStatus = dcc.getFEChannelStatus();
138  for (unsigned int i = 0; i < fiberStatus.size(); ++i) {
139  if (fiberStatus[i] == 4 || fiberStatus[i] == 8 || fiberStatus[i] == 10 || fiberStatus[i] == 11 ||
140  fiberStatus[i] == 12)
141  fiberErr++;
142  }
143  }
144  }
145 
146  shift2Right(hESSLinkErrTrend_->getTProfile(), minuteBinDiff);
147  hESSLinkErrTrend_->Fill(minuteDiff, slinkCRCErr);
148 
149  shift2Right(hESFiberErrTrend_->getTProfile(), minuteBinDiff);
150  hESFiberErrTrend_->Fill(minuteDiff, fiberErr);
151 
153  hESSLinkErrTrendHr_->Fill(hourDiff, slinkCRCErr);
154 
156  hESFiberErrTrendHr_->Fill(hourDiff, fiberErr);
157 
158  // ES RecHits
159  int zside, plane;
160  int nrh[2][2];
161  for (int i = 0; i < 2; i++)
162  for (int j = 0; j < 2; j++) {
163  nrh[i][j] = 0;
164  }
165 
167  if (e.getByToken(rechittoken_, ESRecHit)) {
168  for (ESRecHitCollection::const_iterator hitItr = ESRecHit->begin(); hitItr != ESRecHit->end(); ++hitItr) {
169  ESDetId id = ESDetId(hitItr->id());
170 
171  zside = id.zside();
172  plane = id.plane();
173 
174  int i = (zside == 1) ? 0 : 1;
175  int j = plane - 1;
176 
177  nrh[i][j]++;
178  }
179  } else {
180  LogWarning("ESTrendTask") << "RecHitCollection not available";
181  }
182 
183  for (int i = 0; i < 2; ++i)
184  for (int j = 0; j < 2; ++j) {
185  shift2Right(hESRecHitTrend_[i][j]->getTProfile(), minuteBinDiff);
186  hESRecHitTrend_[i][j]->Fill(minuteDiff, nrh[i][j] / (1072 * 32.));
187 
188  shift2Right(hESRecHitTrendHr_[i][j]->getTProfile(), hourBinDiff);
189  hESRecHitTrendHr_[i][j]->Fill(hourDiff, nrh[i][j] / (1072 * 32.));
190  }
191 }

References edm::SortedCollection< T, SORT >::begin(), MillePedeFileConverter_cfg::e, edm::SortedCollection< T, SORT >::end(), ESDCCHeaderBlock::getDCCErrors(), ESDCCHeaderBlock::getFEChannelStatus(), mps_fire::i, dqmiolumiharvest::j, and ecaldqm::zside().

◆ bookHistograms()

void ESTrendTask::bookHistograms ( DQMStore::IBooker iBooker,
edm::Run const &  ,
edm::EventSetup const &   
)
overrideprotectedvirtual

Implements DQMEDAnalyzer.

Definition at line 51 of file ESTrendTask.cc.

51  {
52  char histo[200];
53 
54  iBooker.setCurrentFolder(prefixME_ + "/ESTrendTask");
55 
56  for (int i = 0; i < 2; ++i)
57  for (int j = 0; j < 2; ++j) {
58  int iz = (i == 0) ? 1 : -1;
59  sprintf(histo, "ES Trending RH Occ per 5 mins Z %d P %d", iz, j + 1);
60  hESRecHitTrend_[i][j] = iBooker.bookProfile(histo, histo, 36, 0.0, 180.0, 100, 0.0, 1.0e6, "s");
61  hESRecHitTrend_[i][j]->setAxisTitle("Elapse time (Minutes)", 1);
62  hESRecHitTrend_[i][j]->setAxisTitle("ES RecHit Occupancy / 5 minutes", 2);
63 
64  sprintf(histo, "ES Trending RH Occ per hour Z %d P %d", iz, j + 1);
65  hESRecHitTrendHr_[i][j] = iBooker.bookProfile(histo, histo, 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
66  hESRecHitTrendHr_[i][j]->setAxisTitle("Elapse time (Hours)", 1);
67  hESRecHitTrendHr_[i][j]->setAxisTitle("ES RecHit Occupancy / hour", 2);
68  }
69 
70  sprintf(histo, "ES Trending SLink CRC Error per 5 mins");
71  hESSLinkErrTrend_ = iBooker.bookProfile(histo, histo, 36, 0.0, 180.0, 100, 0.0, 1.0e6, "s");
72  hESSLinkErrTrend_->setAxisTitle("Elapse time (Minutes)", 1);
73  hESSLinkErrTrend_->setAxisTitle("ES SLink CRC Err / 5 minutes", 2);
74 
75  sprintf(histo, "ES Trending Fiber Error per 5 mins");
76  hESFiberErrTrend_ = iBooker.bookProfile(histo, histo, 36, 0.0, 180.0, 100, 0.0, 1.0e6, "s");
77  hESFiberErrTrend_->setAxisTitle("Elapse time (Minutes)", 1);
78  hESFiberErrTrend_->setAxisTitle("ES Fiber Err / 5 minutes", 2);
79 
80  sprintf(histo, "ES Trending SLink CRC Error per hour");
81  hESSLinkErrTrendHr_ = iBooker.bookProfile(histo, histo, 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
82  hESSLinkErrTrendHr_->setAxisTitle("Elapse time (Hours)", 1);
83  hESSLinkErrTrendHr_->setAxisTitle("ES SLink CRC Err / hour", 2);
84 
85  sprintf(histo, "ES Trending Fiber Error per hour");
86  hESFiberErrTrendHr_ = iBooker.bookProfile(histo, histo, 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
87  hESFiberErrTrendHr_->setAxisTitle("Elapse time (Hours)", 1);
88  hESFiberErrTrendHr_->setAxisTitle("ES Fiber Err / hour", 2);
89 }

References dqm::implementation::IBooker::bookProfile(), timingPdfMaker::histo, mps_fire::i, dqmiolumiharvest::j, dqm::impl::MonitorElement::setAxisTitle(), and dqm::implementation::NavigatorBase::setCurrentFolder().

◆ dqmBeginRun()

void ESTrendTask::dqmBeginRun ( const edm::Run r,
const edm::EventSetup c 
)
overrideprotectedvirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 45 of file ESTrendTask.cc.

45  {
46  start_time_ = (r.beginTime()).unixTime();
47 
48  //std::cout << "start time : " << start_time_ << std::endl;
49 }

References alignCSCRings::r.

◆ shift2Left()

void ESTrendTask::shift2Left ( TProfile *  p,
int  bins = 1 
)
protected

Definition at line 226 of file ESTrendTask.cc.

226  {
227  if (bins <= 0)
228  return;
229 
230  if (!p->GetSumw2())
231  p->Sumw2();
232  int nBins = p->GetXaxis()->GetNbins();
233 
234  // by shifting n bin to the left, the number of entries are
235  // reduced by the number in n bins including the underflow bin.
236  double nentries = p->GetEntries();
237  for (int i = 0; i < bins; i++)
238  nentries -= p->GetBinEntries(i);
239  p->SetEntries(nentries);
240 
241  // the first bin goes to underflow
242  // each bin moves to the right
243 
244  TArrayD* sumw2 = p->GetSumw2();
245 
246  for (int i = 0; i <= nBins + 1 - bins; i++) {
247  // GetBinContent return binContent/binEntries
248  p->SetBinContent(i, p->GetBinContent(i + bins) * p->GetBinEntries(i + bins));
249  p->SetBinEntries(i, p->GetBinEntries(i + bins));
250  sumw2->SetAt(sumw2->GetAt(i + bins), i);
251  }
252 }

References trigObjTnPSource_cfi::bins, mps_fire::i, seedmultiplicitymonitor_newtracking_cfi::nBins, and AlCaHLTBitMon_ParallelJobs::p.

◆ shift2Right()

void ESTrendTask::shift2Right ( TProfile *  p,
int  bins = 1 
)
protected

Definition at line 198 of file ESTrendTask.cc.

198  {
199  if (bins <= 0)
200  return;
201 
202  if (!p->GetSumw2())
203  p->Sumw2();
204  int nBins = p->GetXaxis()->GetNbins();
205 
206  // by shifting n bin to the right, the number of entries are
207  // reduced by the number in n bins including the overflow bin.
208  double nentries = p->GetEntries();
209  for (int i = 0; i < bins; i++)
210  nentries -= p->GetBinEntries(nBins + 1 - bins);
211  p->SetEntries(nentries);
212 
213  // the last bin goes to overflow
214  // each bin moves to the right
215 
216  TArrayD* sumw2 = p->GetSumw2();
217 
218  for (int i = nBins + 1; i > bins; i--) {
219  // GetBinContent return binContent/binEntries
220  p->SetBinContent(i, p->GetBinContent(i - bins) * p->GetBinEntries(i - bins));
221  p->SetBinEntries(i, p->GetBinEntries(i - bins));
222  sumw2->SetAt(sumw2->GetAt(i - bins), i);
223  }
224 }

References trigObjTnPSource_cfi::bins, mps_fire::i, seedmultiplicitymonitor_newtracking_cfi::nBins, and AlCaHLTBitMon_ParallelJobs::p.

◆ updateTime()

void ESTrendTask::updateTime ( const edm::Event e)
protected

Definition at line 193 of file ESTrendTask.cc.

193  {
195  current_time_ = e.time().unixTime();
196 }

References MillePedeFileConverter_cfg::e.

Member Data Documentation

◆ current_time_

long int ESTrendTask::current_time_
private

Definition at line 59 of file ESTrendTask.h.

◆ dccCollections_

edm::EDGetTokenT<ESRawDataCollection> ESTrendTask::dccCollections_
private

Definition at line 48 of file ESTrendTask.h.

◆ hESFiberErrTrend_

MonitorElement* ESTrendTask::hESFiberErrTrend_
private

Definition at line 52 of file ESTrendTask.h.

◆ hESFiberErrTrendHr_

MonitorElement* ESTrendTask::hESFiberErrTrendHr_
private

Definition at line 56 of file ESTrendTask.h.

◆ hESRecHitTrend_

MonitorElement* ESTrendTask::hESRecHitTrend_[2][2]
private

Definition at line 50 of file ESTrendTask.h.

◆ hESRecHitTrendHr_

MonitorElement* ESTrendTask::hESRecHitTrendHr_[2][2]
private

Definition at line 54 of file ESTrendTask.h.

◆ hESSLinkErrTrend_

MonitorElement* ESTrendTask::hESSLinkErrTrend_
private

Definition at line 51 of file ESTrendTask.h.

◆ hESSLinkErrTrendHr_

MonitorElement* ESTrendTask::hESSLinkErrTrendHr_
private

Definition at line 55 of file ESTrendTask.h.

◆ ievt_

int ESTrendTask::ievt_
private

Definition at line 43 of file ESTrendTask.h.

◆ last_time_

long int ESTrendTask::last_time_
private

Definition at line 60 of file ESTrendTask.h.

◆ prefixME_

std::string ESTrendTask::prefixME_
private

Definition at line 45 of file ESTrendTask.h.

◆ rechittoken_

edm::EDGetTokenT<ESRecHitCollection> ESTrendTask::rechittoken_
private

Definition at line 47 of file ESTrendTask.h.

◆ start_time_

long int ESTrendTask::start_time_
private

Definition at line 58 of file ESTrendTask.h.

ESTrendTask::prefixME_
std::string prefixME_
Definition: ESTrendTask.h:45
mps_fire.i
i
Definition: mps_fire.py:355
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
ESTrendTask::hESSLinkErrTrendHr_
MonitorElement * hESSLinkErrTrendHr_
Definition: ESTrendTask.h:55
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
ESTrendTask::hESSLinkErrTrend_
MonitorElement * hESSLinkErrTrend_
Definition: ESTrendTask.h:51
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ESDCCHeaderBlock::getFEChannelStatus
const std::vector< int > & getFEChannelStatus() const
Definition: ESDCCHeaderBlock.h:99
ESTrendTask::shift2Right
void shift2Right(TProfile *p, int bins=1)
Definition: ESTrendTask.cc:198
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
ESTrendTask::hESRecHitTrendHr_
MonitorElement * hESRecHitTrendHr_[2][2]
Definition: ESTrendTask.h:54
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ESDetId
Definition: ESDetId.h:15
edm::Handle
Definition: AssociativeIterator.h:50
ESTrendTask::hESRecHitTrend_
MonitorElement * hESRecHitTrend_[2][2]
Definition: ESTrendTask.h:50
ESDCCHeaderBlock::getDCCErrors
int getDCCErrors() const
Definition: ESDCCHeaderBlock.h:84
ESTrendTask::dccCollections_
edm::EDGetTokenT< ESRawDataCollection > dccCollections_
Definition: ESTrendTask.h:48
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
seedmultiplicitymonitor_newtracking_cfi.nBins
nBins
Definition: seedmultiplicitymonitor_newtracking_cfi.py:8
ESTrendTask::hESFiberErrTrend_
MonitorElement * hESFiberErrTrend_
Definition: ESTrendTask.h:52
ESTrendTask::current_time_
long int current_time_
Definition: ESTrendTask.h:59
edm::LogWarning
Definition: MessageLogger.h:141
ESTrendTask::start_time_
long int start_time_
Definition: ESTrendTask.h:58
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
ESDCCHeaderBlock
Definition: ESDCCHeaderBlock.h:5
ESTrendTask::last_time_
long int last_time_
Definition: ESTrendTask.h:60
dqm::impl::MonitorElement::getTProfile
virtual TProfile * getTProfile()
Definition: MonitorElement.cc:1016
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
ESTrendTask::hESFiberErrTrendHr_
MonitorElement * hESFiberErrTrendHr_
Definition: ESTrendTask.h:56
trigObjTnPSource_cfi.bins
bins
Definition: trigObjTnPSource_cfi.py:20
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ESTrendTask::ievt_
int ievt_
Definition: ESTrendTask.h:43
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
edm::InputTag
Definition: InputTag.h:15
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
ESTrendTask::updateTime
void updateTime(const edm::Event &)
Definition: ESTrendTask.cc:193
ESTrendTask::rechittoken_
edm::EDGetTokenT< ESRecHitCollection > rechittoken_
Definition: ESTrendTask.h:47