10#include "CutsAndMonitors.h"
11#include "CutMonitorX.h"
12#include "CutMonitorXY.h"
13#include "CutMonitorXYZ.h"
15#include "HistogramManager.h"
18#include <TObjString.h>
21 CutsAndMonitors::CutsAndMonitors() :
23 fCutsOptions(nullptr),
24 fCutMonitors(nullptr),
25 fCutMonitorsOptions(nullptr),
26 fGlobalOptionCuts(
""),
27 fGlobalOptionsCutMonitors(
"") {}
29 CutsAndMonitors::CutsAndMonitors(
const CutsAndMonitors& other) :
32 fCutsOptions(nullptr),
33 fCutMonitors(nullptr),
34 fCutMonitorsOptions(nullptr),
35 fGlobalOptionCuts(other.fGlobalOptionCuts),
36 fGlobalOptionsCutMonitors(other.fGlobalOptionsCutMonitors) {
38 fCuts = new TObjArray();
39 fCuts->SetOwner(kTRUE);
40 fCutsOptions = new TObjArray();
41 fCutsOptions->SetOwner(kTRUE);
42 for (int iCut = 0; iCut < other.fCuts->GetEntries(); iCut++) {
43 Cut* cut = (Cut*) other.fCuts->UncheckedAt(iCut);
44 TObjString* str = (TObjString*) other.fCutsOptions->UncheckedAt(iCut);
45 fCuts->AddLast(cut->MakeCopy());
46 fCutsOptions->AddLast(str->Clone());
49 if (other.fCutMonitors) {
50 fCutMonitors = new TObjArray();
51 fCutMonitors->SetOwner(kTRUE);
52 fCutMonitorsOptions = new TObjArray();
53 fCutMonitorsOptions->SetOwner(kTRUE);
54 for (int iCutMon = 0; iCutMon < other.fCutMonitors->GetEntries(); iCutMon++) {
55 CutMonitor* cut = (CutMonitor*) other.fCutMonitors->UncheckedAt(iCutMon);
56 TObjString* str = (TObjString*) other.fCutMonitorsOptions->UncheckedAt(iCutMon);
57 fCutMonitors->AddLast(cut->MakeCopy());
58 fCutMonitorsOptions->AddLast(str->Clone());
63 Int_t CutsAndMonitors::GetNCuts()
const {
64 if (fCuts ==
nullptr)
return 0;
65 return fCuts->GetEntries();
68 Int_t CutsAndMonitors::GetNCutMonitors()
const {
69 if (fCutMonitors ==
nullptr)
return 0;
70 return fCutMonitors->GetEntries();
74 if (&other ==
this)
return *
this;
79 fCutsOptions =
nullptr;
83 delete fCutMonitorsOptions;
84 fCutMonitors =
nullptr;
85 fCutMonitorsOptions =
nullptr;
87 fGlobalOptionCuts = other.fGlobalOptionCuts;
88 fGlobalOptionsCutMonitors = other.fGlobalOptionsCutMonitors;
91 fCuts =
new TObjArray();
92 fCuts->SetOwner(kTRUE);
93 fCutsOptions =
new TObjArray();
94 fCutsOptions->SetOwner(kTRUE);
95 for (
int iCut = 0; iCut < other.fCuts->GetEntries(); iCut++) {
96 Cut* cut = (Cut*) other.fCuts->UncheckedAt(iCut);
97 TObjString* str = (TObjString*) other.fCutsOptions->UncheckedAt(iCut);
98 fCuts->AddLast(cut->MakeCopy());
99 fCutsOptions->AddLast(str->Clone());
102 if (other.fCutMonitors) {
103 fCutMonitors =
new TObjArray();
104 fCutMonitors->SetOwner(kTRUE);
105 fCutMonitorsOptions =
new TObjArray();
106 fCutMonitorsOptions->SetOwner(kTRUE);
107 for (
int iCutMon = 0; iCutMon < other.fCutMonitors->GetEntries(); iCutMon++) {
108 CutMonitor* cut = (CutMonitor*) other.fCutMonitors->UncheckedAt(iCutMon);
109 TObjString* str = (TObjString*) other.fCutMonitorsOptions->UncheckedAt(iCutMon);
110 fCutMonitors->AddLast(cut->MakeCopy());
111 fCutMonitorsOptions->AddLast(str->Clone());
117 void CutsAndMonitors::AddCut(
const Cut& cut, Option_t* opt) {
118 if (fCuts ==
nullptr) {
119 fCuts =
new TObjArray();
120 fCutsOptions =
new TObjArray();
121 fCuts->SetOwner(kTRUE);
122 fCutsOptions->SetOwner(kTRUE);
124 TObjString* str =
new TObjString(opt);
126 fCutsOptions->Add(str);
129 void CutsAndMonitors::AddCutMonitor(
const CutMonitor& monitor, Option_t* opt) {
130 if (fCutMonitors ==
nullptr) {
131 fCutMonitors =
new TObjArray();
132 fCutMonitorsOptions =
new TObjArray();
133 fCutMonitors->SetOwner(kTRUE);
134 fCutMonitorsOptions->SetOwner(kTRUE);
136 TObjString* str =
new TObjString(opt);
137 fCutMonitors->Add(monitor.
MakeCopy());
138 fCutMonitorsOptions->Add(str);
141 const Cut* CutsAndMonitors::GetCut(Int_t i)
const {
return static_cast<Cut*
>(fCuts->UncheckedAt(i)); }
143 TString CutsAndMonitors::GetCutOption(Int_t i)
const {
144 TString opt =
static_cast<TObjString*
>(fCutsOptions->UncheckedAt(i))->GetString();
145 if (opt ==
"" || fGlobalOptionCuts ==
"") {
return opt + fGlobalOptionCuts; }
146 return opt +
"+" + fGlobalOptionCuts;
149 const CutMonitor* CutsAndMonitors::GetMonitor(Int_t i)
const {
return static_cast<CutMonitor*
>(fCutMonitors->UncheckedAt(i)); }
151 TString CutsAndMonitors::GetCutMonitorOption(Int_t i)
const {
152 TString opt =
static_cast<TObjString*
>(fCutMonitorsOptions->UncheckedAt(i))->GetString();
153 if (opt ==
"" || fGlobalOptionsCutMonitors ==
"") {
return opt + fGlobalOptionsCutMonitors; }
154 return opt +
"+" + fGlobalOptionsCutMonitors;
157 CutsAndMonitors::~CutsAndMonitors() {
158 if (fCutMonitors)
delete fCutMonitors;
159 if (fCutMonitorsOptions)
delete fCutMonitorsOptions;
160 if (fCuts)
delete fCuts;
161 if (fCutsOptions)
delete fCutsOptions;
164 Cut* CutsAndMonitors::CutAt(Int_t i)
const {
return static_cast<Cut*
>(fCuts->UncheckedAt(i)); }
166 CutMonitor* CutsAndMonitors::MonitorAt(Int_t i)
const {
return static_cast<CutMonitor*
>(fCutMonitors->UncheckedAt(i)); }
168 void CutsAndMonitors::ClearCuts() {
170 fCutsOptions->Clear();
173 void CutsAndMonitors::ClearMonitors() {
174 fCutMonitors->Clear();
175 fCutMonitorsOptions->Clear();
178 void CutsAndMonitors::AddRawCut(
Cut* cut, TObjString* opt) {
179 if (opt ==
nullptr) { opt =
new TObjString(
""); }
180 if (fCuts ==
nullptr) {
181 fCuts =
new TObjArray();
182 fCutsOptions =
new TObjArray();
183 fCuts->SetOwner(kTRUE);
184 fCutsOptions->SetOwner(kTRUE);
187 fCutsOptions->Add(opt);
190 void CutsAndMonitors::AddRawCutMonitor(
CutMonitor* mon, TObjString* opt) {
191 if (opt ==
nullptr) { opt =
new TObjString(
""); }
192 if (fCutMonitors ==
nullptr) {
193 fCutMonitors =
new TObjArray();
194 fCutMonitorsOptions =
new TObjArray();
195 fCutMonitors->SetOwner(kTRUE);
196 fCutMonitorsOptions->SetOwner(kTRUE);
198 fCutMonitors->Add(mon);
199 fCutMonitorsOptions->Add(opt);
202 CutMonitor* CutsAndMonitors::MakeCutMonitor(Int_t request_no)
const {
203 if (request_no < 0 || request_no > (
int) fCutMonitorRequests.size())
return nullptr;
205 auto TransformOpt = [](TString opt) {
206 if (Hal::Std::FindParam(opt,
"re")) {
208 }
else if (Hal::Std::FindParam(opt,
"im")) {
219 const Cut* CutX = GetCut(x.GetCutNo());
220 TString optX = TransformOpt(GetCutOption(x.GetCutNo()));
230 const Cut* CutX = GetCut(x.GetCutNo());
231 const Cut* CutY = GetCut(y.GetCutNo());
232 TString optX = TransformOpt(GetCutOption(x.GetCutNo()));
233 TString optY = TransformOpt(GetCutOption(y.GetCutNo()));
246 const Cut* CutX = GetCut(x.GetCutNo());
247 const Cut* CutY = GetCut(y.GetCutNo());
248 const Cut* CutZ = GetCut(z.GetCutNo());
249 TString optX = TransformOpt(GetCutOption(x.GetCutNo()));
250 TString optY = TransformOpt(GetCutOption(y.GetCutNo()));
251 TString optZ = TransformOpt(GetCutOption(z.GetCutNo()));
267 void CutsAndMonitors::MakeCutMonitors(Option_t* opt) {
268 AddAllCutMonitorRequests(opt);
269 if (GetNRequest() != 0) {
270 for (
int iMon = 0; iMon < GetNRequest(); iMon++) {
272 if (mon !=
nullptr) { AddRawCutMonitor(mon); }
277 Int_t CutsAndMonitors::GetCutNo(TString classname)
const {
278 for (
int i = 0; i < fCuts->GetEntriesFast(); i++) {
279 Cut* cut =
static_cast<Cut*
>(fCuts->UncheckedAt(i));
280 TString name = cut->ClassName();
281 if (name.EqualTo(classname))
return i;
296 void CutsAndMonitors::SetCollectionID(Int_t
id) {
297 for (
int i = 0; i < fCuts->GetEntriesFast(); i++) {
298 Cut* cut =
static_cast<Cut*
>(fCuts->UncheckedAt(i));
TString GetCutClassName() const
Int_t GetParameterNo() const
CutMonAxisConf GetConf(Char_t axis) const
void SetYaxis(Int_t bins, Double_t min, Double_t max)
void SetZaxis(Int_t bins, Double_t min, Double_t max)
virtual CutMonitor * MakeCopy() const
void SetXaxis(Int_t bins, Double_t min, Double_t max)
virtual TString CutName(Option_t *opt="") const
void SetCollectionID(Int_t i)
virtual Cut * MakeCopy() const