LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
trkf::Track3DKalman Class Reference
Inheritance diagram for trkf::Track3DKalman:
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

 Track3DKalman (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 &evt) override
 
void beginJob () override
 
void endJob () override
 

Private Attributes

std::string fSpacePtsModuleLabel
 
std::string fGenieGenModuleLabel
 
std::string fG4ModuleLabel
 
bool fGenfPRINT
 
TTree * tree
 
TMatrixT< Double_t > * stMCT
 
TMatrixT< Double_t > * covMCT
 
TMatrixT< Double_t > * stREC
 
TMatrixT< Double_t > * covREC
 
Float_t chi2
 
Float_t chi2ndf
 
Float_t * fpRECt3D
 
Float_t * fpRECL
 
Float_t * fpREC
 
Float_t * fpMCT
 
int nfail
 
int ndf
 
unsigned int evtt
 
unsigned int nTrks
 
unsigned int fptsNo
 
Float_t * fshx
 
Float_t * fshy
 
Float_t * fshz
 
unsigned int fDimSize
 
std::vector< double > fPosErr
 
std::vector< double > fMomErr
 
std::vector< double > fMomStart
 
genf::GFAbsTrackReprepMC
 
genf::GFAbsTrackReprep
 
CLHEP::HepRandomEngine & fEngine
 

Detailed Description

Definition at line 62 of file Track3DKalman_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::Track3DKalman::Track3DKalman ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 121 of file Track3DKalman_module.cc.

References art::detail::EngineCreator::createEngine(), fEngine, fG4ModuleLabel, fGenfPRINT, fGenieGenModuleLabel, fMomErr, fMomStart, fPosErr, and fSpacePtsModuleLabel.

122  : EDProducer{pset}
123  , fSpacePtsModuleLabel{pset.get<std::string>("SpacePtsModuleLabel")}
124  , fGenieGenModuleLabel{pset.get<std::string>("GenieGenModuleLabel")}
125  , fG4ModuleLabel{pset.get<std::string>("G4ModuleLabel")}
126  , fGenfPRINT{pset.get<bool>("GenfPRINT")}
127  , fPosErr{pset.get<std::vector<double>>("PosErr3")} // resolution. cm
128  , fMomErr{pset.get<std::vector<double>>("MomErr3")} // GeV
129  , fMomStart{pset.get<std::vector<double>>("MomStart3")} // Will be unit norm'd.
130  // create a default random engine; obtain the random seed from NuRandomService,
131  // unless overridden in configuration with key "Seed"
132  , fEngine(art::ServiceHandle<rndm::NuRandomService>()->registerAndSeedEngine(createEngine(0),
133  pset,
134  "Seed"))
135  {
136  produces<std::vector<recob::Track>>();
137  produces<std::vector<recob::SpacePoint>>();
138  produces<art::Assns<recob::Track, recob::Cluster>>();
139  produces<art::Assns<recob::Track, recob::SpacePoint>>();
140  produces<art::Assns<recob::Track, recob::Hit>>();
141  }
base_engine_t & createEngine(seed_t seed)
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.cc:6
std::vector< double > fMomStart
std::vector< double > fMomErr
CLHEP::HepRandomEngine & fEngine
std::vector< double > fPosErr

Member Function Documentation

void trkf::Track3DKalman::beginJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 144 of file Track3DKalman_module.cc.

References chi2, chi2ndf, covMCT, covREC, evtt, fDimSize, fpMCT, fpREC, fpRECL, fpRECt3D, fptsNo, fshx, fshy, fshz, ndf, nfail, nTrks, stMCT, stREC, and tree.

