28 : fCaloAlg(pset.
get<
fhicl::ParameterSet>(
"CaloAlg")), fMVAReader(
"Silent")
32 bool badinput =
false;
39 if (pset.
has_key(
"Mode")) userMode = pset.
get<
short>(
"Mode");
43 if (pset.
has_key(
"StudyMode")) {
44 std::cout <<
"StudyMode is not valid anymore. Try Study: 1 or Study: 2, etc/n";
47 userMode = pset.
get<
short>(
"Study");
53 if (pset.
has_key(
"SaveShowerTree"))
57 std::vector<std::string> skipAlgsVec;
58 if (pset.
has_key(
"SkipAlgs")) skipAlgsVec = pset.
get<std::vector<std::string>>(
"SkipAlgs");
59 std::vector<std::string> debugConfigVec;
60 if (pset.
has_key(
"DebugConfig"))
61 debugConfigVec = pset.
get<std::vector<std::string>>(
"DebugConfig");
65 std::vector<float> aveHitRMS;
66 if (pset.
has_key(
"AveHitRMS")) aveHitRMS = pset.
get<std::vector<float>>(
"AveHitRMS");
68 if (!aveHitRMS.empty()) {
75 tcc.
minPts = pset.
get<std::vector<unsigned short>>(
"MinPts");
79 tcc.
chargeCuts = pset.
get<std::vector<float>>(
"ChargeCuts", {3, 0.15, 0.25});
89 tcc.
muonTag = pset.
get<std::vector<short>>(
"MuonTag", {-1, -1, -1, -1});
91 tcc.
showerTag = pset.
get<std::vector<float>>(
"ShowerTag", {-1, -1, -1, -1, -1, -1});
95 if (pset.
has_key(
"MatchTruth")) {
96 std::cout <<
"MatchTruth is not used. Use ClusterAnaV2 or DebugConfig to configure\n";
98 tcc.
vtx2DCuts = pset.
get<std::vector<float>>(
"Vertex2DCuts", {-1, -1, -1, -1, -1, -1, -1});
101 tcc.
match3DCuts = pset.
get<std::vector<float>>(
"Match3DCuts", {-1, -1, -1, -1, -1});
114 <<
"Bad input from fcl file. Vector lengths for MinPtsFit, MaxAngleRange and MinMCSMom " 115 "should be defined for each reconstruction pass";
119 <<
"Vertex2DCuts must be size 11\n 0 = Max length definition for short TJs\n 1 = Max " 120 "vtx-TJ sep short TJs\n 2 = Max vtx-TJ sep long TJs\n 3 = Max position pull for >2 " 121 "TJs\n 4 = Max vtx position error\n 5 = Min MCSMom for one of two TJs\n 6 = Min " 122 "fraction of wires hit btw vtx and Tjs\n 7 = Min Score\n 8 = min ChgFrac at a vtx or " 123 "merge point\n 9 = max MCSMom asymmetry, 10 = require chg on wires btw vtx and tjs in " 132 <<
"Vertex3DCuts must be size > 2\n 0 = 2D Vtx max dX (cm)\n 1 = 2D Vtx max pull\n 2 = max " 133 "3D separation (cm) btw PFP and vertex";
135 std::cout <<
"WARNING: Vertex3DCuts is size 2 but should be size 3, where Vertex3DCuts[2] = " 136 "max 3D separation (cm) btw a PFP and a 3D vertex. Setting it to 3 cm\n";
141 <<
"KinkCuts must be size 3\n 0 = Number of points to fit at the end of the trajectory\n 1 " 142 "= Minimum kink significance\n 2 = Use charge in significance calculation? (yes if > " 143 "0)\n 3 = 3D kink fit length (cm). \nYou are using an out-of-date specification?\n";
149 <<
"Are you using an out-of-date specification for KinkCuts? KinkCuts[0] is the number of " 155 <<
"ChargeCuts must be size 3\n 0 = Charge pull cut\n 1 = Min allowed fractional chg RMS\n " 156 "2 = Max allowed fractional chg RMS";
160 <<
"MuonTag must be size 4\n 0 = minPtsFit\n 1 = minMCSMom\n 2= maxWireSkipNoSignal\n 3 = " 161 "min delta ray length for tagging\n 4 = dress muon window size (optional)";
164 <<
"DeltaRayTag must be size 3\n 0 = Max endpoint sep\n 1 = min MCSMom\n 2 = max MCSMom";
167 <<
"ChkStopCuts must be size 3\n 0 = Min Charge ratio\n 1 = Charge slope pull cut\n 2 = " 168 "Charge fit chisq cut\n 3 = BraggSplit FOM (optional)";
171 <<
"ShowerTag must be size 13\n 0 = Mode\n 1 = max MCSMom\n 2 = max separation (WSE " 172 "units)\n 3 = Max angle diff\n 4 = Factor * rms width\n 5 = Min half width\n 6 = min " 173 "total Tps\n 7 = Min Tjs\n 8 = max parent FOM\n 9 = max direction FOM 10 = max " 174 "AspectRatio\n 11 = min Score to preserve a vertex\n 12 = Debug showers in CTP\n";
175 std::cout <<
" Fixing this problem...";
184 <<
"Match3DCuts must be size 5\n 0 = dx (cm) matching cut\n 1 = max number of 3D " 185 "combinations\n 2 = min length for 2-view match\n 3 = number of TP3Ds in each plane to " 186 "fit in each PFP section\n 4 = max pull for accepting TP3Ds in sections\n 5 = max " 187 "ChiDOF for a SectionFit";
191 mf::LogVerbatim(
"TC") <<
"Last element of AngleRange != 90 degrees. Fixing it\n";
207 for (
auto strng : debugConfigVec) {
211 for (
unsigned short ib = 0; ib <
AlgBitNames.size(); ++ib) {
220 std::cout <<
"DecodeDebugString failed: " << strng <<
"\n";
228 if (range < 0 || range > 90)
230 <<
"Invalid angle range " << range <<
" Must be 0 - 90 degrees";
240 <<
"Increase the size of UseAlgs to at least " <<
kAlgBitSize;
249 <<
"Increase the size of EndFlag to at least " <<
kFlagBitSize;
251 bool printHelp =
false;
252 for (
unsigned short ib = 0; ib <
AlgBitNames.size(); ++ib)
259 for (
auto strng : skipAlgsVec) {
261 if (strng ==
"All") {
263 for (
unsigned short ib = 0; ib <
AlgBitNames.size(); ++ib)
268 for (
unsigned short ib = 0; ib <
AlgBitNames.size(); ++ib) {
276 std::cout <<
"******* Unknown SkipAlgs input string '" << strng <<
"'\n";
281 std::cout <<
"Valid AlgNames:";
283 std::cout <<
" " << strng;
285 std::cout <<
"Or specify All to turn all algs off\n";
288 if (fMVAShowerParentWeights !=
"NA" &&
tcc.
showerTag[0] > 0)
309 tcc.
geom = lar::providerFrom<geo::Geometry>();
332 thr = {UINT_MAX, UINT_MAX};
335 unsigned int tpc =
hit.WireID().TPC;
346 std::vector<unsigned int>& hitsInSlice,
352 if (hitsInSlice.size() < 2)
return;
355 if (!
CreateSlice(clockData, detProp, hitsInSlice, sliceID))
return;
368 <<
" AveHitRMS vector size != the number of planes ";
370 std::cout <<
"Reconstruct " << hitsInSlice.size() <<
" hits in Slice " << sliceID
371 <<
" in TPC " << slc.TPCID.TPC <<
"\n";
372 for (
unsigned short plane = 0; plane < slc.nPlanes; ++plane) {
373 CTP_t inCTP =
EncodeCTP(slc.TPCID.Cryostat, slc.TPCID.TPC, plane);
375 if (!slc.isValid)
return;
384 for (
unsigned short plane = 0; plane < slc.nPlanes; ++plane) {
385 CTP_t inCTP =
EncodeCTP(slc.TPCID.Cryostat, slc.TPCID.TPC, plane);
387 std::cout <<
"RTC: ChkVtxAssociations found an error\n";
406 mf::LogVerbatim(
"TC") <<
"RunTrajCluster failed in MakeAllTrajClusters";
416 for (
auto& tj : slc.tjs) {
417 for (
unsigned short ib = 0; ib <
AlgBitNames.size(); ++ib)
422 slc.mallTraj.resize(0);
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;
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;
484 std::cout <<
"RAT: Bad allHitsIndex\n";
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;
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";
608 std::cout <<
"RAT: CheckTraj major failure\n";
613 <<
"-" << work.
EndPt[1] <<
" IsGood " << work.
IsGood;
616 <<
"StepAway done: IsGood " << work.
IsGood <<
" NumPtsWithCharge " 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;
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;
674 work.
Pts.push_back(tp);
679 std::cout <<
"RAT: CheckTraj major failure\n";
693 auto& tj = slc.
tjs[slc.
tjs.size() - 1];
694 mf::LogVerbatim(
"TC") <<
"TRP RAT Stored T" << tj.ID <<
" using seed TP " 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 " 774 for (
auto& slHit : slc.
slHits)
775 if (slHit.InTraj < 0) slHit.InTraj = 0;
779 std::vector<unsigned int> tHits;
781 for (
unsigned int iwire = slc.
firstWire[plane]; iwire < slc.
lastWire[plane] - 3; ++iwire) {
785 unsigned int jwire = iwire + 1;
788 unsigned int ifirsthit = slc.
wireHitRange[plane][iwire].first;
789 unsigned int ilasthit = slc.
wireHitRange[plane][iwire].second;
790 unsigned int jfirsthit = slc.
wireHitRange[plane][jwire].first;
791 unsigned int jlasthit = slc.
wireHitRange[plane][jwire].second;
792 for (
unsigned int iht = ifirsthit; iht <= ilasthit; ++iht) {
793 if(iht >= slc.
slHits.size())
break;
794 auto& islHit = slc.
slHits[iht];
795 if (islHit.InTraj != 0)
continue;
796 std::vector<unsigned int> iHits;
800 if (prt)
mf::LogVerbatim(
"TC") <<
"FJT: debug iht multiplet size " << iHits.size();
801 if (iHits.empty())
continue;
802 for (
unsigned int jht = jfirsthit; jht <= jlasthit; ++jht) {
803 if(jht >= slc.
slHits.size())
break;
804 auto& jslHit = slc.
slHits[jht];
805 if (jslHit.InTraj != 0)
continue;
806 if (prt &&
HitSep2(slc, iht, jht) < 100)
810 std::vector<unsigned int> jHits;
812 if (jHits.empty())
continue;
817 for (
auto iht : iHits)
818 if (slc.
slHits[iht].InTraj == 0) tHits.push_back(iht);
819 for (
auto jht : jHits)
820 if (slc.
slHits[jht].InTraj == 0) tHits.push_back(jht);
821 for (
auto tht : tHits)
822 slc.
slHits[tht].InTraj = -4;
824 if (iwire != 0) { loWire = iwire - 1; }
828 unsigned int hiWire = jwire + 1;
829 if (hiWire > slc.
nWires[plane])
break;
830 unsigned short nit = 0;
832 bool hitsAdded =
false;
833 for (
unsigned int kwire = loWire; kwire <= hiWire; ++kwire) {
834 if (slc.
wireHitRange[plane][kwire].first == UINT_MAX)
continue;
835 if (slc.
wireHitRange[plane][kwire].second == UINT_MAX)
continue;
836 unsigned int kfirsthit = slc.
wireHitRange[plane][kwire].first;
837 unsigned int klasthit = slc.
wireHitRange[plane][kwire].second;
838 for (
unsigned int kht = kfirsthit; kht <= klasthit; ++kht) {
839 if(kht >= slc.
slHits.size())
continue;
840 if (slc.
slHits[kht].InTraj != 0)
continue;
842 if (std::find(tHits.begin(), tHits.end(), kht) != tHits.end())
continue;
847 for (
auto jht : jHits) {
848 if (slc.
slHits[jht].InTraj != 0)
continue;
849 tHits.push_back(jht);
850 slc.
slHits[jht].InTraj = -4;
851 if (kwire > hiWire) hiWire = kwire;
852 if (kwire < loWire) loWire = kwire;
857 if (!hitsAdded)
break;
860 if (hiWire >= slc.
nWires[plane])
break;
863 for (
auto iht : tHits)
864 slc.
slHits[iht].InTraj = 0;
865 if (tHits.size() < 3)
continue;
868 myprt <<
"FJT: tHits";
869 for (
auto tht : tHits)
874 if (
IsGhost(slc, tHits))
break;
879 if (slc.
slHits[jht].InTraj > 0)
break;
897 unsigned short itj = 0;
898 std::vector<unsigned int> tHits;
899 std::vector<unsigned int> atHits;
900 for (
auto& tj : slc.
tjs) {
902 if (tj.AlgMod[
kKilled])
continue;
904 for (
auto& tp : tj.Pts) {
905 if (tp.Hits.size() > 16) {
908 <<
"ChkInTraj: More than 16 hits created a UseHit bitset overflow\n";
910 std::cout <<
"ChkInTraj major failure\n";
915 std::cout << someText <<
" ChkInTraj hit size mis-match in tj ID " << tj.ID
917 for (
unsigned short ib = 0; ib <
AlgBitNames.size(); ++ib)
918 if (tj.AlgMod[ib]) std::cout <<
" " <<
AlgBitNames[ib];
923 if (tHits.size() < 2) {
924 mf::LogVerbatim(
"TC") << someText <<
" ChkInTraj: Insufficient hits in traj " << tj.ID;
929 std::sort(tHits.begin(), tHits.end());
931 for (iht = 0; iht < slc.
slHits.size(); ++iht) {
932 if (slc.
slHits[iht].InTraj == tID) atHits.push_back(iht);
934 if (atHits.size() < 2) {
935 mf::LogVerbatim(
"TC") << someText <<
" ChkInTraj: Insufficient hits in atHits in traj " 936 << tj.ID <<
" Killing it";
940 if (!std::equal(tHits.begin(), tHits.end(), atHits.begin())) {
942 myprt << someText <<
" ChkInTraj failed: inTraj - UseHit mis-match for tj ID " << tID
943 <<
" tj.WorkID " << tj.WorkID <<
" atHits size " << atHits.size() <<
" tHits size " 944 << tHits.size() <<
" in CTP " << tj.CTP <<
"\n";
945 myprt <<
"AlgMods: ";
946 for (
unsigned short ib = 0; ib <
AlgBitNames.size(); ++ib)
947 if (tj.AlgMod[ib]) myprt <<
" " <<
AlgBitNames[ib];
949 myprt <<
"index inTraj UseHit \n";
950 for (iht = 0; iht < atHits.size(); ++iht) {
951 myprt <<
"iht " << iht <<
" " <<
PrintHit(slc.
slHits[atHits[iht]]);
952 if (iht < tHits.size()) myprt <<
" " <<
PrintHit(slc.
slHits[tHits[iht]]);
953 if (atHits[iht] != tHits[iht]) myprt <<
" <<< " << atHits[iht] <<
" != " << tHits[iht];
957 if (tHits.size() > atHits.size()) {
958 for (iht = atHits.size(); iht < atHits.size(); ++iht) {
959 myprt <<
"atHits " << iht <<
" " <<
PrintHit(slc.
slHits[atHits[iht]]) <<
"\n";
965 for (
unsigned short end = 0;
end < 2; ++
end) {
966 if (tj.VtxID[
end] > slc.
vtxs.size()) {
967 mf::LogVerbatim(
"TC") << someText <<
" ChkInTraj: Bad VtxID " << tj.ID;
968 std::cout << someText <<
" ChkInTraj: Bad VtxID " << tj.ID <<
" vtx size " 969 << slc.
vtxs.size() <<
"\n";
985 std::vector<recob::Hit>& newHitCol,
986 std::vector<unsigned int>& newHitAssns)
const 991 if (tpHits.empty())
return;
994 if (tpHits.size() == 1) {
996 std::cout <<
"MergeTPHits Bad input hit index " << tpHits[0] <<
" allHits size " 1001 newHitAssns[tpHits[0]] = newHitCol.size() - 1;
1006 std::vector<unsigned int> wires;
1007 std::vector<std::vector<unsigned int>> wireHits;
1009 wires.push_back(firstHit.WireID().Wire);
1010 std::vector<unsigned int>
tmp(1, tpHits[0]);
1011 wireHits.push_back(tmp);
1012 for (
unsigned short ii = 1; ii < tpHits.size(); ++ii) {
1014 unsigned int wire =
hit.WireID().Wire;
1015 unsigned short indx = 0;
1016 for (indx = 0; indx < wires.size(); ++indx)
1017 if (wires[indx] == wire)
break;
1018 if (indx == wires.size()) {
1019 wires.push_back(wire);
1020 wireHits.resize(wireHits.size() + 1);
1022 wireHits[indx].push_back(tpHits[ii]);
1026 for (
unsigned short indx = 0; indx < wireHits.size(); ++indx) {
1027 auto& hitsOnWire = wireHits[indx];
1029 for (
unsigned short ii = 0; ii < hitsOnWire.size(); ++ii) {
1030 newHitAssns[hitsOnWire[ii]] = newHitCol.size() - 1;
1047 if (tpHits.size() == 1) {
1049 std::cout <<
"MergeTPHits Bad input hit index " << tpHits[0] <<
" allHits size " 1061 oldHit.SigmaPeakTime(),
1063 oldHit.PeakAmplitude(),
1064 oldHit.SigmaPeakAmplitude(),
1067 oldHit.SigmaIntegral(),
1073 oldHit.SignalType(),
1078 double sIntegral = 0;
1079 double peakTime = 0;
1080 double sPeakTime = 0;
1082 double sPeakAmp = 0;
1086 for (
auto allHitsIndex : tpHits) {
1089 if (
hit.StartTick() < startTick) startTick =
hit.StartTick();
1090 if (
hit.EndTick() > endTick) endTick =
hit.EndTick();
1091 double intgrl =
hit.Integral();
1092 sPeakTime += intgrl *
hit.SigmaPeakTime();
1093 sPeakAmp += intgrl *
hit.SigmaPeakAmplitude();
1094 sumADC +=
hit.SummedADC();
1096 sIntegral += intgrl *
hit.SigmaIntegral();
1099 if (integral <= 0) {
1100 std::cout <<
"MergeTPHits found bad hit integral " << integral <<
"\n";
1105 std::vector<double> shape(endTick - startTick + 1, 0.);
1106 for (
auto allHitsIndex : tpHits) {
1108 double peakTick =
hit.PeakTime();
1110 double peakAmp =
hit.PeakAmplitude();
1112 double arg = ((double)
tick - peakTick) /
rms;
1113 unsigned short indx =
tick - startTick;
1114 shape[indx] += peakAmp * exp(-0.5 * arg * arg);
1122 unsigned short indx =
tick - startTick;
1123 sigsum += shape[indx];
1124 sigsumt += shape[indx] *
tick;
1127 peakTime = sigsumt / sigsum;
1134 double dTick =
tick - peakTime;
1135 unsigned short indx =
tick - startTick;
1136 sigsumt += shape[indx] * dTick * dTick;
1138 double rms = std::sqrt(sigsumt / sigsum);
1141 double chgNorm = 2.507 * firstHit.PeakAmplitude() * firstHit.RMS() / firstHit.Integral();
1143 peakAmp = (
float)(integral * chgNorm / (2.507 * rms));
1147 startTick = peakTime - 3 *
rms;
1148 endTick = peakTime + 3 *
rms;
1167 firstHit.SignalType(),
1218 std::vector<unsigned int>& hitsInSlice,
1224 if (hitsInSlice.size() < 2)
return false;
1228 slc.
slHits.resize(hitsInSlice.size());
1230 unsigned int cstat = 0;
1231 unsigned int tpc = UINT_MAX;
1232 unsigned int cnt = 0;
1233 std::vector<unsigned int> nHitsInPln;
1234 for (
auto iht : hitsInSlice) {
1235 if (iht >= (*
evt.
allHits).size())
return false;
1238 cstat =
hit.WireID().Cryostat;
1239 tpc =
hit.WireID().TPC;
1244 if (
hit.WireID().Cryostat != cstat ||
hit.WireID().TPC != tpc)
return false;
1245 slc.
slHits[cnt].allHitsIndex = iht;
1246 ++nHitsInPln[
hit.WireID().Plane];
1250 for (
auto hip : nHitsInPln)
1251 if (hip < 2)
return false;
1261 if (
tcc.
dbgSlc) std::cout <<
"Enabled debugging in sub-slice " <<
slices.size() - 1 <<
"\n";
1269 for (
unsigned int iht = 0; iht < slc.
slHits.size(); ++iht) {
1270 unsigned int ahi = slc.
slHits[iht].allHitsIndex;
1272 std::cout <<
"CreateSlice: Bad allHitsIndex " << ahi <<
" " << (*
evt.
allHits).
size()
1288 for (
auto& slc :
slices) {
1289 if (!slc.isValid)
continue;
1291 for (
auto& pfp : slc.pfps) {
1292 if (pfp.ID <= 0)
continue;
1293 pfp.TjUIDs.resize(pfp.TjIDs.size());
1294 for (
unsigned short ii = 0; ii < pfp.TjIDs.size(); ++ii) {
1296 if (pfp.TjIDs[ii] <= 0 || pfp.TjIDs[ii] > (
int)slc.tjs.size()) {
1297 std::cout <<
"FinishEvent found an invalid T" << pfp.TjIDs[ii] <<
" in P" << pfp.UID
1299 slc.isValid =
false;
1302 auto& tj = slc.tjs[pfp.TjIDs[ii] - 1];
1303 pfp.TjUIDs[ii] = tj.UID;
1310 for (
auto& slc : slices)
Expect tracks entering from the front face. Don't create neutrino PFParticles.
calo::CalorimetryAlg * caloAlg
void ClearResults()
Deletes all the results.
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
void CheckTrajBeginChg(TCSlice &slc, unsigned short itj)
float AveChg
Calculated using ALL hits.
void ReleaseHits(TCSlice &slc, Trajectory &tj)
std::vector< int > EnvStage
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::vector< int > IsShowerParent
std::vector< Trajectory > tjs
vector of all trajectories in each plane
void StepAway(TCSlice &slc, Trajectory &tj)
void ConfigureMVA(TCConfig &tcc, std::string fMVAShowerParentWeights)
bool TrajHitsOK(TCSlice &slc, const std::vector< unsigned int > &iHitsInMultiplet, const std::vector< unsigned int > &jHitsInMultiplet)
std::vector< float > kinkCuts
kink finder algorithm
bool IsGhost(TCSlice &slc, Trajectory &tj)
bool InTrajOK(TCSlice &slc, std::string someText)
std::vector< float > EndWir
std::vector< float > EndAng
std::vector< unsigned int > PutTrajHitsInVector(const Trajectory &tj, HitStatus_t hitRequest)
const std::vector< std::string > AlgBitNames
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
short recoTPC
only reconstruct in the seleted TPC
std::vector< unsigned short > minPtsFit
Reconstruct in several passes.
std::vector< float > vtx3DCuts
2D vtx -> 3D vtx matching cuts
std::vector< float > qualityCuts
Min points/wire, min consecutive pts after a gap.
void Find3DVertices(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc)
std::vector< float > BeginTim
void AddHits(TCSlice &slc, Trajectory &tj, unsigned short ipt, bool &sigOK)
std::vector< float > BeginAng
void PrintTrajectory(std::string someText, const TCSlice &slc, const Trajectory &tj, unsigned short tPoint)
void SplitTrajCrossingVertices(TCSlice &slc, CTP_t inCTP)
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > wireHitRange
void Reconcile2Vs(TCSlice &slc)
int ParentID
ID of the parent, or the ID of the Tj this one was merged with if it is killed.
step from US -> DS (true) or DS -> US (false)
bool StoreTraj(TCSlice &slc, Trajectory &tj)
void RunTrajClusterAlg(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< unsigned int > &hitsInSlice, int sliceID)
calo::CalorimetryAlg fCaloAlg
float maxWireSkipWithSignal
max number of wires to skip with a signal on them
call study functions to develop cuts, etc
std::string PrintPos(const TCSlice &slc, const TrajPoint &tp)
void FillWireHitRange(geo::TPCID inTPCID)
bool AttachAnyTrajToVertex(TCSlice &slc, unsigned short ivx, bool prt)
std::vector< std::pair< unsigned int, unsigned int > > tpcSrcHitRange
bool MakeJunkTraj(TCSlice &slc, std::vector< unsigned int > tHits)
std::vector< float > electronTag
bool FindShowers3D(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc)
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)
std::vector< unsigned int > lastWire
the last wire with a hit
bool CreateSlice(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< unsigned int > &hitsInSlice, int sliceID)
bool LongPulseHit(const recob::Hit &hit)
unsigned int eventsProcessed
bool IsGood
set false if there is a failure or the Tj fails quality cuts
bool doForecast
See TCMode_t above.
void MakePFPTjs(TCSlice &slc)
std::vector< float > angleRanges
list of max angles for each angle range
const std::vector< std::string > EndFlagNames
std::vector< float > showerTag
shower-like trajectory tagging + shower reconstruction
unsigned short Pass
the pass on which it was created
int TDCtick_t
Type representing a TDC tick.
std::vector< float > EndTim
std::vector< int > ShowerID
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::vector< unsigned short > maxAngleCode
max allowed angle code for each pass
bool SetInputHits(std::vector< recob::Hit > const &inputHits, unsigned int run, unsigned int event)
void DefineShTree(TTree *t)
std::vector< unsigned int > fAlgModCount
float projectionErrFactor
unsigned int Hit
set to the hit index in evt.allHits if a Plane:Wire:Tick match is found
std::vector< std::string > StageName
float HitSep2(const TCSlice &slc, unsigned int iht, unsigned int jht)
int Cryostat
Select Cryostat.
float HitsRMSTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
short nPtsAve
dump trajectory points
void PFPVertexCheck(TCSlice &slc)
bool dbgStp
debug stepping using debug.Cryostat, debug.TPC, etc
recob::Hit MergeTPHitsOnWire(std::vector< unsigned int > &tpHits) const
don't mess with this line
float unitsPerTick
scale factor from Tick to WSE equivalent units
std::vector< short > minMCSMom
Min MCSMom for each pass.
bool BraggSplit(TCSlice &slc, unsigned short itj)
std::vector< short > BeginVtx
CTP_t CTP
Cryostat, TPC, Plane code.
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)
std::vector< TrajPoint > Pts
Trajectory points.
TMVA::Reader * showerParentReader
bool ChkVtxAssociations(TCSlice &slc, const CTP_t &inCTP)
T get(std::string const &key) const
std::vector< float > neutralVxCuts
void MakeHaloTj(TCSlice &slc, Trajectory &muTj, bool prt)
std::vector< short > EndVtx
std::vector< VtxStore > vtxs
2D vertices
std::array< unsigned short, 2 > EndPt
First and last point in the trajectory that has charge.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
std::vector< float > match3DCuts
3D matching cuts
void ScoreVertices(TCSlice &slc)
std::string PrintHit(const TCHit &tch)
std::vector< float > Envelope
call study functions to develop cuts, etc
const geo::GeometryCore * geom
std::vector< unsigned short > minPts
min number of Pts required to make a trajectory
bool has_key(std::string const &key) const
PlaneID_t Plane
Index of the plane within its TPC.
void DefineTjParents(TCSlice &slc, bool prt)
float HitsPosTick(const TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
std::vector< unsigned int > firstWire
the first wire with a hit
std::vector< float > BeginChg
int ID
ID that is local to one slice.
std::vector< TCSlice > slices
Detector simulation of raw signals on wires.
std::bitset< 16 > modes
number of points to find AveChg
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
std::vector< TCHit > slHits
std::vector< float > chargeCuts
bool aveHitRMSValid
set true when the average hit RMS is well-known
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< int > EnvPlane
std::vector< TrajPoint > seeds
float maxWireSkipNoSignal
max number of wires to skip w/o a signal on them
std::vector< short > MCSMom
void CheckTraj(TCSlice &slc, Trajectory &tj)
std::vector< float > vtxScoreWeights
bool DecodeDebugString(std::string strng)
std::vector< int > StageNum
std::vector< recob::Hit > const * srcHits
std::bitset< 128 > useAlg
Max hit separation for making junk trajectories. < 0 to turn off.
Contains all timing reference information for the detector.
std::vector< float > pfpStitchCuts
cuts for stitching between TPCs
std::vector< short > deltaRayTag
short StepDir
-1 = going US (-> small wire#), 1 = going DS (-> large wire#)
for(std::string line;std::getline(inFile, line);)
std::bitset< 128 > AlgMod
Bit set if algorithm AlgBit_t modifed the trajectory.
call study functions to develop cuts, etc
void LastEndMerge(TCSlice &slc, CTP_t inCTP)
std::vector< short > muonTag
void UpdateVxEnvironment(TCSlice &slc)
std::vector< float > BeginWir
geo::PlaneID DecodeCTP(CTP_t CTP)
std::optional< T > get_if_present(std::string const &key) const
std::vector< float > EndChg
TrajClusterAlg(fhicl::ParameterSet const &pset)
std::bitset< 128 > dbgAlg
Allow user to turn on debug printing in algorithms (that print...)
std::vector< recob::Hit > const * allHits
CTP_t EncodeCTP(unsigned int cryo, unsigned int tpc, unsigned int plane)
std::vector< unsigned int > nWires
void KillPoorVertices(TCSlice &slc)
std::vector< float > chkStopCuts
Bragg peak finder configuration.
int ID
ID of the recob::Slice (not the sub-slice)
void EndMerge(TCSlice &slc, CTP_t inCTP, bool lastPass)
void MergeTPHits(std::vector< unsigned int > &tpHits, std::vector< recob::Hit > &newHitCol, std::vector< unsigned int > &newHitAssns) const
void DefinePFPParents(TCSlice &slc, bool prt)
std::vector< float > vtx2DCuts
Max position pull, max Position error rms.
std::bitset< 8 > Strategy
void Finish3DShowers(TCSlice &slc)
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
void SetSourceHits(std::vector< recob::Hit > const &srcHits)
void FindPFParticles(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, TCSlice &slc)
float multHitSep
preferentially "merge" hits with < this separation
2D representation of charge deposited in the TDC/wire plane
void ChkInTraj(std::string someText, TCSlice &slc)
void ReconstructAllTraj(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, CTP_t inCTP)
unsigned short NumPtsWithCharge(const TCSlice &slc, const Trajectory &tj, bool includeDeadWires)
std::vector< int > EnvShowerID
void MakeJunkVertices(TCSlice &slc, const CTP_t &inCTP)
call study functions to develop cuts, etc (see TCTruth.cxx)
void Find2DVertices(detinfo::DetectorPropertiesData const &detProp, TCSlice &slc, const CTP_t &inCTP, unsigned short pass)
auto const & get(AssnsNode< L, R, D > const &r)
std::vector< int > IsShowerTj
std::vector< short > PlaneNum
short recoSlice
only reconstruct the slice with ID (0 = all)
master switch for turning on debug mode
don't mess with this line
CTP_t CTP
set to an invalid CTP
QTextStream & endl(QTextStream &s)
Event finding and building.
void SetTPEnvironment(TCSlice &slc, CTP_t inCTP)
void FindJunkTraj(TCSlice &slc, CTP_t inCTP)