test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_(0)
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_(0),
93  axis_(0)
94 {;}
95 
96 // -----------------------------------------------------------------------------
97 //
99  vNumOfEntries_(),
100  explicitFill_(false),
101  histo_(0)
102 {;}
103 
104 // -----------------------------------------------------------------------------
105 //
107 
108 // -----------------------------------------------------------------------------
109 //
111 
112 // -----------------------------------------------------------------------------
113 //
115  histo_ = me;
116  TH1* histo = ExtractTObject<TH1>().extract( histo_ );
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 uint16_t& fed_id,
163  const std::map<uint16_t,float>& fed_ch ) {
165  << "[CommissioningTask::" << __func__ << "]"
166  << " No derived implementation exists!";
167 }
168 
169 // -----------------------------------------------------------------------------
170 //
173  << "[CommissioningTask::" << __func__ << "]"
174  << " No derived implementation exists!";
175 }
176 
177 // -----------------------------------------------------------------------------
178 //
180  book();
181  booked_ = true;
182 }
183 
184 // -----------------------------------------------------------------------------
185 //
187  const edm::DetSet<SiStripRawDigi>& digis ) {
188  if ( !booked_ ) {
190  << "[CommissioningTask::" << __func__ << "]"
191  << " Attempting to fill histos that haven't been booked yet!";
192  return;
193  }
194  fillCntr_++;
195  fill( summary, digis );
196  if ( updateFreq_ && !(fillCntr_%updateFreq_) ) {
197  update();
198  }
199 
200 }
201 
202 // -----------------------------------------------------------------------------
203 //
205  const uint16_t& fed_id,
206  const std::map<uint16_t,float>& fed_ch ) {
207  if ( !booked_ ) {
209  << "[CommissioningTask::" << __func__ << "]"
210  << " Attempting to fill histos that haven't been booked yet!";
211  return;
212  }
213  fillCntr_++;
214  fill( summary, fed_id, fed_ch );
215  if ( updateFreq_ && !(fillCntr_%updateFreq_) ) {
216  update();
217  }
218 
219 }
220 
221 // -----------------------------------------------------------------------------
222 //
224  update();
225 }
226 
227 // -----------------------------------------------------------------------------
228 //
230  const uint32_t& bin ) {
231  float value = 1.;
232  updateHistoSet( histo_set, bin, value );
233 }
234 
235 // -----------------------------------------------------------------------------
236 //
238  const uint32_t& bin ) {
239  short value = 1;
240  updateHistoSet( histo_set, bin, value );
241 }
242 
243 // -----------------------------------------------------------------------------
244 //
246  const float& value ) {
247  float weight = 1.;
248  updateHistoSet( histo_set, histo_set.bin(value), weight );
249 }
250 
251 // -----------------------------------------------------------------------------
252 //
254  const uint32_t& bin,
255  const float& value ) {
256 
257  // Check bin number
258  if ( bin >= histo_set.vNumOfEntries_.size() && !histo_set.explicitFill_ ) {
260  << "[CommissioningTask::" << __func__ << "]"
261  << " Unexpected bin number " << bin
262  << " when filling histogram of size " << histo_set.vNumOfEntries_.size();
263  return;
264  }
265 
266  // Check if histo is TProfile or not
267  if ( !histo_set.isProfile_ ) {
268  // Set entries
269  if (histo_set.explicitFill_) {
270  float origVal = histo_set.histo()->getBinContent( bin+1 );
271  histo_set.histo()->setBinContent( bin+1, origVal + value );
272  } else {
273  histo_set.vNumOfEntries_[bin]+=value;
274  }
275  } else {
276  // Set entries
277  histo_set.vNumOfEntries_[bin]++;
278 
279  // Check bin number
280  if ( bin >= histo_set.vSumOfContents_.size() ||
281  bin >= histo_set.vSumOfSquares_.size() ) {
283  << "[CommissioningTask::" << __func__ << "]"
284  << " Unexpected bin when filling histogram: " << bin;
285  return;
286  }
287 
288  // Set sum of contents and squares
289  histo_set.vSumOfContents_[bin] += value;
290  histo_set.vSumOfSquares_[bin] += value*value;
291  }
292 
293 }
294 
295 // -----------------------------------------------------------------------------
296 //
298  const uint32_t& bin,
299  const short& value ) {
300 
301  // Check bin number
302  if ( bin >= histo_set.vNumOfEntries_.size() && !histo_set.explicitFill_ ) {
304  << "[CommissioningTask::" << __func__ << "]"
305  << " Unexpected bin number " << bin
306  << " when filling histogram of size " << histo_set.vNumOfEntries_.size();
307  return;
308  }
309 
310  if (histo_set.explicitFill_) {
311  float origVal = histo_set.histo()->getBinContent( bin+1 );
312  histo_set.histo()->setBinContent( bin+1, origVal + value );
313  } else {
314  // Set entries
315  histo_set.vNumOfEntries_[bin] += value;
316  }
317 
318 }
319 
320 // -----------------------------------------------------------------------------
321 //
323 
324  // Check if histo exists
325  if ( !histo_set.histo() ) {
327  << "[CommissioningTask::" << __func__ << "]"
328  << " NULL pointer to MonitorElement!";
329  return;
330  }
331 
332  if (!histo_set.explicitFill_) {
333 
334  if ( histo_set.isProfile_ ) {
335 
336  TProfile* prof = ExtractTObject<TProfile>().extract( histo_set.histo() );
337  // if ( prof ) { prof->SetErrorOption("s"); } //@@ necessary?
338  const static UpdateTProfile profile;
339  for ( uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++ ) {
340  profile.setBinContents( prof,
341  ibin+1,
342  histo_set.vNumOfEntries_[ibin],
343  histo_set.vSumOfContents_[ibin],
344  histo_set.vSumOfSquares_[ibin] );
345  }
346 
347  } else {
348 
349  for ( uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++ ) {
350  histo_set.histo()->setBinContent( ibin+1, histo_set.vNumOfEntries_[ibin] );
351  }
352 
353  }
354 
355  }
356 
357 }
358 
359 // -----------------------------------------------------------------------------
360 //
362 
363  // Check if histo exists
364  if ( !histo_set.histo() ) {
366  << "[CommissioningTask::" << __func__ << "]"
367  << " NULL pointer to MonitorElement!";
368  return;
369  }
370 
371  if (!histo_set.explicitFill_) {
372  for ( uint32_t ibin = 0; ibin < histo_set.vNumOfEntries_.size(); ibin++ ) {
373  histo_set.histo()->setBinContent( ibin+1, histo_set.vNumOfEntries_[ibin] );
374  }
375  }
376 
377 }
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_
uint16_t lldChannel() const
const uint16_t & fedId() const
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_[]
virtual void fill(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
const uint16_t & ccuAddr() const
#define LogTrace(id)
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_
volatile std::atomic< bool > shutdown_flag false
int weight
Definition: histoStyle.py:50
FedChannelConnection connection_
void fillHistograms(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)