Skip to content

Commit c7a91a3

Browse files
authored
Merge pull request #49221 from casarsa/mc-btlnewdigi_squash
Update of the BTL digitization model
2 parents 4b8e6bc + dffb4e9 commit c7a91a3

File tree

19 files changed

+1170
-918
lines changed

19 files changed

+1170
-918
lines changed

RecoLocalFastTime/FTLCommonAlgos/interface/MTDTimeCalib.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ class MTDTimeCalib {
2020
private:
2121
const MTDGeometry* geom_;
2222
const MTDTopology* topo_;
23-
float btlTimeOffset_;
24-
float etlTimeOffset_;
2523

2624
//specific paramters from BTL simulation
27-
float btlLightCollTime_;
2825
float btlLightCollSlope_;
2926
};
3027

RecoLocalFastTime/FTLCommonAlgos/plugins/BTLUncalibRecHitAlgo.cc

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3332
private:
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

4543
FTLUncalibratedRecHit 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(

RecoLocalFastTime/FTLCommonAlgos/plugins/MTDRecHitAlgo.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ FTLRecHit MTDRecHitAlgo::makeRecHit(const FTLUncalibratedRecHit& uRecHit, uint32
7474
}
7575
}
7676

77-
// --- Energy calibration: for the time being this is just a conversion pC --> MeV
77+
// --- Energy calibration
7878
energy *= calibration_;
7979

8080
// --- Time calibration: for the time being just removes a time offset in BTL

RecoLocalFastTime/FTLCommonAlgos/src/MTDTimeCalib.cc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99
#include "Geometry/MTDCommonData/interface/MTDTopologyMode.h"
1010

1111
MTDTimeCalib::MTDTimeCalib(edm::ParameterSet const& conf, const MTDGeometry* geom, const MTDTopology* topo)
12-
: geom_(geom),
13-
topo_(topo),
14-
btlTimeOffset_(conf.getParameter<double>("BTLTimeOffset")),
15-
etlTimeOffset_(conf.getParameter<double>("ETLTimeOffset")),
16-
btlLightCollTime_(conf.getParameter<double>("BTLLightCollTime")),
17-
btlLightCollSlope_(conf.getParameter<double>("BTLLightCollSlope")) {}
12+
: geom_(geom), topo_(topo), btlLightCollSlope_(conf.getParameter<double>("BTLLightCollSlope")) {}
1813

