LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
reco3d::SpacePointSolver Class Reference
Inheritance diagram for reco3d::SpacePointSolver:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 SpacePointSolver (const fhicl::ParameterSet &pset)
 
virtual ~SpacePointSolver ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void endJob ()
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Types

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

Protected Member Functions

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
 
CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Protected Attributes

std::string fHitLabel
 
bool fFit
 
bool fAllowBadInductionHit
 
bool fAllowBadCollectionHit
 
double fAlpha
 
double fDistThresh
 
double fDistThreshDrift
 
int fMaxIterationsNoReg
 
int fMaxIterationsReg
 
double fXHitOffset
 
const detinfo::DetectorPropertiesdetprop
 
const geo::GeometryCoregeom
 

Detailed Description

Definition at line 63 of file SpacePointSolver_module.cc.

Member Typedef Documentation

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

Definition at line 77 of file SpacePointSolver_module.cc.

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

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

Definition at line 129 of file SpacePointSolver_module.cc.

References recob::ChargedSpacePointCollectionCreator::produces().

130  : fHitLabel(pset.get<std::string>("HitLabel")),
131  fFit(pset.get<bool>("Fit")),
132  fAllowBadInductionHit(pset.get<bool>("AllowBadInductionHit")),
133  fAllowBadCollectionHit(pset.get<bool>("AllowBadCollectionHit")),
134  fAlpha(pset.get<double>("Alpha")),
135  fDistThresh(pset.get<double>("WireIntersectThreshold")),
136  fDistThreshDrift(pset.get<double>("WireIntersectThresholdDriftDir")),
137  fMaxIterationsNoReg(pset.get<int>("MaxIterationsNoReg")),
138  fMaxIterationsReg(pset.get<int>("MaxIterationsReg")),
139  fXHitOffset(pset.get<double>("XHitOffset"))
140 {
142  if(fFit){
144  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
146  }
147 }
static void produces(art::ProducerBase &producer, std::string const &instanceName={})
Declares the data products being produced.
T get(std::string const &key) const
Definition: ParameterSet.h:231
reco3d::SpacePointSolver::~SpacePointSolver ( )
virtual

Definition at line 150 of file SpacePointSolver_module.cc.

151 {
152 }

Member Function Documentation

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

Definition at line 168 of file SpacePointSolver_module.cc.

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

Referenced by endJob().

