38 std::vector<std::vector<art::Ptr<sbn::crt::CRTHit>>> crtTzeroVect;
42 std::sort(hits.begin(), hits.end(), [](
auto&
left,
auto&
right)->
bool{
46 for(
size_t i = 0; i<hits.size(); i++){
49 vector<art::Ptr<sbn::crt::CRTHit>> crtTzero;
50 double time_ns_A = hits[i]->ts0_ns;
52 crtTzero.push_back(hits[i]);
56 for(
size_t j = i+1; j<hits.size(); j++){
61 double time_ns_B = hits[j]->ts0_ns;
62 double diff =
std::abs(time_ns_B - time_ns_A) * 1
e-3;
65 crtTzero.push_back(hits[j]);
70 crtTzeroVect.push_back(crtTzero);
106 newtr.
length = sqrt(deltax*deltax + deltay*deltay+deltaz*deltaz);
107 newtr.
thetaxy = atan2(deltax,deltay);
108 newtr.
phizy = atan2(deltaz,deltay);
120 vector<pair<sbn::crt::CRTHit, vector<int>>> returnHits;
121 vector<art::Ptr<sbn::crt::CRTHit>> aveHits;
122 vector<art::Ptr<sbn::crt::CRTHit>> spareHits;
128 TVector3 middle(0., 0., 0.);
131 for (
size_t i = 0; i < hits.size(); i++){
133 TVector3 pos(hits[i]->x_pos, hits[i]->y_pos, hits[i]->z_pos);
141 aveHits.push_back(hits[i]);
145 spareHits.push_back(hits[i]);
151 if (aveHits.size() > 0){
155 for(
size_t i = 0; i < aveHits.size(); i++){
156 ids.push_back(hitIds[aveHits[i]]);
159 returnHits.push_back(std::make_pair(aveHit, ids));
162 vector<pair<sbn::crt::CRTHit, vector<int>>> moreHits =
AverageHits(spareHits, hitIds);
163 returnHits.insert(returnHits.end(), moreHits.begin(), moreHits.end());
177 vector<sbn::crt::CRTHit> returnHits;
178 vector<art::Ptr<sbn::crt::CRTHit>> aveHits;
179 vector<art::Ptr<sbn::crt::CRTHit>> spareHits;
184 TVector3 middle(0., 0., 0.);
185 for (
size_t i = 0; i < hits.size(); i++){
187 TVector3 pos(hits[i]->x_pos, hits[i]->y_pos, hits[i]->z_pos);
195 aveHits.push_back(hits[i]);
199 spareHits.push_back(hits[i]);
203 returnHits.push_back(aveHit);
206 vector<sbn::crt::CRTHit> moreHits =
AverageHits(spareHits);
207 returnHits.insert(returnHits.end(), moreHits.begin(), moreHits.end());
222 std::string
tagger = hits[0]->tagger;
226 double xmax = -99999;
double xmin = 99999;
227 double ymax = -99999;
double ymin = 99999;
228 double zmax = -99999;
double zmin = 99999;
229 double ts0_ns = 0., ts1_ns = 0.;
233 for(
auto&
hit : hits ){
238 ts0_ns += (double)(
int)
hit->ts0_ns;
239 ts1_ns += (double)(
int)
hit->ts1_ns;
241 if(
hit->x_pos +
hit->x_err > xmax) xmax =
hit->x_pos +
hit->x_err;
242 if(
hit->x_pos -
hit->x_err < xmin) xmin =
hit->x_pos -
hit->x_err;
243 if(
hit->y_pos +
hit->y_err > ymax) ymax =
hit->y_pos +
hit->y_err;
244 if(
hit->y_pos -
hit->y_err < ymin) ymin =
hit->y_pos -
hit->y_err;
245 if(
hit->z_pos +
hit->z_err > zmax) zmax =
hit->z_pos +
hit->z_err;
246 if(
hit->z_pos -
hit->z_err < zmin) zmin =
hit->z_pos -
hit->z_err;
253 (ts0_ns/nhits)*1
e-3, (ts1_ns/nhits)*1
e-3, hits[0]->plane, xpos/nhits, (xmax-xmin)/2,
254 ypos/nhits, (ymax-ymin)/2., zpos/nhits, (zmax-zmin)/2., tagger);
264 vector<pair<sbn::crt::CRTTrack, vector<int>>> returnTracks;
267 vector<pair<pair<size_t, size_t>,
double>> hitPairDist;
268 vector<pair<size_t, size_t>> usedPairs;
271 for(
size_t i = 0; i < hits.size(); i++){
275 for(
size_t j = 0; j < hits.size(); j++){
278 pair<size_t, size_t> hitPair = std::make_pair(i, j);
279 pair<size_t, size_t> rhitPair = std::make_pair(j, i);
282 if(hit1.
tagger!=hit2.
tagger && std::find(usedPairs.begin(), usedPairs.end(), rhitPair)==usedPairs.end()){
286 double dist = (pos1 - pos2).Mag();
287 usedPairs.push_back(hitPair);
288 hitPairDist.push_back(std::make_pair(hitPair, dist));
294 std::sort(hitPairDist.begin(), hitPairDist.end(), [](
auto&
left,
auto&
right){
298 vector<pair<vector<size_t>,
double>>
tracks;
299 for(
size_t i = 0; i < hitPairDist.size(); i++){
301 size_t hit_i = hitPairDist[i].first.first;
302 size_t hit_j = hitPairDist[i].first.second;
305 if(hits[hit_j].
first.tagger==
"volTaggerBot_0") std::swap(hit_i, hit_j);
313 vector<size_t> nhitsMax;
314 double minDist = 99999;
317 for(
int i = 0; i<21; i++){
319 double fac = (i)/10.;
320 vector<size_t> nhits;
321 double totalDist = 0.;
324 TVector3 diff = start -
end;
327 for(
size_t k = 0;
k < hits.size();
k++){
329 if(
k == hit_i ||
k == hit_j || hits[
k].
first.tagger == ihit.
tagger || hits[
k].first.tagger == jhit.
tagger)
336 double dist = (cross-mid).Mag();
346 if(nhits.size()>=nhitsMax.size() && totalDist/nhits.size() < minDist){
349 minDist = totalDist/nhits.size();
355 vector<size_t> trackCand;
356 trackCand.push_back(hit_i);
357 trackCand.push_back(hit_j);
358 trackCand.insert(trackCand.end(), nhitsMax.begin(), nhitsMax.end());
359 tracks.push_back(std::make_pair(trackCand, facMax));
366 TVector3 diff = start -
end;
367 vector<size_t> trackCand;
368 trackCand.push_back(hit_i);
369 trackCand.push_back(hit_j);
372 for(
size_t k = 0;
k < hits.size();
k++){
374 if(
k == hit_i ||
k == hit_j || hits[
k].
first.tagger == ihit.
tagger || hits[
k].first.tagger == jhit.
tagger)
381 double dist = (cross-mid).Mag();
385 trackCand.push_back(
k);
388 tracks.push_back(std::make_pair(trackCand, 1));
393 std::sort(tracks.begin(), tracks.end(), [](
auto&
left,
auto&
right){
394 return left.first.size() >
right.first.size();});
397 vector<size_t> usedHits;
400 for(
auto&
track : tracks){
402 size_t hit_i =
track.first[0];
403 size_t hit_j =
track.first[1];
406 if(hits[hit_j].
first.tagger==
"volTaggerTopHigh_0")
407 std::swap(hit_i, hit_j);
416 for(
size_t i = 0; i <
track.first.size(); i++){
418 if(std::find(usedHits.begin(), usedHits.end(),
track.first[i]) != usedHits.end())
432 if(
track.first.size()==2 && ihit.
tagger ==
"volTaggerTopHigh_0" && jhit.
tagger ==
"volTaggerTopLow_0"){
437 for(
size_t i = 0; i <
track.first.size(); i++){
438 ids.insert(ids.end(), hits[i].second.begin(), hits[i].second.end());
441 returnTracks.push_back(std::make_pair(crtTrack, ids));
446 for(
size_t i = 0; i <
track.first.size(); i++){
447 if(
track.first.size()>2) usedHits.push_back(
track.first[i]);
457 vector<sbn::crt::CRTTrack> returnTracks;
459 vector<pair<pair<size_t, size_t>,
double>> hitPairDist;
460 vector<pair<size_t, size_t>> usedPairs;
463 for(
size_t i = 0; i < hits.size(); i++){
465 for(
size_t j = 0; j < hits.size(); j++){
468 pair<size_t, size_t> hitPair = std::make_pair(i, j);
469 pair<size_t, size_t> rhitPair = std::make_pair(j, i);
472 if(hit1.
tagger!=hit2.
tagger && std::find(usedPairs.begin(), usedPairs.end(), rhitPair)==usedPairs.end()){
476 double dist = (pos1 - pos2).Mag();
477 usedPairs.push_back(hitPair);
478 hitPairDist.push_back(std::make_pair(hitPair, dist));
484 std::sort(hitPairDist.begin(), hitPairDist.end(), [](
auto&
left,
auto&
right){
488 vector<pair<vector<size_t>,
double>>
tracks;
489 for(
size_t i = 0; i < hitPairDist.size(); i++){
491 size_t hit_i = hitPairDist[i].first.first;
492 size_t hit_j = hitPairDist[i].first.second;
495 if(hits[hit_j].
tagger==
"volTaggerBot_0")
496 std::swap(hit_i, hit_j);
505 vector<size_t> nhitsMax;
506 double minDist = 99999;
509 for(
int i = 0; i<21; i++){
511 double fac = (i)/10.;
512 vector<size_t> nhits;
513 double totalDist = 0.;
516 TVector3 diff = start -
end;
519 for(
size_t k = 0;
k < hits.size();
k++){
528 double dist = (cross-mid).Mag();
537 if(nhits.size()>=nhitsMax.size() && totalDist/nhits.size() < minDist){
540 minDist = totalDist/nhits.size();
545 vector<size_t> trackCand;
546 trackCand.push_back(hit_i);
547 trackCand.push_back(hit_j);
548 trackCand.insert(trackCand.end(), nhitsMax.begin(), nhitsMax.end());
549 tracks.push_back(std::make_pair(trackCand, facMax));
555 TVector3 diff = start -
end;
556 vector<size_t> trackCand;
557 trackCand.push_back(hit_i);
558 trackCand.push_back(hit_j);
561 for(
size_t k = 0;
k < hits.size();
k++){
570 double dist = (cross-mid).Mag();
574 trackCand.push_back(
k);
577 tracks.push_back(std::make_pair(trackCand, 1));
582 std::sort(tracks.begin(), tracks.end(), [](
auto&
left,
auto&
right){
583 return left.first.size() >
right.first.size();});
586 vector<size_t> usedHits;
589 for(
auto&
track : tracks){
591 size_t hit_i =
track.first[0];
592 size_t hit_j =
track.first[1];
595 if(hits[hit_j].
tagger==
"volTaggerTopHigh_0")
596 std::swap(hit_i, hit_j);
604 for(
size_t i = 0; i <
track.first.size(); i++){
606 if(std::find(usedHits.begin(), usedHits.end(),
track.first[i]) != usedHits.end())
619 if(
track.first.size()==2 && ihit.
tagger ==
"volTaggerTopHigh_0" && jhit.
tagger ==
"volTaggerTopLow_0"){
623 returnTracks.push_back(crtTrack);
628 for(
size_t i = 0; i <
track.first.size(); i++){
629 if(
track.first.size()>2) usedHits.push_back(
track.first[i]);
644 double xc = hit.
x_pos;
646 ((xc - start.X()) / (diff.X()) * diff.Y()) + start.Y(),
647 ((xc - start.X()) / (diff.X()) * diff.Z()) + start.Z());
650 else if(hit.
y_err > 0.39 && hit.
y_err < 0.41){
651 double yc = hit.
y_pos;
652 TVector3 crossp(((yc - start.Y()) / (diff.Y()) * diff.X()) + start.X(),
654 ((yc - start.Y()) / (diff.Y()) * diff.Z()) + start.Z());
657 else if(hit.
z_err > 0.39 && hit.
z_err < 0.41){
658 double zc = hit.
z_pos;
659 TVector3 crossp(((zc - start.Z()) / (diff.Z()) * diff.X()) + start.X(),
660 ((zc - start.Z()) / (diff.Z()) * diff.Y()) + start.Y(),
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.
CRTHit FillCRTHit(vector< uint8_t > tfeb_id, map< uint8_t, vector< pair< int, float >>> tpesmap, float peshit, uint64_t time0, Long64_t time1, int plane, double x, double ex, double y, double ey, double z, double ez, string tagger)
Utilities related to art service access.
double ts0_s
Average time (second) of the two hits making the track.
sbn::crt::CRTHit DoAverage(vector< art::Ptr< sbn::crt::CRTHit >> hits)
geo::GeometryCore const * fGeometryService
TVector3 CrossPoint(sbn::crt::CRTHit hit, TVector3 start, TVector3 diff)
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).
double ts0_s_err
Average time (second) spread of the two hits making the track.
float x1_pos
X position of first CRTHit.
process_name use argoneut_mc_hitfinder track
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)]
vector< vector< art::Ptr< sbn::crt::CRTHit > > > CreateCRTTzeros(vector< art::Ptr< sbn::crt::CRTHit >>)
double ts0_ns_h1
T0 time of first CRTHit.
uint64_t ts0_s
Second-only part of timestamp T0.
fhicl::Atom< double > TimeLimit
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
double fAverageHitDistance
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...
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.
void reconfigure(const Config &config)
auto end(FixedBins< T, C > const &) noexcept
float length
Track length.
sbn::crt::CRTTrack FillCrtTrack(sbn::crt::CRTHit hit1, sbn::crt::CRTHit hit2, bool complete)
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)
vector< pair< sbn::crt::CRTHit, vector< int > > > AverageHits(vector< art::Ptr< sbn::crt::CRTHit >> hits, map< art::Ptr< sbn::crt::CRTHit >, int > hitIds)
double ts0_ns_err_h1
T0 time error of first CRTHit.
fhicl::Atom< double > DistanceLimit
bool complete
Whether or not the track is complete.
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).
float phizy
Track angle on the Z-Y plane.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
int plane1
Plane ID of first CRTHit.
float z2_pos
Z position of second CRTHit.
float x_pos
position in x-direction (cm).
float y2_pos
Y position of second CRTHit.
float y1_pos
Y position of first CRTHit.
float x2_pos
X position of second CRTHit.
vector< pair< sbn::crt::CRTTrack, vector< int > > > CreateTracks(vector< pair< sbn::crt::CRTHit, vector< int >>> hits)
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
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.
fhicl::Atom< double > AverageHitDistance