LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
tca::TrajClusterAlg Class Reference

#include "TrajClusterAlg.h"

Data structures for the reconstruction results

TruthMatcher fTM
 Deletes all the results. More...
 
TTree * showertree
 Deletes all the results. More...
 
calo::CalorimetryAlg fCaloAlg
 Deletes all the results. More...
 
TMVA::Reader fMVAReader
 Deletes all the results. More...
 
std::vector< unsigned int > fAlgModCount
 Deletes all the results. More...
 
 TrajClusterAlg (fhicl::ParameterSet const &pset)
 Deletes all the results. More...
 
virtual void reconfigure (fhicl::ParameterSet const &pset)
 Deletes all the results. More...
 
bool SetInputHits (std::vector< recob::Hit > const &inputHits)
 Deletes all the results. More...
 
void RunTrajClusterAlg (std::vector< unsigned int > &hitsInSlice, int sliceID)
 Deletes all the results. More...
 
bool CreateSlice (std::vector< unsigned int > &hitsInSlice)
 Deletes all the results. More...
 
void FinishEvent ()
 Deletes all the results. More...
 
void DefineShTree (TTree *t)
 Deletes all the results. More...
 
unsigned short GetSlicesSize ()
 Deletes all the results. More...
 
TCSlice const & GetSlice (unsigned short sliceIndex) const
 Deletes all the results. More...
 
void MergeTPHits (std::vector< unsigned int > &tpHits, std::vector< recob::Hit > &newHitCol, std::vector< unsigned int > &newHitAssns)
 Deletes all the results. More...
 
std::vector< unsigned int > const & GetAlgModCount () const
 Deletes all the results. More...
 
std::vector< std::string > const & GetAlgBitNames () const
 Deletes all the results. More...
 
void ClearResults ()
 Deletes all the results. More...
 
recob::Hit MergeTPHitsOnWire (std::vector< unsigned int > &tpHits)
 Deletes all the results. More...
 
void ReconstructAllTraj (TCSlice &slc, CTP_t inCTP)
 Deletes all the results. More...
 
void FindJunkTraj (TCSlice &slc, CTP_t inCTP)
 Deletes all the results. More...
 
void ChkInTraj (std::string someText, TCSlice &slc)
 Deletes all the results. More...
 
void FindMissedVxTjs (TCSlice &slc)
 Deletes all the results. More...
 

Detailed Description

Definition at line 49 of file TrajClusterAlg.h.

Constructor & Destructor Documentation

tca::TrajClusterAlg::TrajClusterAlg ( fhicl::ParameterSet const &  pset)

Deletes all the results.

Definition at line 18 of file TrajClusterAlg.cxx.

References tca::TCConfig::caloAlg, fCaloAlg, fMVAReader, reconfigure(), tca::TCConfig::showerParentReader, and tca::tcc.

19  :fCaloAlg(pset.get<fhicl::ParameterSet>("CaloAlg")), fMVAReader("Silent")
20  {
22  reconfigure(pset);
23  tcc.caloAlg = &fCaloAlg;
24 // art::ServiceHandle<art::TFileService> tfs;
25 // hist.CreateHists(*tfs);
26 // tm.Initialize();
27  }
calo::CalorimetryAlg * caloAlg
Definition: DataStructs.h:495
TCConfig tcc
Definition: DataStructs.cxx:6
calo::CalorimetryAlg fCaloAlg
Deletes all the results.
TMVA::Reader * showerParentReader
Definition: DataStructs.h:496
virtual void reconfigure(fhicl::ParameterSet const &pset)
Deletes all the results.
TMVA::Reader fMVAReader
Deletes all the results.

Member Function Documentation

void tca::TrajClusterAlg::ChkInTraj ( std::string  someText,
TCSlice slc 
)
private

Deletes all the results.

Definition at line 876 of file TrajClusterAlg.cxx.

References tca::AlgBitNames, evd::details::end(), fAlgModCount, tca::TCSlice::isValid, tca::kChkInTraj, tca::kKilled, tca::kUsedHits, tca::PrintHit(), tca::PrintTrajectory(), tca::PutTrajHitsInVector(), tca::TCSlice::slHits, tca::tcc, tca::TCSlice::tjs, tca::TCConfig::useAlg, and tca::TCSlice::vtxs.

877  {
878  // Check slc.tjs -> InTraj associations
879 
880  if(!tcc.useAlg[kChkInTraj]) return;
881 
883 
884  int tID;
885  unsigned int iht;
886  unsigned short itj = 0;
887  std::vector<unsigned int> tHits;
888  std::vector<unsigned int> atHits;
889  for(auto& tj : slc.tjs) {
890  // ignore abandoned trajectories
891  if(tj.AlgMod[kKilled]) continue;
892  tID = tj.ID;
893  for(auto& tp : tj.Pts) {
894  if(tp.Hits.size() > 16) {
895  tj.AlgMod[kKilled] = true;
896  mf::LogWarning("TC")<<"ChkInTraj: More than 16 hits created a UseHit bitset overflow\n";
897  slc.isValid = false;
898  return;
899  }
900  } // tp
901  if(tj.AlgMod[kKilled]) {
902  std::cout<<someText<<" ChkInTraj hit size mis-match in tj ID "<<tj.ID<<" AlgBitNames";
903  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) if(tj.AlgMod[ib]) std::cout<<" "<<AlgBitNames[ib];
904  std::cout<<"\n";
905  continue;
906  }
907  tHits = PutTrajHitsInVector(tj, kUsedHits);
908  if(tHits.size() < 2) {
909  mf::LogVerbatim("TC")<<someText<<" ChkInTraj: Insufficient hits in traj "<<tj.ID;
910  PrintTrajectory("CIT", slc, tj, USHRT_MAX);
911  tj.AlgMod[kKilled] = true;
912  continue;
913  }
914  std::sort(tHits.begin(), tHits.end());
915  atHits.clear();
916  for(iht = 0; iht < slc.slHits.size(); ++iht) {
917  if(slc.slHits[iht].InTraj == tID) atHits.push_back(iht);
918  } // iht
919  if(atHits.size() < 2) {
920  mf::LogVerbatim("TC")<<someText<<" ChkInTraj: Insufficient hits in atHits in traj "<<tj.ID<<" Killing it";
921  tj.AlgMod[kKilled] = true;
922  continue;
923  }
924  if(!std::equal(tHits.begin(), tHits.end(), atHits.begin())) {
925  mf::LogVerbatim myprt("TC");
926  myprt<<someText<<" ChkInTraj failed: inTraj - UseHit mis-match for tj ID "<<tID<<" tj.WorkID "<<tj.WorkID<<" atHits size "<<atHits.size()<<" tHits size "<<tHits.size()<<" in CTP "<<tj.CTP<<"\n";
927  myprt<<"AlgMods: ";
928  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) if(tj.AlgMod[ib]) myprt<<" "<<AlgBitNames[ib];
929  myprt<<"\n";
930  myprt<<"index inTraj UseHit \n";
931  for(iht = 0; iht < atHits.size(); ++iht) {
932  myprt<<"iht "<<iht<<" "<<PrintHit(slc.slHits[atHits[iht]]);
933  if(iht < tHits.size()) myprt<<" "<<PrintHit(slc.slHits[tHits[iht]]);
934  if(atHits[iht] != tHits[iht]) myprt<<" <<< "<<atHits[iht]<<" != "<<tHits[iht];
935  myprt<<"\n";
936  slc.isValid = false;
937  } // iht
938  if(tHits.size() > atHits.size()) {
939  for(iht = atHits.size(); iht < atHits.size(); ++iht) {
940  myprt<<"atHits "<<iht<<" "<<PrintHit(slc.slHits[atHits[iht]])<<"\n";
941  } // iht
942  PrintTrajectory("CIT", slc, tj, USHRT_MAX);
943  } // tHit.size > atHits.size()
944  }
945  // check the VtxID
946  for(unsigned short end = 0; end < 2; ++end) {
947  if(tj.VtxID[end] > slc.vtxs.size()) {
948  mf::LogVerbatim("TC")<<someText<<" ChkInTraj: Bad VtxID "<<tj.ID;
949  std::cout<<someText<<" ChkInTraj: Bad VtxID "<<tj.ID<<" vtx size "<<slc.vtxs.size()<<"\n";
950  tj.AlgMod[kKilled] = true;
951  PrintTrajectory("CIT", slc, tj, USHRT_MAX);
952  slc.isValid = false;
953  return;
954  }
955  } // end
956  ++itj;
957  if(!slc.isValid) return;
958  } // tj
959 
960  } // ChkInTraj
void PrintTrajectory(std::string someText, TCSlice &slc, const Trajectory &tj, unsigned short tPoint)
Definition: Utils.cxx:5455
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
const std::vector< std::string > AlgBitNames
Definition: DataStructs.cxx:13
TCConfig tcc
Definition: DataStructs.cxx:6
std::vector< unsigned int > PutTrajHitsInVector(Trajectory const &tj, HitStatus_t hitRequest)
Definition: Utils.cxx:2416
std::vector< unsigned int > fAlgModCount
Deletes all the results.
std::string PrintHit(const TCHit &tch)
Definition: Utils.cxx:5704
std::bitset< 128 > useAlg
Max hit separation for making junk trajectories. < 0 to turn off.
Definition: DataStructs.h:504
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
void tca::TrajClusterAlg::ClearResults ( )
inline

Deletes all the results.

Definition at line 79 of file TrajClusterAlg.h.

References tca::slices.

Referenced by SetInputHits().

79 { slices.resize(0); }
std::vector< TCSlice > slices
Definition: DataStructs.cxx:10
bool tca::TrajClusterAlg::CreateSlice ( std::vector< unsigned int > &  hitsInSlice)

Deletes all the results.

Definition at line 1253 of file TrajClusterAlg.cxx.

References tca::TCEvent::allHits, tca::DebugStuff::Cryostat, tca::DebugStuff::CTP, tca::TCConfig::dbgSlc, tca::debug, tca::EncodeCTP(), tca::evt, tca::FillWireHitRange(), tca::TCSlice::isValid, tca::kDebug, tca::TCConfig::modes, tca::DebugStuff::Plane, tca::TCSlice::slHits, tca::DebugStuff::Slice, tca::slices, tca::tcc, tca::DebugStuff::TPC, and tca::TCSlice::TPCID.

Referenced by RunTrajClusterAlg().

1254  {
1255  // Defines a TCSlice struct and pushes the slice onto slices.
1256  // Sets the isValid flag true if successful.
1257  if((*evt.allHits).empty()) return false;
1258  if(hitsInSlice.size() < 2) return false;
1259 
1260  TCSlice slc;
1261  slc.slHits.resize(hitsInSlice.size());
1262  bool first = true;
1263  unsigned int cstat = 0;
1264  unsigned int tpc = 0;
1265  unsigned int cnt = 0;
1266  for(auto iht : hitsInSlice) {
1267  if(iht > (*evt.allHits).size() - 1) return false;
1268  auto& hit = (*evt.allHits)[iht];
1269  if(first) {
1270  cstat = hit.WireID().Cryostat;
1271  tpc = hit.WireID().TPC;
1272  slc.TPCID = geo::TPCID(cstat, tpc);
1273  first = false;
1274  }
1275  if(hit.WireID().Cryostat != cstat || hit.WireID().TPC != tpc) return false;
1276  slc.slHits[cnt].allHitsIndex = iht;
1277  ++cnt;
1278  } // iht
1279  // Define the wire hit range vectors, UnitsPerTick, etc
1280  if(!FillWireHitRange(slc)) return false;
1281  slc.isValid = true;
1282  slices.push_back(slc);
1283  if(tcc.modes[kDebug] && debug.Slice >= 0 && !tcc.dbgSlc) {
1284  tcc.dbgSlc = ((int)(slices.size() - 1) == debug.Slice);
1285  if(tcc.dbgSlc) std::cout<<"Enabled debugging in sub-slice "<<slices.size() - 1<<"\n";
1286  if(tcc.modes[kDebug] && (unsigned int)debug.Cryostat == cstat && (unsigned int)debug.TPC == tpc && debug.Plane >= 0) {
1287  debug.CTP = EncodeCTP((unsigned int)debug.Cryostat, (unsigned int)debug.TPC, (unsigned int)debug.Plane);
1288  }
1289  }
1290  return true;
1291  } // CreateSlice
TCConfig tcc
Definition: DataStructs.cxx:6
bool dbgSlc
debug only in the user-defined slice? default is all slices
Definition: DataStructs.h:507
int Cryostat
Select Cryostat.
Definition: DebugStruct.h:19
DebugStuff debug
Definition: DebugStruct.cxx:4
int Plane
Select plane.
Definition: DebugStruct.h:21
The data type to uniquely identify a TPC.
Definition: geo_types.h:195
std::vector< TCSlice > slices
Definition: DataStructs.cxx:10
Detector simulation of raw signals on wires.
std::bitset< 16 > modes
number of points to find AveChg
Definition: DataStructs.h:524
int TPC
Select TPC.
Definition: DebugStruct.h:20
std::vector< recob::Hit > const * allHits
Definition: DataStructs.h:536
CTP_t EncodeCTP(unsigned int cryo, unsigned int tpc, unsigned int plane)
Definition: DataStructs.h:45
bool FillWireHitRange(TCSlice &slc)
Definition: Utils.cxx:3944
TCEvent evt
Definition: DataStructs.cxx:5
master switch for turning on debug mode
Definition: DataStructs.h:449
CTP_t CTP
set to an invalid CTP
Definition: DebugStruct.h:22
void tca::TrajClusterAlg::DefineShTree ( TTree *  t)

