204 auto outputTracks = std::make_unique<std::vector<recob::Track>>();
205 auto outputHitsMeta =
206 std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
207 auto outputHits = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
208 auto outputHitInfo = std::make_unique<std::vector<std::vector<recob::TrackFitHitInfo>>>();
211 auto outputTTjTAssn = std::make_unique<art::Assns<recob::TrackTrajectory, recob::Track>>();
212 auto outputTjTAssn = std::make_unique<art::Assns<recob::Trajectory, recob::Track>>();
214 auto const tid =
e.getProductID<std::vector<recob::Track>>();
215 auto const tidgetter =
e.productGetter(tid);
217 auto outputSpacePoints = std::make_unique<std::vector<recob::SpacePoint>>();
218 auto outputHitSpacePointAssn = std::make_unique<art::Assns<recob::Hit, recob::SpacePoint>>();
219 auto const spid =
e.getProductID<std::vector<recob::SpacePoint>>();
220 auto const spidgetter =
e.productGetter(spid);
226 art::ValidHandle<std::vector<sim::MCTrack>> simTracks =
228 for (
unsigned int iMC = 0; iMC < simTracks->size(); ++iMC) {
231 if (mctrack.
PdgCode() != 13)
continue;
232 if (mctrack.
Process() !=
"primary")
continue;
234 mcdir = TVector3(mctrack.
Start().
Momentum().X() * 0.001 / pMC,
242 unsigned int nTrajs = 0;
244 art::Handle<std::vector<recob::TrackTrajectory>> inputTrackTrajectoryH;
245 art::Handle<std::vector<recob::Trajectory>> inputTrajectoryH;
246 const std::vector<recob::TrackTrajectory>* trackTrajectoryVec =
nullptr;
247 const std::vector<recob::Trajectory>* trajectoryVec =
nullptr;
248 const art::Assns<recob::TrackTrajectory, recob::Hit>* trackTrajectoryHitsAssn =
nullptr;
249 const art::Assns<recob::Trajectory, recob::Hit>* trajectoryHitsAssn =
nullptr;
253 throw cet::exception(
"KalmanFilterTrajectoryFitter")
254 <<
"Cannot find recob::TrackTrajectory art::Handle with inputTag " <<
trajectoryInputTag;
255 trackTrajectoryVec = inputTrackTrajectoryH.product();
256 trackTrajectoryHitsAssn =
259 nTrajs = trackTrajectoryVec->size();
264 throw cet::exception(
"KalmanFilterTrajectoryFitter")
266 trajectoryVec = inputTrajectoryH.product();
269 nTrajs = trajectoryVec->size();
272 auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
e);
274 for (
unsigned int iTraj = 0; iTraj < nTrajs; ++iTraj) {
277 (
isTT ? trackTrajectoryVec->at(iTraj) :
279 std::vector<recob::TrajectoryPointFlags>()));
282 std::vector<art::Ptr<recob::Hit>> inHits;
284 for (
auto it = trackTrajectoryHitsAssn->begin(); it != trackTrajectoryHitsAssn->end(); ++it) {
285 if (it->first.key() == iTraj)
286 inHits.push_back(it->second);
287 else if (inHits.size() > 0)
292 for (
auto it = trajectoryHitsAssn->begin(); it != trajectoryHitsAssn->end(); ++it) {
293 if (it->first.key() == iTraj)
294 inHits.push_back(it->second);
295 else if (inHits.size() > 0)
301 const bool flipDir =
setDirFlip(&inTraj, mcdir);
304 std::vector<art::Ptr<recob::Hit>> outHits;
319 if (!fitok)
continue;
321 if (
p_().
options().keepInputTrajectoryPoints()) {
325 outputTracks->emplace_back(std::move(outTrack));
326 art::Ptr<recob::Track> aptr(tid, outputTracks->size() - 1, tidgetter);
328 for (
auto const& trhit : outHits) {
331 outputHitsMeta->addSingle(aptr, trhit, metadata);
332 outputHits->addSingle(aptr, trhit);
333 if (
p_().
options().produceSpacePoints() && outputTracks->back().HasValidPoint(ip)) {
334 auto& tp = outputTracks->back().Trajectory().LocationAtPoint(ip);
335 double fXYZ[3] = {tp.X(), tp.Y(), tp.Z()};
336 double fErrXYZ[6] = {0};
338 outputSpacePoints->emplace_back(std::move(sp));
339 art::Ptr<recob::SpacePoint> apsp(spid, outputSpacePoints->size() - 1, spidgetter);
340 outputHitSpacePointAssn->addSingle(trhit, apsp);
346 outputTTjTAssn->addSingle(art::Ptr<recob::TrackTrajectory>(inputTrackTrajectoryH, iTraj),
350 outputTjTAssn->addSingle(art::Ptr<recob::Trajectory>(inputTrajectoryH, iTraj), aptr);
353 e.put(std::move(outputTracks));
354 e.put(std::move(outputHitsMeta));
355 e.put(std::move(outputHits));
356 if (
p_().
options().produceTrackFitHitInfo()) {
e.put(std::move(outputHitInfo)); }
357 if (
p_().
options().produceSpacePoints()) {
358 e.put(std::move(outputSpacePoints));
359 e.put(std::move(outputHitSpacePointAssn));
362 e.put(std::move(outputTTjTAssn));
364 e.put(std::move(outputTjTAssn));
trkf::TrackKalmanFitter kalmanFitter
void restoreInputPoints(const recob::TrackTrajectory &track, const std::vector< art::Ptr< recob::Hit >> &inHits, recob::Track &outTrack, std::vector< art::Ptr< recob::Hit >> &outHits) const
void initTrackFitInfos()
initialize the output vector of TrackFitHitInfos
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
A trajectory in space reconstructed from hits.
double setMomValue(const recob::TrackTrajectory *ptraj, const double pMC, const int pId) const
const TLorentzVector & Momentum() const
std::vector< recob::TrackFitHitInfo > trackFitHitInfos()
get the output vector of TrackFitHitInfos by releasing and moving
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 MCStep & Start() const
bool setDirFlip(const recob::TrackTrajectory *ptraj, TVector3 &mcdir) const
art::InputTag trajectoryInputTag
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: