LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
trkf::TrackKalmanCheater Class Reference
Inheritance diagram for trkf::TrackKalmanCheater:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 TrackKalmanCheater (fhicl::ParameterSet const &pset)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
void fillProductDescriptions ()
 
void registerProducts (ProductDescriptions &productsToRegister)
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
std::unique_ptr< Worker > makeWorker (WorkerParams const &wp)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Protected Member Functions

ConsumesCollector & consumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Private Member Functions

void produce (art::Event &e) override
 
void beginJob () override
 Begin job method. More...
 
void endJob () override
 End job method. More...
 

Private Attributes

bool fHist
 Make histograms. More...
 
KalmanFilterAlg fKFAlg
 Kalman filter algorithm. More...
 
SpacePointAlg fSpacePointAlg
 Space point algorithm. More...
 
bool fUseClusterHits
 Use cluster hits or all hits? More...
 
std::string fHitModuleLabel
 Unclustered Hits. More...
 
std::string fClusterModuleLabel
 Clustered Hits. More...
 
double fMaxTcut
 Maximum delta ray energy in MeV for restricted dE/dx. More...
 
TH1F * fHIncChisq {nullptr}
 Incremental chisquare. More...
 
TH1F * fHPull {nullptr}
 Hit pull. More...
 
int fNumEvent {0}
 Number of events seen. More...
 
int fNumTrack {0}
 Number of tracks produced. More...
 

Detailed Description

Definition at line 65 of file TrackKalmanCheater_module.cc.

Member Typedef Documentation

Definition at line 17 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::detail::Producer::Table = Modifier::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 26 of file Producer.h.

Constructor & Destructor Documentation

trkf::TrackKalmanCheater::TrackKalmanCheater ( fhicl::ParameterSet const &  pset)
explicit

Constructor.

Arguments:

p - Fcl parameters.

Definition at line 106 of file TrackKalmanCheater_module.cc.

References fClusterModuleLabel, fHist, fHitModuleLabel, fKFAlg, fMaxTcut, fSpacePointAlg, and fUseClusterHits.

