50 #include "TGeoManager.h" 73 #include "CLHEP/Random/RandFlat.h" 74 #include "CLHEP/Random/RandGaussQ.h" 140 const double* xyz1 = h1->
XYZ();
141 const double* xyz2 = h2->
XYZ();
142 return xyz1[2] < xyz2[2];
157 produces< std::vector<recob::Track> >();
158 produces< std::vector<recob::SpacePoint> >();
159 produces< art::Assns<recob::Track, recob::Cluster> >();
160 produces< art::Assns<recob::Track, recob::SpacePoint> >();
161 produces< art::Assns<recob::Track, recob::Hit> >();
172 fPosErr = pset.
get< std::vector < double > >(
"PosErr3");
173 fMomErr = pset.
get< std::vector < double > >(
"MomErr3");
174 fMomStart = pset.
get< std::vector < double > >(
"MomStart3");
203 stMCT =
new TMatrixT<Double_t>(5,1);
204 covMCT =
new TMatrixT<Double_t>(5,5);
205 stREC =
new TMatrixT<Double_t>(5,1);
206 covREC =
new TMatrixT<Double_t>(5,5);
208 fpMCT =
new Float_t[4];
209 fpREC =
new Float_t[4];
221 tree = tfs->
make<TTree>(
"GENFITttree",
"GENFITttree");
224 tree->Branch(
"stMCT",
"TMatrixD",&
stMCT,64000,0);
226 tree->Branch(
"covMCT",
"TMatrixD",&covMCT,64000,0);
228 tree->Branch(
"stREC",
"TMatrixD",&stREC,64000,0);
230 tree->Branch(
"covREC",
"TMatrixD",&covREC,64000,0);
233 tree->Branch(
"chi2",&
chi2,
"chi2/F");
235 tree->Branch(
"ndf",&
ndf,
"ndf/I");
236 tree->Branch(
"evtNo",&
evtt,
"evtNo/I");
241 tree->Branch(
"shx",
fshx,
"shx[ptsNo]/F");
242 tree->Branch(
"shy",
fshy,
"shy[ptsNo]/F");
243 tree->Branch(
"shz",
fshz,
"shz[ptsNo]/F");
245 tree->Branch(
"pMCT",fpMCT,
"pMCT[4]/F");
246 tree->Branch(
"pRECKalF",
fpREC,
"pRECKalF[4]/F");
247 tree->Branch(
"pRECKalL",
fpRECL,
"pRECKalL[4]/F");
276 CLHEP::HepRandomEngine &engine = rng->
getEngine();
277 CLHEP::RandGaussQ gauss(engine);
283 std::unique_ptr<std::vector<recob::Track> > tcol(
new std::vector<recob::Track>);
284 std::unique_ptr< std::vector<recob::SpacePoint> > spcol (
new std::vector<recob::SpacePoint>);
308 for (
unsigned int ii = 0; ii < mctruthListHandle->size(); ++ii)
317 std::vector< art::Ptr<recob::SpacePoint> > spacepoints;
320 mf::LogInfo(
"Track3DKalman: ") <<
"There are " << trackListHandle->size() <<
" Track3Dreco/SpacePt tracks/groups (whichever) in this event.";
326 for(
unsigned int ii = 0; ii < trackListHandle->size(); ++ii)
347 for(
unsigned int ii = 0; ii < mclist.
size(); ++ii )
354 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 " ;
373 mf::LogInfo(
"Track3DKalman: ") <<
" repMC, covMC are ... " ;
382 while(trackIter!=trackIn.
end()) {
384 spacepoints = fmsp.at(
nTrks);
386 mf::LogInfo(
"Track3DKalman: ") <<
"found "<< spacepoints.size() <<
" 3D spacepoint(s).";
389 if(spacepoints.size()>0){
391 const double resolution = 0.5;
399 momM.SetX(gauss.fire(momM.X(),momErr.X()));
400 momM.SetY(gauss.fire(momM.Y(),momErr.Y()));
401 momM.SetZ(gauss.fire(momM.Z(),momErr.Z()));
404 std::sort(spacepoints.begin(), spacepoints.end(),
sp_sort_3dz);
415 (TVector3)(spacepoints[0]->XYZ()),
429 for (
unsigned int point=0;point<spacepoints.size();++point)
432 TVector3 spt3(spacepoints[point]->XYZ());
436 TVector3 magNew(spt3[0],spt3[1],spt3[2]);
437 TVector3 magLast(spacepoints.back()->XYZ()[0],
438 spacepoints.back()->XYZ()[1],
439 spacepoints.back()->XYZ()[2]
441 if (!(magNew.Mag()>=magLast.Mag()+eps ||
442 magNew.Mag()<=magLast.Mag()-eps)
463 LOG_DEBUG(
"Track3DKalman: ") <<
"ihit xyz..." << spt3[0]<<
","<< spt3[1]<<
","<< spt3[2];
482 mf::LogError(
"Track3DKalman: ") <<
"just caught a GFException."<<std::endl;
484 mf::LogError(
"Track3DKalman: ") <<
"Exceptions won't be further handled ->exit(1) "<<__LINE__;
491 LOG_DEBUG(
"Track3DKalman: ") << __FILE__ <<
" " << __LINE__ ;
492 LOG_DEBUG(
"Track3DKalman: ") <<
"Track3DKalman.cxx: Original plane:";
495 LOG_DEBUG(
"Track3DKalman: ") <<
"Current (fit) reference Plane:";
498 LOG_DEBUG(
"Track3DKalman: ") <<
"Track3DKalman.cxx: Last reference Plane:";
504 LOG_DEBUG(
"Track3DKalman: ") <<
"Track3DKalman: Original hit plane (not surprisingly) not current reference Plane!"<<std::endl;
513 LOG_DEBUG(
"Track3DKalman: ") <<
" Final State and Cov:";
521 double dircoss[3],dircose[3];
522 (*trackIter)->Direction(dircoss,dircose);
524 for (
int ii=0;ii<3;++ii)
526 fpMCT[ii] = MCMomentum[ii]/MCMomentum.Mag();
531 fpMCT[3] = MCMomentum.Mag();
532 fpREC[3] = -1.0/(*stREC)[0][0];
535 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] <<
".";
540 std::vector< art::Ptr<recob::Cluster> > clusters = fmc.at(
nTrks);
541 std::vector< art::Ptr<recob::Hit> >
hits = fmh.at(
nTrks);
544 std::vector<TVector3> dircos(spacepoints.size());
545 dircos[0] = TVector3(fpREC);
546 dircos.back() = TVector3(
fpRECL);
549 std::vector<TVector3> xyz(spacepoints.size());
550 size_t spStart = spcol->size();
551 for(
size_t tv = 0; tv < spacepoints.size(); ++tv){
552 xyz[tv] = TVector3(spacepoints[tv]->XYZ());
553 spcol->push_back(*(spacepoints[tv].
get()));
555 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));
std::string fG4ModuleLabel
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
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Declaration of signal hit object.
std::vector< double > fMomStart
virtual const char * what() const
standard error message handling for exceptions. use like "std::cerr << e.what();" ...
void Print(std::ostream &out=std::cout) const
const TMatrixT< Double_t > & getState() const
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void produce(art::Event &evt)
std::vector< double > fMomErr
genf::GFAbsTrackRep * rep
Base Class for genfit track representations. Defines interface for track parameterizations.
ProductID put(std::unique_ptr< PROD > &&product)
TVector3 getNormal() const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
base_engine_t & getEngine() const
base_engine_t & createEngine(seed_t seed)
#define DEFINE_ART_MODULE(klass)
void push_back(Ptr< U > const &p)
T get(std::string const &key) const
void setNumIterations(Int_t i)
Set number of iterations for Kalman Filter.
int getFailedHits(int repId=-1)
return the number of failed Hits in track fit repId == -1 will use cardinal rep
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.
Declaration of cluster object.
const TMatrixT< Double_t > & getCov() const
Track3DKalman(fhicl::ParameterSet const &pset)
Provides recob::Track data product.
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
data_t::const_iterator const_iterator
const simb::MCParticle & GetParticle(int i) const
void reconfigure(fhicl::ParameterSet const &p)
T * make(ARGS...args) const
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
const double * XYZ() const
Utility object to perform functions of association.
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
constexpr double kBogusD
obviously bogus double value
void addHit(GFAbsRecoHit *theHit)
deprecated!
Tools and modules for checking out the basics of the Monte Carlo.
std::vector< double > fPosErr
art framework interface to geometry description
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
TMatrixT< Double_t > * covMCT
std::string GetLArTPCVolumeName(geo::TPCID const &tpcid) const
Return the name of specified LAr TPC volume.
TMatrixT< Double_t > * covREC