30 #include "cetlib_except/exception.h" 109 ,
fKFAlg(pset.get<
fhicl::ParameterSet>(
"KalmanFilterAlg"))
120 produces<std::vector<recob::Track> >();
121 produces<std::vector<recob::SpacePoint> >();
122 produces<art::Assns<recob::Track, recob::Hit> >();
123 produces<art::Assns<recob::Track, recob::SpacePoint> >();
124 produces<art::Assns<recob::SpacePoint, recob::Hit> >();
129 <<
"TrackKalmanCheater configured with the following parameters:\n" 172 fHIncChisq = dir.
make<TH1F>(
"IncChisq",
"Incremental Chisquare", 100, 0., 20.);
173 fHPull = dir.
make<TH1F>(
"Pull",
"Hit Pull", 100, -10., 10.);
194 std::unique_ptr<std::vector<recob::Track> > tracks(
new std::vector<recob::Track>);
201 std::unique_ptr<std::vector<recob::SpacePoint> > spts(
new std::vector<recob::SpacePoint>);
206 std::deque<KGTrack> kalman_tracks;
234 int nclus = clusterh->size();
236 for(
int i = 0; i < nclus; ++i) {
238 std::vector< art::Ptr<recob::Hit> > clushits = fm.at(i);
239 int nhits = clushits.size();
243 ihit != clushits.end(); ++ihit) {
256 int nhits = hith->size();
259 for(
int i = 0; i < nhits; ++i)
266 std::map<int, art::PtrVector<recob::Hit> > hitmap;
271 ihit != hits.
end(); ++ihit) {
281 itid != tids.end(); ++itid) {
282 int trackID = itid->trackID;
286 hitmap[trackID].push_back(*ihit);
303 if (!part)
throw cet::exception(
"TrackKalmanCheater") <<
"no particle!\n";
308 int apdg = std::abs(pdg);
317 if(hitmap.count(trackid) != 0)
318 nhit = hitmap[trackid].size();
319 const TLorentzVector& pos = part->
Position();
320 const TLorentzVector& mom = part->
Momentum();
323 log <<
"Trackid=" << trackid
325 <<
", status=" << stat
326 <<
", NHit=" << nhit <<
"\n" 327 <<
" x = " << pos.X()
328 <<
", y = " << pos.Y()
329 <<
", z = " << pos.Z() <<
"\n" 330 <<
" px= " << mom.Px()
331 <<
", py= " << mom.Py()
332 <<
", pz= " << mom.Pz() <<
"\n";
338 double px = mom.Px();
339 double py = mom.Py();
340 double pz = mom.Pz();
341 double p = std::sqrt(px*px + py*py + pz*pz);
343 if(nhit > 0 && pz != 0.) {
345 if (trackhits.
empty())
346 throw cet::exception(
"TrackKalmanCheater") <<
"No hits in track\n";
350 std::shared_ptr<const Surface> psurf(
new SurfYZPlane(0., y, z, 0.));
363 cont.
fill(trackhits, -1);
368 std::vector<unsigned int> planehits(3, 0);
370 ih != trackhits.
end(); ++ih) {
374 if (plane >= planehits.size()) {
375 throw cet::exception(
"TrackKalmanCheater") <<
"plane " << plane <<
"...\n"; }
378 unsigned int prefplane = 0;
379 for(
unsigned int i=0; i<planehits.size(); ++i) {
380 if(planehits[i] > planehits[prefplane])
384 log <<
"Preferred plane = " << prefplane <<
"\n";
399 kalman_tracks.push_back(trg);
403 log << (ok?
"Build track succeeded.":
"Build track failed.") <<
"\n";
417 k != kalman_tracks.end(); ++k) {
422 const std::multimap<double, KHitTrack>& trackmap = trg.
getTrackMap();
424 ih != trackmap.end(); ++ih) {
426 const std::shared_ptr<const KHitBase>&
hit = trh.
getHit();
427 double chisq = hit->getChisq();
440 tracks->reserve(kalman_tracks.size());
442 k != kalman_tracks.end(); ++k) {
443 const KGTrack& kalman_track = *k;
448 kalman_track.
fillTrack(tracks->back(), tracks->size() - 1);
453 std::vector<unsigned int> hittpindex;
454 kalman_track.
fillHits(hits, hittpindex);
459 int nspt = spts->size();
469 for(
unsigned int ispt = nspt; ispt < spts->size(); ++ispt) {
471 art::ProductID sptid = getProductID<std::vector<recob::SpacePoint> >();
489 evt.
put(std::move(tracks));
490 evt.
put(std::move(spts));
491 evt.
put(std::move(th_assn));
492 evt.
put(std::move(tsp_assn));
493 evt.
put(std::move(sph_assn));
501 <<
"TrackKalmanCheater statistics:\n" 502 <<
" Number of events = " <<
fNumEvent <<
"\n" 503 <<
" Number of tracks created = " <<
fNumTrack;
void reserve(size_type n)
TrackDirection
Track direction enum.
const std::shared_ptr< const KHitBase > & getHit() const
Measurement.
const TLorentzVector & Position(const int i=0) const
Propagate to PropYZPlane surface.
void fillTrack(recob::Track &track, int id) const
Fill a recob::Track.
void fillHits(art::PtrVector< recob::Hit > &hits, std::vector< unsigned int > &hittpindex) const
Fill a PtrVector of Hits.
A KHitContainer for KHitWireX type measurements.
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fClusterModuleLabel
Clustered Hits.
geo::WireID WireID() const
Initial tdc tick for hit.
Planar surface parallel to x-axis.
Declaration of signal hit object.
list_type::const_iterator const_iterator
bool fitMomentum(const KGTrack &trg, const Propagator *prop, KETrack &tremom) const
Estimate track momentum using either range or multiple scattering.
EDProductGetter const * productGetter(ProductID const) const
KalmanFilterAlg fKFAlg
Kalman filter algorithm.
const KVector< N >::type & getResVector() const
Residual vector.
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
const std::multimap< double, KHitTrack > & getTrackMap() const
KHitTrack collection, indexed by path distance.
int fNumEvent
Number of events seen.
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
virtual void beginJob()
Begin job method.
std::string fHitModuleLabel
Unclustered Hits.
virtual ~TrackKalmanCheater()
Destructor.
ProductID put(std::unique_ptr< PROD > &&product)
bool fUseClusterHits
Use cluster hits or all hits?
void fillSpacePoints(std::vector< recob::SpacePoint > &spts, std::multimap< double, KHitTrack > const &trackMap) const
Fill a collection of space points.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
TrackKalmanCheater(fhicl::ParameterSet const &pset)
const KSymMatrix< N >::type & getResError() const
Residual error matrix.
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
Kalman filter measurement class template.
T get(std::string const &key) const
void reconfigure(const fhicl::ParameterSet &pset)
Reconfigure method.
virtual void produce(art::Event &e)
bool updateMomentum(const KETrack &tremom, const Propagator *prop, KGTrack &trg) const
Set track momentum at each track surface.
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane) override
Fill container.
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
bool smoothTrackIter(int niter, KGTrack &trg, const Propagator *prop) const
Iteratively smooth a track.
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
PlaneID_t Plane
Index of the plane within its TPC.
Declaration of cluster object.
Provides recob::Track data product.
Detector simulation of raw signals on wires.
void reconfigure(const fhicl::ParameterSet &pset)
data_t::const_iterator const_iterator
T * make(ARGS...args) const
int fNumTrack
Number of tracks produced.
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
virtual void reconfigure(fhicl::ParameterSet const &pset)
void setPlane(int plane)
Set preferred view plane.
const TLorentzVector & Momentum(const int i=0) const
bool fHist
Make histograms.
SpacePointAlg fSpacePointAlg
Space point algorithm.
bool buildTrack(const KTrack &trk, KGTrack &trg, const Propagator *prop, const Propagator::PropDirection dir, KHitContainer &hits, bool linear) const
Make a new track.
TH1F * fHIncChisq
Incremental chisquare.
virtual void endJob()
End job method.
const sim::ParticleList & ParticleList()
2D representation of charge deposited in the TDC/wire plane
const std::multimap< double, KHitTrack > TrackMap() const
double fMaxTcut
Maximum delta ray energy in MeV for restricted dE/dx.
Algorithm for generating space points from hits.
art framework interface to geometry description
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
cet::coded_exception< error, detail::translate > exception
const Propagator * fProp
Propagator.