7#include "CoralBase/Blob.h"
8#include "CoralBase/AttributeListSpecification.h"
33inline 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)
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
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.)
100 for (
int i = 0; i < 48; ++i) {
101 std::ostringstream sout;
102 sout <<
id <<
'_' << i;
110float 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;
296 ATH_MSG_INFO(
"initNtuple(" << runNumber <<
"," << runType <<
"," << rootFile <<
")" );
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();
367 const auto *digiCollIt = digitsCnt->indexFindPtr(digitsCnt->hashFunc()(frag));
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
450 std::vector<float> sample = digits->
samples();
453 <<
" in:" << sample.size() <<
" expected:" <<
m_nSamples );
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
509 if (
msgLvl(MSG::VERBOSE) && (ros == 1) && (drawer == 1)) {
516 for (
int ipmt = 0; ipmt <
NCHANNELS; ipmt++) {
520 if (
msgLvl(MSG::VERBOSE) && (ros == 1) && (drawer == 1)) {
521 ATH_MSG_VERBOSE(
" ipmt:" << ipmt <<
" ChannelOffset:" << ChannelOffset );
541 if (
msgLvl(MSG::VERBOSE) && (ros == 1) && (drawer == 1)) {
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
601 fitGauss(pmtd.
TimeDiffNoCFCorrHisto, m_TimeDiffNoCFCorrMean[ros][drawer][ipmt], m_TimeDiffNoCFCorrSigma[ros][drawer][ipmt], m_TimeDiffNoCFCorrMeanError[ros][drawer][ipmt]);
608 fitGauss(pmtd.TimeDiffHistoLow, m_TimeDiffLowMean[ros][drawer][ipmt], m_TimeDiffLowSigma[ros][drawer][ipmt], m_TimeDiffLowMeanError[ros][drawer][ipmt]);
612 fitGauss(pmtd.TimeDiffHistoHigh, m_TimeDiffHighMean[ros][drawer][ipmt], m_TimeDiffHighSigma[ros][drawer][ipmt], m_TimeDiffHighMeanError[ros][drawer][ipmt]);
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
661 m_ADCAmplitude[ros][drawer][ipmt] = fmax(pmtd.pulseShapeHigh.GetMaximum(), pmtd.pulseShapeLow.GetMaximum());
665 if (
msgLvl(MSG::VERBOSE) && (ros == 1) && (drawer == 1)) {
666 msg(MSG::VERBOSE) <<
"ipmt: " << ipmt
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;
688 <<
" drawer:" << drawer
714 for (
int ipmt = 0; ipmt <
NCHANNELS; ++ipmt) {
717 if (
isConnectedPMT(ros, ipmt) && (timeDiffs[ros][drawer][ipmt] < 300)) {
718 drawerd.
digid[ipmt / 6].
Add(timeDiffs[ros][drawer][ipmt]);
726 if (
isConnectedPMT(ros, ipmt) && (timeDiffs[ros][drawer][ipmt] < 300)) {
727 if (ipmt < 6) drawerd.
digid[0].
Add(timeDiffs[ros][drawer][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) {
732 drawerd.
digid[4].
Add(timeDiffs[ros][drawer][ipmt]);
733 drawerd.
digid[5].
Add(timeDiffs[ros][drawer][ipmt]);
734 }
else if (ipmt > 35) {
735 drawerd.
digid[6].
Add(timeDiffs[ros][drawer][ipmt]);
736 drawerd.
digid[7].
Add(timeDiffs[ros][drawer][ipmt]);
744 else if (ipmt == 33) {
747 }
else if (ipmt == 47) {
754 for (
int digi = 0; digi <
NDIGI; ++digi) {
760 <<
" drawer: " << drawer
764 <<
" DSkewSet: " <<
m_DSkewSet[ros][drawer][digi] );
770 return StatusCode::SUCCESS;
775 ATH_MSG_INFO(
"writeNtuple(" << runNumber <<
"," << runType <<
"," << rootFile <<
")" );
778 TTree *t =
new TTree(
m_ntupleID.c_str(),
"TileLaserTimingNtuple");
779 t->Branch(
"DrawerOffset",
m_DrawerOffset,
"DrawerOffset[5][64]/F");
782 t->Branch(
"ChannelOffset",
m_ChannelOffset,
"ChannelOffset[5][64][48]/F");
785 t->Branch(
"ADCAmplitude",
m_ADCAmplitude,
"ADCAmplitude[5][64][48]/F");
787 t->Branch(
"PedestalMean",
m_PedestalMean,
"PedestalMean[5][64][48]/F");
788 t->Branch(
"PedestalSigma",
m_PedestalSigma,
"PedestalSigma[5][64][48]/F");
790 t->Branch(
"TimeDiffMean",
m_TimeDiffMean,
"TimeDiffMean[5][64][48]/F");
792 t->Branch(
"TimeDiffSigma",
m_TimeDiffSigma,
"TimeDiffSigma[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");
835 ATH_MSG_INFO(
"writeNtuple(" << runNumber <<
"," << runType <<
"," << rootFile <<
") data written" );
842 ATH_MSG_VERBOSE(
"writeNtuple() ros:" << ros <<
" drawer:" << drawer );
847#ifdef TileLaserTimingMon
850 for (
int ipmt = 0; ipmt <
NCHANNELS; ++ipmt) {
854#ifdef TileLaserTimingMon
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);
958 float DeltaParity = 0;
963 for (
int ipmt = 0; ipmt <
NCHANNELS; ++ipmt) {
967 if (fabs(ChannelOffset[ros][drawer][ipmt]) <
m_maxTimeDiff) {
968 MeanOddPmtTdiff[ros][drawer] += ChannelOffset[ros][drawer][ipmt];
969 ++OddPmtCounter[ros][drawer];
972 <<
" time overflow (" << ChannelOffset[ros][drawer][ipmt]
975 <<
" pmt:" << ipmt );
978 }
else if (ipmt % 2 == 0) {
980 if (fabs(ChannelOffset[ros][drawer][ipmt]) <
m_maxTimeDiff) {
981 MeanEvenPmtTdiff[ros][drawer] += ChannelOffset[ros][drawer][ipmt];
982 ++EvenPmtCounter[ros][drawer];
985 <<
" time overflow (" << ChannelOffset[ros][drawer][ipmt]
988 <<
" pmt:" << ipmt );
995 MeanOddPmtTdiff[ros][drawer] /= (float) OddPmtCounter[ros][drawer];
996 MeanEvenPmtTdiff[ros][drawer] /= (float) EvenPmtCounter[ros][drawer];
997 DeltaParity = 0.5 * (MeanOddPmtTdiff[ros][drawer] - MeanEvenPmtTdiff[ros][drawer]);
999 EvenOddTimeDiff[ros][drawer] = 2 * DeltaParity;
1003 <<
" drawer:" << drawer
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;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
char data[hepevt_bytes_allocation_ATLAS]
Handle class for reading from StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
static const TileCablingService * getInstance()
get pointer to service instance
static const unsigned int MAX_ROS
Number of ROSs.
static const unsigned int MAX_DRAWER
Number of drawers in ROS 1-4.
const std::vector< float > & samples() const
float pedestal(void) const
float time(int ind=0) const
float amplitude(int ind=0) const
Identifier identify(void) const
HWIdentifier adc_HWID(void) const
void getStat(double &mean, double &sigma)
double chi2(TH1 *h0, TH1 *h1)