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)
380 TVector3 cross =
CrossPoint(khit, start, diff);
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]);
float z_err
position uncertainty in z-direction (cm).
float x_err
position uncertainty in x-direction (cm).
TVector3 CrossPoint(sbn::crt::CRTHit hit, TVector3 start, TVector3 diff)
ClusterModuleLabel join with tracks
process_name use argoneut_mc_hitfinder track
float z_pos
position in z-direction (cm).
auto end(FixedBins< T, C > const &) noexcept
sbn::crt::CRTTrack FillCrtTrack(sbn::crt::CRTHit hit1, sbn::crt::CRTHit hit2, bool complete)
bool complete
Whether or not the track is complete.
float y_pos
position in y-direction (cm).
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
float x_pos
position in x-direction (cm).
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
std::string tagger
Name of the CRT wall (in the form of strings).