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 uint16_t& fed_id,
173  const std::map<uint16_t,float>& fed_ch ) {
175  << "[CommissioningTask::" << __func__ << "]"
176  << " No derived implementation exists!";
177 }
178 
179 // -----------------------------------------------------------------------------
180 //
183  << "[CommissioningTask::" << __func__ << "]"
184  << " No derived implementation exists!";
185 }
186 
187 // -----------------------------------------------------------------------------
188 //
190  book();
191  booked_ = true;
192 }
193 
194 // -----------------------------------------------------------------------------
195 //
197  const edm::DetSet<SiStripRawDigi>& digis ) {
198  if(summary.runType() != sistrip::CALIBRATION_SCAN and
199  summary.runType() != sistrip::CALIBRATION_SCAN_DECO and
200  summary.runType() != sistrip::CALIBRATION and
201  summary.runType() != sistrip::CALIBRATION_DECO){
202  if ( !booked_ ) {
204  << "[CommissioningTask::" << __func__ << "]"
205  << " Attempting to fill histos that haven't been booked yet!";
206  return;
207  }
208  }
209  fillCntr_++;
210  fill( summary, digis );
211  if ( updateFreq_ && !(fillCntr_%updateFreq_) ) {
212  update();
213  }
214 }
215 
216 // -----------------------------------------------------------------------------
217 //
219  const edm::DetSet<SiStripRawDigi>& digis,
220  const edm::DetSet<SiStripRawDigi>& digisAlt
221  ) {
222  if ( !booked_ ) {
224  << "[CommissioningTask::" << __func__ << "]"
225  << " Attempting to fill histos that haven't been booked yet!";
226  return;
227  }
228  fillCntr_++;
229  fill( summary, digis, digisAlt );
230  if ( updateFreq_ && !(fillCntr_%updateFreq_) ) {
231  update();
232  }
233 }
234 
235 // -----------------------------------------------------------------------------
236 //
238  const uint16_t& fed_id,
239  const std::map<uint16_t,float>& fed_ch ) {
240  if ( !booked_ ) {
242  << "[CommissioningTask::" << __func__ << "]"
243  << " Attempting to fill histos that haven't been booked yet!";
244  return;
245  }
246  fillCntr_++;
247  fill( summary, fed_id, fed_ch );
248  if ( updateFreq_ && !(fillCntr_%updateFreq_) ) {
249  update();
250  }
251 
252 }
253 
254 // -----------------------------------------------------------------------------
255 //
257  update();
258 }
259 
260 // -----------------------------------------------------------------------------
261 //
263  const uint32_t& bin ) {
264  float value = 1.;
265  updateHistoSet( histo_set, bin, value );
266 }
267 
268 // -----------------------------------------------------------------------------
269 //
271  const uint32_t& bin ) {
272  short value = 1;
273  updateHistoSet( histo_set, bin, value );
274 }
275 
276 // -----------------------------------------------------------------------------
277 //
279  const float& value ) {
280  float weight = 1.;
281  updateHistoSet( histo_set, histo_set.bin(value), weight );
282 }
283 
284 // -----------------------------------------------------------------------------
285 //
287  const uint32_t& bin,
288  const float& value ) {
289 
290  // Check bin number
291  if ( bin >= histo_set.vNumOfEntries_.size() && !histo_set.explicitFill_ ) {
293  << "[CommissioningTask::" << __func__ << "]"
294  << " Unexpected bin number " << bin
295  << " when filling histogram of size " << histo_set.vNumOfEntries_.size();
296  return;
297  }
298 
299  // Check if histo is TProfile or not
300  if ( !histo_set.isProfile_ ) {
301  // Set entries
302  if (histo_set.explicitFill_) {
303  float origVal = histo_set.histo()->getBinContent( bin+1 );
304  histo_set.histo()->setBinContent( bin+1, origVal + value );
305  } else {
306  histo_set.vNumOfEntries_[bin]+=value;
307  }
308  } else {
309  // Set entries
310  histo_set.vNumOfEntries_[bin]++;
311 
312  // Check bin number
313  if ( bin >= histo_set.vSumOfContents_.size() ||
314  bin >= histo_set.vSumOfSquares_.size() ) {
316  << "[CommissioningTask::" << __func__ << "]"
317  << " Unexpected bin when filling histogram: " << bin;
318  return;
319  }
320 
321  // Set sum of contents and squares
322  histo_set.vSumOfContents_[bin] += value;
323  histo_set.vSumOfSquares_[bin] += value*value;
324  }
325 
326 }
327 
328 // -----------------------------------------------------------------------------
329 //
331  const uint32_t& bin,
332  const short& value ) {
333 
334  // Check bin number
335  if ( bin >= histo_set.vNumOfEntries_.size() && !histo_set.explicitFill_ ) {
337  << "[CommissioningTask::" << __func__ << "]"
338  << " Unexpected bin number " << bin
339  << " when filling histogram of size " << histo_set.vNumOfEntries_.size();
340  return;
341  }
342 
343  if (histo_set.explicitFill_) {
344  float origVal = histo_set.histo()->getBinContent( bin+1 );
345  histo_set.histo()->setBinContent( bin+1, origVal + value );
346  } else {
347  // Set entries
348  histo_set.vNumOfEntries_[bin] += value;
349  }
350 
351 }
352 
353 // -----------------------------------------------------------------------------
354 //
356 
357  // Check if histo exists
358  if ( !histo_set.histo() ) {
360  << "[CommissioningTask::" << __func__ << "]"
361  << " NULL pointer to MonitorElement!";
362  return;
363  }
364 
365  if (!histo_set.explicitFill_) {
366 
367  if ( histo_set.isProfile_ ) {
368 
369  TProfile* prof = ExtractTObject<TProfile>().extract( histo_set.histo() );
370  // if ( prof ) { prof->SetErrorOption("s"); } //@@ necessary?
371  const static UpdateTProfile profile;
372  for ( uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++ ) {
373  profile.setBinContents( prof,
374  ibin+1,
375  histo_set.vNumOfEntries_[ibin],
376  histo_set.vSumOfContents_[ibin],
377  histo_set.vSumOfSquares_[ibin] );
378  }
379 
380  } else {
381 
382  for ( uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++ ) {
383  histo_set.histo()->setBinContent( ibin+1, histo_set.vNumOfEntries_[ibin] );
384  }
385 
386  }
387 
388  }
389 
390 }
391 
392 // -----------------------------------------------------------------------------
393 //
395 
396  // Check if histo exists
397  if ( !histo_set.histo() ) {
399  << "[CommissioningTask::" << __func__ << "]"
400  << " NULL pointer to MonitorElement!";
401  return;
402  }
403 
404  if (!histo_set.explicitFill_) {
405  for ( uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++ ) {
406  histo_set.histo()->setBinContent( ibin+1, histo_set.vNumOfEntries_[ibin] );
407  }
408  }
409 
410 }
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_[]
static const char fedKey_[]
std::vector< float > vSumOfContents_
Definition: weight.py:1
uint16_t lldChannel() const
#define nullptr
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 sistrip::RunType & runType() const
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 > &)