ATLAS Offline Software
CscCalibTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "CscCalibTool.h"
6 #include "StoreGate/DataHandle.h"
7 
8 #include <sstream>
9 #include <cmath>
10 
12 ( const std::string& t, const std::string& n, const IInterface* p )
13  : base_class(t,n,p)
14 {
15  declareProperty( "Slope", m_slope = 0.19 );
16  declareProperty( "Noise", m_noise = 3.5 );
17  declareProperty( "Pedestal", m_pedestal = 2048.0 );
18  declareProperty( "ReadFromDatabase", m_readFromDatabase = true);
19  declareProperty( "integrationNumber", m_integrationNumber = 12.0);
20  declareProperty( "integrationNumber2", m_integrationNumber2 = 11.66);
21  declareProperty( "samplingTime", m_samplingTime = 50. ); //ns
22  declareProperty( "signalWidth", m_signalWidth = 14.40922); // 50/3.47ns
23  declareProperty( "SlopeFromDatabase", m_slopeFromDatabase=false);
24  declareProperty( "timeOffset", m_timeOffset = 46.825 );
25 
26  declareProperty( "IsOnline" , m_onlineHLT = true); // This will be fed from jO
27 
28  // new latency starting from 2010...
29  declareProperty( "Latency", m_latency = 100 ); // ns.....
30  declareProperty( "NSamples", m_nSamples = 4); // number of samples
31 
32  declareProperty( "Use2Samples", m_use2Samples = false); // force 2 sample
33 }
34 
35 // ROOT USER Function
36 Double_t bipfunc(const Double_t *x, const Double_t *par){
37  if (x[0] < par[1]) return 0.;
38  Double_t integrationNumber = par[2]; //12
39  Double_t integrationNumber2 = par[3]; //11.66
40  // Double_t samplingTime = par[4]; //50 ns
41  Double_t signalWidth = par[4]; //50 ns
42  Double_t sum = integrationNumber+integrationNumber2;
43  Double_t z0 = 0.5*( (sum+2)
44  -std::sqrt(std::pow(sum+2,2)
45  -4*integrationNumber*(integrationNumber2+1))
46  );
47 
48  Double_t norm = (1.0 - z0 / (1 + integrationNumber2))
49  * std::pow(z0, 1.0 * integrationNumber)
50  * std::exp(-z0);
51 
52  Double_t z = (x[0]-par[1])/signalWidth;//*3.47/samplingTime;
53  Double_t amplitude =
54  par[0]*(1-z/(1+integrationNumber2))
55  *std::pow(z,integrationNumber)*std::exp(-1.0*z)/norm;
56  return amplitude;
57 }
58 // To add two bipolar function and get a distribution, this function is defined
59 Double_t dualbipfunc(const Double_t *x, const Double_t *par){
60  return ( bipfunc(x,par) + bipfunc(x,&par[5]) );
61 }
62 
64 
65  ATH_MSG_DEBUG ( "Initializing Initializing CscCalibTool");
66 
67  ATH_MSG_DEBUG ( "Default slope (if DB is not available) =" << m_slope );
68  ATH_MSG_DEBUG ( "Default noise (if DB is not available) =" << m_noise );
69  ATH_MSG_DEBUG ( "Default pedestal (if DB is not available) =" << m_pedestal );
70  ATH_MSG_DEBUG ( "Calib Constants are from DB ? =" << m_readFromDatabase );
71  ATH_MSG_DEBUG ( "Slope Constants are from DB ? =" << m_slopeFromDatabase );
72  ATH_MSG_DEBUG ( "Bipolar function integrationNumber(N_1) =" << m_integrationNumber);
73  ATH_MSG_DEBUG ( "Bipolar function integrationNumber(N_2) =" << m_integrationNumber2);
74  ATH_MSG_DEBUG ( "SamplingTime =" << m_samplingTime);
75  ATH_MSG_DEBUG ( "Signalwidth =" << m_signalWidth);
76  ATH_MSG_DEBUG ( "timeOffset (digitization) =" << m_timeOffset);
77  ATH_MSG_DEBUG ( "Is OnlineAccess (HLT) ?? =" << m_onlineHLT);
78  ATH_MSG_DEBUG ( "Force the use of the 2 sample charge? =" << m_use2Samples);
79 
80  if (m_onlineHLT) {
81  ATH_MSG_DEBUG( "T0BaseFolder and T0PhaseFolder are not loaded!!! HLT COOLDB does not have it!!");
82  }
83 
85 
88 
89  return StatusCode::SUCCESS;
90 }
91 
92 float CscCalibTool::getPSlope(uint32_t stripHashId) const {
93 
94 
95  float slope = m_slope;
98  const CscCondDbData* readCdo{*readHandle};
99  if(!readCdo->readChannelPSlope(stripHashId, slope).isSuccess()){
100  ATH_MSG_WARNING ( " failed to access CSC conditions database - slope - "
101  << "strip hash id = " << stripHashId );
102  }
103  }
104  ATH_MSG_DEBUG ( "The slope is " << slope << " for strip hash = " << stripHashId );
105 
106  return slope;
107 
108 }
109 
110 
112 int CscCalibTool::numberOfElectronsToADCCount(uint32_t stripHashId, const int numberOfElecEquiv) const
113 {
114 
115  //ATH_MSG_VERBOSE ( "Using CscCalibTool::numberOfElectronsToADCCount" );
116 
117  double conversionFactor = 1.602e-4; // 1 ee in femtoCoulomb
118  double femtoCoulombs = conversionFactor*numberOfElecEquiv;
119 
120  float slope = getPSlope(stripHashId);
121 
122  int adcValue = int ( func(femtoCoulombs,slope) );
123  return adcValue;
124 }
125 
126 int CscCalibTool::femtoCoulombToADCCount(uint32_t stripHashId, const double femtoCoulombs) const
127 {
128 
129  //ATH_MSG_VERBOSE ( "Using CscCalibTool::femtoCoulombToADCCount" );
130 
131  float slope = getPSlope(stripHashId);
132 
133  int adcValue = int ( func(femtoCoulombs,slope) );
134  return adcValue;
135 }
136 
138 double CscCalibTool::adcCountToNumberOfElectrons(const float adcValue, const float slope) const
139 {
140  double conversionFactor = 1.602e-4; // 1 ee in femtoCoulomb
141  double femtoCoulombs = this->adcCountToFemtoCoulomb(adcValue, slope);
142  return (femtoCoulombs/conversionFactor);
143 }
144 
146 double CscCalibTool::stripNoise ( uint32_t stripHashId, const bool convert ) const
147 {
148  ATH_MSG_VERBOSE ( "The strip hash id is " << stripHashId );
149 
150  float noise = m_noise;
151  if ( m_readFromDatabase ) {
153  const CscCondDbData* readCdo{*readHandle};
154  if(!readCdo->readChannelNoise(stripHashId, noise).isSuccess()){
155  ATH_MSG_DEBUG ( " failed to access CSC conditions database - noise - "
156  << "strip hash id = " << stripHashId );
157  noise = m_noise;
158  }
159  }
160 
161  ATH_MSG_VERBOSE ( "The noise is " << noise << " for strip hash = " << stripHashId );
162 
163  if ( convert ) {
164  float slope = getPSlope(stripHashId);
165  return this->adcCountToNumberOfElectrons( noise, slope );
166  } else {
167  return noise;
168  }
169 }
170 
171 
173 double CscCalibTool::stripRMS ( uint32_t stripHashId, const bool convert ) const
174 {
175  ATH_MSG_VERBOSE ( "The strip hash id is " << stripHashId );
176 
177  float rms = m_noise;
178  if ( m_readFromDatabase ) {
180  const CscCondDbData* readCdo{*readHandle};
181  if(!readCdo->readChannelRMS(stripHashId, rms).isSuccess()){
182  ATH_MSG_DEBUG ( " failed to access CSC conditions database - rms - "
183  << "strip hash id = " << stripHashId );
184  rms = m_noise;
185  }
186  }
187 
188  ATH_MSG_VERBOSE ( "The RMS is " << rms << " for strip hash = " << stripHashId );
189 
190  if ( convert ) {
191  float slope = getPSlope(stripHashId);
192  return this->adcCountToNumberOfElectrons( rms, slope );
193  } else {
194  return rms;
195  }
196 
197 }
198 
200 // NOTE: f001 is raw ADC count...+1
201 double CscCalibTool::stripF001 ( uint32_t stripHashId, const bool convert ) const
202 {
203  ATH_MSG_VERBOSE ( "The strip hash id is " << stripHashId );
204 
205  float f001 = m_noise+m_pedestal;
206  if ( m_readFromDatabase ) {
208  const CscCondDbData* readCdo{*readHandle};
209  if(!readCdo->readChannelF001(stripHashId, f001).isSuccess()){
210  ATH_MSG_DEBUG ( " failed to access CSC conditions database - f001 - "
211  << "strip hash id = " << stripHashId );
212  f001 = 3.251*m_noise+m_pedestal;
213  }
214  }
215 
216  ATH_MSG_VERBOSE ( "The F001 is " << f001 << " for strip hash = " << stripHashId );
217 
218  if ( convert ) {
219  float slope = getPSlope(stripHashId);
220  return this->adcCountToNumberOfElectrons( f001, slope );
221  } else {
222  return f001;
223  }
224 }
225 
227 double CscCalibTool::stripPedestal ( uint32_t stripHashId, const bool convert ) const
228 {
229  ATH_MSG_VERBOSE ( "The strip hash id is " << stripHashId );
230 
231  float pedestal = m_pedestal;
232  if ( m_readFromDatabase ) {
234  const CscCondDbData* readCdo{*readHandle};
235  if(!readCdo->readChannelPed(stripHashId, pedestal).isSuccess()){
236  ATH_MSG_DEBUG ( " failed to access CSC conditions database - pedestal - "
237  << "strip hash id = " << stripHashId );
238  pedestal = m_pedestal;
239  }
240  }
241  ATH_MSG_VERBOSE ( "The pedestal is " << pedestal << " for strip hash = " << stripHashId );
242 
243  if ( convert ) {
244  float slope = getPSlope(stripHashId);
245  return this->adcCountToNumberOfElectrons( pedestal, slope );
246  } else {
247  return pedestal;
248  }
249 }
250 
254 bool CscCalibTool::isGood ( uint32_t stripHashId ) const
255 {
256 
257  ATH_MSG_VERBOSE ( "The strip hash id is " << stripHashId );
258 
259  unsigned int status = stripStatusBit(stripHashId);
260  bool is_good = !( (status & 0x1) || ((status >> 1) & 0x1) ); // test for hot/dead channel
261  return is_good;
262 }
263 
264 
265 int CscCalibTool::stripStatusBit ( uint32_t stripHashId ) const {
266 
267  int status = 0;
268  if ( m_readFromDatabase ) {
270  const CscCondDbData* readCdo{*readHandle};
271  if(!readCdo->readChannelStatus(stripHashId, status).isSuccess())
272  ATH_MSG_WARNING ( " failed to access CSC conditions database - status - "
273  << "strip hash id = " << stripHashId );
274  else
275  ATH_MSG_VERBOSE("The status word is " << std::hex << status <<
276  " for strip hash = " << std::dec << stripHashId);
277  }
278  return status;
279 }
280 
281 
282 
283 bool CscCalibTool::stripT0phase ( uint32_t stripHashId ) const {
284 
285  bool t0phase = 0;
286 
287  if (! m_onlineHLT ) {
288  if ( m_readFromDatabase ) {
290  const CscCondDbData* readCdo{*readHandle};
291  if(!readCdo->readChannelT0Phase(stripHashId, t0phase).isSuccess()){
292  if (m_messageCnt_t0phase < 3) {
293  ATH_MSG_WARNING ( " failed to access CSC conditions database - t0phase - "
294  << "strip hash id = " << stripHashId );
295  ATH_MSG_WARNING ( " This WARNING Message can be temporarily until COOL DB is filled");
297  }
298  } else {
299  ATH_MSG_VERBOSE ( "The t0phase is " << t0phase << " for stripHashId " << stripHashId );
300  }
301  }
302  }
303  return t0phase;
304 }
305 
306 
307 double CscCalibTool::stripT0base ( uint32_t stripHashId ) const {
308 
309  float t0base = 0.0;
310  if (! m_onlineHLT ) {
311  if ( m_readFromDatabase ) {
313  const CscCondDbData* readCdo{*readHandle};
314  if(!readCdo->readChannelT0Base(stripHashId, t0base).isSuccess()){
315 
316  if (m_messageCnt_t0base < 3) {
317  ATH_MSG_WARNING ( " failed to access CSC conditions database - t0base - "
318  << "strip hash id = " << stripHashId );
319  ATH_MSG_WARNING ( " This WARNING Message can be temporarily until COOL DB is filled");
321  }
322  } else {
323  ATH_MSG_VERBOSE ( "The t0base is " << t0base << " for stripHashId " << stripHashId );
324  }
325  }
326  }
327  return t0base;
328 }
329 
330 
331 
332 double CscCalibTool::adcCountToFemtoCoulomb(const float adc, const float slope) const
333 {
334 
335  double charge = adc * slope;
336  ATH_MSG_VERBOSE ( "Using CscCalibTool::adcCountToFemtoCoulomb - adc = "
337  << adc << " charge(fC) = " << charge );
338  return charge;
339 }
340 
341 double CscCalibTool::func(const double x, const float slope) const
342 {
343  int val = 0;
344  if ( slope != 0 ) val = int ( (x / slope) + 0.5);
345  // else
346  // ATH_MSG_WARNING ( "CscCalibTool::femtoCoulombToADC - slope = 0" );
347  // if ( val < 0 ) {
348  // ATH_MSG_WARNING ( "CscCalibTool::femtoCoulombToADC - ADC cannot be < 0 - " << val );
349  //val = 0;
350  // }
351 
352  return (1.0*val);
353 }
354 
355 double CscCalibTool::func_prime(const double x, const float slope) const
356 {
357  double val = slope;
358  if ( slope == 0.0 )
359  ATH_MSG_WARNING ( "CscCalibTool - slope = 0 for x = " << x );
360  return val;
361 }
362 
363 //
364 bool CscCalibTool::findCharge(const float samplingTime, const unsigned int samplingPhase,
365  const std::vector<float>& samples, double & charge, double & time) const {
366 
367  time = 0.0;
368  charge = 0.0;
369 
370  int numberOfSamplings = samples.size();
371  // no samples given
372  if (numberOfSamplings==0) return false;
373 
374  // MS: The case of only 2 samples:
375  if ((numberOfSamplings==2) || m_use2Samples) { // no parabola possible
376  int i = numberOfSamplings/2-1;
377  charge = 0.5*(samples[i]+samples[i+1]); // 1+2 for 4 samples, 0+1 for 2
378 
379  double asym = 0.;
380  if (std::abs(samples[i]+samples[i+1])>0.0001) asym = (samples[i+1]-samples[i])/(samples[i]+samples[i+1]);
381  /********************* No charge correction now.
382  // charge correction:
383  double chargecor = 77.85 + 1.415*asym - 44.97*asym*asym; // in percent
384  charge = charge / chargecor * 100.0;
385  *******************/
386 
387  // time = i+0.5; // midpoint beween the 2 samples: no interpolation
388  // time *= samplingTime;
389  time = 76 + 47.85*asym + 6.629*asym*asym; // in ns, for 50ns sampling
390  if ( samplingPhase == 1 ) time -= 25;
391  return true;
392  }
393 
395  float max = -4096000;
396  int maxIndex = -1;
397 
398  if ( numberOfSamplings >10) { // for x5 data
399  maxIndex = 2;
400  max = samples[maxIndex];
401  }
402 
403  for (int i=0; i<numberOfSamplings; i++) {
404  if ( numberOfSamplings >10 && (i<2 || i>6) ) continue; // for x5 data
405  if (samples[i] > max) {
406  max = samples[i];
407  maxIndex = i;
408  }
409  }
410 
412  // if (max == -4096000) return false; //not possible
413 
414 
417  double a, b, c;
418 
419  int midIndex = maxIndex;
420  if (maxIndex == 0) { // peaks on the first sample
421  a = samples[maxIndex];
422  b = samples[maxIndex+1];
423  c = samples[maxIndex+2];
424  midIndex +=1;
425  } else if (maxIndex == numberOfSamplings-1) { // last sample but it won't happen if third and 4th samples are same...
426  a = samples[maxIndex-2];
427  b = samples[maxIndex-1];
428  c = samples[maxIndex];
429  midIndex -=1;
430  } else { // normal case
431  a = samples[maxIndex-1];
432  b = samples[maxIndex];
433  c = samples[maxIndex+1];
434  }
435 
436  //#D!!!!! Need to carefully check the case of 250 * 23898.136 * 28535.650 * 33587.949 * 33587.949 *
437 
438  double aa = 0.5*(c+a-2*b); // p2 (coeff for x^2)
439  double bb = 0.5*(c-a);
440 
441 
444  if ( aa >= 0 ) {
445  time = midIndex;
446  time *= samplingTime;
447  if ( samplingPhase == 1 ) time -= 25; // works for both 20MHz and 40MHz
448  // time =0.0;
449  charge = max;
450 
451  if (maxIndex ==0 || maxIndex ==1)
452  time -= 1000;
453  else if (maxIndex ==2 || maxIndex ==3)
454  time += 1000;
455 
456  ATH_MSG_VERBOSE("WP aa is positive");
457  return false;
458  }
459 
460  double timeOffset = -0.5*bb/aa;
461 
462  ATH_MSG_VERBOSE("WP " << timeOffset);
464  if ( ( maxIndex == 0 && timeOffset < -2.0 )
465  || ( maxIndex == 3 && timeOffset > 2.0) ) {
466  time = midIndex;
467  time *= samplingTime;
468  if ( samplingPhase == 1 ) time -= 25; // works for both 20MHz and 40MHz
469  // time =0.0;
470  charge = max;
471 
472  if (maxIndex ==0 || maxIndex ==1)
473  time -= 1000;
474  else if (maxIndex ==2 || maxIndex ==3)
475  time += 1000;
476 
477  ATH_MSG_VERBOSE("time is out of range");
478 
479  return true;
480  }
481 
483  charge = aa*timeOffset*timeOffset + bb*timeOffset + b;
484  time = timeOffset;
485 
495  time += midIndex;
496  time *= samplingTime;
497  if ( samplingPhase == 1 ) time -= 25;
498 
499  return true;
500 }
501 
502 double CscCalibTool::adcCountToFemtoCoulomb(uint32_t stripHashId, const float adcValue) const
503 {
504  ATH_MSG_VERBOSE ( "The strip hash id is " << stripHashId );
505 
509  float pedestal = m_pedestal;
510  float slope = getPSlope(stripHashId);
511 
512  if ( m_readFromDatabase ) {
514  const CscCondDbData* readCdo{*readHandle};
515  if(!readCdo->readChannelPed(stripHashId, pedestal).isSuccess()){
516  ATH_MSG_DEBUG ( " failed to access CSC conditions database - pedestal - "
517  << "strip hash id = " << stripHashId );
518  pedestal = m_pedestal;
519  }
520  }
521  ATH_MSG_VERBOSE ( "Pedestal is " << pedestal << " For strip hash id " << stripHashId );
522 
523  // allowed negative adc values for bipolar fit
524  float adc = adcValue-pedestal;
525  return this->adcCountToFemtoCoulomb( adc, slope );
526 
527 }
528 
529 double CscCalibTool::adcCountToNumberOfElectrons(uint32_t stripHashId, const float adcValue) const
530 {
531  ATH_MSG_VERBOSE ( "The strip hash id is " << stripHashId );
532 
536  float pedestal = m_pedestal;
537  float slope = getPSlope(stripHashId);
538  if ( m_readFromDatabase ) {
540  const CscCondDbData* readCdo{*readHandle};
541  if(!readCdo->readChannelPed(stripHashId, pedestal).isSuccess()){
542  ATH_MSG_DEBUG ( "failed to access CSC Conditions database - pedestal - "
543  << "strip hash id = " << stripHashId );
544  pedestal = m_pedestal;
545  }
546  }
547  ATH_MSG_VERBOSE ( "Pedestal is " << pedestal << " For strip hash id " << stripHashId );
548 
549  // allowed negative adc values for bipolar fit
550  float adc = adcValue-pedestal;
551  return this->adcCountToNumberOfElectrons( adc, slope );
552 }
553 
554 bool CscCalibTool::adcToCharge(const std::vector<uint16_t>& samples, uint32_t stripHashId,
555  std::vector<float>& charges) const {
556  ATH_MSG_VERBOSE ( "The strip hash id is " << stripHashId );
557 
558  charges.clear();
559 
561  float pedestal = m_pedestal;
562  float slope = getPSlope(stripHashId);
563  if ( m_readFromDatabase ) {
565  const CscCondDbData* readCdo{*readHandle};
566  if(!readCdo->readChannelPed(stripHashId, pedestal).isSuccess()){
567  ATH_MSG_DEBUG ( "failed to access CSC Conditions database - pedestal - "
568  << "strip hash id = " << stripHashId );
569  pedestal = m_pedestal;
570  }
571  }
572  ATH_MSG_VERBOSE ( "Pedestal is " << pedestal << " For strip hash id " << stripHashId );
573 
574  unsigned max = samples.size();
575  if ( max == 0 ) return false;
576  for (unsigned int i=0; i<max; i++) {
577  // if ( samples[i] > pedestal ) {
578  float adc = samples[i]-pedestal;
579  float charge = static_cast<float> ( this->adcCountToNumberOfElectrons( adc, slope ) );
580  charges.push_back( charge );
581  // } else charges.push_back( 0.0 );
582  }
583  return true;
584 }
585 
587 // define bipolar functional shape
588 // Parameters are from Kostas presentation at the following link (09/2007)
589 // http://indico.cern.ch/getFile.py/access?contribId=1&resId=1&materialId=slides&confId=18787
590 
591 double CscCalibTool::getZ0() const{
593  double z0 = 0.5*( (sum+2)
594  -std::sqrt(std::pow(sum+2,2)
596  );
597  return z0;
598 }
599 
600 double CscCalibTool::signal( const double z ) const{
601  double amplitude = (1.0 - z / (1 + m_integrationNumber2))
602  * std::pow(z, 1.0 * m_integrationNumber)
603  * std::exp(-z);
604  return amplitude;
605 }
606 
607 double CscCalibTool::signal_amplitude(const double driftTime, const double samplingTime) const{
608  double z0 = getZ0();
609  double norm = signal(z0);
610  if (samplingTime <= driftTime) return 0.;
611  Double_t z = (samplingTime-driftTime)/m_signalWidth;
612  return signal(z)/norm;
613 }
614 
615 
616 // new schema starting from 09/2010...
617 std::vector<float> CscCalibTool::getSamplesFromBipolarFunc(const double driftTime0, const double stripCharge0) const {
618 
619  std::vector<float> result;
620  if ( stripCharge0==0.0 ) {
621  result.push_back(0.0);
622  result.push_back(0.0);
623  result.push_back(0.0);
624  result.push_back(0.0);
625  return result;
626  }
627 
628  std::unique_ptr<TF1> bipolarFunc = std::make_unique<TF1>("bipolarFunc", bipfunc, -500, 500, 5, 1, TF1::EAddToList::kNo);
629  bipolarFunc->SetParameters(stripCharge0, driftTime0,
631 
632 
633  for (unsigned int i=0; i<m_nSamples; ++i) {
634 
635  float sampleCharge = bipolarFunc->Eval(m_latency + i*m_samplingTime);
636  result.push_back( sampleCharge );
637 
638  }
639  return result;
640 }
641 
642 
643 std::pair<double,double> CscCalibTool::addBipfunc(const double driftTime0,
644  const double stripCharge0,
645  const double driftTime1,
646  const double stripCharge1) const {
647 
648  std::pair<double,double> result;
649  // To get a nomalization constant...
650  result.first =driftTime0;
651  result.second = stripCharge0;
652 
653  if ( (stripCharge0==0.0 && stripCharge1==0.0)||
654  (stripCharge0>0.0 && stripCharge1==0.0))
655  return result;
656 
657  if (stripCharge0==0.0 && stripCharge1>0.0) {
658  result.first =driftTime1;
659  result.second = stripCharge1;
660  return result;
661  }
662 
663  std::unique_ptr<TF1> addedfunc = std::make_unique<TF1>("addedfunc", dualbipfunc, 0, 500, 10, 1, TF1::EAddToList::kNo);
664  addedfunc->SetParameters(stripCharge0, driftTime0,
666  stripCharge1, driftTime1,
668  result.second =addedfunc->GetMaximum(); // ==>stripCharges of added bipolars
669  float tmax =addedfunc->GetX(result.second);
670  result.first = tmax - getZ0()*m_signalWidth;
671 
672  if (stripCharge0>0.0 && stripCharge1>0.0) return result;
673 
674  float bipmin = addedfunc->GetMinimum(); // ==>stripCharges of added bipolars
675  float tmin = addedfunc->GetX(bipmin);
676  if (tmin<tmax) {
677  result.first = tmin-getZ0()*m_signalWidth;
678  result.second = bipmin;
679  }
680 
681  // To check out conversion is correct...
682  ATH_MSG_VERBOSE ( "(" << driftTime0 << ":" << int(stripCharge0) << ")"
683  << "+(" << driftTime1 << ":" << int(stripCharge1) << ")"
684  << " ==> " << result.first << ":" << int(result.second)
685  << " e- which was " << int(stripCharge0+stripCharge1) );
686 
687 
688 
689  return result;
690 }
691 
693 double CscCalibTool::getLatency() const {return m_latency;}
CscCalibTool::stripT0base
virtual double stripT0base(uint32_t stripHashId) const override final
return T0base related to 5 ASM.
Definition: CscCalibTool.cxx:307
CscCalibTool::m_readFromDatabase
bool m_readFromDatabase
Definition: CscCalibTool.h:148
CscCalibTool::signal_amplitude
virtual double signal_amplitude(const double driftTime, const double samplingTime) const override final
Definition: CscCalibTool.cxx:607
PlotCalibFromCool.norm
norm
Definition: PlotCalibFromCool.py:100
CscCalibTool::stripNoise
virtual double stripNoise(uint32_t stripHashId, const bool convert=true) const override final
return the noise(sigma) on the readout strip in ADC counts or Number of Electrons number of electrons...
Definition: CscCalibTool.cxx:146
get_generator_info.result
result
Definition: get_generator_info.py:21
max
#define max(a, b)
Definition: cfImp.cxx:41
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
CscCalibTool::getSamplesFromBipolarFunc
virtual std::vector< float > getSamplesFromBipolarFunc(const double driftTime0, const double stripCharge0) const override final
Definition: CscCalibTool.cxx:617
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
CscCalibTool::m_timeOffset
double m_timeOffset
Definition: CscCalibTool.h:164
dualbipfunc
Double_t dualbipfunc(const Double_t *x, const Double_t *par)
Definition: CscCalibTool.cxx:59
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
CscCalibTool::getLatency
virtual double getLatency() const override final
Definition: CscCalibTool.cxx:693
CscCalibTool::adcToCharge
virtual bool adcToCharge(const std::vector< uint16_t > &samples, uint32_t stripHashId, std::vector< float > &charges) const override final
Conversion of ADC value to charge - Here the charges is returned in numbers of equivalent electrons.
Definition: CscCalibTool.cxx:554
CscCalibTool::m_use2Samples
bool m_use2Samples
Definition: CscCalibTool.h:171
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
x
#define x
DataHandle.h
CscCalibTool::initialize
virtual StatusCode initialize() override final
Definition: CscCalibTool.cxx:63
CscCalibTool::findCharge
virtual bool findCharge(const float samplingTime, const unsigned int samplingPhase, const std::vector< float > &samples, double &charge, double &time) const override final
Given sampling values for a CSC strip, find the corresponding charge by fitting the time samples.
Definition: CscCalibTool.cxx:364
CscCalibTool::stripStatusBit
virtual int stripStatusBit(uint32_t stripHashId) const override final
return status bit
Definition: CscCalibTool.cxx:265
CscCalibTool::CscCalibTool
CscCalibTool(const std::string &, const std::string &, const IInterface *)
Definition: CscCalibTool.cxx:12
CscCalibTool::func
virtual double func(const double x, const float slope) const override final
these function used in the AOD <-> conversion; may not be needed once we integrate the calibration se...
Definition: CscCalibTool.cxx:341
CscCalibTool::getSignalWidth
virtual double getSignalWidth() const override final
Definition: CscCalibTool.cxx:695
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
CscCalibTool::getSamplingTime
virtual double getSamplingTime() const override final
Definition: CscCalibTool.cxx:692
CscCalibTool::getNumberOfIntegration
virtual double getNumberOfIntegration() const override final
Definition: CscCalibTool.cxx:696
CscCalibTool::signal
virtual double signal(const double z) const override final
Definition: CscCalibTool.cxx:600
TRT::Hit::driftTime
@ driftTime
Definition: HitInfo.h:43
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
CscCalibTool::adcCountToNumberOfElectrons
virtual double adcCountToNumberOfElectrons(const float adcValue, const float slope) const override final
given one CSC ADC sample value, convert that to charge in number of equivalent electrons
Definition: CscCalibTool.cxx:138
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
CscCalibTool::func_prime
virtual double func_prime(const double x, const float slope) const override final
Definition: CscCalibTool.cxx:355
CscCalibTool::m_integrationNumber2
double m_integrationNumber2
Definition: CscCalibTool.h:160
beamspotman.n
n
Definition: beamspotman.py:731
CscCalibTool::getZ0
virtual double getZ0() const override final
ROOT version of bipolar function.
Definition: CscCalibTool.cxx:591
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CscCalibTool::stripF001
virtual double stripF001(uint32_t stripHashId, const bool convert=true) const override final
return the F001 on the readout strip in ADC counts or Number of Electrons number of electrons by defa...
Definition: CscCalibTool.cxx:201
CscCalibTool::m_messageCnt_t0phase
std::atomic_int m_messageCnt_t0phase
Definition: CscCalibTool.h:132
CscCalibTool::getTimeOffset
virtual double getTimeOffset() const override final
Definition: CscCalibTool.cxx:694
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
CscCalibTool::m_slope
float m_slope
Definition: CscCalibTool.h:151
CscCalibTool::m_slopeFromDatabase
bool m_slopeFromDatabase
Definition: CscCalibTool.h:149
CscCalibTool::m_signalWidth
double m_signalWidth
Definition: CscCalibTool.h:163
CscCalibTool::getPSlope
float getPSlope(uint32_t stripHashId) const
Definition: CscCalibTool.cxx:92
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
CscCalibTool::stripRMS
virtual double stripRMS(uint32_t stripHashId, const bool convert=true) const override final
return the RMS on the readout strip in ADC counts or Number of Electrons number of electrons by defau...
Definition: CscCalibTool.cxx:173
CscCalibTool::m_nSamples
unsigned int m_nSamples
Definition: CscCalibTool.h:168
charge
double charge(const T &p)
Definition: AtlasPID.h:538
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TMVAToMVAUtils::convert
std::unique_ptr< MVAUtils::BDT > convert(TMVA::MethodBDT *bdt, bool isRegression=true, bool useYesNoLeaf=false)
Definition: TMVAToMVAUtils.h:114
CscCalibTool::m_noise
float m_noise
Definition: CscCalibTool.h:152
CscCalibTool::m_readKey
SG::ReadCondHandleKey< CscCondDbData > m_readKey
Definition: CscCalibTool.h:146
CscCalibTool.h
a
TList * a
Definition: liststreamerinfos.cxx:10
CscCalibTool::getNumberOfIntegration2
virtual double getNumberOfIntegration2() const override final
Definition: CscCalibTool.cxx:697
CscCalibTool::m_latency
double m_latency
Definition: CscCalibTool.h:166
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ReadFloatFromCool.adc
adc
Definition: ReadFloatFromCool.py:48
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CscCalibTool::m_samplingTime
double m_samplingTime
Definition: CscCalibTool.h:162
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
CscCalibTool::m_onlineHLT
bool m_onlineHLT
Definition: CscCalibTool.h:170
CscCalibTool::m_integrationNumber
double m_integrationNumber
ROOT version of bipolar function.
Definition: CscCalibTool.h:159
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
CscCalibTool::stripPedestal
virtual double stripPedestal(uint32_t stripHashId, const bool convert=true) const override final
return the pedestal on the readout strip in ADC counts or Number of Electrons
Definition: CscCalibTool.cxx:227
CscCalibTool::isGood
virtual bool isGood(uint32_t stripHashId) const override final
return the status of this strip, good channel, dead channel, noisy channel - it will return true for ...
Definition: CscCalibTool.cxx:254
merge.status
status
Definition: merge.py:17
CscCalibTool::adcCountToFemtoCoulomb
virtual double adcCountToFemtoCoulomb(const float adcCounts, const float slope) const override final
given one CSC ADC sample value, convert that to charge in femtoCoulomb
Definition: CscCalibTool.cxx:332
CscCalibTool::numberOfElectronsToADCCount
virtual int numberOfElectronsToADCCount(uint32_t stripHashId, const int numberOfElecEquiv) const override final
Here the charge on the CSC strip is given in number of equivalent electrons; conversion to ADC counts...
Definition: CscCalibTool.cxx:112
bipfunc
Double_t bipfunc(const Double_t *x, const Double_t *par)
Definition: CscCalibTool.cxx:36
CscCalibTool::m_messageCnt_t0base
std::atomic_int m_messageCnt_t0base
Definition: CscCalibTool.h:131
test_AnalysisBaseEventLoopJob.aa
aa
Definition: test_AnalysisBaseEventLoopJob.py:37
python.compressB64.c
def c
Definition: compressB64.py:93
CscCalibTool::m_pedestal
float m_pedestal
Definition: CscCalibTool.h:153
CscCalibTool::femtoCoulombToADCCount
virtual int femtoCoulombToADCCount(uint32_t stripHashId, const double femtoCoulombs) const override final
given a charge on the CSC strip, convert that to ADC counts this is needed in the digitization for ex...
Definition: CscCalibTool.cxx:126
CscCalibTool::addBipfunc
virtual std::pair< double, double > addBipfunc(const double driftTime0, const double stripCharge0, const double driftTime1, const double stripCharge1) const override final
Definition: CscCalibTool.cxx:643
WriteCellNoiseToCool.noise
noise
Definition: WriteCellNoiseToCool.py:380
CscCalibTool::stripT0phase
virtual bool stripT0phase(uint32_t stripHashId) const override final
return T0phase related to 5 ASM.
Definition: CscCalibTool.cxx:283
CscCondDbData
Definition: CscCondDbData.h:24