23 #include "cetlib_except/exception.h"
33 if (!
isValid())
throw cet::exception(
"KGTrack") <<
"Starting track is not valid.\n";
46 if (!
isValid())
throw cet::exception(
"KGTrack") <<
"Ending track is not valid.\n";
59 if (!
isValid())
throw cet::exception(
"KGTrack") <<
"Starting track is not valid.\n";
72 if (!
isValid())
throw cet::exception(
"KGTrack") <<
"Ending track is not valid.\n";
83 if (!trh.
isValid())
throw cet::exception(
"KGTrack") <<
"Adding invalid track to KGTrack.\n";
96 std::multimap<double, KHitTrack> newmap;
102 for (std::multimap<double, KHitTrack>::iterator i =
fTrackMap.begin(); i !=
fTrackMap.end();
111 newmap.insert(std::make_pair(s, trh));
137 std::vector<recob::tracking::Point_t> xyz;
138 std::vector<recob::tracking::Vector_t> pxpypz;
139 std::vector<recob::tracking::SMatrixSym55> cov;
140 std::vector<recob::TrajectoryPointFlags> outFlags;
151 for (std::multimap<double, KHitTrack>::const_iterator itr =
fTrackMap.begin();
160 xyz.push_back({pos[0], pos[1], pos[2]});
167 double p = std::sqrt(mom[0] * mom[0] + mom[1] * mom[1] + mom[2] * mom[2]);
168 if (p == 0.)
throw cet::exception(
"KGTrack") << __func__ <<
": null momentum\n";
169 pxpypz.push_back({mom[0], mom[1], mom[2]});
182 const std::shared_ptr<const Surface> psurf(
183 new SurfXYZPlane(pos[0], pos[1], pos[2], mom[0], mom[1], mom[2]));
186 if (!dist)
throw cet::exception(
"KGTrack") << __func__ <<
": error propagation failed\n";
187 for (
int i = 0; i < 5; ++i) {
188 for (
int j = 0; j < 5; ++j)
195 cov.push_back(covar);
203 if (xyz.size() >= 2) {
211 std::move(cov.front()),
212 std::move(cov.back()),
224 KGTrack::fillHits(art::PtrVector<recob::Hit>& hits, std::vector<unsigned int>& hittpindex)
const
226 hits.reserve(hits.size() +
fTrackMap.size());
231 for (std::multimap<double, KHitTrack>::const_iterator it =
fTrackMap.begin();
237 const std::shared_ptr<const KHitBase>&
hit = track.
getHit();
238 if (
const KHitWireX* phit = dynamic_cast<const KHitWireX*>(&*hit)) {
239 const art::Ptr<recob::Hit> prhit = phit->getHit();
240 if (!prhit.isNull()) {
241 hits.push_back(prhit);
242 hittpindex.push_back(counter - 1);
245 else if (
const KHitWireLine* phit = dynamic_cast<const KHitWireLine*>(&*hit)) {
246 const art::Ptr<recob::Hit> prhit = phit->getHit();
247 if (!prhit.isNull()) {
248 hits.push_back(prhit);
249 hittpindex.push_back(counter - 1);
264 double oldxyz[3] = {0., 0., 0.};
268 double s = ele.first;
274 double tmom = std::sqrt(mom[0] * mom[0] + mom[1] * mom[1] + mom[2] * mom[2]);
281 double dx = xyz[0] - oldxyz[0];
282 double dy = xyz[1] - oldxyz[1];
283 double dz = xyz[2] - oldxyz[2];
284 len += std::sqrt(dx * dx + dy * dy + dz * dz);
288 std::ios_base::fmtflags f = out.flags();
289 out <<
"State " << std::setw(4) << n <<
", path=" << std::setw(8) << std::fixed
290 << std::setprecision(2) << s <<
", length=" << std::setw(8) << len
291 <<
", x=" << std::setw(8) << xyz[0] <<
", y=" << std::setw(8) << xyz[1]
292 <<
", z=" << std::setw(8) << xyz[2] <<
", dx=" << std::setw(8) << mom[0]
293 <<
", dy=" << std::setw(8) << mom[1] <<
", dz=" << std::setw(8) << mom[2]
294 <<
", plane=" << std::setw(1) << plane <<
"\n";
311 return trg.
Print(out);
const TrackError & getError() const
Track error matrix.
const std::shared_ptr< const KHitBase > & getHit() const
Measurement.
void fillHits(art::PtrVector< recob::Hit > &hits, std::vector< unsigned int > &hittpindex) const
Fill a PtrVector of Hits.
static constexpr Mask_t makeMask(Flags...flags)
Returns a bit mask with only the specified bit set.
void recalibrate()
Recalibrate track map.
int getMeasPlane() const
Measurement plane index.
const KHitTrack & endTrack() const
Track at end point.
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
Kalman filter wire-time measurement on a SurfWireX surface.
void addTrack(const KHitTrack &trh)
Add track.
process_name use argoneut_mc_hitfinder track
void fillTrack(detinfo::DetectorPropertiesData const &detProp, recob::Track &track, int id) const
Fill a recob::Track.
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
std::ostream & operator<<(std::ostream &out, const KGTrack &trg)
Output operator.
void getPosition(double xyz[3]) const
Get position of track.
double getPath() const
Propagation distance.
Propagate to SurfXYZPlane surface.
std::optional< double > err_prop(KETrack &tre, const std::shared_ptr< const Surface > &psurf, PropDirection dir, bool doDedx, KTrack *ref=0, TrackMatrix *prop_matrix=0) const
Propagate with error, but without noise.
Set of flags pertaining a point of the track.
Provides recob::Track data product.
std::multimap< double, KHitTrack > fTrackMap
KHitTrack collection, indexed by path distance.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
then echo File list $list not found else cat $list while read file do echo $file sed s
void getMomentum(double mom[3]) const
Get momentum vector of track.
std::ostream & Print(std::ostream &out) const
Printout.
Kalman filter wire-time measurement on a SurfWireLine surface.
void setPath(double path)
Set propagation distance.
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
A collection of KHitTracks.
bool isValid() const
Validity flag.
double getChisq() const
Fit chisquare.
const KHitTrack & startTrack() const
Track at start point.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
bool isValid() const
Test if track is valid.