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

 SpacePointSolver (const fhicl::ParameterSet &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 Types

typedef std::map< const WireHit *, const recob::Hit * > HitMap_t
 

Private Member Functions

void produce (art::Event &evt) override
 
void beginJob () override
 
void AddNeighbours (const std::vector< SpaceCharge * > &spaceCharges) const
 
void BuildSystem (const std::vector< HitTriplet > &triplets, std::vector< CollectionWireHit * > &cwires, std::vector< InductionWireHit * > &iwires, std::vector< SpaceCharge * > &orphanSCs, bool incNei, HitMap_t &hitmap) const
 
void Minimize (const std::vector< CollectionWireHit * > &cwires, const std::vector< SpaceCharge * > &orphanSCs, double alpha, int maxiterations)
 
bool AddSpacePoint (const SpaceCharge &sc, int id, recob::ChargedSpacePointCollectionCreator &points) const
 return whether the point was inserted (only happens when it has charge) More...
 
void FillSystemToSpacePoints (const std::vector< CollectionWireHit * > &cwires, const std::vector< SpaceCharge * > &orphanSCs, recob::ChargedSpacePointCollectionCreator &pts) const
 
void FillSystemToSpacePointsAndAssns (const std::vector< art::Ptr< recob::Hit >> &hitlist, const std::vector< CollectionWireHit * > &cwires, const std::vector< SpaceCharge * > &orphanSCs, const HitMap_t &hitmap, recob::ChargedSpacePointCollectionCreator &points, art::Assns< recob::SpacePoint, recob::Hit > &assn) const
 

Private Attributes

std::string fHitLabel
 
bool fFit
 
bool fAllowBadInductionHit
 
bool fAllowBadCollectionHit
 
double fAlpha
 
double fDistThresh
 
double fDistThreshDrift
 
int fMaxIterationsNoReg
 
int fMaxIterationsReg
 
double fXHitOffset
 
const geo::GeometryCoregeom
 
std::unique_ptr< reco3d::IHitReaderfHitReader
 Expt specific tool for reading hits. More...
 
unsigned int fMinNHits
 

Detailed Description

Definition at line 49 of file SpacePointSolver_module.cc.

Member Typedef Documentation

typedef std::map<const WireHit*, const recob::Hit*> reco3d::SpacePointSolver::HitMap_t
private

Definition at line 59 of file SpacePointSolver_module.cc.

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

reco3d::SpacePointSolver::SpacePointSolver ( const fhicl::ParameterSet pset)
explicit

Definition at line 113 of file SpacePointSolver_module.cc.

References recob::ChargedSpacePointCollectionCreator::produces().

114  : EDProducer{pset}
115  , fHitLabel(pset.get<std::string>("HitLabel"))
116  , fFit(pset.get<bool>("Fit"))
117  , fAllowBadInductionHit(pset.get<bool>("AllowBadInductionHit"))
118  , fAllowBadCollectionHit(pset.get<bool>("AllowBadCollectionHit"))
119  , fAlpha(pset.get<double>("Alpha"))
120  , fDistThresh(pset.get<double>("WireIntersectThreshold"))
121  , fDistThreshDrift(pset.get<double>("WireIntersectThresholdDriftDir"))
122  , fMaxIterationsNoReg(pset.get<int>("MaxIterationsNoReg"))
123  , fMaxIterationsReg(pset.get<int>("MaxIterationsReg"))
124  , fXHitOffset(pset.get<double>("XHitOffset"))
125  , fMinNHits(pset.get<unsigned int>("MinNHits"))
126  {
128  if (fFit) {
130  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
132  }
133 
134  fHitReader = art::make_tool<reco3d::IHitReader>(pset.get<fhicl::ParameterSet>("HitReaderTool"));
135  }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
static void produces(art::ProducesCollector &producesCollector, std::string const &instanceName={})
Declares the data products being produced.
std::unique_ptr< reco3d::IHitReader > fHitReader
Expt specific tool for reading hits.
T get(std::string const &key) const
Definition: ParameterSet.h:314
ProducesCollector & producesCollector() noexcept

Member Function Documentation

void reco3d::SpacePointSolver::AddNeighbours ( const std::vector< SpaceCharge * > &  spaceCharges) const
private

Definition at line 144 of file SpacePointSolver_module.cc.

References Neighbour::fCoupling, SpaceCharge::fPred, Neighbour::fSC, SpaceCharge::fX, SpaceCharge::fY, SpaceCharge::fZ, reco3d::InductionWireWithXPos::operator<(), sc, x, y, and z.

145  {
146  static const double kCritDist = 5;
147 
148  // Could use a QuadTree or VPTree etc, but seems like overkill
149  class IntCoord {
150  public:
151  IntCoord(const SpaceCharge& sc)
152  : fX(sc.fX / kCritDist), fY(sc.fY / kCritDist), fZ(sc.fZ / kCritDist)
153  {}
154 
155  bool operator<(const IntCoord& i) const
156  {
157  return std::make_tuple(fX, fY, fZ) < std::make_tuple(i.fX, i.fY, i.fZ);
158  }
159 
160  std::vector<IntCoord> Neighbours() const
161  {
162  std::vector<IntCoord> ret;
163  for (int dx = -1; dx <= +1; ++dx) {
164  for (int dy = -1; dy <= +1; ++dy) {
165  for (int dz = -1; dz <= +1; ++dz) {
166  ret.push_back(IntCoord(fX + dx, fY + dy, fZ + dz));
167  }
168  }
169  }
170  return ret;
171  }
172 
173  protected:
174  IntCoord(int x, int y, int z) : fX(x), fY(y), fZ(z) {}
175 
176  int fX, fY, fZ;
177  };
178 
179  std::map<IntCoord, std::vector<SpaceCharge*>> scMap;
180  for (SpaceCharge* sc : spaceCharges) {
181  scMap[IntCoord(*sc)].push_back(sc);
182  }
183 
184  std::cout << "Neighbour search..." << std::endl;
185 
186  // Now that we know all the space charges, can go through and assign neighbours
187 
188  int Ntests = 0;
189  int Nnei = 0;
190  for (SpaceCharge* sc1 : spaceCharges) {
191  IntCoord ic(*sc1);
192  for (IntCoord icn : ic.Neighbours()) {
193  for (SpaceCharge* sc2 : scMap[icn]) {
194 
195  ++Ntests;
196 
197  if (sc1 == sc2) continue;
198  double dist2 =
199  cet::sum_of_squares(sc1->fX - sc2->fX, sc1->fY - sc2->fY, sc1->fZ - sc2->fZ);
200 
201  if (dist2 > cet::square(kCritDist)) continue;
202 
203  if (dist2 == 0) {
204  std::cout << "ZERO DISTANCE SOMEHOW?" << std::endl;
205  std::cout << sc1->fCWire << " " << sc1->fWire1 << " " << sc1->fWire2 << std::endl;
206  std::cout << sc2->fCWire << " " << sc2->fWire1 << " " << sc2->fWire2 << std::endl;
207  std::cout << dist2 << " " << sc1->fX << " " << sc2->fX << " " << sc1->fY << " "
208  << sc2->fY << " " << sc1->fZ << " " << sc2->fZ << std::endl;
209  continue;
210  dist2 = cet::square(kCritDist);
211  }
212 
213  ++Nnei;
214 
215  // This is a pretty random guess
216  const double coupling = exp(-sqrt(dist2) / 2);
217  sc1->fNeighbours.emplace_back(sc2, coupling);
218 
219  if (isnan(1 / sqrt(dist2)) || isinf(1 / sqrt(dist2))) {
220  std::cout << dist2 << " " << sc1->fX << " " << sc2->fX << " " << sc1->fY << " "
221  << sc2->fY << " " << sc1->fZ << " " << sc2->fZ << std::endl;
222  abort();
223  }
224  } // end for sc2
225  } // end for icn
226 
227  // The neighbours lists use the most memory, so be careful to trim
228  sc1->fNeighbours.shrink_to_fit();
229  } // end for sc1
230 
231  for (SpaceCharge* sc : spaceCharges) {
232  for (Neighbour& nei : sc->fNeighbours) {
233  sc->fNeiPotential += nei.fCoupling * nei.fSC->fPred;
234  }
235  }
236 
237  std::cout << Ntests << " tests to find " << Nnei << " neighbours" << std::endl;
238  }
Float_t x
Definition: compare.C:6
constexpr bool operator<(CryostatID const &a, CryostatID const &b)
Order cryostats with increasing ID.
Definition: geo_types.h:692
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
double fCoupling
Definition: Solver.h:34
Float_t sc
Definition: plot.C:23
double fPred
Definition: Solver.h:57
SpaceCharge * fSC
Definition: Solver.h:33
bool reco3d::SpacePointSolver::AddSpacePoint ( const SpaceCharge sc,
int  id,
recob::ChargedSpacePointCollectionCreator points 
) const
private

return whether the point was inserted (only happens when it has charge)

Definition at line 331 of file SpacePointSolver_module.cc.

References recob::ChargedSpacePointCollectionCreator::add(), SpaceCharge::fPred, SpaceCharge::fX, SpaceCharge::fY, and SpaceCharge::fZ.

334  {
335  static const double err[6] = {
336  0,
337  };
338 
339  const float charge = sc.fPred;
340  if (charge == 0) return false;
341 
342  const double xyz[3] = {sc.fX, sc.fY, sc.fZ};
343  points.add({xyz, err, 0.0, id}, charge);
344 
345  return true;
346  }
double fZ
Definition: Solver.h:51
double fY
Definition: Solver.h:51
double fX
Definition: Solver.h:51
double fPred
Definition: Solver.h:57
void add(recob::SpacePoint const &spacePoint, recob::PointCharge const &charge)
Inserts the specified space point and associated data into the collection.
void reco3d::SpacePointSolver::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 138 of file SpacePointSolver_module.cc.

void reco3d::SpacePointSolver::BuildSystem ( const std::vector< HitTriplet > &  triplets,
std::vector< CollectionWireHit * > &  cwires,
std::vector< InductionWireHit * > &  iwires,
std::vector< SpaceCharge * > &  orphanSCs,
bool  incNei,
HitMap_t hitmap 
) const
private

Definition at line 241 of file SpacePointSolver_module.cc.

References reco3d::InductionWireWithXPos::iwire, and sc.

247  {
248  std::set<const recob::Hit*> ihits;
249  std::set<const recob::Hit*> chits;
250  for (const HitTriplet& trip : triplets) {
251  if (trip.x) chits.insert(trip.x);
252  if (trip.u) ihits.insert(trip.u);
253  if (trip.v) ihits.insert(trip.v);
254  }
255 
256  std::map<const recob::Hit*, InductionWireHit*> inductionMap;
257  for (const recob::Hit* hit : ihits) {
258  InductionWireHit* iwire = new InductionWireHit(hit->Channel(), hit->Integral());
259  inductionMap[hit] = iwire;
260  iwires.emplace_back(iwire);
261  hitmap[iwire] = hit;
262  }
263 
264  std::map<const recob::Hit*, std::vector<SpaceCharge*>> collectionMap;
265  std::map<const recob::Hit*, std::vector<SpaceCharge*>> collectionMapBad;
266 
267  std::set<InductionWireHit*> satisfiedInduction;
268 
269  for (const HitTriplet& trip : triplets) {
270  // Don't have a cwire object yet, set it later
271  SpaceCharge* sc = new SpaceCharge(
272  trip.pt.x, trip.pt.y, trip.pt.z, 0, inductionMap[trip.u], inductionMap[trip.v]);
273 
274  if (trip.u && trip.v) {
275  collectionMap[trip.x].push_back(sc);
276  if (trip.x) {
277  satisfiedInduction.insert(inductionMap[trip.u]);
278  satisfiedInduction.insert(inductionMap[trip.v]);
279  }
280  }
281  else {
282  collectionMapBad[trip.x].push_back(sc);
283  }
284  }
285 
286  std::vector<SpaceCharge*> spaceCharges;
287 
288  for (const recob::Hit* hit : chits) {
289  // Find the space charges associated with this hit
290  std::vector<SpaceCharge*>& scs = collectionMap[hit];
291  if (scs.empty()) {
292  // If there are no full triplets try the triplets with one bad channel
293  scs = collectionMapBad[hit];
294  }
295  else {
296  // If there were good triplets, delete the bad hit ones
297  for (SpaceCharge* sc : collectionMapBad[hit])
298  delete sc;
299  }
300  // Still no space points, don't bother making a wire
301  if (scs.empty()) continue;
302 
303  CollectionWireHit* cwire = new CollectionWireHit(hit->Channel(), hit->Integral(), scs);
304  hitmap[cwire] = hit;
305  cwires.push_back(cwire);
306  spaceCharges.insert(spaceCharges.end(), scs.begin(), scs.end());
307  for (SpaceCharge* sc : scs)
308  sc->fCWire = cwire;
309  } // end for hit
310 
311  // Space charges whose collection wire is bad, which we have no other way of
312  // addressing.
313  for (SpaceCharge* sc : collectionMap[0]) {
314  // Only count orphans where an induction wire has no other explanation
315  if (satisfiedInduction.count(sc->fWire1) == 0 || satisfiedInduction.count(sc->fWire2) == 0) {
316  orphanSCs.push_back(sc);
317  }
318  else {
319  delete sc;
320  }
321  }
322  spaceCharges.insert(spaceCharges.end(), orphanSCs.begin(), orphanSCs.end());
323 
324  std::cout << cwires.size() << " collection wire objects" << std::endl;
325  std::cout << spaceCharges.size() << " potential space points" << std::endl;
326 
327  if (incNei) AddNeighbours(spaceCharges);
328  }
void AddNeighbours(const std::vector< SpaceCharge * > &spaceCharges) const
InductionWireHit * fWire2
Definition: Solver.h:53
InductionWireHit * fWire1
Definition: Solver.h:53
Detector simulation of raw signals on wires.
CollectionWireHit * fCWire
Definition: Solver.h:52
Float_t sc
Definition: plot.C:23
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
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
void reco3d::SpacePointSolver::FillSystemToSpacePoints ( const std::vector< CollectionWireHit * > &  cwires,
const std::vector< SpaceCharge * > &  orphanSCs,
recob::ChargedSpacePointCollectionCreator pts 
) const
private

Definition at line 349 of file SpacePointSolver_module.cc.

References sc.

353  {
354  int iPoint = 0;
355  for (const CollectionWireHit* cwire : cwires) {
356  for (const SpaceCharge* sc : cwire->fCrossings) {
357  AddSpacePoint(*sc, iPoint++, points);
358  } // for sc
359  } // for cwire
360 
361  for (const SpaceCharge* sc : orphanSCs)
362  AddSpacePoint(*sc, iPoint++, points);
363  }
bool AddSpacePoint(const SpaceCharge &sc, int id, recob::ChargedSpacePointCollectionCreator &points) const
return whether the point was inserted (only happens when it has charge)
Float_t sc
Definition: plot.C:23
void reco3d::SpacePointSolver::FillSystemToSpacePointsAndAssns ( const std::vector< art::Ptr< recob::Hit >> &  hitlist,
const std::vector< CollectionWireHit * > &  cwires,
const std::vector< SpaceCharge * > &  orphanSCs,
const HitMap_t hitmap,
recob::ChargedSpacePointCollectionCreator points,
art::Assns< recob::SpacePoint, recob::Hit > &  assn 
) const
private

Definition at line 366 of file SpacePointSolver_module.cc.

References art::Assns< L, R, D >::addSingle(), SpaceCharge::fCWire, SpaceCharge::fWire1, SpaceCharge::fWire2, recob::ChargedSpacePointCollectionCreator::lastSpacePointPtr(), and sc.

373  {
374  std::map<const recob::Hit*, art::Ptr<recob::Hit>> ptrmap;
375  for (art::Ptr<recob::Hit> hit : hitlist)
376  ptrmap[hit.get()] = hit;
377 
378  std::vector<const SpaceCharge*> scs;
379  for (const SpaceCharge* sc : orphanSCs)
380  scs.push_back(sc);
381  for (const CollectionWireHit* cwire : cwires)
382  for (const SpaceCharge* sc : cwire->fCrossings)
383  scs.push_back(sc);
384 
385  int iPoint = 0;
386 
387  for (const SpaceCharge* sc : scs) {
388  if (!AddSpacePoint(*sc, iPoint++, points)) continue;
389  const auto& spsPtr = points.lastSpacePointPtr();
390 
391  if (sc->fCWire) { assn.addSingle(spsPtr, ptrmap[hitmap.at(sc->fCWire)]); }
392  if (sc->fWire1) { assn.addSingle(spsPtr, ptrmap[hitmap.at(sc->fWire1)]); }
393  if (sc->fWire2) { assn.addSingle(spsPtr, ptrmap[hitmap.at(sc->fWire2)]); }
394  }
395  }
art::Ptr< recob::SpacePoint > lastSpacePointPtr() const
Returns an art pointer to the last inserted space point (no check!).
InductionWireHit * fWire2
Definition: Solver.h:53
bool AddSpacePoint(const SpaceCharge &sc, int id, recob::ChargedSpacePointCollectionCreator &points) const
return whether the point was inserted (only happens when it has charge)
InductionWireHit * fWire1
Definition: Solver.h:53
Detector simulation of raw signals on wires.
CollectionWireHit * fCWire
Definition: Solver.h:52
Float_t sc
Definition: plot.C:23
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:549
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 &)
void reco3d::SpacePointSolver::Minimize ( const std::vector< CollectionWireHit * > &  cwires,
const std::vector< SpaceCharge * > &  orphanSCs,
double  alpha,
int  maxiterations 
)
private

