All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
trkf::PMAlgTrackMaker Class Reference
Inheritance diagram for trkf::PMAlgTrackMaker:

Classes

struct  Config
 

Public Types

using Parameters = art::EDProducer::Table< Config >
 

Public Member Functions

 PMAlgTrackMaker (Parameters const &config)
 
 PMAlgTrackMaker (PMAlgTrackMaker const &)=delete
 
 PMAlgTrackMaker (PMAlgTrackMaker &&)=delete
 
PMAlgTrackMakeroperator= (PMAlgTrackMaker const &)=delete
 
PMAlgTrackMakeroperator= (PMAlgTrackMaker &&)=delete
 

Private Member Functions

void produce (art::Event &e) override
 
template<size_t N>
bool init (const art::Event &evt, pma::PMAlgTracker &pmalgTracker) const
 
template<size_t N>
int getPdgFromCnnOnHits (const art::Event &evt, const pma::Track3D &trk) const
 
std::vector< anab::CosmicTagID_tgetCosmicTag (const pma::Track3D::ETag pmaTag) const
 

Private Attributes

art::InputTag fHitModuleLabel
 
art::InputTag fWireModuleLabel
 
art::InputTag fCluModuleLabel
 
art::InputTag fEmModuleLabel
 
pma::ProjectionMatchingAlg::Config fPmaConfig
 
pma::PMAlgTracker::Config fPmaTrackerConfig
 
pma::PMAlgCosmicTagger::Config fPmaTaggingConfig
 
pma::PMAlgVertexing::Config fPmaVtxConfig
 
pma::PMAlgStitching::Config fPmaStitchConfig
 
bool fSaveOnlyBranchingVtx
 
bool fSavePmaNodes
 
geo::GeometryCore const * fGeom
 
std::vector< TH1F * > fAdcInPassingPoints
 
std::vector< TH1F * > fAdcInRejectedPoints
 

Static Private Attributes

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

Detailed Description

Definition at line 71 of file PMAlgTrackMaker_module.cc.

Member Typedef Documentation

using trkf::PMAlgTrackMaker::Parameters = art::EDProducer::Table<Config>

Definition at line 112 of file PMAlgTrackMaker_module.cc.

Constructor & Destructor Documentation

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

Definition at line 167 of file PMAlgTrackMaker_module.cc.

168  : EDProducer{config}
169  , fHitModuleLabel(config().HitModuleLabel())
170  , fWireModuleLabel(config().WireModuleLabel())
171  , fCluModuleLabel(config().ClusterModuleLabel())
172  , fEmModuleLabel(config().EmClusterModuleLabel())
173  , fPmaConfig(config().ProjectionMatchingAlg())
174  , fPmaTrackerConfig(config().PMAlgTracking())
175  , fPmaTaggingConfig(config().PMAlgCosmicTagging())
176  , fPmaVtxConfig(config().PMAlgVertexing())
177  , fPmaStitchConfig(config().PMAlgStitching())
178  , fSaveOnlyBranchingVtx(config().SaveOnlyBranchingVtx())
179  , fSavePmaNodes(config().SavePmaNodes())
180  , fGeom(art::ServiceHandle<geo::Geometry const>().get())
181  {
182  produces<std::vector<recob::Track>>();
183  produces<std::vector<recob::SpacePoint>>();
184  produces<std::vector<recob::Vertex>>(); // no instance name for interaction vertices
185  produces<std::vector<recob::Vertex>>(kKinksName); // collection of kinks on tracks
186  produces<std::vector<recob::Vertex>>(kNodesName); // collection of pma nodes
187  produces<std::vector<anab::T0>>();
188  produces<std::vector<anab::CosmicTag>>(); // Cosmic ray tags
189 
190  produces<art::Assns<recob::Track,
191  recob::Hit>>(); // ****** REMEMBER to remove when FindMany improved ******
192  produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
193 
194  produces<art::Assns<recob::Track, recob::SpacePoint>>();
195  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
196  produces<
197  art::Assns<recob::Vertex,
198  recob::Track>>(); // no instance name for assns of tracks to interaction vertices
199  produces<art::Assns<recob::Track, recob::Vertex>>(kKinksName); // assns of kinks to tracks
200  produces<art::Assns<recob::Track, anab::T0>>();
201  produces<art::Assns<recob::Track, anab::CosmicTag>>(); // Cosmic ray tags associated to tracks
202 
203  produces<std::vector<recob::PFParticle>>();
204  produces<art::Assns<recob::PFParticle, recob::Cluster>>();
205  produces<art::Assns<recob::PFParticle, recob::Vertex>>();
206  produces<art::Assns<recob::PFParticle, recob::Track>>();
207 
208  if (fPmaTrackerConfig.Validation() == "calib") // create histograms only in the calibration mode
209  {
210  art::ServiceHandle<art::TFileService const> tfs;
211  for (size_t p = 0; p < fGeom->MaxPlanes(); ++p) {
212  std::ostringstream ss1;
213  ss1 << "adc_plane_" << p;
214  fAdcInPassingPoints.push_back(tfs->make<TH1F>(
215  (ss1.str() + "_passing").c_str(), "max adc around the point on track", 100., 0., 5.));
216  fAdcInRejectedPoints.push_back(tfs->make<TH1F>(
217  (ss1.str() + "_rejected").c_str(), "max adc around spurious point ", 100., 0., 5.));
218  }
219  }
220  }
static const std::string kKinksName
pdgs p
Definition: selectors.fcl:22
fhicl::Atom< std::string > Validation
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
process_name ccluster WireModuleLabel
Definition: hitana.fcl:49
geo::GeometryCore const * fGeom
pma::PMAlgStitching::Config fPmaStitchConfig
unsigned int MaxPlanes() const
Returns the largest number of planes among all TPCs in this detector.
pma::ProjectionMatchingAlg::Config fPmaConfig
pma::PMAlgVertexing::Config fPmaVtxConfig
pma::PMAlgCosmicTagger::Config fPmaTaggingConfig
std::vector< TH1F * > fAdcInRejectedPoints
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
pma::PMAlgTracker::Config fPmaTrackerConfig
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
art::ServiceHandle< art::TFileService > tfs
std::vector< TH1F * > fAdcInPassingPoints
static const std::string kNodesName
trkf::PMAlgTrackMaker::PMAlgTrackMaker ( PMAlgTrackMaker const &  )
delete
trkf::PMAlgTrackMaker::PMAlgTrackMaker ( PMAlgTrackMaker &&  )
delete

