27 #include "GaudiKernel/IInterface.h"
28 #include "GaudiKernel/MsgStream.h"
41 static const InterfaceID IID_IZdcRecChannelTool(
"ZdcRecChannelTool", 1, 1);
46 return IID_IZdcRecChannelTool;
53 const std::string&
name,
54 const IInterface*
parent) :
56 m_bwl_time_resolution(100),
59 m_cfd_fraction (0.35),
65 declareInterface<ZdcRecChannelTool>(
this);
68 "Supress channels with only 0");
71 "Minimum difference between min and max to be considered a signal");
103 msg(MSG::INFO) <<
"Using a time step of "
105 <<
"ps for the Bandwidth Limited Sin(x)/x Interpolation: "
117 m_spline = gsl_spline_alloc (interp_type, 14);
122 const ZdcID* zdcId =
nullptr;
124 msg(MSG::ERROR) <<
"execute: Could not retrieve ZdcID object from the detector store" <<
endmsg;
125 return StatusCode::FAILURE;
133 return StatusCode::SUCCESS;
145 return StatusCode::SUCCESS;
185 std::vector<std::vector<int> > wfm;
189 std::vector<float> energy_sum;
190 std::vector<float> energy_peak;
191 std::vector<float> time_cfd;
192 std::vector<float> time_sratio;
193 std::vector<float> chi;
199 std::vector<float> vcfd1;
200 std::vector<float> vcfd2;
201 std::vector<float> vcfd3;
214 for (
const ZdcDigits* digits_p : mydata) {
217 id = digits_p->identify();
223 msg(
MSG::DEBUG) <<
"--> ZDC : ZdcRecChannelTool::makeRawFromDigits: "
224 <<
" id;Side;Module;Type;Channel: "
225 <<
id.getString() <<
";"
243 wfm[0] = digits_p->get_digits_gain0_delay0();
244 if (wfm[0].
empty()) {
249 wfm[1] = digits_p->get_digits_gain1_delay0();
250 if (wfm[1].
empty()) {
275 wfm[2] = digits_p->get_digits_gain0_delay1();
276 wfm[3] = digits_p->get_digits_gain1_delay1();
287 for (vit = wfm.begin(); vit<wfm.end(); ++vit) {
288 if (vit->empty()) vit->resize(7);
290 for (
it=vit->begin(); it<vit->
end();++
it) {
354 for (vit = wfm.begin(); vit<wfm.end(); ++vit) {
357 pico = *(std::max_element(
v.begin(),
v.end()) );
358 energy_sum.push_back ((
float) soma);
359 energy_peak.push_back((
float) pico);
378 imax = std::max_element(
v.begin(),
v.end()) -
v.begin();
386 time_sratio.push_back(tsr);
389 msg(
MSG::DEBUG) <<
"--> ZDC : ZdcRecChannelTool " <<
id.getString() <<
391 " Energy Sum=" << soma <<
392 " Energy Peak=" << pico <<
393 " Chi=" << *(chi.end() -1) <<
394 " t0=" <<
t0 <<
" t1=" <<
t1 <<
396 " Time by CFD=" << tzc <<
397 " Peak at imax = " <<
imax <<
398 " v[imax-1] = " << (
imax > 0 ?
v[
imax-1] : 0) <<
399 " V[imax] = " <<
v[
imax] <<
400 " Sample Ratio A1/A2=" << tsr <<
endmsg;
427 z->setEnergy (
i, energy_peak[
i]);
428 z->setTime (
i, time_sratio[
i]);
429 z->setChi (
i, chi[
i]);
433 z->setChi (
i+
k, chi[
i]);
435 z->setEnergy (
i+2*
k, energy_sum[
i]);
437 z->setChi (
i+2*
k, chi[
i]);
448 msg(
MSG::DEBUG) <<
"--> ZDC : ZdcRecChannelTool ChannelCollection size " << ChannelCollection.
size() <<
endmsg ;
462 for (
const ZdcDigits* digits_p : mydata) {
463 digits_p->identify();
466 int ncal = ChannelCollection.
size();
478 unsigned int nsamples_local = 14;
485 std::vector<float> vaux;
486 unsigned int tmin = 0;
487 unsigned int tmax = 0;
495 int max_iterations = 100;
499 gsl_root_fsolver *
s = gsl_root_fsolver_alloc (
T);
507 std::vector<std::vector<int> >::const_iterator vit;
510 std:: vector<float>
result;
514 msg(
MSG::DEBUG) <<
"--> ZDC : ZdcRecChannelTool::getTimingCFD: Id " <<
id.getString() ;
524 for (vit = wfm.begin(); vit<wfm.end(); ++vit) {
527 for (
it=
y.begin();
it !=
y.end();++
it) {
531 for (
i=0;
i<nsamples_local;
i++) {
536 gsl_spline_init (
m_spline,
t,
v, nsamples_local);
540 for (
i=0;
i<nsamples_local;
i++) {
547 gsl_spline_init (
m_spline,
t, vf, nsamples_local);
557 vaux.assign(vf,vf+14);
558 tmin = std::min_element(vaux.begin(), vaux.end()) - vaux.begin();
559 tmax = std::max_element(vaux.begin(), vaux.end()) - vaux.begin();
593 gsl_root_fsolver_set (
s, &
F, x_lo, x_hi);
599 status = gsl_root_fsolver_iterate(
s);
600 r = gsl_root_fsolver_root(
s);
601 x_lo = gsl_root_fsolver_x_lower(
s);
602 x_hi = gsl_root_fsolver_x_upper(
s);
603 status = gsl_root_test_interval (x_lo, x_hi, 0, 0.001);
607 while (
status == GSL_CONTINUE && iterations < max_iterations);
611 gsl_root_fsolver_free (
s);
621 return gsl_spline_eval (
p->m_spline, x0,
p->m_interp_acc);
651 std::vector<float>
vt(7);
655 std::vector<std::vector<int> >::const_iterator vvi_it;
667 msg(
MSG::DEBUG) <<
"--> ZDC : ZdcRecChannelTool::getTimingSinc: "
668 <<
" id;Side;Module;Type;Channel: "
669 <<
id.getString() <<
";"
675 for (vvi_it = wfm.begin(); vvi_it<wfm.end(); ++vvi_it) {
691 x = (TMath::Pi() *(
t*0.1 -
i*25.))/25. ;
692 if (fabs(
x) < 1
e-8) {
721 if ( (mSide == -1) && (mType == 0) && (mModule == 0) && (mChannel == 0) ) {
724 -0.483265 *
pow(tfpeak,2) +
725 0.00234842 *
pow(tfpeak,3);
730 if ( (mSide == 1) && (mType == 0) && (mModule == 0) && (mChannel == 0) ) {
735 -1.229 *
pow(tfpeak,2) +
736 0.006276 *
pow(tfpeak,3);
741 -1.19169 *
pow(tfpeak,2) +
742 0.005659 *
pow(tfpeak,3);
778 double CFD_frac = 1.0;
781 std::vector<std::vector<int> >::const_iterator vit;
813 for (vit = wfm.begin(); vit<wfm.end(); ++vit) {
814 if ( (
i < wfmIndex) && (mType == 0) )
820 for(
int I=0;
I<NSlice;
I++) {Slices[
I]=
y[
I];}
823 zdcSignalSinc.
process(Slices,
gain,pedestal,CFD_frac,corr);
832 msg(
MSG::DEBUG) <<
"--> ZDC : ZdcRecChannelTool::getTimingSinc2: "