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  const FedChannelConnection& conn,
19  const std::string& my_name ) :
20  dqm_(dqm),
21  updateFreq_(0),
22  fillCntr_(0),
23  connection_(conn),
24  fedKey_(0),
25  fecKey_(0),
26  booked_(false),
27  myName_(my_name),
28  eventSetup_(nullptr)
29 {
30  uint16_t fed_ch = connection_.fedCh();
32  SiStripFedKey::feUnit(fed_ch),
33  SiStripFedKey::feChan(fed_ch) ).key();
40 
42  << "[CommissioningTask::" << __func__ << "]"
43  << " Constructing '" << myName_
44  << "' object for FecKey/FedKey: "
45  << "0x" << std::hex << std::setw(8) << std::setfill('0') << fecKey_ << std::dec
46  << "/"
47  << "0x" << std::hex << std::setw(8) << std::setfill('0') << fedKey_ << std::dec
48  << " and Crate/FEC/ring/CCU/module/LLDchan: "
49  << connection_.fecCrate() << "/"
50  << connection_.fecSlot() << "/"
51  << connection_.fecRing() << "/"
52  << connection_.ccuAddr() << "/"
53  << connection_.ccuChan() << "/"
55  << " and FedId/Ch: "
56  << connection_.fedId() << "/"
57  << connection_.fedCh();
58 }
59 
60 // -----------------------------------------------------------------------------
61 //
64  << "[CommissioningTask::" << __func__ << "]"
65  << " Destructing object for FED id/ch "
66  << " Constructing '" << myName_
67  << "' object for FecKey/FedKey: "
68  << "0x" << std::hex << std::setw(8) << std::setfill('0') << fecKey_ << std::dec
69  << "/"
70  << "0x" << std::hex << std::setw(8) << std::setfill('0') << fedKey_ << std::dec
71  << " and Crate/FEC/ring/CCU/module/LLDchan: "
72  << connection_.fecCrate() << "/"
73  << connection_.fecSlot() << "/"
74  << connection_.fecRing() << "/"
75  << connection_.ccuAddr() << "/"
76  << connection_.ccuChan() << "/"
78  << " and FedId/Ch: "
79  << connection_.fedId() << "/"
80  << connection_.fedCh();
81  //@@ do not delete EventSetup pointer!
82 }
83 
84 // -----------------------------------------------------------------------------
85 //
87  vNumOfEntries_(),
88  vSumOfContents_(),
89  vSumOfSquares_(),
90  isProfile_(true),
91  explicitFill_(false),
92  histo_(nullptr),
93  axis_(nullptr)
94 {;}
95 
96 // -----------------------------------------------------------------------------
97 //
99  vNumOfEntries_(),
101  histo_(nullptr)
102 {;}
103 
104 // -----------------------------------------------------------------------------
105 //
107 
108 // -----------------------------------------------------------------------------
109 //
111 
112 // -----------------------------------------------------------------------------
113 //
115  histo_ = me;
117  if ( histo_ ) { axis_ = histo->GetXaxis(); }
118  //TProfile* prof = ExtractTObject<TProfile>().extract( histo_ );
119  //if ( prof ) { prof->SetErrorOption("s"); }
120 }
121 
122 // -----------------------------------------------------------------------------
123 //
125  histo_ = me;
126 }
127 
128 // -----------------------------------------------------------------------------
129 //
131  if ( !axis_ ) { return 0; }
132  float range = axis_->GetXmax() - axis_->GetXmin();
133  if ( range > 0. ) {
134  int32_t bin = static_cast<int32_t>( ( value - axis_->GetXmin() ) *
135  ( axis_->GetNbins() / range ) ) + 1;
136  if ( bin < 0 ) { return 0; }
137  else if ( bin > axis_->GetNbins() ) { return static_cast<uint32_t>( axis_->GetNbins() + 1 ); }
138  else { return bin; }
139  } else { return 0; }
140 }
141 
142 // -----------------------------------------------------------------------------
143 //
146  << "[CommissioningTask::" << __func__ << "]"
147  << " No derived implementation exists!";
148 }
149 
150 // -----------------------------------------------------------------------------
151 //
153  const edm::DetSet<SiStripRawDigi>& digis ) {
155  << "[CommissioningTask::" << __func__ << "]"
156  << " No derived implementation exists!";
157 }
158 
159 // -----------------------------------------------------------------------------
160 //
162  const edm::DetSet<SiStripRawDigi>& digis,
163  const edm::DetSet<SiStripRawDigi>& digisAlt) {
165  << "[CommissioningTask::" << __func__ << "]"
166  << " No derived implementation exists!";
167 }
168 
169 // -----------------------------------------------------------------------------
170 //
172  const edm::DetSet<SiStripRawDigi>& digis,
173  const edm::DetSet<SiStripRawDigi>& digisAlt,
174  const std::vector<uint16_t>& stripOnCluster) {
176  << "[CommissioningTask::" << __func__ << "]"
177  << " No derived implementation exists!";
178 }
179 
180 // -----------------------------------------------------------------------------
181 //
183  const uint16_t& fed_id,
184  const std::map<uint16_t,float>& fed_ch ) {
186  << "[CommissioningTask::" << __func__ << "]"
187  << " No derived implementation exists!";
188 }
189 
190 // -----------------------------------------------------------------------------
191 //
194  << "[CommissioningTask::" << __func__ << "]"
195  << " No derived implementation exists!";
196 }
197 
198 // -----------------------------------------------------------------------------
199 //
201  book();
202  booked_ = true;
203 }
204 
205 // -----------------------------------------------------------------------------
206 //
208  const edm::DetSet<SiStripRawDigi>& digis ) {
209  if ( !booked_ ) {
211  << "[CommissioningTask::" << __func__ << "]"
212  << " Attempting to fill histos that haven't been booked yet!";
213  return;
214  }
215  fillCntr_++;
216  fill( summary, digis );
217  if ( updateFreq_ && !(fillCntr_%updateFreq_) ) {
218  update();
219  }
220 
221 }
222 
223 // -----------------------------------------------------------------------------
224 //
226  const edm::DetSet<SiStripRawDigi>& digis,
227  const edm::DetSet<SiStripRawDigi>& digisAlt
228  ) {
229  if ( !booked_ ) {
231  << "[CommissioningTask::" << __func__ << "]"
232  << " Attempting to fill histos that haven't been booked yet!";
233  return;
234  }
235  fillCntr_++;
236  fill( summary, digis, digisAlt );
237  if ( updateFreq_ && !(fillCntr_%updateFreq_) ) {
238  update();
239  }
240 
241 }
242 
243 
244 // -----------------------------------------------------------------------------
245 //
247  const edm::DetSet<SiStripRawDigi>& digis,
248  const edm::DetSet<SiStripRawDigi>& digisAlt,
249  const std::vector<uint16_t>& stripOnCluster
250  ) {
251  if ( !booked_ ) {
253  << "[CommissioningTask::" << __func__ << "]"
254  << " Attempting to fill histos that haven't been booked yet!";
255  return;
256  }
257  fillCntr_++;
258  fill( summary, digis, digisAlt, stripOnCluster);
259  if ( updateFreq_ && !(fillCntr_%updateFreq_) ) {
260  update();
261  }
262 }
263 
264 // -----------------------------------------------------------------------------
265 //
267  const uint16_t& fed_id,
268  const std::map<uint16_t,float>& fed_ch ) {
269  if ( !booked_ ) {
271  << "[CommissioningTask::" << __func__ << "]"
272  << " Attempting to fill histos that haven't been booked yet!";
273  return;
274  }
275  fillCntr_++;
276  fill( summary, fed_id, fed_ch );
277  if ( updateFreq_ && !(fillCntr_%updateFreq_) ) {
278  update();
279  }
280 
281 }
282 
283 // -----------------------------------------------------------------------------
284 //
286  update();
287 }
288 
289 // -----------------------------------------------------------------------------
290 //
292  const uint32_t& bin ) {
293  float value = 1.;
294  updateHistoSet( histo_set, bin, value );
295 }
296 
297 // -----------------------------------------------------------------------------
298 //
300  const uint32_t& bin ) {
301  short value = 1;
302  updateHistoSet( histo_set, bin, value );
303 }
304 
305 // -----------------------------------------------------------------------------
306 //
308  const float& value ) {
309  float weight = 1.;
310  updateHistoSet( histo_set, histo_set.bin(value), weight );
311 }
312 
313 // -----------------------------------------------------------------------------
314 //
316  const uint32_t& bin,
317  const float& value ) {
318 
319  // Check bin number
320  if ( bin >= histo_set.vNumOfEntries_.size() && !histo_set.explicitFill_ ) {
322  << "[CommissioningTask::" << __func__ << "]"
323  << " Unexpected bin number " << bin
324  << " when filling histogram of size " << histo_set.vNumOfEntries_.size();
325  return;
326  }
327 
328  // Check if histo is TProfile or not
329  if ( !histo_set.isProfile_ ) {
330  // Set entries
331  if (histo_set.explicitFill_) {
332  float origVal = histo_set.histo()->getBinContent( bin+1 );
333  histo_set.histo()->setBinContent( bin+1, origVal + value );
334  } else {
335  histo_set.vNumOfEntries_[bin]+=value;
336  }
337  } else {
338  // Set entries
339  histo_set.vNumOfEntries_[bin]++;
340 
341  // Check bin number
342  if ( bin >= histo_set.vSumOfContents_.size() ||
343  bin >= histo_set.vSumOfSquares_.size() ) {
345  << "[CommissioningTask::" << __func__ << "]"
346  << " Unexpected bin when filling histogram: " << bin;
347  return;
348  }
349 
350  // Set sum of contents and squares
351  histo_set.vSumOfContents_[bin] += value;
352  histo_set.vSumOfSquares_[bin] += value*value;
353  }
354 
355 }
356 
357 // -----------------------------------------------------------------------------
358 //
360  const uint32_t& bin,
361  const short& value ) {
362 
363  // Check bin number
364  if ( bin >= histo_set.vNumOfEntries_.size() && !histo_set.explicitFill_ ) {
366  << "[CommissioningTask::" << __func__ << "]"
367  << " Unexpected bin number " << bin
368  << " when filling histogram of size " << histo_set.vNumOfEntries_.size();
369  return;
370  }
371 
372  if (histo_set.explicitFill_) {
373  float origVal = histo_set.histo()->getBinContent( bin+1 );
374  histo_set.histo()->setBinContent( bin+1, origVal + value );
375  } else {
376  // Set entries
377  histo_set.vNumOfEntries_[bin] += value;
378  }
379 
380 }
381 
382 // -----------------------------------------------------------------------------
383 //
385 
386  // Check if histo exists
387  if ( !histo_set.histo() ) {
389  << "[CommissioningTask::" << __func__ << "]"
390  << " NULL pointer to MonitorElement!";
391  return;
392  }
393 
394  if (!histo_set.explicitFill_) {
395 
396  if ( histo_set.isProfile_ ) {
397 
398  TProfile* prof = ExtractTObject<TProfile>().extract( histo_set.histo() );
399  // if ( prof ) { prof->SetErrorOption("s"); } //@@ necessary?
400  const static UpdateTProfile profile;
401  for ( uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++ ) {
402  profile.setBinContents( prof,
403  ibin+1,
404  histo_set.vNumOfEntries_[ibin],
405  histo_set.vSumOfContents_[ibin],
406  histo_set.vSumOfSquares_[ibin] );
407  }
408 
409  } else {
410 
411  for ( uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++ ) {
412  histo_set.histo()->setBinContent( ibin+1, histo_set.vNumOfEntries_[ibin] );
413  }
414 
415  }
416 
417  }
418 
419 }
420 
421 // -----------------------------------------------------------------------------
422 //
424 
425  // Check if histo exists
426  if ( !histo_set.histo() ) {
428  << "[CommissioningTask::" << __func__ << "]"
429  << " NULL pointer to MonitorElement!";
430  return;
431  }
432 
433  if (!histo_set.explicitFill_) {
434  for ( uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++ ) {
435  histo_set.histo()->setBinContent( ibin+1, histo_set.vNumOfEntries_[ibin] );
436  }
437  }
438 
439 }
const uint16_t & fecSlot() const
std::vector< float > vNumOfEntries_
const uint16_t & fecCrate() const
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
const uint16_t & fedCh() const
static const char mlDqmSource_[]
#define nullptr
static const char fedKey_[]
std::vector< float > vSumOfContents_
Definition: weight.py:1
uint16_t lldChannel() const
const uint16_t & fedId() const
sistrip classes
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
const uint16_t & fecRing() const
Class containning control, module, detector and connection information, at the level of a FED channel...
const uint16_t & ccuChan() const
const reco::Candidate::LorentzVector & axis_
static const char fecKey_[]
Definition: value.py:1
virtual void fill(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)
const uint16_t & ccuAddr() const
#define LogTrace(id)
bin
set the eta bin as selection string.
int extract(std::vector< int > *output, const std::string &dati)
virtual ~CommissioningTask()
const uint16_t & feUnit() const
virtual void update()
void histo(MonitorElement *)
const uint16_t & feChan() const
std::vector< double > vSumOfSquares_
FedChannelConnection connection_
void fillHistograms(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)