40 std::vector<std::vector<art::Ptr<sbn::crt::CRTHit>>> crtTzeroVect;
41 std::vector<int> iflag(hits.size(), 0);
44 std::sort(hits.begin(), hits.end(), [](
auto&
left,
auto&
right)->
bool{
48 for(
size_t i = 0; i<hits.size(); i++){
50 std::vector<art::Ptr<sbn::crt::CRTHit>> crtTzero;
51 double time_ns_A = hits[i]->ts1_ns;
53 crtTzero.push_back(hits[i]);
57 for(
size_t j = i+1; j<hits.size(); j++){
60 double time_ns_B = hits[j]->ts1_ns;
61 double diff =
std::abs(time_ns_B - time_ns_A) * 1
e-3;
64 crtTzero.push_back(hits[j]);
69 crtTzeroVect.push_back(crtTzero);
108 newtr.
length = sqrt(deltax*deltax + deltay*deltay+deltaz*deltaz);
109 newtr.
thetaxy = atan2(deltax,deltay);
110 newtr.
phizy = atan2(deltaz,deltay);
123 bool complete =
true;
126 if((hit1.
tagger ==
"volTaggerTopHigh_0" && hit2.
tagger ==
"volTaggerTopLow_0")
127 || (hit2.
tagger ==
"volTaggerTopHigh_0" && hit1.
tagger ==
"volTaggerTopLow_0")) complete =
false;
133 TVector3 min (crtLimits[0], crtLimits[1], crtLimits[2]);
134 TVector3 max (crtLimits[3], crtLimits[4], crtLimits[5]);
139 if(intersection.first.X() == -99999)
return FillCrtTrack(hit1, hit2, complete);
141 hit1.
x_pos = intersection.first.X();
142 hit1.
y_pos = intersection.first.Y();
143 hit1.
z_pos = intersection.first.Z();
147 hit2.
x_pos = intersection.second.X();
148 hit2.
y_pos = intersection.second.Y();
149 hit2.
z_pos = intersection.second.Z();
163 std::vector<std::pair<sbn::crt::CRTHit, std::vector<int>>> returnHits;
164 std::vector<art::Ptr<sbn::crt::CRTHit>> aveHits;
165 std::vector<art::Ptr<sbn::crt::CRTHit>> spareHits;
170 TVector3 middle(0., 0., 0.);
171 for (
size_t i = 0; i < hits.size(); i++){
173 TVector3 pos(hits[i]->x_pos, hits[i]->y_pos, hits[i]->z_pos);
181 aveHits.push_back(hits[i]);
185 spareHits.push_back(hits[i]);
190 std::vector<int> ids;
191 for(
size_t i = 0; i < aveHits.size(); i++){
192 ids.push_back(hitIds[aveHits[i]]);
194 returnHits.push_back(std::make_pair(aveHit, ids));
197 std::vector<std::pair<sbn::crt::CRTHit, std::vector<int>>> moreHits =
AverageHits(spareHits, hitIds);
198 returnHits.insert(returnHits.end(), moreHits.begin(), moreHits.end());
211 std::map<art::Ptr<sbn::crt::CRTHit>,
int> dummy;
212 for(
size_t i = 0; i < hits.size(); i++){
216 std::vector<std::pair<sbn::crt::CRTHit, std::vector<int>>>
output =
AverageHits(hits, dummy);
218 std::vector<sbn::crt::CRTHit> returnHits;
219 for(
auto const& out : output){
220 returnHits.push_back(out.first);
234 std::string
tagger = hits[0]->tagger;
238 double xmax = -99999;
double xmin = 99999;
239 double ymax = -99999;
double ymin = 99999;
240 double zmax = -99999;
double zmin = 99999;
245 for(
auto&
hit : hits ){
250 ts1_ns += (double)(
int)
hit->ts1_ns;
252 if(
hit->x_pos +
hit->x_err > xmax) xmax =
hit->x_pos +
hit->x_err;
253 if(
hit->x_pos -
hit->x_err < xmin) xmin =
hit->x_pos -
hit->x_err;
254 if(
hit->y_pos +
hit->y_err > ymax) ymax =
hit->y_pos +
hit->y_err;
255 if(
hit->y_pos -
hit->y_err < ymin) ymin =
hit->y_pos -
hit->y_err;
256 if(
hit->z_pos +
hit->z_err > zmax) zmax =
hit->z_pos +
hit->z_err;
257 if(
hit->z_pos -
hit->z_err < zmin) zmin =
hit->z_pos -
hit->z_err;
264 (ts1_ns/nhits)*1
e-3, 0, xpos/nhits, (xmax-xmin)/2,
265 ypos/nhits, (ymax-ymin)/2., zpos/nhits, (zmax-zmin)/2., tagger);
276 std::vector<std::pair<sbn::crt::CRTTrack, std::vector<int>>> returnTracks;
278 std::vector<std::vector<size_t>> trackCandidates;
280 for(
size_t i = 0; i < hits.size(); i++){
283 for(
size_t j = i+1; j < hits.size(); j++){
284 if(hits[i].
first.tagger == hits[j].first.tagger)
continue;
287 TVector3 start (hits[i].
first.x_pos, hits[i].first.y_pos, hits[i].first.z_pos);
288 TVector3
end (hits[j].
first.x_pos, hits[j].first.y_pos, hits[j].first.z_pos);
289 TVector3 diff = end - start;
291 std::vector<size_t> candidate {i, j};
294 for(
size_t k = 0;
k < hits.size();
k++){
295 if(
k == i ||
k == j || hits[
k].
first.tagger == hits[i].first.tagger
296 || hits[
k].first.tagger == hits[j].first.tagger)
continue;
300 candidate.push_back(
k);
303 trackCandidates.push_back(candidate);
308 std::sort(trackCandidates.begin(), trackCandidates.end(), [](
auto&
left,
auto&
right){
312 std::vector<size_t> usedHits;
313 for(
auto const& candidate : trackCandidates){
316 for(
size_t i = 0; i < candidate.size(); i++){
318 if(std::find(usedHits.begin(), usedHits.end(), candidate[i]) != usedHits.end()) used =
true;
323 if(candidate.size() < 2)
continue;
328 std::vector<int> ids;
331 for(
size_t i = 0; i < candidate.size(); i++){
332 ids.insert(ids.end(), hits[candidate[i]].second.begin(), hits[candidate[i]].second.end());
333 if(candidate.size()>2) usedHits.push_back(candidate[i]);
336 returnTracks.push_back(std::make_pair(crtTrack, ids));
348 std::vector<std::pair<sbn::crt::CRTHit, std::vector<int>>> input;
349 for(
auto const&
hit : hits){
350 std::vector<int> dummy;
351 input.push_back(std::make_pair(
hit, dummy));
354 std::vector<std::pair<sbn::crt::CRTTrack, std::vector<int>>>
output =
CreateTracks(input);
356 std::vector<sbn::crt::CRTTrack>
tracks;
357 for(
auto const& out : output){
358 tracks.push_back(out.first);
float z_err
position uncertainty in z-direction (cm).
float x_err
position uncertainty in x-direction (cm).
double ts0_ns_err_h2
T0 time error of second CRTHit.
double ts1_ns_err
Error on average T1 (nanosecond) of the two hits making the track.
double ts0_s
Average time (second) of the two hits making the track.
ClusterModuleLabel join with tracks
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
double ts0_ns_err
Error on average T0 (nanosecond) of the two hits making the track.
int plane
Name of the CRT wall (in the form of numbers).
float peshit
Total photo-electron (PE) in a crt hit.
float y_err
position uncertainty in y-direction (cm).
fhicl::Atom< double > AverageHitDistance
std::vector< std::pair< sbn::crt::CRTTrack, std::vector< int > > > CreateTracks(std::vector< std::pair< sbn::crt::CRTHit, std::vector< int >>> hits)
double ts0_s_err
Average time (second) spread of the two hits making the track.
float x1_pos
X position of first CRTHit.
std::vector< std::pair< sbn::crt::CRTHit, std::vector< int > > > AverageHits(std::vector< art::Ptr< sbn::crt::CRTHit >> hits, std::map< art::Ptr< sbn::crt::CRTHit >, int > hitIds)
float y1_err
Y position error of first CRTHit.
double ts0_ns_corr
[Honestly, not sure at this point, it was there since long time (BB)]
double ts0_ns_h1
T0 time of first CRTHit.
uint64_t ts0_s
Second-only part of timestamp T0.
std::vector< std::vector< art::Ptr< sbn::crt::CRTHit > > > CreateCRTTzeros(std::vector< art::Ptr< sbn::crt::CRTHit >>)
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
float z_pos
position in z-direction (cm).
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
double ts0_ns
Timestamp T0 (from White Rabbit), in UTC absolute time scale in nanoseconds from the Epoch...
double DistToCrtHit(sbn::crt::CRTHit hit, TVector3 start, TVector3 end)
float z1_err
Z position error of first CRTHit.
float y2_err
Y position error of second CRTHit.
double ts1_ns
Average T1 (nanosecond) of the two hits making the track.
fhicl::Atom< double > DistanceLimit
auto end(FixedBins< T, C > const &) noexcept
float length
Track length.
double ts0_ns
Average T0 (nanosecond) of the two hits making the track.
float peshit
Total photoelectrons for this track (sum of PEs from the two CRTHits)
sbn::crt::CRTHit DoAverage(std::vector< art::Ptr< sbn::crt::CRTHit >> hits)
double ts0_ns_err_h1
T0 time error of first CRTHit.
bool complete
Whether or not the track is complete.
void reconfigure(const Config &config)
float z1_pos
Z position of first CRTHit.
double ts0_ns_h2
T0 time of second CRTHit.
float y_pos
position in y-direction (cm).
sbn::crt::CRTTrack FillCrtTrack(sbn::crt::CRTHit hit1, sbn::crt::CRTHit hit2, bool complete)
sbn::crt::CRTHit FillCrtHit(std::vector< uint8_t > tfeb_id, std::map< uint8_t, std::vector< std::pair< int, float >>> tpesmap, float peshit, double time, int plane, double x, double ex, double y, double ey, double z, double ez, std::string tagger)
float phizy
Track angle on the Z-Y plane.
fhicl::Atom< double > TimeLimit
double fAverageHitDistance
int plane1
Plane ID of first CRTHit.
float z2_pos
Z position of second CRTHit.
float x_pos
position in x-direction (cm).
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
float y2_pos
Y position of second CRTHit.
float y1_pos
Y position of first CRTHit.
float x2_pos
X position of second CRTHit.
stream1 can override from command line with o or output services user sbnd
std::pair< TVector3, TVector3 > CubeIntersection(TVector3 min, TVector3 max, TVector3 start, TVector3 end)
std::vector< double > CRTLimits() const
float x1_err
X position error of first CRTHit.
std::string tagger
Name of the CRT wall (in the form of strings).
int plane2
Plane ID of second CRTHit.
float z2_err
Z position error of second CRTHit.
float x2_err
X position error of second CRTHit.
CRTTrackRecoAlg(const Config &config)
float thetaxy
Track angle on the X-Y plane.