Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
TrackToFMass2Cut.cxx
1/*
2 * TrackToFMass2Cut.cxx
3 *
4 * Created on: 10 mar 2018
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "TrackToFMass2Cut.h"
11
12
13#include <TLorentzVector.h>
14#include <TMatrixDfwd.h>
15#include <TMatrixT.h>
16#include <iostream>
17
18#include "Cut.h"
19#include "DataFormat.h"
20#include "ExpTrack.h"
21#include "Package.h"
22#include "Parameter.h"
23#include "ToFTrack.h"
24#include "Track.h"
25
26namespace Hal {
27 TrackToFMass2Cut::TrackToFMass2Cut() : TrackExpCut(1) {
28 SetUnitName("ToF M^{2} A [GeV/c^2]", 0);
29 fLowLine[0] = -1E+2;
30 fHighLine[0] = 1E+2;
31 for (int i = 1; i < 3; i++) {
32 fLowLine[i] = 0;
33 fHighLine[i] = 0;
34 }
35 }
36
37 TrackToFMass2Cut::TrackToFMass2Cut(Int_t nParams) : TrackExpCut(nParams) {
38 SetUnitName("ToF M^{2} A [GeV/c^2]", 0);
39 fLowLine[0] = -1E+2;
40 fHighLine[0] = 1E+2;
41 for (int i = 1; i < 3; i++) {
42 fLowLine[i] = 0;
43 fHighLine[i] = 0;
44 }
45 }
46
47 void TrackToFMass2Cut::SetPolyLineDown(Double_t a, Double_t b, Double_t c) {
48 fLowLine[0] = a;
49 fLowLine[1] = b;
50 fLowLine[2] = c;
51 }
52
53 void TrackToFMass2Cut::SetPolyLineUp(Double_t a, Double_t b, Double_t c) {
54 fHighLine[0] = a;
55 fHighLine[1] = b;
56 fHighLine[2] = c;
57 }
58
59 Bool_t TrackToFMass2Cut::Init(Int_t formad_id) {
60 Bool_t stat = TrackExpCut::Init(formad_id);
61 if (stat == kFALSE) return kFALSE;
62 if (ToFAvaiable(formad_id)) return kTRUE;
63 return kFALSE;
64 }
65
66 Bool_t TrackToFMass2Cut::Pass(Track* tr) {
67 ToFTrack* tof = (ToFTrack*) ((ExpTrack*) tr)->GetDetTrack(DetectorID::kTOF);
68 Double_t m2 = tof->GetMass2();
69 Double_t p = tr->GetMomentum().P();
70 SetValue(m2, 0);
71 Double_t min = fLowLine[0] + fLowLine[1] * p + fLowLine[2] * p * p;
72 Double_t max = fHighLine[0] + fHighLine[1] * p + fHighLine[2] * p * p;
73 if (m2 > max || m2 < min) { return ForcedUpdate(kFALSE); }
74 return Validate();
75 }
76
77 TrackToFMass2Cut::~TrackToFMass2Cut() {}
78
79 Package* TrackToFMass2Cut::Report() const {
80 Package* rep = TrackExpCut::Report();
81 rep->AddObject(new ParameterDouble("ToF m^{2} a_{min} ", fLowLine[0]));
82 rep->AddObject(new ParameterDouble("ToF m^{2} a_{max} ", fHighLine[0]));
83 rep->AddObject(new ParameterDouble("ToF m^{2} b_{min} ", fLowLine[1]));
84 rep->AddObject(new ParameterDouble("ToF m^{2} b_{max} ", fHighLine[0]));
85 rep->AddObject(new ParameterDouble("ToF m^{2} c_{min}", fLowLine[2]));
86 rep->AddObject(new ParameterDouble("ToF m^{2} c_{max} ", fHighLine[0]));
87 return rep;
88 }
89
90 void TrackToFMass2Cut::GetPolyUp(Double_t& a, Double_t& b, Double_t& c) const {
91 a = fHighLine[0];
92 b = fHighLine[1];
93 c = fHighLine[2];
94 }
95
96 void TrackToFMass2Cut::GetPolyDown(Double_t& a, Double_t& b, Double_t& c) const {
97 a = fLowLine[0];
98 b = fLowLine[1];
99 c = fLowLine[2];
100 }
101
102 TrackToFMass2Cut::TrackToFMass2Cut(const TrackToFMass2Cut& other) : TrackExpCut(other) {
103 for (int i = 0; i < 3; i++) {
104 fLowLine[i] = other.fLowLine[i];
105 fHighLine[i] = other.fHighLine[i];
106 }
107 }
108
109 void TrackToFMass2Cut::SetUpPoints(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t x3, Double_t y3) {
110 GetPoly(fHighLine[0], fHighLine[1], fHighLine[2], x1, y1, x2, y2, x3, y3);
111 }
112
113 void TrackToFMass2Cut::GetPoly(Double_t& a,
114 Double_t& b,
115 Double_t& c,
116 Double_t x1,
117 Double_t y1,
118 Double_t x2,
119 Double_t y2,
120 Double_t x3,
121 Double_t y3) {
122 TMatrixD A(3, 3);
123 A[0][0] = x1 * x1;
124 A[0][1] = x1;
125 A[0][2] = 1.0;
126 A[1][0] = x2 * x2;
127 A[1][1] = x2;
128 A[1][2] = 1.0;
129 A[2][0] = x3 * x3;
130 A[2][1] = x3;
131 A[2][2] = 1.0;
132 TMatrixD B(3, 1);
133 B[0][0] = y1;
134 B[1][0] = y2;
135 B[2][0] = y3;
136 A.Invert();
137 TMatrixD C = A * B;
138 c = C[0][0];
139 b = C[1][0];
140 a = C[2][0];
141 std::cout << a << " " << b << " " << c << std::endl;
142 }
143
144 void TrackToFMass2Cut::SetDownPoints(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t x3, Double_t y3) {
145 GetPoly(fLowLine[0], fLowLine[1], fLowLine[2], x1, y1, x2, y2, x3, y3);
146 }
147
149 ToFTrack* tof = (ToFTrack*) ((ExpTrack*) tr)->GetDetTrack(DetectorID::kTOF);
150 Double_t m2 = tof->GetMass2();
151 Double_t p = tr->GetMomentum().P();
152 SetValue(m2, 0);
153 if (m2 == 0) return ForcedUpdate(kFALSE);
154 Double_t min = fLowLine[0] + fLowLine[1] * p + fLowLine[2] * p * p;
155 Double_t max = fHighLine[0] + fHighLine[1] * p + fHighLine[2] * p * p;
156 if (m2 > max || m2 < min) { return ForcedUpdate(kFALSE); }
157 return Validate();
158 }
159
160 TrackTofMass2CutNoZeros::TrackTofMass2CutNoZeros(const TrackToFMass2Cut& other) : TrackToFMass2Cut(other) {}
161} // namespace Hal
Bool_t ForcedUpdate(Bool_t state)
Definition Cut.cxx:79
void SetValue(Double_t val, Int_t i=0)
Definition Cut.h:235
Bool_t Validate()
Definition Cut.cxx:43
void AddObject(TObject *object)
Definition Package.cxx:209
Float_t GetMass2() const
Definition ToFTrack.h:60
virtual Bool_t Pass(Track *tr)
const TLorentzVector & GetMomentum() const
Definition Track.h:118