79 virtual void endJob()
override;
91 const std::vector<KalmanOutput> &outputs,
93 std::vector<recob::Track> &tracks,
94 std::vector<recob::SpacePoint> &spts,
136 fTKHAlg(pset.get<
fhicl::ParameterSet>(
"Track3DKalmanHitAlg")),
143 produces<std::vector<recob::Track> >();
144 produces<std::vector<recob::SpacePoint> >();
145 produces<art::Assns<recob::Track, recob::Hit> >();
146 produces<art::Assns<recob::Track, recob::Hit, recob::TrackHitMeta> >();
147 produces<art::Assns<recob::Track, recob::SpacePoint> >();
148 produces<art::Assns<recob::SpacePoint, recob::Hit> >();
149 produces<art::Assns<recob::PFParticle, recob::Track> >();
154 <<
"Track3DKalmanHit configured with the following parameters:\n" 181 <<
"Using input from both clustered and PFParticle hits.\n";
194 fHIncChisq = dir.
make<TH1F>(
"IncChisq",
"Incremental Chisquare", 100, 0., 20.);
195 fHPull = dir.
make<TH1F>(
"Pull",
"Hit Pull", 100, -10., 10.);
205 auto tracks = std::make_unique<std::vector<recob::Track>>();
206 auto th_assn = std::make_unique<art::Assns<recob::Track, recob::Hit>>();
207 auto thm_assn = std::make_unique< art::Assns< recob::Track, recob::Hit, recob::TrackHitMeta > >();
208 auto tsp_assn = std::make_unique<art::Assns<recob::Track, recob::SpacePoint>>();
209 auto pfPartTrack_assns = std::make_unique<art::Assns<recob::PFParticle, recob::Track>>();
210 auto spts = std::make_unique<std::vector<recob::SpacePoint>>();
211 auto sph_assn = std::make_unique<art::Assns<recob::SpacePoint, recob::Hit>>();
222 createOutputs(evt, outputs, inputs, *tracks, *spts, *th_assn, *thm_assn, *tsp_assn, *sph_assn, *pfPartTrack_assns);
226 evt.
put(std::move(tracks));
227 evt.
put(std::move(spts));
228 evt.
put(std::move(th_assn));
229 evt.
put(std::move(thm_assn));
230 evt.
put(std::move(tsp_assn));
231 evt.
put(std::move(sph_assn));
232 evt.
put(std::move(pfPartTrack_assns));
240 <<
"Track3DKalmanHit statistics:\n" 241 <<
" Number of events = " <<
fNumEvent <<
"\n";
271 if (!clusterh.
isValid())
return hits;
275 for(
size_t i = 0; i < clusterh->size(); ++i) {
276 std::vector< art::Ptr<recob::Hit> > clushits = hitsbycluster.at(i);
277 hits.
insert(hits.
end(), clushits.begin(), clushits.end());
288 if(!hith.
isValid())
return hits;
289 size_t nhits = hith->size();
292 for(
size_t i = 0; i < nhits; ++i) {
309 if (!pfParticleHandle.
isValid())
return inputs;
315 if (!clusterHandle.
isValid())
return inputs;
327 inputs.reserve(pfParticleHandle->size());
330 for(
size_t partIdx = 0; partIdx < pfParticleHandle->size(); partIdx++) {
333 inputs.emplace_back();
340 std::vector<art::Ptr<recob::Cluster> > clusterVec = clusterAssns.at(partIdx);
342 for(
auto const &
cluster : clusterVec) {
343 std::vector<art::Ptr<recob::Hit> > hitVec = clusterHitAssns.at(
cluster.key());
344 hits.insert(hits.end(), hitVec.begin(), hitVec.end());
350 std::vector<art::Ptr<recob::Seed> > seedVec = seedAssns.at(partIdx);
351 seeds.
insert(seeds.
end(), seedVec.begin(), seedVec.end());
354 for(
size_t seedIdx = 0; seedIdx < seedVec.size(); ++seedIdx) {
355 std::vector<art::Ptr<recob::Hit> > seedHitVec;
358 seedHitVec = seedHitAssns.at(seedIdx);
363 kalman_input.
seedhits.emplace_back();
365 seedhits.
insert(seedhits.
end(), seedHitVec.begin(), seedHitVec.end());
373 std::vector<KalmanOutput>
const &outputs,
375 std::vector<recob::Track> &tracks,
376 std::vector<recob::SpacePoint> &spts,
383 if(outputs.size()!= inputs.size())
return;
385 size_t tracksSize(0);
386 for(
auto const &kalman_output : outputs) {
387 tracksSize += kalman_output.tracks.size();
389 tracks.reserve(tracksSize);
391 auto const tid = getProductID<std::vector<recob::Track> >();
394 auto const spacepointId = getProductID<std::vector<recob::SpacePoint> >();
396 for (
size_t i = 0; i<outputs.size();++i) {
398 const std::deque<KGTrack>& kalman_tracks = outputs[i].tracks;
400 for(
auto const& kalman_track:kalman_tracks) {
404 kalman_track.fillTrack(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()<<
" while the number of trajectory points is "<<numtrajpts<<
'\n';
422 auto nspt = spts.size();
425 std::vector<art::Ptr<recob::SpacePoint>> sptvec;
426 for(
auto ispt = nspt; ispt < spts.size(); ++ispt) {
427 sptvec.emplace_back(spacepointId, ispt, getter);
431 for(
auto const& sphit: sphits) {
432 sph_assn.
addSingle(sptvec.back(), sphit);
439 for (
size_t h = 0; h< trhits.
size(); ++h){
442 thm_assn.
addSingle(aptr, trhits[h], metadata);
446 for (
auto const& spt: sptvec) {
452 pfPartTrack_assns.
addSingle(inputs[i].pfPartPtr, aptr);
464 for(
auto const &output : outputs) {
465 const std::deque<KGTrack>& kalman_tracks = output.tracks;
466 for (
size_t i = 0; i < kalman_tracks.size(); ++i) {
467 const KGTrack& trg = kalman_tracks[i];
469 const std::multimap<double, KHitTrack>& trackmap = trg.
getTrackMap();
471 ih != trackmap.end(); ++ih) {
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.
KalmanInputs getInput(const art::Event &evt) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
virtual void beginJob() override
Begin job method.
Declaration of signal hit object.
std::string fPFParticleModuleLabel
PFParticle label.
std::vector< trkf::KalmanOutput > makeTracks(KalmanInputs &kalman_inputs)
size_t NumberTrajectoryPoints() const
Various functions related to the presence and the number of (valid) points.
bool fHist
Make histograms.
std::string fClusterModuleLabel
Clustered Hits.
Cluster finding and building.
EDProductGetter const * productGetter(ProductID const) const
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.
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
ProductID put(std::unique_ptr< PROD > &&product)
void fillSpacePoints(std::vector< recob::SpacePoint > &spts, std::multimap< double, KHitTrack > const &trackMap) const
Fill a collection of space points.
const KSymMatrix< N >::type & getResError() const
Residual error matrix.
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)
T get(std::string const &key) const
Hits getAllHits(const art::Event &evt) const
If both UseClusteredHits and UsePFParticles is false use this method to fill in hits.
void fillHistograms(std::vector< KalmanOutput > &outputs)
Fill Histograms method.
Declaration of cluster object.
Provides recob::Track data product.
void reconfigure(const fhicl::ParameterSet &pset)
Reconfigure method.
Detector simulation of raw signals on wires.
void createOutputs(const art::Event &evt, 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)
void reconfigure(const fhicl::ParameterSet &pset)
int fNumEvent
Number of events seen.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
iterator insert(iterator position, Ptr< U > const &p)
T * make(ARGS...args) const
Utility object to perform functions of association.
bool fUsePFParticleHits
Use PFParticle hits as input.
virtual void produce(art::Event &e) override
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
virtual void reconfigure(fhicl::ParameterSet const &pset)
Algorithm for generating space points from hits.
std::vector< KalmanInput > KalmanInputs
virtual void endJob() override
End job method.
TH1F * fHIncChisq
Incremental chisquare.
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
KalmanInputs getPFParticleStuff(const art::Event &evt) const
If UsePFParticles is true use this method to fill in hits.