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

Classes

struct  Config
 

Public Types

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

Public Member Functions

 PMAlgTrajFitter (Parameters const &config)
 
 PMAlgTrajFitter (PMAlgTrajFitter const &)=delete
 
 PMAlgTrajFitter (PMAlgTrajFitter &&)=delete
 
PMAlgTrajFitteroperator= (PMAlgTrajFitter const &)=delete
 
PMAlgTrajFitteroperator= (PMAlgTrajFitter &&)=delete
 
void produce (art::Event &e) override
 
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 Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

art::InputTag fHitModuleLabel
 
art::InputTag fPfpModuleLabel
 
pma::ProjectionMatchingAlg::Config fPmaConfig
 
pma::PMAlgFitter::Config fPmaFitterConfig
 
pma::PMAlgVertexing::Config fPmaVtxConfig
 
bool fSaveOnlyBranchingVtx
 
bool fSavePmaNodes
 
art::ServiceHandle< geo::GeometryfGeom
 

Static Private Attributes

static const std::string kKinksName = "kink"
 
static const std::string kNodesName = "node"
 

Detailed Description

Definition at line 53 of file PMAlgTrajFitter_module.cc.

Member Typedef Documentation

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

trkf::PMAlgTrajFitter::PMAlgTrajFitter ( PMAlgTrajFitter::Parameters const &  config)
explicit

Definition at line 127 of file PMAlgTrajFitter_module.cc.

References kKinksName, and kNodesName.

127  :
128  fHitModuleLabel(config().HitModuleLabel()),
129  fPfpModuleLabel(config().PfpModuleLabel()),
130 
131  fPmaConfig(config().ProjectionMatchingAlg()),
132  fPmaFitterConfig(config().PMAlgFitting()),
133  fPmaVtxConfig(config().PMAlgVertexing()),
134 
135  fSaveOnlyBranchingVtx(config().SaveOnlyBranchingVtx()),
136  fSavePmaNodes(config().SavePmaNodes())
137 {
138  produces< std::vector<recob::Track> >();
139  produces< std::vector<recob::SpacePoint> >();
140  produces< std::vector<recob::Vertex> >(); // no instance name for interaction vertices
141  produces< std::vector<recob::Vertex> >(kKinksName); // collection of kinks on tracks
142  produces< std::vector<recob::Vertex> >(kNodesName); // collection of pma nodes
143 
144  produces< art::Assns<recob::Track, recob::Hit> >(); // ****** REMEMBER to remove when FindMany improved ******
145  produces< art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta> >();
146 
147  produces< art::Assns<recob::Track, recob::SpacePoint> >();
148  produces< art::Assns<recob::SpacePoint, recob::Hit> >();
149  produces< art::Assns<recob::Vertex, recob::Track> >(); // no instance name for assns of tracks to interaction vertices
150  produces< art::Assns<recob::Track, recob::Vertex> >(kKinksName); // assns of kinks to tracks
151 
152  produces< art::Assns<recob::PFParticle, recob::Track> >();
153 }
pma::PMAlgVertexing::Config fPmaVtxConfig
static const std::string kNodesName
pma::ProjectionMatchingAlg::Config fPmaConfig
static const std::string kKinksName
pma::PMAlgFitter::Config fPmaFitterConfig
trkf::PMAlgTrajFitter::PMAlgTrajFitter ( PMAlgTrajFitter const &  )
delete
trkf::PMAlgTrajFitter::PMAlgTrajFitter ( PMAlgTrajFitter &&  )
delete

Member Function Documentation

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
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
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
PMAlgTrajFitter& trkf::PMAlgTrajFitter::operator= ( PMAlgTrajFitter const &  )
delete
PMAlgTrajFitter& trkf::PMAlgTrajFitter::operator= ( PMAlgTrajFitter &&  )
delete
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 trkf::PMAlgTrajFitter::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 156 of file PMAlgTrajFitter_module.cc.

References art::PtrVector< T >::clear(), pma::Track3D::CompleteMissingWires(), pma::convertFrom(), util::CreateAssn(), DEFINE_ART_MODULE, pma::Hit3D::Dx(), e, fGeom, fHitModuleLabel, art::fill_ptr_vector(), fPfpModuleLabel, fPmaConfig, fPmaFitterConfig, fPmaVtxConfig, pma::Track3D::FrontCryo(), pma::Track3D::FrontTPC(), fSaveOnlyBranchingVtx, fSavePmaNodes, art::DataViewImpl::getByLabel(), geo::TPCGeo::HasPlane(), pma::Hit3D::Hit2DPtr(), pma::Hit3D::IsEnabled(), art::Ptr< T >::isNull(), art::Ptr< T >::key(), kKinksName, kNodesName, geo::kU, geo::kV, geo::kZ, nodes, pma::Hit3D::Point3D(), art::Event::productGetter(), art::PtrVector< T >::push_back(), art::Event::put(), pma::PMAlgFitter::Config::RunVertexing, pma::Track3D::SelectHits(), recob::PFParticle::Self(), pma::Track3D::size(), art::PtrVector< T >::size(), and geo::GeometryCore::TPC().

157 {
158  // ---------------- Create data products ------------------
159  auto tracks = std::make_unique< std::vector<recob::Track> >();
160  auto allsp = std::make_unique< std::vector<recob::SpacePoint> >();
161  auto vtxs = std::make_unique< std::vector<recob::Vertex> >(); // interaction vertices
162  auto kinks = std::make_unique< std::vector<recob::Vertex> >(); // kinks on tracks (no new particles start in kinks)
163  auto nodes = std::make_unique< std::vector<recob::Vertex> >(); // pma nodes
164 
165  auto trk2hit_oldway = std::make_unique< art::Assns<recob::Track, recob::Hit> >(); // ****** REMEMBER to remove when FindMany improved ******
166  auto trk2hit = std::make_unique< art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta> >();
167 
168  auto trk2sp = std::make_unique< art::Assns<recob::Track, recob::SpacePoint> >();
169 
170  auto sp2hit = std::make_unique< art::Assns<recob::SpacePoint, recob::Hit> >();
171  auto vtx2trk = std::make_unique< art::Assns<recob::Vertex, recob::Track> >(); // one or more tracks (particles) start in the vertex
172  auto trk2kink = std::make_unique< art::Assns<recob::Track, recob::Vertex> >(); // one or more kinks on the track
173 
174  auto pfp2trk = std::make_unique< art::Assns< recob::PFParticle, recob::Track> >();
175 
176  // ------------------- Collect inputs ---------------------
177  art::Handle< std::vector<recob::Hit> > allHitListHandle;
180  std::vector< art::Ptr<recob::Hit> > allhitlist;
181  if (!(evt.getByLabel(fHitModuleLabel, allHitListHandle) && // all hits used to make clusters and PFParticles
182  evt.getByLabel(fPfpModuleLabel, cluListHandle) && // clusters associated to PFParticles
183  evt.getByLabel(fPfpModuleLabel, pfparticleHandle))) // and finally PFParticles
184  {
185  throw cet::exception("PMAlgTrajFitter") << "Not all required data products found in the event." << std::endl;
186  }
187 
188  art::fill_ptr_vector(allhitlist, allHitListHandle);
189 
190  art::FindManyP< recob::Hit > hitsFromClusters(cluListHandle, evt, fPfpModuleLabel);
191  art::FindManyP< recob::Cluster > clustersFromPfps(pfparticleHandle, evt, fPfpModuleLabel);
192  art::FindManyP< recob::Vertex > vtxFromPfps(pfparticleHandle, evt, fPfpModuleLabel);
193 
194  // -------------- PMA Fitter for this event ---------------
195  auto pmalgFitter = pma::PMAlgFitter(allhitlist,
196  *cluListHandle, *pfparticleHandle,
197  hitsFromClusters, clustersFromPfps, vtxFromPfps,
199 
200  // ------------------ Do the job here: --------------------
201  int retCode = pmalgFitter.build();
202  // --------------------------------------------------------
203  switch (retCode)
204  {
205  case -2: mf::LogError("Summary") << "problem"; break;
206  case -1: mf::LogWarning("Summary") << "no input"; break;
207  case 0: mf::LogVerbatim("Summary") << "no tracks done"; break;
208  default:
209  if (retCode < 0) mf::LogVerbatim("Summary") << "unknown result";
210  else if (retCode == 1) mf::LogVerbatim("Summary") << retCode << " track ready";
211  else mf::LogVerbatim("Summary") << retCode << " tracks ready";
212  break;
213  }
214 
215  // ---------- Translate output to data products: ----------
216  auto const & result = pmalgFitter.result();
217  if (!result.empty()) // ok, there is something to save
218  {
219  size_t spStart = 0, spEnd = 0;
220  double sp_pos[3], sp_err[6];
221  for (size_t i = 0; i < 3; i++) sp_pos[i] = 1.0;
222  for (size_t i = 0; i < 6; i++) sp_err[i] = 1.0;
223 
224  // use the following to create PFParticle <--> Track associations;
225  std::map< size_t, std::vector< art::Ptr<recob::Track> > > pfPartToTrackVecMap;
226 
227  //auto const make_trkptr = art::PtrMaker<recob::Track>(evt, *this); // PtrMaker Step #1
228 
229  tracks->reserve(result.size());
230  for (size_t trkIndex = 0; trkIndex < result.size(); ++trkIndex)
231  {
232  pma::Track3D* trk = result[trkIndex].Track();
233 
234  trk->SelectHits(); // just in case, set all to enabled
235  unsigned int itpc = trk->FrontTPC(), icryo = trk->FrontCryo();
236  if (fGeom->TPC(itpc, icryo).HasPlane(geo::kU)) trk->CompleteMissingWires(geo::kU);
237  if (fGeom->TPC(itpc, icryo).HasPlane(geo::kV)) trk->CompleteMissingWires(geo::kV);
238  if (fGeom->TPC(itpc, icryo).HasPlane(geo::kZ)) trk->CompleteMissingWires(geo::kZ);
239 
240  //gc: make sure no tracks are created with less than 2 points
241  if (trk->size()<2) continue;
242 
243  tracks->push_back(pma::convertFrom(*trk, trkIndex));
244 
245  //auto const trkPtr = make_trkptr(tracks->size() - 1); // PtrMaker Step #2
246 
247  size_t trkIdx = tracks->size() - 1; // stuff for assns:
248  art::ProductID trkId = getProductID< std::vector<recob::Track> >();
249  art::Ptr<recob::Track> trkPtr(trkId, trkIdx, evt.productGetter(trkId));
250 
251  //gc: save associated hits in the same order as trajectory points
252  for (size_t h = 0, cnt = 0; h < trk->size(); h++)
253  {
254  pma::Hit3D* h3d = (*trk)[h];
255  if (!h3d->IsEnabled()) continue;
256 
257  recob::TrackHitMeta metadata(cnt++, h3d->Dx());
258  trk2hit->addSingle(trkPtr, h3d->Hit2DPtr(), metadata);
259  trk2hit_oldway->addSingle(trkPtr, h3d->Hit2DPtr()); // ****** REMEMBER to remove when FindMany improved ******
260  }
261 
263  spStart = allsp->size();
264  for (size_t h = 0; h < trk->size(); ++h)
265  {
266  pma::Hit3D* h3d = (*trk)[h];
267  if (!h3d->IsEnabled()) continue;
268 
269  double hx = h3d->Point3D().X();
270  double hy = h3d->Point3D().Y();
271  double hz = h3d->Point3D().Z();
272 
273  if ((h == 0) ||
274  (std::fabs(sp_pos[0] - hx) > 1.0e-5) ||
275  (std::fabs(sp_pos[1] - hy) > 1.0e-5) ||
276  (std::fabs(sp_pos[2] - hz) > 1.0e-5))
277  {
278  if (sp_hits.size()) // hits assigned to the previous sp
279  {
280  util::CreateAssn(*this, evt, *allsp, sp_hits, *sp2hit);
281  sp_hits.clear();
282  }
283  sp_pos[0] = hx; sp_pos[1] = hy; sp_pos[2] = hz;
284  allsp->push_back(recob::SpacePoint(sp_pos, sp_err, 1.0));
285  }
286  sp_hits.push_back(h3d->Hit2DPtr());
287  }
288 
289  if (sp_hits.size()) // hits assigned to the last sp
290  {
291  util::CreateAssn(*this, evt, *allsp, sp_hits, *sp2hit);
292  }
293  spEnd = allsp->size();
294 
295  if (spEnd > spStart) util::CreateAssn(*this, evt, *tracks, *allsp, *trk2sp, spStart, spEnd);
296 
297  // if there is a PFParticle collection then recover PFParticle and add info to map
298  if (result[trkIndex].Key() > -1)
299  {
300  size_t trackIdx = tracks->size() - 1;
301  art::ProductID trackId = getProductID< std::vector<recob::Track> >();
302  art::Ptr<recob::Track> trackPtr(trackId, trackIdx, evt.productGetter(trackId));
303  pfPartToTrackVecMap[result[trkIndex].Key()].push_back(trackPtr);
304  }
305  }
306 
307  auto vid = getProductID< std::vector<recob::Vertex> >();
308  auto kid = getProductID< std::vector<recob::Vertex> >(kKinksName);
309  auto const* kinkGetter = evt.productGetter(kid);
310 
311  auto tid = getProductID< std::vector<recob::Track> >();
312  auto const* trkGetter = evt.productGetter(tid);
313 
314  auto vsel = pmalgFitter.getVertices(fSaveOnlyBranchingVtx); // vtx pos's with vector of connected track idxs
315  auto ksel = pmalgFitter.getKinks(); // pairs of kink position - associated track idx
316  std::map< size_t, art::Ptr<recob::Vertex> > frontVtxs; // front vertex ptr for each track index
317 
318  if (fPmaFitterConfig.RunVertexing()) // save vertices and vtx-trk assns
319  {
320  double xyz[3];
321  for (auto const & v : vsel)
322  {
323  xyz[0] = v.first.X(); xyz[1] = v.first.Y(); xyz[2] = v.first.Z();
324  mf::LogVerbatim("Summary")
325  << " vtx:" << xyz[0] << ":" << xyz[1] << ":" << xyz[2]
326  << " (" << v.second.size() << " tracks)";
327 
328  size_t vidx = vtxs->size();
329  vtxs->push_back(recob::Vertex(xyz, vidx));
330 
331  art::Ptr<recob::Vertex> vptr(vid, vidx, evt.productGetter(vid));
332  if (vptr.isNull()) mf::LogWarning("PMAlgTrajFitter") << "Vertex ptr is null.";
333  if (!v.second.empty())
334  {
335  for (const auto & vEntry : v.second)
336  {
337  size_t tidx = vEntry.first;
338  bool isFront = vEntry.second;
339 
340  if (isFront) frontVtxs[tidx] = vptr; // keep ptr of the front vtx
341 
342  art::Ptr<recob::Track> tptr(tid, tidx, trkGetter);
343  vtx2trk->addSingle(vptr, tptr);
344  }
345  }
346  else mf::LogWarning("PMAlgTrajFitter") << "No tracks found at this vertex.";
347  }
348  mf::LogVerbatim("Summary") << vtxs->size() << " vertices ready";
349 
350  for (auto const & k : ksel)
351  {
352  xyz[0] = k.first.X(); xyz[1] = k.first.Y(); xyz[2] = k.first.Z();
353  mf::LogVerbatim("Summary") << " kink:" << xyz[0] << ":" << xyz[1] << ":" << xyz[2];
354 
355  size_t kidx = kinks->size();
356  size_t tidx = k.second; // track idx on which this kink was found
357 
358  kinks->push_back(recob::Vertex(xyz, tidx)); // save index of track (will have color of trk in evd)
359 
360  art::Ptr<recob::Track> tptr(tid, tidx, trkGetter);
361  art::Ptr<recob::Vertex> kptr(kid, kidx, kinkGetter);
362  trk2kink->addSingle(tptr, kptr);
363  }
364  mf::LogVerbatim("Summary") << ksel.size() << " kinks ready";
365  }
366 
367  if (fSavePmaNodes)
368  {
369  double xyz[3];
370  for (size_t t = 0; t < result.size(); ++t)
371  {
372  auto const & trk = *(result[t].Track());
373  for (auto const * node : trk.Nodes())
374  {
375  xyz[0] = node->Point3D().X(); xyz[1] = node->Point3D().Y(); xyz[2] = node->Point3D().Z();
376  nodes->push_back(recob::Vertex(xyz, t));
377  }
378  }
379  }
380 
381  for (const auto & pfParticleItr : pfPartToTrackVecMap)
382  {
383  art::Ptr<recob::PFParticle> pfParticle(pfparticleHandle, pfParticleItr.first);
384  mf::LogVerbatim("PMAlgTrajFitter") << "PFParticle key: " << pfParticle.key()
385  << ", self: " << pfParticle->Self() << ", #tracks: " << pfParticleItr.second.size();
386 
387  if (!pfParticle.isNull()) util::CreateAssn(*this, evt, pfParticle, pfParticleItr.second, *pfp2trk);
388  else mf::LogError("PMAlgTrajFitter") << "Error in PFParticle lookup, pfparticle index: "
389  << pfParticleItr.first << ", key: " << pfParticle.key();
390  }
391  }
392 
393  evt.put(std::move(tracks));
394  evt.put(std::move(allsp));
395  evt.put(std::move(vtxs));
396  evt.put(std::move(kinks), kKinksName);
397  evt.put(std::move(nodes), kNodesName);
398 
399  evt.put(std::move(trk2hit_oldway)); // ****** REMEMBER to remove when FindMany improved ******
400  evt.put(std::move(trk2hit));
401  evt.put(std::move(trk2sp));
402 
403  evt.put(std::move(sp2hit));
404  evt.put(std::move(vtx2trk));
405  evt.put(std::move(trk2kink), kKinksName);
406 
407  evt.put(std::move(pfp2trk));
408 }
bool SelectHits(float fraction=1.0F)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
bool HasPlane(unsigned int iplane) const
Returns whether a plane with index iplane is present in this TPC.
Definition: TPCGeo.h:155
recob::Track convertFrom(const pma::Track3D &src, unsigned int tidx, int pdg=0)
unsigned int FrontTPC(void) const
Definition: PmaTrack3D.h:104
Planes which measure V.
Definition: geo_types.h:77
bool IsEnabled(void) const
Definition: PmaHit3D.h:82
std::vector< pma::Node3D * > const & Nodes(void) const
Definition: PmaTrack3D.h:232
Planes which measure Z direction.
Definition: geo_types.h:79
art::ServiceHandle< geo::Geometry > fGeom
Data related to recob::Hit associated with recob::Track.The purpose is to collect several variables t...
Definition: TrackHitMeta.h:43
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
art::Ptr< recob::Hit > const & Hit2DPtr(void) const
Definition: PmaHit3D.h:46
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
#define nodes
Planes which measure U.
Definition: geo_types.h:76
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
fhicl::Atom< bool > RunVertexing
size_t CompleteMissingWires(unsigned int view)
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
unsigned int FrontCryo(void) const
Definition: PmaTrack3D.h:105
size_type size() const
Definition: PtrVector.h:308
void push_back(pma::Hit3D *hit)
Definition: PmaTrack3D.h:66
TVector3 const & Point3D(void) const
Definition: PmaHit3D.h:48
pma::PMAlgVertexing::Config fPmaVtxConfig
static const std::string kNodesName
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
pma::ProjectionMatchingAlg::Config fPmaConfig
double Dx(void) const
Definition: PmaHit3D.h:67
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
TCEvent evt
Definition: DataStructs.cxx:5
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
size_t size() const
Definition: PmaTrack3D.h:76
static const std::string kKinksName
void clear()
Definition: PtrVector.h:537
pma::PMAlgFitter::Config fPmaFitterConfig
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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

art::ServiceHandle< geo::Geometry > trkf::PMAlgTrajFitter::fGeom
private

Definition at line 120 of file PMAlgTrajFitter_module.cc.

Referenced by produce().

art::InputTag trkf::PMAlgTrajFitter::fHitModuleLabel
private

Definition at line 105 of file PMAlgTrajFitter_module.cc.

Referenced by produce().

art::InputTag trkf::PMAlgTrajFitter::fPfpModuleLabel
private

Definition at line 106 of file PMAlgTrajFitter_module.cc.

Referenced by produce().

pma::ProjectionMatchingAlg::Config trkf::PMAlgTrajFitter::fPmaConfig
private

Definition at line 108 of file PMAlgTrajFitter_module.cc.

Referenced by produce().

pma::PMAlgFitter::Config trkf::PMAlgTrajFitter::fPmaFitterConfig
private

Definition at line 109 of file PMAlgTrajFitter_module.cc.

Referenced by produce().

pma::PMAlgVertexing::Config trkf::PMAlgTrajFitter::fPmaVtxConfig
private

Definition at line 110 of file PMAlgTrajFitter_module.cc.

Referenced by produce().

bool trkf::PMAlgTrajFitter::fSaveOnlyBranchingVtx
private

Definition at line 112 of file PMAlgTrajFitter_module.cc.

Referenced by produce().

bool trkf::PMAlgTrajFitter::fSavePmaNodes
private

Definition at line 113 of file PMAlgTrajFitter_module.cc.

Referenced by produce().

const std::string trkf::PMAlgTrajFitter::kKinksName = "kink"
staticprivate

Definition at line 116 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().

const std::string trkf::PMAlgTrajFitter::kNodesName = "node"
staticprivate

Definition at line 117 of file PMAlgTrajFitter_module.cc.

Referenced by PMAlgTrajFitter(), and produce().


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