CMS 3D CMS Logo

CommissioningTask.cc
Go to the documentation of this file.
9 #include "TAxis.h"
10 #include <iostream>
11 #include <iostream>
12 
13 using namespace sistrip;
14 
15 // -----------------------------------------------------------------------------
16 //
18  : dqm_(dqm),
19  updateFreq_(0),
20  fillCntr_(0),
21  connection_(conn),
22  fedKey_(0),
23  fecKey_(0),
24  booked_(false),
25  myName_(my_name),
26  eventSetup_(nullptr) {
27  uint16_t fed_ch = connection_.fedCh();
35  .key();
36 
37  LogTrace(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
38  << " Constructing '" << myName_ << "' object for FecKey/FedKey: "
39  << "0x" << std::hex << std::setw(8) << std::setfill('0') << fecKey_ << std::dec << "/"
40  << "0x" << std::hex << std::setw(8) << std::setfill('0') << fedKey_ << std::dec
41  << " and Crate/FEC/ring/CCU/module/LLDchan: " << connection_.fecCrate() << "/"
42  << connection_.fecSlot() << "/" << connection_.fecRing() << "/" << connection_.ccuAddr() << "/"
43  << connection_.ccuChan() << "/" << connection_.lldChannel()
44  << " and FedId/Ch: " << connection_.fedId() << "/" << connection_.fedCh();
45 }
46 
47 // -----------------------------------------------------------------------------
48 //
50  LogTrace(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
51  << " Destructing object for FED id/ch "
52  << " Constructing '" << myName_ << "' object for FecKey/FedKey: "
53  << "0x" << std::hex << std::setw(8) << std::setfill('0') << fecKey_ << std::dec << "/"
54  << "0x" << std::hex << std::setw(8) << std::setfill('0') << fedKey_ << std::dec
55  << " and Crate/FEC/ring/CCU/module/LLDchan: " << connection_.fecCrate() << "/"
56  << connection_.fecSlot() << "/" << connection_.fecRing() << "/" << connection_.ccuAddr() << "/"
57  << connection_.ccuChan() << "/" << connection_.lldChannel()
58  << " and FedId/Ch: " << connection_.fedId() << "/" << connection_.fedCh();
59  //@@ do not delete EventSetup pointer!
60 }
61 
62 // -----------------------------------------------------------------------------
63 //
65  : vNumOfEntries_(),
66  vSumOfContents_(),
67  vSumOfSquares_(),
68  isProfile_(true),
69  explicitFill_(false),
70  histo_(nullptr),
71  axis_(nullptr) {
72  ;
73 }
74 
75 // -----------------------------------------------------------------------------
76 //
77 CommissioningTask::CompactHistoSet::CompactHistoSet() : vNumOfEntries_(), explicitFill_(false), histo_(nullptr) { ; }
78 
79 // -----------------------------------------------------------------------------
80 //
82 
83 // -----------------------------------------------------------------------------
84 //
86 
87 // -----------------------------------------------------------------------------
88 //
90  histo_ = me;
91  TH1* histo = ExtractTObject<TH1>().extract(histo_);
92  if (histo_) {
93  axis_ = histo->GetXaxis();
94  }
95  //TProfile* prof = ExtractTObject<TProfile>().extract( histo_ );
96  //if ( prof ) { prof->SetErrorOption("s"); }
97 }
98 
99 // -----------------------------------------------------------------------------
100 //
102 
103 // -----------------------------------------------------------------------------
104 //
106  if (!axis_) {
107  return 0;
108  }
109  float range = axis_->GetXmax() - axis_->GetXmin();
110  if (range > 0.) {
111  int32_t bin = static_cast<int32_t>((value - axis_->GetXmin()) * (axis_->GetNbins() / range)) + 1;
112  if (bin < 0) {
113  return 0;
114  } else if (bin > axis_->GetNbins()) {
115  return static_cast<uint32_t>(axis_->GetNbins() + 1);
116  } else {
117  return bin;
118  }
119  } else {
120  return 0;
121  }
122 }
123 
124 // -----------------------------------------------------------------------------
125 //
127  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
128  << " No derived implementation exists!";
129 }
130 
131 // -----------------------------------------------------------------------------
132 //
134  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
135  << " No derived implementation exists!";
136 }
137 
138 // -----------------------------------------------------------------------------
139 //
141  const edm::DetSet<SiStripRawDigi>& digis,
142  const edm::DetSet<SiStripRawDigi>& digisAlt) {
143  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
144  << " No derived implementation exists!";
145 }
146 
147 // -----------------------------------------------------------------------------
148 //
150  const edm::DetSet<SiStripRawDigi>& digis,
151  const edm::DetSet<SiStripRawDigi>& digisAlt,
152  const std::vector<uint16_t>& stripOnCluster) {
153  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
154  << " No derived implementation exists!";
155 }
156 
157 // -----------------------------------------------------------------------------
158 //
160  const uint16_t& fed_id,
161  const std::map<uint16_t, float>& fed_ch) {
162  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
163  << " No derived implementation exists!";
164 }
165 
166 // -----------------------------------------------------------------------------
167 //
169  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
170  << " No derived implementation exists!";
171 }
172 
173 // -----------------------------------------------------------------------------
174 //
176  book();
177  booked_ = true;
178 }
179 
180 // -----------------------------------------------------------------------------
181 //
183  if (!booked_) {
184  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
185  << " Attempting to fill histos that haven't been booked yet!";
186  return;
187  }
188  fillCntr_++;
189  fill(summary, digis);
190  if (updateFreq_ && !(fillCntr_ % updateFreq_)) {
191  update();
192  }
193 }
194 
195 // -----------------------------------------------------------------------------
196 //
198  const edm::DetSet<SiStripRawDigi>& digis,
199  const edm::DetSet<SiStripRawDigi>& digisAlt) {
200  if (!booked_) {
201  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
202  << " Attempting to fill histos that haven't been booked yet!";
203  return;
204  }
205  fillCntr_++;
206  fill(summary, digis, digisAlt);
207  if (updateFreq_ && !(fillCntr_ % updateFreq_)) {
208  update();
209  }
210 }
211 
212 // -----------------------------------------------------------------------------
213 //
215  const edm::DetSet<SiStripRawDigi>& digis,
216  const edm::DetSet<SiStripRawDigi>& digisAlt,
217  const std::vector<uint16_t>& stripOnCluster) {
218  if (!booked_) {
219  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
220  << " Attempting to fill histos that haven't been booked yet!";
221  return;
222  }
223  fillCntr_++;
224  fill(summary, digis, digisAlt, stripOnCluster);
225  if (updateFreq_ && !(fillCntr_ % updateFreq_)) {
226  update();
227  }
228 }
229 
230 // -----------------------------------------------------------------------------
231 //
233  const uint16_t& fed_id,
234  const std::map<uint16_t, float>& fed_ch) {
235  if (!booked_) {
236  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
237  << " Attempting to fill histos that haven't been booked yet!";
238  return;
239  }
240  fillCntr_++;
241  fill(summary, fed_id, fed_ch);
242  if (updateFreq_ && !(fillCntr_ % updateFreq_)) {
243  update();
244  }
245 }
246 
247 // -----------------------------------------------------------------------------
248 //
250 
251 // -----------------------------------------------------------------------------
252 //
253 void CommissioningTask::updateHistoSet(HistoSet& histo_set, const uint32_t& bin) {
254  float value = 1.;
255  updateHistoSet(histo_set, bin, value);
256 }
257 
258 // -----------------------------------------------------------------------------
259 //
260 void CommissioningTask::updateHistoSet(CompactHistoSet& histo_set, const uint32_t& bin) {
261  short value = 1;
262  updateHistoSet(histo_set, bin, value);
263 }
264 
265 // -----------------------------------------------------------------------------
266 //
267 void CommissioningTask::updateHistoSet(HistoSet& histo_set, const float& value) {
268  float weight = 1.;
269  updateHistoSet(histo_set, histo_set.bin(value), weight);
270 }
271 
272 // -----------------------------------------------------------------------------
273 //
274 void CommissioningTask::updateHistoSet(HistoSet& histo_set, const uint32_t& bin, const float& value) {
275  // Check bin number
276  if (bin >= histo_set.vNumOfEntries_.size() && !histo_set.explicitFill_) {
277  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
278  << " Unexpected bin number " << bin << " when filling histogram of size "
279  << histo_set.vNumOfEntries_.size();
280  return;
281  }
282 
283  // Check if histo is TProfile or not
284  if (!histo_set.isProfile_) {
285  // Set entries
286  if (histo_set.explicitFill_) {
287  float origVal = histo_set.histo()->getBinContent(bin + 1);
288  histo_set.histo()->setBinContent(bin + 1, origVal + value);
289  } else {
290  histo_set.vNumOfEntries_[bin] += value;
291  }
292  } else {
293  // Set entries
294  histo_set.vNumOfEntries_[bin]++;
295 
296  // Check bin number
297  if (bin >= histo_set.vSumOfContents_.size() || bin >= histo_set.vSumOfSquares_.size()) {
298  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
299  << " Unexpected bin when filling histogram: " << bin;
300  return;
301  }
302 
303  // Set sum of contents and squares
304  histo_set.vSumOfContents_[bin] += value;
305  histo_set.vSumOfSquares_[bin] += value * value;
306  }
307 }
308 
309 // -----------------------------------------------------------------------------
310 //
311 void CommissioningTask::updateHistoSet(CompactHistoSet& histo_set, const uint32_t& bin, const short& value) {
312  // Check bin number
313  if (bin >= histo_set.vNumOfEntries_.size() && !histo_set.explicitFill_) {
314  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
315  << " Unexpected bin number " << bin << " when filling histogram of size "
316  << histo_set.vNumOfEntries_.size();
317  return;
318  }
319 
320  if (histo_set.explicitFill_) {
321  float origVal = histo_set.histo()->getBinContent(bin + 1);
322  histo_set.histo()->setBinContent(bin + 1, origVal + value);
323  } else {
324  // Set entries
325  histo_set.vNumOfEntries_[bin] += value;
326  }
327 }
328 
329 // -----------------------------------------------------------------------------
330 //
332  // Check if histo exists
333  if (!histo_set.histo()) {
334  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
335  << " NULL pointer to MonitorElement!";
336  return;
337  }
338 
339  if (!histo_set.explicitFill_) {
340  if (histo_set.isProfile_) {
341  TProfile* prof = ExtractTObject<TProfile>().extract(histo_set.histo());
342  // if ( prof ) { prof->SetErrorOption("s"); } //@@ necessary?
343  const static UpdateTProfile profile;
344  for (uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++) {
345  profile.setBinContents(prof,
346  ibin + 1,
347  histo_set.vNumOfEntries_[ibin],
348  histo_set.vSumOfContents_[ibin],
349  histo_set.vSumOfSquares_[ibin]);
350  }
351 
352  } else {
353  for (uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++) {
354  histo_set.histo()->setBinContent(ibin + 1, histo_set.vNumOfEntries_[ibin]);
355  }
356  }
357  }
358 }
359 
360 // -----------------------------------------------------------------------------
361 //
363  // Check if histo exists
364  if (!histo_set.histo()) {
365  edm::LogWarning(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]"
366  << " NULL pointer to MonitorElement!";
367  return;
368  }
369 
370  if (!histo_set.explicitFill_) {
371  for (uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++) {
372  histo_set.histo()->setBinContent(ibin + 1, histo_set.vNumOfEntries_[ibin]);
373  }
374  }
375 }
CommissioningTask::HistoSet::vSumOfSquares_
std::vector< double > vSumOfSquares_
Definition: CommissioningTask.h:46
sistrip::mlDqmSource_
static const char mlDqmSource_[]
Definition: ConstantsForLogger.h:20
CommissioningTask::HistoSet::bin
uint32_t bin(float value)
Definition: CommissioningTask.cc:105
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
FedChannelConnection::lldChannel
uint16_t lldChannel() const
Definition: FedChannelConnection.cc:106
FedChannelConnection::fecCrate
const uint16_t & fecCrate() const
Definition: FedChannelConnection.h:201
UpdateTProfile
Definition: UpdateTProfile.h:8
MessageLogger.h
CommissioningTask::HistoSet::vSumOfContents_
std::vector< float > vSumOfContents_
Definition: CommissioningTask.h:45
funct::false
false
Definition: Factorize.h:29
CommissioningTask::HistoSet::HistoSet
HistoSet()
Definition: CommissioningTask.cc:64
CommissioningTask::HistoSet::histo
MonitorElement * histo()
Definition: CommissioningTask.cc:81
CommissioningTask::fillHistograms
void fillHistograms(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)
Definition: CommissioningTask.cc:182
edm::DetSet
Definition: DetSet.h:23
FedChannelConnection::fedCh
const uint16_t & fedCh() const
Definition: FedChannelConnection.h:221
mps_merge.weight
weight
Definition: mps_merge.py:88
sistrip::fedKey_
static const char fedKey_[]
Definition: ConstantsForKeyType.h:21
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:278
DQMStore.h
ExtractTObject.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
CommissioningTask::CompactHistoSet::vNumOfEntries_
std::vector< short > vNumOfEntries_
Definition: CommissioningTask.h:60
SiStripFedKey
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
CommissioningTask::bookHistograms
void bookHistograms()
Definition: CommissioningTask.cc:175
ExtractTObject
Definition: ExtractTObject.h:9
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
FedChannelConnection::fecSlot
const uint16_t & fecSlot() const
Definition: FedChannelConnection.h:202
CommissioningTask::HistoSet
Definition: CommissioningTask.h:38
CommissioningTask::fecKey_
uint32_t fecKey_
Definition: CommissioningTask.h:172
CommissioningTask::HistoSet::vNumOfEntries_
std::vector< float > vNumOfEntries_
Definition: CommissioningTask.h:44
CommissioningTask::CompactHistoSet::histo
MonitorElement * histo()
Definition: CommissioningTask.cc:85
CommissioningTask::HistoSet::explicitFill_
bool explicitFill_
Definition: CommissioningTask.h:48
CommissioningTask::fedKey_
uint32_t fedKey_
Definition: CommissioningTask.h:170
dqm::legacy::DQMStore
Definition: DQMStore.h:728
sistrip::fecKey_
static const char fecKey_[]
Definition: ConstantsForKeyType.h:22
CommissioningTask::CompactHistoSet
Definition: CommissioningTask.h:55
CommissioningTask::~CommissioningTask
virtual ~CommissioningTask()
Definition: CommissioningTask.cc:49
CommissioningTask::myName_
std::string myName_
Definition: CommissioningTask.h:176
CommissioningTask::fill
virtual void fill(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)
Definition: CommissioningTask.cc:133
CommissioningTask::CompactHistoSet::histo
void histo(MonitorElement *)
Definition: CommissioningTask.cc:101
SiStripFecKey
Utility class that identifies a position within the strip tracker control structure,...
Definition: SiStripFecKey.h:45
SiStripFecKey.h
CommissioningTask::CommissioningTask
CommissioningTask()
Definition: CommissioningTask.h:143
CommissioningTask::HistoSet::isProfile_
bool isProfile_
Definition: CommissioningTask.h:47
PostProcessor_cff.profile
profile
Definition: PostProcessor_cff.py:38
FedChannelConnection
Class containning control, module, detector and connection information, at the level of a FED channel...
Definition: FedChannelConnection.h:26
funct::true
true
Definition: Factorize.h:173
SiStripConstants.h
FedChannelConnection::ccuAddr
const uint16_t & ccuAddr() const
Definition: FedChannelConnection.h:204
SiStripFedKey.h
CommissioningTask::HistoSet::histo
void histo(MonitorElement *)
Definition: CommissioningTask.cc:89
CommissioningTask::update
virtual void update()
Definition: CommissioningTask.cc:168
CommissioningTask::fillCntr_
uint32_t fillCntr_
Definition: CommissioningTask.h:166
SiStripFedKey::feUnit
const uint16_t & feUnit() const
Definition: SiStripFedKey.h:189
edmLumisInFiles.summary
summary
Definition: edmLumisInFiles.py:39
CommissioningTask::updateHistoSet
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
Definition: CommissioningTask.cc:274
value
Definition: value.py:1
CommissioningTask::book
virtual void book()
Definition: CommissioningTask.cc:126
CommissioningTask::CompactHistoSet::explicitFill_
bool explicitFill_
Definition: CommissioningTask.h:61
UpdateTProfile.h
CommissioningTask::connection_
FedChannelConnection connection_
Definition: CommissioningTask.h:168
ExtractTObject::extract
static T * extract(MonitorElement *me)
Definition: ExtractTObject.cc:21
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
FedChannelConnection::fedId
const uint16_t & fedId() const
Definition: FedChannelConnection.h:220
CommissioningTask::CompactHistoSet::CompactHistoSet
CompactHistoSet()
Definition: CommissioningTask.cc:77
relativeConstraints.value
value
Definition: relativeConstraints.py:53
CommissioningTask.h
dqm
Definition: DQMStore.h:18
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
sistrip
sistrip classes
Definition: EnsembleCalibrationLA.cc:10
SiStripEventSummary
Definition: SiStripEventSummary.h:22
FedChannelConnection::ccuChan
const uint16_t & ccuChan() const
Definition: FedChannelConnection.h:205
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
CommissioningTask::updateFreq_
uint32_t updateFreq_
Definition: CommissioningTask.h:164
crabWrapper.key
key
Definition: crabWrapper.py:19
CommissioningTask::booked_
bool booked_
Definition: CommissioningTask.h:174
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
weight
Definition: weight.py:1
FedChannelConnection::fecRing
const uint16_t & fecRing() const
Definition: FedChannelConnection.h:203
SiStripFedKey::feChan
const uint16_t & feChan() const
Definition: SiStripFedKey.h:190
CommissioningTask::updateHistograms
void updateHistograms()
Definition: CommissioningTask.cc:249