295 auto outputTracks = std::make_unique<std::vector<recob::Track>>();
296 auto outputHitsMeta =
297 std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
298 auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
299 auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo>>>();
301 auto const tid =
e.getProductID<std::vector<recob::Track>>();
302 auto const tidgetter =
e.productGetter(tid);
304 auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
305 auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint>>();
306 auto const spid =
e.getProductID<std::vector<recob::SpacePoint>>();
307 auto const spidgetter =
e.productGetter(spid);
313 art::ValidHandle<std::vector<sim::MCTrack>> simTracks =
315 for (
unsigned int iMC = 0; iMC < simTracks->size(); ++iMC) {
318 if (mctrack.
PdgCode() != 13)
continue;
319 if (mctrack.
Process() !=
"primary")
continue;
321 mcdir = TVector3(mctrack.
Start().
Momentum().X() * 0.001 / pMC,
328 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
e);
332 auto outputPFAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
334 auto inputPFParticle =
e.getValidHandle<std::vector<recob::PFParticle>>(
pfParticleInputTag);
335 if (
p_().options().trackFromPF())
338 if (
p_().options().showerFromPF())
340 std::make_unique<art::FindManyP<recob::Shower>>(inputPFParticle,
e,
showerInputTag);
344 for (
unsigned int iPF = 0; iPF < inputPFParticle->size(); ++iPF) {
346 if (
p_().options().trackFromPF()) {
348 auto const& tkHitsAssn =
350 const std::vector<art::Ptr<recob::Vertex>>& vertices =
assocVertices->at(iPF);
356 for (
unsigned int iTrack = 0; iTrack < tracks.size(); ++iTrack) {
359 art::Ptr<recob::Track> ptrack = tracks[iTrack];
360 const int pId =
setPId(iTrack,
trackId, inputPFParticle->at(iPF).PdgCode());
362 const bool flipDir =
setDirFlip(track, mcdir, &vertices);
365 std::vector<art::Ptr<recob::Hit>> inHits;
366 for (
auto it = tkHitsAssn.begin(); it != tkHitsAssn.end(); ++it) {
367 if (it->first == ptrack)
368 inHits.push_back(it->second);
369 else if (inHits.size() > 0)
374 std::vector<art::Ptr<recob::Hit>> outHits;
389 if (!fitok)
continue;
391 if (
p_().options().keepInputTrajectoryPoints()) {
395 outputTracks->emplace_back(std::move(outTrack));
396 art::Ptr<recob::Track> aptr(tid, outputTracks->size() - 1, tidgetter);
398 for (
auto const& trhit : outHits) {
401 outputHitsMeta->addSingle(aptr, trhit, metadata);
402 outputHits->addSingle(aptr, trhit);
405 outputPFAssn->addSingle(art::Ptr<recob::PFParticle>(inputPFParticle, iPF), aptr);
410 if (
p_().options().showerFromPF()) {
411 art::Ptr<recob::PFParticle> pPF(inputPFParticle, iPF);
412 const std::vector<art::Ptr<recob::Shower>>& showers =
assocShowers->at(iPF);
413 if (showers.size() == 0)
continue;
414 auto const& pfClustersAssn =
415 *e.getValidHandle<art::Assns<recob::PFParticle, recob::Cluster>>(
showerInputTag);
416 auto const& clHitsAssn =
417 *e.getValidHandle<art::Assns<recob::Cluster, recob::Hit>>(
showerInputTag);
418 std::vector<art::Ptr<recob::Hit>> inHits;
419 for (
auto itpf = pfClustersAssn.begin(); itpf != pfClustersAssn.end(); ++itpf) {
420 if (itpf->first == pPF) {
421 art::Ptr<recob::Cluster> clust = itpf->second;
422 for (
auto it = clHitsAssn.begin(); it != clHitsAssn.end(); ++it) {
423 if (it->first == clust) inHits.push_back(it->second);
426 else if (inHits.size() > 0)
429 for (
unsigned int iShower = 0; iShower < showers.size(); ++iShower) {
432 std::vector<art::Ptr<recob::Hit>> outHits;
438 auto pid =
p_().options().pdgId();
439 auto mom =
p_().options().pval();
445 std::vector<recob::TrajectoryPointFlags>(),
452 if (!fitok)
continue;
454 outputTracks->emplace_back(std::move(outTrack));
455 art::Ptr<recob::Track> aptr(tid, outputTracks->size() - 1, tidgetter);
457 for (
auto const& trhit : outHits) {
460 outputHitsMeta->addSingle(aptr, trhit, metadata);
461 outputHits->addSingle(aptr, trhit);
462 if (
p_().
options().produceSpacePoints() && outputTracks->back().HasValidPoint(ip)) {
463 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
464 double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
465 double fErrXYZ[6] = {0};
467 outputSpacePoints->emplace_back(std::move(sp));
468 art::Ptr<recob::SpacePoint> apsp(spid, outputSpacePoints->size() - 1, spidgetter);
469 outputHitSpacePointAssn->addSingle(trhit, apsp);
473 outputPFAssn->addSingle(art::Ptr<recob::PFParticle>(inputPFParticle, iPF), aptr);
478 e.put(std::move(outputTracks));
479 e.put(std::move(outputHitsMeta));
480 e.put(std::move(outputHits));
481 e.put(std::move(outputPFAssn));
482 if (
p_().
options().produceTrackFitHitInfo()) { e.put(std::move(outputHitInfo)); }
483 if (
p_().
options().produceSpacePoints()) {
484 e.put(std::move(outputSpacePoints));
485 e.put(std::move(outputHitSpacePointAssn));
490 art::ValidHandle<std::vector<recob::Track>> inputTracks =
492 auto const& tkHitsAssn = *e.getValidHandle<art::Assns<recob::Track, recob::Hit>>(
trackInputTag);
494 if (
p_().options().pFromCalo()) {
498 if (
p_().options().idFromCollection()) {
502 for (
unsigned int iTrack = 0; iTrack < inputTracks->size(); ++iTrack) {
505 art::Ptr<recob::Track> ptrack(inputTracks, iTrack);
508 const bool flipDir =
setDirFlip(track, mcdir);
511 std::vector<art::Ptr<recob::Hit>> inHits;
512 for (
auto it = tkHitsAssn.begin(); it != tkHitsAssn.end(); ++it) {
513 if (it->first == ptrack)
514 inHits.push_back(it->second);
515 else if (inHits.size() > 0)
520 std::vector<art::Ptr<recob::Hit>> outHits;
535 if (!fitok)
continue;
537 if (
p_().options().keepInputTrajectoryPoints()) {
541 outputTracks->emplace_back(std::move(outTrack));
542 art::Ptr<recob::Track> aptr(tid, outputTracks->size() - 1, tidgetter);
544 for (
auto const& trhit : outHits) {
547 outputHitsMeta->addSingle(aptr, trhit, metadata);
548 outputHits->addSingle(aptr, trhit);
549 if (
p_().
options().produceSpacePoints() && outputTracks->back().HasValidPoint(ip)) {
550 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
551 double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
552 double fErrXYZ[6] = {0};
554 outputSpacePoints->emplace_back(std::move(sp));
555 art::Ptr<recob::SpacePoint> apsp(spid, outputSpacePoints->size() - 1, spidgetter);
556 outputHitSpacePointAssn->addSingle(trhit, apsp);
562 e.put(std::move(outputTracks));
563 e.put(std::move(outputHitsMeta));
564 e.put(std::move(outputHits));
565 if (
p_().
options().produceTrackFitHitInfo()) { e.put(std::move(outputHitInfo)); }
566 if (
p_().
options().produceSpacePoints()) {
567 e.put(std::move(outputSpacePoints));
568 e.put(std::move(outputHitSpacePointAssn));
Trajectory_t const & Trajectory() const
Returns the plain trajectory of this object.
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
ClusterModuleLabel join with tracks
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
const TVector3 & Direction() const
art::InputTag pidInputTag
recob::tracking::SMatrixSym55 SMatrixSym55
bool fitTrack(detinfo::DetectorPropertiesData const &detProp, const recob::TrackTrajectory &traj, int tkID, const SMatrixSym55 &covVtx, const SMatrixSym55 &covEnd, const std::vector< art::Ptr< recob::Hit >> &hits, const double pval, const int pdgid, const bool flipDirection, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit >> &outHits, trkmkr::OptionalOutputs &optionals) const
Fit track starting from TrackTrajectory.
art::InputTag simTrackInputTag
process_name use argoneut_mc_hitfinder track
art::InputTag pfParticleInputTag
art::InputTag caloInputTag
trkf::TrackKalmanFitter kalmanFitter
std::unique_ptr< art::FindManyP< recob::Vertex > > assocVertices
recob::tracking::Point_t Point_t
double setMomValue(art::Ptr< recob::Track > ptrack, const std::unique_ptr< art::FindManyP< anab::Calorimetry >> &trackCalo, const double pMC, const int pId) const
int setPId(const unsigned int iTrack, const std::unique_ptr< art::FindManyP< anab::ParticleID >> &trackId, const int pfPid=0) const
art::InputTag trackInputTag
art::InputTag showerInputTag
std::unique_ptr< art::FindManyP< anab::ParticleID > > trackId
const TLorentzVector & Momentum() const
const SMatrixSym55 & EndCovarianceLocal5D() const
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
std::unique_ptr< art::FindManyP< anab::Calorimetry > > trackCalo
std::unique_ptr< art::FindManyP< recob::Shower > > assocShowers
const std::string & Process() const
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker options
const TVector3 & ShowerStart() const
const MCStep & Start() const
recob::tracking::Vector_t Vector_t
const SMatrixSym55 & VertexCovarianceLocal5D() const
bool setDirFlip(const recob::Track &track, TVector3 &mcdir, const std::vector< art::Ptr< recob::Vertex >> *vertices=0) const
Struct holding optional TrackMaker outputs.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
std::unique_ptr< art::FindManyP< recob::Track > > assocTracks
void restoreInputPoints(const recob::Trajectory &track, const std::vector< art::Ptr< recob::Hit >> &inHits, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit >> &outHits) const