169 {
170  static const double kCritDist = 5;
171 
172  // Could use a QuadTree or VPTree etc, but seems like overkill
173  class IntCoord
174  {
175  public:
176  IntCoord(const SpaceCharge& sc)
177  : fX(sc.fX/kCritDist),
178  fY(sc.fY/kCritDist),
179  fZ(sc.fZ/kCritDist)
180  {
181  }
182 
183  bool operator<(const IntCoord& i) const
184  {
185  return std::make_tuple(fX, fY, fZ) < std::make_tuple(i.fX, i.fY, i.fZ);
186  }
187 
188  std::vector<IntCoord> Neighbours() const
189  {
190  std::vector<IntCoord> ret;
191  for(int dx = -1; dx <= +1; ++dx){
192  for(int dy = -1; dy <= +1; ++dy){
193  for(int dz = -1; dz <= +1; ++dz){
194  ret.push_back(IntCoord(fX+dx, fY+dy, fZ+dz));
195  }
196  }
197  }
198  return ret;
199  }
200  protected:
201  IntCoord(int x, int y, int z) : fX(x), fY(y), fZ(z) {}
202 
203  int fX, fY, fZ;
204  };
205 
206  std::map<IntCoord, std::vector<SpaceCharge*>> scMap;
207  for(SpaceCharge* sc: spaceCharges){
208  scMap[IntCoord(*sc)].push_back(sc);
209  }
210 
211  std::cout << "Neighbour search..." << std::endl;
212 
213  // Now that we know all the space charges, can go through and assign neighbours
214 
215  int Ntests = 0;
216  int Nnei = 0;
217  for(SpaceCharge* sc1: spaceCharges){
218  IntCoord ic(*sc1);
219  for(IntCoord icn: ic.Neighbours()){
220  for(SpaceCharge* sc2: scMap[icn]){
221 
222  ++Ntests;
223 
224  if(sc1 == sc2) continue;
225  /*const*/ double dist2 = sqr(sc1->fX-sc2->fX) + sqr(sc1->fY-sc2->fY) + sqr(sc1->fZ-sc2->fZ);
226 
227  if(dist2 > sqr(kCritDist)) continue;
228 
229  if(dist2 == 0){
230  std::cout << "ZERO DISTANCE SOMEHOW?" << std::endl;
231  std::cout << sc1->fCWire << " " << sc1->fWire1 << " " << sc1->fWire2 << std::endl;
232  std::cout << sc2->fCWire << " " << sc2->fWire1 << " " << sc2->fWire2 << std::endl;
233  std::cout << dist2 << " " << sc1->fX << " " << sc2->fX << " " << sc1->fY << " " << sc2->fY << " " << sc1->fZ << " " << sc2->fZ << std::endl;
234  continue;
235  dist2 = sqr(kCritDist);
236  }
237 
238  ++Nnei;
239 
240  // This is a pretty random guess
241  const double coupling = exp(-sqrt(dist2)/2);
242  sc1->fNeighbours.emplace_back(sc2, coupling);
243 
244  if(isnan(1/sqrt(dist2)) || isinf(1/sqrt(dist2))){
245  std::cout << dist2 << " " << sc1->fX << " " << sc2->fX << " " << sc1->fY << " " << sc2->fY << " " << sc1->fZ << " " << sc2->fZ << std::endl;
246  abort();
247  }
248  } // end for sc2
249  } // end for icn
250 
251  // The neighbours lists use the most memory, so be careful to trim
252  sc1->fNeighbours.shrink_to_fit();
253  } // end for sc1
254 
255  for(SpaceCharge* sc: spaceCharges){
256  for(Neighbour& nei: sc->fNeighbours){
257  sc->fNeiPotential += nei.fCoupling * nei.fSC->fPred;
258  }
259  }
260 
261  std::cout << Ntests << " tests to find " << Nnei << " neighbours" << std::endl;
262 }
Float_t x
Definition: compare.C:6
bool operator<(CryostatID const &a, CryostatID const &b)
Order cryostats with increasing ID.
Definition: geo_types.h:413
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:279
double fCoupling
Definition: Solver.h:37
T sqr(T x)
double fPred
Definition: Solver.h:58
SpaceCharge * fSC
Definition: Solver.h:36
bool reco3d::SpacePointSolver::AddSpacePoint ( const SpaceCharge sc,
int  id,
recob::ChargedSpacePointCollectionCreator points 
) const
protected

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

Definition at line 360 of file SpacePointSolver_module.cc.

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

Referenced by BuildSystem().

363 {
364  static const double err[6] = {0,};
365 
366  const float charge = sc.fPred;
367  if(charge == 0) return false;
368 
369  const double xyz[3] = {sc.fX, sc.fY, sc.fZ};
370  points.add({ xyz, err, 0.0, id }, charge);
371 
372  return true;
373 }
double fZ
Definition: Solver.h:52
double fY
Definition: Solver.h:52
double fX
Definition: Solver.h:52
double fPred
Definition: Solver.h:58
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 ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 155 of file SpacePointSolver_module.cc.

156 {
158  geom = art::ServiceHandle<geo::Geometry>()->provider();
159 }
const geo::GeometryCore * geom
const detinfo::DetectorProperties * detprop
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
protected

Definition at line 266 of file SpacePointSolver_module.cc.

References AddSpacePoint(), and reco3d::InductionWireWithXPos::iwire.

Referenced by AddNeighbours().

272 {
273  std::set<const recob::Hit*> ihits;
274  std::set<const recob::Hit*> chits;
275  for(const HitTriplet& trip: triplets){
276  if(trip.x) chits.insert(trip.x);
277  if(trip.u) ihits.insert(trip.u);
278  if(trip.v) ihits.insert(trip.v);
279  }
280 
281  std::map<const recob::Hit*, InductionWireHit*> inductionMap;
282  for(const recob::Hit* hit: ihits){
283  InductionWireHit* iwire = new InductionWireHit(hit->Channel(),
284  hit->Integral());
285  inductionMap[hit] = iwire;
286  iwires.emplace_back(iwire);
287  hitmap[iwire] = hit;
288  }
289 
290  std::map<const recob::Hit*, std::vector<SpaceCharge*>> collectionMap;
291  std::map<const recob::Hit*, std::vector<SpaceCharge*>> collectionMapBad;
292 
293  std::set<InductionWireHit*> satisfiedInduction;
294 
295  for(const HitTriplet& trip: triplets){
296  // Don't have a cwire object yet, set it later
297  SpaceCharge* sc = new SpaceCharge(trip.pt.x,
298  trip.pt.y,
299  trip.pt.z,
300  0,
301  inductionMap[trip.u],
302  inductionMap[trip.v]);
303 
304  if(trip.u && trip.v){
305  collectionMap[trip.x].push_back(sc);
306  if(trip.x){
307  satisfiedInduction.insert(inductionMap[trip.u]);
308  satisfiedInduction.insert(inductionMap[trip.v]);
309  }
310  }
311  else{
312  collectionMapBad[trip.x].push_back(sc);
313  }
314  }
315 
316  std::vector<SpaceCharge*> spaceCharges;
317 
318  for(const recob::Hit* hit: chits){
319  // Find the space charges associated with this hit
320  std::vector<SpaceCharge*>& scs = collectionMap[hit];
321  if(scs.empty()){
322  // If there are no full triplets try the triplets with one bad channel
323  scs = collectionMapBad[hit];
324  }
325  else{
326  // If there were good triplets, delete the bad hit ones
327  for(SpaceCharge* sc: collectionMapBad[hit]) delete sc;
328  }
329  // Still no space points, don't bother making a wire
330  if(scs.empty()) continue;
331 
332  CollectionWireHit* cwire = new CollectionWireHit(hit->Channel(),
333  hit->Integral(),
334  scs);
335  hitmap[cwire] = hit;
336  cwires.push_back(cwire);
337  spaceCharges.insert(spaceCharges.end(), scs.begin(), scs.end());
338  for(SpaceCharge* sc: scs) sc->fCWire = cwire;
339  } // end for hit
340 
341  // Space charges whose collection wire is bad, which we have no other way of
342  // addressing.
343  for(SpaceCharge* sc: collectionMap[0]){
344  // Only count orphans where an induction wire has no other explanation
345  if(satisfiedInduction.count(sc->fWire1) == 0 ||
346  satisfiedInduction.count(sc->fWire2) == 0){
347  orphanSCs.push_back(sc);
348  }
349  }
350  spaceCharges.insert(spaceCharges.end(), orphanSCs.begin(), orphanSCs.end());
351 
352  std::cout << cwires.size() << " collection wire objects" << std::endl;
353  std::cout << spaceCharges.size() << " potential space points" << std::endl;
354 
355  if(incNei) AddNeighbours(spaceCharges);
356 }
void AddNeighbours(const std::vector< SpaceCharge * > &spaceCharges) const
InductionWireHit * fWire2
Definition: Solver.h:54
InductionWireHit * fWire1
Definition: Solver.h:54
Detector simulation of raw signals on wires.
CollectionWireHit * fCWire
Definition: Solver.h:53
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
void reco3d::SpacePointSolver::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 162 of file SpacePointSolver_module.cc.

References AddNeighbours().

163 {
164 }
void reco3d::SpacePointSolver::FillSystemToSpacePoints ( const std::vector< CollectionWireHit * > &  cwires,
const std::vector< SpaceCharge * > &  orphanSCs,
recob::ChargedSpacePointCollectionCreator pts 
) const
protected

Definition at line 377 of file SpacePointSolver_module.cc.

References FillSystemToSpacePointsAndAssns().

Referenced by AddSpacePoint().

380 {
381  int iPoint = 0;
382  for(const CollectionWireHit* cwire: cwires){
383  for(const SpaceCharge* sc: cwire->fCrossings){
384  AddSpacePoint(*sc, iPoint++, points);
385  } // for sc
386  } // for cwire
387 
388  for(const SpaceCharge* sc: orphanSCs) AddSpacePoint(*sc, iPoint++, points);
389 }
bool AddSpacePoint(const SpaceCharge &sc, int id, recob::ChargedSpacePointCollectionCreator &points) const
return whether the point was inserted (only happens when it has charge)
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
protected

Definition at line 394 of file SpacePointSolver_module.cc.

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

Referenced by FillSystemToSpacePoints().

400 {
401  std::map<const recob::Hit*, art::Ptr<recob::Hit>> ptrmap;
402  for(art::Ptr<recob::Hit> hit: hitlist) ptrmap[hit.get()] = hit;
403 
404  std::vector<const SpaceCharge*> scs;
405  for(const SpaceCharge* sc: orphanSCs) scs.push_back(sc);
406  for(const CollectionWireHit* cwire: cwires)
407  for(const SpaceCharge* sc: cwire->fCrossings)
408  scs.push_back(sc);
409 
410  int iPoint = 0;
411 
412  for(const SpaceCharge* sc: scs){
413  if(!AddSpacePoint(*sc, iPoint++, points)) continue;
414  const auto& spsPtr = points.lastSpacePointPtr();
415 
416  if(sc->fCWire){
417  assn.addSingle(spsPtr, ptrmap[hitmap.at(sc->fCWire)]);
418  }
419  if(sc->fWire1){
420  assn.addSingle(spsPtr, ptrmap[hitmap.at(sc->fWire1)]);
421  }
422  if(sc->fWire2){
423  assn.addSingle(spsPtr, ptrmap[hitmap.at(sc->fWire2)]);
424  }
425  }
426 }
art::Ptr< recob::SpacePoint > lastSpacePointPtr() const
Returns an art pointer to the last inserted space point (no check!).
InductionWireHit * fWire2
Definition: Solver.h:54
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:54
Detector simulation of raw signals on wires.
CollectionWireHit * fCWire
Definition: Solver.h:53
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:489
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void reco3d::SpacePointSolver::Minimize ( const std::vector< CollectionWireHit * > &  cwires,
const std::vector< SpaceCharge * > &  orphanSCs,
double  alpha,
int  maxiterations 
)
protected

Definition at line 429 of file SpacePointSolver_module.cc.

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

433 {
434  double prevMetric = Metric(cwires, alpha);
435  std::cout << "Begin: " << prevMetric << std::endl;
436  for(int i = 0; i < maxiterations; ++i){
437  Iterate(cwires, orphanSCs, alpha);
438  const double metric = Metric(cwires, alpha);
439  std::cout << i << " " << metric << std::endl;
440  if(metric > prevMetric){
441  std::cout << "Warning: metric increased" << std::endl;
442  return;
443  }
444  if(fabs(metric-prevMetric) < 1e-3*fabs(prevMetric)) return;
445  prevMetric = metric;
446  }
447 }
void Iterate(CollectionWireHit *cwire, double alpha)
Definition: Solver.cxx:263
double Metric(double q, double p)
Definition: Solver.cxx:71
Float_t e
Definition: plot.C:34
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void reco3d::SpacePointSolver::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 450 of file SpacePointSolver_module.cc.

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

451 {
453  std::vector<art::Ptr<recob::Hit> > hitlist;
454  if(evt.getByLabel(fHitLabel, hits))
455  art::fill_ptr_vector(hitlist, hits);
456 
457  recob::ChargedSpacePointCollectionCreator spcol_pre(evt, *this, "pre");
458  recob::ChargedSpacePointCollectionCreator spcol_noreg(evt, *this, "noreg");
460  auto assns = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
461 
462  // Skip very small events
463  if(hits->size() < 20){
464  spcol_pre.put();
465  if(fFit){
466  spcol.put();
467  evt.put(std::move(assns));
468  spcol_noreg.put();
469  }
470  return;
471  }
472 
474 
475  bool is2view = false;
476  std::vector<art::Ptr<recob::Hit>> xhits, uhits, vhits;
477  for(auto& hit: hitlist){
478  if(hit->Integral() < 0 || isnan(hit->Integral()) || isinf(hit->Integral())){
479  std::cout << "WARNING: bad recob::Hit::Integral() = "
480  << hit->Integral()
481  << ". Skipping." << std::endl;
482  continue;
483  }
484 
485  if(hit->SignalType() == geo::kCollection){
486  // For DualPhase, both view are collection. Arbitrarily map V to the main
487  // "X" view. For Argoneut and Lariat, collection=V is also the right
488  // convention.
489  if(hit->View() == geo::kZ){
490  xhits.push_back(hit);
491  }
492  if(hit->View() == geo::kV){
493  xhits.push_back(hit);
494  is2view = true;
495  }
496  if(hit->View() == geo::kU || hit->View() == geo::kY){
497  uhits.push_back(hit);
498  is2view = true;
499  }
500  }
501  else{
502  if(hit->View() == geo::kU) uhits.push_back(hit);
503  if(hit->View() == geo::kV) vhits.push_back(hit);
504  }
505  } // end for hit
506 
507  std::vector<raw::ChannelID_t> xbadchans, ubadchans, vbadchans;
509  for(raw::ChannelID_t cid: art::ServiceHandle<lariov::ChannelStatusService>()->GetProvider().BadChannels()){
510  if(geom->SignalType(cid) == geo::kCollection){
511  if(fAllowBadCollectionHit && geom->View(cid) == geo::kZ){
512  xbadchans.push_back(cid);
513  }
514  }
515  else{
517  if(geom->View(cid) == geo::kU) ubadchans.push_back(cid);
518  if(geom->View(cid) == geo::kV) vbadchans.push_back(cid);
519  }
520  }
521  }
522  }
523  std::cout << xbadchans.size() << " X, "
524  << ubadchans.size() << " U, "
525  << vbadchans.size() << " V bad channels" << std::endl;
526 
527 
528  std::vector<CollectionWireHit*> cwires;
529  // So we can find them all to free the memory
530  std::vector<InductionWireHit*> iwires;
531  // Nodes with a bad collection wire that we otherwise can't address
532  std::vector<SpaceCharge*> orphanSCs;
533 
534  HitMap_t hitmap;
535  if(is2view){
536  std::cout << "Finding 2-view coincidences..." << std::endl;
537  TripletFinder tf(xhits, uhits, {},
538  xbadchans, ubadchans, {},
540  BuildSystem(tf.TripletsTwoView(),
541  cwires, iwires, orphanSCs,
542  fAlpha != 0, hitmap);
543  }
544  else{
545  std::cout << "Finding XUV coincidences..." << std::endl;
546  TripletFinder tf(xhits, uhits, vhits,
547  xbadchans, ubadchans, vbadchans,
548  fDistThresh, fDistThreshDrift, fXHitOffset);
549  BuildSystem(tf.Triplets(),
550  cwires, iwires, orphanSCs,
551  fAlpha != 0, hitmap);
552  }
553 
554  FillSystemToSpacePoints(cwires, orphanSCs, spcol_pre);
555  spcol_pre.put();
556 
557  if(fFit){
558  std::cout << "Iterating with no regularization..." << std::endl;
559  Minimize(cwires, orphanSCs, 0, fMaxIterationsNoReg);
560 
561  FillSystemToSpacePoints(cwires, orphanSCs, spcol_noreg);
562  spcol_noreg.put();
563 
564  std::cout << "Now with regularization..." << std::endl;
565  Minimize(cwires, orphanSCs, fAlpha, fMaxIterationsReg);
566 
567  FillSystemToSpacePointsAndAssns(hitlist, cwires, orphanSCs, hitmap, spcol, *assns);
568  spcol.put();
569  evt.put(std::move(assns));
570  } // end if fFit
571 
572  for(InductionWireHit* i: iwires) delete i;
573  for(CollectionWireHit* c: cwires) delete c;
574  for(SpaceCharge* s: orphanSCs) delete s;
575 }
Float_t s
Definition: plot.C:23
const geo::GeometryCore * geom
Planes which measure V.
Definition: geo_types.h:77
void Minimize(const std::vector< CollectionWireHit * > &cwires, const std::vector< SpaceCharge * > &orphanSCs, double alpha, int maxiterations)
Planes which measure Z direction.
Definition: geo_types.h:79
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
Definition: tf_graph.h:23
Planes which measure Y direction.
Definition: geo_types.h:80
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
Planes which measure U.
Definition: geo_types.h:76
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
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Detector simulation of raw signals on wires.
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
Creates a collection of space points with associated charge.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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:27
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Signal from collection planes.
Definition: geo_types.h:93
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

const detinfo::DetectorProperties* reco3d::SpacePointSolver::detprop
protected

Definition at line 122 of file SpacePointSolver_module.cc.

bool reco3d::SpacePointSolver::fAllowBadCollectionHit
protected

Definition at line 110 of file SpacePointSolver_module.cc.

bool reco3d::SpacePointSolver::fAllowBadInductionHit
protected

Definition at line 110 of file SpacePointSolver_module.cc.

double reco3d::SpacePointSolver::fAlpha
protected

Definition at line 112 of file SpacePointSolver_module.cc.

double reco3d::SpacePointSolver::fDistThresh
protected

Definition at line 114 of file SpacePointSolver_module.cc.

double reco3d::SpacePointSolver::fDistThreshDrift
protected

Definition at line 115 of file SpacePointSolver_module.cc.

bool reco3d::SpacePointSolver::fFit
protected

Definition at line 109 of file SpacePointSolver_module.cc.

std::string reco3d::SpacePointSolver::fHitLabel
protected

Definition at line 107 of file SpacePointSolver_module.cc.

int reco3d::SpacePointSolver::fMaxIterationsNoReg
protected

Definition at line 117 of file SpacePointSolver_module.cc.

int reco3d::SpacePointSolver::fMaxIterationsReg
protected

Definition at line 118 of file SpacePointSolver_module.cc.

double reco3d::SpacePointSolver::fXHitOffset
protected

Definition at line 120 of file SpacePointSolver_module.cc.

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

Definition at line 123 of file SpacePointSolver_module.cc.


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