FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairEveRecoTrack.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 /*
9  * FairEveRecoTrack.cxx
10  *
11  * Created on: 23 kwi 2020
12  * Author: Daniel Wielanek
13  * E-mail: daniel.wielanek@gmail.com
14  * Warsaw University of Technology, Faculty of Physics
15  */
16 
17  #include "FairEveRecoTrack.h"
18  #include <TEvePointSet.h> // for TEvePointSet
19  #include <TGeoTrack.h> // for TGeoTrack
20  #include <TMathBase.h> // for Abs
21  #include <TParticle.h> // for TParticle
22  #include "FairEveTrack.h" // for FairEveTrack
23  #include "FairEventManager.h" // for FairEventManager
24 
26  : TEveCompound()
27  , fHits(nullptr)
28  , fNPoints(0)
29  , fRecoTrack(nullptr)
30  , fMCTrack(nullptr)
31 {}
32 
33 FairEveRecoTrack::FairEveRecoTrack(TParticle *t, Int_t label, TEveTrackPropagator *prop)
34  : TEveCompound()
35  , fHits(nullptr)
36  , fNPoints(0)
37  , fRecoTrack(new FairEveTrack(t, label, prop))
38  , fMCTrack(nullptr)
39 {
40  OpenCompound();
41  AddElement(fRecoTrack);
42 }
43 
44 void FairEveRecoTrack::AddHit(TVector3 hit)
45 {
46  TVector3 world = FairEventManager::Instance()->GetWorldSize();
47  if (TMath::Abs(hit.X()) > world.X())
48  return;
49  if (TMath::Abs(hit.Y()) > world.Y())
50  return;
51  if (TMath::Abs(hit.Z()) > world.Z())
52  return;
53  if (fHits == nullptr) {
54  fHits = new TEvePointSet();
55  fHits->SetCompound(this);
56  fHits->SetMainColor(GetMainColor());
57  AddElement(fHits);
58  }
59  fHits->SetNextPoint(hit.X(), hit.Y(), hit.Z());
60 }
61 
62 void FairEveRecoTrack::MakeMCTrack(const TGeoTrack *geo)
63 {
64  if (fMCTrack != nullptr)
65  return;
66  TParticle *p = static_cast<TParticle *>(geo->GetParticle());
67  fMCTrack = new FairEveTrack(p, fRecoTrack->GetLabel(), fRecoTrack->GetPropagator());
68  fMCTrack->SetLineColor(fRecoTrack->GetLineColor());
69  TVector3 mom(p->Px(), p->Py(), p->Pz());
70  const Double_t *posV = geo->GetFirstPoint();
71  TVector3 pos(posV[0], posV[1], posV[2]);
72  fMCTrack->SetFirstPoint(mom, pos);
73  for (int i = 1; i < geo->GetNpoints(); i++) {
74  const Double_t *xyz = geo->GetPoint(i);
75  pos.SetXYZ(xyz[0], xyz[1], xyz[2]);
76  fMCTrack->SetNextPoint(pos);
77  }
78  fMCTrack->SetLineStyle(10);
79  AddElement(fMCTrack);
80  CloseCompound();
81 }
82 
83 void FairEveRecoTrack::InitMCTrack(const TParticle *p)
84 {
85  if (fMCTrack != nullptr)
86  return;
87  TParticle *P = new TParticle(*p);
88  fMCTrack = new FairEveTrack(P, fRecoTrack->GetLabel(), fRecoTrack->GetPropagator());
89  fMCTrack->SetLineColor(fRecoTrack->GetLineColor());
90  TVector3 mom(p->Px(), p->Py(), p->Pz());
91  TVector3 pos(P->Vx(), P->Vy(), P->Vz());
92  fMCTrack->SetFirstPoint(mom, pos);
93  fMCTrack->SetLineStyle(10);
94  AddElement(fMCTrack);
95 }
96 
97 void FairEveRecoTrack::SetMainColor(Color_t color)
98 {
99  TEveCompound::SetMainColor(color);
100  if (fRecoTrack)
101  fRecoTrack->SetMainColor(color);
102  if (fHits)
103  fHits->SetMainColor(color);
104  if (fMCTrack)
105  fMCTrack->SetMainColor(color);
106 }
107 
void MakeMCTrack(const TGeoTrack *geo)
void AddHit(TVector3 hit)
void SetMainColor(Color_t color)
TVector3 GetWorldSize() const
static FairEventManager * Instance()
void SetNextPoint(const TVector3 &point)
void SetFirstPoint(const TVector3 &mom, const TVector3 &pos)
void InitMCTrack(const TParticle *p)