29 #include "FairRootManager.h"
31 #include "TClonesArray.h"
32 #include "TDatabasePDG.h"
34 #include "FairMCPoint.h"
37 #include "FairBaseParSet.h"
38 #include "FairTrackParH.h"
43 #include "LSLTrackRep.h"
47 #include "TGeoManager.h"
48 #include "TGeoTrack.h"
50 #include "TLorentzVector.h"
52 #include "FairGeanePro.h"
61 #include "RKTrackRep.h"
62 #include "TMatrixFSym.h"
68 : FairTask(
"Kalman Filter"), fPersistence(kFALSE) {
88 : FairTask(
"Kalman Filter"), fPersistence(kFALSE) {
109 FairRootManager* ioman = FairRootManager::Instance();
112 Error(
"PndLmdKalmanTask::Init",
"RootManager not instantiated!");
120 Error(
"PndLmdKalmanTask::Init",
"GFTrackCandLmd array not found!");
131 ioman->Register(
"LMDPndTrackFilt",
"PndLmd",
fTrkOutArray, kTRUE);
138 Error(
"PndLmdKalmanTask::Init",
"LMDHitsPixel array not found");
141 std::cout <<
"detID = " << detID << std::endl;
146 std::cout <<
"*** PndLmdKalmanTask::Init"
148 <<
"fSdsHitBranchName array found" << std::endl;
152 FairRun*
fRun = FairRun::Instance();
153 FairRuntimeDb*
rtdb = fRun->GetRuntimeDb();
154 FairBaseParSet*
par =
155 (FairBaseParSet*)(rtdb->findContainer(
"FairBaseParSet"));
156 fPbeam = par->GetBeamMom();
159 std::cout <<
"Beam Momentum for this run is " <<
fPbeam << std::endl;
164 fPro =
new FairGeanePro();
166 std::cout <<
"RKTrackRep will be used for track representation"
172 std::cout <<
"GeaneTrackRep will be used for track representation"
174 fPro =
new FairGeanePro();
193 <<
"((((((((((((((((((((( PndLmdKalmanTask::Exec )))))))))))))))))))))"
195 Int_t counterGeaneTrk = 0;
196 Int_t rec_tkr_count = 0;
201 std::cout <<
" -I- PndLmdKalmanTask: contains " << ntracks <<
" Tracks."
206 for (Int_t itr = 0; itr < ntracks; ++itr) {
207 if (
fVerbose > 1) std::cout <<
"starting track" << itr << std::endl;
210 const int Ntrkcandhits = trackCand->
GetNHits();
216 if (
fVerbose > 1) std::cout <<
"hitCov:" << std::endl;
223 std::cout <<
"oo:" << std::endl;
225 std::cout <<
"uu:" << std::endl;
227 std::cout <<
"vv:" << std::endl;
239 TVector3 StartMom =
fPbeam * StartDir;
240 TVector3 StartPosErr(
sqrt(hitCov[0][0]),
sqrt(hitCov[1][1]),
242 TVector3 StartDirErr(
243 0.1 * (
sqrt(hitCov[0][0])), 0.1 * (
sqrt(hitCov[1][1])),
247 TVector3 StartMomErr =
fPbeam * StartDirErr;
254 unsigned int detid = 12345, index = 12345;
255 std::cout <<
"GFTrackCand no. " << itr <<
" has " << GFtrkCand->
getNHits()
256 <<
" hits." << std::endl;
257 std::cout <<
"[ ihit | detid | index";
258 for (
unsigned int ihit = 0; ihit < GFtrkCand->
getNHits(); ihit++) {
259 GFtrkCand->
getHit(ihit, detid,
261 std::cout <<
" ]\n[ " << ihit <<
" | " << detid <<
" | " << index;
263 std::cout <<
" ]" << std::endl;
267 std::cout <<
"*** BEFORE ***" << std::endl;
268 std::cout <<
"StartPos:" << std::endl;
270 std::cout <<
"StartPosErr:" << std::endl;
272 std::cout <<
"StartMom:" << std::endl;
274 std::cout <<
"StartMomErr:" << std::endl;
282 std::cout <<
"RKTrackRep will be used for track representation"
284 rep =
new RKTrackRep(StartPos, StartMom, StartPosErr, StartMomErr,
316 std::cout << trk->
getNumHits() <<
" hits in track " << itr << std::endl;
319 std::cout <<
" *** PndLmdKalmanTask::Exec "
321 <<
"Genfit Exception: trk->addHitVector " << e.
what()
329 std::cout <<
" ... GFtrk BEFORE ..." << std::endl;
334 std::cout <<
" ... GFtrk AFTER ..." << std::endl;
338 std::cout <<
"*** FITTER EXCEPTION ***" << std::endl;
339 std::cout << e.
what() << std::endl;
341 if (
fVerbose > 1) std::cout <<
"successful FIT!" << std::endl;
346 std::cout <<
"trkPnd AFTER GenFit " << std::endl;
348 std::cout <<
"Number of hits in trk-cand: " << trackCand->
GetNHits()
357 Int_t size = clref.GetEntriesFast();
486 Int_t size = clref.GetEntriesFast();
487 new (clref[size])
PndTrack(*(trkpnd));
490 std::cout <<
"Fitting done, result is " <<
fTrkOutArray->GetEntriesFast()
491 <<
" fitted trks" << std::endl;
Base Class for genfit track representations. Defines interface for track parameterizations.
unsigned int getNumHits() const
void SetRefIndex(TString branch, Int_t i)
void GetOUVShortId(Int_t shortId, TVector3 &o, TVector3 &u, TVector3 &v)
Detector plane genfit geometry class.
friend F32vec4 sqrt(const F32vec4 &a)
ClassImp(PndLmdKalmanTask)
Track object for genfit. genfit algorithms work on these objects.
std::vector< GFAbsRecoHit * > createMany(const GFTrackCand &cand)
Creat a collection of RecoHits.
void addProducer(int detID, GFAbsRecoHitProducer *hitProd)
Register a producer module to the factory.
double getChiSqu() const
Get chi2.
Generic Kalman Filter implementation.
PndTrackCandHit GetSortedHit(UInt_t i)
virtual const char * what() const
standard error message handling for exceptions. use like "std::cerr << e.what();" ...
unsigned int getNHits() const
void addHitVector(std::vector< GFAbsRecoHit * > hits)
Add collection of hits.
Template class for a hit producer module.
void setCandidate(const GFTrackCand &cand, bool doreset=false)
set track candidate
TString GetPath(Int_t shortID)
for a given shortID the path is returned
TClonesArray * fTrackTmpArray
TVector3 getPosSeed() const
get the seed value for track: pos
virtual InitStatus Init()
TVector3 getDirSeed() const
get the seed value for track: direction
Factory object to create RecoHits from digitized and clustered data.
Track Representation module based on a Runge-Kutta algorithm including a full material model...
TClonesArray * fSdsHitsArray
void getHit(unsigned int i, unsigned int &detId, unsigned int &hitId) const
Get detector ID and cluster index (hitId) for hit number i.
Track candidate – a list of cluster indices.
GFTrackCand * PndTrackCand2GenfitTrackCand(PndTrackCand *cand)
void processTrack(GFTrack *trk)
Performs fit on a GFTrack.
static PndGeoHandling * Instance()
const GFTrackCand & getCand() const
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
void init(GFAbsBField *b)
set the magntic field here. Magnetic field classes must be derived from GFAbsBField ...
TClonesArray * fTrackArray
PndTrack * GenfitTrack2PndTrack(const GFTrack *tr)
static GFFieldManager * getInstance()
Int_t GetSensorID() const
virtual ~PndLmdKalmanTask()
virtual void Exec(Option_t *opt)
void setNumIterations(Int_t i)
Set number of iterations for Kalman Filter.
void SetTrackCand(const PndTrackCand &cand)
TMatrixT< double > TMatrixD
TString fSdsHitBranchName
TClonesArray * fTrkOutArray
GFRecoHitFactory * fTheRecoHitFactory