25 #include <TClonesArray.h>
26 #include <TEveManager.h>
27 #include <TEveTrack.h>
28 #include <TGeoTrack.h>
29 #include <TParticle.h>
39 , fShowSecondary(kTRUE)
43 , fTMax(std::numeric_limits<Double_t>::max())
45 SetElementNameTitle(
"FairGeoTracks",
"FairGeoTracks");
51 fContainer = (TClonesArray *)mngr->
GetObject(
"GeoTracks");
52 if (fContainer ==
nullptr)
54 fBranch = mngr->
GetInTree()->GetBranch(
"GeoTracks");
61 TGeoTrack *tr = (TGeoTrack *)fContainer->UncheckedAt(
id);
64 TParticle *p = (TParticle *)tr->GetParticle();
69 track->SetElementTitle(Form(
"p={%4.3f,%4.3f,%4.3f}", p->Px(), p->Py(), p->Pz()));
70 track->SetMainColor(color);
72 tr->GetPoint(0, x, y, z, t);
73 TVector3 pos(x, y, z);
74 TVector3 mom(p->Px(), p->Py(), p->Pz());
75 track->SetFirstPoint(mom, pos);
76 for (
int i = 1; i < tr->GetNpoints(); i++) {
77 tr->GetPoint(i, x, y, z, t);
79 track->SetNextPoint(pos);
81 track->SetRnrLine(kTRUE);
82 trList->AddElement(track);
87 const Double_t timeScale = 1E+9;
90 if (tr->GetNpoints() < 2)
92 if (tr->GetPoint(tr->GetNpoints() - 1)[3] * timeScale + t0 < fTMin)
94 if (tr->GetPoint(0)[3] * timeScale + t0 > fTMax)
96 TParticle *p = (TParticle *)tr->GetParticle();
100 track->SetElementTitle(Form(
"p={%4.3f,%4.3f,%4.3f}", p->Px(), p->Py(), p->Pz()));
101 track->SetMainColor(color);
103 Double_t xp, yp, zp, tp;
104 bool firstPoint =
true;
105 bool previousPoint =
false;
106 for (
int i = 0; i < tr->GetNpoints(); i++) {
107 tr->GetPoint(i, x, y, z, t);
108 t = t * timeScale + t0;
109 TVector3 pos(x, y, z);
115 previousPoint =
true;
116 }
else if (t > fTMin && t < fTMax) {
117 if (firstPoint && previousPoint) {
118 Double_t dT = (fTMin - tp) / (t - tp);
119 Double_t dx = x - xp;
120 Double_t dy = y - yp;
121 Double_t dz = z - zp;
122 pos.SetXYZ(xp + dx * dT, yp + dy * dT, zp + dz * dT);
125 TVector3 mom(p->Px(), p->Py(), p->Pz());
126 track->SetFirstPoint(mom, pos);
129 track->SetNextPoint(pos);
137 Double_t dT = (fTMax - tp) / (t - tp);
138 Double_t dx = x - xp;
139 Double_t dy = y - yp;
140 Double_t dz = z - zp;
141 pos.SetXYZ(xp + dx * dT, yp + dy * dT, zp + dz * dT);
142 track->SetNextPoint(pos);
146 track->SetRnrLine(kTRUE);
147 trList->AddElement(track);
152 bool useGeoTrackHandler =
false;
160 fBranch->GetEvent(evt.first);
163 fGeoTrackHandler.
Reset();
166 fGeoTrackHandler.
FillTClonesArray(fContainer, evt.first, evt.second, simTime);
167 useGeoTrackHandler =
true;
170 if (useGeoTrackHandler) {
171 nTracks = fGeoTrackHandler.
GetData().size();
173 nTracks = fContainer->GetEntriesFast();
178 for (
int iTrack = 0; iTrack < nTracks; iTrack++) {
182 for (
int iTrack = 0; iTrack < nTracks; iTrack++) {
185 if (useGeoTrackHandler) {
186 track = fGeoTrackHandler.
GetData()[iTrack].first;
187 t0 = fGeoTrackHandler.
GetData()[iTrack].second;
189 track = (TGeoTrack *)fContainer->At(iTrack);
194 gEve->Redraw3D(kFALSE);
199 TParticle *p = (TParticle *)tr->GetParticle();
219 if (p->GetPdgCode() != fPdgCut)
222 if (fShowPrimary && p->IsPrimary())
224 if (fShowSecondary && !p->IsPrimary())
std::vector< std::pair< T *, double > > & GetData()
virtual InitStatus Init()
static FairGetEventTime & Instance()
FairEventManager * GetEventManager() const
Bool_t CheckCuts(TGeoTrack *tr)
Float_t GetEvtTime()
current time in ns to display in the event display. Either set value or event time taken from FairRoo...
Double_t GetEtaMax() const
Bool_t UseEnergyCut() const
static FairRootManager * Instance()
void FillTClonesArray(TClonesArray *inputArray, int evtIndex, double t0Event, double t0Current)
Double_t GetEnergyMin() const
TObject * GetObject(const char *BrName)
std::pair< int, double > GetEvent(double simTime) const
virtual ~FairEveGeoTracks()
Double_t GetEnergyMax() const
static FairRunAna * Instance()
virtual Int_t Color(Int_t pdg)
void GetTimeLimits(Double_t &min, Double_t &max)
void DrawAnimatedTrack(TGeoTrack *tr, double t0=0)
static FairEventManager * Instance()
Double_t GetPtMax() const
virtual InitStatus Init()
Double_t GetEtaMin() const
TEveTrackList * FindTrackGroup(TString groupName, Color_t color)
Double_t GetPtMin() const