7 #include "CoralBase/Blob.h"
8 #include "CoralBase/AttributeListSpecification.h"
24 #include "TObjArray.h"
33 inline int imax(
int i,
int j) {
return i < j ? j :
i; }
36 : TimeDiffHisto((
"pmt_dtime"+
id).c_str(),(
"pmt_dtime"+
id).c_str(),1200,-60,60)
37 , TimeDiffNoCFCorrHisto((
"dtimeNoCorr"+
id).c_str(),(
"dtimeNoCorr"+
id).c_str(),1200,-60,60)
40 , timeHisto((
"time" +
id).c_str(), (
"time" +
id).c_str(), 200, -100, 100)
41 , eneHisto((
"energy" +
id).c_str(), (
"energy" +
id).c_str(), 300, 0., 300.)
42 , gainHisto((
"gain" +
id).c_str(), (
"gain" +
id).c_str(), 2, 0, 2)
45 #ifdef TileLaserTimingPMT0Mon
46 , TimeDiffHistoHigh((
"dtime" +
id +
"hi").c_str(), (
"dtime" +
id +
"hi").c_str(), 200, -40, 40)
47 , TimeDiffHistoLow((
"dtime" +
id +
"lo").c_str(), (
"dtime" +
id +
"lo").c_str(), 200, -60, 60)
50 #ifdef TileLaserTimingMonPulse
51 , pulseShapeHigh((
"pulseShape_" +
id +
"hi").c_str(), (
"pulseShape_" +
id +
"hi").c_str(), 400, -200., 300., 0, 100000.)
52 , pulseShapeLow((
"pulseShape_" +
id +
"lo").c_str(), (
"pulseShape_" +
id +
"lo").c_str(), 400, -200., 300., 0, 100000.)
55 , TimeDiffResHis((
"dtimeRes"+
id).c_str(),(
"dtimeRes"+
id).c_str(),1000,-40.,40.)
58 #ifdef TileLaserTimingPMT0
76 m_ch_time[m_N_active] =
time;
84 for (
int i = 0;
i < m_N_active; ++
i) m_mean_time += m_ch_time[
i];
86 m_mean_time = m_mean_time / ((
float) m_N_active);
88 for (
int i = 0;
i < m_N_active; ++
i) m_mean_rms +=
sqr(m_ch_time[
i] - m_mean_time);
90 m_mean_rms = m_mean_rms / ((
float) m_N_active);
91 m_mean_rms = sqrt(m_mean_rms);
95 : Digi0TimeDiffHisto((
"TimeDiff" +
id).c_str(), (
"TimeDiff" +
id).c_str(), 2000, -100., 100.)
96 , Digi0Time((
"Digi0Time" +
id).c_str(), (
"Digi0Time" +
id).c_str(), 2000, -100., 100.)
97 , FarDigitizerMeanTime(0.0)
100 for (
int i = 0;
i < 48; ++
i) {
101 std::ostringstream sout;
102 sout <<
id <<
'_' <<
i;
110 float const TileLaserTimingTool::s_fiberLength[2][48] = {{167.1,167.1,178.7,178.7,190.3,190.3,201.9,201.9,213.5,213.5,
111 225.1,225.1,236.7,236.7,248.3,248.3,259.9,259.9,271.5,271.5,
112 283.1,283.1,294.7,294.7,201.9,201.9,213.5,213.5,225.1,225.1,
113 236.7,236.7,248.3,248.3,259.9,259.9,271.5,271.5,283.1,283.1,
114 294.7,294.7,306.3,306.3,317.9,317.9,329.6,329.6},
116 { 51.1, 51.1, 62.7, 62.7, 74.3, 74.3, 85.9, 85.9, 97.5, 97.5,
117 109.1,109.1,120.7,120.7,132.3,132.3,143.9,143.9,143.9,143.9,
118 167.1,167.1,178.1,178.1,178.1,178.1,178.1,178.1,213.5,213.5,
119 213.5,213.5,236.7,236.7,236.7,236.7,259.9,259.9,259.9,259.9,
120 283.1,283.1,294.7,294.7,294.7,294.7,294.7,294.7}};
130 declareInterface<ITileCalibTool>(
this );
142 #ifdef TileLaserTimingMonPulse
144 m_h1_time_check =
new TH1F(
"h1_time_check",
"Time(Tfit based) - Time(cispar based)", 1000, -200., 200.);
145 m_h2_time_check =
new TH2F(
"h2_time_check",
"Time(Tfit based) vs Time(cispar based)", 1000, -200., 200., 1000, -200., 200.);
147 m_PulseShapeHigh =
new TProfile(
"pulse_shape_HG",
"pulse shape HG", 400, -200., 300., 0, 100000.);
148 m_PulseShapeLow =
new TProfile(
"pulse_shape_LG",
"pulse shape LG", 400, -200., 300., 0, 100000.);
175 #ifdef TileLaserTimingPMT0Mon
191 #ifdef TileLaserTimingMon
226 #ifdef TileLaserTimingPMT0Mon
227 delete[] m_TimeDiffHighMean;
228 delete[] m_TimeDiffHighMeanError;
229 delete[] m_TimeDiffHighSigma;
230 delete[] m_TimeDiffLowMean;
231 delete[] m_TimeDiffLowMeanError;
232 delete[] m_TimeDiffLowSigma;
233 delete[] m_TimeDiffNoCFCorrMean;
234 delete[] m_TimeDiffNoCFCorrMeanError;
235 delete[] m_TimeDiffNoCFCorrSigma;
240 #ifdef TileLaserTimingMon
276 m_gaussf =
new TF1(
"GainGauss",
"[0]*exp(- (x-[1])*(x-[1])/(2*[2]*[2]))", -60, 60);
291 return StatusCode::SUCCESS;
298 return StatusCode::SUCCESS;
347 float dtime, dtimeNoCFCorr;
349 #ifdef TileLaserTimingMonPulse
350 float f_SampleTime, f_phase1, f_phase2, f_time, f_tfittime;
364 for (; itColl != itCollEnd; ++itColl) {
366 frag = (*itColl)->identify();
368 if (digiCollIt ==
nullptr) {
372 digiColl = digiCollIt;
373 colls = (*itColl)->
size();
375 <<
" digiColl->size:" << digiColl->
size()
376 <<
" drawer:" <<
drawerIdStr((*itColl)->identify()) );
378 if (digiColl->
size() != colls) {
379 ATH_MSG_ERROR(
" size of TileDigitsCollection and TileRawChannelCollection differ for drawer:" <<
drawerIdStr((*itColl)->identify()) );
396 for (
size_t i = 0;
i < colls; ++
i) {
397 digits = digiColl->
at(
i);
398 rawch = (*itColl)->at(
i);
410 if (rawch && digits) {
430 dtimeNoCFCorr = pmtdata.
time - pmt0data.
time;
434 #ifdef TileLaserTimingPMT0
437 if(
gain == 0) pmtdata.TimeDiffHistoLow.Fill(dtime);
438 else pmtdata.TimeDiffHistoHigh.Fill(dtime);
441 #ifdef TileLaserTimingMon
448 #ifdef TileLaserTimingMonPulse
455 for (
unsigned jsample = 0; jsample <
m_nSamples; ++jsample) {
456 f_SampleTime = ((
float) jsample) * 25.;
457 f_phase1 = (25. * ((
float)
phase)) / (30. * 8);
458 f_phase2 = -pmtdata.
time;
459 f_time = f_SampleTime + f_phase1 - 100;
460 f_tfittime = f_SampleTime + f_phase2 - 100;
466 if (phase < 140 || phase > 160) {
469 m_h1_time_check->Fill(f_phase1 - f_phase2);
470 m_h2_time_check->Fill(f_phase1, f_phase2);
473 pmtdata.pulseShapeLow.Fill(f_tfittime, (LG2HG * (
sample[jsample] - rawch->
pedestal())));
478 pmtdata.pulseShapeHigh.Fill(f_tfittime, (
sample[jsample] - rawch->
pedestal()));
496 for (
int ipmt = 0; ipmt < 6; ++ipmt) {
505 #ifdef TileLaserTimingMon
516 for (
int ipmt = 0; ipmt <
NCHANNELS; ipmt++) {
521 ATH_MSG_VERBOSE(
" ipmt:" << ipmt <<
" ChannelOffset:" << ChannelOffset );
550 return StatusCode::SUCCESS;
559 float fmean, fdummy, fchi2, fmeanerr;
565 for (
int ipmt = 0; ipmt <
NCHANNELS; ++ipmt) {
569 #ifdef TileLaserTimingMon
578 #ifdef TileLaserTimingMonPulse
579 if(pmtd.TimeDiffHistoLow.GetEntries() > 0.99 *
m_nevts) {
580 m_PulseShapeLow->Add(&pmtd.pulseShapeLow);
583 if(pmtd.TimeDiffHistoHigh.GetEntries() > 0.99 *
m_nevts) {
584 m_PulseShapeHigh->Add(&pmtd.pulseShapeHigh);
596 #ifdef TileLaserTimingPMT0
630 <<
" has chi2 value " << fchi2
631 <<
" force timing residual same as PMT-1 " );
638 if (fabs(fmean) > 100) {
640 <<
" has ChannelOffset " << fmean
641 <<
" force timing residual same as PMT-1" );
655 #ifdef TileLaserTimingMonPulse
667 <<
" TimeDiffLow: " << m_TimeDiffLowMean[
ros][
drawer][ipmt] <<
"(" << m_TimeDiffLowSigma[
ros][
drawer][ipmt] <<
") +-" << m_TimeDiffLowMeanError[
ros][
drawer][ipmt]
668 <<
" TimeDiffHigh:" << m_TimeDiffHighMean[
ros][
drawer][ipmt] <<
"(" << m_TimeDiffHighSigma[
ros][
drawer][ipmt] <<
") +-" << m_TimeDiffHighMeanError[
ros][
drawer][ipmt] <<
endmsg;
671 <<
" TomeDiffNoCF:" << m_TimeDiffNoCFCorrMean[
ros][
drawer][ipmt] <<
"(" << m_TimeDiffNoCFCorrSigma[
ros][
drawer][ipmt] <<
") +-" << m_TimeDiffNoCFCorrMeanError[
ros][
drawer][ipmt] <<
endmsg;
714 for (
int ipmt = 0; ipmt <
NCHANNELS; ++ipmt) {
728 else if (ipmt > 5 && ipmt < 12) drawerd.
digid[1].
Add(timeDiffs[
ros][
drawer][ipmt]);
729 else if (ipmt > 11 && ipmt < 18) drawerd.
digid[2].
Add(timeDiffs[
ros][
drawer][ipmt]);
730 else if (ipmt > 17 && ipmt < 24) drawerd.
digid[3].
Add(timeDiffs[
ros][
drawer][ipmt]);
731 else if (ipmt > 27 && ipmt < 34) {
734 }
else if (ipmt > 35) {
744 else if (ipmt == 33) {
747 }
else if (ipmt == 47) {
754 for (
int digi = 0; digi <
NDIGI; ++digi) {
770 return StatusCode::SUCCESS;
778 TTree *
t =
new TTree(
m_ntupleID.c_str(),
"TileLaserTimingNtuple");
785 t->Branch(
"ADCAmplitude",
m_ADCAmplitude,
"ADCAmplitude[5][64][48]/F");
787 t->Branch(
"PedestalMean",
m_PedestalMean,
"PedestalMean[5][64][48]/F");
790 t->Branch(
"TimeDiffMean",
m_TimeDiffMean,
"TimeDiffMean[5][64][48]/F");
794 #ifdef TileLaserTimingPMT0Mon
795 t->Branch(
"TimeDiffHighMean", m_TimeDiffHighMean,
"TimeDiffHighMean[5][64][48]/F");
796 t->Branch(
"TimeDiffHighMeanError", m_TimeDiffHighMeanError,
"TimeDiffHighMeanError[5][64][48]/F");
797 t->Branch(
"TimeDiffHighSigma", m_TimeDiffHighSigma,
"TimeDiffHighSigma[5][64][48]/F");
798 t->Branch(
"TimeDiffLowMean", m_TimeDiffLowMean,
"TimeDiffLowMean[5][64][48]/F");
799 t->Branch(
"TimeDiffLowMeanError", m_TimeDiffLowMeanError,
"TimeDiffLowMeanError[5][64][48]/F");
800 t->Branch(
"TimeDiffLowSigma", m_TimeDiffLowSigma,
"TimeDiffLowSigma[5][64][48]/F");
801 t->Branch(
"TimeDiffNoCFCorrMean", m_TimeDiffNoCFCorrMean,
"TimeDiffNoCFCorrMean[5][64][48]/F");
802 t->Branch(
"TimeDiffNoCFCorrMeanError", m_TimeDiffNoCFCorrMeanError,
"TimeDiffNoCFCorrMeanError[5][64][48]/F");
803 t->Branch(
"TimeDiffNoCFCorrSigma", m_TimeDiffNoCFCorrSigma,
"TimeDiffNoCFCorrSigma[5][64][48]/F");
805 t->Branch(
"FiberLength",
m_FiberLength,
"FiberLength[5][64][48]/F");
807 #ifdef TileLaserTimingMon
811 t->Branch(
"IsConnected",
m_IsConnected,
"IsConnected[5][64][48]/F");
829 t->Branch(
"DSkewSet",
m_DSkewSet,
"DSkewSet[5][64][8]/F");
830 t->Branch(
"DigiMean",
m_DigiMean,
"DigiMean[5][64][8]/F");
846 dd->Digi0TimeDiffHisto.Write();
847 #ifdef TileLaserTimingMon
848 dd->Digi0Time.Write();
850 for (
int ipmt = 0; ipmt <
NCHANNELS; ++ipmt) {
854 #ifdef TileLaserTimingMon
855 dd->pmtd[ipmt]->timeHisto.Write();
856 dd->pmtd[ipmt]->eneHisto.Write();
857 dd->pmtd[ipmt]->gainHisto.Write();
863 dd->pmtd[ipmt]->TimeDiffResHis.Write();
870 return StatusCode::SUCCESS;
877 return StatusCode::SUCCESS;
884 return !(ipmt == 31 || ipmt == 32 || ipmt == 43);
886 return !( ipmt == 18 || ipmt == 19 || ipmt == 24 || ipmt == 25
887 || ipmt == 26 || ipmt == 27 || ipmt == 30 || ipmt == 31
888 || ipmt == 34 || ipmt == 35 || ipmt == 38 || ipmt == 39
889 || ipmt == 44 || ipmt == 45 || ipmt == 46 || ipmt == 47);
898 if (hi.GetEntries() == 0) {
899 p1 =
p2 = p1_err = 0.0;
902 double MaxAmplitude = hi.GetMaximum();
903 double MeanTimeDiff = hi.GetMean();
904 double RMSTimeDiff = hi.GetRMS();
905 m_gaussf->SetParameter(0, MaxAmplitude);
906 m_gaussf->SetParameter(1, MeanTimeDiff);
907 m_gaussf->SetParameter(2, RMSTimeDiff);
908 m_gaussf->SetRange(MeanTimeDiff - 2.0 * RMSTimeDiff, MeanTimeDiff + 2.0 * RMSTimeDiff);
919 if (hi.GetEntries() == 0) {
920 p1 =
p2 =
chi2 = p1_err = w1 = w2 = 0.0;
924 double MaxAmplitude = hi.GetMaximum();
925 double MeanTimeDiff = hi.GetMean();
926 double RMSTimeDiff = hi.GetRMS();
928 m_gaussf->SetParameter(0, MaxAmplitude);
929 m_gaussf->SetParameter(1, MeanTimeDiff);
930 m_gaussf->SetParameter(2, RMSTimeDiff);
931 m_gaussf->SetRange(MeanTimeDiff - w1 * RMSTimeDiff, MeanTimeDiff + w1 * RMSTimeDiff);
934 double FittedAmplitude =
m_gaussf->GetParameter(0);
935 double FittedMean =
m_gaussf->GetParameter(1);
936 double FittedSigma =
m_gaussf->GetParameter(2);
940 m_gaussf->SetParameter(0, FittedAmplitude);
941 m_gaussf->SetParameter(1, FittedMean);
942 m_gaussf->SetParameter(2, FittedSigma);
943 m_gaussf->SetRange(FittedMean - w2 * FittedSigma, FittedMean + w2 * FittedSigma);
953 , TDrawerArrayF& MeanOddPmtTdiff, TDrawerArrayI& OddPmtCounter
954 , TDrawerArrayF& MeanEvenPmtTdiff, TDrawerArrayI& EvenPmtCounter
955 , TDrawerArrayF& EvenOddTimeDiff) {
958 float DeltaParity = 0;
963 for (
int ipmt = 0; ipmt <
NCHANNELS; ++ipmt) {
972 <<
" time overflow (" << ChannelOffset[
ros][
drawer][ipmt]
975 <<
" pmt:" << ipmt );
978 }
else if (ipmt % 2 == 0) {
985 <<
" time overflow (" << ChannelOffset[
ros][
drawer][ipmt]
988 <<
" pmt:" << ipmt );
999 EvenOddTimeDiff[
ros][
drawer] = 2 * DeltaParity;
1004 <<
" EvenOddTimeDiff:" << EvenOddTimeDiff[
ros][
drawer]
1005 <<
" | MeanOddPmtTdiff:" << MeanOddPmtTdiff[
ros][
drawer]
1006 <<
" MeanEvenPmtTdiff:" << MeanEvenPmtTdiff[
ros][
drawer]
1007 <<
" DeltaParity:" << DeltaParity );
1012 for (
int ipmt = 0; ipmt <
NCHANNELS; ++ipmt) {
1015 ChannelOffset[
ros][
drawer][ipmt] -= DeltaParity;
1016 else if (ipmt % 2 == 0) ChannelOffset[
ros][
drawer][ipmt] += DeltaParity;