435 if (slc.firstWire[plane] > slc.nWires[plane])
return;
436 unsigned int nwires = slc.lastWire[plane] - slc.firstWire[plane] - 1;
437 if (nwires > slc.nWires[plane])
return;
444 for (
unsigned int ii = 0; ii <
nwires; ++ii) {
446 unsigned int iwire = 0;
447 unsigned int jwire = 0;
450 iwire = slc.firstWire[plane] + ii;
455 iwire = slc.lastWire[plane] - ii - 1;
458 if (iwire > slc.wireHitRange[plane].size() - 1)
continue;
459 if (jwire > slc.wireHitRange[plane].size() - 1)
continue;
461 if (slc.wireHitRange[plane][iwire].first == UINT_MAX)
continue;
462 if (slc.wireHitRange[plane][jwire].first == UINT_MAX)
continue;
463 unsigned int ifirsthit = slc.wireHitRange[plane][iwire].first;
464 unsigned int ilasthit = slc.wireHitRange[plane][iwire].second;
465 unsigned int jfirsthit = slc.wireHitRange[plane][jwire].first;
466 unsigned int jlasthit = slc.wireHitRange[plane][jwire].second;
467 if (ifirsthit > slc.slHits.size() || ilasthit > slc.slHits.size()) {
468 std::cout <<
"RAT: bad hit range " << ifirsthit <<
" " << ilasthit <<
" size " 469 << slc.slHits.size() <<
" inCTP " << inCTP <<
"\n";
472 for (
unsigned int iht = ifirsthit; iht <= ilasthit; ++iht) {
480 if (slc.slHits[iht].InTraj != 0)
continue;
483 if (slc.slHits[iht].allHitsIndex > (*
evt.
allHits).size() - 1) {
484 std::cout <<
"RAT: Bad allHitsIndex\n";
487 auto& iHit = (*
evt.
allHits)[slc.slHits[iht].allHitsIndex];
489 unsigned int fromWire = iHit.WireID().Wire;
490 float fromTick = iHit.PeakTime();
491 float iqtot = iHit.Integral();
492 float hitsRMSTick = iHit.RMS();
493 std::vector<unsigned int> iHitsInMultiplet;
496 iHitsInMultiplet.resize(1);
497 iHitsInMultiplet[0] = iht;
501 if (iHitsInMultiplet.empty())
continue;
503 if (iHitsInMultiplet.size() > 4)
continue;
505 if (iHitsInMultiplet.size() > 1) {
509 if (hitsRMSTick == 0)
continue;
510 bool fatIHit = (hitsRMSTick > maxHitsRMS);
512 mf::LogVerbatim(
"TC") <<
" hit RMS " << iHit.RMS() <<
" BB Multiplicity " 513 << iHitsInMultiplet.size() <<
" AveHitRMS[" << plane <<
"] " 514 <<
evt.
aveHitRMS[plane] <<
" HitsRMSTick " << hitsRMSTick
515 <<
" fatIHit " << fatIHit;
516 for (
unsigned int jht = jfirsthit; jht <= jlasthit; ++jht) {
518 if (slc.slHits[iht].InTraj != 0)
break;
519 if (slc.slHits[jht].InTraj != 0)
continue;
521 for (
auto& slHit : slc.slHits) {
522 if (slHit.InTraj < 0) {
523 std::cout <<
"RAT: Dirty hit " <<
PrintHit(slHit) <<
" EventsProcessed " 528 unsigned int toWire = jwire;
529 auto& jHit = (*
evt.
allHits)[slc.slHits[jht].allHitsIndex];
531 float toTick = jHit.PeakTime();
532 float jqtot = jHit.Integral();
533 std::vector<unsigned int> jHitsInMultiplet;
536 jHitsInMultiplet.resize(1);
537 jHitsInMultiplet[0] = jht;
541 if (jHitsInMultiplet.empty())
continue;
543 if (jHitsInMultiplet.size() > 4)
continue;
546 if (hitsRMSTick == 0)
continue;
547 bool fatJHit = (hitsRMSTick > maxHitsRMS);
550 if ((fatIHit && !fatJHit) || (!fatIHit && fatJHit)) {
continue; }
554 if (jHitsInMultiplet.size() > 1)
557 bool hitsOK =
TrajHitsOK(slc, iHitsInMultiplet, jHitsInMultiplet);
559 if (!hitsOK)
continue;
562 if (!
StartTraj(slc, work, fromWire, fromTick, toWire, toTick, inCTP,
pass))
continue;
565 std::cout <<
"RAT: StartTraj major failure\n";
568 if (work.Pts.empty()) {
581 std::cout <<
"RAT: AddHits major failure\n";
584 if (!sigOK || work.Pts[0].Chg == 0) {
590 work.Pts[0].Pos = work.Pts[0].HitPos;
599 std::cout <<
"RAT: StepAway major failure\n";
603 mf::LogVerbatim(
"TC") <<
" After first StepAway. IsGood " << work.IsGood;
608 std::cout <<
"RAT: CheckTraj major failure\n";
612 mf::LogVerbatim(
"TC") <<
"ReconstructAllTraj: After CheckTraj EndPt " << work.EndPt[0]
613 <<
"-" << work.EndPt[1] <<
" IsGood " << work.IsGood;
616 <<
"StepAway done: IsGood " << work.IsGood <<
" NumPtsWithCharge " 623 <<
" minimum " <<
tcc.
minPts[work.Pass] <<
" or !IsGood";
629 auto& tj = slc.tjs[slc.tjs.size() - 1];
632 std::cout <<
"RAT: InTrajOK major failure. " << tj.ID <<
"\n";
645 for (
auto tp :
seeds) {
646 unsigned short nAvailable = 0;
647 for (
unsigned short ii = 0; ii < tp.Hits.size(); ++ii) {
648 if (!tp.UseHit[ii])
continue;
649 unsigned int iht = tp.Hits[ii];
650 if (slc.slHits[iht].InTraj == 0) ++nAvailable;
654 <<
PrintHit(slc.slHits[iht]) <<
" iht " << iht;
657 if (nAvailable == 0)
continue;
660 for (
unsigned short ii = 0; ii < tp.Hits.size(); ++ii) {
661 if (!tp.UseHit[ii])
continue;
662 unsigned int iht = tp.Hits[ii];
663 if (slc.slHits[iht].InTraj == 0) slc.slHits[iht].InTraj = work.ID;
667 if (tp.Dir[0] < 0) work.StepDir = -1;
670 work.Strategy.reset();
673 work.AlgMod[
kRvPrp] =
true;
674 work.Pts.push_back(tp);
679 std::cout <<
"RAT: CheckTraj major failure\n";
687 <<
tcc.
minPts[work.Pass] <<
" or !IsGood";
693 auto& tj = slc.tjs[slc.tjs.size() - 1];
694 mf::LogVerbatim(
"TC") <<
"TRP RAT Stored T" << tj.ID <<
" using seed TP " 706 if (!slc.isValid)
return;
719 for (
auto& tj : slc.tjs) {
720 if (tj.AlgMod[
kKilled])
continue;
721 if (tj.PDGCode != 13)
continue;
736 std::cout <<
"RAT: MakeJunkVertices major failure\n";
741 for (
unsigned short ivx = 0; ivx < slc.vtxs.size(); ++ivx) {
742 auto& vx2 = slc.vtxs[ivx];
743 if (vx2.ID == 0)
continue;
744 if (vx2.CTP != inCTP)
continue;
756 std::cout <<
"RAT: ChkVtxAssociations found an error. Events processed " void CheckTrajBeginChg(TCSlice &slc, unsigned short itj)
void ReleaseHits(TCSlice &slc, Trajectory &tj)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void StepAway(TCSlice &slc, Trajectory &tj)
bool TrajHitsOK(TCSlice &slc, const std::vector< unsigned int > &iHitsInMultiplet, const std::vector< unsigned int > &jHitsInMultiplet)
bool InTrajOK(TCSlice &slc, std::string someText)
std::vector< unsigned short > minPtsFit
Reconstruct in several passes.
void AddHits(TCSlice &slc, Trajectory &tj, unsigned short ipt, bool &sigOK)
void PrintTrajectory(std::string someText, const TCSlice &slc, const Trajectory &tj, unsigned short tPoint)
void SplitTrajCrossingVertices(TCSlice &slc, CTP_t inCTP)
step from US -> DS (true) or DS -> US (false)
bool StoreTraj(TCSlice &slc, Trajectory &tj)
std::string PrintPos(const TCSlice &slc, const TrajPoint &tp)
bool AttachAnyTrajToVertex(TCSlice &slc, unsigned short ivx, bool prt)
bool dbgSlc
debug only in the user-defined slice? default is all slices
bool StartTraj(TCSlice &slc, Trajectory &tj, unsigned int fromhit, unsigned int tohit, unsigned short pass)
bool LongPulseHit(const recob::Hit &hit)
unsigned int eventsProcessed
std::vector< float > showerTag
shower-like trajectory tagging + shower reconstruction
unsigned int Hit
set to the hit index in evt.allHits if a Plane:Wire:Tick match is found
float HitsRMSTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
bool dbgStp
debug stepping using debug.Cryostat, debug.TPC, etc
float unitsPerTick
scale factor from Tick to WSE equivalent units
bool BraggSplit(TCSlice &slc, unsigned short itj)
bool dbg2V
debug 2D vertex finding
void GetHitMultiplet(const TCSlice &slc, unsigned int theHit, std::vector< unsigned int > &hitsInMultiplet, bool useLongPulseHits)
std::vector< float > aveHitRMS
average RMS of an isolated hit
void TagShowerLike(std::string inFcnLabel, TCSlice &slc, const CTP_t &inCTP)
bool ChkVtxAssociations(TCSlice &slc, const CTP_t &inCTP)
void MakeHaloTj(TCSlice &slc, Trajectory &muTj, bool prt)
std::string PrintHit(const TCHit &tch)
std::vector< unsigned short > minPts
min number of Pts required to make a trajectory
PlaneID_t Plane
Index of the plane within its TPC.
float HitsPosTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
std::vector< TCSlice > slices
std::bitset< 16 > modes
number of points to find AveChg
std::vector< TrajPoint > seeds
void CheckTraj(TCSlice &slc, Trajectory &tj)
std::bitset< 128 > useAlg
Max hit separation for making junk trajectories. < 0 to turn off.
void LastEndMerge(TCSlice &slc, CTP_t inCTP)
std::vector< short > muonTag
void UpdateVxEnvironment(TCSlice &slc)
geo::PlaneID DecodeCTP(CTP_t CTP)
std::vector< recob::Hit > const * allHits
void EndMerge(TCSlice &slc, CTP_t inCTP, bool lastPass)
unsigned short NumPtsWithCharge(const TCSlice &slc, const Trajectory &tj, bool includeDeadWires)
void MakeJunkVertices(TCSlice &slc, const CTP_t &inCTP)
void Find2DVertices(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, const CTP_t &inCTP, unsigned short pass)
master switch for turning on debug mode
void SetTPEnvironment(TCSlice &slc, CTP_t inCTP)
void FindJunkTraj(TCSlice &slc, CTP_t inCTP)