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