LArSoft  v10_04_05
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 51 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 73 of file SpacePts_module.cc.

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

73  : EDProducer{pset}
74  {
75  fPreSamplings = pset.get<double>("TicksOffset");
76  ftmatch = pset.get<int>("TMatch");
77  fClusterModuleLabel = pset.get<std::string>("ClusterModuleLabel");
78  fEndPoint2DModuleLabel = pset.get<std::string>("EndPoint2DModuleLabel");
79  fvertexclusterWindow = pset.get<double>("vertexclusterWindow");
80 
81  produces<std::vector<recob::Track>>();
82  produces<std::vector<recob::SpacePoint>>();
83  produces<art::Assns<recob::Track, recob::SpacePoint>>();
84  produces<art::Assns<recob::Track, recob::Cluster>>();
85  produces<art::Assns<recob::Track, recob::Hit>>();
86  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
87  }
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 90 of file SpacePts_module.cc.

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

91  {
93  auto const& wireReadoutGeom = art::ServiceHandle<geo::WireReadout const>()->Get();
94  auto const detProp =
96 
98  // Make a std::unique_ptr<> for the thing you want to put into the event
99  // because that handles the memory management for you
101  auto tcol = std::make_unique<std::vector<recob::Track>>();
102  auto spcol = std::make_unique<std::vector<recob::SpacePoint>>();
103  auto tspassn = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
104  auto tcassn = std::make_unique<art::Assns<recob::Track, recob::Cluster>>();
105  auto thassn = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
106  auto shassn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
107 
108  // define TPC parameters
109  constexpr geo::TPCID tpcid{0, 0};
110  auto const& tpc = geom->TPC(tpcid);
111  TString tpcName = tpc.ActiveVolume()->GetName();
112 
113  //TPC dimensions
114  double YC = tpc.HalfHeight() * 2.; // TPC height in cm
115  double Angle = wireReadoutGeom.Plane(geo::PlaneID{tpcid, 1}).Wire(0).ThetaZ(false) -
116  TMath::Pi() / 2.; // wire angle with respect to the vertical direction
117  // Parameters temporary defined here, but possibly to be retrieved somewhere in the code
118  double timetick = 0.198; //time sample in us
119  double presamplings = fPreSamplings; // 60.;
120  const double wireShift =
121  50.; // half the number of wires from the Induction(Collection) plane intersecting with a wire from the Collection(Induction) plane.
122  double plane_pitch = wireReadoutGeom.PlanePitch(tpcid); //wire plane pitch in cm
123  double wire_pitch = wireReadoutGeom.FirstPlane(tpcid).WirePitch(); //wire pitch in cm
124  double Efield_drift = 0.5; // Electric Field in the drift region in kV/cm
125  double Efield_SI = 0.7; // Electric Field between Shield and Induction planes in kV/cm
126  double Efield_IC = 0.9; // Electric Field between Induction and Collection planes in kV/cm
127  double Temperature = 90.; // LAr Temperature in K
128 
129  double driftvelocity =
130  detProp.DriftVelocity(Efield_drift, Temperature); //drift velocity in the drift region (cm/us)
131  double driftvelocity_SI = detProp.DriftVelocity(
132  Efield_SI, Temperature); //drift velocity between shield and induction (cm/us)
133  double driftvelocity_IC = detProp.DriftVelocity(
134  Efield_IC, Temperature); //drift velocity between induction and collection (cm/us)
135  double timepitch = driftvelocity * timetick; //time sample (cm)
136  double tSI = plane_pitch / driftvelocity_SI /
137  timetick; //drift time between Shield and Collection planes (time samples)
138  double tIC = plane_pitch / driftvelocity_IC /
139  timetick; //drift time between Induction and Collection planes (time samples)
140 
141  // get input Cluster object(s).
142  art::Handle<std::vector<recob::Cluster>> clusterListHandle;
143  evt.getByLabel(fClusterModuleLabel, clusterListHandle);
144 
145  // get input EndPoint2D object(s).
146  art::Handle<std::vector<recob::EndPoint2D>> endpointListHandle;
147  evt.getByLabel(fEndPoint2DModuleLabel, endpointListHandle);
148 
150  if (evt.getByLabel(fEndPoint2DModuleLabel, endpointListHandle))
151  for (unsigned int i = 0; i < endpointListHandle->size(); ++i) {
152  art::Ptr<recob::EndPoint2D> endpointHolder(endpointListHandle, i);
153  endpointlist.push_back(endpointHolder);
154  }
155 
156  // Declare some vectors..
157  // Induction
158  std::vector<double> Iwirefirsts; // in cm
159  std::vector<double> Iwirelasts; // in cm
160  std::vector<double> Itimefirsts; // in cm
161  std::vector<double> Itimelasts; // in cm
162  std::vector<double> Itimefirsts_line; // in cm
163  std::vector<double> Itimelasts_line; // in cm
164  std::vector<std::vector<art::Ptr<recob::Hit>>> IclusHitlists;
165  std::vector<unsigned int> Icluster_count;
166 
167  // Collection
168  std::vector<double> Cwirefirsts; // in cm
169  std::vector<double> Cwirelasts; // in cm
170  std::vector<double> Ctimefirsts; // in cm
171  std::vector<double> Ctimelasts; // in cm
172  std::vector<double> Ctimefirsts_line; // in cm
173  std::vector<double> Ctimelasts_line; // in cm
174  std::vector<std::vector<art::Ptr<recob::Hit>>> CclusHitlists;
175  std::vector<unsigned int> Ccluster_count;
176 
177  art::FindManyP<recob::Hit> fm(clusterListHandle, evt, fClusterModuleLabel);
178 
179  for (unsigned int ii = 0; ii < clusterListHandle->size(); ++ii) {
180  art::Ptr<recob::Cluster> cl(clusterListHandle, ii);
181 
182  // Figure out which View the cluster belongs to
183  //only consider merged-lines that are associated with the vertex.
184  //this helps get rid of through-going muon background -spitz
185  int vtx2d_w = -99999;
186  double vtx2d_t = -99999;
187  bool found2dvtx = false;
188 
189  for (unsigned int j = 0; j < endpointlist.size(); j++) {
190  if (endpointlist[j]->View() == cl->View()) {
191  vtx2d_w = endpointlist[j]->WireID().Wire; //for update to EndPoint2D ... WK 4/22/13
192  vtx2d_t = endpointlist[j]->DriftTime();
193  found2dvtx = true;
194  break;
195  }
196  }
197  if (found2dvtx) {
198  double w = cl->StartWire();
199  double t = cl->StartTick();
200  double dtdw = std::tan(cl->StartAngle());
201  double t_vtx = t + dtdw * (vtx2d_w - w);
202  double dis = std::abs(vtx2d_t - t_vtx);
203  if (dis > fvertexclusterWindow) continue;
204  }
205  //else continue; //what to do if a 2D vertex is not found? perhaps vertex finder was not even run.
206 
207  // Some variables for the hit
208  float time; //hit time at maximum
209 
210  std::vector<art::Ptr<recob::Hit>> hitlist = fm.at(ii);
211  std::sort(hitlist.begin(), hitlist.end(), trkf::SortByWire());
212 
213  TGraph* the2Dtrack = new TGraph(hitlist.size());
214 
215  std::vector<double> wires;
216  std::vector<double> times;
217 
218  int np = 0;
219  //loop over cluster hits
220  for (std::vector<art::Ptr<recob::Hit>>::const_iterator theHit = hitlist.begin();
221  theHit != hitlist.end();
222  theHit++) {
223  //recover the Hit
224  // recob::Hit* theHit = (recob::Hit*)(*hitIter);
225  time = (*theHit)->PeakTime();
226 
227  time -= presamplings;
228 
229  if (wireReadoutGeom.SignalType((*theHit)->Channel()) == geo::kCollection)
230  time -= tIC; // Collection
231  //transform hit wire and time into cm
232  double wire_cm = 0.;
233  if (wireReadoutGeom.SignalType((*theHit)->Channel()) == geo::kInduction)
234  wire_cm = (double)(((*theHit)->WireID().Wire + 3.95) * wire_pitch);
235  else
236  wire_cm = (double)(((*theHit)->WireID().Wire + 1.84) * wire_pitch);
237 
238  //double time_cm = (double)(time * timepitch);
239  double time_cm;
240  if (time > tSI)
241  time_cm = (double)((time - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
242  else
243  time_cm = time * driftvelocity_SI * timetick;
244 
245  wires.push_back(wire_cm);
246  times.push_back(time_cm);
247 
248  the2Dtrack->SetPoint(np, wire_cm, time_cm);
249  np++;
250  } //end of loop over cluster hits
251 
252  // fit the 2Dtrack and get some info to store
253  try {
254  the2Dtrack->Fit("pol1", "Q");
255  }
256  catch (...) {
257  std::cout << "The 2D track fit failed" << std::endl;
258  continue;
259  }
260 
261  TF1* pol1 = (TF1*)the2Dtrack->GetFunction("pol1");
262  double par[2];
263  pol1->GetParameters(par);
264  double intercept = par[0];
265  double slope = par[1];
266 
267  double w0 = wires.front(); // first hit wire (cm)
268  double w1 = wires.back(); // last hit wire (cm)
269  double t0 = times.front(); // first hit time (cm)
270  double t1 = times.back(); // last hit time (cm)
271  double t0_line = intercept + (w0)*slope; // time coordinate at wire w0 on the fit line (cm)
272  double t1_line = intercept + (w1)*slope; // time coordinate at wire w1 on the fit line (cm)
273 
274  // actually store the 2Dtrack info
275  switch (wireReadoutGeom.SignalType((*hitlist.begin())->Channel())) {
276  case geo::kInduction:
277  Iwirefirsts.push_back(w0);
278  Iwirelasts.push_back(w1);
279  Itimefirsts.push_back(t0);
280  Itimelasts.push_back(t1);
281  Itimefirsts_line.push_back(t0_line);
282  Itimelasts_line.push_back(t1_line);
283  IclusHitlists.push_back(hitlist);
284  Icluster_count.push_back(ii);
285  break;
286  case geo::kCollection:
287  Cwirefirsts.push_back(w0);
288  Cwirelasts.push_back(w1);
289  Ctimefirsts.push_back(t0);
290  Ctimelasts.push_back(t1);
291  Ctimefirsts_line.push_back(t0_line);
292  Ctimelasts_line.push_back(t1_line);
293  CclusHitlists.push_back(hitlist);
294  Ccluster_count.push_back(ii);
295  break;
296  case geo::kMysteryType: break;
297  }
298  delete pol1;
299  } // end of loop over all input clusters
300 
304 
305  for (unsigned int collectionIter = 0; collectionIter < CclusHitlists.size();
306  collectionIter++) { //loop over Collection view 2D tracks
307  // Recover previously stored info
308  double Cw0 = Cwirefirsts[collectionIter];
309  double Cw1 = Cwirelasts[collectionIter];
310  double Ct0_line = Ctimefirsts_line[collectionIter];
311  double Ct1_line = Ctimelasts_line[collectionIter];
312  std::vector<art::Ptr<recob::Hit>> hitsCtrk = CclusHitlists[collectionIter];
313 
314  double collLength =
315  TMath::Sqrt(TMath::Power(Ct1_line - Ct0_line, 2) + TMath::Power(Cw1 - Cw0, 2));
316 
317  for (unsigned int inductionIter = 0; inductionIter < IclusHitlists.size();
318  inductionIter++) { //loop over Induction view 2D tracks
319  // Recover previously stored info
320  double Iw0 = Iwirefirsts[inductionIter];
321  double Iw1 = Iwirelasts[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  geo::WireID hit1WireID = minhits[imin]->WireID();
426  auto const hitSigType = minhits[imin]->SignalType();
427  double w1 = 0;
428 
429  //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.
430  if (hitSigType == geo::kInduction)
431  w1 = (double)((hit1WireID.Wire + 3.95) * wire_pitch);
432  else
433  w1 = (double)((hit1WireID.Wire + 1.84) * wire_pitch);
434 
435  double temptime1 = minhits[imin]->PeakTime() - presamplings;
436  if (hitSigType == geo::kCollection) temptime1 -= tIC;
437  double t1;
438  if (temptime1 > tSI)
439  t1 = (double)((temptime1 - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
440  else
441  t1 = temptime1 * driftvelocity_SI * timetick;
442 
443  //get the track origin co-ordinates in the two views
444  TVector2 minVtx2D;
445  (hitSigType == geo::kCollection) ? minVtx2D.Set(collVtx.X(), collVtx.Y()) :
446  minVtx2D.Set(indVtx.X(), indVtx.Y());
447  TVector2 maxVtx2D;
448  (hitSigType == geo::kCollection) ? maxVtx2D.Set(indVtx.X(), indVtx.Y()) :
449  maxVtx2D.Set(collVtx.X(), collVtx.Y());
450 
451  double ratio =
452  (collLength > indLength) ? collLength / indLength : indLength / collLength;
453 
454  //compute the distance of the hit (imin) from the relative track origin
455  double minDistance = ratio * TMath::Sqrt(TMath::Power(t1 - minVtx2D.X(), 2) +
456  TMath::Power(w1 - minVtx2D.Y(), 2));
457 
458  //core matching algorithm
459  double difference = 9999999.;
460 
461  for (unsigned int imax = 0; imax < maxhits.size();
462  imax++) { //loop over hits of the other view
463  if (!maxhitsMatch[imax]) {
464  //get wire - time coordinate of the hit
465  geo::WireID hit2WireID = maxhits[imax]->WireID();
466  auto const hit2SigType = maxhits[imax]->SignalType();
467  double w2 = 0.;
468  if (hit2SigType == geo::kInduction)
469  w2 = (double)((hit2WireID.Wire + 3.95) * wire_pitch);
470  else
471  w2 = (double)((hit2WireID.Wire + 1.84) * wire_pitch);
472 
473  double temptime2 = maxhits[imax]->PeakTime() - presamplings;
474  if (hit2SigType == geo::kCollection) temptime2 -= tIC;
475  double t2;
476  if (temptime2 > tSI)
477  t2 = (double)((temptime2 - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
478  else
479  t2 = temptime2 * driftvelocity_SI * timetick;
480 
481  bool timematch = (std::abs(t1 - t2) < ftmatch * timepitch);
482  bool wirematch = (std::abs(w1 - w2) < wireShift * wire_pitch);
483 
484  double maxDistance = TMath::Sqrt(TMath::Power(t2 - maxVtx2D.X(), 2) +
485  TMath::Power(w2 - maxVtx2D.Y(), 2));
486  if (wirematch && timematch && std::abs(maxDistance - minDistance) < difference) {
487  difference = std::abs(maxDistance - minDistance);
488  imaximum = imax;
489  }
490  }
491  }
492  maxhitsMatch[imaximum] = true;
493 
495  if (difference != 9999999.) {
496  sp_hits.push_back(minhits[imin]);
497  sp_hits.push_back(maxhits[imaximum]);
498  }
499 
500  // Get the time-wire co-ordinates of the matched hit
501  geo::WireID hit2WireID = maxhits[imaximum]->WireID();
502  auto const hit2SigType = maxhits[imaximum]->SignalType();
503 
504  double w1_match = 0.;
505  if (hit2SigType == geo::kInduction)
506  w1_match = (double)((hit2WireID.Wire + 3.95) * wire_pitch);
507  else
508  w1_match = (double)((hit2WireID.Wire + 1.84) * wire_pitch);
509 
510  double temptime3 = maxhits[imaximum]->PeakTime() - presamplings;
511  if (hit2SigType == geo::kCollection) temptime3 -= tIC;
512  double t1_match;
513  if (temptime3 > tSI)
514  t1_match =
515  (double)((temptime3 - tSI) * timepitch + tSI * driftvelocity_SI * timetick);
516  else
517  t1_match = temptime3 * driftvelocity_SI * timetick;
518 
519  // create the 3D hit, compute its co-ordinates and add it to the 3D hits list
520  double Ct = hitSigType == geo::kCollection ? t1 : t1_match;
521  double Cw = hit2SigType == geo::kCollection ? w1 : w1_match;
522  double Iw = hit2SigType == geo::kCollection ? w1_match : w1;
523 
524  const TVector3 hit3d(Ct,
525  (Cw - Iw) / (2. * TMath::Sin(Angle)),
526  (Cw + Iw) / (2. * TMath::Cos(Angle)) -
527  YC / 2. * TMath::Tan(Angle));
528 
529  Double_t hitcoord[3];
530  hitcoord[0] = hit3d.X();
531  hitcoord[1] = hit3d.Y();
532  hitcoord[2] = hit3d.Z();
533 
534  double err[6] = {util::kBogusD};
535  recob::SpacePoint mysp(hitcoord,
536  err,
538  spStart + spacepoints.size()); //3d point at end of track
539  // Don't add a spacepoint right on top of the last one.
540  const double eps(0.1); // 1mm
541  if (spacepoints.size() >= 1) {
542  TVector3 magNew(mysp.XYZ()[0], mysp.XYZ()[1], mysp.XYZ()[2]);
543  TVector3 magLast(spacepoints.back().XYZ()[0],
544  spacepoints.back().XYZ()[1],
545  spacepoints.back().XYZ()[2]);
546  if (!(magNew.Mag() >= magLast.Mag() + eps || magNew.Mag() <= magLast.Mag() - eps))
547  continue;
548  }
549  spacepoints.push_back(mysp);
550  spcol->push_back(mysp);
551  util::CreateAssn(evt, *spcol, sp_hits, *shassn);
552 
553  } //loop over min-hits
554 
555  size_t spEnd = spcol->size();
556 
557  // Add the 3D track to the vector of the reconstructed tracks
558  if (spacepoints.size() > 0) {
559 
560  // make a vector of the trajectory points along the track
561  std::vector<TVector3> xyz(spacepoints.size());
562  for (size_t s = 0; s < spacepoints.size(); ++s) {
563  xyz[s] = TVector3(spacepoints[s].XYZ());
564  }
565 
567  std::vector<TVector3> dircos(spacepoints.size(), DirCos);
568 
569  tcol->push_back(
572  recob::Track::Flags_t(xyz.size()),
573  false),
574  0,
575  -1.,
576  0,
579  tcol->size()));
580 
581  // make associations between the track and space points
582  util::CreateAssn(evt, *tcol, *spcol, *tspassn, spStart, spEnd);
583 
584  // now the track and clusters
585  util::CreateAssn(evt, *tcol, clustersPerTrack, *tcassn);
586 
587  // and the hits and track
588  art::FindManyP<recob::Hit> fmh(clustersPerTrack, evt, fClusterModuleLabel);
589  for (size_t cpt = 0; cpt < clustersPerTrack.size(); ++cpt)
590  util::CreateAssn(evt, *tcol, fmh.at(cpt), *thassn);
591  }
592  } //close match 2D tracks
593 
594  } //close loop over Induction view 2D tracks
595 
596  } //close loop over Collection xxview 2D tracks
597 
598  mf::LogVerbatim("Summary") << std::setfill('-') << std::setw(175) << "-" << std::setfill(' ');
599  mf::LogVerbatim("Summary") << "SpacePts Summary:";
600  for (unsigned int i = 0; i < tcol->size(); ++i)
601  mf::LogVerbatim("Summary") << tcol->at(i);
602 
603  evt.put(std::move(tcol));
604  evt.put(std::move(spcol));
605  evt.put(std::move(tspassn));
606  evt.put(std::move(tcassn));
607  evt.put(std::move(thassn));
608  evt.put(std::move(shassn));
609 
610  } // end SpacePts::produce()
code to link reconstructed objects back to the MC truth information
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
TTree * t1
Definition: plottest35.C:26
Who knows?
Definition: geo_types.h:149
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:364
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
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:430
std::string fClusterModuleLabel
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
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:147
A trajectory in space reconstructed from hits.
const TGeoVolume * ActiveVolume() const
Returns the expected drift direction based on geometry.
Definition: TPCGeo.h:114
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:306
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.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
constexpr double kBogusD
obviously bogus double value
std::string fEndPoint2DModuleLabel
TPCGeo const & TPC(TPCID const &tpcid=details::tpc_zero) const
Returns the specified TPC.
Definition: GeometryCore.h:448
Float_t w
Definition: plot.C:20
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:148
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 61 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().

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

Definition at line 62 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().

double trkf::SpacePts::fPreSamplings
private

Definition at line 59 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().

int trkf::SpacePts::ftmatch
private

Definition at line 58 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().

double trkf::SpacePts::fvertexclusterWindow
private

Definition at line 60 of file SpacePts_module.cc.

Referenced by produce(), and SpacePts().


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