20 #include "TObjectTable.h"
21 #include "TClonesArray.h"
22 #include "TParticlePDG.h"
26 #include <EicDetName.h>
32 FairTask(
"EIC Ideal Tracking Code"), fMCTracks(new TClonesArray()),
33 fTrackIds(new TClonesArray()), fMomSigma(0,0,0), fDPoP(0.), fRelative (kFALSE),
34 fVtxSigma(0,0,0), fEfficiency(1.),
35 fTracksArrayName(
"EicIdealTrack"),
pdg(0)
38 fTracks =
new TClonesArray(
"PndTrack");
56 if(
fVerbose>3) Info(
"Register",
"Done.");
74 if(
fVerbose>3) Info(
"Init",
"Start initialisation.");
81 std::cout <<
"-W- EicIdealTrackingCode::Init: No MCTrack array! Needed for MC Truth" << std::endl;
88 it->_fMCPoints = (TClonesArray*)fManager->
GetObject(
it->dname->Name() +
"MoCaPoint");
89 if ( !
it->_fMCPoints ) {
90 std::cout <<
"-W- EicIdealTrackingCode::Init: No " <<
it->dname->Name() <<
"Point array!" << std::endl;
95 it->_fHits = (TClonesArray *)fManager->
GetObject(
it->dname->Name() +
"TrackingDigiHit");
97 std::cout <<
"-W- EicIdealTrackingCode::Init: No " <<
it->dname->Name() <<
"Hit array!" << std::endl;
102 it->_fBranchID = fManager->
GetBranchId(
it->dname->Name() +
"TrackingDigiHit");
110 if(
fVerbose>3) Info(
"Init",
"Fetched all arrays.");
114 pdg =
new TDatabasePDG();
115 if(
fVerbose>3) Info(
"Init",
"End initialisation.");
125 if(
fVerbose>3) Info(
"Exec",
"Start eventloop.");
127 if(
fVerbose>4) Info(
"Exec",
"Print some array properties");
130 std::map<Int_t, FairHit*> firstHit;
131 std::map<Int_t, FairHit*> lastHit;
133 std::map<Int_t, FairMCPoint*> firstPoint;
134 std::map<Int_t, FairMCPoint*> lastPoint;
135 std::map<Int_t, PndTrackCand*> candlist;
140 for (Int_t ih = 0; ih <
it->_fHits->GetEntriesFast(); ih++) {
143 if(
fVerbose>3) Error(
"Exec",
"Have no ghit %i, array size: %i",ih,
it->_fHits->GetEntriesFast());
149 if(
fVerbose>3) Error(
"Exec",
"Have a mcHit %i",mchitid);
153 if(!myPoint)
continue;
155 if(trackID<0)
continue;
157 if(
fVerbose>5) Info(
"Exec",
"Have a Hit %i at Track index %i",ih,trackID);
158 if(
fVerbose>5) Info(
"Exec",
" --> mchitid %i",mchitid);
162 if(
fVerbose>5) Info(
"Exec",
"Create new PndTrack object %i",trackID);
165 if(
fVerbose>5) Info(
"Exec",
"Create new PndTrack object finished %i",trackID);
167 if(
fVerbose>5) Info(
"Exec",
"add the hit %i to trackcand %i",ih,trackID);
180 if(!firstHit[trackID] || firstHit[trackID]->GetZ() > ghit->
GetZ()) {
181 firstHit[trackID]=ghit;
182 firstPoint[trackID]=myPoint;
184 if(!lastHit[trackID] || lastHit[trackID]->GetZ() < ghit->
GetZ()) {
185 lastHit[trackID]=ghit;
186 lastPoint[trackID]=myPoint;
189 candlist[trackID] = cand;
192 if(
fVerbose>3) Info(
"Exec",
"Insert to TCA (depending on efficiency)");
195 std::map<Int_t, PndTrackCand*>::iterator candit;
198 Int_t
charge=0, trackID=-1;
200 for(candit=candlist.begin(); candit!=candlist.end(); ++candit) {
202 trackID=candit->first;
204 if(
fVerbose>3) Warning(
"Exec",
"Have no candidate at %i",trackID);
207 if( tcand->
GetNHits() < 3 )
continue;
218 firstHit[trackID]->Position(svtx);
220 firstPoint[trackID]->Momentum(smom);
230 TVector3(1.,0.,0.), TVector3(0.,1.,0.));
232 lastHit[trackID]->Position(svtx);
234 lastPoint[trackID]->Momentum(smom);
243 TVector3(1.,0.,0.), TVector3(0.,1.,0.));
245 if(
fVerbose>3) Info(
"Exec",
"Store candidate at %i",trackID);
247 if(
fVerbose>3) Info(
"AddTrack",
"Adding a Track.");
248 TClonesArray &pndtracks = *
fTracks;
251 Int_t size = pndtrackcands.GetEntriesFast();
252 if(pndtracks.GetEntriesFast() != size) {
253 Error(
"Exec",
"Arrays out of synchronisation: %i tracks, %i cands. Abort event."
254 ,pndtracks.GetEntriesFast(),pndtrackcands.GetEntriesFast());
260 PndTrack* pndTrack =
new(pndtracks[size])
269 for(candit=candlist.begin(); candit!=candlist.end(); ++candit)
270 delete candit->second;
276 if(fVerbose>3) Info(
"Exec",
"End eventloop.");
285 std::cout <<
" Found "<<
fTracks->GetEntriesFast() <<
" tracks\n";
291 Write(
"EicIdealTrackingCode");
317 rannn = gRandom->Gaus(vec.X(),sigma.X());
320 rannn = gRandom->Gaus(vec.Y(),sigma.Y());
323 rannn = gRandom->Gaus(vec.Z(),sigma.Z());