LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
trkf::Track3Dreco Class Reference
Inheritance diagram for trkf::Track3Dreco:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 Track3Dreco (fhicl::ParameterSet const &pset)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

void produce (art::Event &evt) override
 

Private Attributes

int ftmatch
 tolerance for time matching (in time samples) More...
 
double fchi2dof
 tolerance for chi2/dof of cluster fit to function More...
 
std::string fClusterModuleLabel
 label for input cluster collection More...
 

Detailed Description

Definition at line 51 of file Track3Dreco_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

trkf::Track3Dreco::Track3Dreco ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 68 of file Track3Dreco_module.cc.

References fchi2dof, fClusterModuleLabel, and ftmatch.

68  : EDProducer{pset}
69  {
70  fClusterModuleLabel = pset.get<std::string>("ClusterModuleLabel");
71  ftmatch = pset.get<int>("TMatch");
72  fchi2dof = pset.get<double>("Chi2DOFmax");
73 
74  produces<std::vector<recob::Track>>();
75  produces<std::vector<recob::SpacePoint>>();
76  produces<art::Assns<recob::Track, recob::Cluster>>();
77  produces<art::Assns<recob::Track, recob::SpacePoint>>();
78  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
79  produces<art::Assns<recob::Track, recob::Hit>>();
80  }
std::string fClusterModuleLabel
label for input cluster collection
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
double fchi2dof
tolerance for chi2/dof of cluster fit to function
int ftmatch
tolerance for time matching (in time samples)

Member Function Documentation

template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void trkf::Track3Dreco::produce ( art::Event evt)
overrideprivatevirtual
Todo:
: This is very bad practice and should be changed ASAP

Implements art::EDProducer.

Definition at line 83 of file Track3Dreco_module.cc.

References util::abs(), recob::tracking::convertCollToPoint(), recob::tracking::convertCollToVector(), util::CreateAssn(), DEFINE_ART_MODULE, geo::GeometryCore::DetHalfHeight(), fClusterModuleLabel, ftmatch, art::ProductRetriever::getByLabel(), geo::GeometryCore::GetLArTPCVolumeName(), hits(), geo::kZ, geo::GeometryCore::Plane(), geo::GeometryCore::PlanePitch(), art::PtrVector< T >::push_back(), art::Event::put(), art::PtrVector< T >::size(), t1, t2, geo::PlaneGeo::ThetaZ(), recob::Cluster::View(), and geo::GeometryCore::WirePitch().