Member Function Documentation

std::vector< anab::CosmicTagID_t > trkf::PMAlgTrackMaker::getCosmicTag ( const pma::Track3D::ETag  pmaTag) const
private

Definition at line 294 of file PMAlgTrackMaker_module.cc.

295  {
296  std::vector<anab::CosmicTagID_t> anabTags;
297 
299  anabTags.push_back(anab::CosmicTagID_t::kOutsideDrift_Partial);
300  }
303  }
304  if (pmaTag & pma::Track3D::kBeamIncompatible) {
306  }
307  if (pmaTag & pma::Track3D::kGeometry_XX) {
308  anabTags.push_back(anab::CosmicTagID_t::kGeometry_XX);
309  }
310  if (pmaTag & pma::Track3D::kGeometry_YY) {
311  anabTags.push_back(anab::CosmicTagID_t::kGeometry_YY);
312  }
313  if (pmaTag & pma::Track3D::kGeometry_ZZ) {
314  anabTags.push_back(anab::CosmicTagID_t::kGeometry_ZZ);
315  }
316  if (pmaTag & pma::Track3D::kGeometry_YZ) {
317  anabTags.push_back(anab::CosmicTagID_t::kGeometry_YZ);
318  }
319  if (pmaTag & pma::Track3D::kGeometry_Y) {
320  anabTags.push_back(anab::CosmicTagID_t::kGeometry_Y);
321  }
322 
323  if (anabTags.empty()) { anabTags.push_back(anab::CosmicTagID_t::kUnknown); }
324 
325  return anabTags;
326  }
template<size_t N>
int trkf::PMAlgTrackMaker::getPdgFromCnnOnHits ( const art::Event &  evt,
const pma::Track3D trk 
) const
private

Definition at line 225 of file PMAlgTrackMaker_module.cc.

