9 #include "CLHEP/Matrix/Matrix.h"
10 #include "CLHEP/Matrix/Vector.h"
15 using CLHEP::HepMatrix;
16 using CLHEP::HepVector;
23 m_fileShapeName(
"parabola_Shape.dat"),
24 m_fileADCcorName(
"parabola_adccor.dat")
30 declareInterface<LArParabolaPeakRecoTool>(
this);
38 std::cout <<
"LArParabolaPeakRecoTool: correctBias flag is ON " << std::endl;
47 float timeValue, adccorValue;
50 while( fscanf(
m_fileShape,
"%80d %80d %80f",&idelay,&ilayer,&timeValue) != EOF )
52 if ( ilayer >= 0 && ilayer < 4 && idelay >= 0 && idelay < 25 )
56 if ( idelay == 0 &&
m_QT_Shape[ilayer][0] != 0. )
63 while( fscanf(
m_fileADCcor,
"%80d %80d %80f",&idelay,&ilayer,&adccorValue) != EOF )
65 if ( ilayer >= 0 && ilayer < 4 && idelay >= 0 && idelay < 25 )
74 return StatusCode::SUCCESS;
78 {
return StatusCode::SUCCESS;}
82 return peak(samples, -1, -1.);
87 std::vector<float> newsamples;
88 for(
unsigned int i=0;
i<samples.size();
i++)
90 newsamples.push_back((
float)samples[
i]);
92 return peak(newsamples, -1, -1.);
99 std::vector<float> newsamples;
100 for(
unsigned int i=0;
i<samples.size();
i++)
102 newsamples.push_back((
float)samples[
i]);
104 return peak(newsamples,
layer, pedestal);
110 std::vector<float> solution;
112 const std::vector<float>::const_iterator it_max=max_element(samples.begin(),samples.end());
113 if (it_max==samples.end()) {
117 if (it_max==samples.begin() || it_max==samples.end()-1)
119 solution.push_back(*it_max);
124 HepMatrix alpha(3,3);
126 for (
int i=0;
i<3;
i++)
128 for (
int j=0;j<3;j++)
129 alpha[
i][j]=
pow(-1+
i,j);
132 float retval=0, tmax=0, traw=0, trec=0;
147 traw += ( it_max-samples.begin() - 3 )*25.;
149 if(layer < 0 || layer > 3) {
156 if(pedestal<0)
ATH_MSG_ERROR(
"Pedestal is wrong ! Ped = " << pedestal );
161 solution.push_back(
retval);
163 solution.push_back(tmax);
166 solution.push_back(traw);
167 solution.push_back(trec);
189 QT_true_lower = -999.;
190 QT_raw_lower = -999.;
191 QT_raw_upper = -999.;
216 for ( idelay=0; idelay < 25; idelay++ )
221 QT_true_lower = (
float) (idelay - iOffset * 25.);
231 if ( QT_true_lower == -999. )
233 QT_true_time = -999.;
237 QT_true_time = QT_true_lower +
238 (QT_fittime-QT_raw_lower)/(QT_raw_upper - QT_raw_lower);
253 float QT_correct_ADC;
267 if ( QT_true_time < 0. )
269 QT_true_time += ( ( (
int) std::abs(QT_true_time / 25)) + 1)*25;
276 ichoosedelay = (
int) QT_true_time % 25;
282 if ( ilayer >=0 && ilayer< 4 )
284 if ( ichoosedelay < 25 - 1 ){
287 * (QT_true_time - (
int) QT_true_time);
292 * (QT_true_time - (
int) QT_true_time);
297 QT_correct_ADC = 100.;
307 QT_true_ADC = ADCref - PEDref;
308 QT_true_ADC = QT_true_ADC / QT_correct_ADC * 100.;
309 QT_true_ADC += PEDref;