11(
const std::string& t,
const std::string& n,
const IInterface* p )
14 declareProperty(
"Slope",
m_slope = 0.19 );
15 declareProperty(
"Noise",
m_noise = 3.5 );
16 declareProperty(
"Pedestal",
m_pedestal = 2048.0 );
28 declareProperty(
"Latency",
m_latency = 100 );
35Double_t
bipfunc(
const Double_t *
x,
const Double_t *par){
36 if (
x[0] < par[1])
return 0.;
37 Double_t integrationNumber = par[2];
38 Double_t integrationNumber2 = par[3];
40 Double_t signalWidth = par[4];
41 Double_t sum = integrationNumber+integrationNumber2;
42 Double_t z0 = 0.5*( (sum+2)
43 -std::sqrt(std::pow(sum+2,2)
44 -4*integrationNumber*(integrationNumber2+1))
47 Double_t norm = (1.0 - z0 / (1 + integrationNumber2))
48 * std::pow(z0, 1.0 * integrationNumber)
51 Double_t
z = (
x[0]-par[1])/signalWidth;
53 par[0]*(1-
z/(1+integrationNumber2))
54 *std::pow(
z,integrationNumber)*std::exp(-1.0*
z)/norm;
80 ATH_MSG_DEBUG(
"T0BaseFolder and T0PhaseFolder are not loaded!!! HLT COOLDB does not have it!!");
88 return StatusCode::SUCCESS;
99 ATH_MSG_WARNING (
" failed to access CSC conditions database - slope - "
100 <<
"strip hash id = " << stripHashId );
103 ATH_MSG_DEBUG (
"The slope is " << slope <<
" for strip hash = " << stripHashId );
116 double conversionFactor = 1.602e-4;
117 double femtoCoulombs = conversionFactor*numberOfElecEquiv;
121 int adcValue = int (
func(femtoCoulombs,slope) );
132 int adcValue = int (
func(femtoCoulombs,slope) );
139 double conversionFactor = 1.602e-4;
141 return (femtoCoulombs/conversionFactor);
154 ATH_MSG_DEBUG (
" failed to access CSC conditions database - noise - "
155 <<
"strip hash id = " << stripHashId );
160 ATH_MSG_VERBOSE (
"The noise is " << noise <<
" for strip hash = " << stripHashId );
181 ATH_MSG_DEBUG (
" failed to access CSC conditions database - rms - "
182 <<
"strip hash id = " << stripHashId );
187 ATH_MSG_VERBOSE (
"The RMS is " << rms <<
" for strip hash = " << stripHashId );
209 ATH_MSG_DEBUG (
" failed to access CSC conditions database - f001 - "
210 <<
"strip hash id = " << stripHashId );
215 ATH_MSG_VERBOSE (
"The F001 is " << f001 <<
" for strip hash = " << stripHashId );
235 ATH_MSG_DEBUG (
" failed to access CSC conditions database - pedestal - "
236 <<
"strip hash id = " << stripHashId );
240 ATH_MSG_VERBOSE (
"The pedestal is " << pedestal <<
" for strip hash = " << stripHashId );
259 bool is_good = !( (status & 0x1) || ((status >> 1) & 0x1) );
271 ATH_MSG_WARNING (
" failed to access CSC conditions database - status - "
272 <<
"strip hash id = " << stripHashId );
275 " for strip hash = " << std::dec << stripHashId);
292 ATH_MSG_WARNING (
" failed to access CSC conditions database - t0phase - "
293 <<
"strip hash id = " << stripHashId );
294 ATH_MSG_WARNING (
" This WARNING Message can be temporarily until COOL DB is filled");
298 ATH_MSG_VERBOSE (
"The t0phase is " << t0phase <<
" for stripHashId " << stripHashId );
316 ATH_MSG_WARNING (
" failed to access CSC conditions database - t0base - "
317 <<
"strip hash id = " << stripHashId );
318 ATH_MSG_WARNING (
" This WARNING Message can be temporarily until COOL DB is filled");
322 ATH_MSG_VERBOSE (
"The t0base is " << t0base <<
" for stripHashId " << stripHashId );
334 double charge = adc * slope;
335 ATH_MSG_VERBOSE (
"Using CscCalibTool::adcCountToFemtoCoulomb - adc = "
336 << adc <<
" charge(fC) = " <<
charge );
343 if ( slope != 0 ) val = int ( (
x / slope) + 0.5);
364 const std::vector<float>& samples,
double &
charge,
double & time)
const {
369 int numberOfSamplings = samples.size();
371 if (numberOfSamplings==0)
return false;
375 int i = numberOfSamplings/2-1;
376 charge = 0.5*(samples[i]+samples[i+1]);
379 if (std::abs(samples[i]+samples[i+1])>0.0001) asym = (samples[i+1]-samples[i])/(samples[i]+samples[i+1]);
388 time = 76 + 47.85*asym + 6.629*asym*asym;
389 if ( samplingPhase == 1 ) time -= 25;
394 float max = -4096000;
397 if ( numberOfSamplings >10) {
399 max = samples[maxIndex];
402 for (
int i=0; i<numberOfSamplings; i++) {
403 if ( numberOfSamplings >10 && (i<2 || i>6) )
continue;
404 if (samples[i] >
max) {
416 double a{}, b{}, c{};
418 int midIndex = maxIndex;
420 a = samples[maxIndex];
421 b = samples[maxIndex+1];
422 c = samples[maxIndex+2];
424 }
else if (maxIndex == numberOfSamplings-1) {
425 a = samples[maxIndex-2];
426 b = samples[maxIndex-1];
427 c = samples[maxIndex];
429 }
else if (maxIndex > 0){
430 a = samples[maxIndex-1];
431 b = samples[maxIndex];
432 c = samples[maxIndex+1];
437 double aa = 0.5*(c+
a-2*b);
438 double bb = 0.5*(c-
a);
445 time *= samplingTime;
446 if ( samplingPhase == 1 ) time -= 25;
450 if (maxIndex ==0 || maxIndex ==1)
452 else if (maxIndex ==2 || maxIndex ==3)
459 double timeOffset = -0.5*bb/aa;
463 if ( ( maxIndex == 0 && timeOffset < -2.0 )
464 || ( maxIndex == 3 && timeOffset > 2.0) ) {
466 time *= samplingTime;
467 if ( samplingPhase == 1 ) time -= 25;
471 if (maxIndex ==0 || maxIndex ==1)
473 else if (maxIndex ==2 || maxIndex ==3)
482 charge = aa*timeOffset*timeOffset + bb*timeOffset + b;
495 time *= samplingTime;
496 if ( samplingPhase == 1 ) time -= 25;
515 ATH_MSG_DEBUG (
" failed to access CSC conditions database - pedestal - "
516 <<
"strip hash id = " << stripHashId );
520 ATH_MSG_VERBOSE (
"Pedestal is " << pedestal <<
" For strip hash id " << stripHashId );
523 float adc = adcValue-pedestal;
541 ATH_MSG_DEBUG (
"failed to access CSC Conditions database - pedestal - "
542 <<
"strip hash id = " << stripHashId );
546 ATH_MSG_VERBOSE (
"Pedestal is " << pedestal <<
" For strip hash id " << stripHashId );
549 float adc = adcValue-pedestal;
554 std::vector<float>& charges)
const {
566 ATH_MSG_DEBUG (
"failed to access CSC Conditions database - pedestal - "
567 <<
"strip hash id = " << stripHashId );
571 ATH_MSG_VERBOSE (
"Pedestal is " << pedestal <<
" For strip hash id " << stripHashId );
573 unsigned max = samples.size();
574 if (
max == 0 )
return false;
575 for (
unsigned int i=0; i<
max; i++) {
577 float adc = samples[i]-pedestal;
579 charges.push_back(
charge );
592 double z0 = 0.5*( (sum+2)
593 -std::sqrt(std::pow(sum+2,2)
609 if (samplingTime <= driftTime)
return 0.;
618 std::vector<float> result;
619 if ( stripCharge0==0.0 ) {
620 result.push_back(0.0);
621 result.push_back(0.0);
622 result.push_back(0.0);
623 result.push_back(0.0);
627 std::unique_ptr<TF1> bipolarFunc = std::make_unique<TF1>(
"bipolarFunc",
bipfunc, -500, 500, 5, 1, TF1::EAddToList::kNo);
628 bipolarFunc->SetParameters(stripCharge0, driftTime0,
635 result.push_back( sampleCharge );
643 const double stripCharge0,
644 const double driftTime1,
645 const double stripCharge1)
const {
647 std::pair<double,double> result;
649 result.first =driftTime0;
650 result.second = stripCharge0;
652 if ( (stripCharge0==0.0 && stripCharge1==0.0)||
653 (stripCharge0>0.0 && stripCharge1==0.0))
656 if (stripCharge0==0.0 && stripCharge1>0.0) {
657 result.first =driftTime1;
658 result.second = stripCharge1;
662 std::unique_ptr<TF1> addedfunc = std::make_unique<TF1>(
"addedfunc",
dualbipfunc, 0, 500, 10, 1, TF1::EAddToList::kNo);
663 addedfunc->SetParameters(stripCharge0, driftTime0,
665 stripCharge1, driftTime1,
667 result.second =addedfunc->GetMaximum();
668 float tmax =addedfunc->GetX(result.second);
671 if (stripCharge0>0.0 && stripCharge1>0.0)
return result;
673 float bipmin = addedfunc->GetMinimum();
674 float tmin = addedfunc->GetX(bipmin);
677 result.second = bipmin;
682 <<
"+(" << driftTime1 <<
":" <<
int(stripCharge1) <<
")"
683 <<
" ==> " << result.first <<
":" <<
int(result.second)
684 <<
" e- which was " <<
int(stripCharge0+stripCharge1) );
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double charge(const T &p)
StatusCode readChannelPed(IdentifierHash, float &) const
StatusCode readChannelT0Base(IdentifierHash, float &) const
StatusCode readChannelT0Phase(IdentifierHash, bool &) const
StatusCode readChannelRMS(IdentifierHash, float &) const
StatusCode readChannelStatus(IdentifierHash, int &) const
StatusCode readChannelPSlope(IdentifierHash, float &) const
StatusCode readChannelNoise(IdentifierHash, float &) const
StatusCode readChannelF001(IdentifierHash, float &) const