46 #include "art_root_io/TFileDirectory.h" 47 #include "art_root_io/TFileService.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" 179 art::TFileDirectory
dir = tfs->mkdir(
"hitkalman",
"Track3DKalmanHit histograms");
181 fHIncChisq = dir.make<TH1F>(
"IncChisq",
"Incremental Chisquare", 100, 0., 20.);
182 fHPull = dir.make<TH1F>(
"Pull",
"Hit Pull", 100, -10., 10.);
192 auto tracks = std::make_unique<std::vector<recob::Track>>();
193 auto th_assn = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
194 auto thm_assn = std::make_unique<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta>>();
195 auto tsp_assn = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
196 auto pfPartTrack_assns = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
197 auto spts = std::make_unique<std::vector<recob::SpacePoint>>();
198 auto sph_assn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
224 evt.
put(std::move(tracks));
225 evt.
put(std::move(spts));
226 evt.
put(std::move(th_assn));
227 evt.
put(std::move(thm_assn));
228 evt.
put(std::move(tsp_assn));
229 evt.
put(std::move(sph_assn));
230 evt.
put(std::move(pfPartTrack_assns));
237 mf::LogInfo(
"Track3DKalmanHit") <<
"Track3DKalmanHit statistics:\n" 238 <<
" Number of events = " <<
fNumEvent <<
"\n";
268 if (!clusterh.
isValid())
return hits;
272 for (
size_t i = 0; i < clusterh->size(); ++i) {
273 std::vector<art::Ptr<recob::Hit>> clushits = hitsbycluster.at(i);
274 hits.
insert(hits.
end(), clushits.begin(), clushits.end());
286 if (!hith.
isValid())
return hits;
287 size_t nhits = hith->size();
290 for (
size_t i = 0; i < nhits; ++i) {
308 if (!pfParticleHandle.
isValid())
return inputs;
314 if (!clusterHandle.
isValid())
return inputs;
326 inputs.reserve(pfParticleHandle->size());
329 for (
size_t partIdx = 0; partIdx < pfParticleHandle->size(); partIdx++) {
332 inputs.emplace_back();
339 std::vector<art::Ptr<recob::Cluster>> clusterVec = clusterAssns.at(partIdx);
341 for (
auto const&
cluster : clusterVec) {
342 std::vector<art::Ptr<recob::Hit>> hitVec = clusterHitAssns.at(
cluster.key());
343 hits.insert(hits.end(), hitVec.begin(), hitVec.end());
349 std::vector<art::Ptr<recob::Seed>> seedVec = seedAssns.at(partIdx);
350 seeds.
insert(seeds.
end(), seedVec.begin(), seedVec.end());
353 for (
size_t seedIdx = 0; seedIdx < seedVec.size(); ++seedIdx) {
354 std::vector<art::Ptr<recob::Hit>> seedHitVec;
357 seedHitVec = seedHitAssns.at(seedIdx);
362 kalman_input.
seedhits.emplace_back();
364 seedhits.
insert(seedhits.
end(), seedHitVec.begin(), seedHitVec.end());
374 std::vector<KalmanOutput>
const& outputs,
376 std::vector<recob::Track>& tracks,
377 std::vector<recob::SpacePoint>& spts,
384 if (outputs.size() != inputs.size())
return;
386 size_t tracksSize(0);
387 for (
auto const& kalman_output : outputs) {
388 tracksSize += kalman_output.tracks.size();
390 tracks.reserve(tracksSize);
392 auto const tid = evt.
getProductID<std::vector<recob::Track>>();
395 auto const spacepointId = evt.
getProductID<std::vector<recob::SpacePoint>>();
398 for (
size_t i = 0; i < outputs.size(); ++i) {
400 const std::deque<KGTrack>& kalman_tracks = outputs[i].tracks;
402 for (
auto const& kalman_track : kalman_tracks) {
406 kalman_track.fillTrack(detProp, track, tracks.size());
409 tracks.emplace_back(std::move(track));
414 std::vector<unsigned int> hittpindex;
415 kalman_track.fillHits(trhits, hittpindex);
416 if (hittpindex.back() >= numtrajpts) {
418 <<
"Last hit corresponds to trajectory point index " << hittpindex.back()
419 <<
" while the number of trajectory points is " << numtrajpts <<
'\n';
423 auto nspt = spts.size();
426 std::vector<art::Ptr<recob::SpacePoint>> sptvec;
427 for (
auto ispt = nspt; ispt < spts.size(); ++ispt) {
428 sptvec.emplace_back(spacepointId, ispt, getter);
432 for (
auto const& sphit : sphits) {
433 sph_assn.
addSingle(sptvec.back(), sphit);
440 for (
size_t h = 0; h < trhits.
size(); ++h) {
443 thm_assn.
addSingle(aptr, trhits[h], metadata);
447 for (
auto const& spt : sptvec) {
463 for (
auto const& output : outputs) {
464 const std::deque<KGTrack>& kalman_tracks = output.tracks;
465 for (
size_t i = 0; i < kalman_tracks.size(); ++i) {
466 const KGTrack& trg = kalman_tracks[i];
468 const std::multimap<double, KHitTrack>& trackmap = trg.
getTrackMap();
470 ih != trackmap.end();
473 const std::shared_ptr<const KHitBase>&
hit = trh.
getHit();
474 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.
Declaration of signal hit object.
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
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
const KSymMatrix< N >::type & getResError() const
Residual error matrix.
Hits getClusteredHits(const art::Event &evt) const
Fill a collection using clustered hits.
EDProductGetter const * productGetter(ProductID const pid) const
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
Kalman filter measurement class template.
Hits getAllHits(const art::Event &evt) const
If both UseClusteredHits and UsePFParticles is false use this method to fill in hits.
Provides recob::Track data product.
void fillHistograms(std::vector< KalmanOutput > &outputs)
Fill Histograms method.
Declaration of cluster object.
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)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
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)
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.