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>>();
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>>();
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,
332 auto outputPFAssn = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
335 if (
p_().options().trackFromPF())
337 std::make_unique<art::FindManyP<recob::Track>>(inputPFParticle, e,
pfParticleInputTag);
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) {
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));
398 for (
auto const& trhit : outHits) {
401 outputHitsMeta->addSingle(aptr, trhit,
metadata);
402 outputHits->addSingle(aptr, trhit);
410 if (
p_().options().showerFromPF()) {
413 if (showers.size() == 0)
continue;
414 auto const& pfClustersAssn =
416 auto const& clHitsAssn =
418 std::vector<art::Ptr<recob::Hit>> inHits;
419 for (
auto itpf = pfClustersAssn.begin(); itpf != pfClustersAssn.end(); ++itpf) {
420 if (itpf->first == pPF) {
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));
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));
469 outputHitSpacePointAssn->addSingle(trhit, apsp);
483 if (
p_().
options().produceSpacePoints()) {
485 e.put(
std::move(outputHitSpacePointAssn));
494 if (
p_().options().pFromCalo()) {
498 if (
p_().options().idFromCollection()) {
502 for (
unsigned int iTrack = 0; iTrack < inputTracks->size(); ++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));
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));
556 outputHitSpacePointAssn->addSingle(trhit, apsp);
566 if (
p_().
options().produceSpacePoints()) {
568 e.put(
std::move(outputHitSpacePointAssn));
const TVector3 & ShowerStart() const
Trajectory_t const & Trajectory() const
Returns the plain trajectory of this object.
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
ProductID getProductID(std::string const &instance_name="") const
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
art::InputTag pidInputTag
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >> Point_t
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
art::InputTag pfParticleInputTag
art::InputTag caloInputTag
trkf::TrackKalmanFitter kalmanFitter
std::unique_ptr< art::FindManyP< recob::Vertex > > assocVertices
const_iterator begin() const
double setMomValue(art::Ptr< recob::Track > ptrack, const std::unique_ptr< art::FindManyP< anab::Calorimetry >> &trackCalo, const double pMC, const int pId) const
EDProductGetter const * productGetter(ProductID const pid) const
int setPId(const unsigned int iTrack, const std::unique_ptr< art::FindManyP< anab::ParticleID >> &trackId, const int pfPid=0) const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
art::InputTag trackInputTag
art::InputTag showerInputTag
std::unique_ptr< art::FindManyP< anab::ParticleID > > trackId
const TVector3 & Direction() const
const TLorentzVector & Momentum() const
const_iterator end() 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
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