12#include "ComplexEvent.h"
13#include "ComplexTrack.h"
15#include "DataFormatManager.h"
17#include "HistogramManager.h"
18#include "QAPlotAxis.h"
29 QAPlot::QAPlot() : fUpdate(ECutUpdate::kNo), fReport(nullptr) {}
31 QAPlot::QAPlot(ECutUpdate upd) : QAPlot(
"", upd) {}
34 if (fReport)
delete fReport;
37 QAPlot::QAPlot(
const QAPlot& other) : TNamed(other), fReport(nullptr) {
38 if (other.fReport) fReport =
new QAPlotReport(*other.fReport);
39 fUpdate = other.fUpdate;
40 for (
int i = 0; i < 3; i++) {
41 fSettings[i] = other.fSettings[i];
45 QAPlot::QAPlot(TString name, ECutUpdate upd) : fUpdate(upd), fReport(nullptr) { SetName(name); }
49 if (ev ==
nullptr)
return kFALSE;
51 case ECutUpdate::kEvent: {
52 for (
int j = 0; j < 3; j++) {
53 for (
unsigned int i = 0; i < fSettings[j].size(); i++) {
54 if (fSettings[j][i].IsCustom())
continue;
55 Int_t fieldIDx = fSettings[j][i].GetFillFlagX();
58 fSettings[j][i].SetXaxisName(axisNameX);
61 Int_t fieldIDy = fSettings[j][i].GetFillFlagY();
63 fSettings[j][i].SetYaxisName(axisNameY);
66 Int_t fieldIDz = fSettings[j][i].GetFillFlagZ();
68 fSettings[j][i].SetZaxisName(axisNameZ);
73 case ECutUpdate::kTrack: {
77 Track* re_track =
nullptr;
78 Track* im_track =
nullptr;
82 re_track = zev->GetNewRealTrack();
83 re_track->
SetEvent(zEvent->GetRealEvent());
84 im_track = zev->GetNewImgTrack();
85 im_track->
SetEvent(zEvent->GetImgEvent());
86 z_track->SetImgTrack(im_track);
87 z_track->SetRealTrack(re_track);
90 for (
int j = 0; j < 3; j++) {
91 for (
unsigned int i = 0; i < fSettings[j].size(); i++) {
92 if (fSettings[j][i].IsCustom())
continue;
93 Int_t fieldIDx = fSettings[j][i].GetFillFlagX();
96 fSettings[j][i].SetXaxisName(axisNameX);
99 Int_t fieldIDy = fSettings[j][i].GetFillFlagY();
101 fSettings[j][i].SetYaxisName(axisNameY);
104 Int_t fieldIDz = fSettings[j][i].GetFillFlagZ();
106 fSettings[j][i].SetZaxisName(axisNameZ);
112 if (re_track)
delete re_track;
113 if (im_track)
delete im_track;
119 for (
int j = 0; j < 3; j++) {
120 for (
unsigned int i = 0; i < fSettings[j].size(); i++) {
121 fReport->
SetFlag(i, fSettings[j][i].GetFlag(), j + 1);
124 if (GetSize1D() > 0) {
125 fReport->f1dHistos->
Init(GetSize1D(), 1, 0, 1);
126 for (
int i = 0; i < GetSize1D(); i++) {
127 fReport->f1dHistos->
OverwriteAt(((TH1D*) fSettings[0][i].MakeHisto()), i);
133 fReport->f2dHistos->
OverwriteAt(((TH2D*) fSettings[1][i].MakeHisto()), i);
137 fReport->f3dHistos->
Init(
GetSize3D(), 1, 0, 1, 1, 0, 1, 1, 0, 1);
139 fReport->f3dHistos->
OverwriteAt(((TH3D*) fSettings[2][i].MakeHisto()), i);
146 case ECutUpdate::kEvent: {
147 FillEvent(
static_cast<Event*
>(obj));
149 case ECutUpdate::kTrack: {
150 FillTrack(
static_cast<Track*
>(obj));
157 if (&other ==
this)
return *
this;
158 if (fReport)
delete fReport;
160 if (other.fReport) fReport =
new QAPlotReport(*other.fReport);
161 TNamed::operator=(other);
162 fUpdate = other.fUpdate;
163 for (
int i = 0; i < 3; i++) {
164 fSettings[i] = other.fSettings[i];
169 QAPlotReport* QAPlot::GetReport()
const {
170 QAPlotReport* rep =
new QAPlotReport(*this->fReport);
171 rep->SetName(this->GetName());
172 rep->SetOriginClass(this->ClassName());
177 Int_t old_size = fSettings[0].size();
179 fSettings[0][old_size].SetName(name);
180 fSettings[0][old_size].SetTitle(name);
181 fSettings[0][old_size].SetFlag(flag);
182 fSettings[0][old_size].SetFillFlagX(x.GetFlag());
183 fSettings[0][old_size].SetXaxis(x.GetNBins(), x.GetMin(), x.GetMax());
188 Int_t old_size = fSettings[1].size();
190 fSettings[1][old_size].SetName(name);
191 fSettings[1][old_size].SetTitle(name);
192 fSettings[1][old_size].SetFlag(flag);
193 fSettings[1][old_size].SetFillFlagX(x.GetFlag());
194 fSettings[1][old_size].SetFillFlagY(y.GetFlag());
195 fSettings[1][old_size].SetXaxis(x.GetNBins(), x.GetMin(), x.GetMax());
196 fSettings[1][old_size].SetYaxis(y.GetNBins(), y.GetMin(), y.GetMax());
201 Int_t old_size = fSettings[2].size();
203 fSettings[2][old_size].SetName(name);
204 fSettings[2][old_size].SetTitle(name);
205 fSettings[2][old_size].SetFlag(flag);
206 fSettings[2][old_size].SetFillFlagX(x.GetFlag());
207 fSettings[2][old_size].SetFillFlagY(y.GetFlag());
208 fSettings[2][old_size].SetFillFlagZ(z.GetFlag());
209 fSettings[2][old_size].SetXaxis(x.GetNBins(), x.GetMin(), x.GetMax());
210 fSettings[2][old_size].SetYaxis(y.GetNBins(), y.GetMin(), y.GetMax());
211 fSettings[2][old_size].SetZaxis(z.GetNBins(), z.GetMin(), z.GetMax());
215 void QAPlot::FillTrack(
Track* track) {
216 for (
unsigned int i = 0; i < fSettings[0].size(); i++) {
217 if (fSettings[0][i].IsCustom()) {
223 for (
unsigned int i = 0; i < fSettings[1].size(); i++) {
224 if (fSettings[1][i].IsCustom()) {
230 for (
unsigned int i = 0; i < fSettings[2].size(); i++) {
231 if (fSettings[2][i].IsCustom()) {
235 track->
GetFieldVal(fSettings[2][i].GetFillFlagY()),
236 track->
GetFieldVal(fSettings[2][i].GetFillFlagZ()));
241 void QAPlot::FillEvent(Event* event) {
242 for (
int i = 0; i < GetSize1D(); i++) {
243 if (fSettings[0][i].IsCustom()) {
246 Get1D(i)->Fill(event->GetFieldVal(fSettings[0][i].GetFillFlagX()));
250 if (fSettings[1][i].IsCustom()) {
253 Get2D(i)->Fill(event->GetFieldVal(fSettings[1][i].GetFillFlagX()), event->GetFieldVal(fSettings[1][i].GetFillFlagY()));
257 if (fSettings[2][i].IsCustom()) {
260 Get3D(i)->Fill(event->GetFieldVal(fSettings[2][i].GetFillFlagX()),
261 event->GetFieldVal(fSettings[2][i].GetFillFlagY()),
262 event->GetFieldVal(fSettings[2][i].GetFillFlagZ()));
267 void QAPlot::Print(Option_t* )
const {
268 for (
int i = 0; i < 3; i++) {
269 for (
unsigned int j = 0; j < fSettings[i].size(); j++) {
270 fSettings[i][j].Print();
Track * GetNewTrack() const
virtual Event * GetNewEvent() const
virtual TString GetFieldName(Int_t fieldID) const
void Init(Int_t size, HistogramAxisConf **axisconf, TString title, Bool_t Sumw=kFALSE)
void OverwriteAt(T *t, Int_t pos)
void OverwriteAt(T *t, Int_t pos)
void Init(Int_t size, HistogramAxisConf **axisconf, TString title, Bool_t Sumw=kFALSE)
void Init(Int_t size, HistogramAxisConf **axisconf, TString title, Bool_t Sumw=kFALSE)
void OverwriteAt(T *t, Int_t pos)
void SetFlag(Int_t no, TString flag, Int_t dim)
virtual void FillEventCustom3D(Event *, TH3D *, Int_t)
virtual void Fill(TObject *obj)
virtual Bool_t Init(Int_t id_task=-1)
Int_t AddTH1(TString name, const QAPlotAxis &x, TString flag="")
Int_t AddTH2(TString name, const QAPlotAxis &x, const QAPlotAxis &y, TString flag="")
Int_t AddTH3(TString name, const QAPlotAxis &x, const QAPlotAxis &y, const QAPlotAxis &z, TString flag="")
virtual void FillEventCustom2D(Event *, TH2D *, Int_t)
TH1D * Get1D(Int_t no) const
virtual void FillTrackCustom1D(Track *, TH1D *, Int_t)
TH3D * Get3D(Int_t no) const
TH2D * Get2D(Int_t no) const
virtual void FillTrackCustom2D(Track *, TH2D *, Int_t)
virtual void FillEventCustom1D(Event *, TH1D *, Int_t)
virtual void FillTrackCustom3D(Track *, TH3D *, Int_t)
void SetEvent(Event *event)
virtual Float_t GetFieldVal(Int_t fieldID) const
virtual TString GetFieldName(Int_t fieldID) const