1914
float MTDTimeCalib::getTimeCalib(const MTDDetId& id) const {
2015
if (id.subDetector() != MTDDetId::FastTime) {
@@ -25,7 +20,6 @@ float MTDTimeCalib::getTimeCalib(const MTDDetId& id) const {
2520
float time_calib = 0.;
2621

2722
if (id.mtdSubDetector() == MTDDetId::BTL) {
28-
time_calib += btlTimeOffset_;
2923
BTLDetId hitId(id);
3024
//for BTL topology gives different layout id
3125
DetId geoId = hitId.geographicalId(MTDTopologyMode::crysLayoutFromTopoMode(topo_->getMTDTopologyMode()));
@@ -47,7 +41,7 @@ float MTDTimeCalib::getTimeCalib(const MTDDetId& id) const {
4741
<< "BTL topology mode " << static_cast<int>(btlL) << " unsupported! Aborting";
4842
}
4943
} else if (id.mtdSubDetector() == MTDDetId::ETL) {
50-
time_calib += etlTimeOffset_;
44+
// no correction applied for ETL
5145
} else {
5246
throw cms::Exception("MTDTimeCalib") << "MTDDetId: " << std::hex << id.rawId() << " is invalid!" << std::dec
5347
<< std::endl;

RecoLocalFastTime/FTLRecProducers/plugins/MTDTimeCalibESProducer.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ MTDTimeCalibESProducer::MTDTimeCalibESProducer(const edm::ParameterSet& p) {
4444
// Configuration descriptions
4545
void MTDTimeCalibESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
4646
edm::ParameterSetDescription desc;
47-
desc.add<double>("BTLTimeOffset", 0.)->setComment("Time offset (additive) to all the BTL RecHits [ns]");
48-
desc.add<double>("ETLTimeOffset", 0.)->setComment("Time offset (additive) to all the ETL RecHits [ns]");
49-
desc.add<double>("BTLLightCollTime", 0.2)->setComment("Light collection time for BTL tile geometry [ns]");
50-
desc.add<double>("BTLLightCollSlope", 0.075)
47+
desc.add<double>("BTLLightCollSlope", 0.095)
5148
->setComment("Light collection slope for bar for BTL bar tile geometry [ns/cm]");
5249
descriptions.add("MTDTimeCalibESProducer", desc);
5350
}

RecoLocalFastTime/FTLRecProducers/python/MTDTimeCalibESProducers_cff.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22

33
from RecoLocalFastTime.FTLRecProducers.MTDTimeCalibESProducer_cfi import *
44

5-
# the following numbers are obtained on single pions 0.7-10 GeV noPU
6-
# to have backpropagated time average at 0
7-
MTDTimeCalibESProducer.BTLTimeOffset = cms.double(0.0115)
8-
MTDTimeCalibESProducer.ETLTimeOffset = cms.double(0.0066)
5+
from SimFastTiming.FastTimingCommon.mtdDigitizer_cfi import mtdDigitizer
6+
MTDTimeCalibESProducer.BTLLightCollSlope = mtdDigitizer.barrelDigitizer.DeviceSimulation.LightCollectionSlope

RecoLocalFastTime/FTLRecProducers/python/mtdRecHits_cfi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
_barrelAlgo = cms.PSet(
44
algoName = cms.string("MTDRecHitAlgo"),
5-
thresholdToKeep = cms.double(1.), # MeV
6-
calibrationConstant = cms.double(0.03125), # MeV/pC
5+
thresholdToKeep = cms.double(1.), # [MeV]
6+
calibrationConstant = cms.double(1.)
77
)
88

99

RecoLocalFastTime/FTLRecProducers/python/mtdUncalibratedRecHits_cfi.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,29 @@
22

33
from SimFastTiming.FastTimingCommon.mtdDigitizer_cfi import mtdDigitizer
44

5-
65
_barrelAlgo = cms.PSet(
76
algoName = cms.string("BTLUncalibRecHitAlgo"),
8-
adcNbits = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.adcNbits,
9-
adcSaturation = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.adcSaturation_MIP,
10-
toaLSB_ns = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.toaLSB_ns,
11-
timeResolutionInNs = cms.string("0.308*pow(x,-0.4175)"), # [ns]
12-
timeCorr_p0 = cms.double( 2.21103),
13-
timeCorr_p1 = cms.double(-0.933552),
14-
timeCorr_p2 = cms.double( 0.),
15-
c_LYSO = cms.double(13.846235) # in unit cm/ns
7+
invLightSpeedLYSO = mtdDigitizer.barrelDigitizer.DeviceSimulation.LightCollectionSlope, # [ns/cm]
8+
npeToADC = mtdDigitizer.barrelDigitizer.ElectronicsSimulation.PulseQParam, # Npe to ADC counts conversion
9+
npePerMeV = mtdDigitizer.barrelDigitizer.DeviceSimulation.LightOutput, # [Npe/MeV]
10+
tdcLSB_ns = cms.double(0.020), # [ns]
11+
timeResolutionInNs = cms.string("0.0593858*pow(x,-1.02826)+0.0156719"), # [ns]
12+
timeWalkCorrection = cms.string("1.9e6/0.020*pow(9.389e5/0.0348*(x+22.5),-0.663)-7.5e-4*x-3.5e-3") # linear ad hoc correction for bias from global delay removal
1613
)
1714

18-
1915
_endcapAlgo = cms.PSet(
2016
algoName = cms.string("ETLUncalibRecHitAlgo"),
2117
adcNbits = mtdDigitizer.endcapDigitizer.ElectronicsSimulation.adcNbits,
2218
adcSaturation = mtdDigitizer.endcapDigitizer.ElectronicsSimulation.adcSaturation_MIP,
2319
toaLSB_ns = mtdDigitizer.endcapDigitizer.ElectronicsSimulation.toaLSB_ns,
2420
tofDelay = mtdDigitizer.endcapDigitizer.DeviceSimulation.tofDelay,
2521
timeResolutionInNs = cms.string("0.0370"), # [ns]
26-
timeCorr_p0 = cms.double(0.974683),
22+
timeCorr_p0 = cms.double(0.967683), # 0.974683 - 0.007, ad hoc correction for bias from global delay removal
2723
timeCorr_p1 = cms.double(-0.237274),
2824
timeCorr_p2 = cms.double(0.021455),
2925
timeCorr_p3 = cms.double(-0.000727429)
3026
)
3127

32-
3328
mtdUncalibratedRecHits = cms.EDProducer(
3429
"MTDUncalibratedRecHitProducer",
3530
barrel = _barrelAlgo,

0 commit comments

Comments
 (0)