CMS 3D CMS Logo

CalibrationSummaryFactory.cc
Go to the documentation of this file.
5 #include <iostream>
6 #include <sstream>
7 
8 using namespace sistrip;
9 
10 // -----------------------------------------------------------------------------
11 //
13 
14  CalibrationAnalysis* anal = dynamic_cast<CalibrationAnalysis*>( iter->second );
15  if ( !anal ) { return; }
16 
17  std::vector<float> temp(128, 1. * sistrip::invalid_ );
18  std::vector< std::vector<float> > value( 2, temp );
19  std::vector< std::vector<float> > error( 2, temp );
20  std::vector< std::vector<float> > amplitude( 2, temp );
21  std::vector< std::vector<float> > tail( 2, temp );
22  std::vector< std::vector<float> > riseTime( 2, temp );
23  std::vector< std::vector<float> > timeConstant( 2, temp );
24  std::vector< std::vector<float> > turnOn( 2, temp );
25  std::vector< std::vector<float> > maximum( 2, temp );
26  std::vector< std::vector<float> > undershoot( 2, temp );
27  std::vector< std::vector<float> > baseline( 2, temp );
28  std::vector< std::vector<float> > smearing( 2, temp );
29  std::vector< std::vector<float> > chi2( 2, temp );
30  amplitude[0] = anal->amplitude()[0];
31  amplitude[1] = anal->amplitude()[1];
32  tail[0] = anal->tail()[0];
33  tail[1] = anal->tail()[1];
34  riseTime[0] = anal->riseTime()[0];
35  riseTime[1] = anal->riseTime()[1];
36  timeConstant[0] = anal->timeConstant()[0];
37  timeConstant[1] = anal->timeConstant()[1];
38  turnOn[0] = anal->turnOn()[0];
39  turnOn[1] = anal->turnOn()[1];
40  maximum[0] = anal->maximum()[0];
41  maximum[1] = anal->maximum()[1];
42  undershoot[0] = anal->undershoot()[0];
43  undershoot[1] = anal->undershoot()[1];
44  baseline[0] = anal->baseline()[0];
45  baseline[1] = anal->baseline()[1];
46  smearing[0] = anal->smearing()[0];
47  smearing[1] = anal->smearing()[1];
48  chi2[0] = anal->chi2()[0];
49  chi2[1] = anal->chi2()[1];
50 
51  SiStripFecKey lldKey = SiStripFecKey(iter->first);
52  uint32_t key1 = SiStripFecKey(lldKey.fecCrate(),
53  lldKey.fecSlot(),
54  lldKey.fecRing(),
55  lldKey.ccuAddr(),
56  lldKey.ccuChan(),
57  lldKey.lldChan(),
58  lldKey.i2cAddr(lldKey.lldChan(),true)).key();
59  uint32_t key2 = SiStripFecKey(lldKey.fecCrate(),
60  lldKey.fecSlot(),
61  lldKey.fecRing(),
62  lldKey.ccuAddr(),
63  lldKey.ccuChan(),
64  lldKey.lldChan(),
65  lldKey.i2cAddr(lldKey.lldChan(),false)).key();
66 
67  bool all_strips = false;
68  bool with_error = false;
69 
70  // Amplitude
72  all_strips = true;
73  uint16_t bins = amplitude[amplitude[0].size() < amplitude[1].size() ? 1 : 0].size();
74  for ( uint16_t i = 0; i < bins; i++ ) {
75  value[0][i] = amplitude[0][i]/10.;
76  value[1][i] = amplitude[1][i]/10.;
77  }
78  } else if ( mon_ == sistrip::CALIBRATION_AMPLITUDE) {
79  with_error = true;
80  value[0][0] = anal->amplitudeMean()[0]/10.;
81  value[1][0] = anal->amplitudeMean()[1]/10.;
82  error[0][0] = anal->amplitudeSpread()[0]/10.;
83  error[1][0] = anal->amplitudeSpread()[1]/10.;
84  } else if ( mon_ == sistrip::CALIBRATION_AMPLITUDE_MIN) {
85  value[0][0] = anal->amplitudeMin()[0]/10.;
86  value[1][0] = anal->amplitudeMin()[1]/10.;
87  } else if ( mon_ == sistrip::CALIBRATION_AMPLITUDE_MAX) {
88  value[0][0] = anal->amplitudeMax()[0]/10.;
89  value[1][0] = anal->amplitudeMax()[1]/10.;
90  }
91  // Tail parameter
92  else if ( mon_ == sistrip::CALIBRATION_TAIL_ALLSTRIPS) {
93  all_strips = true;
94  uint16_t bins = tail[tail[0].size() < tail[1].size() ? 1 : 0].size();
95  for ( uint16_t i = 0; i < bins; i++ ) {
96  value[0][i] = tail[0][i];
97  value[1][i] = tail[1][i];
98  }
99  } else if ( mon_ == sistrip::CALIBRATION_TAIL) {
100  with_error = true;
101  value[0][0] = anal->tailMean()[0];
102  value[1][0] = anal->tailMean()[1];
103  error[0][0] = anal->tailSpread()[0];
104  error[1][0] = anal->tailSpread()[1];
105  } else if ( mon_ == sistrip::CALIBRATION_TAIL_MIN) {
106  value[0][0] = anal->tailMin()[0];
107  value[1][0] = anal->tailMin()[1];
108  } else if ( mon_ == sistrip::CALIBRATION_TAIL_MAX) {
109  value[0][0] = anal->tailMax()[0];
110  value[1][0] = anal->tailMax()[1];
111  }
112  // Risetime parameter
113  else if ( mon_ == sistrip::CALIBRATION_RISETIME_ALLSTRIPS) {
114  all_strips = true;
115  uint16_t bins = riseTime[riseTime[0].size() < riseTime[1].size() ? 1 : 0].size();
116  for ( uint16_t i = 0; i < bins; i++ ) {
117  value[0][i] = riseTime[0][i];
118  value[1][i] = riseTime[1][i];
119  }
120  } else if ( mon_ == sistrip::CALIBRATION_RISETIME) {
121  with_error = true;
122  value[0][0] = anal->riseTimeMean()[0];
123  value[1][0] = anal->riseTimeMean()[1];
124  error[0][0] = anal->riseTimeSpread()[0];
125  error[1][0] = anal->riseTimeSpread()[1];
126  } else if ( mon_ == sistrip::CALIBRATION_RISETIME_MIN) {
127  value[0][0] = anal->riseTimeMin()[0];
128  value[1][0] = anal->riseTimeMin()[1];
129  } else if ( mon_ == sistrip::CALIBRATION_RISETIME_MAX) {
130  value[0][0] = anal->riseTimeMax()[0];
131  value[1][0] = anal->riseTimeMax()[1];
132  }
133  // TimeConstant
135  all_strips = true;
136  uint16_t bins = timeConstant[timeConstant[0].size() < timeConstant[1].size() ? 1 : 0].size();
137  for ( uint16_t i = 0; i < bins; i++ ) {
138  value[0][i] = timeConstant[0][i];
139  value[1][i] = timeConstant[1][i];
140  }
141  } else if ( mon_ == sistrip::CALIBRATION_TIMECONSTANT) {
142  with_error = true;
143  value[0][0] = anal->timeConstantMean()[0];
144  value[1][0] = anal->timeConstantMean()[1];
145  error[0][0] = anal->timeConstantSpread()[0];
146  error[1][0] = anal->timeConstantSpread()[1];
147  } else if ( mon_ == sistrip::CALIBRATION_TIMECONSTANT_MIN) {
148  value[0][0] = anal->timeConstantMin()[0];
149  value[1][0] = anal->timeConstantMin()[1];
150  } else if ( mon_ == sistrip::CALIBRATION_TIMECONSTANT_MAX) {
151  value[0][0] = anal->timeConstantMax()[0];
152  value[1][0] = anal->timeConstantMax()[1];
153  }
154  // Turn-on
155  else if ( mon_ == sistrip::CALIBRATION_TURNON_ALLSTRIPS) {
156  all_strips = true;
157  uint16_t bins = turnOn[turnOn[0].size() < turnOn[1].size() ? 1 : 0].size();
158  for ( uint16_t i = 0; i < bins; i++ ) {
159  value[0][i] = turnOn[0][i];
160  value[1][i] = turnOn[1][i];
161  }
162  } else if ( mon_ == sistrip::CALIBRATION_TURNON) {
163  with_error = true;
164  value[0][0] = anal->turnOnMean()[0];
165  value[1][0] = anal->turnOnMean()[1];
166  error[0][0] = anal->turnOnSpread()[0];
167  error[1][0] = anal->turnOnSpread()[1];
168  } else if ( mon_ == sistrip::CALIBRATION_TURNON_MIN) {
169  value[0][0] = anal->turnOnMin()[0];
170  value[1][0] = anal->turnOnMin()[1];
171  } else if ( mon_ == sistrip::CALIBRATION_TURNON_MAX) {
172  value[0][0] = anal->turnOnMax()[0];
173  value[1][0] = anal->turnOnMax()[1];
174 
175  }
176  // Maximum
177  else if ( mon_ == sistrip::CALIBRATION_MAXIMUM_ALLSTRIPS) {
178  all_strips = true;
179  uint16_t bins = maximum[maximum[0].size() < maximum[1].size() ? 1 : 0].size();
180  for ( uint16_t i = 0; i < bins; i++ ) {
181  value[0][i] = maximum[0][i];
182  value[1][i] = maximum[1][i];
183  }
184  } else if ( mon_ == sistrip::CALIBRATION_MAXIMUM) {
185  with_error = true;
186  value[0][0] = anal->maximumMean()[0];
187  value[1][0] = anal->maximumMean()[1];
188  error[0][0] = anal->maximumSpread()[0];
189  error[1][0] = anal->maximumSpread()[1];
190  } else if ( mon_ == sistrip::CALIBRATION_MAXIMUM_MIN) {
191  value[0][0] = anal->maximumMin()[0];
192  value[1][0] = anal->maximumMin()[1];
193  } else if ( mon_ == sistrip::CALIBRATION_MAXIMUM_MAX) {
194  value[0][0] = anal->maximumMax()[0];
195  value[1][0] = anal->maximumMax()[1];
196 
197  }
198  // Undershoot
199  else if ( mon_ == sistrip::CALIBRATION_UNDERSHOOT_ALLSTRIPS) {
200  all_strips = true;
201  uint16_t bins = undershoot[undershoot[0].size() < undershoot[1].size() ? 1 : 0].size();
202  for ( uint16_t i = 0; i < bins; i++ ) {
203  value[0][i] = undershoot[0][i];
204  value[1][i] = undershoot[1][i];
205  }
206  } else if ( mon_ == sistrip::CALIBRATION_UNDERSHOOT) {
207  with_error = true;
208  value[0][0] = anal->undershootMean()[0];
209  value[1][0] = anal->undershootMean()[1];
210  error[0][0] = anal->undershootSpread()[0];
211  error[1][0] = anal->undershootSpread()[1];
212  } else if ( mon_ == sistrip::CALIBRATION_UNDERSHOOT_MIN) {
213  value[0][0] = anal->undershootMin()[0];
214  value[1][0] = anal->undershootMin()[1];
215  } else if ( mon_ == sistrip::CALIBRATION_UNDERSHOOT_MAX) {
216  value[0][0] = anal->undershootMax()[0];
217  value[1][0] = anal->undershootMax()[1];
218 
219  }
220  // Baseline
221  else if ( mon_ == sistrip::CALIBRATION_BASELINE_ALLSTRIPS) {
222  all_strips = true;
223  uint16_t bins = baseline[baseline[0].size() < baseline[1].size() ? 1 : 0].size();
224  for ( uint16_t i = 0; i < bins; i++ ) {
225  value[0][i] = baseline[0][i];
226  value[1][i] = baseline[1][i];
227  }
228  } else if ( mon_ == sistrip::CALIBRATION_BASELINE) {
229  with_error = true;
230  value[0][0] = anal->baselineMean()[0];
231  value[1][0] = anal->baselineMean()[1];
232  error[0][0] = anal->baselineSpread()[0];
233  error[1][0] = anal->baselineSpread()[1];
234  } else if ( mon_ == sistrip::CALIBRATION_BASELINE_MIN) {
235  value[0][0] = anal->baselineMin()[0];
236  value[1][0] = anal->baselineMin()[1];
237  } else if ( mon_ == sistrip::CALIBRATION_BASELINE_MAX) {
238  value[0][0] = anal->baselineMax()[0];
239  value[1][0] = anal->baselineMax()[1];
240  }
241 
242  // Smearing
243  else if ( mon_ == sistrip::CALIBRATION_SMEARING_ALLSTRIPS) {
244  all_strips = true;
245  uint16_t bins = smearing[smearing[0].size() < smearing[1].size() ? 1 : 0].size();
246  for ( uint16_t i = 0; i < bins; i++ ) {
247  value[0][i] = smearing[0][i];
248  value[1][i] = smearing[1][i];
249  }
250  }
251  else if ( mon_ == sistrip::CALIBRATION_SMEARING) {
252  with_error = true;
253  value[0][0] = anal->smearingMean()[0];
254  value[1][0] = anal->smearingMean()[1];
255  error[0][0] = anal->smearingSpread()[0];
256  error[1][0] = anal->smearingSpread()[1];
257  } else if ( mon_ == sistrip::CALIBRATION_SMEARING_MIN) {
258  value[0][0] = anal->smearingMin()[0];
259  value[1][0] = anal->smearingMin()[1];
260  } else if ( mon_ == sistrip::CALIBRATION_SMEARING_MAX) {
261  value[0][0] = anal->smearingMax()[0];
262  value[1][0] = anal->smearingMax()[1];
263  }
264  // Fit chi2
265  else if ( mon_ == sistrip::CALIBRATION_CHI2_ALLSTRIPS) {
266  all_strips = true;
267  uint16_t bins = chi2[chi2[0].size() < chi2[1].size() ? 1 : 0].size();
268  for ( uint16_t i = 0; i < bins; i++ ) {
269  value[0][i] = chi2[0][i];
270  value[1][i] = chi2[1][i];
271  }
272  }
273  else if ( mon_ == sistrip::CALIBRATION_CHI2) {
274  with_error = true;
275  value[0][0] = anal->chi2Mean()[0]/100.;
276  value[1][0] = anal->chi2Mean()[1]/100.;
277  error[0][0] = anal->chi2Spread()[0]/100.;
278  error[1][0] = anal->chi2Spread()[1]/100.;
279  } else if ( mon_ == sistrip::CALIBRATION_CHI2_MIN) {
280  value[0][0] = anal->chi2Min()[0]/100.;
281  value[1][0] = anal->chi2Min()[1]/100.;
282  } else if ( mon_ == sistrip::CALIBRATION_CHI2_MAX) {
283  value[0][0] = anal->chi2Max()[0]/100.;
284  value[1][0] = anal->chi2Max()[1]/100.;
285  } else {
287  << "[SummaryPlotFactory::" << __func__ << "]"
288  << " Unexpected monitorable: "
290  return;
291  }
292 
293  if ( !all_strips ) {
294  if( !with_error) {
297  key1,
298  value[0][0] );
299 
302  key2,
303  value[1][0] );
304  } else {
307  key1,
308  value[0][0],
309  error[0][0]);
310 
313  key2,
314  value[1][0],
315  error[1][0]);
316  }
317  } else {
318 
319  for ( uint16_t istr = 0; istr < value[0].size(); istr++ ) {
322  key1,
323  value[0][istr] );
324  }
325 
326  for ( uint16_t istr = 0; istr < value[1].size(); istr++ ) {
329  key2,
330  value[1][istr] );
331  }
332  }
333 }
334 
335 //------------------------------------------------------------------------------
336 //
338 
339  // Histogram formatting
340  // Histogram formatting
341  if ( mon_ == sistrip::CALIBRATION_AMPLITUDE ) {
342  generator_->axisLabel( "Amplitude (ADC*Nevt/10.)" );
343  } else if ( mon_ == sistrip::CALIBRATION_TAIL ) {
344  generator_->axisLabel( "Tail (%)" );
345  } else if ( mon_ == sistrip::CALIBRATION_RISETIME ) {
346  generator_->axisLabel( "Rise time (ns)" );
347  } else if ( mon_ == sistrip::CALIBRATION_TIMECONSTANT ) {
348  generator_->axisLabel( "Time constant (ns)" );
349  } else if ( mon_ == sistrip::CALIBRATION_TURNON ) {
350  generator_->axisLabel( "TrunOn (ns)" );
351  } else if ( mon_ == sistrip::CALIBRATION_MAXIMUM ) {
352  generator_->axisLabel( "Maximum time (ns)" );
353  } else if ( mon_ == sistrip::CALIBRATION_UNDERSHOOT ) {
354  generator_->axisLabel( "Undershoot (ADC*Nevt/10.)" );
355  } else if ( mon_ == sistrip::CALIBRATION_BASELINE ) {
356  generator_->axisLabel( "Baseline Amplitude (ADC*Nevt/10.)" );
357  } else if ( mon_ == sistrip::CALIBRATION_SMEARING ) {
358  generator_->axisLabel( "Smearing (ns)" );
359  } else if ( mon_ == sistrip::CALIBRATION_CHI2 ) {
360  generator_->axisLabel( "Chi2/100." );
361  } else {
363  << "[SummaryPlotFactory::" << __func__ << "]"
364  << " Unexpected SummaryHisto value:"
366  }
367 }
368 
const VFloat & maximumMean() const
static std::string monitorable(const sistrip::Monitorable &)
const VFloat & smearingMean() const
const VFloat & turnOnMin() const
const VFloat & undershootMax() const
const VFloat & riseTimeSpread() const
const VVFloat & riseTime() const
sistrip::Monitorable mon_
const uint16_t & fecRing() const
const VFloat & amplitudeMean() const
const VFloat & amplitudeMin() const
const VVFloat & amplitude() const
const VFloat & timeConstantMean() const
const VFloat & chi2Spread() const
const VFloat & smearingSpread() const
const VFloat & baselineMean() const
const VFloat & riseTimeMean() const
const VVFloat & smearing() const
const uint16_t & lldChan() const
const VFloat & maximumMax() const
const uint16_t & fecSlot() const
const VVFloat & timeConstant() const
const uint16_t & i2cAddr() const
sistrip classes
const uint32_t & key() const
Definition: SiStripKey.h:125
const VFloat & chi2Min() const
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
const VFloat & chi2Max() const
const VVFloat & baseline() const
void fillMap(const std::string &top_level_dir, const sistrip::Granularity &, const uint32_t &key, const float &value, const float &error=0.)
const VFloat & tailMax() const
const VFloat & riseTimeMin() const
Analysis for calibration runs.
const VFloat & baselineMin() const
const VVFloat & tail() const
const VVFloat & undershoot() const
const VFloat & maximumMin() const
const VFloat & amplitudeMax() const
const VFloat & timeConstantSpread() const
const VFloat & turnOnMean() const
sistrip::Granularity gran_
const VFloat & baselineMax() const
const VFloat & chi2Mean() const
const uint16_t & fecCrate() const
const VFloat & baselineSpread() const
static const char mlSummaryPlots_[]
const VVFloat & maximum() const
const VFloat & riseTimeMax() const
const VFloat & undershootMin() const
SummaryGenerator * generator_
const uint16_t & ccuAddr() const
static const uint16_t invalid_
Definition: Constants.h:16
const VFloat & timeConstantMin() const
const VFloat & maximumSpread() const
const VFloat & turnOnSpread() const
const VFloat & smearingMin() const
const VFloat & timeConstantMax() const
const VVFloat & turnOn() const
const VVFloat & chi2() const
const VFloat & turnOnMax() const
const uint16_t & ccuChan() const
const VFloat & tailMean() const
const VFloat & smearingMax() const
const VFloat & tailSpread() const
const VFloat & amplitudeSpread() const
const VFloat & tailMin() const
const VFloat & undershootSpread() const
const VFloat & undershootMean() const