145  {
147 
148  stMCT = new TMatrixT<Double_t>(5, 1);
149  covMCT = new TMatrixT<Double_t>(5, 5);
150  stREC = new TMatrixT<Double_t>(5, 1);
151  covREC = new TMatrixT<Double_t>(5, 5);
152 
153  fpMCT = new Float_t[4];
154  fpREC = new Float_t[4];
155  fpRECL = new Float_t[4];
156  fpRECt3D = new Float_t[4];
157  fDimSize = 400; // if necessary will get this from pset in constructor.
158 
159  fshx = new Float_t[fDimSize];
160  fshy = new Float_t[fDimSize];
161  fshz = new Float_t[fDimSize];
162 
163  tree = tfs->make<TTree>("GENFITttree", "GENFITttree");
164  //tree->Branch("stMCT",&stMCT,"stMCT[5]/F"); // "TMatrixT<Double_t>"
165 
166  tree->Branch("stMCT", "TMatrixD", &stMCT, 64000, 0);
167  //tree->Branch("covMCT",&covMCT,"covMCT[25]/F");
168  tree->Branch("covMCT", "TMatrixD", &covMCT, 64000, 0);
169  //tree->Branch("stREC",&stREC,"stREC[5]/F");
170  tree->Branch("stREC", "TMatrixD", &stREC, 64000, 0);
171  //tree->Branch("covREC",&covREC,"covREC[25]/F");
172  tree->Branch("covREC", "TMatrixD", &covREC, 64000, 0);
173 
174  tree->Branch("chi2", &chi2, "chi2/F");
175  tree->Branch("nfail", &nfail, "nfail/I");
176  tree->Branch("ndf", &ndf, "ndf/I");
177  tree->Branch("evtNo", &evtt, "evtNo/I");
178  tree->Branch("chi2ndf", &chi2ndf, "chi2ndf/F");
179 
180  tree->Branch("trkNo", &nTrks, "trkNo/I");
181  tree->Branch("ptsNo", &fptsNo, "ptsNo/I");
182  tree->Branch("shx", fshx, "shx[ptsNo]/F");
183  tree->Branch("shy", fshy, "shy[ptsNo]/F");
184  tree->Branch("shz", fshz, "shz[ptsNo]/F");
185 
186  tree->Branch("pMCT", fpMCT, "pMCT[4]/F");
187  tree->Branch("pRECKalF", fpREC, "pRECKalF[4]/F");
188  tree->Branch("pRECKalL", fpRECL, "pRECKalL[4]/F");
189  tree->Branch("pRECt3D", fpRECt3D, "pRECt3D[4]/F");
190  }
TMatrixT< Double_t > * stMCT
TMatrixT< Double_t > * stREC
TMatrixT< Double_t > * covMCT
TMatrixT< Double_t > * covREC
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::Track3DKalman::endJob ( )
overrideprivatevirtual

Reimplemented from art::EDProducer.

Definition at line 193 of file Track3DKalman_module.cc.

References rep, and repMC.

194  {
195  if (!rep) delete rep;
196  if (!repMC) delete repMC;
197  }
genf::GFAbsTrackRep * rep
genf::GFAbsTrackRep * repMC
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::Track3DKalman::produce ( art::Event evt)
overrideprivatevirtual
Todo:
: remove this statement, there is no place for checks on isRealData in reconstruction code

Implements art::EDProducer.

Definition at line 200 of file Track3DKalman_module.cc.

References genf::GFTrack::addHit(), art::PtrVector< T >::begin(), chi2, chi2ndf, recob::tracking::convertCollToPoint(), recob::tracking::convertCollToVector(), covMCT, covREC, util::CreateAssn(), DEFINE_ART_MODULE, e, art::PtrVector< T >::end(), art::EventID::event(), evtt, fDimSize, fEngine, fGenfPRINT, fGenieGenModuleLabel, fMomErr, fMomStart, fpMCT, fPosErr, fpREC, fpRECL, fpRECt3D, fptsNo, fshx, fshy, fshz, fSpacePtsModuleLabel, art::ProductRetriever::getByLabel(), genf::GFAbsTrackRep::getChiSqu(), genf::GFAbsTrackRep::getCov(), genf::GFTrack::getFailedHits(), genf::GFFieldManager::getInstance(), geo::GeometryCore::GetLArTPCVolumeName(), genf::GFAbsTrackRep::getLastPlane(), genf::GFAbsTrackRep::getNDF(), genf::GFDetPlane::getNormal(), simb::MCTruth::GetParticle(), genf::GFAbsTrackRep::getReferencePlane(), genf::GFAbsTrackRep::getState(), genf::GFAbsTrackRep::getStatusFlag(), hits(), art::Event::id(), genf::GFFieldManager::init(), art::Event::isRealData(), MF_LOG_DEBUG, ndf, nfail, simb::MCTruth::NParticles(), nTrks, part, genf::GFDetPlane::Print(), genf::GFKalman::processTrack(), art::PtrVector< T >::push_back(), art::Event::put(), rep, repMC, genf::GFKalman::setNumIterations(), art::PtrVector< T >::size(), sp_sort_3dz(), stMCT, stREC, track, tree, and GFException::what().

201  {
202  rep = 0;
203  repMC = 0;
204 
205  // get services
207  CLHEP::RandGaussQ gauss(fEngine);
208 
210  // Make a std::unique_ptr<> for the thing you want to put into the event
211  // because that handles the memory management for you
213  std::unique_ptr<std::vector<recob::Track>> tcol(new std::vector<recob::Track>);
214  std::unique_ptr<std::vector<recob::SpacePoint>> spcol(new std::vector<recob::SpacePoint>);
215  std::unique_ptr<art::Assns<recob::Track, recob::SpacePoint>> tspassn(
217  std::unique_ptr<art::Assns<recob::Track, recob::Cluster>> tcassn(
219  std::unique_ptr<art::Assns<recob::Track, recob::Hit>> thassn(
221 
222  // define TPC parameters
223  TString tpcName = geom->GetLArTPCVolumeName();
224 
225  // get input Hit object(s).
226  art::Handle<std::vector<recob::Track>> trackListHandle;
227  evt.getByLabel(fSpacePtsModuleLabel, trackListHandle);
228 
230 
231  if (!evt.isRealData()) {
232  art::Handle<std::vector<simb::MCTruth>> mctruthListHandle;
233  evt.getByLabel(fGenieGenModuleLabel, mctruthListHandle);
234 
235  for (unsigned int ii = 0; ii < mctruthListHandle->size(); ++ii) {
236  art::Ptr<simb::MCTruth> mctparticle(mctruthListHandle, ii);
237  mclist.push_back(mctparticle);
238  }
239  }
240 
241  //create collection of spacepoints that will be used when creating the Track object
242  std::vector<art::Ptr<recob::SpacePoint>> spacepoints;
244  // std::cout<<"Run "<<evt.run()<<" Event "<<evt.id().event()<<std::endl;
245  mf::LogInfo("Track3DKalman: ")
246  << "There are " << trackListHandle->size()
247  << " Track3Dreco/SpacePt tracks/groups (whichever) in this event.";
248 
249  art::FindManyP<recob::SpacePoint> fmsp(trackListHandle, evt, fSpacePtsModuleLabel);
250  art::FindManyP<recob::Cluster> fmc(trackListHandle, evt, fSpacePtsModuleLabel);
251  art::FindManyP<recob::Hit> fmh(trackListHandle, evt, fSpacePtsModuleLabel);
252 
253  for (unsigned int ii = 0; ii < trackListHandle->size(); ++ii) {
254  art::Ptr<recob::Track> track(trackListHandle, ii);
255  trackIn.push_back(track);
256  }
257 
258  TVector3 MCOrigin;
259  TVector3 MCMomentum;
260  // TVector3 posErr(.05,.05,.05); // resolution. 0.5mm
261  // TVector3 momErr(.1,.1,0.2); // GeV
262  TVector3 posErr(fPosErr[0], fPosErr[1], fPosErr[2]); // resolution. 0.5mm
263  TVector3 momErr(fMomErr[0], fMomErr[1], fMomErr[2]); // GeV
264 
265  // This is strictly for MC
267  if (!evt.isRealData()) {
268  // Below breaks are stupid, I realize. But rather than keep all the MC
269  // particles I just take the first primary, e.g., muon and only keep its
270  // info in the branches of the Ttree. I could generalize later, ...
271  for (unsigned int ii = 0; ii < mclist.size(); ++ii) {
272  //art::Ptr<const simb::MCTruth> mc(mctruthListHandle,i);
273  art::Ptr<simb::MCTruth> mc(mclist[ii]);
274  for (int jj = 0; jj < mc->NParticles(); ++jj) {
275  simb::MCParticle part(mc->GetParticle(jj));
276  mf::LogInfo("Track3DKalman: ")
277  << "FROM MC TRUTH, the particle's pdg code is: " << part.PdgCode()
278  << " with energy = " << part.E() << ", with energy = " << part.E()
279  << " and vtx and momentum in Global (not volTPC) coords are ";
280  MCOrigin.SetXYZ(part.Vx(), part.Vy(), part.Vz()); // V for Vertex
281  MCMomentum.SetXYZ(part.Px(), part.Py(), part.Pz());
282  MCOrigin.Print();
283  MCMomentum.Print();
284  repMC = new genf::RKTrackRep(MCOrigin, MCMomentum, posErr, momErr, part.PdgCode());
285  break;
286  }
287  break;
288  }
289  //for saving of MC truth
290  stMCT->ResizeTo(repMC->getState());
291  *stMCT = repMC->getState();
292  covMCT->ResizeTo(repMC->getCov());
293  *covMCT = repMC->getCov();
294  mf::LogInfo("Track3DKalman: ") << " repMC, covMC are ... ";
295  repMC->getState().Print();
296  repMC->getCov().Print();
297 
298  } // !isRealData
299 
301 
302  nTrks = 0;
303  while (trackIter != trackIn.end()) {
304  spacepoints.clear();
305  spacepoints = fmsp.at(nTrks);
306 
307  mf::LogInfo("Track3DKalman: ") << "found " << spacepoints.size() << " 3D spacepoint(s).";
308 
309  // Add the 3D track to the vector of the reconstructed tracks
310  if (spacepoints.size() > 0) {
311  // Insert the GENFIT/Kalman stuff here then make the tracks. Units are cm, GeV.
312  const double resolution = 0.5; // dunno, 5 mm
313  const int numIT = 3; // 3->1, EC, 6-Jan-2011. Back, 7-Jan-2011.
314 
315  //TVector3 mom(0.0,0.0,2.0);
316  TVector3 mom(fMomStart[0], fMomStart[1], fMomStart[2]);
317  //mom.SetMag(1.);
318  TVector3 momM(mom);
319  momM.SetX(gauss.fire(momM.X(), momErr.X() /* *momM.X() */));
320  momM.SetY(gauss.fire(momM.Y(), momErr.Y() /* *momM.Y() */));
321  momM.SetZ(gauss.fire(momM.Z(), momErr.Z() /* *momM.Z() */));
322  //std::cout << "Track3DKalman: sort spacepoints by z
323 
324  std::sort(spacepoints.begin(), spacepoints.end(), sp_sort_3dz);
325 
326  //std::sort(spacepoints.begin(), spacepoints.end(), sp_sort_3dx); // Reverse sort!
327 
329  genf::GFDetPlane planeG((TVector3)(spacepoints[0]->XYZ()), momM);
330 
331  // std::cout<<"Track3DKalman about to do GAbsTrackRep."<<std::endl;
332  // Initialize with 1st spacepoint location and a guess at the momentum.
333  rep = new genf::RKTrackRep( //posM-.5/momM.Mag()*momM,
334  (TVector3)(spacepoints[0]->XYZ()),
335  momM,
336  posErr,
337  momErr,
338  13); // mu- hypothesis
339  // std::cout<<"Track3DKalman: about to do GFTrack. repDim is " << rep->getDim() <<std::endl;
340 
341  genf::GFTrack fitTrack(rep); //initialized with smeared rep
342  // Gonna sort in x cuz I want to essentially transform here to volTPC coords.
343  // volTPC coords, cuz that's what the Geant3/Geane stepper wants, as that's its understanding
344  // from the Geant4 geometry, which it'll use. EC, 7-Jan-2011.
345  int ihit = 0;
346  fptsNo = 0;
347  for (unsigned int point = 0; point < spacepoints.size(); ++point) {
348 
349  TVector3 spt3(spacepoints[point]->XYZ());
350  if (point > 0) {
351  double eps(0.1);
352  TVector3 magNew(spt3[0], spt3[1], spt3[2]);
353  TVector3 magLast(spacepoints.back()->XYZ()[0],
354  spacepoints.back()->XYZ()[1],
355  spacepoints.back()->XYZ()[2]);
356  if (!(magNew.Mag() >= magLast.Mag() + eps || magNew.Mag() <= magLast.Mag() - eps))
357  continue;
358  }
359 
360  if (point % 20) // Jump out of loop except on every 20th pt.
361  {
362  //continue;
363  // Icarus paper suggests we may wanna decimate our data in order to give
364  // trackfitter a better idea of multiple-scattering. EC, 7-Jan-2011.
365  //if (std::abs(spt3[0]-spacepoints.at(point-1).XYZ()[0]) < 2) continue;
366  }
367  if (fptsNo < fDimSize) {
368  fshx[fptsNo] = spt3[0];
369  fshy[fptsNo] = spt3[1];
370  fshz[fptsNo] = spt3[2];
371  }
372  fptsNo++;
373 
374  MF_LOG_DEBUG("Track3DKalman: ")
375  << "ihit xyz..." << spt3[0] << "," << spt3[1] << "," << spt3[2];
376  fitTrack.addHit(new genf::PointHit(spt3, resolution),
377  1, //dummy detector id
378  ihit++);
379  }
380 
381  // std::cout<<"Track3DKalman about to do GFKalman."<<std::endl;
382  genf::GFKalman k;
383  //k.setBlowUpFactor(500); // Instead of 500 out of box. EC, 6-Jan-2011.
384  //k.setInitialDirection(+1); // Instead of 1 out of box. EC, 6-Jan-2011.
385  k.setNumIterations(numIT);
386  // std::cout<<"Track3DKalman back from setNumIterations."<<std::endl;
387  try {
388  // std::cout<<"Track3DKalman about to processTrack."<<std::endl;
389  k.processTrack(&fitTrack);
390  //std::cout<<"Track3DKalman back from processTrack."<<std::endl;
391  }
392  catch (GFException& e) {
393  mf::LogError("Track3DKalman: ") << "just caught a GFException." << std::endl;
394  e.what();
395  mf::LogError("Track3DKalman: ")
396  << "Exceptions won't be further handled ->exit(1) " << __LINE__;
397 
398  // exit(1);
399  }
400 
401  if (rep->getStatusFlag() == 0) // 0 is successful completion
402  {
403  MF_LOG_DEBUG("Track3DKalman: ") << __FILE__ << " " << __LINE__;
404  MF_LOG_DEBUG("Track3DKalman: ") << "Track3DKalman.cxx: Original plane:";
405 
406  if (fGenfPRINT) planeG.Print();
407  MF_LOG_DEBUG("Track3DKalman: ") << "Current (fit) reference Plane:";
409 
410  MF_LOG_DEBUG("Track3DKalman: ") << "Track3DKalman.cxx: Last reference Plane:";
411  if (fGenfPRINT) rep->getLastPlane().Print();
412 
413  if (fGenfPRINT) {
414  if (planeG != rep->getReferencePlane())
415  MF_LOG_DEBUG("Track3DKalman: ") << "Track3DKalman: Original hit plane (not "
416  "surprisingly) not current reference Plane!"
417  << std::endl;
418  }
419 
420  stREC->ResizeTo(rep->getState());
421  *stREC = rep->getState();
422  covREC->ResizeTo(rep->getCov());
423  *covREC = rep->getCov();
424  if (fGenfPRINT) {
425  MF_LOG_DEBUG("Track3DKalman: ") << " Final State and Cov:";
426  stREC->Print();
427  covREC->Print();
428  }
429  chi2 = rep->getChiSqu();
430  ndf = rep->getNDF();
431  nfail = fitTrack.getFailedHits();
432  chi2ndf = chi2 / ndf;
433  TVector3 dircoss = (*trackIter)->VertexDirection<TVector3>();
434 
435  for (int ii = 0; ii < 3; ++ii) {
436  fpMCT[ii] = MCMomentum[ii] / MCMomentum.Mag();
437  fpREC[ii] = rep->getReferencePlane().getNormal()[ii];
438  fpRECL[ii] = rep->getLastPlane().getNormal()[ii];
439  fpRECt3D[ii] = dircoss[ii];
440  }
441  fpMCT[3] = MCMomentum.Mag();
442  fpREC[3] = -1.0 / (*stREC)[0][0];
443 
444  evtt = (unsigned int)evt.id().event();
445  mf::LogInfo("Track3DKalman: ")
446  << "Track3DKalman about to do tree->Fill(). Chi2/ndf is " << chi2 / ndf
447  << ". All in volTPC coords .... pMCT[0-3] is " << fpMCT[0] << ", " << fpMCT[1] << ", "
448  << fpMCT[2] << ", " << fpMCT[3] << ". pREC[0-3] is " << fpREC[0] << ", " << fpREC[1]
449  << ", " << fpREC[2] << ", " << fpREC[3] << ".";
450 
451  tree->Fill();
452 
453  // Get the clusters associated to each track in induction and collection view
454  std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(nTrks);
455  std::vector<art::Ptr<recob::Hit>> hits = fmh.at(nTrks);
456 
457  // Use new Track constructor... EC, 21-Apr-2011.
458  std::vector<TVector3> dircos(spacepoints.size());
459  dircos[0] = TVector3(fpREC);
460  dircos.back() = TVector3(fpRECL);
461 
462  // fill a vector of TVector3 with the space points used to make this track
463  std::vector<TVector3> xyz(spacepoints.size());
464  size_t spStart = spcol->size();
465  for (size_t tv = 0; tv < spacepoints.size(); ++tv) {
466  xyz[tv] = TVector3(spacepoints[tv]->XYZ());
467  spcol->push_back(*(spacepoints[tv].get()));
468  }
469  size_t spEnd = spcol->size();
470 
471  tcol->push_back(
474  recob::Track::Flags_t(xyz.size()),
475  false),
476  0,
477  -1.,
478  0,
481  tcol->size() - 1));
482 
483  // associate the track with its clusters and tracks
484  util::CreateAssn(evt, *tcol, clusters, *tcassn);
485  util::CreateAssn(evt, *tcol, hits, *thassn);
486 
487  // associate the track to the space points
488  util::CreateAssn(evt, *tcol, *spcol, *tspassn, spStart, spEnd);
489 
490  } // getStatusFlag
491  } // spacepoints.size()>0
492 
493  //
494  //std::cout<<"Track3DKalman found "<< tcol->size() <<" 3D track(s)"<<std::endl;
495  if (trackIter != trackIn.end()) trackIter++;
496 
497  nTrks++;
498 
499  } // end loop over Track3Dreco/SpacePt tracks/groups (whichever) we brought into this event.
500 
501  evt.put(std::move(tcol));
502  evt.put(std::move(spcol));
503  evt.put(std::move(tcassn));
504  evt.put(std::move(thassn));
505  evt.put(std::move(tspassn));
506 
507  } // end method
unsigned int getNDF() const
std::string GetLArTPCVolumeName(TPCID const &tpcid=tpc_zero) const
Return the name of specified LAr TPC volume.
static bool sp_sort_3dz(const art::Ptr< recob::SpacePoint > &h1, const art::Ptr< recob::SpacePoint > &h2)
const GFDetPlane & getReferencePlane() const
GFDetPlane getLastPlane() const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
Definition: TrackingTypes.h:78
iterator begin()
Definition: PtrVector.h:217
std::vector< double > fMomStart
TrackTrajectory::Flags_t Flags_t
Definition: Track.h:67
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 >> SMatrixSym55
void Print(std::ostream &out=std::cout) const
Definition: GFDetPlane.cxx:228
const TMatrixT< Double_t > & getState() const
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
bool isRealData() const
Definition: Event.cc:53
std::vector< double > fMomErr
genf::GFAbsTrackRep * rep
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
TVector3 getNormal() const
Definition: GFDetPlane.cxx:133
TString part[npart]
Definition: Style.C:32
void hits()
Definition: readHits.C:15
typename data_t::const_iterator const_iterator
Definition: PtrVector.h:55
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:435
A trajectory in space reconstructed from hits.
iterator end()
Definition: PtrVector.h:231
void setNumIterations(Int_t i)
Set number of iterations for Kalman Filter.
Definition: GFKalman.h:91
void processTrack(GFTrack *)
Performs fit on a GFTrack.
Definition: GFKalman.cxx:57
static GFFieldManager * getInstance()
genf::GFAbsTrackRep * repMC
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
Definition: TrackingTypes.h:68
const TMatrixT< Double_t > & getCov() const
size_type size() const
Definition: PtrVector.h:302
const char * what() const noexcept override
standard error message handling for exceptions. use like "std::cerr << e.what();" ...
Definition: GFException.cxx:55
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.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:47
TMatrixT< Double_t > * stMCT
#define MF_LOG_DEBUG(id)
TMatrixT< Double_t > * stREC
void init(GFAbsBField *b)
set the magntic field here. Magnetic field classes must be derived from GFAbsBField ...
EventNumber_t event() const
Definition: EventID.h:116
CLHEP::HepRandomEngine & fEngine
double getChiSqu() const
Float_t e
Definition: plot.C:35
Float_t track
Definition: plot.C:35
std::vector< double > fPosErr
EventID id() const
Definition: Event.cc:23
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
TMatrixT< Double_t > * covMCT
TMatrixT< Double_t > * covREC
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

Float_t trkf::Track3DKalman::chi2
private

Definition at line 82 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

Float_t trkf::Track3DKalman::chi2ndf
private

Definition at line 83 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

TMatrixT<Double_t>* trkf::Track3DKalman::covMCT
private

Definition at line 79 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

TMatrixT<Double_t>* trkf::Track3DKalman::covREC
private

Definition at line 81 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

unsigned int trkf::Track3DKalman::evtt
private

Definition at line 91 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

unsigned int trkf::Track3DKalman::fDimSize
private

Definition at line 97 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

CLHEP::HepRandomEngine& trkf::Track3DKalman::fEngine
private

Definition at line 104 of file Track3DKalman_module.cc.

Referenced by produce(), and Track3DKalman().

std::string trkf::Track3DKalman::fG4ModuleLabel
private

Definition at line 73 of file Track3DKalman_module.cc.

Referenced by Track3DKalman().

bool trkf::Track3DKalman::fGenfPRINT
private

Definition at line 74 of file Track3DKalman_module.cc.

Referenced by produce(), and Track3DKalman().

std::string trkf::Track3DKalman::fGenieGenModuleLabel
private

Definition at line 72 of file Track3DKalman_module.cc.

Referenced by produce(), and Track3DKalman().

std::vector<double> trkf::Track3DKalman::fMomErr
private

Definition at line 100 of file Track3DKalman_module.cc.

Referenced by produce(), and Track3DKalman().

std::vector<double> trkf::Track3DKalman::fMomStart
private

Definition at line 101 of file Track3DKalman_module.cc.

Referenced by produce(), and Track3DKalman().

Float_t* trkf::Track3DKalman::fpMCT
private

Definition at line 88 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

std::vector<double> trkf::Track3DKalman::fPosErr
private

Definition at line 99 of file Track3DKalman_module.cc.

Referenced by produce(), and Track3DKalman().

Float_t* trkf::Track3DKalman::fpREC
private

Definition at line 87 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

Float_t* trkf::Track3DKalman::fpRECL
private

Definition at line 86 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

Float_t* trkf::Track3DKalman::fpRECt3D
private

Definition at line 85 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

unsigned int trkf::Track3DKalman::fptsNo
private

Definition at line 93 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

Float_t* trkf::Track3DKalman::fshx
private

Definition at line 94 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

Float_t* trkf::Track3DKalman::fshy
private

Definition at line 95 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

Float_t* trkf::Track3DKalman::fshz
private

Definition at line 96 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

std::string trkf::Track3DKalman::fSpacePtsModuleLabel
private

Definition at line 71 of file Track3DKalman_module.cc.

Referenced by produce(), and Track3DKalman().

int trkf::Track3DKalman::ndf
private

Definition at line 90 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

int trkf::Track3DKalman::nfail
private

Definition at line 89 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

unsigned int trkf::Track3DKalman::nTrks
private

Definition at line 92 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

genf::GFAbsTrackRep* trkf::Track3DKalman::rep
private

Definition at line 103 of file Track3DKalman_module.cc.

Referenced by endJob(), and produce().

genf::GFAbsTrackRep* trkf::Track3DKalman::repMC
private

Definition at line 102 of file Track3DKalman_module.cc.

Referenced by endJob(), and produce().

TMatrixT<Double_t>* trkf::Track3DKalman::stMCT
private

Definition at line 78 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

TMatrixT<Double_t>* trkf::Track3DKalman::stREC
private

Definition at line 80 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().

TTree* trkf::Track3DKalman::tree
private

Definition at line 76 of file Track3DKalman_module.cc.

Referenced by beginJob(), and produce().


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