84  {
86  auto const detProp =
88 
89  auto tcol = std::make_unique<std::vector<recob::Track>>();
90  auto spacepoints = std::make_unique<std::vector<recob::SpacePoint>>();
91  auto cassn = std::make_unique<art::Assns<recob::Track, recob::Cluster>>();
92  auto sassn = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
93  auto shassn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
94  auto hassn = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
95 
96  // define TPC parameters
97  TString tpcName = geom->GetLArTPCVolumeName();
98 
99  double YC = (geom->DetHalfHeight()) * 2.; // *ArgoNeuT* TPC active-volume height in cm
100  constexpr geo::TPCID tpcid{0, 0};
101  double Angle = geom->Plane(geo::PlaneID{tpcid, 1}).Wire(0).ThetaZ(false) -
102  TMath::Pi() / 2.; // wire angle with respect to the vertical direction
103  // Parameters temporary defined here, but possibly to be retrieved somewhere in the code
104  double timetick = 0.198; //time sample in us
105  double presamplings = 60.;
106  const double wireShift =
107  50.; // half the number of wires from the Induction(Collection) plane intersecting with a wire from the Collection(Induction) plane.
108  double plane_pitch = geom->PlanePitch(tpcid, 0, 1); //wire plane pitch in cm
109  double wire_pitch = geom->WirePitch(); //wire pitch in cm
110  double Efield_drift = 0.5; // Electric Field in the drift region in kV/cm
111  double Efield_SI = 0.7; // Electric Field between Shield and Induction planes in kV/cm
112  double Efield_IC = 0.9; // Electric Field between Induction and Collection planes in kV/cm
113  double Temperature = 87.6; // LAr Temperature in K
114 
115  double driftvelocity =
116  detProp.DriftVelocity(Efield_drift, Temperature); //drift velocity in the drift
117  //region (cm/us)
118  double driftvelocity_SI =
119  detProp.DriftVelocity(Efield_SI, Temperature); //drift velocity between shield
120  //and induction (cm/us)
121  double driftvelocity_IC =
122  detProp.DriftVelocity(Efield_IC, Temperature); //drift velocity between induction
123  //and collection (cm/us)
124  double timepitch = driftvelocity * timetick; //time sample (cm)
125  double tSI = plane_pitch / driftvelocity_SI / timetick; //drift time between Shield and
126  //Collection planes (time samples)
127  double tIC = plane_pitch / driftvelocity_IC / timetick; //drift time between Induction and
128  //Collection planes (time samples)
129 
130  // get input Cluster object(s).
131  art::Handle<std::vector<recob::Cluster>> clusterListHandle;
132  evt.getByLabel(fClusterModuleLabel, clusterListHandle);
133 
134  // Declare some vectors..
135  // Induction
136  std::vector<double> Iwirefirsts; // in cm
137  std::vector<double> Iwirelasts; // in cm
138  std::vector<double> Itimefirsts; // in cm
139  std::vector<double> Itimelasts; // in cm
140  std::vector<double> Itimefirsts_line; // in cm
141  std::vector<double> Itimelasts_line; // in cm
142  std::vector<std::vector<art::Ptr<recob::Hit>>> IclusHitlists;
143  std::vector<unsigned int> Icluster_count;
144 
145  // Collection
146  std::vector<double> Cwirefirsts; // in cm
147  std::vector<double> Cwirelasts; // in cm
148  std::vector<double> Ctimefirsts; // in cm
149  std::vector<double> Ctimelasts; // in cm
150  std::vector<double> Ctimefirsts_line; // in cm
151  std::vector<double> Ctimelasts_line; // in cm
152  std::vector<std::vector<art::Ptr<recob::Hit>>> CclusHitlists;
153  std::vector<unsigned int> Ccluster_count;
154 
155  // Some variables for the hit
156  float time; //hit time at maximum
157  unsigned int wire = 0; //hit wire number
158  unsigned int plane = 0; //hit plane number
159 
160  size_t startSPIndex =
161  spacepoints->size(); //index for knowing which spacepoints are with which cluster
162  size_t endSPIndex =
163  spacepoints->size(); //index for knowing which spacepoints are with which cluster
164 
165  art::FindManyP<recob::Hit> fmh(clusterListHandle, evt, fClusterModuleLabel);
166 
167  for (size_t ii = 0; ii < clusterListHandle->size(); ++ii) {
168  art::Ptr<recob::Cluster> cl(clusterListHandle, ii);
169 
173 
174  // Gaaaaaah! Change me soon!!! But, for now,
175  // let's just chuck one plane's worth of info. EC, 30-Mar-2011.
177  if (cl->View() == geo::kZ) continue;
178 
179  // Can not be const, cuz we're gonna sort 'em.
180  std::vector<art::Ptr<recob::Hit>> hitlist(fmh.at(ii));
181 
182  if (hitlist.size() == 1)
183  continue; //only one Hit in this Cluster...will cause TGraph fit to fail.
184 
185  // sort the hit list to be sure it is in the correct order
186  // using the Hit < operator
187  std::sort(hitlist.begin(), hitlist.end());
188 
189  TGraph* the2Dtrack = new TGraph(hitlist.size());
190 
191  std::vector<double> wires;
192  std::vector<double> times;
193 
194  int np = 0;
195  //loop over cluster hits
196  for (art::PtrVector<recob::Hit>::const_iterator theHit = hitlist.begin();
197  theHit != hitlist.end();
198  theHit++) {
199  //recover the Hit
200  time = (*theHit)->PeakTime();
201 
202  time -= presamplings;
203 
204  plane = (*theHit)->WireID().Plane;
205  wire = (*theHit)->WireID().Wire;
206 
207  //correct for the distance between wire planes
208  if (plane == 1) time -= tIC; // Collection
209 
210  //transform hit wire and time into cm
211  double wire_cm;
212  if (plane == 0)
213  wire_cm = (double)((wire + 3.95) * wire_pitch);
214  else
215  wire_cm = (double)((wire + 1.84) * wire_pitch);
216 
217  double time_cm;
218  if (time > tSI)
219  time_cm = (double)((time - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
220  else
221  time_cm = time * driftvelocity_SI * timetick;
222 
223  wires.push_back(wire_cm);
224  times.push_back(time_cm);
225 
226  the2Dtrack->SetPoint(np, wire_cm, time_cm);
227  np++;
228  } //end of loop over cluster hits
229 
230  // fit the 2Dtrack and get some info to store
231  try {
232  the2Dtrack->Fit("pol1", "Q");
233  }
234  catch (...) {
235  mf::LogWarning("Track3Dreco") << "The 2D track fit failed";
236  continue;
237  }
238 
239  TF1* pol1 = (TF1*)the2Dtrack->GetFunction("pol1");
240  double par[2];
241  pol1->GetParameters(par);
242  double intercept = par[0];
243  double slope = par[1];
244 
245  double w0 = wires.front(); // first hit wire (cm)
246  double w1 = wires.back(); // last hit wire (cm)
247  double t0 = times.front(); // first hit time (cm)
248  double t1 = times.back(); // last hit time (cm)
249  double t0_line = intercept + (w0)*slope; // time coordinate at wire w0 on the fit line (cm)
250  double t1_line = intercept + (w1)*slope; // time coordinate at wire w1 on the fit line (cm)
251 
252  // actually store the 2Dtrack info
253  switch (plane) {
254  case 0:
255  Iwirefirsts.push_back(w0);
256  Iwirelasts.push_back(w1);
257  Itimefirsts.push_back(t0);
258  Itimelasts.push_back(t1);
259  Itimefirsts_line.push_back(t0_line);
260  Itimelasts_line.push_back(t1_line);
261  IclusHitlists.push_back(hitlist);
262  Icluster_count.push_back(ii);
263  break;
264  case 1:
265  Cwirefirsts.push_back(w0);
266  Cwirelasts.push_back(w1);
267  Ctimefirsts.push_back(t0);
268  Ctimelasts.push_back(t1);
269  Ctimefirsts_line.push_back(t0_line);
270  Ctimelasts_line.push_back(t1_line);
271  CclusHitlists.push_back(hitlist);
272  Ccluster_count.push_back(ii);
273  break;
274  }
275  delete pol1;
276  } // end of loop over all input clusters
277 
281 
282  //loop over Collection view 2D tracks
283  for (size_t collectionIter = 0; collectionIter < CclusHitlists.size(); ++collectionIter) {
284  // Recover previously stored info
285  double Cw0 = Cwirefirsts[collectionIter];
286  double Cw1 = Cwirelasts[collectionIter];
287  //double Ct0 = Ctimefirsts[collectionIter];
288  //double Ct1 = Ctimelasts[collectionIter];
289  double Ct0_line = Ctimefirsts_line[collectionIter];
290  double Ct1_line = Ctimelasts_line[collectionIter];
291  std::vector<art::Ptr<recob::Hit>> hitsCtrk = CclusHitlists[collectionIter];
292 
293  double collLength = std::hypot(Ct1_line - Ct0_line, Cw1 - Cw0);
294 
295  //loop over Induction view 2D tracks
296  for (size_t inductionIter = 0; inductionIter < IclusHitlists.size(); ++inductionIter) {
297  // Recover previously stored info
298  double Iw0 = Iwirefirsts[inductionIter];
299  double Iw1 = Iwirelasts[inductionIter];
300  double It0_line = Itimefirsts_line[inductionIter];
301  double It1_line = Itimelasts_line[inductionIter];
302  std::vector<art::Ptr<recob::Hit>> hitsItrk = IclusHitlists[inductionIter];
303 
304  double indLength = std::hypot(It1_line - It0_line, Iw1 - Iw0);
305 
306  bool forward_match = ((std::abs(Ct0_line - It0_line) < ftmatch * timepitch) &&
307  (std::abs(Ct1_line - It1_line) < ftmatch * timepitch));
308  bool backward_match = ((std::abs(Ct0_line - It1_line) < ftmatch * timepitch) &&
309  (std::abs(Ct1_line - It0_line) < ftmatch * timepitch));
310 
311  // match 2D tracks
312  if (forward_match || backward_match) {
313 
314  // Reconstruct the 3D track
315  TVector3 XYZ0, XYZ1; // track endpoints
316  if (forward_match) {
317  XYZ0.SetXYZ(Ct0_line,
318  (Cw0 - Iw0) / (2. * std::sin(Angle)),
319  (Cw0 + Iw0) / (2. * std::cos(Angle)) - YC / 2. * std::tan(Angle));
320  XYZ1.SetXYZ(Ct1_line,
321  (Cw1 - Iw1) / (2. * std::sin(Angle)),
322  (Cw1 + Iw1) / (2. * std::cos(Angle)) - YC / 2. * std::tan(Angle));
323  }
324  else {
325  XYZ0.SetXYZ(Ct0_line,
326  (Cw0 - Iw1) / (2. * std::sin(Angle)),
327  (Cw0 + Iw1) / (2. * std::cos(Angle)) - YC / 2. * std::tan(Angle));
328  XYZ1.SetXYZ(Ct1_line,
329  (Cw1 - Iw0) / (2. * std::sin(Angle)),
330  (Cw1 + Iw0) / (2. * std::cos(Angle)) - YC / 2. * std::tan(Angle));
331  }
332 
333  //compute track direction in Local co-ordinate system
334  //WARNING: There is an ambiguity introduced here for the case of backwards-going tracks.
335  //If available, vertex info. could sort this out.
336  TVector3 startpointVec, endpointVec;
337  TVector2 collVtx, indVtx;
338  if (XYZ0.Z() <= XYZ1.Z()) {
339  startpointVec.SetXYZ(XYZ0.X(), XYZ0.Y(), XYZ0.Z());
340  endpointVec.SetXYZ(XYZ1.X(), XYZ1.Y(), XYZ1.Z());
341  if (forward_match) {
342  collVtx.Set(Ct0_line, Cw0);
343  indVtx.Set(It0_line, Iw0);
344  }
345  else {
346  collVtx.Set(Ct0_line, Cw0);
347  indVtx.Set(It1_line, Iw1);
348  }
349  }
350  else {
351  startpointVec.SetXYZ(XYZ1.X(), XYZ1.Y(), XYZ1.Z());
352  endpointVec.SetXYZ(XYZ0.X(), XYZ0.Y(), XYZ0.Z());
353  if (forward_match) {
354  collVtx.Set(Ct1_line, Cw1);
355  indVtx.Set(It1_line, Iw1);
356  }
357  else {
358  collVtx.Set(Ct1_line, Cw1);
359  indVtx.Set(It0_line, Iw0);
360  }
361  }
362 
363  //compute track (normalized) cosine directions in the TPC co-ordinate system
364  TVector3 DirCos = endpointVec - startpointVec;
365 
366  //SetMag casues a crash if the magnitude of the vector is zero
367  try {
368  DirCos.SetMag(1.0); //normalize vector
369  }
370  catch (...) {
371  mf::LogWarning("Track3Dreco") << "The Spacepoint is infinitely small";
372  continue;
373  }
374 
375  art::Ptr<recob::Cluster> cl1(clusterListHandle, Icluster_count[inductionIter]);
376  art::Ptr<recob::Cluster> cl2(clusterListHandle, Ccluster_count[collectionIter]);
377  art::PtrVector<recob::Cluster> clustersPerTrack;
378  clustersPerTrack.push_back(cl1);
379  clustersPerTrack.push_back(cl2);
380 
382  // Match hits
384 
385  std::vector<art::Ptr<recob::Hit>> minhits =
386  hitsCtrk.size() <= hitsItrk.size() ? hitsCtrk : hitsItrk;
387  std::vector<art::Ptr<recob::Hit>> maxhits =
388  hitsItrk.size() <= hitsCtrk.size() ? hitsCtrk : hitsItrk;
389 
390  std::vector<bool> maxhitsMatch(maxhits.size());
391  for (size_t it = 0; it < maxhits.size(); ++it)
392  maxhitsMatch[it] = false;
393 
394  std::vector<recob::Hit*> hits3Dmatched;
395  // For the matching start from the view where the track projection presents less hits
396  unsigned int imaximum = 0;
397  //loop over hits
398 
399  startSPIndex = spacepoints->size();
400 
401  for (size_t imin = 0; imin < minhits.size(); ++imin) {
402  //get wire - time coordinate of the hit
403  unsigned int wire, plane1, plane2;
404  wire = minhits[imin]->WireID().Wire;
405  plane1 = minhits[imin]->WireID().Plane;
406 
407  // get the wire-time co-ordinates of the hit to be matched
408  double w1;
409  if (plane1 == 0)
410  w1 = (double)((wire + 3.95) * wire_pitch);
411  else
412  w1 = (double)((wire + 1.84) * wire_pitch);
413  double temptime1 = minhits[imin]->PeakTime() - presamplings;
414  if (plane1 == 1) temptime1 -= tIC;
415  double t1;
416  if (temptime1 > tSI)
417  t1 = (double)((temptime1 - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
418  else
419  t1 = temptime1 * driftvelocity_SI * timetick;
420 
421  //get the track origin co-ordinates in the two views
422  TVector2 minVtx2D;
423  plane1 == 1 ? minVtx2D.Set(collVtx.X(), collVtx.Y()) :
424  minVtx2D.Set(indVtx.X(), indVtx.Y());
425  TVector2 maxVtx2D;
426  plane1 == 1 ? maxVtx2D.Set(indVtx.X(), indVtx.Y()) :
427  maxVtx2D.Set(collVtx.X(), collVtx.Y());
428 
429  double ratio =
430  (collLength > indLength) ? collLength / indLength : indLength / collLength;
431 
432  //compute the distance of the hit (imin) from the relative track origin
433  double minDistance = ratio * TMath::Sqrt(TMath::Power(t1 - minVtx2D.X(), 2) +
434  TMath::Power(w1 - minVtx2D.Y(), 2));
435 
436  //core matching algorithm
437  double difference = 9999999.;
438 
439  //loop over hits of the other view
440  for (size_t imax = 0; imax < maxhits.size(); ++imax) {
441  if (!maxhitsMatch[imax]) {
442  //get wire - time coordinate of the hit
443  wire = maxhits[imax]->WireID().Wire;
444  plane2 = maxhits[imax]->WireID().Plane;
445 
446  double w2;
447  if (plane2 == 0)
448  w2 = (double)((wire + 3.95) * wire_pitch);
449  else
450  w2 = (double)((wire + 1.84) * wire_pitch);
451  double temptime2 = maxhits[imax]->PeakTime() - presamplings;
452  if (plane2 == 1) temptime2 -= tIC;
453  double t2;
454  if (temptime2 > tSI)
455  t2 = (double)((temptime2 - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
456  else
457  t2 = temptime2 * driftvelocity_SI * timetick;
458 
459  bool timematch = (std::abs(t1 - t2) < ftmatch * timepitch);
460  bool wirematch = (std::abs(w1 - w2) < wireShift * wire_pitch);
461 
462  double maxDistance = TMath::Sqrt(TMath::Power(t2 - maxVtx2D.X(), 2) +
463  TMath::Power(w2 - maxVtx2D.Y(), 2));
464  if (wirematch && timematch && std::abs(maxDistance - minDistance) < difference) {
465  difference = std::abs(maxDistance - minDistance);
466  imaximum = imax;
467  }
468  }
469  } // end loop over max hits
470  maxhitsMatch[imaximum] = true;
471 
473  if (difference != 9999999.) {
474  sp_hits.push_back(minhits[imin]);
475  sp_hits.push_back(maxhits[imaximum]);
476  }
477 
478  // Get the time-wire co-ordinates of the matched hit
479  wire = maxhits[imaximum]->WireID().Wire;
480  plane2 = maxhits[imaximum]->WireID().Plane;
481 
482  double w1_match;
483  if (plane2 == 0)
484  w1_match = (double)((wire + 3.95) * wire_pitch);
485  else
486  w1_match = (double)((wire + 1.84) * wire_pitch);
487  double temptime3 = maxhits[imaximum]->PeakTime() - presamplings;
488  if (plane2 == 1) temptime3 -= tIC;
489  double t1_match;
490  if (temptime3 > tSI)
491  t1_match =
492  (double)((temptime3 - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
493  else
494  t1_match = temptime3 * driftvelocity_SI * timetick;
495 
496  // create the 3D hit, compute its co-ordinates and add it to the 3D hits list
497  double Ct = plane1 == 1 ? t1 : t1_match;
498  double Cw = plane1 == 1 ? w1 : w1_match;
499  double Iw = plane1 == 1 ? w1_match : w1;
500 
501  const TVector3 hit3d(Ct,
502  (Cw - Iw) / (2. * std::sin(Angle)),
503  (Cw + Iw) / (2. * std::cos(Angle)) - YC / 2. * std::tan(Angle));
504  Double_t hitcoord[3];
505  hitcoord[0] = hit3d.X();
506  hitcoord[1] = hit3d.Y();
507  hitcoord[2] = hit3d.Z();
508 
509  Double_t hitcoord_errs[3];
510  for (int i = 0; i < 3; i++)
511  hitcoord_errs[i] = -1.000;
512 
513  //3d point at end of track
514  recob::SpacePoint mysp(hitcoord, hitcoord_errs, -1., spacepoints->size());
515 
516  spacepoints->push_back(mysp);
517 
518  // associate the hits to the space point
519  util::CreateAssn(evt, *spacepoints, sp_hits, *shassn);
520 
521  } //loop over min-hits
522 
523  endSPIndex = spacepoints->size();
524 
525  // Add the 3D track to the vector of the reconstructed tracks
526  if (spacepoints->size() > startSPIndex || clustersPerTrack.size() > 0) {
527 
528  std::vector<TVector3> xyz;
529  xyz.push_back(startpointVec);
530  xyz.push_back(endpointVec);
531  std::vector<TVector3> dir_xyz;
532  dir_xyz.push_back(DirCos);
533  dir_xyz.push_back(DirCos);
534 
535  recob::Track the3DTrack(
538  recob::Track::Flags_t(xyz.size()),
539  false),
540  0,
541  -1.,
542  0,
545  tcol->size());
546  tcol->push_back(the3DTrack);
547 
548  // associate the track with its spacepoints
549  util::CreateAssn(evt, *tcol, *spacepoints, *sassn, startSPIndex, endSPIndex);
550 
551  // associate the track with its clusters
552  util::CreateAssn(evt, *tcol, clustersPerTrack, *cassn);
553 
554  art::FindManyP<recob::Hit> fmhc(clustersPerTrack, evt, fClusterModuleLabel);
555 
556  // get the hits associated with each cluster and associate those with the track
557  for (size_t p = 0; p < clustersPerTrack.size(); ++p) {
558  const std::vector<art::Ptr<recob::Hit>>& hits = fmhc.at(p);
559  util::CreateAssn(evt, *tcol, hits, *hassn);
560  }
561  }
562 
563  } //close match 2D tracks
564 
565  } //close loop over Induction view 2D tracks
566 
567  } //close loop over Collection view 2D tracks
568 
569  mf::LogVerbatim("Summary") << std::setfill('-') << std::setw(175) << "-" << std::setfill(' ');
570  mf::LogVerbatim("Summary") << "Track3Dreco Summary:";
571  for (unsigned int i = 0; i < tcol->size(); ++i) {
572  mf::LogVerbatim("Summary") << tcol->at(i);
573  }
574 
575  evt.put(std::move(tcol));
576  evt.put(std::move(spacepoints));
577  evt.put(std::move(cassn));
578  evt.put(std::move(sassn));
579  evt.put(std::move(hassn));
580  evt.put(std::move(shassn));
581 
582  return;
583  }
code to link reconstructed objects back to the MC truth information
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::string GetLArTPCVolumeName(TPCID const &tpcid=tpc_zero) const
Return the name of specified LAr TPC volume.
TTree * t1
Definition: plottest35.C:26
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
Definition: TrackingTypes.h:78
std::string fClusterModuleLabel
label for input cluster collection
The data type to uniquely identify a Plane.
Definition: geo_types.h:463
TrackTrajectory::Flags_t Flags_t
Definition: Track.h:67
constexpr auto abs(T v)
Returns the absolute value of the argument.
Planes which measure Z direction.
Definition: geo_types.h:138
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 >> SMatrixSym55
double ThetaZ() const
Angle of the wires from positive z axis; .
Definition: PlaneGeo.cxx:646
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
PlaneGeo const & Plane(PlaneID const &planeid) const
Returns the specified wire.
void hits()
Definition: readHits.C:15
typename data_t::const_iterator const_iterator
Definition: PtrVector.h:55
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
A trajectory in space reconstructed from hits.
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
Definition: TrackingTypes.h:68
The data type to uniquely identify a TPC.
Definition: geo_types.h:381
size_type size() const
Definition: PtrVector.h:302
TTree * t2
Definition: plottest35.C:36
int ftmatch
tolerance for time matching (in time samples)
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Length_t PlanePitch(TPCID const &tpcid, PlaneID::PlaneID_t p1=0, PlaneID::PlaneID_t p2=1) const
Returns the distance between two planes.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Length_t DetHalfHeight(TPCID const &tpcid=tpc_zero) const
Returns the half height of the active volume of the specified TPC.
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

double trkf::Track3Dreco::fchi2dof
private

tolerance for chi2/dof of cluster fit to function

Definition at line 59 of file Track3Dreco_module.cc.

Referenced by Track3Dreco().

std::string trkf::Track3Dreco::fClusterModuleLabel
private

label for input cluster collection

Definition at line 60 of file Track3Dreco_module.cc.

Referenced by produce(), and Track3Dreco().

int trkf::Track3Dreco::ftmatch
private

tolerance for time matching (in time samples)

Definition at line 58 of file Track3Dreco_module.cc.

Referenced by produce(), and Track3Dreco().


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