CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  : 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 }
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
#define LogTrace(id)
const uint16_t range(const Frame &aFrame)
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
tuple key
prepare the HTCondor submission files and eventually submit them
static const char fecKey_[]
virtual void fill(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)
const uint16_t & ccuAddr() const
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
tuple conn
Definition: getInfo.py:9
std::vector< double > vSumOfSquares_
Log< level::Warning, false > LogWarning
int weight
Definition: histoStyle.py:51
FedChannelConnection connection_
void fillHistograms(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &)