443 if (slc.firstWire[plane] > slc.nWires[plane])
return;
444 unsigned int nwires = slc.lastWire[plane] - slc.firstWire[plane] - 1;
445 if (nwires > slc.nWires[plane])
return;
451 for (
unsigned short pass = 0; pass <
tcc.
minPtsFit.size(); ++pass) {
452 for (
unsigned int ii = 0; ii < nwires; ++ii) {
454 unsigned int iwire = 0;
455 unsigned int jwire = 0;
458 iwire = slc.firstWire[plane] + ii;
463 iwire = slc.lastWire[plane] - ii - 1;
466 if (iwire > slc.wireHitRange[plane].size() - 1)
continue;
467 if (jwire > slc.wireHitRange[plane].size() - 1)
continue;
469 if (slc.wireHitRange[plane][iwire].first == UINT_MAX)
continue;
470 if (slc.wireHitRange[plane][jwire].first == UINT_MAX)
continue;
471 unsigned int ifirsthit = slc.wireHitRange[plane][iwire].first;
472 unsigned int ilasthit = slc.wireHitRange[plane][iwire].second;
473 unsigned int jfirsthit = slc.wireHitRange[plane][jwire].first;
474 unsigned int jlasthit = slc.wireHitRange[plane][jwire].second;
475 if (ifirsthit > slc.slHits.size() || ilasthit > slc.slHits.size()) {
476 std::cout <<
"RAT: bad hit range " << ifirsthit <<
" " << ilasthit <<
" size "
477 << slc.slHits.size() <<
" inCTP " << inCTP <<
"\n";
480 for (
unsigned int iht = ifirsthit; iht <= ilasthit; ++iht) {
483 mf::LogVerbatim(
"TC") <<
"+++++++ Pass " << pass <<
" Found debug hit "
488 if (slc.slHits[iht].InTraj != 0)
continue;
491 if (slc.slHits[iht].allHitsIndex > (*
evt.
allHits).size() - 1) {
495 auto& iHit = (*
evt.
allHits)[slc.slHits[iht].allHitsIndex];
497 unsigned int fromWire = iHit.WireID().Wire;
498 float fromTick = iHit.PeakTime();
499 float iqtot = iHit.Integral();
500 float hitsRMSTick = iHit.RMS();
501 std::vector<unsigned int> iHitsInMultiplet;
504 iHitsInMultiplet.resize(1);
505 iHitsInMultiplet[0] = iht;
509 if (iHitsInMultiplet.empty())
continue;
511 if (iHitsInMultiplet.size() > 4)
continue;
513 if (iHitsInMultiplet.size() > 1) {
517 if (hitsRMSTick == 0)
continue;
518 bool fatIHit = (hitsRMSTick > maxHitsRMS);
520 mf::LogVerbatim(
"TC") <<
" hit RMS " << iHit.RMS() <<
" BB Multiplicity "
521 << iHitsInMultiplet.size() <<
" AveHitRMS[" << plane <<
"] "
522 <<
evt.
aveHitRMS[plane] <<
" HitsRMSTick " << hitsRMSTick
523 <<
" fatIHit " << fatIHit;
524 for (
unsigned int jht = jfirsthit; jht <= jlasthit; ++jht) {
526 if (slc.slHits[iht].InTraj != 0)
break;
527 if (slc.slHits[jht].InTraj != 0)
continue;
529 for (
auto& slHit : slc.slHits) {
530 if (slHit.InTraj < 0) {
536 unsigned int toWire = jwire;
537 auto& jHit = (*
evt.
allHits)[slc.slHits[jht].allHitsIndex];
539 float toTick = jHit.PeakTime();
540 float jqtot = jHit.Integral();
541 std::vector<unsigned int> jHitsInMultiplet;
544 jHitsInMultiplet.resize(1);
545 jHitsInMultiplet[0] = jht;
549 if (jHitsInMultiplet.empty())
continue;
551 if (jHitsInMultiplet.size() > 4)
continue;
554 if (hitsRMSTick == 0)
continue;
555 bool fatJHit = (hitsRMSTick > maxHitsRMS);
558 if ((fatIHit && !fatJHit) || (!fatIHit && fatJHit)) {
continue; }
562 if (jHitsInMultiplet.size() > 1)
565 bool hitsOK =
TrajHitsOK(slc, iHitsInMultiplet, jHitsInMultiplet);
567 if (!hitsOK)
continue;
570 if (!
StartTraj(slc, work, fromWire, fromTick, toWire, toTick, inCTP, pass))
continue;
573 std::cout <<
"RAT: StartTraj major failure\n";
576 if (work.Pts.empty()) {
577 if (
tcc.
dbgStp) mf::LogVerbatim(
"TC") <<
"ReconstructAllTraj: StartTraj failed";
589 std::cout <<
"RAT: AddHits major failure\n";
592 if (!sigOK || work.Pts[0].Chg == 0) {
593 if (
tcc.
dbgStp) mf::LogVerbatim(
"TC") <<
" No hits at initial trajectory point ";
598 work.Pts[0].Pos = work.Pts[0].HitPos;
607 std::cout <<
"RAT: StepAway major failure\n";
611 mf::LogVerbatim(
"TC") <<
" After first StepAway. IsGood " << work.IsGood;
616 std::cout <<
"RAT: CheckTraj major failure\n";
620 mf::LogVerbatim(
"TC") <<
"ReconstructAllTraj: After CheckTraj EndPt " << work.EndPt[0]
621 <<
"-" << work.EndPt[1] <<
" IsGood " << work.IsGood;
623 mf::LogVerbatim(
"TC")
624 <<
"StepAway done: IsGood " << work.IsGood <<
" NumPtsWithCharge "
629 mf::LogVerbatim(
"TC")
631 <<
" minimum " <<
tcc.
minPts[work.Pass] <<
" or !IsGood";
637 auto& tj = slc.tjs[slc.tjs.size() - 1];
640 std::cout <<
"RAT: InTrajOK major failure. " << tj.ID <<
"\n";
653 for (
auto tp :
seeds) {
654 unsigned short nAvailable = 0;
655 for (
unsigned short ii = 0; ii < tp.Hits.size(); ++ii) {
656 if (!tp.UseHit[ii])
continue;
657 unsigned int iht = tp.Hits[ii];
658 if (slc.slHits[iht].InTraj == 0) ++nAvailable;
661 mf::LogVerbatim(
"TC") <<
"+++++++ Seed debug hit " <<
slices.size() - 1 <<
":"
662 <<
PrintHit(slc.slHits[iht]) <<
" iht " << iht;
665 if (nAvailable == 0)
continue;
668 for (
unsigned short ii = 0; ii < tp.Hits.size(); ++ii) {
669 if (!tp.UseHit[ii])
continue;
670 unsigned int iht = tp.Hits[ii];
671 if (slc.slHits[iht].InTraj == 0) slc.slHits[iht].InTraj = work.ID;
675 if (tp.Dir[0] < 0) work.StepDir = -1;
678 work.Strategy.reset();
681 work.AlgMod[
kRvPrp] =
true;
682 work.Pts.push_back(tp);
687 std::cout <<
"RAT: CheckTraj major failure\n";
693 mf::LogVerbatim(
"TC") <<
" xxxxxxx Not enough points "
695 <<
tcc.
minPts[work.Pass] <<
" or !IsGood";
701 auto& tj = slc.tjs[slc.tjs.size() - 1];
702 mf::LogVerbatim(
"TC") <<
"TRP RAT Stored T" << tj.ID <<
" using seed TP "
714 if (!slc.isValid)
return;
727 for (
auto& tj : slc.tjs) {
728 if (tj.AlgMod[
kKilled])
continue;
729 if (tj.PDGCode != 13)
continue;
744 std::cout <<
"RAT: MakeJunkVertices major failure\n";
749 for (
unsigned short ivx = 0; ivx < slc.vtxs.size(); ++ivx) {
750 auto& vx2 = slc.vtxs[ivx];
751 if (vx2.ID == 0)
continue;
752 if (vx2.CTP != inCTP)
continue;
764 std::cout <<
"RAT: ChkVtxAssociations found an error. Events processed "
void CheckTrajBeginChg(TCSlice &slc, unsigned short itj)
void ReleaseHits(TCSlice &slc, Trajectory &tj)
void StepAway(TCSlice &slc, Trajectory &tj)
then if[["$THISISATEST"==1]]
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
BEGIN_PROLOG could also be cout
void SetTPEnvironment(TCSlice &slc, CTP_t inCTP)
void FindJunkTraj(TCSlice &slc, CTP_t inCTP)