Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
EventComplexCut.cxx
1/*
2 * EventComplexCut.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#include "EventComplexCut.h"
10
11#include "ComplexEvent.h"
12#include "Cout.h"
13#include "DataFormatManager.h"
14#include "Package.h"
15#include "Parameter.h"
16
17
18namespace Hal {
19 EventComplexCut::EventComplexCut() :
20 EventCut(1), fRealCut(NULL), fImgCut(NULL), fStep(0), fNullObjects(0), fAcceptNulls(kFALSE) {}
21
22 EventComplexCut::EventComplexCut(const EventCut* real, const EventCut* img) :
23 EventCut(real->GetCutSize() + img->GetCutSize()),
24 fRealCut((EventCut*) real->MakeCopy()),
25 fImgCut((EventCut*) img->MakeCopy()),
26 fNullObjects(0),
27 fAcceptNulls(kFALSE) {
28 for (int i = 0; i < real->GetCutSize(); i++) {
29 SetUnitName(real->GetUnit(i) + "_{re}", i);
30 SetMinMax(real->GetMin(i), real->GetMax(i), i);
31 }
32 fStep = real->GetCutSize();
33 int j = 0;
34 for (int i = fStep; i < GetCutSize(); i++) {
35 SetUnitName(img->GetUnit(j) + "_{img}", i);
36 SetMinMax(img->GetMin(j), img->GetMax(j), i);
37 j++;
38 }
39 }
40
41 EventComplexCut::EventComplexCut(const EventComplexCut& other) : EventComplexCut(other.fRealCut, other.fImgCut) {
42 fNullObjects = other.fNullObjects;
43 fAcceptNulls = other.fAcceptNulls;
44 }
45
46 Bool_t EventComplexCut::Pass(Event* event) {
47 ComplexEvent* z_event = (ComplexEvent*) event;
48 Bool_t stat2 = kTRUE;
49 if (z_event->GetImgEvent() == nullptr) {
50 ++fNullObjects;
51 for (int i = 0; i < fImgCut->GetCutSize(); i++)
52 fImgCut->SetValue(-DBL_MAX, i);
53 stat2 = fImgCut->ForcedUpdate(fAcceptNulls);
54 } else {
55 stat2 = fImgCut->Pass(z_event->GetImgEvent());
56 }
57 Bool_t stat1 = fRealCut->Pass(z_event->GetRealEvent());
58 for (int i = 0; i < fStep; i++) {
59 SetValue(fRealCut->GetValue(i), i);
60 }
61 for (int i = 0; i < fImgCut->GetCutSize(); i++) {
62 SetValue(fImgCut->GetValue(i), fStep + i);
63 }
64 if (stat1 && stat2) return ForcedUpdate(kTRUE);
65 return ForcedUpdate(kFALSE);
66 }
67
68 Bool_t EventComplexCut::Init(Int_t task_id) {
69 if (!EventCut::Init(task_id)) return kFALSE;
70 DataFormatManager* manager = DataFormatManager::Instance();
71 const Event* event = manager->GetFormat(task_id, EFormatDepth::kNonBuffered);
72 if (event->InheritsFrom("Hal::ComplexEvent")) {
73 ComplexEvent* z = (ComplexEvent*) event;
74 Int_t ok = 0;
75 manager->SetFormat(z->GetRealEvent(), task_id, EFormatDepth::kNonBuffered, kTRUE);
76 ok += fRealCut->Init(task_id);
77 manager->SetFormat(z->GetImgEvent(), task_id, EFormatDepth::kNonBuffered, kTRUE);
78 ok += fImgCut->Init(task_id);
79 manager->SetFormat(z, task_id, EFormatDepth::kNonBuffered, kTRUE);
80 for (int i = 0; i < fRealCut->GetCutSize(); i++) {
81 SetMinMax(fRealCut->GetMin(i), fRealCut->GetMax(i), i);
82 }
83 for (int i = 0; i < fImgCut->GetCutSize(); i++) {
84 SetMinMax(fImgCut->GetMin(i), fImgCut->GetMax(i), i + fStep);
85 }
86 if (ok == 2) return kTRUE;
87 }
88 return kFALSE;
89 }
90
91 Package* EventComplexCut::Report() const {
92 Package* pack = EventCut::Report();
93 pack->AddObject(new ParameterString("CutName_{re}", fRealCut->CutName()));
94 pack->AddObject(new ParameterString("CutName_{im}", fImgCut->CutName()));
95 pack->AddObject(new ParameterInt("CutSize_{re}", fRealCut->GetCutSize()));
96 pack->AddObject(new ParameterInt("CutSize_{im}", fImgCut->GetCutSize()));
97 pack->AddObject(new ParameterULong64("Passed_{re}", fRealCut->GetPassed(), '+'));
98 pack->AddObject(new ParameterULong64("Failed_{re}", fRealCut->GetFailed(), '+'));
99 pack->AddObject(new ParameterULong64("Passed_{im}", fImgCut->GetPassed(), '+'));
100 pack->AddObject(new ParameterULong64("Failed_{im}", fImgCut->GetFailed(), '+'));
101 pack->AddObject(new ParameterULong64("Nulls", fNullObjects, '+'));
102 pack->AddObject(new ParameterBool("Accept Nulls", fAcceptNulls));
103 pack->AddObject(fRealCut->Report());
104 pack->AddObject(fImgCut->Report());
105 return pack;
106 }
107
108 TString EventComplexCut::CutName(Option_t* /*opt*/) const {
109 return Form("Hal::EventComplexCut(%s,%s)", fRealCut->CutName().Data(), fImgCut->CutName().Data());
110 }
111
112 EventComplexCut::~EventComplexCut() {
113 if (fRealCut) delete fRealCut;
114 if (fImgCut) delete fImgCut;
115 }
116
117 EventComplexCut::EventComplexCut(const EventCut& real, const EventCut& img) :
118 EventCut(real.GetCutSize() + img.GetCutSize()),
119 fRealCut((EventCut*) real.MakeCopy()),
120 fImgCut((EventCut*) img.MakeCopy()),
121 fNullObjects(0),
122 fAcceptNulls(kFALSE) {
123 for (int i = 0; i < real.GetCutSize(); i++) {
124 SetUnitName(real.GetUnit(i) + "_{re}", i);
125 SetMinMax(real.GetMin(i), real.GetMax(i), i);
126 }
127 fStep = real.GetCutSize();
128 int j = 0;
129 for (int i = fStep; i < GetCutSize(); i++) {
130 SetUnitName(img.GetUnit(j) + "_{img}", i);
131 SetMinMax(img.GetMin(j), img.GetMax(j), i);
132 j++;
133 }
134 }
135
136 //============================================
137
138 EventRealCut::EventRealCut() : EventCut(1), fRealCut(nullptr) {}
139
140 EventRealCut::EventRealCut(const EventCut* real) : EventCut(real->GetCutSize()), fRealCut((EventCut*) real->MakeCopy()) {
141 for (int i = 0; i < real->GetCutSize(); i++) {
142 SetUnitName(real->GetUnit(i) + "_{re}", i);
143 SetMinMax(real->GetMin(i), real->GetMax(i), i);
144 }
145 }
146
147 EventRealCut::EventRealCut(const EventCut& real) : EventCut(real.GetCutSize()), fRealCut((EventCut*) real.MakeCopy()) {
148 for (int i = 0; i < real.GetCutSize(); i++) {
149 SetUnitName(real.GetUnit(i) + "_{re}", i);
150 SetMinMax(real.GetMin(i), real.GetMax(i), i);
151 }
152 }
153
154 EventRealCut::EventRealCut(const EventRealCut& other) : EventRealCut(other.GetRealCut()) {}
155
156 Bool_t EventRealCut::Pass(Event* event) {
157 ComplexEvent* z_event = (ComplexEvent*) event;
158 Bool_t passed = fRealCut->Pass(z_event->GetRealEvent());
159 for (int i = 0; i < GetCutSize(); i++) {
160 SetValue(fRealCut->GetValue(i), i);
161 }
162 return ForcedUpdate(passed);
163 }
164
165 Bool_t EventRealCut::Init(Int_t task_id) {
166 if (!EventCut::Init(task_id)) return kFALSE;
168 const Event* event = manager->GetFormat(task_id, EFormatDepth::kNonBuffered);
169 if (event->InheritsFrom("Hal::ComplexEvent")) {
170 ComplexEvent* z = (ComplexEvent*) event;
171 manager->SetFormat(z->GetRealEvent(), task_id, EFormatDepth::kNonBuffered, kTRUE);
172 Bool_t ok = fRealCut->Init(task_id);
173 manager->SetFormat(z, task_id, EFormatDepth::kNonBuffered, kTRUE);
174 for (int i = 0; i < fRealCut->GetCutSize(); i++) {
175 SetMinMax(fRealCut->GetMin(i), fRealCut->GetMax(i), i);
176 }
177 if (ok) return kTRUE;
178 }
179
180 return kFALSE;
181 }
182
184 Package* pack = EventCut::Report();
185 pack->AddObject(new ParameterString("CutName_{re}", fRealCut->CutName()));
186 pack->AddObject(new ParameterInt("CutSize_{re}", fRealCut->GetCutSize()));
187 pack->AddObject(new ParameterULong64("Passed_{re}", fRealCut->GetPassed(), '+'));
188 pack->AddObject(new ParameterULong64("Failed_{re}", fRealCut->GetFailed(), '+'));
189 pack->AddObject(fRealCut->Report());
190 return pack;
191 }
192
193 TString EventRealCut::CutName(Option_t* /*opt*/) const { return Form("Hal::EventRealCut(%s)", fRealCut->CutName().Data()); }
194
195 EventRealCut::~EventRealCut() {
196 if (fRealCut) delete fRealCut;
197 }
198
199 //============================================
200
201 EventImaginaryCut::EventImaginaryCut() : EventCut(1), fImgCut(nullptr), fNullObjects(0), fAcceptNulls(kFALSE) {}
202
203 EventImaginaryCut::EventImaginaryCut(const EventCut* img) :
204 EventCut(img->GetCutSize()), fImgCut((EventCut*) img->MakeCopy()), fNullObjects(0), fAcceptNulls(kFALSE) {
205 for (int i = 0; i < img->GetCutSize(); i++) {
206 SetUnitName(img->GetUnit(i) + "_{im}", i);
207 SetMinMax(img->GetMin(i), img->GetMax(i), i);
208 }
209 }
210
211 EventImaginaryCut::EventImaginaryCut(const EventCut& img) :
212 EventCut(img.GetCutSize()), fImgCut((EventCut*) img.MakeCopy()), fNullObjects(0), fAcceptNulls(kFALSE) {
213 for (int i = 0; i < img.GetCutSize(); i++) {
214 SetUnitName(img.GetUnit(i) + "_{im}", i);
215 SetMinMax(img.GetMin(i), img.GetMax(i), i);
216 }
217 }
218
219 EventImaginaryCut::EventImaginaryCut(const EventImaginaryCut& other) : EventImaginaryCut(other.GetImgCut()) {
220 fNullObjects = other.fNullObjects;
221 fAcceptNulls = other.fAcceptNulls;
222 }
223
225 ComplexEvent* z_event = (ComplexEvent*) event;
226 if (z_event->GetImgEvent() == nullptr) {
227 for (int i = 0; i < GetCutSize(); i++) {
228 fImgCut->SetValue(-DBL_MAX, i);
229 SetValue(-DBL_MAX, i);
230 }
231 ++fNullObjects;
232 fImgCut->ForcedUpdate(fAcceptNulls);
233 return ForcedUpdate(fAcceptNulls);
234 }
235
236 Bool_t passed = fImgCut->Pass(z_event->GetImgEvent());
237 for (int i = 0; i < GetCutSize(); i++) {
238 SetValue(fImgCut->GetValue(i), i);
239 }
240 return ForcedUpdate(passed);
241 }
242
243 Bool_t EventImaginaryCut::Init(Int_t task_id) {
244 if (!EventCut::Init(task_id)) return kFALSE;
246 const Event* event = manager->GetFormat(task_id, EFormatDepth::kNonBuffered);
247 if (event->InheritsFrom("Hal::ComplexEvent")) {
248 ComplexEvent* z = (ComplexEvent*) event;
249 manager->SetFormat(z->GetImgEvent(), task_id, EFormatDepth::kNonBuffered, kTRUE);
250 Bool_t ok = fImgCut->Init(task_id);
251 manager->SetFormat(z, task_id, EFormatDepth::kNonBuffered, kTRUE);
252 for (int i = 0; i < fImgCut->GetCutSize(); i++) {
253 SetMinMax(fImgCut->GetMin(i), fImgCut->GetMax(i), i);
254 }
255 if (ok) return kTRUE;
256 }
257 return kFALSE;
258 }
259
261 Package* pack = EventCut::Report();
262 pack->AddObject(new ParameterString("CutName_{im}", fImgCut->CutName()));
263 pack->AddObject(new ParameterInt("CutSize_{im}", fImgCut->GetCutSize()));
264 pack->AddObject(new ParameterULong64("Passed_{im}", fImgCut->GetPassed(), '+'));
265 pack->AddObject(new ParameterULong64("Failed_{im}", fImgCut->GetFailed(), '+'));
266 pack->AddObject(new ParameterULong64("Nulls", fNullObjects, '+'));
267 pack->AddObject(new ParameterBool("Accept Nulls", fAcceptNulls));
268 pack->AddObject(fImgCut->Report());
269 return pack;
270 }
271
272 TString EventImaginaryCut::CutName(Option_t* /*opt*/) const {
273 return Form("Hal::EventImaginaryCut(%s)", fImgCut->CutName().Data());
274 }
275
276 EventImaginaryCut::~EventImaginaryCut() {
277 if (fImgCut) delete fImgCut;
278 }
279} // 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()
virtual Package * Report() const
Definition EventCut.cxx:18
virtual Bool_t Pass(Event *event)=0
virtual TString CutName(Option_t *opt="") const
virtual Package * Report() const
virtual Bool_t Init(Int_t task_id)
virtual Bool_t Pass(Event *event)
virtual Bool_t Pass(Event *event)
virtual Bool_t Init(Int_t task_id)
virtual TString CutName(Option_t *opt="") const
virtual Package * Report() const
void AddObject(TObject *object)
Definition Package.cxx:209