226  {
227  int pdg = 0;
230  if (hitResults) {
231  int trkLikeIdx = hitResults->getIndex("track");
232  int emLikeIdx = hitResults->getIndex("em");
233  if ((trkLikeIdx < 0) || (emLikeIdx < 0)) {
234  throw cet::exception("PMAlgTrackMaker")
235  << "No em/track labeled columns in MVA data products." << std::endl;
236  }
237 
238  size_t nh[3] = {0, 0, 0};
239  for (size_t hidx = 0; hidx < trk.size(); ++hidx) {
240  ++nh[trk[hidx]->View2D()];
241  }
242 
243  size_t best_view = 2; // collection
244  if ((nh[0] >= nh[1]) && (nh[0] > 1.25 * nh[2])) best_view = 0; // ind1
245  if ((nh[1] >= nh[0]) && (nh[1] > 1.25 * nh[2])) best_view = 1; // ind2
246 
247  std::vector<art::Ptr<recob::Hit>> trkHitPtrList;
248  trkHitPtrList.reserve(nh[best_view]);
249  for (size_t hidx = 0; hidx < trk.size(); ++hidx) {
250  if (trk[hidx]->View2D() == best_view) {
251  trkHitPtrList.emplace_back(trk[hidx]->Hit2DPtr());
252  }
253  }
254  auto vout = hitResults->getOutput(trkHitPtrList);
255  double trk_like = -1, trk_or_em = vout[trkLikeIdx] + vout[emLikeIdx];
256  if (trk_or_em > 0) {
257  trk_like = vout[trkLikeIdx] / trk_or_em;
258  if (trk_like < fPmaTrackerConfig.TrackLikeThreshold()) pdg = 11; // tag if EM-like
259  // (don't set pdg for track-like, for the moment don't like the idea of using "13")
260  }
261  //std::cout << "trk:" << best_view << ":" << trk.size() << ":" << trkHitPtrList.size() << " p=" << trk_like << std::endl;
262  }
263  }
264  return pdg;
265  }
var pdg
Definition: selectors.fcl:14
fhicl::Atom< float > TrackLikeThreshold
pma::PMAlgTracker::Config fPmaTrackerConfig
TCEvent evt
Definition: DataStructs.cxx:8
size_t size() const
Definition: PmaTrack3D.h:111
static std::unique_ptr< MVAReader > create(const art::Event &evt, const art::InputTag &tag)
Definition: MVAReader.h:110
template<size_t N>
bool trkf::PMAlgTrackMaker::init ( const art::Event &  evt,
pma::PMAlgTracker pmalgTracker 
) const
private

Definition at line 269 of file PMAlgTrackMaker_module.cc.

270  {
272  if (!cluResults) { return false; }
273 
274  int trkLikeIdx = cluResults->getIndex("track");
275  int emLikeIdx = cluResults->getIndex("em");
276  if ((trkLikeIdx < 0) || (emLikeIdx < 0)) { return false; }
277 
278  const art::FindManyP<recob::Hit> hitsFromClusters(
279  cluResults->dataHandle(), evt, cluResults->dataTag());
280  const auto& cnnOuts = cluResults->outputs();
281  std::vector<float> trackLike(cnnOuts.size());
282  for (size_t i = 0; i < cnnOuts.size(); ++i) {
283  double trkOrEm = cnnOuts[i][trkLikeIdx] + cnnOuts[i][emLikeIdx];
284  if (trkOrEm > 0) { trackLike[i] = cnnOuts[i][trkLikeIdx] / trkOrEm; }
285  else {
286  trackLike[i] = 0;
287  }
288  }
289  pmalgTracker.init(hitsFromClusters, trackLike);
290  return true;
291  }
void init(const art::FindManyP< recob::Hit > &hitsFromClusters)
TCEvent evt
Definition: DataStructs.cxx:8
static std::unique_ptr< MVAReader > create(const art::Event &evt, const art::InputTag &tag)
Definition: MVAReader.h:110
PMAlgTrackMaker& trkf::PMAlgTrackMaker::operator= ( PMAlgTrackMaker const &  )
delete
PMAlgTrackMaker& trkf::PMAlgTrackMaker::operator= ( PMAlgTrackMaker &&  )
delete
void trkf::PMAlgTrackMaker::produce ( art::Event &  e)
overrideprivate

Definition at line 329 of file PMAlgTrackMaker_module.cc.

