275 CLHEP::HepRandomEngine &engine = rng->
getEngine();
276 CLHEP::RandGaussQ gauss(engine);
282 std::unique_ptr<std::vector<recob::Track> > tcol(
new std::vector<recob::Track>);
283 std::unique_ptr< std::vector<recob::SpacePoint> > spcol (
new std::vector<recob::SpacePoint>);
307 for (
unsigned int ii = 0; ii < mctruthListHandle->size(); ++ii)
316 std::vector< art::Ptr<recob::SpacePoint> > spacepoints;
319 mf::LogInfo(
"Track3DKalman: ") <<
"There are " << trackListHandle->size() <<
" Track3Dreco/SpacePt tracks/groups (whichever) in this event.";
325 for(
unsigned int ii = 0; ii < trackListHandle->size(); ++ii)
346 for(
unsigned int ii = 0; ii < mclist.
size(); ++ii )
350 for(
int jj = 0; jj < mc->NParticles(); ++jj)
353 mf::LogInfo(
"Track3DKalman: ") <<
"FROM MC TRUTH, the particle's pdg code is: "<<
part.PdgCode()<<
" with energy = "<<
part.E() <<
", with energy = "<<
part.E()<<
" and vtx and momentum in Global (not volTPC) coords are " ;
372 mf::LogInfo(
"Track3DKalman: ") <<
" repMC, covMC are ... " ;
381 while(trackIter!=trackIn.
end()) {
383 spacepoints = fmsp.at(
nTrks);
385 mf::LogInfo(
"Track3DKalman: ") <<
"found "<< spacepoints.size() <<
" 3D spacepoint(s).";
388 if(spacepoints.size()>0){
390 const double resolution = 0.5;
398 momM.SetX(gauss.fire(momM.X(),momErr.X()));
399 momM.SetY(gauss.fire(momM.Y(),momErr.Y()));
400 momM.SetZ(gauss.fire(momM.Z(),momErr.Z()));
403 std::sort(spacepoints.begin(), spacepoints.end(),
sp_sort_3dz);
414 (TVector3)(spacepoints[0]->XYZ()),
428 for (
unsigned int point=0;point<spacepoints.size();++point)
431 TVector3 spt3(spacepoints[point]->XYZ());
435 TVector3 magNew(spt3[0],spt3[1],spt3[2]);
436 TVector3 magLast(spacepoints.back()->XYZ()[0],
437 spacepoints.back()->XYZ()[1],
438 spacepoints.back()->XYZ()[2]
440 if (!(magNew.Mag()>=magLast.Mag()+eps ||
441 magNew.Mag()<=magLast.Mag()-eps)
462 LOG_DEBUG(
"Track3DKalman: ") <<
"ihit xyz..." << spt3[0]<<
","<< spt3[1]<<
","<< spt3[2];
481 mf::LogError(
"Track3DKalman: ") <<
"just caught a GFException."<<std::endl;
483 mf::LogError(
"Track3DKalman: ") <<
"Exceptions won't be further handled ->exit(1) "<<__LINE__;
490 LOG_DEBUG(
"Track3DKalman: ") << __FILE__ <<
" " << __LINE__ ;
491 LOG_DEBUG(
"Track3DKalman: ") <<
"Track3DKalman.cxx: Original plane:";
494 LOG_DEBUG(
"Track3DKalman: ") <<
"Current (fit) reference Plane:";
497 LOG_DEBUG(
"Track3DKalman: ") <<
"Track3DKalman.cxx: Last reference Plane:";
503 LOG_DEBUG(
"Track3DKalman: ") <<
"Track3DKalman: Original hit plane (not surprisingly) not current reference Plane!"<<std::endl;
512 LOG_DEBUG(
"Track3DKalman: ") <<
" Final State and Cov:";
518 nfail = fitTrack.getFailedHits();
520 TVector3 dircoss = (*trackIter)->VertexDirection<TVector3>();
522 for (
int ii=0;ii<3;++ii)
524 fpMCT[ii] = MCMomentum[ii]/MCMomentum.Mag();
529 fpMCT[3] = MCMomentum.Mag();
530 fpREC[3] = -1.0/(*stREC)[0][0];
533 mf::LogInfo(
"Track3DKalman: ") <<
"Track3DKalman about to do tree->Fill(). Chi2/ndf is " <<
chi2/
ndf <<
". All in volTPC coords .... pMCT[0-3] is " <<
fpMCT[0] <<
", " <<
fpMCT[1] <<
", " <<
fpMCT[2] <<
", " <<
fpMCT[3] <<
". pREC[0-3] is " <<
fpREC[0] <<
", "<<
fpREC[1] <<
", " <<
fpREC[2] <<
", " <<
fpREC[3] <<
".";
538 std::vector< art::Ptr<recob::Cluster> > clusters = fmc.at(
nTrks);
539 std::vector< art::Ptr<recob::Hit> >
hits = fmh.at(
nTrks);
542 std::vector<TVector3> dircos(spacepoints.size());
543 dircos[0] = TVector3(fpREC);
544 dircos.back() = TVector3(
fpRECL);
547 std::vector<TVector3> xyz(spacepoints.size());
548 size_t spStart = spcol->size();
549 for(
size_t tv = 0; tv < spacepoints.size(); ++tv){
550 xyz[tv] = TVector3(spacepoints[tv]->XYZ());
551 spcol->push_back(*(spacepoints[tv].
get()));
553 size_t spEnd = spcol->size();
572 if(trackIter!=trackIn.
end()) trackIter++;
578 evt.
put(std::move(tcol));
579 evt.
put(std::move(spcol));
580 evt.
put(std::move(tcassn));
581 evt.
put(std::move(thassn));
582 evt.
put(std::move(tspassn));
unsigned int getNDF() const
static bool sp_sort_3dz(const art::Ptr< recob::SpacePoint > &h1, const art::Ptr< recob::SpacePoint > &h2)
const GFDetPlane & getReferencePlane() const
GFDetPlane getLastPlane() const
ROOT::Math::SMatrix< Double32_t, 5, 5, ROOT::Math::MatRepSym< Double32_t, 5 > > SMatrixSym55
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
std::vector< double > fMomStart
virtual const char * what() const
standard error message handling for exceptions. use like "std::cerr << e.what();" ...
TrackTrajectory::Flags_t Flags_t
void Print(std::ostream &out=std::cout) const
const TMatrixT< Double_t > & getState() const
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::vector< double > fMomErr
genf::GFAbsTrackRep * rep
ProductID put(std::unique_ptr< PROD > &&product)
TVector3 getNormal() const
base_engine_t & getEngine() const
void push_back(Ptr< U > const &p)
A trajectory in space reconstructed from hits.
void setNumIterations(Int_t i)
Set number of iterations for Kalman Filter.
void processTrack(GFTrack *)
Performs fit on a GFTrack.
static GFFieldManager * getInstance()
std::string fGenieGenModuleLabel
genf::GFAbsTrackRep * repMC
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.
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
const TMatrixT< Double_t > & getCov() const
data_t::const_iterator const_iterator
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
std::string fSpacePtsModuleLabel
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
TMatrixT< Double_t > * stMCT
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
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
std::vector< double > fPosErr
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
TMatrixT< Double_t > * covMCT
std::string GetLArTPCVolumeName(geo::TPCID const &tpcid) const
Return the name of specified LAr TPC volume.
TMatrixT< Double_t > * covREC