46 #include "art_root_io/TFileDirectory.h" 47 #include "art_root_io/TFileService.h" 49 #include "canvas/Persistency/Common/FindManyP.h" 92 const std::vector<KalmanOutput>&
outputs,
94 std::vector<recob::Track>&
tracks,
95 std::vector<recob::SpacePoint>& spts,
143 fHist = pset.get<
bool>(
"Hist");
150 if (fUseClusterHits && fUsePFParticleHits) {
152 <<
"Using input from both clustered and PFParticle hits.\n";
155 produces<std::vector<recob::Track>>();
156 produces<std::vector<recob::SpacePoint>>();
159 produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
160 produces<art::Assns<recob::Track, recob::SpacePoint>>();
161 produces<art::Assns<recob::SpacePoint, recob::Hit>>();
162 produces<art::Assns<recob::PFParticle, recob::Track>>();
166 mf::LogInfo(
"Track3DKalmanHit") <<
"Track3DKalmanHit configured with the following parameters:\n" 167 <<
" UseClusterHits = " << fUseClusterHits <<
"\n" 168 <<
" HitModuleLabel = " << fHitModuleLabel <<
"\n" 180 art::TFileDirectory
dir = tfs->mkdir(
"hitkalman",
"Track3DKalmanHit histograms");
182 fHIncChisq = dir.make<TH1F>(
"IncChisq",
"Incremental Chisquare", 100, 0., 20.);
183 fHPull = dir.make<TH1F>(
"Pull",
"Hit Pull", 100, -10., 10.);
194 auto tracks = std::make_unique<std::vector<recob::Track>>();
195 auto th_assn = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
196 auto thm_assn = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
197 auto tsp_assn = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
198 auto pfPartTrack_assns = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
199 auto spts = std::make_unique<std::vector<recob::SpacePoint>>();
200 auto sph_assn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
240 mf::LogInfo(
"Track3DKalmanHit") <<
"Track3DKalmanHit statistics:\n" 241 <<
" Number of events = " <<
fNumEvent <<
"\n";
274 if (!clusterh.
isValid())
return hits;
278 for (
size_t i = 0; i < clusterh->size(); ++i) {
279 std::vector<art::Ptr<recob::Hit>> clushits = hitsbycluster.at(i);
280 hits.
insert(hits.
end(), clushits.begin(), clushits.end());
293 if (!hith.
isValid())
return hits;
294 size_t nhits = hith->size();
297 for (
size_t i = 0; i < nhits; ++i) {
316 if (!pfParticleHandle.
isValid())
return inputs;
322 if (!clusterHandle.
isValid())
return inputs;
334 inputs.reserve(pfParticleHandle->size());
337 for (
size_t partIdx = 0; partIdx < pfParticleHandle->size(); partIdx++) {
340 inputs.emplace_back();
347 std::vector<art::Ptr<recob::Cluster>> clusterVec = clusterAssns.
at(partIdx);
349 for (
auto const&
cluster : clusterVec) {
350 std::vector<art::Ptr<recob::Hit>> hitVec = clusterHitAssns.at(
cluster.key());
351 hits.insert(hits.end(), hitVec.begin(), hitVec.end());
357 std::vector<art::Ptr<recob::Seed>> seedVec = seedAssns.
at(partIdx);
358 seeds.
insert(seeds.
end(), seedVec.begin(), seedVec.end());
361 for (
size_t seedIdx = 0; seedIdx < seedVec.size(); ++seedIdx) {
362 std::vector<art::Ptr<recob::Hit>> seedHitVec;
365 seedHitVec = seedHitAssns.at(seedIdx);
370 kalman_input.
seedhits.emplace_back();
372 seedhits.
insert(seedhits.
end(), seedHitVec.begin(), seedHitVec.end());
383 std::vector<KalmanOutput>
const&
outputs,
385 std::vector<recob::Track>&
tracks,
386 std::vector<recob::SpacePoint>& spts,
393 if (outputs.size() != inputs.size())
return;
395 size_t tracksSize(0);
396 for (
auto const& kalman_output : outputs) {
397 tracksSize += kalman_output.tracks.size();
399 tracks.reserve(tracksSize);
401 auto const tid = evt.
getProductID<std::vector<recob::Track>>();
404 auto const spacepointId = evt.
getProductID<std::vector<recob::SpacePoint>>();
407 for (
size_t i = 0; i < outputs.size(); ++i) {
409 const std::deque<KGTrack>& kalman_tracks = outputs[i].tracks;
411 for (
auto const& kalman_track : kalman_tracks) {
415 kalman_track.fillTrack(detProp, track, tracks.size());
423 std::vector<unsigned int> hittpindex;
424 kalman_track.fillHits(trhits, hittpindex);
425 if (hittpindex.back() >= numtrajpts) {
427 <<
"Last hit corresponds to trajectory point index " << hittpindex.back()
428 <<
" while the number of trajectory points is " << numtrajpts <<
'\n';
432 auto nspt = spts.size();
435 std::vector<art::Ptr<recob::SpacePoint>> sptvec;
436 for (
auto ispt = nspt; ispt < spts.size(); ++ispt) {
437 sptvec.emplace_back(spacepointId, ispt, getter);
441 for (
auto const& sphit : sphits) {
442 sph_assn.
addSingle(sptvec.back(), sphit);
449 for (
size_t h = 0;
h < trhits.
size(); ++
h) {
452 thm_assn.
addSingle(aptr, trhits[h], metadata);
456 for (
auto const& spt : sptvec) {
473 for (
auto const&
output : outputs) {
474 const std::deque<KGTrack>& kalman_tracks =
output.tracks;
475 for (
size_t i = 0; i < kalman_tracks.size(); ++i) {
476 const KGTrack& trg = kalman_tracks[i];
478 const std::multimap<double, KHitTrack>& trackmap = trg.
getTrackMap();
480 ih != trackmap.end();
483 const std::shared_ptr<const KHitBase>&
hit = trh.
getHit();
484 double chisq = hit->getChisq();
void reserve(size_type n)
bool fUseClusterHits
Use clustered hits as input.
const std::shared_ptr< const KHitBase > & getHit() const
Measurement.
std::string fHitModuleLabel
Unclustered Hits.
Track3DKalmanHitAlg fTKHAlg
Track3DKalmanHit algorithm.
bool fUsePFParticleSeeds
Use PFParticle seeds.
ProductID getProductID(std::string const &instance_name="") const
KalmanInputs getInput(const art::Event &evt) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void beginJob() override
Begin job method.
EDProducer(fhicl::ParameterSet const &pset)
std::string fPFParticleModuleLabel
PFParticle label.
void produces(std::string const &instanceName={}, Persistable const persistable=Persistable::Yes)
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
bool fHist
Make histograms.
std::vector< trkf::KalmanOutput > makeTracks(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, KalmanInputs &kalman_inputs)
std::string fClusterModuleLabel
Clustered Hits.
Cluster finding and building.
Track3DKalmanHit(fhicl::ParameterSet const &pset)
const KVector< N >::type & getResVector() const
Residual vector.
Track3DKalmanHit Algorithm.
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
SpacePointAlg fSpacePointAlg
Space point algorithm.
const std::multimap< double, KHitTrack > & getTrackMap() const
KHitTrack collection, indexed by path distance.
bool isValid() const noexcept
const KSymMatrix< N >::type & getResError() const
Residual error matrix.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Hits getClusteredHits(const art::Event &evt) const
Fill a collection using clustered hits.
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
Kalman filter measurement class template.
EDProductGetter const * productGetter(ProductID const pid) const
Hits getAllHits(const art::Event &evt) const
If both UseClusteredHits and UsePFParticles is false use this method to fill in hits.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
reference at(size_type n)
void fillHistograms(std::vector< KalmanOutput > &outputs)
Fill Histograms method.
void fillSpacePoints(detinfo::DetectorPropertiesData const &detProp, std::vector< recob::SpacePoint > &spts, std::multimap< double, KHitTrack > const &trackMap) const
Fill a collection of space points.
Detector simulation of raw signals on wires.
int fNumEvent
Number of events seen.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< TrajPoint > seeds
iterator insert(iterator position, Ptr< U > const &p)
Declaration of signal hit object.
bool fUsePFParticleHits
Use PFParticle hits as input.
void produce(art::Event &e) override
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Provides recob::Track data product.
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
2D representation of charge deposited in the TDC/wire plane
Algorithm for generating space points from hits.
void createOutputs(const art::Event &evt, detinfo::DetectorPropertiesData const &detProp, const std::vector< KalmanOutput > &outputs, const KalmanInputs &inputs, std::vector< recob::Track > &tracks, std::vector< recob::SpacePoint > &spts, art::Assns< recob::Track, recob::Hit > &th_assn, art::Assns< recob::Track, recob::Hit, recob::TrackHitMeta > &thm_assn, art::Assns< recob::Track, recob::SpacePoint > &tsp_assn, art::Assns< recob::SpacePoint, recob::Hit > &sph_assn, art::Assns< recob::PFParticle, recob::Track > &pfPartTrack_assns)
std::vector< KalmanInput > KalmanInputs
void endJob() override
End job method.
TH1F * fHIncChisq
Incremental chisquare.
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
KalmanInputs getPFParticleStuff(const art::Event &evt) const
If UsePFParticles is true use this method to fill in hits.