330  {
331  // ---------------- Create data products --------------------------
332  auto tracks = std::make_unique<std::vector<recob::Track>>();
333  auto allsp = std::make_unique<std::vector<recob::SpacePoint>>();
334  auto vtxs = std::make_unique<std::vector<recob::Vertex>>(); // interaction vertices
335  auto kinks = std::make_unique<
336  std::vector<recob::Vertex>>(); // kinks on tracks (no new particles start in kinks)
337  auto nodes = std::make_unique<std::vector<recob::Vertex>>(); // pma nodes
338  auto t0s = std::make_unique<std::vector<anab::T0>>();
339  auto cosmicTags = std::make_unique<std::vector<anab::CosmicTag>>();
340 
341  auto trk2hit_oldway = std::make_unique<
342  art::Assns<recob::Track,
343  recob::Hit>>(); // ****** REMEMBER to remove when FindMany improved ******
344  auto trk2hit = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
345 
346  auto trk2sp = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
347  auto trk2t0 = std::make_unique<art::Assns<recob::Track, anab::T0>>();
348  auto trk2ct = std::make_unique<art::Assns<recob::Track, anab::CosmicTag>>();
349 
350  auto sp2hit = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
351  auto vtx2trk = std::make_unique<
352  art::Assns<recob::Vertex,
353  recob::Track>>(); // one or more tracks (particles) start in the vertex
354  auto trk2kink =
355  std::make_unique<art::Assns<recob::Track, recob::Vertex>>(); // one or more kinks on the track
356 
357  auto pfps = std::make_unique<std::vector<recob::PFParticle>>();
358 
359  auto pfp2clu = std::make_unique<art::Assns<recob::PFParticle, recob::Cluster>>();
360  auto pfp2vtx = std::make_unique<art::Assns<recob::PFParticle, recob::Vertex>>();
361  auto pfp2trk = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
362 
363  // --------------------- Wires & Hits -----------------------------
364  auto wireHandle = evt.getValidHandle<std::vector<recob::Wire>>(fWireModuleLabel);
365  auto allHitListHandle = evt.getValidHandle<std::vector<recob::Hit>>(fHitModuleLabel);
366  std::vector<art::Ptr<recob::Hit>> allhitlist;
367  art::fill_ptr_vector(allhitlist, allHitListHandle);
368 
369  // -------------- PMA Tracker for this event ----------------------
370  auto pmalgTracker = pma::PMAlgTracker(allhitlist,
371  *wireHandle,
372  fPmaConfig,
379 
380  size_t mvaLength = 0;
381  if (fEmModuleLabel != "") // ----------- Exclude EM parts ---------
382  {
383  auto cluListHandle = evt.getValidHandle<std::vector<recob::Cluster>>(fCluModuleLabel);
384  auto splitCluHandle = evt.getValidHandle<std::vector<recob::Cluster>>(fEmModuleLabel);
385 
386  art::FindManyP<recob::Hit> hitsFromClusters(cluListHandle, evt, fCluModuleLabel);
387  art::FindManyP<recob::Hit> hitsFromEmParts(splitCluHandle, evt, fEmModuleLabel);
388  pmalgTracker.init(hitsFromClusters, hitsFromEmParts);
389  }
390  else if (fPmaTrackerConfig.TrackLikeThreshold() > 0) // --- CNN EM/trk separation ----
391  {
392  // try to dig out 4- or 3-output MVA data product
393  if (init<4>(evt, pmalgTracker)) { mvaLength = 4; } // e.g.: EM / track / Michel / none
394  else if (init<3>(evt, pmalgTracker)) {
395  mvaLength = 3;
396  } // e.g.: EM / track / none
397  else if (init<2>(evt, pmalgTracker)) {
398  mvaLength = 2;
399  } // just EM / track (LArIAT starts with this style)
400  else {
401  throw cet::exception("PMAlgTrackMaker") << "No EM/track MVA data products." << std::endl;
402  }
403  }
404  else // ------------------------ Use ALL clusters -----------------
405  {
406  auto cluListHandle = evt.getValidHandle<std::vector<recob::Cluster>>(fCluModuleLabel);
407  art::FindManyP<recob::Hit> hitsFromClusters(cluListHandle, evt, fCluModuleLabel);
408  pmalgTracker.init(hitsFromClusters);
409  }
410 
411  // ------------------ Do the job here: ----------------------------
412  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
413  auto const detProp =
414  art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
415  int retCode = pmalgTracker.build(clockData, detProp);
416  // ----------------------------------------------------------------
417  switch (retCode) {
418  case -2: mf::LogError("Summary") << "problem"; break;
419  case -1: mf::LogWarning("Summary") << "no input"; break;
420  case 0: mf::LogVerbatim("Summary") << "no tracks done"; break;
421  default:
422  if (retCode < 0)
423  mf::LogVerbatim("Summary") << "unknown result";
424  else if (retCode == 1)
425  mf::LogVerbatim("Summary") << retCode << " track ready";
426  else
427  mf::LogVerbatim("Summary") << retCode << " tracks ready";
428  break;
429  }
430 
431  // ---------- Translate output to data products: ------------------
432  auto const& result = pmalgTracker.result();
433  if (!result.empty()) // ok, there is something to save
434  {
435  size_t spStart = 0, spEnd = 0;
436  double sp_pos[3], sp_err[6];
437  for (size_t i = 0; i < 3; ++i)
438  sp_pos[i] = 0.0;
439  for (size_t i = 0; i < 6; ++i)
440  sp_err[i] = 1.0;
441 
442  auto const make_pfpptr = art::PtrMaker<recob::PFParticle>(evt);
443  auto const make_trkptr = art::PtrMaker<recob::Track>(evt); // PtrMaker Step #1
444  auto const make_vtxptr = art::PtrMaker<recob::Vertex>(evt);
445  auto const make_kinkptr = art::PtrMaker<recob::Vertex>(evt, kKinksName);
446  auto const make_t0ptr = art::PtrMaker<anab::T0>(evt);
447  auto const make_ctptr = art::PtrMaker<anab::CosmicTag>(evt);
448 
449  tracks->reserve(result.size());
450  for (size_t trkIndex = 0; trkIndex < result.size(); ++trkIndex) {
451  pma::Track3D* trk = result[trkIndex].Track();
452 
453  trk->SelectHits(); // just in case, set all to enabled
454  unsigned int itpc = trk->FrontTPC(), icryo = trk->FrontCryo();
455  pma::dedx_map dedx_tmp;
456  if (fGeom->TPC(itpc, icryo).HasPlane(geo::kU)) {
458  trk->GetRawdEdxSequence(dedx_tmp, geo::kU, 1);
459  }
460  if (fGeom->TPC(itpc, icryo).HasPlane(geo::kV)) {
462  trk->GetRawdEdxSequence(dedx_tmp, geo::kV, 1);
463  }
464  if (fGeom->TPC(itpc, icryo).HasPlane(geo::kX)) {
466  trk->GetRawdEdxSequence(dedx_tmp, geo::kX, 1);
467  }
468  if (fGeom->TPC(itpc, icryo).HasPlane(geo::kY)) {
470  trk->GetRawdEdxSequence(dedx_tmp, geo::kY, 1);
471  }
472  if (fGeom->TPC(itpc, icryo).HasPlane(geo::kZ)) {
474  trk->GetRawdEdxSequence(dedx_tmp, geo::kZ, 1);
475  }
476 
477  //gc: make sure no tracks are created with less than 2 points
478  if (trk->size() < 2) continue;
479 
480  int pdg = 0;
481  if (mvaLength == 4)
482  pdg = getPdgFromCnnOnHits<4>(evt, *(result[trkIndex].Track()));
483  else if (mvaLength == 3)
484  pdg = getPdgFromCnnOnHits<3>(evt, *(result[trkIndex].Track()));
485  else if (mvaLength == 2)
486  pdg = getPdgFromCnnOnHits<2>(evt, *(result[trkIndex].Track()));
487  //else mf::LogInfo("PMAlgTrackMaker") << "Not using PID from CNN.";
488 
489  tracks->push_back(pma::convertFrom(*trk, trkIndex, pdg));
490 
491  auto const trkPtr = make_trkptr(tracks->size() - 1); // PtrMaker Step #2
492 
493  if (trk->HasT0()) {
494  // TriggBits=3 means from 3d reco (0,1,2 mean something else)
495  t0s->push_back(anab::T0(trk->GetT0(), 0, 3, tracks->back().ID()));
496 
497  auto const t0Ptr = make_t0ptr(t0s->size() - 1); // PtrMaker Step #3
498  trk2t0->addSingle(trkPtr, t0Ptr);
499  }
500 
501  // Check if this is a cosmic ray and create an association if it is.
502  if (trk->HasTagFlag(pma::Track3D::kCosmic)) {
503  // Get the track end points
504  std::vector<float> trkEnd0;
505  std::vector<float> trkEnd1;
506  // Get the drift direction, but don't care about the sign
507  // Also need to subtract 1 due to the definition.
508  int driftDir =
509  abs(fGeom->TPC(trk->FrontTPC(), trk->FrontCryo()).DetectDriftDirection()) - 1;
510 
511  for (int i = 0; i < 3; ++i) {
512  // Get the drift direction and apply the opposite of the drift shift in order to
513  // give the CosmicTag the drift coordinate assuming T0 = T_beam as it requests.
514  double shift = 0.0;
515  if (i == driftDir) { shift = trk->Nodes()[0]->GetDriftShift(); }
516  trkEnd0.push_back(trk->Nodes()[0]->Point3D()[i] - shift);
517  trkEnd1.push_back(trk->Nodes()[trk->Nodes().size() - 1]->Point3D()[i] - shift);
518  }
519  // Make the tag object. For now, let's say this is very likely a cosmic (3rd argument = 1).
520  // Set the type of cosmic to the value saved in pma::Track.
521  auto tags = getCosmicTag(trk->GetTag());
522  for (const auto t : tags) {
523  cosmicTags->emplace_back(trkEnd0, trkEnd1, 1, t);
524  auto const cosmicPtr = make_ctptr(cosmicTags->size() - 1);
525  trk2ct->addSingle(trkPtr, cosmicPtr);
526  }
527  }
528 
529  //gc: save associated hits in the same order as trajectory points
530  for (size_t h = 0, cnt = 0; h < trk->size(); h++) {
531  pma::Hit3D* h3d = (*trk)[h];
532  if (!h3d->IsEnabled()) continue;
533 
534  recob::TrackHitMeta metadata(cnt++, h3d->Dx());
535  trk2hit->addSingle(trkPtr, h3d->Hit2DPtr(), metadata);
536  trk2hit_oldway->addSingle(
537  trkPtr, h3d->Hit2DPtr()); // ****** REMEMBER to remove when FindMany improved ******
538  }
539 
540  art::PtrVector<recob::Hit> sp_hits;
541  spStart = allsp->size();
542  //rs: so make also associations to space points in the order of trajectory points
543  for (size_t h = 0; h < trk->size(); ++h) {
544  pma::Hit3D* h3d = (*trk)[h];
545  if (!h3d->IsEnabled()) continue;
546 
547  double hx = h3d->Point3D().X();
548  double hy = h3d->Point3D().Y();
549  double hz = h3d->Point3D().Z();
550 
551  if ((h == 0) || (std::fabs(sp_pos[0] - hx) > 1.0e-5) ||
552  (std::fabs(sp_pos[1] - hy) > 1.0e-5) || (std::fabs(sp_pos[2] - hz) > 1.0e-5)) {
553  if (sp_hits.size()) // hits assigned to the previous sp
554  {
555  util::CreateAssn(evt, *allsp, sp_hits, *sp2hit);
556  sp_hits.clear();
557  }
558  sp_pos[0] = hx;
559  sp_pos[1] = hy;
560  sp_pos[2] = hz;
561  allsp->push_back(recob::SpacePoint(sp_pos, sp_err, 1.0));
562  }
563  sp_hits.push_back(h3d->Hit2DPtr());
564  }
565 
566  if (sp_hits.size()) // hits assigned to the last sp
567  {
568  util::CreateAssn(evt, *allsp, sp_hits, *sp2hit);
569  }
570  spEnd = allsp->size();
571 
572  if (spEnd > spStart) util::CreateAssn(evt, *tracks, *allsp, *trk2sp, spStart, spEnd);
573  }
574 
575  auto vsel = pmalgTracker.getVertices(
576  fSaveOnlyBranchingVtx); // vtx pos's with vector of connected track idxs
577  auto ksel = pmalgTracker.getKinks(); // pairs of kink position - associated track idx
578  std::map<size_t, art::Ptr<recob::Vertex>> frontVtxs; // front vertex ptr for each track index
579 
580  if (fPmaTrackerConfig.RunVertexing()) // save vertices and vtx-trk assns
581  {
582  double xyz[3];
583  for (auto const& v : vsel) {
584  xyz[0] = v.first.X();
585  xyz[1] = v.first.Y();
586  xyz[2] = v.first.Z();
587  mf::LogVerbatim("Summary") << " vtx:" << xyz[0] << ":" << xyz[1] << ":" << xyz[2]
588  << " (" << v.second.size() << " tracks)";
589 
590  size_t vidx = vtxs->size();
591  vtxs->push_back(recob::Vertex(xyz, vidx));
592 
593  auto const vptr = make_vtxptr(vidx);
594  if (!v.second.empty()) {
595  for (const auto& vEntry : v.second) {
596  size_t tidx = vEntry.first;
597  bool isFront = vEntry.second;
598 
599  if (isFront) frontVtxs[tidx] = vptr; // keep ptr of the front vtx
600 
601  auto const tptr = make_trkptr(tidx);
602  vtx2trk->addSingle(vptr, tptr);
603  }
604  }
605  else
606  mf::LogWarning("PMAlgTrackMaker") << "No tracks found at this vertex.";
607  }
608  mf::LogVerbatim("Summary") << vtxs->size() << " vertices ready";
609 
610  for (auto const& k : ksel) {
611  xyz[0] = k.first.X();
612  xyz[1] = k.first.Y();
613  xyz[2] = k.first.Z();
614  mf::LogVerbatim("Summary") << " kink:" << xyz[0] << ":" << xyz[1] << ":" << xyz[2];
615 
616  size_t kidx = kinks->size();
617  size_t tidx = k.second; // track idx on which this kink was found
618 
619  kinks->push_back(
620  recob::Vertex(xyz, tidx)); // save index of track (will have color of trk in evd)
621 
622  auto const tptr = make_trkptr(tidx);
623  auto const kptr = make_kinkptr(kidx);
624  trk2kink->addSingle(tptr, kptr);
625  }
626  mf::LogVerbatim("Summary") << ksel.size() << " kinks ready";
627  }
628 
629  if (fSavePmaNodes) {
630  double xyz[3];
631  for (size_t t = 0; t < result.size(); ++t) {
632  auto const& trk = *(result[t].Track());
633  for (auto const* node : trk.Nodes()) {
634  xyz[0] = node->Point3D().X();
635  xyz[1] = node->Point3D().Y();
636  xyz[2] = node->Point3D().Z();
637  nodes->push_back(recob::Vertex(xyz, t));
638  }
639  }
640  }
641 
642  for (size_t t = 0; t < result.size(); ++t) {
643  size_t parentIdx = recob::PFParticle::kPFParticlePrimary;
644  if (result[t].Parent() >= 0) parentIdx = (size_t)result[t].Parent();
645 
646  std::vector<size_t> daughterIdxs;
647  for (size_t idx : result[t].Daughters()) {
648  daughterIdxs.push_back(idx);
649  }
650 
651  size_t pfpidx = pfps->size();
652  pfps->emplace_back((*tracks)[t].ParticleId(), pfpidx, parentIdx, daughterIdxs);
653 
654  auto const pfpptr = make_pfpptr(pfpidx);
655  auto const tptr = make_trkptr(t);
656  pfp2trk->addSingle(pfpptr, tptr);
657 
658  // add assns to FRONT vertex of each particle
660  art::Ptr<recob::Vertex> vptr = frontVtxs[t];
661  if (!vptr.isNull())
662  pfp2vtx->addSingle(pfpptr, vptr);
663  else
664  mf::LogWarning("PMAlgTrackMaker") << "Front vertex for PFParticle is missing.";
665  }
666  }
667  mf::LogVerbatim("Summary") << pfps->size()
668  << " PFParticles created for reconstructed tracks.";
669  mf::LogVerbatim("Summary") << "Adding " << result.parents().size() << " primary PFParticles.";
670  for (size_t t = 0; t < result.parents().size(); ++t) {
671  std::vector<size_t> daughterIdxs;
672  for (size_t idx : result.parents()[t].Daughters()) {
673  daughterIdxs.push_back(idx);
674  }
675 
676  size_t pfpidx = pfps->size();
677  size_t parentIdx = recob::PFParticle::kPFParticlePrimary;
678  pfps->emplace_back(0, pfpidx, parentIdx, daughterIdxs);
679 
680  // add assns to END vertex of primary
681  if (fPmaTrackerConfig.RunVertexing() && !daughterIdxs.empty()) {
682  auto const pfpptr = make_pfpptr(pfpidx);
683  art::Ptr<recob::Vertex> vptr =
684  frontVtxs[daughterIdxs.front()]; // same vertex for all daughters
685  if (!vptr.isNull())
686  pfp2vtx->addSingle(pfpptr, vptr);
687  else
688  mf::LogWarning("PMAlgTrackMaker") << "Front vertex for PFParticle is missing.";
689  }
690  }
691  mf::LogVerbatim("Summary") << pfps->size() << " PFParticles created in total.";
692  }
693 
694  // for (const auto & ct : *cosmicTags) { std::cout << "Cosmic tag: " << ct << std::endl; }
695 
696  evt.put(std::move(tracks));
697  evt.put(std::move(allsp));
698  evt.put(std::move(vtxs));
699  evt.put(std::move(kinks), kKinksName);
700  evt.put(std::move(nodes), kNodesName);
701  evt.put(std::move(t0s));
702  evt.put(std::move(cosmicTags));
703 
704  evt.put(std::move(trk2hit_oldway)); // ****** REMEMBER to remove when FindMany improved ******
705  evt.put(std::move(trk2hit));
706  evt.put(std::move(trk2sp));
707  evt.put(std::move(trk2t0));
708  evt.put(std::move(trk2ct));
709 
710  evt.put(std::move(sp2hit));
711  evt.put(std::move(vtx2trk));
712  evt.put(std::move(trk2kink), kKinksName);
713 
714  evt.put(std::move(pfps));
715  evt.put(std::move(pfp2clu));
716  evt.put(std::move(pfp2vtx));
717  evt.put(std::move(pfp2trk));
718  }
bool SelectHits(float fraction=1.0F)
bool HasPlane(unsigned int iplane) const
Returns whether a plane with index iplane is present in this TPC.
Definition: TPCGeo.h:175
double Dx() const noexcept
Definition: PmaHit3D.h:130
bool HasTagFlag(ETag value) const noexcept
Definition: PmaTrack3D.h:72
static const std::string kKinksName
var pdg
Definition: selectors.fcl:14
ClusterModuleLabel join with tracks
recob::Track convertFrom(const pma::Track3D &src, unsigned int tidx, int pdg=0)
static constexpr size_t kPFParticlePrimary
Define index to signify primary particle.
Definition: PFParticle.h:61
Planes which measure V.
Definition: geo_types.h:130
Planes which measure X direction.
Definition: geo_types.h:134
ETag GetTag() const noexcept
Definition: PmaTrack3D.h:67
std::vector< pma::Node3D * > const & Nodes() const noexcept
Definition: PmaTrack3D.h:338
TVector3 const & Point3D() const
Definition: PmaHit3D.h:55
Planes which measure Z direction.
Definition: geo_types.h:132
Data related to recob::Hit associated with recob::Track.The purpose is to collect several variables t...
Definition: TrackHitMeta.h:43
fhicl::Atom< bool > RunVertexing
Definition: T0.h:16
shift
Definition: fcl_checks.sh:26
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
Planes which measure Y direction.
Definition: geo_types.h:133
std::vector< anab::CosmicTagID_t > getCosmicTag(const pma::Track3D::ETag pmaTag) const
geo::GeometryCore const * fGeom
while getopts h
T abs(T value)
Planes which measure U.
Definition: geo_types.h:129
double GetT0() const
Definition: PmaTrack3D.h:309
pma::PMAlgStitching::Config fPmaStitchConfig
pma::ProjectionMatchingAlg::Config fPmaConfig
pma::PMAlgVertexing::Config fPmaVtxConfig
unsigned int FrontTPC() const
Definition: PmaTrack3D.h:148
unsigned int FrontCryo() const
Definition: PmaTrack3D.h:153
pma::PMAlgCosmicTagger::Config fPmaTaggingConfig
size_t CompleteMissingWires(detinfo::DetectorPropertiesData const &detProp, unsigned int view)
void push_back(pma::Hit3D *hit)
Definition: PmaTrack3D.h:90
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
std::map< size_t, std::vector< double > > dedx_map
fhicl::Atom< float > TrackLikeThreshold
double GetRawdEdxSequence(std::map< size_t, std::vector< double >> &dedx, unsigned int view=geo::kZ, unsigned int skip=0, bool inclDisabled=false) const
bool HasT0() const noexcept
Definition: PmaTrack3D.h:316
do i e
art::Ptr< recob::Hit > const & Hit2DPtr() const
Definition: PmaHit3D.h:49
std::vector< TH1F * > fAdcInRejectedPoints
bool IsEnabled() const noexcept
Definition: PmaHit3D.h:161
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
pma::PMAlgTracker::Config fPmaTrackerConfig
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
TCEvent evt
Definition: DataStructs.cxx:8
pdgs k
Definition: selectors.fcl:22
size_t size() const
Definition: PmaTrack3D.h:111
auto const detProp
std::vector< TH1F * > fAdcInPassingPoints
static const std::string kNodesName

Member Data Documentation

std::vector<TH1F*> trkf::PMAlgTrackMaker::fAdcInPassingPoints
private

Definition at line 160 of file PMAlgTrackMaker_module.cc.

std::vector<TH1F*> trkf::PMAlgTrackMaker::fAdcInRejectedPoints
private

Definition at line 160 of file PMAlgTrackMaker_module.cc.

art::InputTag trkf::PMAlgTrackMaker::fCluModuleLabel
private

Definition at line 140 of file PMAlgTrackMaker_module.cc.

art::InputTag trkf::PMAlgTrackMaker::fEmModuleLabel
private

Definition at line 141 of file PMAlgTrackMaker_module.cc.

geo::GeometryCore const* trkf::PMAlgTrackMaker::fGeom
private

Definition at line 157 of file PMAlgTrackMaker_module.cc.

art::InputTag trkf::PMAlgTrackMaker::fHitModuleLabel
private

Definition at line 138 of file PMAlgTrackMaker_module.cc.

pma::ProjectionMatchingAlg::Config trkf::PMAlgTrackMaker::fPmaConfig
private

Definition at line 143 of file PMAlgTrackMaker_module.cc.

pma::PMAlgStitching::Config trkf::PMAlgTrackMaker::fPmaStitchConfig
private

Definition at line 147 of file PMAlgTrackMaker_module.cc.

pma::PMAlgCosmicTagger::Config trkf::PMAlgTrackMaker::fPmaTaggingConfig
private

Definition at line 145 of file PMAlgTrackMaker_module.cc.

pma::PMAlgTracker::Config trkf::PMAlgTrackMaker::fPmaTrackerConfig
private

Definition at line 144 of file PMAlgTrackMaker_module.cc.

pma::PMAlgVertexing::Config trkf::PMAlgTrackMaker::fPmaVtxConfig
private

Definition at line 146 of file PMAlgTrackMaker_module.cc.

bool trkf::PMAlgTrackMaker::fSaveOnlyBranchingVtx
private

Definition at line 149 of file PMAlgTrackMaker_module.cc.

bool trkf::PMAlgTrackMaker::fSavePmaNodes
private

Definition at line 150 of file PMAlgTrackMaker_module.cc.

art::InputTag trkf::PMAlgTrackMaker::fWireModuleLabel
private

Definition at line 139 of file PMAlgTrackMaker_module.cc.

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

Definition at line 153 of file PMAlgTrackMaker_module.cc.

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

Definition at line 154 of file PMAlgTrackMaker_module.cc.


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