Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
ComplexTrack.cxx
1/*
2 * TrackCombined.cxx
3 *
4 * Created on: 4 kwi 2017
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "ComplexTrack.h"
10#include "ComplexEvent.h"
11#include "DataFormat.h"
12
13#include <TVector2.h>
14
15namespace Hal {
16 ComplexTrack::ComplexTrack() : Track(), fMatchID(-1), fRealTrack(NULL), fImgTrack(NULL) {}
17
18 ComplexTrack::~ComplexTrack() {}
19
20 void ComplexTrack::CopyData(Track* other) {
21 Track::CopyData(other);
22 fMatchID = ((ComplexTrack*) other)->GetMatchID();
23 }
24
25 ComplexTrack::ComplexTrack(const ComplexTrack& other) :
26 Track(other), fMatchID(other.fMatchID), fRealTrack(other.fRealTrack), fImgTrack(other.fImgTrack) {}
27
28 ComplexTrack& ComplexTrack::operator=(const ComplexTrack& other) {
29 if (this != &other) {
30 Track::operator=(other);
31 fMatchID = other.fMatchID;
32 fRealTrack = other.fRealTrack;
33 fImgTrack = other.fImgTrack;
34 }
35 return *this;
36 }
37
38 Float_t ComplexTrack::GetFieldVal(Int_t fieldID) const {
39 if (fieldID >= DataFieldID::Internal::EventStart) {
40 if (GetEvent())
41 return GetEvent()->GetFieldVal(fieldID);
42 else
43 return FLT_MIN;
44 } else if (fieldID >= DataFieldID::ImStep) {
45 if (GetImgTrack() == nullptr) return FLT_MIN;
46 return GetImgTrack()->GetFieldVal(fieldID - DataFieldID::ImStep);
47 } else if (fieldID >= DataFieldID::ReStep) {
48 return GetRealTrack()->GetFieldVal(fieldID - DataFieldID::ReStep);
49 } else {
50 Track* mc = GetImgTrack();
51 Track* reco = GetRealTrack();
52 if (mc == nullptr) return FLT_MIN;
53 switch (fieldID) {
54 case DataFieldID::Track::EComplex::kDeltaPt: return mc->GetMomentum().Pt() - reco->GetMomentum().Pt(); break;
55 case DataFieldID::Track::EComplex::kDeltaPz: return mc->GetMomentum().Pz() - reco->GetMomentum().Pz(); break;
56 case DataFieldID::Track::EComplex::kDeltaP: return mc->GetMomentum().P() - reco->GetMomentum().P(); break;
57 case DataFieldID::Track::EComplex::kDeltaPx: return mc->GetMomentum().Px() - reco->GetMomentum().Px(); break;
58 case DataFieldID::Track::EComplex::kDeltaPy: return mc->GetMomentum().Py() - reco->GetMomentum().Py(); break;
59 case DataFieldID::Track::EComplex::kDeltaPhi:
60 return TVector2::Phi_mpi_pi(mc->GetMomentum().Phi() - reco->GetMomentum().Phi());
61 break;
62 case DataFieldID::Track::EComplex::kDeltaTheta:
63 return TVector2::Phi_mpi_pi(mc->GetMomentum().Theta() - reco->GetMomentum().Theta());
64 break;
65 case DataFieldID::Track::EComplex::kDeltaEta: return mc->GetMomentum().Eta() - reco->GetMomentum().Eta(); break;
66 default: return Track::GetFieldVal(fieldID); break;
67 }
68 }
69 return Track::GetFieldVal(fieldID);
70 }
71
72 TString ComplexTrack::GetFieldName(Int_t fieldID) const {
73 if (fieldID >= DataFieldID::Internal::EventStart) {
74 if (GetEvent())
75 return GetEvent()->GetFieldVal(fieldID);
76 else
77 return "xxx";
78 } else if (fieldID >= DataFieldID::ImStep) {
79 ComplexEvent* ev = static_cast<ComplexEvent*>(GetEvent());
80 Track* tr = ev->GetImgEvent()->GetNewTrack();
81 tr->SetEvent(ev->GetImgEvent());
82 TString name = tr->GetFieldName(fieldID - DataFieldID::ImStep) + " (im)";
83
84 delete tr;
85 return name;
86 } else if (fieldID >= DataFieldID::ReStep) {
87 ComplexEvent* ev = static_cast<ComplexEvent*>(GetEvent());
88 Track* tr = ev->GetRealEvent()->GetNewTrack();
89 tr->SetEvent(ev->GetRealEvent());
90 TString name = tr->GetFieldName(fieldID - DataFieldID::ReStep) + " (re)";
91 delete tr;
92 return name;
93 } else {
94 switch (fieldID) {
95 case DataFieldID::Track::EComplex::kDeltaPt: return "#Delta p_{T} [GeV/c]"; break;
96 case DataFieldID::Track::EComplex::kDeltaPz: return "#Delta p_{z} [GeV/c]"; break;
97 case DataFieldID::Track::EComplex::kDeltaP: return "#Delta p [GeV/c]"; break;
98 case DataFieldID::Track::EComplex::kDeltaPx: return "#Delta p_{x} [GeV/c]"; break;
99 case DataFieldID::Track::EComplex::kDeltaPy: return "#Delta p_{y} [GeV/c]"; break;
100 case DataFieldID::Track::EComplex::kDeltaPhi: return "#Delta #phi [rad]"; break;
101 case DataFieldID::Track::EComplex::kDeltaTheta: return "#Delta #theta [rad]"; break;
102 case DataFieldID::Track::EComplex::kDeltaEta: return "#Delta #eta []"; break;
103 default: return Track::GetFieldName(fieldID); break;
104 }
105 }
106 return Track::GetFieldName(fieldID);
107 }
108
109 void ComplexTrack::Clear(Option_t* /*opt*/) {
110 Track::Clear();
111 if (fRealTrack) fRealTrack->Clear();
112 if (fImgTrack) fImgTrack->Clear();
113 }
114
115 void ComplexTrack::ResetTrack(Int_t thisID, Event* event) {
116 Track::ResetTrack(thisID, event);
117 fRealTrack = nullptr;
118 fImgTrack = nullptr;
119 fMatchID = -1;
120 }
121
123 Track::CopyAllData(other);
124 fMatchID = ((ComplexTrack*) other)->GetMatchID();
125 fRealTrack = ((ComplexTrack*) other)->GetRealTrack();
126 fImgTrack = ((ComplexTrack*) other)->GetImgTrack();
127 }
128} // namespace Hal
virtual void ResetTrack(Int_t thisId=-1, Event *event=nullptr)
virtual TString GetFieldName(Int_t fieldID) const
virtual Float_t GetFieldVal(Int_t fieldID) const
virtual void Clear(Option_t *opt="")
virtual void CopyAllData(Track *other)
Track * GetNewTrack() const
Definition Event.cxx:204
virtual Float_t GetFieldVal(Int_t fieldID) const
Definition Event.cxx:254
virtual void ResetTrack(Int_t thisID=-1, Event *event=nullptr)
Definition Track.cxx:295
Track & operator=(const Track &track)=default
Event * GetEvent() const
Definition Track.h:315
const TLorentzVector & GetMomentum() const
Definition Track.h:118
void SetEvent(Event *event)
Definition Track.h:337
virtual Float_t GetFieldVal(Int_t fieldID) const
Definition Track.cxx:206
virtual TString GetFieldName(Int_t fieldID) const
Definition Track.cxx:244
virtual void CopyAllData(Track *other)
Definition Track.cxx:60
virtual void Clear(Option_t *opt="")
Definition Track.cxx:281