LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
trkf::TrackKalmanCheater Class Reference
Inheritance diagram for trkf::TrackKalmanCheater:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 TrackKalmanCheater (fhicl::ParameterSet const &pset)
 
virtual ~TrackKalmanCheater ()
 Destructor. More...
 
virtual void reconfigure (fhicl::ParameterSet const &pset)
 
virtual void produce (art::Event &e)
 
virtual void beginJob ()
 Begin job method. More...
 
virtual void endJob ()
 End job method. More...
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

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...
 
const PropagatorfProp
 Propagator. More...
 
TH1F * fHIncChisq
 Incremental chisquare. More...
 
TH1F * fHPull
 Hit pull. More...
 
int fNumEvent
 Number of events seen. More...
 
int fNumTrack
 Number of tracks produced. More...
 

Detailed Description

Definition at line 54 of file TrackKalmanCheater_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

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

Constructor.

Arguments:

p - Fcl parameters.

Definition at line 107 of file TrackKalmanCheater_module.cc.

References fClusterModuleLabel, fHitModuleLabel, fUseClusterHits, and reconfigure().

108  : fHist(false)
109  , fKFAlg(pset.get<fhicl::ParameterSet>("KalmanFilterAlg"))
110  , fSpacePointAlg(pset.get<fhicl::ParameterSet>("SpacePointAlg"))
111  , fUseClusterHits(false)
112  , fMaxTcut(0.)
113  , fProp(0)
114  , fHIncChisq(0)
115  , fHPull(0)
116  , fNumEvent(0)
117  , fNumTrack(0)
118 {
119  reconfigure(pset);
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> >();
125 
126  // Report.
127 
128  mf::LogInfo("TrackKalmanCheater")
129  << "TrackKalmanCheater configured with the following parameters:\n"
130  << " UseClusterHits = " << fUseClusterHits << "\n"
131  << " HitModuleLabel = " << fHitModuleLabel << "\n"
132  << " ClusterModuleLabel = " << fClusterModuleLabel;
133 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fClusterModuleLabel
Clustered Hits.
KalmanFilterAlg fKFAlg
Kalman filter algorithm.
int fNumEvent
Number of events seen.
std::string fHitModuleLabel
Unclustered Hits.
bool fUseClusterHits
Use cluster hits or all hits?
int fNumTrack
Number of tracks produced.
virtual void reconfigure(fhicl::ParameterSet const &pset)
SpacePointAlg fSpacePointAlg
Space point algorithm.
TH1F * fHIncChisq
Incremental chisquare.
double fMaxTcut
Maximum delta ray energy in MeV for restricted dE/dx.
const Propagator * fProp
Propagator.
trkf::TrackKalmanCheater::~TrackKalmanCheater ( )
virtual

Destructor.

Definition at line 137 of file TrackKalmanCheater_module.cc.

138 {}

Member Function Documentation

void trkf::TrackKalmanCheater::beginJob ( )
virtual

Begin job method.

Reimplemented from art::EDProducer.

Definition at line 163 of file TrackKalmanCheater_module.cc.

References dir, fHIncChisq, fHist, fHPull, art::TFileDirectory::make(), and art::TFileDirectory::mkdir().

164 {
165  if(fHist) {
166 
167  // Book histograms.
168 
170  art::TFileDirectory dir = tfs->mkdir("hitkalman", "TrackKalmanCheater histograms");
171 
172  fHIncChisq = dir.make<TH1F>("IncChisq", "Incremental Chisquare", 100, 0., 20.);
173  fHPull = dir.make<TH1F>("Pull", "Hit Pull", 100, -10., 10.);
174  }
175 }
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
T * make(ARGS...args) const
TDirectory * dir
Definition: macro.C:5
TH1F * fHIncChisq
Incremental chisquare.
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
void trkf::TrackKalmanCheater::endJob ( )
virtual

End job method.

Reimplemented from art::EDProducer.

Definition at line 498 of file TrackKalmanCheater_module.cc.

References fNumEvent, and fNumTrack.

499 {
500  mf::LogInfo("TrackKalmanCheater")
501  << "TrackKalmanCheater statistics:\n"
502  << " Number of events = " << fNumEvent << "\n"
503  << " Number of tracks created = " << fNumTrack;
504 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fNumEvent
Number of events seen.
int fNumTrack
Number of tracks produced.
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void trkf::TrackKalmanCheater::produce ( art::Event evt)
virtual

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 187 of file TrackKalmanCheater_module.cc.

References 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::KGTrack::fillHits(), trkf::SpacePointAlg::fillSpacePoints(), trkf::KGTrack::fillTrack(), trkf::KalmanFilterAlg::fitMomentum(), fKFAlg, fNumEvent, fNumTrack, trkf::Surface::FORWARD, trkf::Propagator::FORWARD, fProp, fSpacePointAlg, fUseClusterHits, trkf::SpacePointAlg::getAssociatedHits(), art::DataViewImpl::getByLabel(), trkf::KHitTrack::getHit(), trkf::KHit< N >::getResError(), trkf::KHit< N >::getResVector(), trkf::KGTrack::getTrackMap(), 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::Event::productGetter(), art::PtrVector< T >::push_back(), art::Event::put(), art::PtrVector< T >::reserve(), trkf::KalmanFilterAlg::setPlane(), art::PtrVector< T >::size(), trkf::KalmanFilterAlg::smoothTrackIter(), simb::MCParticle::StatusCode(), simb::MCParticle::TrackId(), trkf::KGTrack::TrackMap(), trkf::KalmanFilterAlg::updateMomentum(), lar::dump::vector(), recob::Hit::WireID(), x, y, and z.

188 {
189  ++fNumEvent;
190 
191  // Make a collection of tracks, plus associations, that will
192  // eventually be inserted into the event.
193 
194  std::unique_ptr<std::vector<recob::Track> > tracks(new std::vector<recob::Track>);
195  std::unique_ptr< art::Assns<recob::Track, recob::Hit> > th_assn(new art::Assns<recob::Track, recob::Hit>);
196  std::unique_ptr< art::Assns<recob::Track, recob::SpacePoint> > tsp_assn(new art::Assns<recob::Track, recob::SpacePoint>);
197 
198  // Make a collection of space points, plus associations, that will
199  // be inserted into the event.
200 
201  std::unique_ptr<std::vector<recob::SpacePoint> > spts(new std::vector<recob::SpacePoint>);
202  std::unique_ptr< art::Assns<recob::SpacePoint, recob::Hit> > sph_assn(new art::Assns<recob::SpacePoint, recob::Hit>);
203 
204  // Make a collection of KGTracks where we will save our results.
205 
206  std::deque<KGTrack> kalman_tracks;
207 
208  // Get Services.
209 
213 
214  // Reset space point algorithm.
215 
217 
218 
219  // Get Hits.
220 
222 
223  if(fUseClusterHits) {
224 
225  // Get clusters.
226 
228  evt.getByLabel(fClusterModuleLabel, clusterh);
229 
230  // Get hits from all clusters.
232 
233  if(clusterh.isValid()) {
234  int nclus = clusterh->size();
235 
236  for(int i = 0; i < nclus; ++i) {
237  art::Ptr<recob::Cluster> pclus(clusterh, i);
238  std::vector< art::Ptr<recob::Hit> > clushits = fm.at(i);
239  int nhits = clushits.size();
240  hits.reserve(hits.size() + nhits);
241 
242  for(std::vector< art::Ptr<recob::Hit> >::const_iterator ihit = clushits.begin();
243  ihit != clushits.end(); ++ihit) {
244  hits.push_back(*ihit);
245  }
246  }
247  }
248  }
249  else {
250 
251  // Get unclustered hits.
252 
254  evt.getByLabel(fHitModuleLabel, hith);
255  if(hith.isValid()) {
256  int nhits = hith->size();
257  hits.reserve(nhits);
258 
259  for(int i = 0; i < nhits; ++i)
260  hits.push_back(art::Ptr<recob::Hit>(hith, i));
261  }
262  }
263 
264  // Sort hits into separate PtrVectors based on track id.
265 
266  std::map<int, art::PtrVector<recob::Hit> > hitmap;
267 
268  // Loop over hits.
269 
271  ihit != hits.end(); ++ihit) {
272  //const recob::Hit& hit = **ihit;
273 
274  // Get track ids for this hit.
275 
276  std::vector<sim::TrackIDE> tids = bt_serv->HitToTrackIDEs(*ihit);
277 
278  // Loop over track ids.
279 
280  for(std::vector<sim::TrackIDE>::const_iterator itid = tids.begin();
281  itid != tids.end(); ++itid) {
282  int trackID = itid->trackID;
283 
284  // Add hit to PtrVector corresponding to this track id.
285 
286  hitmap[trackID].push_back(*ihit);
287  }
288  }
289 
290  // Extract geant mc particles.
291 
292  sim::ParticleList const& plist = pi_serv->ParticleList();
293 
294  // Loop over geant particles.
295 
296  {
297  // use mf::LogDebug instead of LOG_DEBUG because we reuse it in many lines;
298  // insertions are protected by mf::isDebugEnabled()
299  mf::LogDebug log("TrackKalmanCheater");
301  ipart != plist.end(); ++ipart) {
302  const simb::MCParticle* part = (*ipart).second;
303  if (!part) throw cet::exception("TrackKalmanCheater") << "no particle!\n";
304  int pdg = part->PdgCode();
305 
306  // Ignore everything except stable charged nonshowering particles.
307 
308  int apdg = std::abs(pdg);
309  if(apdg == 13 || // Muon
310  apdg == 211 || // Charged pion
311  apdg == 321 || // Charged kaon
312  apdg == 2212) { // (Anti)proton
313 
314  int trackid = part->TrackId();
315  int stat = part->StatusCode();
316  int nhit = 0;
317  if(hitmap.count(trackid) != 0)
318  nhit = hitmap[trackid].size();
319  const TLorentzVector& pos = part->Position();
320  const TLorentzVector& mom = part->Momentum();
321 
322  if (mf::isDebugEnabled()) {
323  log << "Trackid=" << trackid
324  << ", pdgid=" << pdg
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";
333  } // if debugging
334 
335  double x = pos.X();
336  double y = pos.Y();
337  double z = pos.Z();
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);
342 
343  if(nhit > 0 && pz != 0.) {
344  const art::PtrVector<recob::Hit>& trackhits = hitmap[trackid];
345  if (trackhits.empty())
346  throw cet::exception("TrackKalmanCheater") << "No hits in track\n";
347 
348  // Make a seed track (KTrack).
349 
350  std::shared_ptr<const Surface> psurf(new SurfYZPlane(0., y, z, 0.));
351  TrackVector vec(5);
352  vec(0) = x;
353  vec(1) = 0.;
354  vec(2) = px / pz;
355  vec(3) = py / pz;
356  vec(4) = 1. / p;
358  KTrack trk(psurf, vec, dir, pdg);
359 
360  // Fill KHitContainer with hits.
361 
362  KHitContainerWireX cont;
363  cont.fill(trackhits, -1);
364 
365  // Count hits in each plane. Set the preferred plane to be
366  // the one with the most hits.
367 
368  std::vector<unsigned int> planehits(3, 0);
370  ih != trackhits.end(); ++ih) {
371  const recob::Hit& hit = **ih;
372  unsigned int plane = hit.WireID().Plane;
373 
374  if (plane >= planehits.size()) {
375  throw cet::exception("TrackKalmanCheater") << "plane " << plane << "...\n"; }
376  ++planehits[plane];
377  }
378  unsigned int prefplane = 0;
379  for(unsigned int i=0; i<planehits.size(); ++i) {
380  if(planehits[i] > planehits[prefplane])
381  prefplane = i;
382  }
383  if (mf::isDebugEnabled())
384  log << "Preferred plane = " << prefplane << "\n";
385 
386  // Build and smooth track.
387 
388  KGTrack trg(prefplane);
389  fKFAlg.setPlane(prefplane);
390  bool ok = fKFAlg.buildTrack(trk, trg, fProp, Propagator::FORWARD, cont, false);
391  if(ok) {
392  ok = fKFAlg.smoothTrackIter(5, trg, fProp);
393  if(ok) {
394  KETrack tremom;
395  bool pok = fKFAlg.fitMomentum(trg, fProp, tremom);
396  if(pok)
397  fKFAlg.updateMomentum(tremom, fProp, trg);
398  ++fNumTrack;
399  kalman_tracks.push_back(trg);
400  }
401  }
402  if (mf::isDebugEnabled())
403  log << (ok? "Build track succeeded.": "Build track failed.") << "\n";
404 
405  }
406  }
407  }
408  }
409 
410  // Fill histograms.
411 
412  if(fHist) {
413 
414  // First loop over tracks.
415 
416  for(std::deque<KGTrack>::const_iterator k = kalman_tracks.begin();
417  k != kalman_tracks.end(); ++k) {
418  const KGTrack& trg = *k;
419 
420  // Loop over measurements in this track.
421 
422  const std::multimap<double, KHitTrack>& trackmap = trg.getTrackMap();
423  for(std::multimap<double, KHitTrack>::const_iterator ih = trackmap.begin();
424  ih != trackmap.end(); ++ih) {
425  const KHitTrack& trh = (*ih).second;
426  const std::shared_ptr<const KHitBase>& hit = trh.getHit();
427  double chisq = hit->getChisq();
428  fHIncChisq->Fill(chisq);
429  const KHit<1>* ph1 = dynamic_cast<const KHit<1>*>(&*hit);
430  if(ph1 != 0) {
431  double pull = ph1->getResVector()(0) / std::sqrt(ph1->getResError()(0, 0));
432  fHPull->Fill(pull);
433  }
434  }
435  }
436  }
437 
438  // Process Kalman filter tracks into persistent objects.
439 
440  tracks->reserve(kalman_tracks.size());
441  for(std::deque<KGTrack>::const_iterator k = kalman_tracks.begin();
442  k != kalman_tracks.end(); ++k) {
443  const KGTrack& kalman_track = *k;
444 
445  // Add Track object to collection.
446 
447  tracks->push_back(recob::Track());
448  kalman_track.fillTrack(tracks->back(), tracks->size() - 1);
449 
450  // Make Track to Hit associations.
451 
453  std::vector<unsigned int> hittpindex;
454  kalman_track.fillHits(hits, hittpindex);
455  util::CreateAssn(*this, evt, *tracks, trhits, *th_assn, tracks->size()-1);
456 
457  // Make space points from this track.
458 
459  int nspt = spts->size();
460  fSpacePointAlg.fillSpacePoints(*spts, kalman_track.TrackMap());
461 
462  // Associate newly created space points with hits.
463  // Also associate track with newly created space points.
464 
466 
467  // Loop over newly created space points.
468 
469  for(unsigned int ispt = nspt; ispt < spts->size(); ++ispt) {
470  const recob::SpacePoint& spt = (*spts)[ispt];
471  art::ProductID sptid = getProductID<std::vector<recob::SpacePoint> >();
472  art::Ptr<recob::SpacePoint> sptptr(sptid, ispt, evt.productGetter(sptid));
473  sptvec.push_back(sptptr);
474 
475  // Make space point to hit associations.
476 
477  const art::PtrVector<recob::Hit>& sphits =
479  util::CreateAssn(*this, evt, *spts, sphits, *sph_assn, ispt);
480  }
481 
482  // Make track to space point associations.
483 
484  util::CreateAssn(*this, evt, *tracks, sptvec, *tsp_assn, tracks->size()-1);
485  }
486 
487  // Add tracks and associations to event.
488 
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));
494 }
Float_t x
Definition: compare.C:6
void reserve(size_type n)
Definition: PtrVector.h:343
TrackDirection
Track direction enum.
Definition: Surface.h:56
const TLorentzVector & Position(const int i=0) const
Definition: MCParticle.h:223
int PdgCode() const
Definition: MCParticle.h:216
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit)
std::string fClusterModuleLabel
Clustered Hits.
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
iterator begin()
Definition: PtrVector.h:223
Float_t y
Definition: compare.C:6
list_type::const_iterator const_iterator
Definition: ParticleList.h:132
Double_t z
Definition: plot.C:279
int StatusCode() const
Definition: MCParticle.h:215
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
Definition: Event.cc:64
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:214
std::string fHitModuleLabel
Unclustered Hits.
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
bool fUseClusterHits
Use cluster hits or all hits?
bool isValid() const
Definition: Handle.h:190
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.
Definition: DumpUtils.h:265
void hits()
Definition: readHits.C:15
intermediate_table::const_iterator const_iterator
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
TString part[npart]
Definition: Style.C:32
iterator end()
Definition: PtrVector.h:237
iterator begin()
Definition: ParticleList.h:305
bool updateMomentum(const KETrack &tremom, const Propagator *prop, KGTrack &trg) const
Set track momentum at each track surface.
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 isDebugEnabled()
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.
Definition: geo_types.h:258
bool empty() const
Definition: PtrVector.h:336
size_type size() const
Definition: PtrVector.h:308
Detector simulation of raw signals on wires.
data_t::const_iterator const_iterator
Definition: PtrVector.h:61
void clearHitMap() const
int fNumTrack
Number of tracks produced.
TDirectory * dir
Definition: macro.C:5
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
void setPlane(int plane)
Set preferred view plane.
const TLorentzVector & Momentum(const int i=0) const
Definition: MCParticle.h:224
Int_t ipart
Definition: Style.C:10
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.
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:49
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:52
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
const Propagator * fProp
Propagator.
void trkf::TrackKalmanCheater::reconfigure ( fhicl::ParameterSet const &  pset)
virtual

Reconfigure method.

Arguments:

p - Fcl parameter set.

Definition at line 147 of file TrackKalmanCheater_module.cc.

References fClusterModuleLabel, fHist, fHitModuleLabel, fKFAlg, fMaxTcut, fProp, fSpacePointAlg, fUseClusterHits, fhicl::ParameterSet::get(), trkf::KalmanFilterAlg::reconfigure(), and trkf::SpacePointAlg::reconfigure().

Referenced by TrackKalmanCheater().

148 {
149  fHist = pset.get<bool>("Hist");
150  fKFAlg.reconfigure(pset.get<fhicl::ParameterSet>("KalmanFilterAlg"));
151  fSpacePointAlg.reconfigure(pset.get<fhicl::ParameterSet>("SpacePointAlg"));
152  fUseClusterHits = pset.get<bool>("UseClusterHits");
153  fHitModuleLabel = pset.get<std::string>("HitModuleLabel");
154  fClusterModuleLabel = pset.get<std::string>("ClusterModuleLabel");
155  fMaxTcut = pset.get<double>("MaxTcut");
156  if(fProp != 0)
157  delete fProp;
158  fProp = new PropYZPlane(fMaxTcut, true);
159 }
std::string fClusterModuleLabel
Clustered Hits.
KalmanFilterAlg fKFAlg
Kalman filter algorithm.
std::string fHitModuleLabel
Unclustered Hits.
bool fUseClusterHits
Use cluster hits or all hits?
void reconfigure(const fhicl::ParameterSet &pset)
Reconfigure method.
void reconfigure(const fhicl::ParameterSet &pset)
SpacePointAlg fSpacePointAlg
Space point algorithm.
double fMaxTcut
Maximum delta ray energy in MeV for restricted dE/dx.
const Propagator * fProp
Propagator.
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

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

Clustered Hits.

Definition at line 78 of file TrackKalmanCheater_module.cc.

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

TH1F* trkf::TrackKalmanCheater::fHIncChisq
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 73 of file TrackKalmanCheater_module.cc.

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

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

Unclustered Hits.

Definition at line 77 of file TrackKalmanCheater_module.cc.

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

TH1F* trkf::TrackKalmanCheater::fHPull
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 74 of file TrackKalmanCheater_module.cc.

Referenced by produce(), and reconfigure().

double trkf::TrackKalmanCheater::fMaxTcut
private

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

Definition at line 79 of file TrackKalmanCheater_module.cc.

Referenced by reconfigure().

int trkf::TrackKalmanCheater::fNumEvent
private

Number of events seen.

Definition at line 91 of file TrackKalmanCheater_module.cc.

Referenced by endJob(), and produce().

int trkf::TrackKalmanCheater::fNumTrack
private

Number of tracks produced.

Definition at line 92 of file TrackKalmanCheater_module.cc.

Referenced by endJob(), and produce().

const Propagator* trkf::TrackKalmanCheater::fProp
private

Propagator.

Definition at line 82 of file TrackKalmanCheater_module.cc.

Referenced by produce(), and reconfigure().

SpacePointAlg trkf::TrackKalmanCheater::fSpacePointAlg
private

Space point algorithm.

Definition at line 75 of file TrackKalmanCheater_module.cc.

Referenced by produce(), and reconfigure().

bool trkf::TrackKalmanCheater::fUseClusterHits
private

Use cluster hits or all hits?

Definition at line 76 of file TrackKalmanCheater_module.cc.

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


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