Skip to content

Commit 601998c

Browse files
Merge pull request #503 from SBNSoftware/feature/hlay_crt_offline_reco
CRT Offline - Reco
2 parents a46a522 + 0c4c952 commit 601998c

8 files changed

Lines changed: 288 additions & 107 deletions

sbndcode/CRT/CRTReco/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ art_make_library(
88
simple_plugin(
99
CRTStripHitProducer module
1010
sbnobj::SBND_CRT
11+
sbnobj::SBND_Timing
1112
sbndcode_GeoWrappers
1213
)
1314

sbndcode/CRT/CRTReco/CRTClusterCharacterisationAlg.cc

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ namespace sbnd::crt {
44

55
CRTClusterCharacterisationAlg::CRTClusterCharacterisationAlg(const fhicl::ParameterSet& pset)
66
: fCRTGeoAlg(pset.get<fhicl::ParameterSet>("CRTGeoAlg"))
7-
, fUseT1(pset.get<bool>("UseT1"))
87
, fTimeOffset(pset.get<double>("TimeOffset"))
98
, fOverlapBuffer(pset.get<double>("OverlapBuffer"))
109
, fPEAttenuation(pset.get<double>("PEAttenuation"))
@@ -14,8 +13,6 @@ namespace sbnd::crt {
1413
{
1514
}
1615

17-
CRTClusterCharacterisationAlg::CRTClusterCharacterisationAlg(){}
18-
1916
CRTClusterCharacterisationAlg::~CRTClusterCharacterisationAlg(){}
2017

2118
CRTSpacePoint CRTClusterCharacterisationAlg::CharacteriseSingleHitCluster(const art::Ptr<CRTCluster> &cluster, const art::Ptr<CRTStripHit> &stripHit)
@@ -27,7 +24,7 @@ namespace sbnd::crt {
2724
geo::Point_t pos, err;
2825
CentralPosition(hitPos, pos, err);
2926

30-
return CRTSpacePoint(pos, err, pe, stripHit->Ts1() + fTimeOffset, 0., false);
27+
return CRTSpacePoint(pos, err, pe, stripHit->Ts0() + fTimeOffset, 0., stripHit->Ts1() + fTimeOffset, 0., false);
3128
}
3229

3330
bool CRTClusterCharacterisationAlg::CharacteriseDoubleHitCluster(const art::Ptr<CRTCluster> &cluster, const std::vector<art::Ptr<CRTStripHit>> &stripHits, CRTSpacePoint &spacepoint)
@@ -52,10 +49,10 @@ namespace sbnd::crt {
5249
CentralPosition(overlap, pos, err);
5350

5451
const double pe = ReconstructPE(hit0, hit1, pos);
55-
double time, etime;
56-
CorrectTime(hit0, hit1, pos, time, etime);
52+
double t0, et0, t1, et1;
53+
CorrectTime(hit0, hit1, pos, t0, et0, t1, et1);
5754

58-
spacepoint = CRTSpacePoint(pos, err, pe, time + fTimeOffset, etime, true);
55+
spacepoint = CRTSpacePoint(pos, err, pe, t0 + fTimeOffset, et0, t1 + fTimeOffset, et1, true);
5956
return true;
6057
}
6158
return false;
@@ -69,11 +66,13 @@ namespace sbnd::crt {
6966
geo::Point_t pos, err;
7067
CentralPosition(overlap, pos, err);
7168

72-
const double pe = ADCToPE(hit0->Channel(), hit0->ADC1(), hit0->ADC2()) + ADCToPE(hit1->Channel(), hit1->ADC1(), hit1->ADC2());
73-
const double time = (hit0->Ts1() + hit1->Ts1()) / 2.;
74-
const double etime = std::abs((double)hit0->Ts1() - (double)hit1->Ts1()) / 2.;
69+
const double pe = ADCToPE(hit0->Channel(), hit0->ADC1(), hit0->ADC2()) + ADCToPE(hit1->Channel(), hit1->ADC1(), hit1->ADC2());
70+
const double t0 = (hit0->Ts0() + hit1->Ts0()) / 2.;
71+
const double t1 = (hit0->Ts1() + hit1->Ts1()) / 2.;
72+
const double et0 = std::abs((double)hit0->Ts0() - (double)hit1->Ts0()) / 2.;
73+
const double et1 = std::abs((double)hit0->Ts1() - (double)hit1->Ts1()) / 2.;
7574

76-
spacepoint = CRTSpacePoint(pos, err, pe, time + fTimeOffset, etime, false);
75+
spacepoint = CRTSpacePoint(pos, err, pe, t0 + fTimeOffset, et0, t1 + fTimeOffset, et1, false);
7776
return true;
7877
}
7978
return false;
@@ -107,21 +106,25 @@ namespace sbnd::crt {
107106
return false;
108107

109108
double pe = 0.;
110-
std::vector<double> times;
109+
std::vector<double> t0s, t1s;
111110

112111
for(auto const &sp : complete_spacepoints)
113112
{
114113
pe += sp.PE();
115-
times.push_back(sp.Time());
114+
t0s.push_back(sp.Ts0());
115+
t1s.push_back(sp.Ts1());
116116
}
117117

118118
geo::Point_t pos, err;
119119
AggregatePositions(complete_spacepoints, pos, err);
120120

121-
double time, etime;
122-
TimeErrorCalculator(times, time, etime);
123-
124-
spacepoint = CRTSpacePoint(pos, err, pe, time, etime, true);
121+
double t0, et0;
122+
TimeErrorCalculator(t0s, t0, et0);
123+
124+
double t1, et1;
125+
TimeErrorCalculator(t1s, t1, et1);
126+
127+
spacepoint = CRTSpacePoint(pos, err, pe, t0, et0, t1, et1, true);
125128
return true;
126129
}
127130

@@ -194,7 +197,7 @@ namespace sbnd::crt {
194197
}
195198

196199
void CRTClusterCharacterisationAlg::CorrectTime(const art::Ptr<CRTStripHit> &hit0, const art::Ptr<CRTStripHit> &hit1, const geo::Point_t &pos,
197-
double &time, double &etime)
200+
double &t0, double &et0, double &t1, double &et1)
198201
{
199202
const double dist0 = fCRTGeoAlg.DistanceDownStrip(pos, hit0->Channel());
200203
const double dist1 = fCRTGeoAlg.DistanceDownStrip(pos, hit1->Channel());
@@ -205,16 +208,11 @@ namespace sbnd::crt {
205208
const double corr0 = TimingCorrectionOffset(dist0, pe0);
206209
const double corr1 = TimingCorrectionOffset(dist1, pe1);
207210

208-
if(fUseT1)
209-
{
210-
time = ((double)hit0->Ts1() - corr0 + (double)hit1->Ts1() - corr1) / 2.;
211-
etime = std::abs(((double)hit0->Ts1() - corr0) - ((double)hit1->Ts1() - corr1)) / 2.;
212-
}
213-
else
214-
{
215-
time = ((double)hit0->Ts0() - corr0 + (double)hit1->Ts0() - corr1) / 2.;
216-
etime = std::abs(((double)hit0->Ts0() - corr0) - ((double)hit1->Ts0() - corr1)) / 2.;
217-
}
211+
t0 = ((double)hit0->Ts0() - corr0 + (double)hit1->Ts0() - corr1) / 2.;
212+
et0 = std::abs(((double)hit0->Ts0() - corr0) - ((double)hit1->Ts0() - corr1)) / 2.;
213+
214+
t1 = ((double)hit0->Ts1() - corr0 + (double)hit1->Ts1() - corr1) / 2.;
215+
et1 = std::abs(((double)hit0->Ts1() - corr0) - ((double)hit1->Ts1() - corr1)) / 2.;
218216
}
219217

220218
double CRTClusterCharacterisationAlg::TimingCorrectionOffset(const double &dist, const double &pe)

sbndcode/CRT/CRTReco/CRTClusterCharacterisationAlg.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ namespace sbnd::crt {
3636
class CRTClusterCharacterisationAlg {
3737
public:
3838

39-
CRTClusterCharacterisationAlg();
40-
4139
CRTClusterCharacterisationAlg(const fhicl::ParameterSet& pset);
4240

4341
~CRTClusterCharacterisationAlg();
@@ -65,7 +63,7 @@ namespace sbnd::crt {
6563
double ReconstructPE(const art::Ptr<CRTStripHit> &hit, const double dist);
6664

6765
void CorrectTime(const art::Ptr<CRTStripHit> &hit0, const art::Ptr<CRTStripHit> &hit1, const geo::Point_t &pos,
68-
double &time, double &etime);
66+
double &t0, double &et0, double &t1, double &et1);
6967

7068
double TimingCorrectionOffset(const double &dist, const double &pe);
7169

sbndcode/CRT/CRTReco/CRTClusterProducer_module.cc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class sbnd::crt::CRTClusterProducer : public art::EDProducer {
5757
std::string fCRTStripHitModuleLabel;
5858
uint32_t fCoincidenceTimeRequirement;
5959
double fOverlapBuffer;
60+
bool fUseTs0;
6061
};
6162

6263

@@ -66,10 +67,11 @@ sbnd::crt::CRTClusterProducer::CRTClusterProducer(fhicl::ParameterSet const& p)
6667
, fCRTStripHitModuleLabel(p.get<std::string>("CRTStripHitModuleLabel"))
6768
, fCoincidenceTimeRequirement(p.get<uint32_t>("CoincidenceTimeRequirement"))
6869
, fOverlapBuffer(p.get<double>("OverlapBuffer"))
69-
{
70-
produces<std::vector<CRTCluster>>();
71-
produces<art::Assns<CRTCluster, CRTStripHit>>();
72-
}
70+
, fUseTs0(p.get<bool>("UseTs0"))
71+
{
72+
produces<std::vector<CRTCluster>>();
73+
produces<art::Assns<CRTCluster, CRTStripHit>>();
74+
}
7375

7476
void sbnd::crt::CRTClusterProducer::produce(art::Event& e)
7577
{
@@ -86,8 +88,8 @@ void sbnd::crt::CRTClusterProducer::produce(art::Event& e)
8688

8789
for(auto& [tagger, stripHits] : taggerStripHitsMap)
8890
{
89-
std::sort(stripHits.begin(), stripHits.end(), [](art::Ptr<CRTStripHit> &a, art::Ptr<CRTStripHit> &b)->bool{
90-
return a->Ts1() < b->Ts1();});
91+
std::sort(stripHits.begin(), stripHits.end(), [&](art::Ptr<CRTStripHit> &a, art::Ptr<CRTStripHit> &b)->bool{
92+
return fUseTs0 ? a->Ts0() < b->Ts0() : a->Ts1() < b->Ts1();});
9193

9294
std::vector<std::pair<CRTCluster, std::vector<art::Ptr<CRTStripHit>>>> clustersAndHits = CreateClusters(stripHits);
9395

@@ -144,7 +146,10 @@ std::vector<std::pair<sbnd::crt::CRTCluster, std::vector<art::Ptr<sbnd::crt::CRT
144146

145147
if(!used[ii])
146148
{
147-
if(stripHit->Ts1() - initialStripHit->Ts1() < fCoincidenceTimeRequirement)
149+
const uint64_t timeDiff = fUseTs0 ? stripHit->Ts0() - initialStripHit->Ts0() :
150+
stripHit->Ts1() - initialStripHit->Ts1();
151+
152+
if(timeDiff < fCoincidenceTimeRequirement)
148153
{
149154
clusteredHits.push_back(stripHit);
150155
used[ii] = true;
@@ -160,7 +165,7 @@ std::vector<std::pair<sbnd::crt::CRTCluster, std::vector<art::Ptr<sbnd::crt::CRT
160165
}
161166

162167
std::vector<std::pair<sbnd::crt::CRTCluster, std::vector<art::Ptr<sbnd::crt::CRTStripHit>>>>
163-
sbnd::crt::CRTClusterProducer::SplitClusters(const std::vector<std::pair<CRTCluster, std::vector<art::Ptr<CRTStripHit>>>> &initialClusters)
168+
sbnd::crt::CRTClusterProducer::SplitClusters(const std::vector<std::pair<CRTCluster, std::vector<art::Ptr<CRTStripHit>>>> &initialClusters)
164169
{
165170
std::vector<std::pair<CRTCluster, std::vector<art::Ptr<CRTStripHit>>>> clustersAndHits;
166171

@@ -237,7 +242,8 @@ sbnd::crt::CRTCluster sbnd::crt::CRTClusterProducer::CharacteriseCluster(const s
237242
const CRTStripGeo strip0 = fCRTGeoAlg.GetStrip(clusteredHits.at(0)->Channel());
238243
const CRTTagger tagger = fCRTGeoAlg.ChannelToTaggerEnum(clusteredHits.at(0)->Channel());
239244

240-
uint32_t ts0 = 0, ts1 = 0, s = 0;
245+
int64_t ts0 = 0, ts1 = 0;
246+
uint64_t s = 0;
241247
CoordSet composition = kUndefinedSet;
242248

243249
for(uint16_t i = 0; i < clusteredHits.size(); ++i)

0 commit comments

Comments
 (0)