107  : EDProducer{pset}
108  , fHist(pset.get<bool>("Hist"))
109  , fKFAlg(pset.get<fhicl::ParameterSet>("KalmanFilterAlg"))
110  , fSpacePointAlg(pset.get<fhicl::ParameterSet>("SpacePointAlg"))
111  , fUseClusterHits(pset.get<bool>("UseClusterHits"))
112  , fHitModuleLabel{pset.get<std::string>("HitModuleLabel")}
113  , fClusterModuleLabel{pset.get<std::string>("ClusterModuleLabel")}
114  , fMaxTcut(pset.get<double>("MaxTcut"))
115 {
116  produces<std::vector<recob::Track>>();
117  produces<std::vector<recob::SpacePoint>>();
118  produces<art::Assns<recob::Track, recob::Hit>>();
119  produces<art::Assns<recob::Track, recob::SpacePoint>>();
120  produces<art::Assns<recob::SpacePoint, recob::Hit>>();
121 
122  // Report.
123 
124  mf::LogInfo("TrackKalmanCheater")
125  << "TrackKalmanCheater configured with the following parameters:\n"
126  << " UseClusterHits = " << fUseClusterHits << "\n"
127  << " HitModuleLabel = " << fHitModuleLabel << "\n"
128  << " ClusterModuleLabel = " << fClusterModuleLabel;
129 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fClusterModuleLabel
Clustered Hits.
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
KalmanFilterAlg fKFAlg
Kalman filter algorithm.
std::string fHitModuleLabel
Unclustered Hits.
bool fUseClusterHits
Use cluster hits or all hits?
SpacePointAlg fSpacePointAlg
Space point algorithm.
double fMaxTcut
Maximum delta ray energy in MeV for restricted dE/dx.

Member Function Documentation

void trkf::TrackKalmanCheater::beginJob ( )
overrideprivatevirtual

Begin job method.

Reimplemented from art::EDProducer.

Definition at line 133 of file TrackKalmanCheater_module.cc.

References dir, fHIncChisq, fHist, and fHPull.

134 {
135  if (fHist) {
136 
137  // Book histograms.
138 
140  art::TFileDirectory dir = tfs->mkdir("hitkalman", "TrackKalmanCheater histograms");
141 
142  fHIncChisq = dir.make<TH1F>("IncChisq", "Incremental Chisquare", 100, 0., 20.);
143  fHPull = dir.make<TH1F>("Pull", "Hit Pull", 100, -10., 10.);
144  }
145 }
TDirectory * dir
Definition: macro.C:5
TH1F * fHIncChisq
Incremental chisquare.
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::consumes ( InputTag const &  tag)
protectedinherited

Definition at line 61 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumes().

62  {
63  return collector_.consumes<T, BT>(tag);
64  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ProductToken< T > consumes(InputTag const &)
ConsumesCollector & art::ModuleBase::consumesCollector ( )
protectedinherited

Definition at line 57 of file ModuleBase.cc.

References art::ModuleBase::collector_.

58  {
59  return collector_;
60  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::consumesMany ( )
protectedinherited

Definition at line 75 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesMany().

76  {
77  collector_.consumesMany<T, BT>();
78  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::consumesView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::consumesView ( InputTag const &  tag)
inherited

Definition at line 68 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::consumesView().

69  {
70  return collector_.consumesView<T, BT>(tag);
71  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > consumesView(InputTag const &)
void art::detail::Producer::doBeginJob ( SharedResources const &  resources)
inherited

Definition at line 22 of file Producer.cc.

References art::detail::Producer::beginJobWithFrame(), and art::detail::Producer::setupQueues().

23  {
24  setupQueues(resources);
25  ProcessingFrame const frame{ScheduleID{}};
26  beginJobWithFrame(frame);
27  }
virtual void setupQueues(SharedResources const &)=0
virtual void beginJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doBeginRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 65 of file Producer.cc.

References art::detail::Producer::beginRunWithFrame(), art::RangeSet::forRun(), art::RunPrincipal::makeRun(), r, art::RunPrincipal::runID(), and art::ModuleContext::scheduleID().

66  {
67  auto r = rp.makeRun(mc, RangeSet::forRun(rp.runID()));
68  ProcessingFrame const frame{mc.scheduleID()};
69  beginRunWithFrame(r, frame);
70  r.commitProducts();
71  return true;
72  }
TRandom r
Definition: spectrum.C:23
virtual void beginRunWithFrame(Run &, ProcessingFrame const &)=0
static RangeSet forRun(RunID)
Definition: RangeSet.cc:51
bool art::detail::Producer::doBeginSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 85 of file Producer.cc.

References art::detail::Producer::beginSubRunWithFrame(), art::RangeSet::forSubRun(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::SubRunPrincipal::subRunID().

86  {
87  auto sr = srp.makeSubRun(mc, RangeSet::forSubRun(srp.subRunID()));
88  ProcessingFrame const frame{mc.scheduleID()};
89  beginSubRunWithFrame(sr, frame);
90  sr.commitProducts();
91  return true;
92  }
virtual void beginSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:57
void art::detail::Producer::doEndJob ( )
inherited

Definition at line 30 of file Producer.cc.

References art::detail::Producer::endJobWithFrame().

31  {
32  ProcessingFrame const frame{ScheduleID{}};
33  endJobWithFrame(frame);
34  }
virtual void endJobWithFrame(ProcessingFrame const &)=0
bool art::detail::Producer::doEndRun ( RunPrincipal rp,
ModuleContext const &  mc 
)
inherited

Definition at line 75 of file Producer.cc.

References art::detail::Producer::endRunWithFrame(), art::RunPrincipal::makeRun(), r, art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

76  {
77  auto r = rp.makeRun(mc, rp.seenRanges());
78  ProcessingFrame const frame{mc.scheduleID()};
79  endRunWithFrame(r, frame);
80  r.commitProducts();
81  return true;
82  }
TRandom r
Definition: spectrum.C:23
virtual void endRunWithFrame(Run &, ProcessingFrame const &)=0
bool art::detail::Producer::doEndSubRun ( SubRunPrincipal srp,
ModuleContext const &  mc 
)
inherited

Definition at line 95 of file Producer.cc.

References art::detail::Producer::endSubRunWithFrame(), art::SubRunPrincipal::makeSubRun(), art::ModuleContext::scheduleID(), and art::Principal::seenRanges().

96  {
97  auto sr = srp.makeSubRun(mc, srp.seenRanges());
98  ProcessingFrame const frame{mc.scheduleID()};
99  endSubRunWithFrame(sr, frame);
100  sr.commitProducts();
101  return true;
102  }
virtual void endSubRunWithFrame(SubRun &, ProcessingFrame const &)=0
bool art::detail::Producer::doEvent ( EventPrincipal ep,
ModuleContext const &  mc,
std::atomic< std::size_t > &  counts_run,
std::atomic< std::size_t > &  counts_passed,
std::atomic< std::size_t > &  counts_failed 
)
inherited

Definition at line 105 of file Producer.cc.

References art::detail::Producer::checkPutProducts_, e, art::EventPrincipal::makeEvent(), art::detail::Producer::produceWithFrame(), and art::ModuleContext::scheduleID().

110  {
111  auto e = ep.makeEvent(mc);
112  ++counts_run;
113  ProcessingFrame const frame{mc.scheduleID()};
114  produceWithFrame(e, frame);
115  e.commitProducts(checkPutProducts_, &expectedProducts<InEvent>());
116  ++counts_passed;
117  return true;
118  }
bool const checkPutProducts_
Definition: Producer.h:70
Float_t e
Definition: plot.C:35
virtual void produceWithFrame(Event &, ProcessingFrame const &)=0
void art::detail::Producer::doRespondToCloseInputFile ( FileBlock const &  fb)
inherited

Definition at line 44 of file Producer.cc.

References art::detail::Producer::respondToCloseInputFileWithFrame().

45  {
46  ProcessingFrame const frame{ScheduleID{}};
48  }
virtual void respondToCloseInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToCloseOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 58 of file Producer.cc.

References art::detail::Producer::respondToCloseOutputFilesWithFrame().

59  {
60  ProcessingFrame const frame{ScheduleID{}};
62  }
virtual void respondToCloseOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenInputFile ( FileBlock const &  fb)
inherited

Definition at line 37 of file Producer.cc.

References art::detail::Producer::respondToOpenInputFileWithFrame().

38  {
39  ProcessingFrame const frame{ScheduleID{}};
41  }
virtual void respondToOpenInputFileWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void art::detail::Producer::doRespondToOpenOutputFiles ( FileBlock const &  fb)
inherited

Definition at line 51 of file Producer.cc.

References art::detail::Producer::respondToOpenOutputFilesWithFrame().

52  {
53  ProcessingFrame const frame{ScheduleID{}};
55  }
virtual void respondToOpenOutputFilesWithFrame(FileBlock const &, ProcessingFrame const &)=0
TFile fb("Li6.root")
void trkf::TrackKalmanCheater::endJob ( )
overrideprivatevirtual

End job method.

Reimplemented from art::EDProducer.

Definition at line 449 of file TrackKalmanCheater_module.cc.

References fNumEvent, and fNumTrack.

450 {
451  mf::LogInfo("TrackKalmanCheater") << "TrackKalmanCheater statistics:\n"
452  << " Number of events = " << fNumEvent << "\n"
453  << " Number of tracks created = " << fNumTrack;
454 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fNumEvent
Number of events seen.
int fNumTrack
Number of tracks produced.
void art::Modifier::fillProductDescriptions ( )
inherited

Definition at line 10 of file Modifier.cc.

References art::ProductRegistryHelper::fillDescriptions(), and art::ModuleBase::moduleDescription().

11  {
13  }
void fillDescriptions(ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
std::array< std::vector< ProductInfo >, NumBranchTypes > const & art::ModuleBase::getConsumables ( ) const
inherited

Definition at line 43 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::getConsumables().

44  {
45  return collector_.getConsumables();
46  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables() const
std::unique_ptr< Worker > art::ModuleBase::makeWorker ( WorkerParams const &  wp)
inherited

Definition at line 37 of file ModuleBase.cc.

References art::ModuleBase::doMakeWorker(), and art::NumBranchTypes.

38  {
39  return doMakeWorker(wp);
40  }
virtual std::unique_ptr< Worker > doMakeWorker(WorkerParams const &wp)=0
template<typename T , BranchType BT>
ProductToken< T > art::ModuleBase::mayConsume ( InputTag const &  tag)
protectedinherited

Definition at line 82 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsume().

83  {
84  return collector_.mayConsume<T, BT>(tag);
85  }
ProductToken< T > mayConsume(InputTag const &)
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename T , BranchType BT>
void art::ModuleBase::mayConsumeMany ( )
protectedinherited

Definition at line 96 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeMany().

97  {
98  collector_.mayConsumeMany<T, BT>();
99  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::ModuleBase::mayConsumeView ( InputTag const &  )
protectedinherited
template<typename T , BranchType BT>
ViewToken<T> art::ModuleBase::mayConsumeView ( InputTag const &  tag)
inherited

Definition at line 89 of file ModuleBase.h.

References art::ModuleBase::collector_, and art::ConsumesCollector::mayConsumeView().

90  {
91  return collector_.mayConsumeView<T, BT>(tag);
92  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
ViewToken< Element > mayConsumeView(InputTag const &)
ModuleDescription const & art::ModuleBase::moduleDescription ( ) const
inherited

Definition at line 13 of file ModuleBase.cc.

References art::errors::LogicError.

Referenced by art::OutputModule::doRespondToOpenInputFile(), art::OutputModule::doWriteEvent(), art::Modifier::fillProductDescriptions(), art::OutputModule::makePlugins_(), art::OutputWorker::OutputWorker(), reco::shower::LArPandoraModularShowerCreation::produce(), art::Modifier::registerProducts(), and art::OutputModule::registerProducts().

14  {
15  if (md_.has_value()) {
16  return *md_;
17  }
18 
20  "There was an error while calling moduleDescription().\n"}
21  << "The moduleDescription() base-class member function cannot be called\n"
22  "during module construction. To determine which module is "
23  "responsible\n"
24  "for calling it, find the '<module type>:<module "
25  "label>@Construction'\n"
26  "tag in the message prefix above. Please contact artists@fnal.gov\n"
27  "for guidance.\n";
28  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void trkf::TrackKalmanCheater::produce ( art::Event evt)
overrideprivatevirtual

Produce method.

Arguments:

e - Art event.

This method extracts Hit from the event and produces and adds Track objects.

Implements art::EDProducer.

Definition at line 157 of file TrackKalmanCheater_module.cc.

References util::abs(), trkf::Surface::BACKWARD, art::PtrVector< T >::begin(), sim::ParticleList::begin(), trkf::KalmanFilterAlg::buildTrack(), trkf::SpacePointAlg::clearHitMap(), util::CreateAssn(), dir, art::PtrVector< T >::empty(), art::PtrVector< T >::end(), sim::ParticleList::end(), fClusterModuleLabel, fHIncChisq, fHist, fHitModuleLabel, fHPull, trkf::KHitContainerWireX::fill(), trkf::SpacePointAlg::fillSpacePoints(), trkf::KalmanFilterAlg::fitMomentum(), fKFAlg, fMaxTcut, fNumEvent, fNumTrack, trkf::Surface::FORWARD, trkf::Propagator::FORWARD, fSpacePointAlg, fUseClusterHits, trkf::SpacePointAlg::getAssociatedHits(), art::ProductRetriever::getByLabel(), trkf::KHitTrack::getHit(), art::ProductRetriever::getProductID(), trkf::KHit< N >::getResError(), trkf::KHit< N >::getResVector(), hits(), cheat::BackTrackerService::HitToTrackIDEs(), ipart, mf::isDebugEnabled(), art::Handle< T >::isValid(), simb::MCParticle::Momentum(), part, cheat::ParticleInventoryService::ParticleList(), simb::MCParticle::PdgCode(), geo::PlaneID::Plane, simb::MCParticle::Position(), art::ProductRetriever::productGetter(), art::PtrVector< T >::push_back(), art::Event::put(), art::PtrVector< T >::reserve(), trkf::KalmanFilterAlg::setPlane(), art::PtrVector< T >::size(), util::size(), trkf::KalmanFilterAlg::smoothTrackIter(), simb::MCParticle::StatusCode(), simb::MCParticle::TrackId(), trkf::KalmanFilterAlg::updateMomentum(), lar::dump::vector(), recob::Hit::WireID(), x, y, and z.

158 {
159  ++fNumEvent;
160 
161  // Make a collection of tracks, plus associations, that will
162  // eventually be inserted into the event.
163 
164  std::unique_ptr<std::vector<recob::Track>> tracks(new std::vector<recob::Track>);
165  std::unique_ptr<art::Assns<recob::Track, recob::Hit>> th_assn(
167  std::unique_ptr<art::Assns<recob::Track, recob::SpacePoint>> tsp_assn(
169 
170  // Make a collection of space points, plus associations, that will
171  // be inserted into the event.
172 
173  std::unique_ptr<std::vector<recob::SpacePoint>> spts(new std::vector<recob::SpacePoint>);
174  std::unique_ptr<art::Assns<recob::SpacePoint, recob::Hit>> sph_assn(
176 
177  // Make a collection of KGTracks where we will save our results.
178 
179  std::deque<KGTrack> kalman_tracks;
180 
181  // Get Services.
182 
186  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
187 
188  // Reset space point algorithm.
189 
191 
192  // Get Hits.
193 
195 
196  if (fUseClusterHits) {
197 
198  // Get clusters.
199 
201  evt.getByLabel(fClusterModuleLabel, clusterh);
202 
203  // Get hits from all clusters.
205 
206  if (clusterh.isValid()) {
207  int nclus = clusterh->size();
208 
209  for (int i = 0; i < nclus; ++i) {
210  art::Ptr<recob::Cluster> pclus(clusterh, i);
211  std::vector<art::Ptr<recob::Hit>> clushits = fm.at(i);
212  int nhits = clushits.size();
213  hits.reserve(hits.size() + nhits);
214 
215  for (std::vector<art::Ptr<recob::Hit>>::const_iterator ihit = clushits.begin();
216  ihit != clushits.end();
217  ++ihit) {
218  hits.push_back(*ihit);
219  }
220  }
221  }
222  }
223  else {
224 
225  // Get unclustered hits.
226 
228  evt.getByLabel(fHitModuleLabel, hith);
229  if (hith.isValid()) {
230  int nhits = hith->size();
231  hits.reserve(nhits);
232 
233  for (int i = 0; i < nhits; ++i)
234  hits.push_back(art::Ptr<recob::Hit>(hith, i));
235  }
236  }
237 
238  // Sort hits into separate PtrVectors based on track id.
239 
240  std::map<int, art::PtrVector<recob::Hit>> hitmap;
241 
242  // Loop over hits.
243 
244  for (art::PtrVector<recob::Hit>::const_iterator ihit = hits.begin(); ihit != hits.end(); ++ihit) {
245  //const recob::Hit& hit = **ihit;
246 
247  // Get track ids for this hit.
248 
249  std::vector<sim::TrackIDE> tids = bt_serv->HitToTrackIDEs(clockData, *ihit);
250 
251  // Loop over track ids.
252 
253  for (std::vector<sim::TrackIDE>::const_iterator itid = tids.begin(); itid != tids.end();
254  ++itid) {
255  int trackID = itid->trackID;
256 
257  // Add hit to PtrVector corresponding to this track id.
258 
259  hitmap[trackID].push_back(*ihit);
260  }
261  }
262 
263  // Extract geant mc particles.
264 
265  sim::ParticleList const& plist = pi_serv->ParticleList();
266 
267  auto const det_prop =
269 
270  PropYZPlane const prop{det_prop, fMaxTcut, true};
271 
272  // Loop over geant particles.
273 
274  {
275  // use mf::LogDebug instead of MF_LOG_DEBUG because we reuse it in many lines;
276  // insertions are protected by mf::isDebugEnabled()
277  mf::LogDebug log("TrackKalmanCheater");
278  for (sim::ParticleList::const_iterator ipart = plist.begin(); ipart != plist.end(); ++ipart) {
279  const simb::MCParticle* part = (*ipart).second;
280  if (!part) throw cet::exception("TrackKalmanCheater") << "no particle!\n";
281  int pdg = part->PdgCode();
282 
283  // Ignore everything except stable charged nonshowering particles.
284 
285  int apdg = std::abs(pdg);
286  if (not accepted_particle(apdg)) { continue; }
287 
288  int trackid = part->TrackId();
289  int stat = part->StatusCode();
290  int nhit = 0;
291  if (hitmap.count(trackid) != 0) nhit = hitmap[trackid].size();
292  const TLorentzVector& pos = part->Position();
293  const TLorentzVector& mom = part->Momentum();
294 
295  if (mf::isDebugEnabled()) {
296  log << "Trackid=" << trackid << ", pdgid=" << pdg << ", status=" << stat
297  << ", NHit=" << nhit << "\n"
298  << " x = " << pos.X() << ", y = " << pos.Y() << ", z = " << pos.Z() << "\n"
299  << " px= " << mom.Px() << ", py= " << mom.Py() << ", pz= " << mom.Pz() << "\n";
300  } // if debugging
301 
302  double x = pos.X();
303  double y = pos.Y();
304  double z = pos.Z();
305  double px = mom.Px();
306  double py = mom.Py();
307  double pz = mom.Pz();
308  double p = std::hypot(px, py, pz);
309 
310  if (nhit > 0 && pz != 0.) {
311  const art::PtrVector<recob::Hit>& trackhits = hitmap[trackid];
312  if (trackhits.empty()) throw cet::exception("TrackKalmanCheater") << "No hits in track\n";
313 
314  // Make a seed track (KTrack).
315 
316  std::shared_ptr<const Surface> psurf(new SurfYZPlane(0., y, z, 0.));
317  TrackVector vec(5);
318  vec(0) = x;
319  vec(1) = 0.;
320  vec(2) = px / pz;
321  vec(3) = py / pz;
322  vec(4) = 1. / p;
324  KTrack trk(psurf, vec, dir, pdg);
325 
326  // Fill KHitContainer with hits.
327 
328  KHitContainerWireX cont;
329  cont.fill(det_prop, trackhits, -1);
330 
331  // Count hits in each plane. Set the preferred plane to be
332  // the one with the most hits.
333 
334  std::vector<unsigned int> planehits(3, 0);
336  ih != trackhits.end();
337  ++ih) {
338  const recob::Hit& hit = **ih;
339  unsigned int plane = hit.WireID().Plane;
340 
341  if (plane >= planehits.size()) {
342  throw cet::exception("TrackKalmanCheater") << "plane " << plane << "...\n";
343  }
344  ++planehits[plane];
345  }
346  unsigned int prefplane = 0;
347  for (unsigned int i = 0; i < planehits.size(); ++i) {
348  if (planehits[i] > planehits[prefplane]) prefplane = i;
349  }
350  if (mf::isDebugEnabled()) log << "Preferred plane = " << prefplane << "\n";
351 
352  // Build and smooth track.
353 
354  KGTrack trg(prefplane);
355  fKFAlg.setPlane(prefplane);
356  if (fKFAlg.buildTrack(trk, trg, prop, Propagator::FORWARD, cont, false)) {
357  if (fKFAlg.smoothTrackIter(5, trg, prop)) {
358  KETrack tremom;
359  if (fKFAlg.fitMomentum(trg, prop, tremom)) { fKFAlg.updateMomentum(tremom, prop, trg); }
360  ++fNumTrack;
361  kalman_tracks.push_back(trg);
362  }
363  }
364  }
365  }
366  }
367 
368  // Fill histograms.
369 
370  if (fHist) {
371 
372  // First loop over tracks.
373 
374  for (auto const& trg : kalman_tracks) {
375 
376  // Loop over measurements in this track.
377 
378  const std::multimap<double, KHitTrack>& trackmap = trg.getTrackMap();
379  for (std::multimap<double, KHitTrack>::const_iterator ih = trackmap.begin();
380  ih != trackmap.end();
381  ++ih) {
382  const KHitTrack& trh = (*ih).second;
383  const std::shared_ptr<const KHitBase>& hit = trh.getHit();
384  double chisq = hit->getChisq();
385  fHIncChisq->Fill(chisq);
386  const KHit<1>* ph1 = dynamic_cast<const KHit<1>*>(&*hit);
387  if (ph1 != 0) {
388  double pull = ph1->getResVector()(0) / std::sqrt(ph1->getResError()(0, 0));
389  fHPull->Fill(pull);
390  }
391  }
392  }
393  }
394 
395  // Process Kalman filter tracks into persistent objects.
396 
397  tracks->reserve(kalman_tracks.size());
398  for (auto const& kalman_track : kalman_tracks) {
399  tracks->push_back(recob::Track());
400  kalman_track.fillTrack(det_prop, tracks->back(), tracks->size() - 1);
401 
402  // Make Track to Hit associations.
403 
405  std::vector<unsigned int> hittpindex;
406  kalman_track.fillHits(hits, hittpindex);
407  util::CreateAssn(evt, *tracks, trhits, *th_assn, tracks->size() - 1);
408 
409  // Make space points from this track.
410 
411  int nspt = spts->size();
412  fSpacePointAlg.fillSpacePoints(det_prop, *spts, kalman_track.TrackMap());
413 
414  // Associate newly created space points with hits.
415  // Also associate track with newly created space points.
416 
418 
419  // Loop over newly created space points.
420 
421  for (unsigned int ispt = nspt; ispt < spts->size(); ++ispt) {
422  const recob::SpacePoint& spt = (*spts)[ispt];
423  art::ProductID sptid = evt.getProductID<std::vector<recob::SpacePoint>>();
424  art::Ptr<recob::SpacePoint> sptptr(sptid, ispt, evt.productGetter(sptid));
425  sptvec.push_back(sptptr);
426 
427  // Make space point to hit associations.
428 
430  util::CreateAssn(evt, *spts, sphits, *sph_assn, ispt);
431  }
432 
433  // Make track to space point associations.
434 
435  util::CreateAssn(evt, *tracks, sptvec, *tsp_assn, tracks->size() - 1);
436  }
437 
438  // Add tracks and associations to event.
439 
440  evt.put(std::move(tracks));
441  evt.put(std::move(spts));
442  evt.put(std::move(th_assn));
443  evt.put(std::move(tsp_assn));
444  evt.put(std::move(sph_assn));
445 }
Float_t x
Definition: compare.C:6
void reserve(size_type n)
Definition: PtrVector.h:337
TrackDirection
Track direction enum.
Definition: Surface.h:54
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:220
int PdgCode() const
Definition: MCParticle.h:213
Int_t ipart
Definition: Style.C:10
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
bool smoothTrackIter(int niter, KGTrack &trg, const Propagator &prop) const
Iteratively smooth a track.
ProductID getProductID(std::string const &instance_name="") const
std::string fClusterModuleLabel
Clustered Hits.
iterator begin()
Definition: PtrVector.h:217
Float_t y
Definition: compare.C:6
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
Double_t z
Definition: plot.C:276
constexpr auto abs(T v)
Returns the absolute value of the argument.
int StatusCode() const
Definition: MCParticle.h:212
intermediate_table::const_iterator const_iterator
geo::WireID const & WireID() const
Initial tdc tick for hit.
Definition: Hit.h:280
KalmanFilterAlg fKFAlg
Kalman filter algorithm.
const art::PtrVector< recob::Hit > & getAssociatedHits(const recob::SpacePoint &spt) const
int fNumEvent
Number of events seen.
int TrackId() const
Definition: MCParticle.h:211
std::string fHitModuleLabel
Unclustered Hits.
bool isValid() const noexcept
Definition: Handle.h:203
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
bool fUseClusterHits
Use cluster hits or all hits?
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
TString part[npart]
Definition: Style.C:32
void hits()
Definition: readHits.C:15
typename data_t::const_iterator const_iterator
Definition: PtrVector.h:55
bool buildTrack(const KTrack &trk, KGTrack &trg, const Propagator &prop, const Propagator::PropDirection dir, KHitContainer &hits, bool linear) const
Make a new track.
EDProductGetter const * productGetter(ProductID const pid) const
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
iterator end()
Definition: PtrVector.h:231
iterator begin()
Definition: ParticleList.h:305
bool isDebugEnabled()
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:481
bool empty() const
Definition: PtrVector.h:330
size_type size() const
Definition: PtrVector.h:302
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.
const sim::ParticleList & ParticleList() const
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
void clearHitMap() const
int fNumTrack
Number of tracks produced.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
TDirectory * dir
Definition: macro.C:5
void setPlane(int plane)
Set preferred view plane.
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:221
SpacePointAlg fSpacePointAlg
Space point algorithm.
TH1F * fHIncChisq
Incremental chisquare.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:46
double fMaxTcut
Maximum delta ray energy in MeV for restricted dE/dx.
bool fitMomentum(const KGTrack &trg, const Propagator &prop, KETrack &tremom) const
Estimate track momentum using either range or multiple scattering.
bool updateMomentum(const KETrack &tremom, const Propagator &prop, KGTrack &trg) const
Set track momentum at each track surface.
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void art::Modifier::registerProducts ( ProductDescriptions productsToRegister)
inherited

Definition at line 16 of file Modifier.cc.

References art::ModuleBase::moduleDescription(), and art::ProductRegistryHelper::registerProducts().

17  {
18  ProductRegistryHelper::registerProducts(productsToRegister,
20  }
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
ModuleDescription const & moduleDescription() const
Definition: ModuleBase.cc:13
void art::ModuleBase::setModuleDescription ( ModuleDescription const &  md)
inherited

Definition at line 31 of file ModuleBase.cc.

References art::ModuleBase::md_.

32  {
33  md_ = md;
34  }
std::optional< ModuleDescription > md_
Definition: ModuleBase.h:55
void art::ModuleBase::sortConsumables ( std::string const &  current_process_name)
inherited

Definition at line 49 of file ModuleBase.cc.

References art::ModuleBase::collector_, and art::ConsumesCollector::sortConsumables().

50  {
51  // Now that we know we have seen all the consumes declarations,
52  // sort the results for fast lookup later.
53  collector_.sortConsumables(current_process_name);
54  }
ConsumesCollector collector_
Definition: ModuleBase.h:56
void sortConsumables(std::string const &current_process_name)

Member Data Documentation

std::string trkf::TrackKalmanCheater::fClusterModuleLabel
private

Clustered Hits.

Definition at line 81 of file TrackKalmanCheater_module.cc.

Referenced by produce(), and TrackKalmanCheater().

TH1F* trkf::TrackKalmanCheater::fHIncChisq {nullptr}
private

Incremental chisquare.

Definition at line 86 of file TrackKalmanCheater_module.cc.

Referenced by beginJob(), and produce().

bool trkf::TrackKalmanCheater::fHist
private

Make histograms.

Definition at line 76 of file TrackKalmanCheater_module.cc.

Referenced by beginJob(), produce(), and TrackKalmanCheater().

std::string trkf::TrackKalmanCheater::fHitModuleLabel
private

Unclustered Hits.

Definition at line 80 of file TrackKalmanCheater_module.cc.

Referenced by produce(), and TrackKalmanCheater().

TH1F* trkf::TrackKalmanCheater::fHPull {nullptr}
private

Hit pull.

Definition at line 87 of file TrackKalmanCheater_module.cc.

Referenced by beginJob(), and produce().

KalmanFilterAlg trkf::TrackKalmanCheater::fKFAlg
private

Kalman filter algorithm.

Definition at line 77 of file TrackKalmanCheater_module.cc.

Referenced by produce(), and TrackKalmanCheater().

double trkf::TrackKalmanCheater::fMaxTcut
private

Maximum delta ray energy in MeV for restricted dE/dx.

Definition at line 82 of file TrackKalmanCheater_module.cc.

Referenced by produce(), and TrackKalmanCheater().

int trkf::TrackKalmanCheater::fNumEvent {0}
private

Number of events seen.

Definition at line 91 of file TrackKalmanCheater_module.cc.

Referenced by endJob(), and produce().

int trkf::TrackKalmanCheater::fNumTrack {0}
private

Number of tracks produced.

Definition at line 92 of file TrackKalmanCheater_module.cc.

Referenced by endJob(), and produce().

SpacePointAlg trkf::TrackKalmanCheater::fSpacePointAlg
private

Space point algorithm.

Definition at line 78 of file TrackKalmanCheater_module.cc.

Referenced by produce(), and TrackKalmanCheater().

bool trkf::TrackKalmanCheater::fUseClusterHits
private

Use cluster hits or all hits?

Definition at line 79 of file TrackKalmanCheater_module.cc.

Referenced by produce(), and TrackKalmanCheater().


The documentation for this class was generated from the following file: