Skip to content

Commit 9f374be

Browse files
committed
Add relevant value to CRTAnalysis module
1 parent d680790 commit 9f374be

1 file changed

Lines changed: 52 additions & 16 deletions

File tree

sbndcode/CRT/CRTAna/CRTAnalysis_module.cc

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class sbnd::crt::CRTAnalysis : public art::EDAnalyzer {
8787
const art::Handle<std::vector<CRTSpacePoint>> &CRTSpacePointModuleLabel, const art::Handle<std::vector<recob::PFParticle>> &PFPHandle,
8888
const std::map<CRTBackTrackerAlg::Category, bool> &spacePointRecoStatusMap = {}, const std::map<int, std::pair<bool, bool>> &trackRecoStatusMap = {});
8989

90+
double SPTimeDelta(std::vector<std::pair<int, double>> &time_set);
91+
9092
private:
9193

9294
CRTGeoAlg fCRTGeoAlg;
@@ -217,6 +219,8 @@ class sbnd::crt::CRTAnalysis : public art::EDAnalyzer {
217219
std::vector<double> _cl_sp_ets0;
218220
std::vector<double> _cl_sp_ts1;
219221
std::vector<double> _cl_sp_ets1;
222+
std::vector<double> _cl_sp_dts0;
223+
std::vector<double> _cl_sp_dts1;
220224
std::vector<bool> _cl_sp_complete;
221225

222226
//backtrack truth information from reco level
@@ -476,6 +480,8 @@ sbnd::crt::CRTAnalysis::CRTAnalysis(fhicl::ParameterSet const& p)
476480
fTree->Branch("cl_sp_ets0", "std::vector<double>", &_cl_sp_ets0);
477481
fTree->Branch("cl_sp_ts1", "std::vector<double>", &_cl_sp_ts1);
478482
fTree->Branch("cl_sp_ets1", "std::vector<double>", &_cl_sp_ets1);
483+
fTree->Branch("cl_sp_dts0", "std::vector<double>", &_cl_sp_dts0);
484+
fTree->Branch("cl_sp_dts1", "std::vector<double>", &_cl_sp_dts1);
479485
fTree->Branch("cl_sp_complete", "std::vector<bool>", &_cl_sp_complete);
480486

481487
if(!fDataMode)
@@ -1144,6 +1150,8 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
11441150
_cl_sp_ets0.resize(nClusters);
11451151
_cl_sp_ts1.resize(nClusters);
11461152
_cl_sp_ets1.resize(nClusters);
1153+
_cl_sp_dts0.resize(nClusters);
1154+
_cl_sp_dts1.resize(nClusters);
11471155
_cl_sp_complete.resize(nClusters);
11481156

11491157
for(unsigned i = 0; i < nClusters; ++i)
@@ -1162,12 +1170,14 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
11621170
const auto striphits = clustersToStripHits.at(cluster.key());
11631171
_cl_channel_set[i].resize(_cl_nhits[i]);
11641172
_cl_adc_set[i].resize(2 * _cl_nhits[i]);
1165-
_cl_sh_ts0_set[i].resize(_cl_nhits[i] );
1166-
_cl_sh_ts1_set[i].resize(_cl_nhits[i] );
1173+
_cl_sh_ts0_set[i].resize(_cl_nhits[i]);
1174+
_cl_sh_ts1_set[i].resize(_cl_nhits[i]);
11671175
_cl_sh_feb_mac5_set[i].resize(_cl_nhits[i]);
11681176
_cl_sh_time_walk_set[i].resize(_cl_nhits[i]);
11691177
_cl_sh_prop_delay_set[i].resize(_cl_nhits[i]);
11701178

1179+
std::vector<std::pair<int, double>> ts0_set, ts1_set;
1180+
11711181
for(unsigned ii = 0; ii < _cl_nhits[i]; ++ii)
11721182
{
11731183
const auto striphit = striphits[ii];
@@ -1192,24 +1202,28 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
11921202
* Because the Ts0(), Ts1() getters invoked in _cl_sp_ts*, _cl_sh_ts*_set are raw T0/1
11931203
* counters, the time walk and propagation delay are saved as explicit branches here.
11941204
*/
1195-
if(spacepoints.size() == 1) { // need unique position of spacepoint
1196-
double pe0 = fCRTGeoAlg.GetSiPM( striphit->Channel() ).gain * striphit->ADC1();
1197-
double pe1 = fCRTGeoAlg.GetSiPM( striphit->Channel() + 1 ).gain * striphit->ADC2();
1198-
double pe = pe0 + pe1;
1199-
1200-
double dist = fCRTGeoAlg.DistanceDownStrip( spacepoints[0]->Pos(), striphit->Channel() );
1205+
if(spacepoints.size() == 1)
1206+
{
1207+
double pe0 = fCRTGeoAlg.GetSiPM( striphit->Channel() ).gain * striphit->ADC1();
1208+
double pe1 = fCRTGeoAlg.GetSiPM( striphit->Channel() + 1 ).gain * striphit->ADC2();
1209+
double pe = pe0 + pe1;
12011210

1202-
double corr = std::pow( dist - fPEAttenuation, 2.0 ) / std::pow( fPEAttenuation, 2.0 );
1203-
double tw_pe = pe * corr;
1211+
double dist = fCRTGeoAlg.DistanceDownStrip( spacepoints[0]->Pos(), striphit->Channel() );
12041212

1205-
_cl_sh_time_walk_set[i][ii] = fTimeWalkNorm * std::exp( -fTimeWalkScale * tw_pe );
1206-
_cl_sh_prop_delay_set[i][ii] = fPropDelay * dist;
1213+
double corr = std::pow( dist - fPEAttenuation, 2.0 ) / std::pow( fPEAttenuation, 2.0 );
1214+
double tw_pe = pe * corr;
12071215

1208-
} else { // fill with nonsense
1209-
_cl_sh_time_walk_set[i][ii] = -999999.;
1210-
_cl_sh_prop_delay_set[i][ii] = -999999.;
1211-
}
1216+
_cl_sh_time_walk_set[i][ii] = fTimeWalkNorm * std::exp( -fTimeWalkScale * tw_pe );
1217+
_cl_sh_prop_delay_set[i][ii] = fPropDelay * dist;
12121218

1219+
ts0_set.push_back({_cl_sh_feb_mac5_set[i][ii], _cl_sh_ts0_set[i][ii] - _cl_sh_time_walk_set[i][ii] - _cl_sh_prop_delay_set[i][ii]});
1220+
ts1_set.push_back({_cl_sh_feb_mac5_set[i][ii], _cl_sh_ts1_set[i][ii] - _cl_sh_time_walk_set[i][ii] - _cl_sh_prop_delay_set[i][ii]});
1221+
}
1222+
else
1223+
{
1224+
_cl_sh_time_walk_set[i][ii] = -999999.;
1225+
_cl_sh_prop_delay_set[i][ii] = -999999.;
1226+
}
12131227
}
12141228

12151229
if(!fDataMode)
@@ -1249,6 +1263,8 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
12491263
_cl_sp_ets0[i] = spacepoint->Ts0Err();
12501264
_cl_sp_ts1[i] = spacepoint->Ts1();
12511265
_cl_sp_ets1[i] = spacepoint->Ts1Err();
1266+
_cl_sp_dts0[i] = SPTimeDelta(ts0_set);
1267+
_cl_sp_dts1[i] = SPTimeDelta(ts1_set);
12521268
_cl_sp_complete[i] = spacepoint->Complete();
12531269
}
12541270
else
@@ -1265,6 +1281,8 @@ void sbnd::crt::CRTAnalysis::AnalyseCRTClusters(const art::Event &e, const std::
12651281
_cl_sp_ets0[i] = -999999.;
12661282
_cl_sp_ts1[i] = -999999.;
12671283
_cl_sp_ets1[i] = -999999.;
1284+
_cl_sp_dts0[i] = -999999.;
1285+
_cl_sp_dts1[i] = -999999.;
12681286
_cl_sp_complete[i] = false;
12691287
}
12701288
}
@@ -1665,4 +1683,22 @@ void sbnd::crt::CRTAnalysis::AnalyseTPCMatching(const art::Event &e, const art::
16651683
_tpc_tr_score.resize(nActualTracks);
16661684
}
16671685

1686+
double sbnd::crt::CRTAnalysis::SPTimeDelta(std::vector<std::pair<int, double>> &time_set)
1687+
{
1688+
std::sort(time_set.begin(), time_set.end(), [](auto &a, auto &b)
1689+
{ return a.first < b.first; });
1690+
1691+
double sum = 0;
1692+
1693+
for(unsigned int i = 0; i < time_set.size(); ++i)
1694+
{
1695+
for(unsigned int ii = i + 1; ii < time_set.size(); ++ii)
1696+
sum += (time_set[i].second - time_set[ii].second);
1697+
}
1698+
1699+
sum /= (time_set.size() - 1);
1700+
1701+
return sum;
1702+
}
1703+
16681704
DEFINE_ART_MODULE(sbnd::crt::CRTAnalysis)

0 commit comments

Comments
 (0)