10#include "TwoTrackComplexCut.h"
12#include "ComplexEvent.h"
13#include "ComplexTrack.h"
15#include "DataFormatManager.h"
25 TwoTrackComplexCut::TwoTrackComplexCut() :
26 TwoTrackCut(1), fRealCut(nullptr), fImgCut(nullptr), fNullObjects(0), fAcceptNulls(kTRUE) {
28 fRealPair =
new TwoTrack();
29 fImgPair =
new TwoTrack();
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()),
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);
45 fStep = real->GetCutSize();
47 for (
int i = fStep; i < GetCutSize(); i++) {
48 SetUnitName(img->GetUnit(j) +
"_{img}", i);
49 SetMinMax(img->GetMin(j), img->GetMax(j), i);
54 TwoTrackComplexCut::TwoTrackComplexCut(
const TwoTrackComplexCut& other) : TwoTrackComplexCut(other.fRealCut, other.fImgCut) {
55 fNullObjects = other.fNullObjects;
56 fAcceptNulls = other.fAcceptNulls;
59 Bool_t TwoTrackComplexCut::Pass(
TwoTrack* pair) {
62 fRealPair->FastBuild(track1->GetRealTrack(), track2->GetRealTrack());
63 fImgPair->FastBuild(track1->GetImgTrack(), track2->GetImgTrack());
65 if (fImgPair->GetTrack1() ==
nullptr || fImgPair->GetTrack2() ==
nullptr) {
67 for (
int i = 0; i < fStep; i++)
68 fImgCut->SetValue(-DBL_MAX, i);
69 stat2 = fImgCut->ForcedUpdate(fAcceptNulls);
71 stat2 = fImgCut->Pass(fImgPair);
73 Bool_t stat1 = fRealCut->Pass(fRealPair);
74 for (
int i = 0; i < fStep; i++) {
75 SetValue(fRealCut->GetValue(i), i);
77 for (
int i = 0; i < fImgCut->GetCutSize(); i++) {
78 SetValue(fImgCut->GetValue(i), fStep + i);
80 if (stat1 && stat2)
return ForcedUpdate(kTRUE);
81 return ForcedUpdate(kFALSE);
84 Bool_t TwoTrackComplexCut::Init(Int_t task_id) {
85 if (!TwoTrackCut::Init(task_id))
return kFALSE;
87 const Event*
event = manager->
GetFormat(task_id, EFormatDepth::kBuffered);
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);
99 for (
int i = 0; i < fImgCut->GetCutSize(); i++) {
100 SetMinMax(fImgCut->GetMin(i), fImgCut->GetMax(i), i + fStep);
102 if (ok == 2)
return kTRUE;
108 Package* pack = TwoTrackCut::Report();
124 TString TwoTrackComplexCut::CutName(Option_t* )
const {
125 return Form(
"Hal::TwoTrackComplexCut(%s,%s)", fRealCut->CutName().Data(), fImgCut->CutName().Data());
128 TwoTrackComplexCut::~TwoTrackComplexCut() {
129 if (fImgCut)
delete fImgCut;
130 if (fRealCut)
delete fRealCut;
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()),
141 fAcceptNulls(kFALSE) {
142 fRealPair =
new TwoTrack();
143 fImgPair =
new TwoTrack();
144 for (
int i = 0; i < real.GetCutSize(); i++) {
146 SetMinMax(real.GetMin(i), real.GetMax(i), i);
148 fStep = real.GetCutSize();
152 SetMinMax(img.GetMin(j), img.GetMax(j), i);
159 TwoTrackRealCut::TwoTrackRealCut() : TwoTrackCut(1), fRealCut(nullptr), fPair(new TwoTrack()) {}
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++) {
165 SetMinMax(real->GetMin(i), real->GetMax(i), i);
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++) {
173 SetMinMax(real.GetMin(i), real.GetMax(i), i);
177 TwoTrackRealCut::TwoTrackRealCut(
const TwoTrackRealCut& other) : TwoTrackRealCut(other.GetRealCut()) {}
182 fPair->
FastBuild(tr1->GetRealTrack(), tr2->GetRealTrack());
183 Bool_t passed = fRealCut->
Pass(fPair);
193 const Event*
event = manager->
GetFormat(task_id, EFormatDepth::kBuffered);
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++) {
202 if (ok)
return kTRUE;
218 return Form(
"Hal::TwoTrackRealCut(%s)", fRealCut->
CutName().Data());
221 TwoTrackRealCut::~TwoTrackRealCut() {
222 if (fRealCut)
delete fRealCut;
223 if (fPair)
delete fPair;
227 TwoTrackImaginaryCut::TwoTrackImaginaryCut() :
228 TwoTrackCut(1), fImgCut(nullptr), fPair(new TwoTrack()), fNullObjects(0), fAcceptNulls(kFALSE) {}
230 TwoTrackImaginaryCut::TwoTrackImaginaryCut(
const TwoTrackCut* img) :
231 TwoTrackCut(img->GetCutSize()),
232 fImgCut((TwoTrackCut*) img->MakeCopy()),
233 fPair(new TwoTrack()),
235 fAcceptNulls(kFALSE) {
236 for (
int i = 0; i < img->GetCutSize(); i++) {
238 SetMinMax(img->GetMin(i), img->GetMax(i), i);
242 TwoTrackImaginaryCut::TwoTrackImaginaryCut(
const TwoTrackCut& img) :
243 TwoTrackCut(img.GetCutSize()),
244 fImgCut((TwoTrackCut*) img.MakeCopy()),
245 fPair(new TwoTrack()),
247 fAcceptNulls(kFALSE) {
248 for (
int i = 0; i < img.GetCutSize(); i++) {
250 SetMinMax(img.GetMin(i), img.GetMax(i), i);
254 TwoTrackImaginaryCut::TwoTrackImaginaryCut(
const TwoTrackImaginaryCut& other) : TwoTrackImaginaryCut(other.GetImgCut()) {
255 fNullObjects = other.fNullObjects;
256 fAcceptNulls = other.fAcceptNulls;
263 if (tr1->GetImgTrack() ==
nullptr || tr2->GetImgTrack() ==
nullptr) {
273 fPair->
FastBuild(tr1->GetImgTrack(), tr2->GetImgTrack());
274 Bool_t passed = fImgCut->
Pass(fPair);
284 const Event*
event = manager->
GetFormat(task_id, EFormatDepth::kBuffered);
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++) {
293 if (ok)
return kTRUE;
311 return Form(
"Hal::TwoTrackImaginaryCut(%s)", fImgCut->
CutName().Data());
314 TwoTrackImaginaryCut::~TwoTrackImaginaryCut() {
315 if (fImgCut)
delete fImgCut;
316 if (fPair)
delete fPair;
virtual TString CutName(Option_t *opt="") const
virtual Bool_t Init(Int_t=0)
void SetMinMax(Double_t min, Double_t max, Int_t i=0)
Double_t GetValue(Int_t i=0) const
Bool_t ForcedUpdate(Bool_t state)
void SetValue(Double_t val, Int_t i=0)
ULong64_t GetFailed() const
Double_t GetMin(Int_t i=0) const
ULong64_t GetPassed() const
Double_t GetMax(Int_t i=0) const
void SetUnitName(TString name, Int_t i=0)
void AddObject(TObject *object)
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)
Track * GetTrack1() const
Track * GetTrack2() const