Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
TwoTrackSailorCowboyCut.cxx
1/*
2 * TwoTrackSailorCowboyCut.cxx
3 *
4 * Created on: 15 gru 2018
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "TwoTrackSailorCowboyCut.h"
11
12#include "HelixBase.h"
13#include "Package.h"
14#include "Parameter.h"
15
16#include <RtypesCore.h>
17#include <TLorentzVector.h>
18#include <TMath.h>
19#include <TVector2.h>
20#include <TVector3.h>
21
22#include "Cut.h"
23#include "Event.h"
24#include "ExpTrack.h"
25#include "Track.h"
26#include "TwoTrack.h"
27
28namespace Hal {
29 TwoTrackSailorCowboyCut::TwoTrackSailorCowboyCut() : TwoTrackCut(1) {
30 SetUnitName("SC [AU]", 0);
31 SetMinMax(-1, 1);
32 fThreshold = 0;
33 // TODO check for fixed target
34 }
35
36 Bool_t TwoTrackSailorCowboyCut::Pass(TwoTrack* pair) {
37 ExpTrackHelix* tr1 = (ExpTrackHelix*) pair->GetTrack1();
38 ExpTrackHelix* tr2 = (ExpTrackHelix*) pair->GetTrack2();
39 const Helix& h1 = tr1->GetHelix();
40 const Helix& h2 = tr2->GetHelix();
41 TVector3 X1 = h1.GetStartPoint() - tr1->GetEvent()->GetVertex()->Vect();
42 TVector3 P1 = tr1->GetMomentum().Vect();
43 TVector3 X2 = h2.GetStartPoint() - tr2->GetEvent()->GetVertex()->Vect();
44 TVector3 P2 = tr2->GetMomentum().Vect();
45#ifdef HALHELIX_X
46 X1.SetXYZ(X1.Y(), X1.Z(), Z1.X());
47 X2.SetXYZ(X2.Y(), X2.Z(), Z2.X());
48 P1.SetXYZ(P1.Y(), P1.Z(), P1.X());
49 P2.SetXYZ(P2.Y(), P2.Z(), P2.X());
50#else
51#ifdef HALHELIX_Y
52 X1.SetXYZ(X1.Z(), X1.X(), Z1.Y());
53 X2.SetXYZ(X2.Z(), X2.X(), Z2.Y());
54 P1.SetXYZ(P1.Z(), P1.X(), P1.Y());
55 P2.SetXYZ(P2.Z(), P2.X(), P2.Y());
56#endif
57#endif
58 switch (pair->GetPairType()) {
59 case TwoTrack::kRotated: {
60 X2.SetX(-X2.X());
61 X2.SetY(-X2.Y());
62 P2.SetX(-P2.X());
63 P2.SetY(-P2.Y());
64 } break;
65 case TwoTrack::kHemishpere: {
66 X2.SetX(-X2.X());
67 X2.SetY(-X2.Y());
68 X2.SetZ(-X2.Z());
69 P2.SetX(-P2.X());
70 P2.SetY(-P2.Y());
71 P2.SetZ(-P2.Z());
72 } break;
73 default: break;
74 }
75 fHz1 = HelixZ(X1, P1, tr1->GetCharge());
76 fHz2 = HelixZ(X2, P2, tr2->GetCharge());
77 return Check();
78 }
79
80 TwoTrackSailorCowboyCut::~TwoTrackSailorCowboyCut() {}
81
82 Double_t TwoTrackSailorCowboyCut::NormalizeAngle(const TVector3 pos, Double_t x, Double_t y) const {
83 Double_t dx = pos.X() - x;
84 Double_t dy = pos.Y() - y;
85 return TMath::ATan2(dy, dx);
86 }
87
88 Bool_t TwoTrackSailorCowboyCut::AreBetween(Double_t phi, Double_t sign) const {
89 if (sign < 0) {
90 if (phi > 0) return kFALSE;
91 } else {
92 if (phi < 0) return kFALSE;
93 }
94 return kTRUE;
95 }
96
97 Bool_t TwoTrackSailorCowboyCut::Check() {
98 Double_t sign1 = fHz1.GetRotationDirection();
99 Double_t sign2 = fHz2.GetRotationDirection();
100 Double_t r2 = 1.0 / fHz2.GetCurv();
101 Double_t x2 = fHz2.GetXcenter();
102 Double_t y2 = fHz2.GetYcenter();
103 Double_t x1 = fHz1.GetXcenter();
104 Double_t y1 = fHz1.GetYcenter();
105 Double_t phi1 = fHz1.GetPhi0();
106 Double_t phi2 = fHz2.GetPhi0();
107 Double_t s1, s2;
108 fHz1.PathLength(r2, x2, y2, s1, s2);
109
110 TVector3 pos1 = fHz1.EvalPos(s1);
111 TVector3 pos2 = fHz1.EvalPos(s2);
112 if (s1 == s2 && s1 == Helix::MaxPath()) { // sailor
113 SetValue(Sailor());
114 return Validate();
115 }
116 Double_t phi1_1 = TVector2::Phi_mpi_pi(NormalizeAngle(pos1, x1, y1) - phi1);
117 Double_t phi2_1 = TVector2::Phi_mpi_pi(NormalizeAngle(pos2, x1, y1) - phi1);
118 Double_t phi1_2 = TVector2::Phi_mpi_pi(NormalizeAngle(pos1, x2, y2) - phi2);
119 Double_t phi2_2 = TVector2::Phi_mpi_pi(NormalizeAngle(pos2, x2, y2) - phi2);
120 if (AreBetween(phi1_1, sign1) && AreBetween(phi1_2, sign2)) { // first point is overlap
121 if (pos1.Pt() >= fThreshold) {
122 SetValue(Cowboy());
123 return Validate();
124 }
125 }
126 if (AreBetween(phi2_1, sign1) && AreBetween(phi2_2, sign2)) { // first point is overlap
127 if (pos2.Pt() >= fThreshold) {
128 SetValue(Cowboy());
129 return Validate();
130 }
131 }
132 SetValue(Sailor());
133 return Validate();
134 }
135
136 Package* TwoTrackSailorCowboyCut::Report() const {
137 Package* report = TwoTrackCut::Report();
138 report->AddObject(new ParameterDouble("Threshold", fThreshold));
139 return report;
140 }
141
142 TwoTrackSailorCowboyCut::TwoTrackSailorCowboyCut(const TwoTrackSailorCowboyCut& other) : TwoTrackCut(other) {
143 fHz1 = other.fHz1;
144 fHz2 = other.fHz2;
145 fThreshold = other.fThreshold;
146 }
147
148 TwoTrackSailorCowboyCut& TwoTrackSailorCowboyCut::operator=(const TwoTrackSailorCowboyCut& other) {
149 if (&other != this) {
150 fHz1 = other.fHz1;
151 fHz2 = other.fHz2;
152 fThreshold = other.fThreshold;
153 }
154 return *this;
155 }
156
157 Bool_t TwoTrackSailorCowboyCut::Init(Int_t formatId) { return FormatInhertis("Hal::ExpEventHelix", formatId); }
158} // namespace Hal
Bool_t FormatInhertis(TString format, Int_t format_id, EFormatDepth depth=EFormatDepth::kAll) const
Definition Cut.cxx:202
TLorentzVector * GetVertex() const
Definition Event.h:261
const Helix & GetHelix() const
Definition ExpTrack.h:145
TVector3 GetStartPoint() const
Definition Helix.h:132
void AddObject(TObject *object)
Definition Package.cxx:209
Event * GetEvent() const
Definition Track.h:315
const TLorentzVector & GetMomentum() const
Definition Track.h:118
Double_t GetCharge() const
Definition Track.h:184
PairType GetPairType() const
Definition TwoTrack.h:70
Track * GetTrack1() const
Definition TwoTrack.h:75
Track * GetTrack2() const
Definition TwoTrack.h:80