Deletes all the results.

Definition at line 1201 of file TrajClusterAlg.cxx.

References tca::ShowerTreeVars::BeginAng, tca::ShowerTreeVars::BeginChg, tca::ShowerTreeVars::BeginTim, tca::ShowerTreeVars::BeginVtx, tca::ShowerTreeVars::BeginWir, tca::ShowerTreeVars::EndAng, tca::ShowerTreeVars::EndChg, tca::ShowerTreeVars::EndTim, tca::ShowerTreeVars::EndVtx, tca::ShowerTreeVars::EndWir, tca::ShowerTreeVars::Envelope, tca::ShowerTreeVars::EnvPlane, tca::ShowerTreeVars::EnvShowerID, tca::ShowerTreeVars::EnvStage, tca::TCEvent::event, tca::evt, tca::ShowerTreeVars::IsShowerParent, tca::ShowerTreeVars::IsShowerTj, tca::ShowerTreeVars::MCSMom, tca::ShowerTreeVars::nPlanes, tca::ShowerTreeVars::nStages, tca::ShowerTreeVars::PlaneNum, tca::TCEvent::run, tca::ShowerTreeVars::ShowerID, showertree, tca::ShowerTreeVars::StageName, tca::ShowerTreeVars::StageNum, tca::stv, tca::TCEvent::subRun, and tca::ShowerTreeVars::TjID.

1201  {
1202  showertree = t;
1203 
1204  showertree->Branch("run", &evt.run, "run/I");
1205  showertree->Branch("subrun", &evt.subRun, "subrun/I");
1206  showertree->Branch("event", &evt.event, "event/I");
1207 
1208  showertree->Branch("BeginWir", &stv.BeginWir);
1209  showertree->Branch("BeginTim", &stv.BeginTim);
1210  showertree->Branch("BeginAng", &stv.BeginAng);
1211  showertree->Branch("BeginChg", &stv.BeginChg);
1212  showertree->Branch("BeginVtx", &stv.BeginVtx);
1213 
1214  showertree->Branch("EndWir", &stv.EndWir);
1215  showertree->Branch("EndTim", &stv.EndTim);
1216  showertree->Branch("EndAng", &stv.EndAng);
1217  showertree->Branch("EndChg", &stv.EndChg);
1218  showertree->Branch("EndVtx", &stv.EndVtx);
1219 
1220  showertree->Branch("MCSMom", &stv.MCSMom);
1221 
1222  showertree->Branch("PlaneNum", &stv.PlaneNum);
1223  showertree->Branch("TjID", &stv.TjID);
1224  showertree->Branch("IsShowerTj", &stv.IsShowerTj);
1225  showertree->Branch("ShowerID", &stv.ShowerID);
1226  showertree->Branch("IsShowerParent", &stv.IsShowerParent);
1227  showertree->Branch("StageNum", &stv.StageNum);
1228  showertree->Branch("StageName", &stv.StageName);
1229 
1230  showertree->Branch("Envelope", &stv.Envelope);
1231  showertree->Branch("EnvPlane", &stv.EnvPlane);
1232  showertree->Branch("EnvStage", &stv.EnvStage);
1233  showertree->Branch("EnvShowerID", &stv.EnvShowerID);
1234 
1235  showertree->Branch("nStages", &stv.nStages);
1236  showertree->Branch("nPlanes", &stv.nPlanes);
1237 
1238  } // end DefineShTree
std::vector< int > EnvStage
Definition: DataStructs.h:330
std::vector< int > IsShowerParent
Definition: DataStructs.h:323
unsigned int event
Definition: DataStructs.h:537
std::vector< float > EndWir
Definition: DataStructs.h:310
std::vector< float > EndAng
Definition: DataStructs.h:312
unsigned int run
Definition: DataStructs.h:538
std::vector< float > BeginTim
Definition: DataStructs.h:306
std::vector< float > BeginAng
Definition: DataStructs.h:307
std::vector< float > EndTim
Definition: DataStructs.h:311
std::vector< int > ShowerID
Definition: DataStructs.h:322
ShowerTreeVars stv
Definition: DataStructs.cxx:8
std::vector< std::string > StageName
Definition: DataStructs.h:325
std::vector< int > TjID
Definition: DataStructs.h:320
std::vector< short > BeginVtx
Definition: DataStructs.h:309
std::vector< short > EndVtx
Definition: DataStructs.h:314
std::vector< float > Envelope
Definition: DataStructs.h:328
std::vector< float > BeginChg
Definition: DataStructs.h:308
std::vector< int > EnvPlane
Definition: DataStructs.h:329
std::vector< short > MCSMom
Definition: DataStructs.h:316
std::vector< int > StageNum
Definition: DataStructs.h:324
unsigned short nPlanes
Definition: DataStructs.h:334
std::vector< float > BeginWir
Definition: DataStructs.h:305
TTree * showertree
Deletes all the results.
std::vector< float > EndChg
Definition: DataStructs.h:313
unsigned int subRun
Definition: DataStructs.h:539
std::vector< int > EnvShowerID
Definition: DataStructs.h:331
TCEvent evt
Definition: DataStructs.cxx:5
std::vector< int > IsShowerTj
Definition: DataStructs.h:321
std::vector< short > PlaneNum
Definition: DataStructs.h:318
void tca::TrajClusterAlg::FindJunkTraj ( TCSlice slc,
CTP_t  inCTP 
)
private

Deletes all the results.

Definition at line 730 of file TrajClusterAlg.cxx.

References tca::TCConfig::dbgAlg, tca::TCConfig::dbgStp, tca::debug, tca::DecodeCTP(), tca::TCSlice::firstWire, tca::GetHitMultiplet(), tca::DebugStuff::Hit, tca::HitSep2(), tca::IsGhost(), tca::TCConfig::JTMaxHitSep2, tca::kDebug, tca::kJunkTj, tca::TCSlice::lastWire, tca::MakeJunkTraj(), tca::TCConfig::modes, tca::TCSlice::nWires, geo::PlaneID::Plane, tca::PrintHit(), tca::TCSlice::slHits, tca::tcc, tca::TrajHitsOK(), tca::TCConfig::useAlg, and tca::TCSlice::wireHitRange.

Referenced by ReconstructAllTraj().

