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:
one::DQMEDAnalyzer< T > one::dqmimplementation::DQMBaseClass< T... >

Public Member Functions

 ESTrendTask (const edm::ParameterSet &ps)
 
 ~ESTrendTask () override
 
- Public Member Functions inherited from one::DQMEDAnalyzer< T >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

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 endJob (void)
 
void shift2Left (TProfile *p, int bins=1)
 
void shift2Right (TProfile *p, int bins=1)
 
void updateTime (const edm::Event &)
 

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_
 

Detailed Description

Definition at line 17 of file ESTrendTask.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file ESTrendTask.cc.

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

23  {
24 
25  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "EcalPreshower");
26  rechittoken_ = consumes<ESRecHitCollection>(ps.getParameter<InputTag>("RecHitLabel"));
27  dccCollections_ = consumes<ESRawDataCollection>(ps.getParameter<InputTag>("ESDCCCollections"));
28 
29  for (int i=0; i<2; ++i)
30  for (int j=0; j<2; ++j) {
31  hESRecHitTrend_[i][j] = nullptr;
32  hESRecHitTrendHr_[i][j] = nullptr;
33  }
34 
35  hESSLinkErrTrend_ = nullptr;
36  hESFiberErrTrend_ = nullptr;
37  hESSLinkErrTrendHr_ = nullptr;
38  hESFiberErrTrendHr_ = nullptr;
39 
40  start_time_ = 0;
41  current_time_ = 0;
42  last_time_ = 0;
43 
44  ievt_ = 0;
45 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * hESRecHitTrendHr_[2][2]
Definition: ESTrendTask.h:62
edm::EDGetTokenT< ESRecHitCollection > rechittoken_
Definition: ESTrendTask.h:55
std::string prefixME_
Definition: ESTrendTask.h:53
MonitorElement * hESSLinkErrTrendHr_
Definition: ESTrendTask.h:63
long int current_time_
Definition: ESTrendTask.h:67
edm::EDGetTokenT< ESRawDataCollection > dccCollections_
Definition: ESTrendTask.h:56
long int start_time_
Definition: ESTrendTask.h:66
MonitorElement * hESRecHitTrend_[2][2]
Definition: ESTrendTask.h:58
MonitorElement * hESFiberErrTrend_
Definition: ESTrendTask.h:60
long int last_time_
Definition: ESTrendTask.h:68
MonitorElement * hESFiberErrTrendHr_
Definition: ESTrendTask.h:64
MonitorElement * hESSLinkErrTrend_
Definition: ESTrendTask.h:59
ESTrendTask::~ESTrendTask ( )
inlineoverride

Member Function Documentation

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

Definition at line 102 of file ESTrendTask.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), edm::Event::getByToken(), ESDCCHeaderBlock::getDCCErrors(), ESDCCHeaderBlock::getFEChannelStatus(), mps_fire::i, ESDetId::zside(), and ecaldqm::zside().

Referenced by ~ESTrendTask().

102  {
103 
104  ievt_++;
105 
106  // Collect time information
107  updateTime(e);
108 
109  long int diff_current_start = current_time_ - start_time_;
110  long int diff_last_start = last_time_ - start_time_;
111  //LogInfo("ESTrendTask") << "time difference is negative in " << ievt_ << " events\n"
112  //<< "\tcurrent - start time = " << diff_current_start
113  //<< ", \tlast - start time = " << diff_last_start << endl;
114 
115  // std::cout << "current_time : " << current_time_ << ", diff : " << diff_current_start << std::endl;
116 
117  // Calculate time interval and bin width
118  // int minuteBinWidth = int(nBasicClusterMinutely_->getTProfile()->GetXaxis()->GetBinWidth(1));
119  int minuteBinWidth = 5;
120  long int minuteBinDiff = diff_current_start/60/minuteBinWidth - diff_last_start/60/minuteBinWidth;
121  long int minuteDiff = (current_time_ - last_time_)/60;
122 
123  // int hourBinWidth = int(nBasicClusterHourly_->getTProfile()->GetXaxis()->GetBinWidth(1));
124  int hourBinWidth = 1;
125  long int hourBinDiff = diff_current_start/3600/hourBinWidth - diff_last_start/3600/hourBinWidth;
126  long int hourDiff = (current_time_ - last_time_)/3600;
127 
128  if (minuteDiff >= minuteBinWidth) {
129  while (minuteDiff >= minuteBinWidth) minuteDiff -= minuteBinWidth;
130  }
131  if (hourDiff >= hourBinWidth) {
132  while (hourDiff >= hourBinWidth) hourDiff -= hourBinWidth;
133  }
134 
135  // ES DCC
136  Int_t slinkCRCErr = 0;
137  Int_t fiberErr = 0;
138  vector<int> fiberStatus;
140  if ( e.getByToken(dccCollections_, dccs) ) {
141  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
142  ESDCCHeaderBlock dcc = (*dccItr);
143 
144  if (dcc.getDCCErrors() == 101) slinkCRCErr++;
145 
146  fiberStatus = dcc.getFEChannelStatus();
147  for (unsigned int i=0; i<fiberStatus.size(); ++i) {
148  if (fiberStatus[i]==4 || fiberStatus[i]==8 || fiberStatus[i]==10 || fiberStatus[i]==11 || fiberStatus[i]==12)
149  fiberErr++;
150  }
151 
152  }
153  }
154 
155  shift2Right(hESSLinkErrTrend_->getTProfile(), minuteBinDiff);
156  hESSLinkErrTrend_->Fill(minuteDiff, slinkCRCErr);
157 
158  shift2Right(hESFiberErrTrend_->getTProfile(), minuteBinDiff);
159  hESFiberErrTrend_->Fill(minuteDiff, fiberErr);
160 
162  hESSLinkErrTrendHr_->Fill(hourDiff, slinkCRCErr);
163 
165  hESFiberErrTrendHr_->Fill(hourDiff, fiberErr);
166 
167  // ES RecHits
168  int zside, plane;
169  int nrh[2][2];
170  for (int i = 0; i < 2; i++ )
171  for( int j = 0; j < 2; j++) {
172  nrh[i][j] = 0;
173  }
174 
176  if ( e.getByToken(rechittoken_, ESRecHit) ) {
177 
178  for (ESRecHitCollection::const_iterator hitItr = ESRecHit->begin(); hitItr != ESRecHit->end(); ++hitItr) {
179 
180  ESDetId id = ESDetId(hitItr->id());
181 
182  zside = id.zside();
183  plane = id.plane();
184 
185  int i = (zside==1)? 0:1;
186  int j = plane-1;
187 
188  nrh[i][j]++;
189  }
190  } else {
191  LogWarning("ESTrendTask") << "RecHitCollection not available";
192  }
193 
194  for (int i=0; i<2; ++i)
195  for (int j=0; j<2; ++j) {
196  shift2Right(hESRecHitTrend_[i][j]->getTProfile(), minuteBinDiff);
197  hESRecHitTrend_[i][j]->Fill(minuteDiff, nrh[i][j]/(1072*32.));
198 
199  shift2Right(hESRecHitTrendHr_[i][j]->getTProfile(), hourBinDiff);
200  hESRecHitTrendHr_[i][j]->Fill(hourDiff, nrh[i][j]/(1072*32.));
201  }
202 
203 }
TProfile * getTProfile() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
MonitorElement * hESRecHitTrendHr_[2][2]
Definition: ESTrendTask.h:62
edm::EDGetTokenT< ESRecHitCollection > rechittoken_
Definition: ESTrendTask.h:55
std::vector< ESDCCHeaderBlock >::const_iterator const_iterator
void shift2Right(TProfile *p, int bins=1)
Definition: ESTrendTask.cc:212
MonitorElement * hESSLinkErrTrendHr_
Definition: ESTrendTask.h:63
int zside(DetId const &)
long int current_time_
Definition: ESTrendTask.h:67
edm::EDGetTokenT< ESRawDataCollection > dccCollections_
Definition: ESTrendTask.h:56
const std::vector< int > & getFEChannelStatus() const
void Fill(long long x)
long int start_time_
Definition: ESTrendTask.h:66
MonitorElement * hESRecHitTrend_[2][2]
Definition: ESTrendTask.h:58
MonitorElement * hESFiberErrTrend_
Definition: ESTrendTask.h:60
long int last_time_
Definition: ESTrendTask.h:68
int zside() const
Definition: ESDetId.h:45
const_iterator end() const
MonitorElement * hESFiberErrTrendHr_
Definition: ESTrendTask.h:64
int getDCCErrors() const
void updateTime(const edm::Event &)
Definition: ESTrendTask.cc:205
const_iterator begin() const
MonitorElement * hESSLinkErrTrend_
Definition: ESTrendTask.h:59
void ESTrendTask::bookHistograms ( DQMStore::IBooker iBooker,
edm::Run const &  ,
edm::EventSetup const &   
)
overrideprotected

Definition at line 55 of file ESTrendTask.cc.

References DQMStore::IBooker::bookProfile(), trackerHits::histo, mps_fire::i, MonitorElement::setAxisTitle(), and DQMStore::IBooker::setCurrentFolder().

Referenced by ~ESTrendTask().

56 {
57  char histo[200];
58 
59  iBooker.setCurrentFolder(prefixME_ + "/ESTrendTask");
60 
61  for (int i=0 ; i<2; ++i)
62  for (int j=0 ; j<2; ++j) {
63  int iz = (i==0)? 1:-1;
64  sprintf(histo, "ES Trending RH Occ per 5 mins Z %d P %d", iz, j+1);
65  hESRecHitTrend_[i][j] = iBooker.bookProfile(histo, histo, 36, 0.0, 180.0, 100, 0.0, 1.0e6, "s");
66  hESRecHitTrend_[i][j]->setAxisTitle("Elapse time (Minutes)", 1);
67  hESRecHitTrend_[i][j]->setAxisTitle("ES RecHit Occupancy / 5 minutes", 2);
68 
69  sprintf(histo, "ES Trending RH Occ per hour Z %d P %d", iz, j+1);
70  hESRecHitTrendHr_[i][j] = iBooker.bookProfile(histo, histo, 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
71  hESRecHitTrendHr_[i][j]->setAxisTitle("Elapse time (Hours)", 1);
72  hESRecHitTrendHr_[i][j]->setAxisTitle("ES RecHit Occupancy / hour", 2);
73  }
74 
75  sprintf(histo, "ES Trending SLink CRC Error per 5 mins");
76  hESSLinkErrTrend_ = iBooker.bookProfile(histo, histo, 36, 0.0, 180.0, 100, 0.0, 1.0e6, "s");
77  hESSLinkErrTrend_->setAxisTitle("Elapse time (Minutes)", 1);
78  hESSLinkErrTrend_->setAxisTitle("ES SLink CRC Err / 5 minutes", 2);
79 
80  sprintf(histo, "ES Trending Fiber Error per 5 mins");
81  hESFiberErrTrend_ = iBooker.bookProfile(histo, histo, 36, 0.0, 180.0, 100, 0.0, 1.0e6, "s");
82  hESFiberErrTrend_->setAxisTitle("Elapse time (Minutes)", 1);
83  hESFiberErrTrend_->setAxisTitle("ES Fiber Err / 5 minutes", 2);
84 
85  sprintf(histo, "ES Trending SLink CRC Error per hour");
86  hESSLinkErrTrendHr_ = iBooker.bookProfile(histo, histo, 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
87  hESSLinkErrTrendHr_->setAxisTitle("Elapse time (Hours)", 1);
88  hESSLinkErrTrendHr_->setAxisTitle("ES SLink CRC Err / hour", 2);
89 
90  sprintf(histo, "ES Trending Fiber Error per hour");
91  hESFiberErrTrendHr_ = iBooker.bookProfile(histo, histo, 24, 0.0, 24.0, 100, 0.0, 1.0e6, "s");
92  hESFiberErrTrendHr_->setAxisTitle("Elapse time (Hours)", 1);
93  hESFiberErrTrendHr_->setAxisTitle("ES Fiber Err / hour", 2);
94 }
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:113
MonitorElement * hESRecHitTrendHr_[2][2]
Definition: ESTrendTask.h:62
std::string prefixME_
Definition: ESTrendTask.h:53
MonitorElement * hESSLinkErrTrendHr_
Definition: ESTrendTask.h:63
MonitorElement * hESRecHitTrend_[2][2]
Definition: ESTrendTask.h:58
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * hESFiberErrTrend_
Definition: ESTrendTask.h:60
MonitorElement * hESFiberErrTrendHr_
Definition: ESTrendTask.h:64
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
MonitorElement * hESSLinkErrTrend_
Definition: ESTrendTask.h:59
void ESTrendTask::dqmBeginRun ( const edm::Run r,
const edm::EventSetup c 
)
overrideprotected

Definition at line 47 of file ESTrendTask.cc.

References edm::RunBase::beginTime().

Referenced by ~ESTrendTask().

47  {
48 
49  start_time_ = (r.beginTime()).unixTime();
50 
51  //std::cout << "start time : " << start_time_ << std::endl;
52 
53 }
long int start_time_
Definition: ESTrendTask.h:66
Timestamp const & beginTime() const
Definition: RunBase.h:41
void ESTrendTask::endJob ( void  )
protected

Definition at line 96 of file ESTrendTask.cc.

Referenced by ~ESTrendTask().

96  {
97 
98  LogInfo("ESTrendTask") << "analyzed " << ievt_ << " events";
99 
100 }
void ESTrendTask::shift2Left ( TProfile *  p,
int  bins = 1 
)
protected

Definition at line 239 of file ESTrendTask.cc.

References create_public_pileup_plots::bins, DEFINE_FWK_MODULE, and mps_fire::i.

Referenced by ~ESTrendTask().

239  {
240 
241  if(bins <= 0) return;
242 
243  if(!p->GetSumw2()) p->Sumw2();
244  int nBins = p->GetXaxis()->GetNbins();
245 
246  // by shifting n bin to the left, the number of entries are
247  // reduced by the number in n bins including the underflow bin.
248  double nentries = p->GetEntries();
249  for(int i=0; i<bins; i++) nentries -= p->GetBinEntries(i);
250  p->SetEntries(nentries);
251 
252  // the first bin goes to underflow
253  // each bin moves to the right
254 
255  TArrayD* sumw2 = p->GetSumw2();
256 
257  for(int i=0; i<=nBins+1-bins; i++) {
258  // GetBinContent return binContent/binEntries
259  p->SetBinContent(i, p->GetBinContent(i+bins)*p->GetBinEntries(i+bins));
260  p->SetBinEntries(i,p->GetBinEntries(i+bins));
261  sumw2->SetAt(sumw2->GetAt(i+bins),i);
262  }
263 
264 }
void ESTrendTask::shift2Right ( TProfile *  p,
int  bins = 1 
)
protected

Definition at line 212 of file ESTrendTask.cc.

References create_public_pileup_plots::bins, and mps_fire::i.

Referenced by ~ESTrendTask().

212  {
213 
214  if(bins <= 0) return;
215 
216  if(!p->GetSumw2()) p->Sumw2();
217  int nBins = p->GetXaxis()->GetNbins();
218 
219  // by shifting n bin to the right, the number of entries are
220  // reduced by the number in n bins including the overflow bin.
221  double nentries = p->GetEntries();
222  for(int i=0; i<bins; i++) nentries -= p->GetBinEntries(nBins+1-bins);
223  p->SetEntries(nentries);
224 
225  // the last bin goes to overflow
226  // each bin moves to the right
227 
228  TArrayD* sumw2 = p->GetSumw2();
229 
230  for(int i=nBins+1; i>bins; i--) {
231  // GetBinContent return binContent/binEntries
232  p->SetBinContent(i, p->GetBinContent(i-bins)*p->GetBinEntries(i-bins));
233  p->SetBinEntries(i,p->GetBinEntries(i-bins));
234  sumw2->SetAt(sumw2->GetAt(i-bins),i);
235  }
236 
237 }
void ESTrendTask::updateTime ( const edm::Event e)
protected

Definition at line 205 of file ESTrendTask.cc.

References edm::EventBase::time(), and edm::Timestamp::unixTime().

Referenced by ~ESTrendTask().

205  {
206 
208  current_time_ = e.time().unixTime();
209 
210 }
long int current_time_
Definition: ESTrendTask.h:67
unsigned int unixTime() const
Time in seconds since January 1, 1970.
Definition: Timestamp.h:46
long int last_time_
Definition: ESTrendTask.h:68
edm::Timestamp time() const
Definition: EventBase.h:61

Member Data Documentation

long int ESTrendTask::current_time_
private

Definition at line 67 of file ESTrendTask.h.

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

Definition at line 56 of file ESTrendTask.h.

MonitorElement* ESTrendTask::hESFiberErrTrend_
private

Definition at line 60 of file ESTrendTask.h.

MonitorElement* ESTrendTask::hESFiberErrTrendHr_
private

Definition at line 64 of file ESTrendTask.h.

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

Definition at line 58 of file ESTrendTask.h.

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

Definition at line 62 of file ESTrendTask.h.

MonitorElement* ESTrendTask::hESSLinkErrTrend_
private

Definition at line 59 of file ESTrendTask.h.

MonitorElement* ESTrendTask::hESSLinkErrTrendHr_
private

Definition at line 63 of file ESTrendTask.h.

int ESTrendTask::ievt_
private

Definition at line 51 of file ESTrendTask.h.

long int ESTrendTask::last_time_
private

Definition at line 68 of file ESTrendTask.h.

std::string ESTrendTask::prefixME_
private

Definition at line 53 of file ESTrendTask.h.

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

Definition at line 55 of file ESTrendTask.h.

long int ESTrendTask::start_time_
private

Definition at line 66 of file ESTrendTask.h.