@@ -10,15 +10,14 @@ class BTLUncalibRecHitAlgo : public BTLUncalibratedRecHitAlgoBase {
1010 // / Constructor
1111 BTLUncalibRecHitAlgo (const edm::ParameterSet& conf, edm::ConsumesCollector& sumes)
1212 : MTDUncalibratedRecHitAlgoBase<BTLDataFrame>(conf, sumes),
13- adcNBits_ (conf.getParameter<uint32_t >(" adcNbits" )),
14- adcSaturation_ (conf.getParameter<double >(" adcSaturation" )),
15- adcLSB_ (adcSaturation_ / (1 << adcNBits_)),
16- toaLSBToNS_ (conf.getParameter<double >(" toaLSB_ns" )),
13+ invLightSpeedLYSO_ (conf.getParameter<double >(" invLightSpeedLYSO" )),
14+ c_LYSO_ (1 . / invLightSpeedLYSO_),
15+ npeToADC_ (conf.getParameter<std::vector<double >>(" npeToADC" )),
16+ npePerMeV_ (conf.getParameter<double >(" npePerMeV" )),
17+ invADCPerMeV_ (1 . / (npeToADC_[1 ] * npePerMeV_)),
18+ tdc_to_ns_ (conf.getParameter<double >(" tdcLSB_ns" )),
1719 timeError_ (conf.getParameter<std::string>(" timeResolutionInNs" )),
18- timeCorr_p0_ (conf.getParameter<double >(" timeCorr_p0" )),
19- timeCorr_p1_ (conf.getParameter<double >(" timeCorr_p1" )),
20- timeCorr_p2_ (conf.getParameter<double >(" timeCorr_p2" )),
21- c_LYSO_ (conf.getParameter<double >(" c_LYSO" )) {}
20+ timeWalkCorr_ (conf.getParameter<std::string>(" timeWalkCorrection" )) {}
2221
2322 // / Destructor
2423 ~BTLUncalibRecHitAlgo () override {}
@@ -31,26 +30,20 @@ class BTLUncalibRecHitAlgo : public BTLUncalibratedRecHitAlgoBase {
3130 FTLUncalibratedRecHit makeRecHit (const BTLDataFrame& dataFrame) const final ;
3231
3332private:
34- const uint32_t adcNBits_;
35- const double adcSaturation_;
36- const double adcLSB_;
37- const double toaLSBToNS_;
38- const reco::FormulaEvaluator timeError_;
39- const double timeCorr_p0_;
40- const double timeCorr_p1_;
41- const double timeCorr_p2_;
33+ const double invLightSpeedLYSO_;
4234 const double c_LYSO_;
35+ const std::vector<double > npeToADC_;
36+ const double npePerMeV_;
37+ const double invADCPerMeV_;
38+ const double tdc_to_ns_;
39+ const reco::FormulaEvaluator timeError_;
40+ const reco::FormulaEvaluator timeWalkCorr_;
4341};
4442
4543FTLUncalibratedRecHit BTLUncalibRecHitAlgo::makeRecHit (const BTLDataFrame& dataFrame) const {
46- // The reconstructed amplitudes and times are saved in a std::pair
47- // BTL tile geometry (1 SiPM): only the first value of the amplitude
48- // and time pairs is used.
49- // BTL bar geometry (2 SiPMs): both values of the amplitude and
50- // time pairs are filled.
51-
52- std::pair<float , float > amplitude (0 ., 0 .);
53- std::pair<float , float > time (0 ., 0 .);
44+ // The reconstructed amplitudes and times of the right and left hits are saved in a std::pair
45+ std::pair<double , double > amplitude (0 ., 0 .);
46+ std::pair<double , double > time (0 ., 0 .);
5447
5548 unsigned char flag = 0 ;
5649
@@ -59,30 +52,37 @@ FTLUncalibratedRecHit BTLUncalibRecHitAlgo::makeRecHit(const BTLDataFrame& dataF
5952
6053 double nHits = 0 .;
6154
62- LogDebug (" BTLUncalibRecHit" ) << " Original input time t1,t2 " << float (sampleRight.toa ()) * toaLSBToNS_ << " , "
63- << float (sampleLeft.toa ()) * toaLSBToNS_ << std::endl;
55+ LogDebug (" BTLUncalibRecHit" ) << " Original input time t1, t2 " << double (sampleRight.toa ()) * tdc_to_ns_ << " , "
56+ << double (sampleLeft.toa ()) * tdc_to_ns_ << std::endl;
6457
58+ // --- Reconstruct amplitude and time of the crystal's right channel
6559 if (sampleRight.data () > 0 ) {
66- amplitude.first = float (sampleRight.data ()) * adcLSB_;
67- time.first = float (sampleRight.toa ()) * toaLSBToNS_;
60+ // Correct the time of the right SiPM for the time-walk
61+ amplitude.first = double (sampleRight.data ());
62+ time.first = double (sampleRight.toa ()) -
63+ timeWalkCorr_.evaluate (std::array<double , 1 >{{amplitude.first }}, std::array<double , 1 >{{0.0 }});
6864
69- nHits += 1 .;
65+ // Convert ADC counts to MeV and TDC counts to ns
66+ amplitude.first = (double (sampleRight.data ()) - npeToADC_[0 ]) * invADCPerMeV_;
67+ time.first *= tdc_to_ns_;
7068
71- // Correct the time of the left SiPM for the time-walk
72- time.first -= timeCorr_p0_ * pow (amplitude.first , timeCorr_p1_) + timeCorr_p2_;
7369 flag |= 0x1 ;
70+ nHits += 1 .;
7471 }
7572
76- // --- If available, reconstruct the amplitude and time of the second SiPM
73+ // --- Reconstruct amplitude and time of the crystal's left channel
7774 if (sampleLeft.data () > 0 ) {
78- amplitude.second = float (sampleLeft.data ()) * adcLSB_;
79- time.second = float (sampleLeft.toa ()) * toaLSBToNS_;
75+ // Correct the time of the left SiPM for the time-walk
76+ amplitude.second = double (sampleLeft.data ());
77+ time.second = double (sampleLeft.toa ()) -
78+ timeWalkCorr_.evaluate (std::array<double , 1 >{{amplitude.second }}, std::array<double , 1 >{{0.0 }});
8079
81- nHits += 1 .;
80+ // Convert ADC counts to MeV and TDC counts to ns
81+ amplitude.second = (double (sampleLeft.data ()) - npeToADC_[0 ]) * invADCPerMeV_;
82+ time.second *= tdc_to_ns_;
8283
83- // Correct the time of the right SiPM for the time-walk
84- time.second -= timeCorr_p0_ * pow (amplitude.second , timeCorr_p1_) + timeCorr_p2_;
8584 flag |= (0x1 << 1 );
85+ nHits += 1 .;
8686 }
8787
8888 // --- Calculate the error on the hit time using the provided parameterization
@@ -95,16 +95,16 @@ FTLUncalibratedRecHit BTLUncalibRecHitAlgo::makeRecHit(const BTLDataFrame& dataF
9595 // Calculate the position
9696 // Distance from center of bar to hit
9797
98- float position = 0 .5f * (c_LYSO_ * (time.second - time.first ));
99- float positionError = BTLRecHitsErrorEstimatorIM::positionError ();
98+ double position = 0 .5f * (c_LYSO_ * (time.second - time.first ));
99+ double positionError = BTLRecHitsErrorEstimatorIM::positionError ();
100100
101101 LogDebug (" BTLUncalibRecHit" ) << " DetId: " << dataFrame.id ().rawId () << " x position = " << position << " +/- "
102102 << positionError;
103103 LogDebug (" BTLUncalibRecHit" ) << " ADC+: set the charge to: (" << amplitude.first << " , " << amplitude.second << " ) ("
104- << sampleRight.data () << " , " << sampleLeft.data () << " ) " << adcLSB_ << ' '
104+ << sampleRight.data () << " , " << sampleLeft.data () << " ) " << invADCPerMeV_ << ' '
105105 << std::endl;
106106 LogDebug (" BTLUncalibRecHit" ) << " TDC+: set the time to: (" << time.first << " , " << time.second << " ) ("
107- << sampleRight.toa () << " , " << sampleLeft.toa () << " ) " << toaLSBToNS_ << ' '
107+ << sampleRight.toa () << " , " << sampleLeft.toa () << " ) " << tdc_to_ns_ << ' '
108108 << std::endl;
109109
110110 return FTLUncalibratedRecHit (
0 commit comments