731  {
732  // Makes junk trajectories using unassigned hits
733 
734  if(!tcc.useAlg[kJunkTj]) return;
735 
736  // shouldn't have to do this but...
737  for(auto& slHit : slc.slHits) {
738  if(slHit.InTraj < 0) {
739  std::cout<<"FJT: dirty hit "<<PrintHit(slHit)<<"\n";
740  slHit.InTraj = 0;
741  }
742  }
743  unsigned short plane = DecodeCTP(inCTP).Plane;
744  std::vector<unsigned int> tHits;
745  // Stay well away from the last wire in the plane
746  for(unsigned int iwire = slc.firstWire[plane]; iwire < slc.lastWire[plane] - 3; ++iwire) {
747  // skip bad wires or no hits on the wire
748  if(slc.wireHitRange[plane][iwire].first < 0) continue;
749  unsigned int jwire = iwire + 1;
750  if(slc.wireHitRange[plane][jwire].first < 0) continue;
751  unsigned int ifirsthit = (unsigned int)slc.wireHitRange[plane][iwire].first;
752  unsigned int ilasthit = (unsigned int)slc.wireHitRange[plane][iwire].second;
753  unsigned int jfirsthit = (unsigned int)slc.wireHitRange[plane][jwire].first;
754  unsigned int jlasthit = (unsigned int)slc.wireHitRange[plane][jwire].second;
755  for(unsigned int iht = ifirsthit; iht < ilasthit; ++iht) {
756  tcc.dbgStp = (tcc.modes[kDebug] && slc.slHits[iht].allHitsIndex == debug.Hit);
757  auto& islHit = slc.slHits[iht];
758  if(islHit.InTraj != 0) continue;
759  bool prt = (tcc.dbgStp || tcc.dbgAlg[kJunkTj]);
760  if(prt) {
761  mf::LogVerbatim("TC")<<"FindJunkTraj: Found debug hit "<<PrintHit(islHit)<<" iht "<<iht<<" jfirsthit "<<jfirsthit<<" jlasthit "<<jlasthit;
762  }
763  std::vector<unsigned int> iHits;
764  GetHitMultiplet(slc, iht, iHits);
765  for(unsigned int jht = jfirsthit; jht < jlasthit; ++jht) {
766  auto& jslHit = slc.slHits[jht];
767  if(jslHit.InTraj != 0) continue;
768  if(prt && HitSep2(slc, iht, jht) < 100) mf::LogVerbatim("TC")<<" use "<<PrintHit(jslHit);
769  if(HitSep2(slc, iht, jht) > tcc.JTMaxHitSep2) continue;
770  std::vector<unsigned int> jHits;
771  GetHitMultiplet(slc, jht, jHits);
772  // check for hit overlap consistency
773  if(!TrajHitsOK(slc, iHits, jHits)) continue;
774  tHits.clear();
775  // add the available hits and flag them
776  for(auto iht : iHits) if(slc.slHits[iht].InTraj == 0) tHits.push_back(iht);
777  for(auto jht : jHits) if(slc.slHits[jht].InTraj == 0) tHits.push_back(jht);
778  for(auto tht : tHits) slc.slHits[tht].InTraj = -4;
779  unsigned int loWire;
780  if(iwire != 0) { loWire = iwire - 1; } else { loWire = 0; }
781  unsigned int hiWire = jwire + 1;
782  if(hiWire > slc.nWires[plane]) break;
783 // if(jwire < slc.nWires[plane] - 3) { hiWire = jwire + 2; } else { hiWire = slc.nWires[plane] - 1; }
784  unsigned short nit = 0;
785  while(nit < 100) {
786  bool hitsAdded = false;
787  for(unsigned int kwire = loWire; kwire <= hiWire; ++kwire) {
788  if(slc.wireHitRange[plane][kwire].first < 0) continue;
789  unsigned int kfirsthit = (unsigned int)slc.wireHitRange[plane][kwire].first;
790  unsigned int klasthit = (unsigned int)slc.wireHitRange[plane][kwire].second;
791  for(unsigned int kht = kfirsthit; kht < klasthit; ++kht) {
792  if(slc.slHits[kht].InTraj != 0) continue;
793  // this shouldn't be needed but do it anyway
794  if(std::find(tHits.begin(), tHits.end(), kht) != tHits.end()) continue;
795  // re-purpose jHits and check for consistency
796  GetHitMultiplet(slc, kht, jHits);
797  if(!TrajHitsOK(slc, tHits, jHits)) continue;
798  // add them all and update the wire range
799  for(auto jht : jHits) {
800  if(slc.slHits[jht].InTraj != 0) continue;
801  tHits.push_back(jht);
802  slc.slHits[jht].InTraj = -4;
803  if(kwire > hiWire) hiWire = kwire;
804  if(kwire < loWire) loWire = kwire;
805  hitsAdded = true;
806  } // jht
807  } // kht
808  } // kwire
809  if(!hitsAdded) break;
810  ++nit;
811  ++hiWire;
812  if(hiWire >= slc.nWires[plane]) break;
813  } // nit < 100
814  // clear InTraj
815  for(auto iht : tHits) slc.slHits[iht].InTraj = 0;
816  if(prt) {
817  mf::LogVerbatim myprt("TC");
818  myprt<<"FJT: tHits";
819  for(auto tht : tHits) myprt<<" "<<PrintHit(slc.slHits[tht]);
820  myprt<<"\n";
821  } // prt
822  // See if this is a ghost trajectory
823  if(IsGhost(slc, tHits)) break;
824  if(!MakeJunkTraj(slc, tHits)) {
825  if(prt) mf::LogVerbatim()<<"FJT: MakeJunkTraj failed";
826  break;
827  }
828  if(slc.slHits[jht].InTraj > 0) break;
829  } // jht
830  } // iht
831  } // iwire
832  } // FindJunkTraj
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
bool TrajHitsOK(TCSlice &slc, const std::vector< unsigned int > &iHitsInMultiplet, const std::vector< unsigned int > &jHitsInMultiplet)
Definition: Utils.cxx:1736
bool IsGhost(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:3221
TCConfig tcc
Definition: DataStructs.cxx:6
void GetHitMultiplet(TCSlice &slc, unsigned int theHit, std::vector< unsigned int > &hitsInMultiplet)
Definition: StepUtils.cxx:1573
bool MakeJunkTraj(TCSlice &slc, std::vector< unsigned int > tHits)
Definition: StepUtils.cxx:4223
unsigned int Hit
set to the hit index in evt.allHits if a Plane:Wire:Tick match is found
Definition: DebugStruct.h:25
bool dbgStp
debug stepping using debug.Cryostat, debug.TPC, etc
Definition: DataStructs.h:508
DebugStuff debug
Definition: DebugStruct.cxx:4
std::string PrintHit(const TCHit &tch)
Definition: Utils.cxx:5704
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
std::bitset< 16 > modes
number of points to find AveChg
Definition: DataStructs.h:524
std::bitset< 128 > useAlg
Max hit separation for making junk trajectories. < 0 to turn off.
Definition: DataStructs.h:504
geo::PlaneID DecodeCTP(CTP_t CTP)
std::bitset< 128 > dbgAlg
Allow user to turn on debug printing in algorithms (that print...)
Definition: DataStructs.h:505
float HitSep2(TCSlice &slc, unsigned int iht, unsigned int jht)
Definition: Utils.cxx:2239
float JTMaxHitSep2
Definition: DataStructs.h:503
master switch for turning on debug mode
Definition: DataStructs.h:449
void tca::TrajClusterAlg::FindMissedVxTjs ( TCSlice slc)
private

Deletes all the results.

Definition at line 963 of file TrajClusterAlg.cxx.

References detinfo::DetectorProperties::ConvertXToTicks(), geo::CryostatID::Cryostat, tca::TCConfig::dbg3V, tca::TCConfig::dbgAlg, tca::TCConfig::dbgStp, tca::TCConfig::detprop, tca::EncodeCTP(), tca::Vtx3Store::ID, tca::kComp3DVx, tca::kHaloTj, tca::kKilled, tca::kMisdVxTj, tca::TCSlice::nPlanes, tca::TrajPoint::Pos, tca::tcc, tca::TCSlice::tjs, geo::TPCID::TPC, tca::Vtx3Store::TPCID, tca::TrajPointTrajDOCA(), tca::TCConfig::unitsPerTick, tca::TCConfig::useAlg, tca::TCSlice::vtx3s, tca::TCSlice::vtxs, tca::Vtx3Store::Vx2ID, tca::Vtx3Store::Wire, and tca::Vtx3Store::X.

Referenced by RunTrajClusterAlg().

964  {
965  // Find missing 2D vertices in a plane due to a mis-reconstructed Tj
966 
967  if(!tcc.useAlg[kMisdVxTj]) return;
968 
969  bool prt = (tcc.dbgStp || tcc.dbg3V || tcc.dbgAlg[kMisdVxTj]);
970 
971  float maxdoca = 6;
972  for(unsigned short iv3 = 0; iv3 < slc.vtx3s.size(); ++iv3) {
973  Vtx3Store& vx3 = slc.vtx3s[iv3];
974  // ignore obsolete vertices
975  if(vx3.ID == 0) continue;
976  // check for a completed 3D vertex
977  if(vx3.Wire < 0) continue;
978  unsigned short mPlane = USHRT_MAX;
979  unsigned short ntj_1stPlane = USHRT_MAX;
980  unsigned short ntj_2ndPlane = USHRT_MAX;
981  for(unsigned short plane = 0; plane < slc.nPlanes; ++plane) {
982  if(vx3.Vx2ID[plane] > 0) {
983  auto& vx2 = slc.vtxs[vx3.Vx2ID[plane] - 1];
984  if(ntj_1stPlane == USHRT_MAX) {
985  ntj_1stPlane = vx2.NTraj;
986  } else {
987  ntj_2ndPlane = vx2.NTraj;
988  }
989  continue;
990  }
991  mPlane = plane;
992  } // plane
993  if(mPlane == USHRT_MAX) continue;
994  CTP_t mCTP = EncodeCTP(vx3.TPCID.Cryostat, vx3.TPCID.TPC, mPlane);
995  // X position of the purported missing vertex
996  // A TP for the missing 2D vertex
997  TrajPoint tp;
998  tp.Pos[0] = vx3.Wire;
999  tp.Pos[1] = tcc.detprop->ConvertXToTicks(vx3.X, mPlane, vx3.TPCID.TPC, vx3.TPCID.Cryostat) * tcc.unitsPerTick;
1000  std::vector<int> tjIDs;
1001  std::vector<unsigned short> tj2Pts;
1002  for(unsigned short itj = 0; itj < slc.tjs.size(); ++itj) {
1003  auto& tj = slc.tjs[itj];
1004  if(tj.CTP != mCTP) continue;
1005  if(tj.AlgMod[kKilled] || tj.AlgMod[kHaloTj]) continue;
1006  if(tj.Pts.size() < 6) continue;
1007  if(tj.AlgMod[kComp3DVx]) continue;
1008  float doca = maxdoca;
1009  // find the closest distance between the vertex and the trajectory
1010  unsigned short closePt = 0;
1011  TrajPointTrajDOCA(slc, tp, tj, closePt, doca);
1012  if(closePt > tj.EndPt[1]) continue;
1013  if(prt) mf::LogVerbatim("TC")<<"MisdVxTj: 3V"<<vx3.ID<<" candidate T"<<slc.tjs[itj].ID<<" closePT "<<closePt<<" doca "<<doca;
1014  tjIDs.push_back(tj.ID);
1015  tj2Pts.push_back(closePt);
1016  } // itj
1017  // handle the case where there are one or more TJs with TPs near the ends
1018  // that make a vertex (a failure by Find2DVertices)
1019  if(tjIDs.empty()) continue;
1020  if(prt) mf::LogVerbatim("TC")<<" 3V"<<vx3.ID<<" mPlane "<<mPlane<<" ntj_1stPlane "<<ntj_1stPlane<<" ntj_2ndPlane "<<ntj_2ndPlane;
1021  } // iv3
1022  } // FindMissedVxTjs
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void TrajPointTrajDOCA(TCSlice &slc, TrajPoint const &tp, Trajectory const &tj, unsigned short &closePt, float &minSep)
Definition: Utils.cxx:2155
TCConfig tcc
Definition: DataStructs.cxx:6
virtual double ConvertXToTicks(double X, int p, int t, int c) const =0
bool dbg3V
debug 3D vertex finding
Definition: DataStructs.h:514
bool dbgStp
debug stepping using debug.Cryostat, debug.TPC, etc
Definition: DataStructs.h:508
float unitsPerTick
scale factor from Tick to WSE equivalent units
Definition: DataStructs.h:488
const detinfo::DetectorProperties * detprop
Definition: DataStructs.h:494
unsigned int CTP_t
Definition: DataStructs.h:41
std::bitset< 128 > useAlg
Max hit separation for making junk trajectories. < 0 to turn off.
Definition: DataStructs.h:504
std::bitset< 128 > dbgAlg
Allow user to turn on debug printing in algorithms (that print...)
Definition: DataStructs.h:505
CTP_t EncodeCTP(unsigned int cryo, unsigned int tpc, unsigned int plane)
Definition: DataStructs.h:45
void tca::TrajClusterAlg::FinishEvent ( )

Deletes all the results.

Definition at line 1294 of file TrajClusterAlg.cxx.

References tca::PFPVertexCheck(), tca::slices, and tca::StitchPFPs().

1295  {
1296  // final steps that involve correlations between slices
1297  // Stitch PFParticles between TPCs
1298 
1299  // define the PFP TjUIDs vector before calling StitchPFPs
1300  for(auto& slc : slices) {
1301  if(!slc.isValid) continue;
1302  for(auto& pfp : slc.pfps) {
1303  if(pfp.ID <= 0) continue;
1304  pfp.TjUIDs.resize(pfp.TjIDs.size());
1305  for(unsigned short ii = 0; ii < pfp.TjIDs.size(); ++ii) {
1306  // do a sanity check while we are here
1307  if(pfp.TjIDs[ii] <=0 || pfp.TjIDs[ii] > (int)slc.tjs.size()) {
1308  std::cout<<"FinishEvent found an invalid T"<<pfp.TjIDs[ii]<<" in P"<<pfp.UID<<"\n";
1309  slc.isValid = false;
1310  continue;
1311  } // sanity check
1312  auto& tj = slc.tjs[pfp.TjIDs[ii] - 1];
1313  pfp.TjUIDs[ii] = tj.UID;
1314  } // ii
1315  } // pfp
1316  } // slc
1317 
1318  StitchPFPs();
1319  // TODO: Try to make a neutrino PFParticle here
1320  // Ensure that all PFParticles have a start vertex
1321  for(auto& slc : slices) PFPVertexCheck(slc);
1322  } // FinishEvent
void PFPVertexCheck(TCSlice &slc)
Definition: PFPUtils.cxx:2502
std::vector< TCSlice > slices
Definition: DataStructs.cxx:10
void StitchPFPs()
Definition: PFPUtils.cxx:16
std::vector<std::string> const& tca::TrajClusterAlg::GetAlgBitNames ( ) const
inline

Deletes all the results.

Definition at line 76 of file TrajClusterAlg.h.

References tca::AlgBitNames.

76 {return AlgBitNames; }
const std::vector< std::string > AlgBitNames
Definition: DataStructs.cxx:13
std::vector<unsigned int> const& tca::TrajClusterAlg::GetAlgModCount ( ) const
inline

Deletes all the results.

Definition at line 75 of file TrajClusterAlg.h.

References fAlgModCount.

75 {return fAlgModCount; }
std::vector< unsigned int > fAlgModCount
Deletes all the results.
TCSlice const& tca::TrajClusterAlg::GetSlice ( unsigned short  sliceIndex) const
inline

Deletes all the results.

Definition at line 71 of file TrajClusterAlg.h.

References MergeTPHits(), and tca::slices.

71 {return slices[sliceIndex]; }
std::vector< TCSlice > slices
Definition: DataStructs.cxx:10
unsigned short tca::TrajClusterAlg::GetSlicesSize ( )
inline

Deletes all the results.

Definition at line 70 of file TrajClusterAlg.h.

References tca::slices.

70 { return slices.size(); }
std::vector< TCSlice > slices
Definition: DataStructs.cxx:10
void tca::TrajClusterAlg::MergeTPHits ( std::vector< unsigned int > &  tpHits,
std::vector< recob::Hit > &  newHitCol,
std::vector< unsigned int > &  newHitAssns 
)

Deletes all the results.

Definition at line 1025 of file TrajClusterAlg.cxx.

References tca::TCEvent::allHits, tca::evt, MergeTPHitsOnWire(), and tmp.

Referenced by GetSlice().

1027  {
1028  // merge the hits indexed by tpHits into one or more hits with the requirement that the hits
1029  // are on different wires
1030 
1031  if(tpHits.empty()) return;
1032 
1033  // no merge required. Just put a close copy of the single hit in the output hit collection
1034  if(tpHits.size() == 1) {
1035  if(tpHits[0] > (*evt.allHits).size() - 1) {
1036  std::cout<<"MergeTPHits Bad input hit index "<<tpHits[0]<<" allHits size "<<(*evt.allHits).size()<<"\n";
1037  return;
1038  }
1039  newHitCol.push_back(MergeTPHitsOnWire(tpHits));
1040  newHitAssns[tpHits[0]] = newHitCol.size() - 1;
1041  return;
1042  } // tpHits.size() == 1
1043 
1044  // split the hit list into sub-lists of hits on a single wire
1045  std::vector<unsigned int> wires;
1046  std::vector<std::vector<unsigned int>> wireHits;
1047  auto& firstHit = (*evt.allHits)[tpHits[0]];
1048  wires.push_back(firstHit.WireID().Wire);
1049  std::vector<unsigned int> tmp(1, tpHits[0]);
1050  wireHits.push_back(tmp);
1051  for(unsigned short ii = 1; ii < tpHits.size(); ++ii) {
1052  auto& hit = (*evt.allHits)[tpHits[ii]];
1053  unsigned int wire = hit.WireID().Wire;
1054  unsigned short indx = 0;
1055  for(indx = 0; indx < wires.size(); ++indx) if(wires[indx] == wire) break;
1056  if(indx == wires.size()) {
1057  wires.push_back(wire);
1058  wireHits.resize(wireHits.size() + 1);
1059  }
1060  wireHits[indx].push_back(tpHits[ii]);
1061  } // ii
1062 
1063  // now merge hits in each sub-list.
1064  for(unsigned short indx = 0; indx < wireHits.size(); ++indx) {
1065  auto& hitsOnWire = wireHits[indx];
1066  if(hitsOnWire.empty()) {
1067  std::cout<<"coding error\n";
1068  exit(1);
1069  }
1070  newHitCol.push_back(MergeTPHitsOnWire(hitsOnWire));
1071  for(unsigned short ii = 0; ii < hitsOnWire.size(); ++ii) {
1072  newHitAssns[hitsOnWire[ii]] = newHitCol.size() - 1;
1073  }
1074  } // hitsOnWire
1075 
1076  return;
1077 
1078  } // MergeTPHits
recob::Hit MergeTPHitsOnWire(std::vector< unsigned int > &tpHits)
Deletes all the results.
Float_t tmp
Definition: plot.C:37
Detector simulation of raw signals on wires.
std::vector< recob::Hit > const * allHits
Definition: DataStructs.h:536
TCEvent evt
Definition: DataStructs.cxx:5
recob::Hit tca::TrajClusterAlg::MergeTPHitsOnWire ( std::vector< unsigned int > &  tpHits)
private

Deletes all the results.

Definition at line 1081 of file TrajClusterAlg.cxx.

References tca::TCEvent::allHits, and tca::evt.

Referenced by MergeTPHits().

1082  {
1083  // merge the hits indexed by tpHits into one hit
1084 
1085  if(tpHits.empty()) return recob::Hit();
1086 
1087  // no merge required. Just return a slightly modified copy of the single hit
1088  if(tpHits.size() == 1) {
1089  if(tpHits[0] > (*evt.allHits).size() - 1) {
1090  std::cout<<"MergeTPHits Bad input hit index "<<tpHits[0]<<" allHits size "<<(*evt.allHits).size()<<"\n";
1091  return recob::Hit();
1092  }
1093  auto& oldHit = (*evt.allHits)[tpHits[0]];
1094  raw::TDCtick_t startTick = oldHit.PeakTime() - 3 * oldHit.RMS();
1095  raw::TDCtick_t endTick = oldHit.PeakTime() + 3 * oldHit.RMS();
1096 
1097  return recob::Hit(oldHit.Channel(),
1098  startTick, endTick,
1099  oldHit.PeakTime(), oldHit.SigmaPeakTime(),
1100  oldHit.RMS(),
1101  oldHit.PeakAmplitude(), oldHit.SigmaPeakAmplitude(),
1102  oldHit.SummedADC(), oldHit.Integral(), oldHit.SigmaIntegral(),
1103  1, 0, // Multiplicity, LocalIndex
1104  1, 0, // GoodnessOfFit, DOF
1105  oldHit.View(),
1106  oldHit.SignalType(),
1107  oldHit.WireID()
1108  );
1109  } // tpHits.size() == 1
1110 
1111  double integral = 0;
1112  double sIntegral = 0;
1113  double peakTime = 0;
1114  double sPeakTime = 0;
1115  double peakAmp = 0;
1116  double sPeakAmp = 0;
1117  float sumADC = 0;
1118  raw::TDCtick_t startTick = INT_MAX;
1119  raw::TDCtick_t endTick = 0;
1120  for(auto allHitsIndex : tpHits) {
1121  if(allHitsIndex > (*evt.allHits).size() - 1) return recob::Hit();
1122  auto& hit = (*evt.allHits)[allHitsIndex];
1123  if(hit.StartTick() < startTick) startTick = hit.StartTick();
1124  if(hit.EndTick() > endTick) endTick = hit.EndTick();
1125  double intgrl = hit.Integral();
1126  sPeakTime += intgrl * hit.SigmaPeakTime();
1127  sPeakAmp += intgrl * hit.SigmaPeakAmplitude();
1128  sumADC += hit.SummedADC();
1129  integral += intgrl;
1130  sIntegral += intgrl * hit.SigmaIntegral();
1131  // Get the charge normalization from an input hit
1132  } // tpHit
1133  if(integral <= 0) {
1134  std::cout<<"MergeTPHits found bad hit integral "<<integral<<"\n";
1135  return recob::Hit();
1136  }
1137 
1138  // Create a signal shape vector to find the rms and peak tick
1139  std::vector<double> shape(endTick - startTick + 1, 0.);
1140  for(auto allHitsIndex : tpHits) {
1141  auto& hit = (*evt.allHits)[allHitsIndex];
1142  double peakTick = hit.PeakTime();
1143  double rms = hit.RMS();
1144  double peakAmp = hit.PeakAmplitude();
1145  for(raw::TDCtick_t tick = startTick; tick <= endTick; ++tick) {
1146  double arg = ((double)tick - peakTick) / rms;
1147  unsigned short indx = tick - startTick;
1148  shape[indx] += peakAmp * exp(-0.5 * arg * arg);
1149  } // tick
1150  } // allHitsIndex
1151 
1152  // find the peak tick
1153  double sigsum = 0;
1154  double sigsumt = 0;
1155  for(raw::TDCtick_t tick = startTick; tick <= endTick; ++tick) {
1156  unsigned short indx = tick - startTick;
1157  sigsum += shape[indx];
1158  sigsumt += shape[indx] * tick;
1159  } // tick
1160 
1161  peakTime = sigsumt / sigsum;
1162  // Use the sigma peak time calculated in the first loop
1163  sPeakTime /= integral;
1164 
1165  // find the RMS
1166  sigsumt = 0.;
1167  for(raw::TDCtick_t tick = startTick; tick <= endTick; ++tick) {
1168  double dTick = tick - peakTime;
1169  unsigned short indx = tick - startTick;
1170  sigsumt += shape[indx] * dTick * dTick;
1171  }
1172  double rms = std::sqrt(sigsumt / sigsum);
1173  // get a reference to the first hit to get the charge normalization, channel, view, etc
1174  auto& firstHit = (*evt.allHits)[tpHits[0]];
1175  double chgNorm = 2.507 * firstHit.PeakAmplitude() * firstHit.RMS() / firstHit.Integral();
1176  // find the amplitude from the integrated charge and the RMS
1177  peakAmp = (float)(integral * chgNorm / (2.507 * rms));
1178  // Use the sigma integral calculated in the first loop
1179  sPeakAmp /= integral;
1180  // reset the start and end tick
1181  startTick = peakTime - 3 * rms;
1182  endTick = peakTime + 3 * rms;
1183 
1184  // construct the hit
1185  return recob::Hit(firstHit.Channel(),
1186  startTick, endTick,
1187  peakTime, sPeakTime,
1188  rms,
1189  peakAmp, sPeakAmp,
1190  sumADC, integral, sIntegral,
1191  1, 0, // Multiplicity, LocalIndex
1192  1, 0, // GoodnessOfFit, DOF
1193  firstHit.View(),
1194  firstHit.SignalType(),
1195  firstHit.WireID()
1196  );
1197 
1198  } // MergeTPHits
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:24
Detector simulation of raw signals on wires.
std::vector< recob::Hit > const * allHits
Definition: DataStructs.h:536
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
TCEvent evt
Definition: DataStructs.cxx:5
void tca::TrajClusterAlg::reconfigure ( fhicl::ParameterSet const &  pset)
virtual

Deletes all the results.

Definition at line 30 of file TrajClusterAlg.cxx.

References tca::AlgBitNames, tca::TCConfig::angleRanges, tca::TCEvent::aveHitRMS, tca::TCEvent::aveHitRMSValid, tca::TCConfig::chargeCuts, tca::TCConfig::chkStopCuts, art::errors::Configuration, tca::ConfigureMVA(), tca::TCConfig::dbgAlg, tca::debug, tca::DecodeDebugString(), tca::TCConfig::deltaRayTag, tca::TCConfig::doForecast, tca::TCConfig::electronTag, tca::TCEvent::eventsProcessed, tca::evt, fAlgModCount, fhicl::ParameterSet::get(), fhicl::ParameterSet::get_if_present(), fhicl::ParameterSet::has_key(), tca::TCConfig::hitErrFac, tca::TCConfig::JTMaxHitSep2, tca::kAlgBitSize, tca::kChkInTraj, tca::kDebug, tca::kFlagBitSize, tca::TCConfig::kinkCuts, tca::kKilled, tca::kSaveCRTree, tca::kSaveShowerTree, tca::kStepDir, tca::kStopAtTj, tca::kStudy1, tca::kStudy2, tca::kStudy3, tca::kStudy4, tca::kTagCosmics, tca::kTestBeam, tca::TCConfig::match3DCuts, tca::TCConfig::matchTruth, tca::TCConfig::maxAngleCode, tca::TCConfig::maxChi, tca::TCConfig::maxWireSkipNoSignal, tca::TCConfig::maxWireSkipWithSignal, tca::TCConfig::minMCSMom, tca::TCConfig::minPts, tca::TCConfig::minPtsFit, tca::TCConfig::modes, tca::TCConfig::multHitSep, tca::TCConfig::muonTag, tca::TCConfig::neutralVxCuts, tca::TCConfig::nPtsAve, tca::TCConfig::pfpStitchCuts, tca::TCConfig::projectionErrFactor, tca::TCConfig::qualityCuts, tca::TCConfig::showerTag, tca::DebugStuff::Slice, tca::StopFlagNames, tca::tcc, tca::TCConfig::testBeamCuts, tca::TCConfig::useAlg, tca::TCConfig::VLAStepSize, tca::TCConfig::vtx2DCuts, tca::TCConfig::vtx3DCuts, tca::TCConfig::vtxScoreWeights, and tca::DebugStuff::WorkID.

Referenced by TrajClusterAlg().

31  {
32 
33  bool badinput = false;
34  // set all configurable modes false
35  tcc.modes.reset();
36 
37  // default mode is stepping US -> DS
38  tcc.modes[kStepDir] = true;
39  short userMode = 1;
40  if(pset.has_key("Mode")) userMode = pset.get< short >("Mode");
41  if(userMode < 0) tcc.modes[kStepDir] = false;
42  if(pset.has_key("DoForecast")) tcc.doForecast = pset.get< bool >("DoForecast");
43  if(pset.has_key("StudyMode")) {
44  std::cout<<"StudyMode is not valid anymore. Try Study: 1 or Study: 2, etc/n";
45  } // old StudyMode
46  if(pset.has_key("Study")) {
47  userMode = pset.get< short >("Study");
48  if(userMode == 1) tcc.modes[kStudy1] = true;
49  if(userMode == 2) tcc.modes[kStudy2] = true;
50  if(userMode == 3) tcc.modes[kStudy3] = true;
51  if(userMode == 4) tcc.modes[kStudy4] = true;
52  } // new Study mode
53  if(pset.has_key("SaveShowerTree")) tcc.modes[kSaveShowerTree] = pset.get<bool>("SaveShowerTree");
54  if(pset.has_key("SaveCRTree")) tcc.modes[kSaveCRTree] = pset.get<bool>("SaveCRTree");
55  if(pset.has_key("TagCosmics")) tcc.modes[kTagCosmics] = pset.get<bool>("TagCosmics");
56  std::vector<std::string> skipAlgsVec;
57  if(pset.has_key("SkipAlgs")) skipAlgsVec = pset.get<std::vector<std::string>>("SkipAlgs");
58  std::vector<std::string> debugConfigVec;
59  if(pset.has_key("DebugConfig")) debugConfigVec = pset.get<std::vector<std::string>>("DebugConfig");
60  std::vector<std::string> specialAlgsVec;
61  if(pset.has_key("SpecialAlgs")) specialAlgsVec = pset.get<std::vector<std::string>>("SpecialAlgs");
62 
63  tcc.hitErrFac = pset.get< float >("HitErrFac", 0.4);
64  // Allow the user to specify the typical hit rms for small-angle tracks
65  std::vector<float> aveHitRMS;
66  if(pset.has_key("AveHitRMS")) aveHitRMS = pset.get<std::vector<float>>("AveHitRMS");
67  // Turn off the call to AnalyzeHits
68  if(!aveHitRMS.empty()) {
69  evt.aveHitRMSValid = true;
70  evt.aveHitRMS = aveHitRMS;
71  }
72  tcc.angleRanges = pset.get< std::vector<float>>("AngleRanges");
73  tcc.nPtsAve = pset.get< short >("NPtsAve", 20);
74  tcc.minPtsFit = pset.get< std::vector<unsigned short >>("MinPtsFit");
75  tcc.minPts = pset.get< std::vector<unsigned short >>("MinPts");
76  tcc.maxAngleCode = pset.get< std::vector<unsigned short>>("MaxAngleCode");
77  tcc.minMCSMom = pset.get< std::vector<short >>("MinMCSMom");
78  tcc.maxChi = pset.get< float >("MaxChi", 10);
79  tcc.chargeCuts = pset.get< std::vector<float >>("ChargeCuts", {3, 0.15, 0.25});
80  tcc.multHitSep = pset.get< float >("MultHitSep", 2.5);
81  tcc.kinkCuts = pset.get< std::vector<float >>("KinkCuts", {0.4, 1.5, 4});
82  tcc.qualityCuts = pset.get< std::vector<float >>("QualityCuts", {0.8, 3});
83  tcc.maxWireSkipNoSignal = pset.get< float >("MaxWireSkipNoSignal", 1);
84  tcc.maxWireSkipWithSignal= pset.get< float >("MaxWireSkipWithSignal", 100);
85  tcc.projectionErrFactor = pset.get< float >("ProjectionErrFactor", 2);
86  tcc.VLAStepSize = pset.get< float >("VLAStepSize", 1.5);
87  tcc.JTMaxHitSep2 = pset.get< float >("JTMaxHitSep", 2);
88  tcc.deltaRayTag = pset.get< std::vector<short>>("DeltaRayTag", {-1, -1, -1});
89  tcc.muonTag = pset.get< std::vector<short>>("MuonTag", {-1, -1, -1, - 1});
90  if(pset.has_key("ElectronTag")) tcc.electronTag = pset.get<std::vector<float>>("ElectronTag");
91  tcc.showerTag = pset.get< std::vector<float>>("ShowerTag", {-1, -1, -1, -1, -1, -1});
92  std::string fMVAShowerParentWeights = "NA";
93  pset.get_if_present<std::string>("MVAShowerParentWeights", fMVAShowerParentWeights);
94  tcc.chkStopCuts = pset.get< std::vector<float>>("ChkStopCuts", {-1, -1, -1});
95  tcc.matchTruth = pset.get< std::vector<float> >("MatchTruth", {-1, -1, -1, -1});
96  tcc.vtx2DCuts = pset.get< std::vector<float >>("Vertex2DCuts", {-1, -1, -1, -1, -1, -1, -1});
97  tcc.vtx3DCuts = pset.get< std::vector<float >>("Vertex3DCuts", {-1, -1});
98  tcc.vtxScoreWeights = pset.get< std::vector<float> >("VertexScoreWeights");
99  tcc.match3DCuts = pset.get< std::vector<float >>("Match3DCuts", {-1, -1, -1, -1, -1});
100  tcc.pfpStitchCuts = pset.get< std::vector<float >>("PFPStitchCuts", {-1});
101  pset.get_if_present<std::vector<float>>("TestBeamCuts", tcc.testBeamCuts);
102  pset.get_if_present<std::vector<float>>("NeutralVxCuts", tcc.neutralVxCuts);
104 
105  // in the following section we ensure that the fcl vectors are appropriately sized so that later references are valid
106  if(tcc.minPtsFit.size() != tcc.minPts.size()) badinput = true;
107  if(tcc.maxAngleCode.size() != tcc.minPts.size()) badinput = true;
108  if(tcc.minMCSMom.size() != tcc.minPts.size()) badinput = true;
109  if(badinput) throw art::Exception(art::errors::Configuration)<< "Bad input from fcl file. Vector lengths for MinPtsFit, MaxAngleRange and MinMCSMom should be defined for each reconstruction pass";
110 
111  if(tcc.vtx2DCuts.size() < 10) throw art::Exception(art::errors::Configuration)<<"Vertex2DCuts must be size 11\n 0 = Max length definition for short TJs\n 1 = Max vtx-TJ sep short TJs\n 2 = Max vtx-TJ sep long TJs\n 3 = Max position pull for >2 TJs\n 4 = Max vtx position error\n 5 = Min MCSMom for one of two TJs\n 6 = Min fraction of wires hit btw vtx and Tjs\n 7 = Min Score\n 8 = min ChgFrac at a vtx or merge point\n 9 = max MCSMom asymmetry, 10 = require chg on wires btw vtx and tjs in induction planes?";
112  if(tcc.vtx2DCuts.size() == 10) {
113  // User didn't specify a requirement for the presence of charge between a vertex and the start of the
114  // vertex Tjs in induction planes. Assume that it is required
115  tcc.vtx2DCuts.resize(11, 1.);
116  }
117  if(tcc.vtx3DCuts.size() < 2) throw art::Exception(art::errors::Configuration)<<"Vertex3DCuts must be size 2\n 0 = Max dX (cm)\n 1 = Max pull";
118  if(tcc.kinkCuts.size() != 3) throw art::Exception(art::errors::Configuration)<<"KinkCuts must be size 2\n 0 = Hard kink angle cut\n 1 = Kink angle significance\n 2 = nPts fit";
119  if(tcc.kinkCuts[2] < 2) throw art::Exception(art::errors::Configuration)<<"KinkCuts[2] must be > 1";
120  if(tcc.chargeCuts.size() != 3) throw art::Exception(art::errors::Configuration)<<"ChargeCuts must be size 3\n 0 = Charge pull cut\n 1 = Min allowed fractional chg RMS\n 2 = Max allowed fractional chg RMS";
121  // dressed muons - change next line
122  if(tcc.muonTag.size() < 4) throw art::Exception(art::errors::Configuration)<<"MuonTag must be size 4\n 0 = minPtsFit\n 1 = minMCSMom\n 2= maxWireSkipNoSignal\n 3 = min delta ray length for tagging\n 4 = dress muon window size (optional)";
123  if(tcc.deltaRayTag.size() != 3) throw art::Exception(art::errors::Configuration)<<"DeltaRayTag must be size 3\n 0 = Max endpoint sep\n 1 = min MCSMom\n 2 = max MCSMom";
124  if(tcc.chkStopCuts.size() != 3) throw art::Exception(art::errors::Configuration)<<"ChkStopCuts must be size 3\n 0 = Min Charge ratio\n 1 = Charge slope pull cut\n 2 = Charge fit chisq cut";
125  if(tcc.showerTag.size() < 13) {
126  std::cout<< "ShowerTag must be size 13\n 0 = Mode\n 1 = max MCSMom\n 2 = max separation (WSE units)\n 3 = Max angle diff\n 4 = Factor * rms width\n 5 = Min half width\n 6 = min total Tps\n 7 = Min Tjs\n 8 = max parent FOM\n 9 = max direction FOM 10 = max AspectRatio\n 11 = min Score to preserve a vertex\n 12 = Debug showers in CTP\n";
127  std::cout<<" Fixing this problem...";
128  tcc.showerTag.resize(13);
129  // set the min score to 0
130  tcc.showerTag[11] = 0;
131  // turn off printing
132  tcc.showerTag[12] = -1;
133  }
134  if(tcc.match3DCuts.size() < 7) {
135  std::cout<<">>>>>>>> Match3DCuts has been expanded to size 7. Please update your fcl file\n";
136  unsigned short oldsize = tcc.match3DCuts.size();
137  tcc.match3DCuts.resize(7);
138  if(oldsize < 5) std::cout<<" Setting Match3DCuts[4] = 2000 combinations\n";
139  if(oldsize < 6) std::cout<<" Setting Match3DCuts[5] = 1, which disables charge asymmetry checking\n";
140  tcc.match3DCuts[4] = 2000;
141  tcc.match3DCuts[5] = 1;
142  tcc.match3DCuts[6] = tcc.kinkCuts[0];
143  }
144  // convert Match3DCuts[6] from angle to cos(angle)
145  tcc.match3DCuts[6] = cos(tcc.match3DCuts[6]);
146 
147  // check the angle ranges and convert from degrees to radians
148  if(tcc.angleRanges.back() < 90) {
149  mf::LogVerbatim("TC")<<"Last element of AngleRange != 90 degrees. Fixing it\n";
150  tcc.angleRanges.back() = 90;
151  }
152 
153  // convert PFP stitch cuts
154  if(tcc.pfpStitchCuts.size() > 1 && tcc.pfpStitchCuts[0] > 0) {
155  // square the separation cut
157  // convert angle to cos
158  tcc.pfpStitchCuts[1] = cos(tcc.pfpStitchCuts[1]);
159  }
160  // turn on TestBeam mode?
161  tcc.modes[kTestBeam] = (!tcc.testBeamCuts.empty());
162 
163 
164  // configure algorithm debugging. Configuration for debugging standard stepping
165  // is done in Utils/AnalyzeHits when the input hit collection is passed to SetInputHits
166  tcc.modes[kDebug] = false;
167  tcc.dbgAlg.reset();
168  for(auto strng : debugConfigVec) {
169  // try to interpret this as a C:T:P:W:Tick specification or something similar
170  if(!DecodeDebugString(strng)) {
171  // try to set a dbgAlg bit
172  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) {
173  if(strng == AlgBitNames[ib]) {
174  tcc.dbgAlg[ib] = true;
175  tcc.modes[kDebug] = true;
176  break;
177  }
178  } // ib
179  // print some instructions and quit if there was a failure
180  if(!tcc.modes[kDebug]) {
181  DecodeDebugString("instruct");
182  exit(1);
183  }
184  } // DecodeDebugString failed
185  } // strng
186 /*
187  if(tcc.modes[kDebug] && debug.Cryostat >= 0 && debug.TPC >= 0 && debug.Plane >= 0) {
188  debug.CTP = EncodeCTP((unsigned int)debug.Cryostat, (unsigned int)debug.TPC, (unsigned int)debug.Plane);
189  }
190 */
191  for(auto& range : tcc.angleRanges) {
192  if(range < 0 || range > 90) throw art::Exception(art::errors::Configuration)<< "Invalid angle range "<<range<<" Must be 0 - 90 degrees";
193  range *= M_PI / 180;
194  } // range
195 
196  // Ensure that the size of the AlgBitNames vector is consistent with the AlgBit typedef enum
197  if(kAlgBitSize != AlgBitNames.size()) throw art::Exception(art::errors::Configuration)<<"kAlgBitSize "<<kAlgBitSize<<" != AlgBitNames size "<<AlgBitNames.size();
198  if(kAlgBitSize > 128) throw art::Exception(art::errors::Configuration)<<"Increase the size of UseAlgs to at least "<<kAlgBitSize;
199  fAlgModCount.resize(kAlgBitSize);
200 
201  if(kFlagBitSize != StopFlagNames.size()) throw art::Exception(art::errors::Configuration)<<"kFlagBitSize "<<kFlagBitSize<<" != StopFlagNames size "<<StopFlagNames.size();
202 
203  if(kFlagBitSize > 8) throw art::Exception(art::errors::Configuration)<<"Increase the size of StopFlag to at least "<<kFlagBitSize;
204 
205  bool printHelp = false;
206  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) tcc.useAlg[ib] = true;
207 
208  // turn off the special algs
209  // A lightly tested algorithm that should only be turned on for testing
210  tcc.useAlg[kStopAtTj] = false;
211  // Do an exhaustive (and slow) check of the hit -> trajectory associations
212  tcc.useAlg[kChkInTraj] = false;
213 
214  for(auto strng : skipAlgsVec) {
215  bool gotit = false;
216  if(strng == "All") {
217  // turn everything off
218  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) tcc.useAlg[ib] = false;
219  gotit = true;
220  break;
221  } // All off
222  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) {
223  if(strng == AlgBitNames[ib]) {
224  tcc.useAlg[ib] = false;
225  gotit = true;
226  break;
227  }
228  } // ib
229  if(!gotit) {
230  std::cout<<"******* Unknown SkipAlgs input string '"<<strng<<"'\n";
231  printHelp = true;
232  }
233  } // strng
234  if(printHelp) {
235  std::cout<<"Valid AlgNames:";
236  for(auto strng : AlgBitNames) std::cout<<" "<<strng;
237  std::cout<<"\n";
238  std::cout<<"Or specify All to turn all algs off\n";
239  throw art::Exception(art::errors::Configuration)<< "Invalid SkipAlgs specification";
240  }
241  // overwrite any settings above with special algs
242  for(auto strng : specialAlgsVec) {
243  bool gotit = false;
244  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) {
245  if(strng == AlgBitNames[ib]) {
246  tcc.useAlg[ib] = true;
247  gotit = true;
248  break;
249  }
250  } // ib
251  if(!gotit) {
252  std::cout<<"******* Unknown SpecialAlgs input string '"<<strng<<"'\n";
253  printHelp = true;
254  }
255  } // strng
256  if(printHelp) {
257  std::cout<<"Valid AlgNames:";
258  for(auto strng : AlgBitNames) std::cout<<" "<<strng;
259  std::cout<<"\n";
260  std::cout<<"Or specify All to turn all algs off\n";
261  throw art::Exception(art::errors::Configuration)<< "Invalid SkipAlgs specification";
262  }
263 
264  // Configure the TMVA reader for the shower parent BDT
265  if(fMVAShowerParentWeights != "NA" && tcc.showerTag[0] > 0) ConfigureMVA(tcc, fMVAShowerParentWeights);
266 
267  if(tcc.modes[kDebug]) {
268  std::cout<<"Debug mode: using algs:";
269  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) {
270  if(ib % 15 == 0) std::cout<<"\n";
271  if(tcc.useAlg[ib] && ib != kKilled) std::cout<<" "<<AlgBitNames[ib];
272  }
273  std::cout<<"\n";
274  std::cout<<"Skipping algs:";
275  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) if(!tcc.useAlg[ib] && ib != kKilled) std::cout<<" "<<AlgBitNames[ib];
276  std::cout<<"\n";
277  if(debug.Slice < 0) {
278  std::cout<<"Debugging in all slices\n";
279  } else {
280  std::cout<<"Debug sub-slice index "<<debug.Slice<<"\n";
281  }
282  if(debug.WorkID < 0) std::cout<<"Debug WorkID "<<debug.WorkID<<"\n";
283  } // debug mode
284 
285  evt.eventsProcessed = 0;
286 
287  } // reconfigure
Expect tracks entering from the front face. Don&#39;t create neutrino PFParticles.
Definition: DataStructs.h:448
don&#39;t mess with this line
Definition: DataStructs.h:431
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void ConfigureMVA(TCConfig &tcc, std::string fMVAShowerParentWeights)
Definition: TCShower.cxx:15
std::vector< float > kinkCuts
kink angle, nPts fit, (alternate) kink angle significance
Definition: DataStructs.h:475
const std::vector< std::string > AlgBitNames
Definition: DataStructs.cxx:13
std::vector< unsigned short > minPtsFit
Reconstruct in several passes.
Definition: DataStructs.h:482
std::vector< float > vtx3DCuts
2D vtx -> 3D vtx matching cuts
Definition: DataStructs.h:467
std::vector< float > qualityCuts
Min points/wire, min consecutive pts after a gap.
Definition: DataStructs.h:479
TCConfig tcc
Definition: DataStructs.cxx:6
step from US -> DS (true) or DS -> US (false)
Definition: DataStructs.h:447
float maxWireSkipWithSignal
max number of wires to skip with a signal on them
Definition: DataStructs.h:500
call study functions to develop cuts, etc
Definition: DataStructs.h:452
std::vector< float > electronTag
Definition: DataStructs.h:472
std::vector< float > matchTruth
Match to MC truth.
Definition: DataStructs.h:477
unsigned int eventsProcessed
Definition: DataStructs.h:540
bool doForecast
See TCMode_t above.
Definition: DataStructs.h:525
std::vector< float > angleRanges
list of max angles for each angle range
Definition: DataStructs.h:486
std::vector< float > showerTag
[min MCSMom, max separation, min # Tj < separation] for a shower tag
Definition: DataStructs.h:474
std::vector< unsigned short > maxAngleCode
max allowed angle code for each pass
Definition: DataStructs.h:484
std::vector< unsigned int > fAlgModCount
Deletes all the results.
float projectionErrFactor
Definition: DataStructs.h:501
save shower tree
Definition: DataStructs.h:456
short nPtsAve
dump trajectory points
Definition: DataStructs.h:523
std::vector< float > testBeamCuts
Definition: DataStructs.h:481
std::vector< short > minMCSMom
Min MCSMom for each pass.
Definition: DataStructs.h:485
int WorkID
Select the StartWorkID for debugging.
Definition: DebugStruct.h:26
DebugStuff debug
Definition: DebugStruct.cxx:4
const std::vector< std::string > StopFlagNames
Definition: DataStructs.cxx:82
std::vector< float > aveHitRMS
average RMS of an isolated hit
Definition: DataStructs.h:541
std::vector< float > neutralVxCuts
Definition: DataStructs.h:469
std::vector< float > match3DCuts
3D matching cuts
Definition: DataStructs.h:476
call study functions to develop cuts, etc
Definition: DataStructs.h:453
std::vector< unsigned short > minPts
min number of Pts required to make a trajectory
Definition: DataStructs.h:483
std::bitset< 16 > modes
number of points to find AveChg
Definition: DataStructs.h:524
std::vector< float > chargeCuts
Definition: DataStructs.h:478
bool aveHitRMSValid
set true when the average hit RMS is well-known
Definition: DataStructs.h:549
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
float maxWireSkipNoSignal
max number of wires to skip w/o a signal on them
Definition: DataStructs.h:499
std::vector< float > vtxScoreWeights
Definition: DataStructs.h:468
bool DecodeDebugString(std::string strng)
Definition: Utils.cxx:4611
std::bitset< 128 > useAlg
Max hit separation for making junk trajectories. < 0 to turn off.
Definition: DataStructs.h:504
std::vector< float > pfpStitchCuts
cuts for stitching between TPCs
Definition: DataStructs.h:480
std::vector< short > deltaRayTag
min length, min MCSMom and min separation (WSE) for a delta ray tag
Definition: DataStructs.h:470
save cosmic ray tree
Definition: DataStructs.h:454
float VLAStepSize
Definition: DataStructs.h:502
call study functions to develop cuts, etc
Definition: DataStructs.h:451
std::vector< short > muonTag
min length and min MCSMom for a muon tag
Definition: DataStructs.h:471
std::bitset< 128 > dbgAlg
Allow user to turn on debug printing in algorithms (that print...)
Definition: DataStructs.h:505
std::vector< float > chkStopCuts
[Min Chg ratio, Chg slope pull cut, Chg fit chi cut]
Definition: DataStructs.h:473
std::vector< float > vtx2DCuts
Max position pull, max Position error rms.
Definition: DataStructs.h:466
float multHitSep
preferentially "merge" hits with < this separation
Definition: DataStructs.h:491
float JTMaxHitSep2
Definition: DataStructs.h:503
TCEvent evt
Definition: DataStructs.cxx:5
call study functions to develop cuts, etc (see TCTruth.cxx)
Definition: DataStructs.h:450
master switch for turning on debug mode
Definition: DataStructs.h:449
tag cosmic rays
Definition: DataStructs.h:455
don&#39;t mess with this line
Definition: DataStructs.h:413
void tca::TrajClusterAlg::ReconstructAllTraj ( TCSlice slc,
CTP_t  inCTP 
)
private

Deletes all the results.

Definition at line 415 of file TrajClusterAlg.cxx.

References tca::AddHits(), tca::Trajectory::AlgMod, tca::TCEvent::allHits, tca::AttachAnyTrajToVertex(), tca::Trajectory::AveChg, tca::TCEvent::aveHitRMS, tca::CheckTraj(), tca::CheckTrajBeginChg(), tca::ChkHiChgHits(), tca::ChkVtxAssociations(), tca::Trajectory::CTP, tca::TCConfig::dbg2V, tca::TCConfig::dbgSlc, tca::TCConfig::dbgStp, tca::debug, tca::DecodeCTP(), tca::EndMerge(), tca::Trajectory::EndPt, tca::TCEvent::eventsProcessed, tca::evt, tca::Find2DVertices(), FindJunkTraj(), tca::TCSlice::firstWire, tca::GetHitMultiplet(), tca::DebugStuff::Hit, tca::TCConfig::hitErrFac, tca::HitsPosTick(), tca::HitsRMSTick(), tca::Trajectory::ID, tca::InTrajOK(), tca::Trajectory::IsGood, tca::TCSlice::isValid, tca::TCConfig::JTMaxHitSep2, tca::kChkInTraj, tca::kDebug, tca::kKilled, tca::kNewStpCuts, tca::kNormal, tca::kRvPrp, tca::kStepDir, tca::kStopAtTj, tca::kUnusedHits, tca::TCSlice::lastWire, tca::LongPulseHit(), tca::MakeHaloTj(), tca::MakeJunkVertices(), tca::TCConfig::maxAngleCode, tca::TCConfig::minPts, tca::TCConfig::minPtsFit, tca::TCConfig::modes, tca::TCConfig::muonTag, tca::NumPtsWithCharge(), tca::TCSlice::nWires, tca::Trajectory::ParentID, tca::Trajectory::Pass, geo::PlaneID::Plane, tca::PrintHit(), tca::PrintPos(), tca::PrintTrajectory(), tca::Trajectory::Pts, tca::ReleaseHits(), tca::seeds, tca::TCConfig::showerTag, tca::TCSlice::slHits, tca::slices, tca::SplitTrajCrossingVertices(), tca::StartTraj(), tca::StepAway(), tca::Trajectory::StepDir, tca::StoreTraj(), tca::Trajectory::Strategy, tca::TagDeltaRays(), tca::TagShowerLike(), tca::tcc, tca::TCSlice::tjs, tca::TrajHitsOK(), tca::TCConfig::unitsPerTick, tca::UpdateVxEnvironment(), tca::TCConfig::useAlg, tca::VtxHitsSwap(), tca::TCSlice::vtxs, tca::TCSlice::wireHitRange, and tca::TCEvent::WorkID.

Referenced by RunTrajClusterAlg().

416  {
417  // Reconstruct clusters in inCTP and put them in allTraj
418 
419  unsigned short plane = DecodeCTP(inCTP).Plane;
420  if(slc.firstWire[plane] > slc.nWires[plane]) return;
421  unsigned int nwires = slc.lastWire[plane] - slc.firstWire[plane] - 1;
422  if(nwires > slc.nWires[plane]) return;
423 
424  // Make several passes through the hits with user-specified cuts for each
425  // pass. In general these are to not reconstruct large angle trajectories on
426  // the first pass
427  float maxHitsRMS = 4 * evt.aveHitRMS[plane];
428  for(unsigned short pass = 0; pass < tcc.minPtsFit.size(); ++pass) {
429  for(unsigned int ii = 0; ii < nwires; ++ii) {
430  // decide which way to step given the sign of StepDir
431  unsigned int iwire = 0;
432  unsigned int jwire = 0;
433  if(tcc.modes[kStepDir]) {
434  // step DS
435  iwire = slc.firstWire[plane] + ii;
436  jwire = iwire + 1;
437  } else {
438  // step US
439  iwire = slc.lastWire[plane] - ii - 1;
440  jwire = iwire - 1;
441  }
442  if(iwire > slc.wireHitRange[plane].size() - 1) continue;
443  if(jwire > slc.wireHitRange[plane].size() - 1) continue;
444  // skip bad wires or no hits on the wire
445  if(slc.wireHitRange[plane][iwire].first < 0) continue;
446  if(slc.wireHitRange[plane][jwire].first < 0) continue;
447  unsigned int ifirsthit = (unsigned int)slc.wireHitRange[plane][iwire].first;
448  unsigned int ilasthit = (unsigned int)slc.wireHitRange[plane][iwire].second;
449  unsigned int jfirsthit = (unsigned int)slc.wireHitRange[plane][jwire].first;
450  unsigned int jlasthit = (unsigned int)slc.wireHitRange[plane][jwire].second;
451  for(unsigned int iht = ifirsthit; iht < ilasthit; ++iht) {
452  tcc.dbgStp = (tcc.modes[kDebug] && (slc.slHits[iht].allHitsIndex == debug.Hit));
453  if(tcc.dbgStp) {
454  mf::LogVerbatim("TC")<<"+++++++ Pass "<<pass<<" Found debug hit "<<slices.size()-1<<":"<<PrintHit(slc.slHits[iht])<<" iht "<<iht;
455  }
456  // Only consider hits that are available
457  if(slc.slHits[iht].InTraj != 0) continue;
458  // We hope to make a trajectory point at the hit position of iht in WSE units
459  // with a direction pointing to jht
460  auto& iHit = (*evt.allHits)[slc.slHits[iht].allHitsIndex];
461  if(tcc.useAlg[kNewStpCuts] && LongPulseHit(iHit)) continue;
462  unsigned int fromWire = iHit.WireID().Wire;
463  float fromTick = iHit.PeakTime();
464  float iqtot = iHit.Integral();
465  float hitsRMSTick = iHit.RMS();
466  std::vector<unsigned int> iHitsInMultiplet;
467  if(pass == 0) {
468  // only use the hit on the first pass
469  iHitsInMultiplet.resize(1);
470  iHitsInMultiplet[0] = iht;
471  } else {
472  GetHitMultiplet(slc, iht, iHitsInMultiplet);
473  // ignore very high multiplicities
474  if(iHitsInMultiplet.size() > 4) continue;
475  }
476  if(iHitsInMultiplet.size() > 1) {
477  fromTick = HitsPosTick(slc, iHitsInMultiplet, iqtot, kUnusedHits);
478  hitsRMSTick = HitsRMSTick(slc, iHitsInMultiplet, kUnusedHits);
479  }
480  if(hitsRMSTick == 0) continue;
481  bool fatIHit = (hitsRMSTick > maxHitsRMS);
482  if(tcc.dbgStp) mf::LogVerbatim("TC")<<" hit RMS "<<iHit.RMS()<<" BB Multiplicity "<<iHitsInMultiplet.size()<<" AveHitRMS["<<plane<<"] "<<evt.aveHitRMS[plane]<<" HitsRMSTick "<<hitsRMSTick<<" fatIHit "<<fatIHit;
483  for(unsigned int jht = jfirsthit; jht < jlasthit; ++jht) {
484  // Only consider hits that are available
485  if(slc.slHits[iht].InTraj != 0) break;
486  if(slc.slHits[jht].InTraj != 0) continue;
487  // clear out any leftover work inTraj's that weren't cleaned up properly
488  for(auto& slHit : slc.slHits) {
489  if(slHit.InTraj < 0) {
490  std::cout<<"RAT: Dirty hit "<<PrintHit(slHit)<<" EventsProcessed "<<evt.eventsProcessed<<" WorkID "<<evt.WorkID<<"\n";
491  slHit.InTraj = 0;
492  }
493  }
494  unsigned int toWire = jwire;
495  auto& jHit = (*evt.allHits)[slc.slHits[jht].allHitsIndex];
496  if(tcc.useAlg[kNewStpCuts] && LongPulseHit(jHit)) continue;
497  float toTick = jHit.PeakTime();
498  float jqtot = jHit.Integral();
499  std::vector<unsigned int> jHitsInMultiplet;
500  if(pass == 0) {
501  // only use the hit on the first pass
502  jHitsInMultiplet.resize(1);
503  jHitsInMultiplet[0] = jht;
504  } else {
505  GetHitMultiplet(slc, jht, jHitsInMultiplet);
506  // ignore very high multiplicities
507  if(jHitsInMultiplet.size() > 4) continue;
508  }
509  hitsRMSTick = HitsRMSTick(slc, jHitsInMultiplet, kUnusedHits);
510  if(hitsRMSTick == 0) continue;
511  bool fatJHit = (hitsRMSTick > maxHitsRMS);
512  if(pass == 0) {
513  // require both hits to be consistent
514  if((fatIHit && !fatJHit) || (!fatIHit && fatJHit)) {
515  continue;
516  }
517  } else {
518  // pass > 0
519  if(jHitsInMultiplet.size() > 1) toTick = HitsPosTick(slc, jHitsInMultiplet, jqtot, kUnusedHits);
520  }
521  bool hitsOK = TrajHitsOK(slc, iHitsInMultiplet, jHitsInMultiplet);
522  // Ensure that the hits StartTick and EndTick have the proper overlap
523  if(!hitsOK) continue;
524  // start a trajectory with direction from iht -> jht
525  Trajectory work;
526  if(!StartTraj(slc, work, fromWire, fromTick, toWire, toTick, inCTP, pass)) continue;
527  // check for a major failure
528  if(!slc.isValid) return;
529  if(work.Pts.empty()) {
530  if(tcc.dbgStp) mf::LogVerbatim("TC")<<"ReconstructAllTraj: StartTraj failed";
531  continue;
532  }
533  // check for a large angle crawl
534  if(work.Pts[0].AngleCode > tcc.maxAngleCode[work.Pass]) {
535  if(tcc.dbgStp) mf::LogVerbatim("TC")<<"ReconstructAllTraj: Wrong angle code "<<work.Pts[0].AngleCode<<" for this pass "<<work.Pass;
536  ReleaseHits(slc, work);
537  continue;
538  }
539  work.Pts[0].DeltaRMS = tcc.hitErrFac * tcc.unitsPerTick * hitsRMSTick;
540  // don't include the charge of iht since it will be low if this
541  // is a starting/ending track
542  work.AveChg = jqtot;
543  // try to add close hits
544  bool sigOK;
545  AddHits(slc, work, 0, sigOK);
546  // check for a major failure
547  if(!slc.isValid) return;
548  if(!sigOK || work.Pts[0].Chg == 0) {
549  if(tcc.dbgStp) mf::LogVerbatim("TC")<<" No hits at initial trajectory point ";
550  ReleaseHits(slc, work);
551  continue;
552  }
553  // move the TP position to the hit position but don't mess with the direction
554  work.Pts[0].Pos = work.Pts[0].HitPos;
555  // print the header and the first TP
556  if(tcc.dbgStp) PrintTrajectory("RAT", slc, work, USHRT_MAX);
557  // We can't update the trajectory yet because there is only one TP.
558  work.EndPt[0] = 0;
559  // now try stepping away
560  StepAway(slc, work);
561  // check for a major failure
562  if(!slc.isValid) return;
563  if(tcc.dbgStp) mf::LogVerbatim("TC")<<" After first StepAway. IsGood "<<work.IsGood;
564 /*
565  if(!work.IsGood && fTryWithNextPass) {
566  StepAway(slc, work);
567  if(!work.IsGood || work.NeedsUpdate) {
568  if(tcc.dbgStp) mf::LogVerbatim("TC")<<" xxxxxxx StepAway failed AGAIN ";
569  ReleaseHits(slc, work);
570  continue;
571  } // Failed again
572  }
573 */
574  // Check the quality of the work trajectory
575  CheckTraj(slc, work);
576  // check for a major failure
577  if(!slc.isValid) return;
578  if(tcc.dbgStp) mf::LogVerbatim("TC")<<"ReconstructAllTraj: After CheckTraj EndPt "<<work.EndPt[0]<<"-"<<work.EndPt[1]<<" IsGood "<<work.IsGood;
579  if(tcc.dbgStp) mf::LogVerbatim("TC")<<"StepAway done: IsGood "<<work.IsGood<<" NumPtsWithCharge "<<NumPtsWithCharge(slc, work, true)<<" cut "<<tcc.minPts[work.Pass];
580  // decide if the trajectory is long enough for this pass
581  if(!work.IsGood || NumPtsWithCharge(slc, work, true) < tcc.minPts[work.Pass]) {
582  if(tcc.dbgStp) mf::LogVerbatim("TC")<<" xxxxxxx Not enough points "<<NumPtsWithCharge(slc, work, true)<<" minimum "<<tcc.minPts[work.Pass]<<" or !IsGood";
583  ReleaseHits(slc, work);
584  continue;
585  }
586  slc.isValid = StoreTraj(slc, work);
587  // check for a major failure
588  if(!slc.isValid) return;
589  if(tcc.dbgStp) {
590  auto& tj = slc.tjs[slc.tjs.size() - 1];
591  mf::LogVerbatim("TC")<<"TRP RAT Stored T"<<tj.ID;
592  }
593  if(tcc.useAlg[kChkInTraj]) {
594  slc.isValid = InTrajOK(slc, "RAT");
595  if(!slc.isValid) {
596  mf::LogVerbatim("TC")<<"InTrajOK failed in ReconstructAllTraj";
597  return;
598  }
599  } // use ChkInTraj
600  // See if it should be split
601  CheckTrajBeginChg(slc, slc.tjs.size() - 1);
602  break;
603  } // jht
604  } // iht
605  } // iwire
606 
607  // See if there are any seed trajectory points that were saved before reverse
608  // propagation and try to make Tjs from them
609  for(auto tp : seeds) {
610  unsigned short nAvailable = 0;
611  for(unsigned short ii = 0; ii < tp.Hits.size(); ++ii) {
612  if(!tp.UseHit[ii]) continue;
613  unsigned int iht = tp.Hits[ii];
614  if(slc.slHits[iht].InTraj == 0) ++nAvailable;
615  tcc.dbgStp = (tcc.modes[kDebug] && (slc.slHits[iht].allHitsIndex == debug.Hit));
616  if(tcc.dbgStp) {
617  mf::LogVerbatim("TC")<<"+++++++ Seed debug hit "<<slices.size()-1<<":"<<PrintHit(slc.slHits[iht])<<" iht "<<iht;
618  }
619  } // ii
620  if(nAvailable == 0) continue;
621 // std::cout<<"Seed TP "<<PrintPos(slc, tp)<<" is available\n";
622  Trajectory work;
623  work.ID = evt.WorkID;
624  for(unsigned short ii = 0; ii < tp.Hits.size(); ++ii) {
625  if(!tp.UseHit[ii]) continue;
626  unsigned int iht = tp.Hits[ii];
627  if(slc.slHits[iht].InTraj == 0) slc.slHits[iht].InTraj = work.ID;
628  } // ii
629  work.Pass = pass;
630  work.StepDir = 1;
631  if(tp.Dir[0] < 0) work.StepDir = -1;
632  work.CTP = tp.CTP;
633  work.ParentID = -1;
634  work.Strategy.reset();
635  work.Strategy[kNormal] = true;
636  // don't allow yet another reverse propagation
637  work.AlgMod[kRvPrp] = true;
638  work.Pts.push_back(tp);
639  // stop stepping if we hit another tj (the one that created this seed TP)
640  tcc.useAlg[kStopAtTj] = true;
641  StepAway(slc, work);
642  tcc.useAlg[kStopAtTj] = false;
643  CheckTraj(slc, work);
644  // check for a major failure
645  if(!slc.isValid) return;
646  // decide if the trajectory is long enough for this pass
647  if(!work.IsGood || NumPtsWithCharge(slc, work, true) < tcc.minPts[work.Pass]) {
648  if(tcc.dbgStp) mf::LogVerbatim("TC")<<" xxxxxxx Not enough points "<<NumPtsWithCharge(slc, work, true)<<" minimum "<<tcc.minPts[work.Pass]<<" or !IsGood";
649  ReleaseHits(slc, work);
650  continue;
651  }
652  slc.isValid = StoreTraj(slc, work);
653  // check for a major failure
654  if(!slc.isValid) return;
655  if(tcc.dbgStp) {
656  auto& tj = slc.tjs[slc.tjs.size() - 1];
657  mf::LogVerbatim("TC")<<"TRP RAT Stored T"<<tj.ID<<" using seed TP "<<PrintPos(slc, tp);
658  }
659  } // seed
660  seeds.resize(0);
661 
662  // Tag delta rays before merging and making vertices
663  TagDeltaRays(slc, inCTP);
664  // Try to merge trajectories before making vertices
665  bool lastPass = (pass == tcc.minPtsFit.size() - 1);
666  EndMerge(slc, inCTP, lastPass);
667  if(!slc.isValid) return;
668 
669  // TY: Split high charge hits near the trajectory end
670  ChkHiChgHits(slc, inCTP);
671 
672  Find2DVertices(slc, inCTP, pass);
673  if(!slc.isValid) return;
674 
675  } // pass
676 
677  // Use unused hits in all trajectories
678  // BB Nov 2018: This can be a bad idea if the fcl configuration allows widely separated hits to
679  // be associated with TPs
680 // UseUnusedHits(slc);
681 
682  // make junk trajectories using nearby un-assigned hits
683  if(tcc.JTMaxHitSep2 > 0) {
684  FindJunkTraj(slc, inCTP);
685  if(!slc.isValid) return;
686  }
687  TagDeltaRays(slc, inCTP);
688  // dressed muons with halo trajectories
689  if(tcc.muonTag.size() > 4 && tcc.muonTag[4] > 0) {
690  for(auto& tj : slc.tjs) {
691  if(tj.AlgMod[kKilled]) continue;
692  if(tj.PDGCode != 13) continue;
693  MakeHaloTj(slc, tj, tcc.dbgSlc);
694  } // tj
695  } // dressed muons
696 
697  // Tag ShowerLike Tjs
698  if(tcc.showerTag[0] > 0) TagShowerLike("RAT", slc, inCTP);
699 
700  Find2DVertices(slc, inCTP);
701  SplitTrajCrossingVertices(slc, inCTP);
702  // Make vertices between long Tjs and junk Tjs
703  MakeJunkVertices(slc, inCTP);
704  // check for a major failure
705  if(!slc.isValid) return;
706 
707  // last attempt to attach Tjs to vertices
708  for(unsigned short ivx = 0; ivx < slc.vtxs.size(); ++ivx) {
709  auto& vx2 = slc.vtxs[ivx];
710  if(vx2.ID == 0) continue;
711  if(vx2.CTP != inCTP) continue;
712  AttachAnyTrajToVertex(slc, ivx, tcc.dbgStp || tcc.dbg2V);
713  UpdateVxEnvironment("RAT", slc, vx2, false);
714  } // ivx
715 
716  // Check the Tj <-> vtx associations and define the vertex quality
717  if(!ChkVtxAssociations(slc, inCTP)) {
718  std::cout<<"RAT: ChkVtxAssociations found an error. Events processed "<<evt.eventsProcessed<<" WorkID "<<evt.WorkID<<"\n";
719  }
720 
721  // TY: Improve hit assignments near vertex
722  VtxHitsSwap(slc, inCTP);
723 
724  // Refine vertices, trajectories and nearby hits
725 // Refine2DVertices();
726 
727  } // ReconstructAllTraj
void PrintTrajectory(std::string someText, TCSlice &slc, const Trajectory &tj, unsigned short tPoint)
Definition: Utils.cxx:5455
void CheckTrajBeginChg(TCSlice &slc, unsigned short itj)
Definition: Utils.cxx:1406
void ReleaseHits(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:1150
float HitsRMSTick(TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, HitStatus_t hitRequest)
Definition: Utils.cxx:3706
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void StepAway(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:15
void VtxHitsSwap(TCSlice &slc, const CTP_t inCTP)
Definition: TCVertex.cxx:2962
bool TrajHitsOK(TCSlice &slc, const std::vector< unsigned int > &iHitsInMultiplet, const std::vector< unsigned int > &jHitsInMultiplet)
Definition: Utils.cxx:1736
bool InTrajOK(TCSlice &slc, std::string someText)
Definition: Utils.cxx:1333
std::vector< unsigned short > minPtsFit
Reconstruct in several passes.
Definition: DataStructs.h:482
void AddHits(TCSlice &slc, Trajectory &tj, unsigned short ipt, bool &sigOK)
Definition: StepUtils.cxx:1091
TCConfig tcc
Definition: DataStructs.cxx:6
void SplitTrajCrossingVertices(TCSlice &slc, CTP_t inCTP)
Definition: TCVertex.cxx:1268
step from US -> DS (true) or DS -> US (false)
Definition: DataStructs.h:447
bool StoreTraj(TCSlice &slc, Trajectory &tj)
Definition: Utils.cxx:1175
void GetHitMultiplet(TCSlice &slc, unsigned int theHit, std::vector< unsigned int > &hitsInMultiplet)
Definition: StepUtils.cxx:1573
bool AttachAnyTrajToVertex(TCSlice &slc, unsigned short ivx, bool prt)
Definition: TCVertex.cxx:1868
void TagDeltaRays(TCSlice &slc, const CTP_t &inCTP)
Definition: Utils.cxx:3065
bool dbgSlc
debug only in the user-defined slice? default is all slices
Definition: DataStructs.h:507
bool StartTraj(TCSlice &slc, Trajectory &tj, unsigned int fromhit, unsigned int tohit, unsigned short pass)
Definition: Utils.cxx:4431
bool LongPulseHit(const recob::Hit &hit)
Definition: Utils.cxx:3936
unsigned int eventsProcessed
Definition: DataStructs.h:540
std::vector< float > showerTag
[min MCSMom, max separation, min # Tj < separation] for a shower tag
Definition: DataStructs.h:474
void UpdateVxEnvironment(std::string inFcnLabel, TCSlice &slc, VtxStore &vx2, bool prt)
Definition: Utils.cxx:3385
float HitsPosTick(TCSlice &slc, const std::vector< unsigned int > &hitsInMultiplet, float &sum, HitStatus_t hitRequest)
Definition: Utils.cxx:3742
std::vector< unsigned short > maxAngleCode
max allowed angle code for each pass
Definition: DataStructs.h:484
unsigned int Hit
set to the hit index in evt.allHits if a Plane:Wire:Tick match is found
Definition: DebugStruct.h:25
bool dbgStp
debug stepping using debug.Cryostat, debug.TPC, etc
Definition: DataStructs.h:508
float unitsPerTick
scale factor from Tick to WSE equivalent units
Definition: DataStructs.h:488
DebugStuff debug
Definition: DebugStruct.cxx:4
bool dbg2V
debug 2D vertex finding
Definition: DataStructs.h:510
std::vector< float > aveHitRMS
average RMS of an isolated hit
Definition: DataStructs.h:541
void TagShowerLike(std::string inFcnLabel, TCSlice &slc, const CTP_t &inCTP)
Definition: TCShower.cxx:3631
bool ChkVtxAssociations(TCSlice &slc, const CTP_t &inCTP)
Definition: TCVertex.cxx:2326
void MakeHaloTj(TCSlice &slc, Trajectory &muTj, bool prt)
Definition: Utils.cxx:20
void ChkHiChgHits(TCSlice &slc, CTP_t inCTP)
Definition: StepUtils.cxx:4105
std::string PrintHit(const TCHit &tch)
Definition: Utils.cxx:5704
std::vector< unsigned short > minPts
min number of Pts required to make a trajectory
Definition: DataStructs.h:483
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:258
std::vector< TCSlice > slices
Definition: DataStructs.cxx:10
unsigned short NumPtsWithCharge(TCSlice &slc, const Trajectory &tj, bool includeDeadWires)
Definition: Utils.cxx:1863
std::bitset< 16 > modes
number of points to find AveChg
Definition: DataStructs.h:524
std::vector< TrajPoint > seeds
Definition: DataStructs.cxx:11
void CheckTraj(TCSlice &slc, Trajectory &tj)
Definition: StepUtils.cxx:911
std::bitset< 128 > useAlg
Max hit separation for making junk trajectories. < 0 to turn off.
Definition: DataStructs.h:504
std::vector< short > muonTag
min length and min MCSMom for a muon tag
Definition: DataStructs.h:471
geo::PlaneID DecodeCTP(CTP_t CTP)
std::vector< recob::Hit > const * allHits
Definition: DataStructs.h:536
std::string PrintPos(TCSlice &slc, const TrajPoint &tp)
Definition: Utils.cxx:5712
void Find2DVertices(TCSlice &slc, const CTP_t &inCTP, unsigned short pass)
Definition: TCVertex.cxx:114
void EndMerge(TCSlice &slc, CTP_t inCTP, bool lastPass)
Definition: StepUtils.cxx:3464
float JTMaxHitSep2
Definition: DataStructs.h:503
void MakeJunkVertices(TCSlice &slc, const CTP_t &inCTP)
Definition: TCVertex.cxx:14
TCEvent evt
Definition: DataStructs.cxx:5
master switch for turning on debug mode
Definition: DataStructs.h:449
void FindJunkTraj(TCSlice &slc, CTP_t inCTP)
Deletes all the results.
void tca::TrajClusterAlg::RunTrajClusterAlg ( std::vector< unsigned int > &  hitsInSlice,
int  sliceID 
)

Deletes all the results.

Definition at line 312 of file TrajClusterAlg.cxx.

References tca::AlgBitNames, tca::TCEvent::aveHitRMS, tca::ChkVtxAssociations(), art::errors::Configuration, CreateSlice(), tca::TCConfig::dbgDump, tca::DefinePFPParents(), tca::DefineTjParents(), tca::DumpTj(), tca::EncodeCTP(), tca::TCEvent::eventsProcessed, tca::evt, fAlgModCount, tca::FillmAllTraj(), tca::Find3DVertices(), FindMissedVxTjs(), tca::FindNeutralVertices(), tca::FindPFParticles(), tca::FindShowers3D(), tca::Finish3DShowers(), tca::kDebug, tca::KillPoorVertices(), tca::kSaveShowerTree, tca::TCConfig::match3DCuts, tca::TCConfig::modes, ReconstructAllTraj(), tca::TCConfig::recoSlice, tca::ScoreVertices(), tca::TCConfig::showerTag, showertree, tca::slices, tca::ShowerTreeVars::StageNum, tca::stv, and tca::tcc.

313  {
314  // Reconstruct everything using the hits in a slice
315 
316  if(slices.empty()) ++evt.eventsProcessed;
317  if(hitsInSlice.size() < 2) return;
318  if(tcc.recoSlice > 0) {
319  if(sliceID != tcc.recoSlice) return;
320  }
321 
322  if(!CreateSlice(hitsInSlice)) {
323  std::cout<<"CreateSlice failed\n";
324  return;
325  }
326  // get a reference to the stored slice
327  auto& slc = slices[slices.size() - 1];
328  slc.ID = sliceID;
329  if(evt.aveHitRMS.size() != slc.nPlanes) throw art::Exception(art::errors::Configuration)<<" AveHitRMS vector size != the number of planes ";
330  // flag high-multiplicity hits
331 // AnalyzeHits(slc);
332  if(tcc.recoSlice) std::cout<<"Reconstruct "<<hitsInSlice.size()<<" hits in Slice "<<sliceID<<" in TPC "<<slc.TPCID.TPC<<"\n";
333  for(unsigned short plane = 0; plane < slc.nPlanes; ++plane) {
334  CTP_t inCTP = EncodeCTP(slc.TPCID.Cryostat, slc.TPCID.TPC, plane);
335  ReconstructAllTraj(slc, inCTP);
336  if(!slc.isValid) return;
337  } // plane
338 
339  // No sense taking muon direction if delta ray tagging is disabled
340 // if(tcc.deltaRayTag[0] >= 0) TagMuonDirections(slc, debug.WorkID);
341  Find3DVertices(slc);
342  // Look for incomplete 3D vertices that won't be recovered because there are
343  // missing trajectories in a plane
344  FindMissedVxTjs(slc);
345  ScoreVertices(slc);
346  // Define the ParentID of trajectories using the vertex score
347  // TODO: decide how to print debug output
348  DefineTjParents(slc, false);
349  for(unsigned short plane = 0; plane < slc.nPlanes; ++plane) {
350  CTP_t inCTP = EncodeCTP(slc.TPCID.Cryostat, slc.TPCID.TPC, plane);
351  if(!ChkVtxAssociations(slc, inCTP)) {
352  std::cout<<"RTC: ChkVtxAssociations found an error\n";
353  }
354  } // plane
355  if(tcc.match3DCuts[0] > 0) {
356  FillmAllTraj(slc);
357  FindPFParticles(slc);
358  // TODO: decide how to print debug output
359  DefinePFPParents(slc, false);
360 /*
361  if(tcc.modes[kTagCosmics]) {
362  for(auto& pfp : slc.pfps) {
363  if(pfp.ID == 0) continue;
364  SaveCRInfo(slc, pfp, prt, fIsRealData);
365  } // pfp
366  } // TagCosmics
367  */
368  } // 3D matching requested
369  KillPoorVertices(slc);
370  FindNeutralVertices(slc);
371  // Use 3D matching information to find showers in 2D. FindShowers3D returns
372  // true if the algorithm was successful indicating that the matching needs to be redone
373  if(tcc.showerTag[0] == 2 || tcc.showerTag[0] == 4) {
374  FindShowers3D(slc);
375  if(tcc.modes[kSaveShowerTree]) {
376  std::cout << "SHOWER TREE STAGE NUM SIZE: " << stv.StageNum.size() << std::endl;
377  showertree->Fill();
378  }
379  } // 3D shower code
380 // } // tpcid
381 
382 // if(tcc.studyMode) tm.StudyShowerParents(hist);
383 
384  if(!slc.isValid) {
385  mf::LogVerbatim("TC")<<"RunTrajCluster failed in MakeAllTrajClusters";
386  return;
387  }
388 
389  // dump a trajectory?
390  if(tcc.modes[kDebug] && tcc.dbgDump) DumpTj();
391 
392 // if (tcc.modes[kSaveCRTree]) crtree->Fill();
393 
394 /*
395  // fill some basic histograms
396  if(tcc.modes[kStudy1]) {
397  for(auto& vx2 : slc.vtxs) if(vx2.ID > 0 && vx2.Score > 0) hist.fVx2Score->Fill(vx2.Score);
398  for(auto& vx3 : slc.vtx3s) if(vx3.ID > 0 && vx3.Score > 0) hist.fVx3Score->Fill(vx3.Score);
399  }
400 */
401  Finish3DShowers(slc);
402 
403  // count algorithm usage
404  for(auto& tj : slc.tjs) {
405  for(unsigned short ib = 0; ib < AlgBitNames.size(); ++ib) if(tj.AlgMod[ib]) ++fAlgModCount[ib];
406  } // tj
407 
408  // clear vectors that are not needed later
409  slc.mallTraj.clear();
410  slc.matchVec.clear();
411 
412  } // RunTrajClusterAlg
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
const std::vector< std::string > AlgBitNames
Definition: DataStructs.cxx:13
void ReconstructAllTraj(TCSlice &slc, CTP_t inCTP)
Deletes all the results.
TCConfig tcc
Definition: DataStructs.cxx:6
void FindMissedVxTjs(TCSlice &slc)
Deletes all the results.
unsigned int eventsProcessed
Definition: DataStructs.h:540
std::vector< float > showerTag
[min MCSMom, max separation, min # Tj < separation] for a shower tag
Definition: DataStructs.h:474
ShowerTreeVars stv
Definition: DataStructs.cxx:8
std::vector< unsigned int > fAlgModCount
Deletes all the results.
save shower tree
Definition: DataStructs.h:456
bool CreateSlice(std::vector< unsigned int > &hitsInSlice)
Deletes all the results.
void DumpTj()
Definition: Utils.cxx:4728
std::vector< float > aveHitRMS
average RMS of an isolated hit
Definition: DataStructs.h:541
bool ChkVtxAssociations(TCSlice &slc, const CTP_t &inCTP)
Definition: TCVertex.cxx:2326
std::vector< float > match3DCuts
3D matching cuts
Definition: DataStructs.h:476
void ScoreVertices(TCSlice &slc)
Definition: TCVertex.cxx:2391
void DefineTjParents(TCSlice &slc, bool prt)
Definition: Utils.cxx:129
std::vector< TCSlice > slices
Definition: DataStructs.cxx:10
std::bitset< 16 > modes
number of points to find AveChg
Definition: DataStructs.h:524
void FindPFParticles(TCSlice &slc)
Definition: PFPUtils.cxx:1998
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
unsigned int CTP_t
Definition: DataStructs.h:41
std::vector< int > StageNum
Definition: DataStructs.h:324
bool FindShowers3D(TCSlice &slc)
Definition: TCShower.cxx:286
TTree * showertree
Deletes all the results.
CTP_t EncodeCTP(unsigned int cryo, unsigned int tpc, unsigned int plane)
Definition: DataStructs.h:45
void KillPoorVertices(TCSlice &slc)
Definition: TCVertex.cxx:2418
void FillmAllTraj(TCSlice &slc)
Definition: PFPUtils.cxx:271
void DefinePFPParents(TCSlice &slc, bool prt)
Definition: PFPUtils.cxx:2530
void Finish3DShowers(TCSlice &slc)
Definition: TCShower.cxx:131
void FindNeutralVertices(TCSlice &slc)
Definition: TCVertex.cxx:529
TCEvent evt
Definition: DataStructs.cxx:5
void Find3DVertices(TCSlice &slc)
Definition: TCVertex.cxx:1392
short recoSlice
only reconstruct the slice with ID (0 = all)
Definition: DataStructs.h:506
master switch for turning on debug mode
Definition: DataStructs.h:449
bool tca::TrajClusterAlg::SetInputHits ( std::vector< recob::Hit > const &  inputHits)

Deletes all the results.

Definition at line 290 of file TrajClusterAlg.cxx.

References tca::TCEvent::allHits, tca::AnalyzeHits(), ClearResults(), tca::TCConfig::detprop, tca::evt, tca::TCConfig::geom, tca::TCEvent::globalPFPID, tca::TCEvent::globalS2ID, tca::TCEvent::globalS3ID, tca::TCEvent::globalTjID, tca::TCEvent::globalVx2ID, tca::TCEvent::globalVx3ID, tca::tcc, and tca::TCEvent::WorkID.

291  {
292  // defines the pointer to the input hit collection, analyzes them,
293  // initializes global counters and refreshes service references
294  ClearResults();
295  evt.allHits = &inputHits;
296  // refresh service references
297  tcc.detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
298  tcc.geom = lar::providerFrom<geo::Geometry>();
299  evt.WorkID = 0;
300  evt.globalTjID = 0;
301  evt.globalVx2ID = 0;
302  evt.globalVx3ID = 0;
303  evt.globalPFPID = 0;
304  evt.globalS2ID = 0;
305  evt.globalS3ID = 0;
306  // find the average hit RMS using the full hit collection and define the
307  // configuration for the current TPC
308  return AnalyzeHits();
309  } // SetInputHits
void ClearResults()
Deletes all the results.
TCConfig tcc
Definition: DataStructs.cxx:6
const detinfo::DetectorProperties * detprop
Definition: DataStructs.h:494
const geo::GeometryCore * geom
Definition: DataStructs.h:493
bool AnalyzeHits()
Definition: Utils.cxx:3877
std::vector< recob::Hit > const * allHits
Definition: DataStructs.h:536
TCEvent evt
Definition: DataStructs.cxx:5

Member Data Documentation

std::vector<unsigned int> tca::TrajClusterAlg::fAlgModCount
private

Deletes all the results.

Definition at line 95 of file TrajClusterAlg.h.

Referenced by ChkInTraj(), GetAlgModCount(), reconfigure(), and RunTrajClusterAlg().

calo::CalorimetryAlg tca::TrajClusterAlg::fCaloAlg
private

Deletes all the results.

Definition at line 92 of file TrajClusterAlg.h.

Referenced by TrajClusterAlg().

TMVA::Reader tca::TrajClusterAlg::fMVAReader
private

Deletes all the results.

Definition at line 93 of file TrajClusterAlg.h.

Referenced by TrajClusterAlg().

TruthMatcher tca::TrajClusterAlg::fTM

Deletes all the results.

Definition at line 80 of file TrajClusterAlg.h.

TTree* tca::TrajClusterAlg::showertree
private

Deletes all the results.

Definition at line 87 of file TrajClusterAlg.h.

Referenced by DefineShTree(), and RunTrajClusterAlg().


The documentation for this class was generated from the following files: