LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
trkf::SpacePts Class Reference
Inheritance diagram for trkf::SpacePts:
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

 SpacePts (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)
 

Private Attributes

int ftmatch
 
double fPreSamplings
 
double fvertexclusterWindow
 
std::string fClusterModuleLabel
 
std::string fEndPoint2DModuleLabel
 

Detailed Description

Definition at line 50 of file SpacePts_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::SpacePts::SpacePts ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 72 of file SpacePts_module.cc.

References fClusterModuleLabel, fEndPoint2DModuleLabel, fPreSamplings, ftmatch, and fvertexclusterWindow.

72  : EDProducer{pset}
73  {
74  fPreSamplings = pset.get<double>("TicksOffset");
75  ftmatch = pset.get<int>("TMatch");
76  fClusterModuleLabel = pset.get<std::string>("ClusterModuleLabel");
77  fEndPoint2DModuleLabel = pset.get<std::string>("EndPoint2DModuleLabel");
78  fvertexclusterWindow = pset.get<double>("vertexclusterWindow");
79 
80  produces<std::vector<recob::Track>>();
81  produces<std::vector<recob::SpacePoint>>();
82  produces<art::Assns<recob::Track, recob::SpacePoint>>();
83  produces<art::Assns<recob::Track, recob::Cluster>>();
84  produces<art::Assns<recob::Track, recob::Hit>>();
85  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
86  }
double fvertexclusterWindow
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
std::string fClusterModuleLabel
std::string fEndPoint2DModuleLabel

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::SpacePts::produce ( art::Event evt)
privatevirtual
Todo:
really should fill the direction cosines with unique values

Implements art::EDProducer.

Definition at line 89 of file SpacePts_module.cc.

References util::abs(), recob::tracking::convertCollToPoint(), recob::tracking::convertCollToVector(), util::CreateAssn(), DEFINE_ART_MODULE, geo::GeometryCore::DetHalfHeight(), fClusterModuleLabel, fEndPoint2DModuleLabel, fPreSamplings, ftmatch, fvertexclusterWindow, art::ProductRetriever::getByLabel(), geo::GeometryCore::GetLArTPCVolumeName(), util::kBogusD, geo::kCollection, geo::kInduction, geo::kMysteryType, geo::GeometryCore::Plane(), geo::GeometryCore::PlanePitch(), art::PtrVector< T >::push_back(), art::Event::put(), geo::GeometryCore::SignalType(), art::PtrVector< T >::size(), SortByWire(), recob::Cluster::StartAngle(), recob::Cluster::StartTick(), recob::Cluster::StartWire(), t1, t2, geo::PlaneGeo::ThetaZ(), lar::dump::vector(), recob::Cluster::View(), w, geo::WireID::Wire, and geo::GeometryCore::WirePitch().

90  {
92  auto const detProp =
94 
96  // Make a std::unique_ptr<> for the thing you want to put into the event
97  // because that handles the memory management for you
99  auto tcol = std::make_unique<std::vector<recob::Track>>();
100  auto spcol = std::make_unique<std::vector<recob::SpacePoint>>();
101  auto tspassn = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
102  auto tcassn = std::make_unique<art::Assns<recob::Track, recob::Cluster>>();
103  auto thassn = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
104  auto shassn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
105 
106  // define TPC parameters
107  TString tpcName = geom->GetLArTPCVolumeName();
108 
109  //TPC dimensions
110  double YC = (geom->DetHalfHeight()) * 2.; // TPC height in cm
111  constexpr geo::TPCID tpcid{0, 0};
112  double Angle = geom->Plane(geo::PlaneID{tpcid, 1}).Wire(0).ThetaZ(false) -
113  TMath::Pi() / 2.; // wire angle with respect to the vertical direction
114  // Parameters temporary defined here, but possibly to be retrieved somewhere in the code
115  double timetick = 0.198; //time sample in us
116  double presamplings = fPreSamplings; // 60.;
117  const double wireShift =
118  50.; // half the number of wires from the Induction(Collection) plane intersecting with a wire from the Collection(Induction) plane.
119  double plane_pitch = geom->PlanePitch(tpcid, 0, 1); //wire plane pitch in cm
120  double wire_pitch = geom->WirePitch(); //wire pitch in cm
121  double Efield_drift = 0.5; // Electric Field in the drift region in kV/cm
122  double Efield_SI = 0.7; // Electric Field between Shield and Induction planes in kV/cm
123  double Efield_IC = 0.9; // Electric Field between Induction and Collection planes in kV/cm
124  double Temperature = 90.; // LAr Temperature in K
125 
126  double driftvelocity =
127  detProp.DriftVelocity(Efield_drift, Temperature); //drift velocity in the drift region (cm/us)
128  double driftvelocity_SI = detProp.DriftVelocity(
129  Efield_SI, Temperature); //drift velocity between shield and induction (cm/us)
130  double driftvelocity_IC = detProp.DriftVelocity(
131  Efield_IC, Temperature); //drift velocity between induction and collection (cm/us)
132  double timepitch = driftvelocity * timetick; //time sample (cm)
133  double tSI = plane_pitch / driftvelocity_SI /
134  timetick; //drift time between Shield and Collection planes (time samples)
135  double tIC = plane_pitch / driftvelocity_IC /
136  timetick; //drift time between Induction and Collection planes (time samples)
137 
138  // get input Cluster object(s).
139  art::Handle<std::vector<recob::Cluster>> clusterListHandle;
140  evt.getByLabel(fClusterModuleLabel, clusterListHandle);
141 
142  // get input EndPoint2D object(s).
143  art::Handle<std::vector<recob::EndPoint2D>> endpointListHandle;
144  evt.getByLabel(fEndPoint2DModuleLabel, endpointListHandle);
145 
147  if (evt.getByLabel(fEndPoint2DModuleLabel, endpointListHandle))
148  for (unsigned int i = 0; i < endpointListHandle->size(); ++i) {
149  art::Ptr<recob::EndPoint2D> endpointHolder(endpointListHandle, i);
150  endpointlist.push_back(endpointHolder);
151  }
152 
153  // Declare some vectors..
154  // Induction
155  std::vector<double> Iwirefirsts; // in cm
156  std::vector<double> Iwirelasts; // in cm
157  std::vector<double> Itimefirsts; // in cm
158  std::vector<double> Itimelasts; // in cm
159  std::vector<double> Itimefirsts_line; // in cm
160  std::vector<double> Itimelasts_line; // in cm
161  std::vector<std::vector<art::Ptr<recob::Hit>>> IclusHitlists;
162  std::vector<unsigned int> Icluster_count;
163 
164  // Collection
165  std::vector<double> Cwirefirsts; // in cm
166  std::vector<double> Cwirelasts; // in cm
167  std::vector<double> Ctimefirsts; // in cm
168  std::vector<double> Ctimelasts; // in cm
169  std::vector<double> Ctimefirsts_line; // in cm
170  std::vector<double> Ctimelasts_line; // in cm
171  std::vector<std::vector<art::Ptr<recob::Hit>>> CclusHitlists;
172  std::vector<unsigned int> Ccluster_count;
173 
174  art::FindManyP<recob::Hit> fm(clusterListHandle, evt, fClusterModuleLabel);
175 
176  for (unsigned int ii = 0; ii < clusterListHandle->size(); ++ii) {
177  art::Ptr<recob::Cluster> cl(clusterListHandle, ii);
178 
179  // Figure out which View the cluster belongs to
180  //only consider merged-lines that are associated with the vertex.
181  //this helps get rid of through-going muon background -spitz
182  int vtx2d_w = -99999;
183  double vtx2d_t = -99999;
184  bool found2dvtx = false;
185 
186  for (unsigned int j = 0; j < endpointlist.size(); j++) {
187  if (endpointlist[j]->View() == cl->View()) {
188  vtx2d_w = endpointlist[j]->WireID().Wire; //for update to EndPoint2D ... WK 4/22/13
189  vtx2d_t = endpointlist[j]->DriftTime();
190  found2dvtx = true;
191  break;
192  }
193  }
194  if (found2dvtx) {
195  double w = cl->StartWire();
196  double t = cl->StartTick();
197  double dtdw = std::tan(cl->StartAngle());
198  double t_vtx = t + dtdw * (vtx2d_w - w);
199  double dis = std::abs(vtx2d_t - t_vtx);
200  if (dis > fvertexclusterWindow) continue;
201  }
202  //else continue; //what to do if a 2D vertex is not found? perhaps vertex finder was not even run.
203 
204  // Some variables for the hit
205  float time; //hit time at maximum
206 
207  std::vector<art::Ptr<recob::Hit>> hitlist = fm.at(ii);
208  std::sort(hitlist.begin(), hitlist.end(), trkf::SortByWire());
209 
210  TGraph* the2Dtrack = new TGraph(hitlist.size());
211 
212  std::vector<double> wires;
213  std::vector<double> times;
214 
215  int np = 0;
216  //loop over cluster hits
217  for (std::vector<art::Ptr<recob::Hit>>::const_iterator theHit = hitlist.begin();
218  theHit != hitlist.end();
219  theHit++) {
220  //recover the Hit
221  // recob::Hit* theHit = (recob::Hit*)(*hitIter);
222  time = (*theHit)->PeakTime();
223 
224  time -= presamplings;
225 
226  if (geom->SignalType((*theHit)->Channel()) == geo::kCollection) time -= tIC; // Collection
227  //transform hit wire and time into cm
228  double wire_cm = 0.;
229  if (geom->SignalType((*theHit)->Channel()) == geo::kInduction)
230  wire_cm = (double)(((*theHit)->WireID().Wire + 3.95) * wire_pitch);
231  else
232  wire_cm = (double)(((*theHit)->WireID().Wire + 1.84) * wire_pitch);
233 
234  //double time_cm = (double)(time * timepitch);
235  double time_cm;
236  if (time > tSI)
237  time_cm = (double)((time - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
238  else
239  time_cm = time * driftvelocity_SI * timetick;
240 
241  wires.push_back(wire_cm);
242  times.push_back(time_cm);
243 
244  the2Dtrack->SetPoint(np, wire_cm, time_cm);
245  np++;
246  } //end of loop over cluster hits
247 
248  // fit the 2Dtrack and get some info to store
249  try {
250  the2Dtrack->Fit("pol1", "Q");
251  }
252  catch (...) {
253  std::cout << "The 2D track fit failed" << std::endl;
254  continue;
255  }
256 
257  TF1* pol1 = (TF1*)the2Dtrack->GetFunction("pol1");
258  double par[2];
259  pol1->GetParameters(par);
260  double intercept = par[0];
261  double slope = par[1];
262 
263  double w0 = wires.front(); // first hit wire (cm)
264  double w1 = wires.back(); // last hit wire (cm)
265  double t0 = times.front(); // first hit time (cm)
266  double t1 = times.back(); // last hit time (cm)
267  double t0_line = intercept + (w0)*slope; // time coordinate at wire w0 on the fit line (cm)
268  double t1_line = intercept + (w1)*slope; // time coordinate at wire w1 on the fit line (cm)
269 
270  // actually store the 2Dtrack info
271  switch (geom->SignalType((*hitlist.begin())->Channel())) {
272  case geo::kInduction:
273  Iwirefirsts.push_back(w0);
274  Iwirelasts.push_back(w1);
275  Itimefirsts.push_back(t0);
276  Itimelasts.push_back(t1);
277  Itimefirsts_line.push_back(t0_line);
278  Itimelasts_line.push_back(t1_line);
279  IclusHitlists.push_back(hitlist);
280  Icluster_count.push_back(ii);
281  break;
282  case geo::kCollection:
283  Cwirefirsts.push_back(w0);
284  Cwirelasts.push_back(w1);
285  Ctimefirsts.push_back(t0);
286  Ctimelasts.push_back(t1);
287  Ctimefirsts_line.push_back(t0_line);
288  Ctimelasts_line.push_back(t1_line);
289  CclusHitlists.push_back(hitlist);
290  Ccluster_count.push_back(ii);
291  break;
292  case geo::kMysteryType: break;
293  }
294  delete pol1;
295  } // end of loop over all input clusters
296 
300 
301  for (unsigned int collectionIter = 0; collectionIter < CclusHitlists.size();
302  collectionIter++) { //loop over Collection view 2D tracks
303  // Recover previously stored info
304  double Cw0 = Cwirefirsts[collectionIter];
305  double Cw1 = Cwirelasts[collectionIter];
306  //double Ct0 = Ctimefirsts[collectionIter];
307  //double Ct1 = Ctimelasts[collectionIter];
308  double Ct0_line = Ctimefirsts_line[collectionIter];
309  double Ct1_line = Ctimelasts_line[collectionIter];
310  std::vector<art::Ptr<recob::Hit>> hitsCtrk = CclusHitlists[collectionIter];
311 
312  double collLength =
313  TMath::Sqrt(TMath::Power(Ct1_line - Ct0_line, 2) + TMath::Power(Cw1 - Cw0, 2));
314 
315  for (unsigned int inductionIter = 0; inductionIter < IclusHitlists.size();
316  inductionIter++) { //loop over Induction view 2D tracks
317  // Recover previously stored info
318  double Iw0 = Iwirefirsts[inductionIter];
319  double Iw1 = Iwirelasts[inductionIter];
320  //double It0 = Itimefirsts[inductionIter];
321  //double It1 = Itimelasts[inductionIter];
322  double It0_line = Itimefirsts_line[inductionIter];
323  double It1_line = Itimelasts_line[inductionIter];
324  std::vector<art::Ptr<recob::Hit>> hitsItrk = IclusHitlists[inductionIter];
325 
326  double indLength =
327  TMath::Sqrt(TMath::Power(It1_line - It0_line, 2) + TMath::Power(Iw1 - Iw0, 2));
328 
329  bool forward_match = ((std::abs(Ct0_line - It0_line) < ftmatch * timepitch) &&
330  (std::abs(Ct1_line - It1_line) < ftmatch * timepitch));
331  bool backward_match = ((std::abs(Ct0_line - It1_line) < ftmatch * timepitch) &&
332  (std::abs(Ct1_line - It0_line) < ftmatch * timepitch));
333 
334  if (forward_match || backward_match) {
335 
336  // Reconstruct the 3D track
337  TVector3 XYZ0, XYZ1; // track endpoints
338  if (forward_match) {
339  XYZ0.SetXYZ(Ct0_line,
340  (Cw0 - Iw0) / (2. * TMath::Sin(Angle)),
341  (Cw0 + Iw0) / (2. * TMath::Cos(Angle)) - YC / 2. * TMath::Tan(Angle));
342  XYZ1.SetXYZ(Ct1_line,
343  (Cw1 - Iw1) / (2. * TMath::Sin(Angle)),
344  (Cw1 + Iw1) / (2. * TMath::Cos(Angle)) - YC / 2. * TMath::Tan(Angle));
345  }
346  else {
347  XYZ0.SetXYZ(Ct0_line,
348  (Cw0 - Iw1) / (2. * TMath::Sin(Angle)),
349  (Cw0 + Iw1) / (2. * TMath::Cos(Angle)) - YC / 2. * TMath::Tan(Angle));
350  XYZ1.SetXYZ(Ct1_line,
351  (Cw1 - Iw0) / (2. * TMath::Sin(Angle)),
352  (Cw1 + Iw0) / (2. * TMath::Cos(Angle)) - YC / 2. * TMath::Tan(Angle));
353  }
354 
355  //compute track direction in Local co-ordinate system
356  //WARNING: There is an ambiguity introduced here for the case of backwards-going tracks.
357  //If available, vertex info. could sort this out.
358  TVector3 startpointVec, endpointVec;
359  TVector2 collVtx, indVtx;
360  if (XYZ0.Z() <= XYZ1.Z()) {
361  startpointVec.SetXYZ(XYZ0.X(), XYZ0.Y(), XYZ0.Z());
362  endpointVec.SetXYZ(XYZ1.X(), XYZ1.Y(), XYZ1.Z());
363  if (forward_match) {
364  collVtx.Set(Ct0_line, Cw0);
365  indVtx.Set(It0_line, Iw0);
366  }
367  else {
368  collVtx.Set(Ct0_line, Cw0);
369  indVtx.Set(It1_line, Iw1);
370  }
371  }
372  else {
373  startpointVec.SetXYZ(XYZ1.X(), XYZ1.Y(), XYZ1.Z());
374  endpointVec.SetXYZ(XYZ0.X(), XYZ0.Y(), XYZ0.Z());
375  if (forward_match) {
376  collVtx.Set(Ct1_line, Cw1);
377  indVtx.Set(It1_line, Iw1);
378  }
379  else {
380  collVtx.Set(Ct1_line, Cw1);
381  indVtx.Set(It0_line, Iw0);
382  }
383  }
384 
385  //compute track (normalized) cosine directions in the TPC co-ordinate system
386  TVector3 DirCos = endpointVec - startpointVec;
387 
388  //SetMag casues a crash if the magnitude of the vector is zero
389  try {
390  DirCos.SetMag(1.0); //normalize vector
391  }
392  catch (...) {
393  std::cout << "The Spacepoint is infinitely small" << std::endl;
394  continue;
395  }
396 
397  art::Ptr<recob::Cluster> cl1(clusterListHandle, Icluster_count[inductionIter]);
398  art::Ptr<recob::Cluster> cl2(clusterListHandle, Ccluster_count[collectionIter]);
399  art::PtrVector<recob::Cluster> clustersPerTrack;
400  clustersPerTrack.push_back(cl1);
401  clustersPerTrack.push_back(cl2);
402 
404  // Match hits
406 
407  //create collection of spacepoints that will be used when creating the Track object
408  std::vector<recob::SpacePoint> spacepoints;
409 
410  std::vector<art::Ptr<recob::Hit>> minhits =
411  hitsCtrk.size() <= hitsItrk.size() ? hitsCtrk : hitsItrk;
412  std::vector<art::Ptr<recob::Hit>> maxhits =
413  hitsItrk.size() < hitsCtrk.size() ? hitsCtrk : hitsItrk;
414 
415  std::vector<bool> maxhitsMatch(maxhits.size());
416  for (unsigned int it = 0; it < maxhits.size(); it++)
417  maxhitsMatch[it] = false;
418 
419  std::vector<recob::Hit*> hits3Dmatched;
420  // For the matching start from the view where the track projection presents less hits
421  unsigned int imaximum = 0;
422  size_t spStart = spcol->size();
423  for (unsigned int imin = 0; imin < minhits.size(); imin++) { //loop over hits
424  //get wire - time coordinate of the hit
425  //unsigned int channel,wire,plane1,plane2,tpc,cstat;
426  geo::WireID hit1WireID = minhits[imin]->WireID();
427  auto const hitSigType = minhits[imin]->SignalType();
428  double w1 = 0;
429 
430  //the 3.95 and 1.84 below are the ArgoNeuT TPC offsets for the induction and collection plane, respectively and are in units of wire pitch.
431  if (hitSigType == geo::kInduction)
432  w1 = (double)((hit1WireID.Wire + 3.95) * wire_pitch);
433  else
434  w1 = (double)((hit1WireID.Wire + 1.84) * wire_pitch);
435 
436  double temptime1 = minhits[imin]->PeakTime() - presamplings;
437  if (hitSigType == geo::kCollection) temptime1 -= tIC;
438  double
439  t1; // = plane1==1?(double)((minhits[imin]->PeakTime()-presamplings-tIC)*timepitch):(double)((minhits[imin]->PeakTime()-presamplings)*timepitch); //in cm
440  if (temptime1 > tSI)
441  t1 = (double)((temptime1 - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
442  else
443  t1 = temptime1 * driftvelocity_SI * timetick;
444 
445  //get the track origin co-ordinates in the two views
446  TVector2 minVtx2D;
447  (hitSigType == geo::kCollection) ? minVtx2D.Set(collVtx.X(), collVtx.Y()) :
448  minVtx2D.Set(indVtx.X(), indVtx.Y());
449  TVector2 maxVtx2D;
450  (hitSigType == geo::kCollection) ? maxVtx2D.Set(indVtx.X(), indVtx.Y()) :
451  maxVtx2D.Set(collVtx.X(), collVtx.Y());
452 
453  double ratio =
454  (collLength > indLength) ? collLength / indLength : indLength / collLength;
455 
456  //compute the distance of the hit (imin) from the relative track origin
457  double minDistance = ratio * TMath::Sqrt(TMath::Power(t1 - minVtx2D.X(), 2) +
458  TMath::Power(w1 - minVtx2D.Y(), 2));
459 
460  //core matching algorithm
461  double difference = 9999999.;
462 
463  for (unsigned int imax = 0; imax < maxhits.size();
464  imax++) { //loop over hits of the other view
465  if (!maxhitsMatch[imax]) {
466  //get wire - time coordinate of the hit
467  geo::WireID hit2WireID = maxhits[imax]->WireID();
468  auto const hit2SigType = maxhits[imax]->SignalType();
469  double w2 = 0.;
470  if (hit2SigType == geo::kInduction)
471  w2 = (double)((hit2WireID.Wire + 3.95) * wire_pitch);
472  else
473  w2 = (double)((hit2WireID.Wire + 1.84) * wire_pitch);
474 
475  double temptime2 = maxhits[imax]->PeakTime() - presamplings;
476  if (hit2SigType == geo::kCollection) temptime2 -= tIC;
477  double t2;
478  if (temptime2 > tSI)
479  t2 = (double)((temptime2 - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
480  else
481  t2 = temptime2 * driftvelocity_SI * timetick;
482 
483  bool timematch = (std::abs(t1 - t2) < ftmatch * timepitch);
484  bool wirematch = (std::abs(w1 - w2) < wireShift * wire_pitch);
485 
486  double maxDistance = TMath::Sqrt(TMath::Power(t2 - maxVtx2D.X(), 2) +
487  TMath::Power(w2 - maxVtx2D.Y(), 2));
488  if (wirematch && timematch && std::abs(maxDistance - minDistance) < difference) {
489  difference = std::abs(maxDistance - minDistance);
490  imaximum = imax;
491  }
492  }
493  }
494  maxhitsMatch[imaximum] = true;
495 
497  if (difference != 9999999.) {
498  sp_hits.push_back(minhits[imin]);
499  sp_hits.push_back(maxhits[imaximum]);
500  }
501 
502  // Get the time-wire co-ordinates of the matched hit
503  geo::WireID hit2WireID = maxhits[imaximum]->WireID();
504  auto const hit2SigType = maxhits[imaximum]->SignalType();
505 
506  //double w1_match = (double)((wire+1)*wire_pitch);
507  double w1_match = 0.;
508  if (hit2SigType == geo::kInduction)
509  w1_match = (double)((hit2WireID.Wire + 3.95) * wire_pitch);
510  else
511  w1_match = (double)((hit2WireID.Wire + 1.84) * wire_pitch);
512 
513  double temptime3 = maxhits[imaximum]->PeakTime() - presamplings;
514  if (hit2SigType == geo::kCollection) temptime3 -= tIC;
515  double t1_match;
516  if (temptime3 > tSI)
517  t1_match =
518  (double)((temptime3 - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
519  else
520  t1_match = temptime3 * driftvelocity_SI * timetick;
521 
522  // create the 3D hit, compute its co-ordinates and add it to the 3D hits list
523  double Ct = hitSigType == geo::kCollection ? t1 : t1_match;
524  double Cw = hit2SigType == geo::kCollection ? w1 : w1_match;
525  double Iw = hit2SigType == geo::kCollection ? w1_match : w1;
526 
527  const TVector3 hit3d(Ct,
528  (Cw - Iw) / (2. * TMath::Sin(Angle)),
529  (Cw + Iw) / (2. * TMath::Cos(Angle)) -
530  YC / 2. * TMath::Tan(Angle));
531 
532  Double_t hitcoord[3];
533  hitcoord[0] = hit3d.X();
534  hitcoord[1] = hit3d.Y();
535  hitcoord[2] = hit3d.Z();
536 
537  /*
538  double yy,zz;
539  if(geom->ChannelsIntersect(geom->PlaneWireToChannel(0,(int)((Iw/wire_pitch)-3.95)), geom->PlaneWireToChannel(1,(int)((Cw/wire_pitch)-1.84)),yy,zz))
540  {
541  //channelsintersect provides a slightly more accurate set of y and z coordinates. use channelsintersect in case the wires in question do cross.
542  hitcoord[1] = yy;
543  hitcoord[2] = zz;
544  mf::LogInfo("SpacePts: ") << "SpacePoint adding xyz ..." << hitcoord[0] <<","<< hitcoord[1] <<","<< hitcoord[2];
545  // std::cout<<"wire 1: "<<(Iw/wire_pitch)-3.95<<" "<<(Cw/wire_pitch)-1.84<<std::endl;
546  // std::cout<<"Intersect: "<<yy<<" "<<zz<<std::endl;
547  }
548  else
549  continue;
550  */
551 
552  double err[6] = {util::kBogusD};
553  recob::SpacePoint mysp(hitcoord,
554  err,
556  spStart + spacepoints.size()); //3d point at end of track
557  // Don't add a spacepoint right on top of the last one.
558  const double eps(0.1); // 1mm
559  if (spacepoints.size() >= 1) {
560  TVector3 magNew(mysp.XYZ()[0], mysp.XYZ()[1], mysp.XYZ()[2]);
561  TVector3 magLast(spacepoints.back().XYZ()[0],
562  spacepoints.back().XYZ()[1],
563  spacepoints.back().XYZ()[2]);
564  if (!(magNew.Mag() >= magLast.Mag() + eps || magNew.Mag() <= magLast.Mag() - eps))
565  continue;
566  }
567  spacepoints.push_back(mysp);
568  spcol->push_back(mysp);
569  util::CreateAssn(evt, *spcol, sp_hits, *shassn);
570 
571  } //loop over min-hits
572 
573  size_t spEnd = spcol->size();
574 
575  // Add the 3D track to the vector of the reconstructed tracks
576  if (spacepoints.size() > 0) {
577 
578  // make a vector of the trajectory points along the track
579  std::vector<TVector3> xyz(spacepoints.size());
580  for (size_t s = 0; s < spacepoints.size(); ++s) {
581  xyz[s] = TVector3(spacepoints[s].XYZ());
582  }
583 
585  std::vector<TVector3> dircos(spacepoints.size(), DirCos);
586 
587  tcol->push_back(
590  recob::Track::Flags_t(xyz.size()),
591  false),
592  0,
593  -1.,
594  0,
597  tcol->size()));
598 
599  // make associations between the track and space points
600  util::CreateAssn(evt, *tcol, *spcol, *tspassn, spStart, spEnd);
601 
602  // now the track and clusters
603  util::CreateAssn(evt, *tcol, clustersPerTrack, *tcassn);
604 
605  // and the hits and track
606  art::FindManyP<recob::Hit> fmh(clustersPerTrack, evt, fClusterModuleLabel);
607  for (size_t cpt = 0; cpt < clustersPerTrack.size(); ++cpt)
608  util::CreateAssn(evt, *tcol, fmh.at(cpt), *thassn);
609  }
610  } //close match 2D tracks
611 
612  } //close loop over Induction view 2D tracks
613 
614  } //close loop over Collection xxview 2D tracks
615 
616  mf::LogVerbatim("Summary") << std::setfill('-') << std::setw(175) << "-" << std::setfill(' ');
617  mf::LogVerbatim("Summary") << "SpacePts Summary:";
618  for (unsigned int i = 0; i < tcol->size(); ++i)
619  mf::LogVerbatim("Summary") << tcol->at(i);
620 
621  evt.put(std::move(tcol));
622  evt.put(std::move(spcol));
623  evt.put(std::move(tspassn));
624  evt.put(std::move(tcassn));
625  evt.put(std::move(thassn));
626  evt.put(std::move(shassn));
627 
628  } // end SpacePts::produce()
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
Who knows?
Definition: geo_types.h:153
double fvertexclusterWindow
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
Definition: TrackingTypes.h:78
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.
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 >> SMatrixSym55
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:563
std::string fClusterModuleLabel
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
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
PlaneGeo const & Plane(PlaneID const &planeid) const
Returns the specified wire.
bool SortByWire(art::Ptr< recob::Hit > const &h1, art::Ptr< recob::Hit > const &h2)
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
Signal from induction planes.
Definition: geo_types.h:151
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
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.
SigType_t SignalType(PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
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.
constexpr double kBogusD
obviously bogus double value
Length_t DetHalfHeight(TPCID const &tpcid=tpc_zero) const
Returns the half height of the active volume of the specified TPC.
std::string fEndPoint2DModuleLabel
Float_t w
Definition: plot.C:20
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
Definition: fwd.h:26
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
Signal from collection planes.
Definition: geo_types.h:152
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

std::string trkf::SpacePts::fClusterModuleLabel
private

Definition at line 60 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().

std::string trkf::SpacePts::fEndPoint2DModuleLabel
private

Definition at line 61 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().

double trkf::SpacePts::fPreSamplings
private

Definition at line 58 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().

int trkf::SpacePts::ftmatch
private

Definition at line 57 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().

double trkf::SpacePts::fvertexclusterWindow
private

Definition at line 59 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().


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