Definition at line 398 of file SpacePointSolver_module.cc.

References e, Iterate(), and Metric().

402  {
403  double prevMetric = Metric(cwires, alpha);
404  std::cout << "Begin: " << prevMetric << std::endl;
405  for (int i = 0; i < maxiterations; ++i) {
406  Iterate(cwires, orphanSCs, alpha);
407  const double metric = Metric(cwires, alpha);
408  std::cout << i << " " << metric << std::endl;
409  if (metric > prevMetric) {
410  std::cout << "Warning: metric increased" << std::endl;
411  return;
412  }
413  if (fabs(metric - prevMetric) < 1e-3 * fabs(prevMetric)) return;
414  prevMetric = metric;
415  }
416  }
void Iterate(CollectionWireHit *cwire, double alpha)
Definition: Solver.cxx:260
double Metric(double q, double p)
Definition: Solver.cxx:70
Float_t e
Definition: plot.C:35
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 reco3d::SpacePointSolver::produce ( art::Event evt)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 419 of file SpacePointSolver_module.cc.

References art::fill_ptr_vector(), recob::ChargedSpacePointCollectionCreator::forPtrs(), art::ProductRetriever::getByLabel(), hits(), geo::kCollection, geo::kU, geo::kV, geo::kZ, art::Event::put(), geo::GeometryCore::SignalType(), reco3d::TripletFinder::Triplets(), and geo::GeometryCore::View().

