Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
TwoTrackComplexCut.cxx
1/*
2 * TwoTrackComplexCut.cxx
3 *
4 * Created on: 24 maj 2018
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "TwoTrackComplexCut.h"
11
12#include "ComplexEvent.h"
13#include "ComplexTrack.h"
14#include "Cut.h"
15#include "DataFormatManager.h"
16#include "Package.h"
17#include "Parameter.h"
18#include "Std.h"
19#include "TwoTrack.h"
20
21#include <TString.h>
22
23
24namespace Hal {
25 TwoTrackComplexCut::TwoTrackComplexCut() :
26 TwoTrackCut(1), fRealCut(nullptr), fImgCut(nullptr), fNullObjects(0), fAcceptNulls(kTRUE) {
27 fStep = 0;
28 fRealPair = new TwoTrack();
29 fImgPair = new TwoTrack();
30 }
31
32 TwoTrackComplexCut::TwoTrackComplexCut(const TwoTrackCut* real, const TwoTrackCut* img) :
33 TwoTrackCut(real->GetCutSize() + img->GetCutSize()),
34 fRealCut((TwoTrackCut*) real->MakeCopy()),
35 fImgCut((TwoTrackCut*) img->MakeCopy()),
36 fStep(0),
37 fNullObjects(0),
38 fAcceptNulls(kTRUE) {
39 fRealPair = new TwoTrack();
40 fImgPair = new TwoTrack();
41 for (int i = 0; i < real->GetCutSize(); i++) {
42 SetUnitName(real->GetUnit(i) + "_{re}", i);
43 SetMinMax(real->GetMin(i), real->GetMax(i), i);
44 }
45 fStep = real->GetCutSize();
46 int j = 0;
47 for (int i = fStep; i < GetCutSize(); i++) {
48 SetUnitName(img->GetUnit(j) + "_{img}", i);
49 SetMinMax(img->GetMin(j), img->GetMax(j), i);
50 j++;
51 }
52 }
53
54 TwoTrackComplexCut::TwoTrackComplexCut(const TwoTrackComplexCut& other) : TwoTrackComplexCut(other.fRealCut, other.fImgCut) {
55 fNullObjects = other.fNullObjects;
56 fAcceptNulls = other.fAcceptNulls;
57 }
58
59 Bool_t TwoTrackComplexCut::Pass(TwoTrack* pair) {
60 ComplexTrack* track1 = (ComplexTrack*) pair->GetTrack1();
61 ComplexTrack* track2 = (ComplexTrack*) pair->GetTrack2();
62 fRealPair->FastBuild(track1->GetRealTrack(), track2->GetRealTrack());
63 fImgPair->FastBuild(track1->GetImgTrack(), track2->GetImgTrack());
64 Bool_t stat2 = kTRUE;
65 if (fImgPair->GetTrack1() == nullptr || fImgPair->GetTrack2() == nullptr) {
66 ++fNullObjects;
67 for (int i = 0; i < fStep; i++)
68 fImgCut->SetValue(-DBL_MAX, i);
69 stat2 = fImgCut->ForcedUpdate(fAcceptNulls);
70 } else {
71 stat2 = fImgCut->Pass(fImgPair);
72 }
73 Bool_t stat1 = fRealCut->Pass(fRealPair);
74 for (int i = 0; i < fStep; i++) {
75 SetValue(fRealCut->GetValue(i), i);
76 }
77 for (int i = 0; i < fImgCut->GetCutSize(); i++) {
78 SetValue(fImgCut->GetValue(i), fStep + i);
79 }
80 if (stat1 && stat2) return ForcedUpdate(kTRUE);
81 return ForcedUpdate(kFALSE);
82 }
83
84 Bool_t TwoTrackComplexCut::Init(Int_t task_id) {
85 if (!TwoTrackCut::Init(task_id)) return kFALSE;
86 DataFormatManager* manager = DataFormatManager::Instance();
87 const Event* event = manager->GetFormat(task_id, EFormatDepth::kBuffered);
88 if (dynamic_cast<const ComplexEvent*>(event)) {
89 ComplexEvent* z = (ComplexEvent*) event;
90 Int_t ok = 0;
91 manager->SetFormat(z->GetRealEvent(), task_id, EFormatDepth::kBuffered, kTRUE);
92 ok += fRealCut->Init(task_id);
93 manager->SetFormat(z->GetImgEvent(), task_id, EFormatDepth::kBuffered, kTRUE);
94 ok += fImgCut->Init(task_id);
95 manager->SetFormat(z, task_id, EFormatDepth::kBuffered, kTRUE);
96 for (int i = 0; i < fRealCut->GetCutSize(); i++) {
97 SetMinMax(fRealCut->GetMin(i), fRealCut->GetMax(i), i);
98 }
99 for (int i = 0; i < fImgCut->GetCutSize(); i++) {
100 SetMinMax(fImgCut->GetMin(i), fImgCut->GetMax(i), i + fStep);
101 }
102 if (ok == 2) return kTRUE;
103 }
104 return kFALSE;
105 }
106
107 Package* TwoTrackComplexCut::Report() const {
108 Package* pack = TwoTrackCut::Report();
109 pack->AddObject(new ParameterString("CutName_{re}", fRealCut->CutName()));
110 pack->AddObject(new ParameterString("CutName_{im}", fImgCut->CutName()));
111 pack->AddObject(new ParameterInt("CutSize_{re}", fRealCut->GetCutSize()));
112 pack->AddObject(new ParameterInt("CutSize_{im}", fImgCut->GetCutSize()));
113 pack->AddObject(new ParameterULong64("Passed_{re}", fRealCut->GetPassed(), '+'));
114 pack->AddObject(new ParameterULong64("Failed_{re}", fRealCut->GetFailed(), '+'));
115 pack->AddObject(new ParameterULong64("Passed_{im}", fImgCut->GetPassed(), '+'));
116 pack->AddObject(new ParameterULong64("Failed_{im}", fImgCut->GetFailed(), '+'));
117 pack->AddObject(new ParameterULong64("Nulls", fNullObjects, '+'));
118 pack->AddObject(new ParameterBool("Accept Nulls", fAcceptNulls));
119 pack->AddObject(fRealCut->Report());
120 pack->AddObject(fImgCut->Report());
121 return pack;
122 }
123
124 TString TwoTrackComplexCut::CutName(Option_t* /*opt*/) const {
125 return Form("Hal::TwoTrackComplexCut(%s,%s)", fRealCut->CutName().Data(), fImgCut->CutName().Data());
126 }
127
128 TwoTrackComplexCut::~TwoTrackComplexCut() {
129 if (fImgCut) delete fImgCut;
130 if (fRealCut) delete fRealCut;
131 delete fImgPair;
132 delete fRealPair;
133 }
134
135 TwoTrackComplexCut::TwoTrackComplexCut(const TwoTrackCut& real, const TwoTrackCut& img) :
136 TwoTrackCut(real.GetCutSize() + img.GetCutSize()),
137 fRealCut((TwoTrackCut*) real.MakeCopy()),
138 fImgCut((TwoTrackCut*) img.MakeCopy()),
139 fStep(0),
140 fNullObjects(0),
141 fAcceptNulls(kFALSE) {
142 fRealPair = new TwoTrack();
143 fImgPair = new TwoTrack();
144 for (int i = 0; i < real.GetCutSize(); i++) {
145 SetUnitName(real.GetUnit(i) + "_{re}", i);
146 SetMinMax(real.GetMin(i), real.GetMax(i), i);
147 }
148 fStep = real.GetCutSize();
149 int j = 0;
150 for (int i = fStep; i < GetCutSize(); i++) {
151 SetUnitName(img.GetUnit(j) + "_{img}", i);
152 SetMinMax(img.GetMin(j), img.GetMax(j), i);
153 j++;
154 }
155 }
156
157 //============================================
158
159 TwoTrackRealCut::TwoTrackRealCut() : TwoTrackCut(1), fRealCut(nullptr), fPair(new TwoTrack()) {}
160
161 TwoTrackRealCut::TwoTrackRealCut(const TwoTrackCut* real) :
162 TwoTrackCut(real->GetCutSize()), fRealCut((TwoTrackCut*) real->MakeCopy()), fPair(new TwoTrack()) {
163 for (int i = 0; i < real->GetCutSize(); i++) {
164 SetUnitName(real->GetUnit(i) + "_{re}", i);
165 SetMinMax(real->GetMin(i), real->GetMax(i), i);
166 }
167 }
168
169 TwoTrackRealCut::TwoTrackRealCut(const TwoTrackCut& real) :
170 TwoTrackCut(real.GetCutSize()), fRealCut((TwoTrackCut*) real.MakeCopy()), fPair(new TwoTrack()) {
171 for (int i = 0; i < real.GetCutSize(); i++) {
172 SetUnitName(real.GetUnit(i) + "_{re}", i);
173 SetMinMax(real.GetMin(i), real.GetMax(i), i);
174 }
175 }
176
177 TwoTrackRealCut::TwoTrackRealCut(const TwoTrackRealCut& other) : TwoTrackRealCut(other.GetRealCut()) {}
178
180 ComplexTrack* tr1 = (ComplexTrack*) pair->GetTrack1();
181 ComplexTrack* tr2 = (ComplexTrack*) pair->GetTrack2();
182 fPair->FastBuild(tr1->GetRealTrack(), tr2->GetRealTrack());
183 Bool_t passed = fRealCut->Pass(fPair);
184 for (int i = 0; i < GetCutSize(); i++) {
185 SetValue(fRealCut->GetValue(i), i);
186 }
187 return ForcedUpdate(passed);
188 }
189
190 Bool_t TwoTrackRealCut::Init(Int_t task_id) {
191 if (!TwoTrackCut::Init(task_id)) return kFALSE;
193 const Event* event = manager->GetFormat(task_id, EFormatDepth::kBuffered);
194 if (dynamic_cast<const ComplexEvent*>(event)) {
195 ComplexEvent* z = (ComplexEvent*) event;
196 manager->SetFormat(z->GetRealEvent(), task_id, EFormatDepth::kBuffered, kTRUE);
197 Bool_t ok = fRealCut->Init(task_id);
198 manager->SetFormat(z, task_id, EFormatDepth::kBuffered, kTRUE);
199 for (int i = 0; i < fRealCut->GetCutSize(); i++) {
200 SetMinMax(fRealCut->GetMin(i), fRealCut->GetMax(i), i);
201 }
202 if (ok) return kTRUE;
203 }
204 return kFALSE;
205 }
206
209 pack->AddObject(new ParameterString("CutName_{re}", fRealCut->CutName()));
210 pack->AddObject(new ParameterInt("CutSize_{re}", fRealCut->GetCutSize()));
211 pack->AddObject(new ParameterULong64("Passed_{re}", fRealCut->GetPassed(), '+'));
212 pack->AddObject(new ParameterULong64("Failed_{re}", fRealCut->GetFailed(), '+'));
213 pack->AddObject(fRealCut->Report());
214 return pack;
215 }
216
217 TString TwoTrackRealCut::CutName(Option_t* /*opt*/) const {
218 return Form("Hal::TwoTrackRealCut(%s)", fRealCut->CutName().Data());
219 }
220
221 TwoTrackRealCut::~TwoTrackRealCut() {
222 if (fRealCut) delete fRealCut;
223 if (fPair) delete fPair;
224 }
225
226 //============================================
227 TwoTrackImaginaryCut::TwoTrackImaginaryCut() :
228 TwoTrackCut(1), fImgCut(nullptr), fPair(new TwoTrack()), fNullObjects(0), fAcceptNulls(kFALSE) {}
229
230 TwoTrackImaginaryCut::TwoTrackImaginaryCut(const TwoTrackCut* img) :
231 TwoTrackCut(img->GetCutSize()),
232 fImgCut((TwoTrackCut*) img->MakeCopy()),
233 fPair(new TwoTrack()),
234 fNullObjects(0),
235 fAcceptNulls(kFALSE) {
236 for (int i = 0; i < img->GetCutSize(); i++) {
237 SetUnitName(img->GetUnit(i) + "_{im}", i);
238 SetMinMax(img->GetMin(i), img->GetMax(i), i);
239 }
240 }
241
242 TwoTrackImaginaryCut::TwoTrackImaginaryCut(const TwoTrackCut& img) :
243 TwoTrackCut(img.GetCutSize()),
244 fImgCut((TwoTrackCut*) img.MakeCopy()),
245 fPair(new TwoTrack()),
246 fNullObjects(0),
247 fAcceptNulls(kFALSE) {
248 for (int i = 0; i < img.GetCutSize(); i++) {
249 SetUnitName(img.GetUnit(i) + "_{im}", i);
250 SetMinMax(img.GetMin(i), img.GetMax(i), i);
251 }
252 }
253
254 TwoTrackImaginaryCut::TwoTrackImaginaryCut(const TwoTrackImaginaryCut& other) : TwoTrackImaginaryCut(other.GetImgCut()) {
255 fNullObjects = other.fNullObjects;
256 fAcceptNulls = other.fAcceptNulls;
257 }
258
260 ComplexTrack* tr1 = (ComplexTrack*) pair->GetTrack1();
261 ComplexTrack* tr2 = (ComplexTrack*) pair->GetTrack2();
262
263 if (tr1->GetImgTrack() == nullptr || tr2->GetImgTrack() == nullptr) {
264 ++fNullObjects;
265 for (int i = 0; i < GetCutSize(); i++) {
266 SetValue(-DBL_MAX, i);
267 fImgCut->SetValue(-DBL_MAX, i);
268 }
269 fImgCut->ForcedUpdate(fAcceptNulls);
270 return ForcedUpdate(fAcceptNulls);
271 }
272
273 fPair->FastBuild(tr1->GetImgTrack(), tr2->GetImgTrack());
274 Bool_t passed = fImgCut->Pass(fPair);
275 for (int i = 0; i < GetCutSize(); i++) {
276 SetValue(fImgCut->GetValue(i), i);
277 }
278 return ForcedUpdate(passed);
279 }
280
281 Bool_t TwoTrackImaginaryCut::Init(Int_t task_id) {
282 if (!TwoTrackCut::Init(task_id)) return kFALSE;
284 const Event* event = manager->GetFormat(task_id, EFormatDepth::kBuffered);
285 if (dynamic_cast<const ComplexEvent*>(event)) {
286 ComplexEvent* z = (ComplexEvent*) event;
287 manager->SetFormat(z->GetImgEvent(), task_id, EFormatDepth::kBuffered, kTRUE);
288 Bool_t ok = fImgCut->Init(task_id);
289 manager->SetFormat(z, task_id, EFormatDepth::kBuffered, kTRUE);
290 for (int i = 0; i < fImgCut->GetCutSize(); i++) {
291 SetMinMax(fImgCut->GetMin(i), fImgCut->GetMax(i), i);
292 }
293 if (ok) return kTRUE;
294 }
295 return kFALSE;
296 }
297
300 pack->AddObject(new ParameterString("CutName_{im}", fImgCut->CutName()));
301 pack->AddObject(new ParameterInt("CutSize_{im}", fImgCut->GetCutSize()));
302 pack->AddObject(new ParameterULong64("Passed_{im}", fImgCut->GetPassed(), '+'));
303 pack->AddObject(new ParameterULong64("Failed_{im}", fImgCut->GetFailed(), '+'));
304 pack->AddObject(new ParameterULong64("Nulls", fNullObjects, '+'));
305 pack->AddObject(new ParameterBool("Accept Nulls", fAcceptNulls));
306 pack->AddObject(fImgCut->Report());
307 return pack;
308 }
309
310 TString TwoTrackImaginaryCut::CutName(Option_t* /*opt*/) const {
311 return Form("Hal::TwoTrackImaginaryCut(%s)", fImgCut->CutName().Data());
312 }
313
314 TwoTrackImaginaryCut::~TwoTrackImaginaryCut() {
315 if (fImgCut) delete fImgCut;
316 if (fPair) delete fPair;
317 }
318} // namespace Hal
virtual TString CutName(Option_t *opt="") const
Definition Cut.cxx:214
virtual Bool_t Init(Int_t=0)
Definition Cut.h:346
void SetMinMax(Double_t min, Double_t max, Int_t i=0)
Definition Cut.cxx:93
Double_t GetValue(Int_t i=0) const
Definition Cut.h:285
Bool_t ForcedUpdate(Bool_t state)
Definition Cut.cxx:79
void SetValue(Double_t val, Int_t i=0)
Definition Cut.h:235
ULong64_t GetFailed() const
Definition Cut.h:305
Int_t GetCutSize() const
Definition Cut.h:252
Double_t GetMin(Int_t i=0) const
Definition Cut.h:273
ULong64_t GetPassed() const
Definition Cut.h:295
Double_t GetMax(Int_t i=0) const
Definition Cut.h:279
void SetUnitName(TString name, Int_t i=0)
Definition Cut.h:241
const Event * GetFormat(Int_t task_id, EFormatDepth format_depth=EFormatDepth::kAll) const
void SetFormat(Event *format, Int_t task_id, EFormatDepth depth=EFormatDepth::kAll, Bool_t silent=kFALSE)
static DataFormatManager * Instance()
void AddObject(TObject *object)
Definition Package.cxx:209
virtual Package * Report() const
virtual Bool_t Pass(TwoTrack *pair)=0
virtual Package * Report() const
virtual TString CutName(Option_t *opt="") const
virtual Bool_t Init(Int_t task_id)
virtual Bool_t Pass(TwoTrack *track)
virtual Package * Report() const
virtual TString CutName(Option_t *opt="") const
virtual Bool_t Pass(TwoTrack *track)
virtual Bool_t Init(Int_t task_id)
void FastBuild(Track *track1, Track *track2)
Definition TwoTrack.h:39
Track * GetTrack1() const
Definition TwoTrack.h:75
Track * GetTrack2() const
Definition TwoTrack.h:80