420  {
422  std::vector<art::Ptr<recob::Hit>> hitlist;
423  if (evt.getByLabel(fHitLabel, hits)) art::fill_ptr_vector(hitlist, hits);
424 
425  auto spcol_pre = recob::ChargedSpacePointCollectionCreator::forPtrs(evt, "pre");
426  auto spcol_noreg = recob::ChargedSpacePointCollectionCreator::forPtrs(evt, "noreg");
428  auto assns = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
429 
430  // Skip very small events
431  if (hits->size() < fMinNHits) {
432  spcol_pre.put();
433  if (fFit) {
434  spcol.put();
435  evt.put(std::move(assns));
436  spcol_noreg.put();
437  }
438  return;
439  }
440 
442 
443  std::vector<art::Ptr<recob::Hit>> xhits, uhits, vhits;
444  bool is2view = fHitReader->readHits(hitlist, xhits, uhits, vhits);
445 
446  std::vector<raw::ChannelID_t> xbadchans, ubadchans, vbadchans;
448  for (raw::ChannelID_t cid :
449  art::ServiceHandle<lariov::ChannelStatusService const>()->GetProvider().BadChannels()) {
450  if (geom->SignalType(cid) == geo::kCollection) {
451  if (fAllowBadCollectionHit && geom->View(cid) == geo::kZ) { xbadchans.push_back(cid); }
452  }
453  else {
454  if (fAllowBadInductionHit) {
455  if (geom->View(cid) == geo::kU) ubadchans.push_back(cid);
456  if (geom->View(cid) == geo::kV) vbadchans.push_back(cid);
457  }
458  }
459  }
460  }
461  std::cout << xbadchans.size() << " X, " << ubadchans.size() << " U, " << vbadchans.size()
462  << " V bad channels" << std::endl;
463 
464  std::vector<CollectionWireHit*> cwires;
465  // So we can find them all to free the memory
466  std::vector<InductionWireHit*> iwires;
467  // Nodes with a bad collection wire that we otherwise can't address
468  std::vector<SpaceCharge*> orphanSCs;
469 
470  auto const detProp =
472 
473  HitMap_t hitmap;
474  if (is2view) {
475  std::cout << "Finding 2-view coincidences..." << std::endl;
476  TripletFinder tf(detProp,
477  xhits,
478  uhits,
479  {},
480  xbadchans,
481  ubadchans,
482  {},
483  fDistThresh,
485  fXHitOffset);
486  BuildSystem(tf.TripletsTwoView(), cwires, iwires, orphanSCs, fAlpha != 0, hitmap);
487  }
488  else {
489  std::cout << "Finding XUV coincidences..." << std::endl;
490  TripletFinder tf(detProp,
491  xhits,
492  uhits,
493  vhits,
494  xbadchans,
495  ubadchans,
496  vbadchans,
497  fDistThresh,
498  fDistThreshDrift,
499  fXHitOffset);
500  BuildSystem(tf.Triplets(), cwires, iwires, orphanSCs, fAlpha != 0, hitmap);
501  }
502 
503  FillSystemToSpacePoints(cwires, orphanSCs, spcol_pre);
504  spcol_pre.put();
505 
506  if (fFit) {
507  std::cout << "Iterating with no regularization..." << std::endl;
508  Minimize(cwires, orphanSCs, 0, fMaxIterationsNoReg);
509 
510  FillSystemToSpacePoints(cwires, orphanSCs, spcol_noreg);
511  spcol_noreg.put();
512 
513  std::cout << "Now with regularization..." << std::endl;
514  Minimize(cwires, orphanSCs, fAlpha, fMaxIterationsReg);
515 
516  FillSystemToSpacePointsAndAssns(hitlist, cwires, orphanSCs, hitmap, spcol, *assns);
517  spcol.put();
518  evt.put(std::move(assns));
519  } // end if fFit
520 
521  for (InductionWireHit* i : iwires)
522  delete i;
523  for (CollectionWireHit* c : cwires)
524  delete c;
525  for (SpaceCharge* s : orphanSCs)
526  delete s;
527  }
const geo::GeometryCore * geom
Planes which measure V.
Definition: geo_types.h:136
void Minimize(const std::vector< CollectionWireHit * > &cwires, const std::vector< SpaceCharge * > &orphanSCs, double alpha, int maxiterations)
std::unique_ptr< reco3d::IHitReader > fHitReader
Expt specific tool for reading hits.
Planes which measure Z direction.
Definition: geo_types.h:138
Definition: tf_graph.h:25
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
Planes which measure U.
Definition: geo_types.h:135
void hits()
Definition: readHits.C:15
std::map< const WireHit *, const recob::Hit * > HitMap_t
void FillSystemToSpacePointsAndAssns(const std::vector< art::Ptr< recob::Hit >> &hitlist, const std::vector< CollectionWireHit * > &cwires, const std::vector< SpaceCharge * > &orphanSCs, const HitMap_t &hitmap, recob::ChargedSpacePointCollectionCreator &points, art::Assns< recob::SpacePoint, recob::Hit > &assn) const
static ChargedSpacePointCollectionCreator forPtrs(art::Event &event, std::string const &instanceName={})
Static function binding a new object to a specific art event.
void BuildSystem(const std::vector< HitTriplet > &triplets, std::vector< CollectionWireHit * > &cwires, std::vector< InductionWireHit * > &iwires, std::vector< SpaceCharge * > &orphanSCs, bool incNei, HitMap_t &hitmap) const
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
View_t View(PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
void FillSystemToSpacePoints(const std::vector< CollectionWireHit * > &cwires, const std::vector< SpaceCharge * > &orphanSCs, recob::ChargedSpacePointCollectionCreator &pts) const
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:306
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

bool reco3d::SpacePointSolver::fAllowBadCollectionHit
private

Definition at line 92 of file SpacePointSolver_module.cc.

bool reco3d::SpacePointSolver::fAllowBadInductionHit
private

Definition at line 92 of file SpacePointSolver_module.cc.

double reco3d::SpacePointSolver::fAlpha
private

Definition at line 94 of file SpacePointSolver_module.cc.

double reco3d::SpacePointSolver::fDistThresh
private

Definition at line 96 of file SpacePointSolver_module.cc.

double reco3d::SpacePointSolver::fDistThreshDrift
private

Definition at line 97 of file SpacePointSolver_module.cc.

bool reco3d::SpacePointSolver::fFit
private

Definition at line 91 of file SpacePointSolver_module.cc.

std::string reco3d::SpacePointSolver::fHitLabel
private

Definition at line 89 of file SpacePointSolver_module.cc.

std::unique_ptr<reco3d::IHitReader> reco3d::SpacePointSolver::fHitReader
private

Expt specific tool for reading hits.

Definition at line 105 of file SpacePointSolver_module.cc.

int reco3d::SpacePointSolver::fMaxIterationsNoReg
private

Definition at line 99 of file SpacePointSolver_module.cc.

int reco3d::SpacePointSolver::fMaxIterationsReg
private

Definition at line 100 of file SpacePointSolver_module.cc.

unsigned int reco3d::SpacePointSolver::fMinNHits
private

Definition at line 107 of file SpacePointSolver_module.cc.

double reco3d::SpacePointSolver::fXHitOffset
private

Definition at line 102 of file SpacePointSolver_module.cc.

const geo::GeometryCore* reco3d::SpacePointSolver::geom
private

Definition at line 104 of file SpacePointSolver_module.cc.


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