Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
PropertyMonitorXYZ.cxx
1/*
2 * PropertyMonitorXYZ.cxx
3 *
4 * Created on: 21 sie 2020
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "PropertyMonitorXYZ.h"
11
12#include "ComplexEvent.h"
13#include "ComplexTrack.h"
14#include "Cout.h"
15#include "DataFormatManager.h"
16#include "Event.h"
17#include "Package.h"
18#include "Parameter.h"
19#include "Std.h"
20#include "StdString.h"
21
22#include <TAxis.h>
23#include <TH1.h>
24#include <TH3.h>
25#include <TString.h>
26
27
28namespace Hal {
30 TString title = Form("%s vs %s vs %s",
31 Hal::Std::RemoveUnits(fZaxisName).Data(),
32 Hal::Std::RemoveUnits(fYaxisName).Data(),
33 Hal::Std::RemoveUnits(fXaxisName).Data());
34 TString
35 name; // = Form("%s_vs_%s_vs_%s",
36 // fCut[0]->GetUnit(fOptionAxis[0]).Data(),fCut[1]->GetUnit(fOptionAxis[1]).Data(),fCut[2]->GetUnit(fOptionAxis[2]).Data());
37 name = "Passed";
38 // title = title + Form(" ** %s %s %s
39 // ",fCut[0]->ClassName(),fCut[1]->ClassName(),fCut[2]->ClassName());
40 fHistoPassed = new TH3D(name,
41 title,
42 fAxisBins[0],
43 fAxisMin[0],
44 fAxisMax[0],
45 fAxisBins[1],
46 fAxisMin[1],
47 fAxisMax[1],
48 fAxisBins[2],
49 fAxisMin[2],
50 fAxisMax[2]);
51 fHistoPassed->GetXaxis()->SetTitle(fXaxisName);
52 fHistoPassed->GetYaxis()->SetTitle(fYaxisName);
53 fHistoPassed->GetZaxis()->SetTitle(fZaxisName);
54 name = "Failed";
55 fHistoFailed = (TH3D*) fHistoPassed->Clone(name);
56 fInit = kTRUE;
57 }
58
59 PropertyMonitorXYZ::PropertyMonitorXYZ(TString xLabel, TString yLabel, TString zLabel, ECutUpdate update) :
60 fXaxisName(xLabel), fYaxisName(yLabel), fZaxisName(zLabel), fFormatType(EFormatType::kReco) {
61 fUpdateRatio = update;
62 }
63
65 fXaxisName = other.fXaxisName;
66 fYaxisName = other.fYaxisName;
67 fZaxisName = other.fZaxisName;
68 fFormatType = other.fFormatType;
69 }
70
71 Bool_t PropertyMonitorXYZ::Init(Int_t task_id) {
72 if (fInit) {
73#ifdef HAL_DEBUG
74 Cout::PrintInfo(Form("%s is initialized ", this->ClassName()), EInfo::kDebugInfo);
75#endif
76 return kFALSE;
77 }
78 const Event* ev = DataFormatManager::Instance()->GetFormat(task_id, EFormatDepth::kNonBuffered);
79 fFormatType = ev->GetFormatType();
80 TH1::AddDirectory(kFALSE);
82 TH1::AddDirectory(kTRUE);
83 fInit = kTRUE;
84 return kTRUE;
85 }
86
89 report->AddObject(new ParameterString("AxisX", fXaxisName));
90 report->AddObject(new ParameterString("CutXName", "-"));
91 report->AddObject(new ParameterDouble("CutXMin", 0));
92 report->AddObject(new ParameterDouble("CutXMax", 0));
93 report->AddObject(new ParameterInt("CutXAxis", 0));
94 report->AddObject(new ParameterInt("CutXCollection", fCollectionID));
95 report->AddObject(new ParameterString("AxisY", fYaxisName));
96 report->AddObject(new ParameterString("CutYName", "-"));
97 report->AddObject(new ParameterDouble("CutYMin", 0));
98 report->AddObject(new ParameterDouble("CutYMax", 0));
99 report->AddObject(new ParameterInt("CutYAxis", 0));
100 report->AddObject(new ParameterInt("CutYCollection", fCollectionID));
101 report->AddObject(new ParameterString("AxisZ", fZaxisName));
102 report->AddObject(new ParameterString("CutZName", "-"));
103 report->AddObject(new ParameterDouble("CutZMin", 0));
104 report->AddObject(new ParameterDouble("CutZMax", 0));
105 report->AddObject(new ParameterInt("CutZAxis", 0));
106 report->AddObject(new ParameterInt("CutZCollection", fCollectionID));
107 return report;
108 }
109
111 if (this != &other) {
113 fXaxisName = other.fXaxisName;
114 fYaxisName = other.fYaxisName;
115 fZaxisName = other.fZaxisName;
116 fFormatType = other.fFormatType;
117 }
118 return *this;
119 }
120
121 PropertyMonitorXYZ::~PropertyMonitorXYZ() {
122 // TODO Auto-generated destructor stub
123 }
124 //========================================================================
125 EventFieldMonitorXYZ::EventFieldMonitorXYZ(Int_t fieldIDX, Int_t fiedIDY, Int_t fiedIDZ) :
126 PropertyMonitorXYZ("", "", "", ECutUpdate::kEvent), fFieldIDX(fieldIDX), fFieldIDY(fiedIDY), fFieldIDZ(fiedIDZ) {}
127
129 std::initializer_list<Double_t> xAxis,
130 Int_t fieldDY,
131 std::initializer_list<Double_t> yAxis,
132 Int_t fieldDZ,
133 std::initializer_list<Double_t> zAxis) :
134 PropertyMonitorXYZ("", "", "", ECutUpdate::kEvent), fFieldIDX(fieldIDX), fFieldIDY(fieldDY), fFieldIDZ(fieldDZ) {
135 SetAxisList(xAxis, 'x');
136 SetAxisList(yAxis, 'y');
137 SetAxisList(zAxis, 'z');
138 }
139
140 void EventFieldMonitorXYZ::Update(Bool_t passed, TObject* obj) {
141
142 Event* ev = (Event*) obj;
143 if (passed) {
144 ((TH3*) fHistoPassed)->Fill(ev->GetFieldVal(fFieldIDX), ev->GetFieldVal(fFieldIDY), ev->GetFieldVal(fFieldIDZ));
145 } else {
146 ((TH3*) fHistoFailed)->Fill(ev->GetFieldVal(fFieldIDX), ev->GetFieldVal(fFieldIDY), ev->GetFieldVal(fFieldIDZ));
147 }
148 }
149
150 Bool_t EventFieldMonitorXYZ::Init(Int_t task_id) {
151 const Event* ev = DataFormatManager::Instance()->GetFormat(task_id, EFormatDepth::kNonBuffered);
152
153 fXaxisName = ev->GetFieldName(fFieldIDX);
154 fYaxisName = ev->GetFieldName(fFieldIDY);
155 fZaxisName = ev->GetFieldName(fFieldIDZ);
156 return PropertyMonitorXYZ::Init(task_id);
157 }
158 //========================================================================
159 TrackFieldMonitorXYZ::TrackFieldMonitorXYZ(Int_t fieldIDX, Int_t fiedIDY, Int_t fiedIDZ) :
160 PropertyMonitorXYZ("", "", "", ECutUpdate::kTrack), fFieldIDX(fieldIDX), fFieldIDY(fiedIDY), fFieldIDZ(fiedIDZ) {}
161
163 std::initializer_list<Double_t> xAxis,
164 Int_t fieldDY,
165 std::initializer_list<Double_t> yAxis,
166 Int_t fieldDZ,
167 std::initializer_list<Double_t> zAxis) :
168 PropertyMonitorXYZ("", "", "", ECutUpdate::kTrack), fFieldIDX(fieldIDX), fFieldIDY(fieldDY), fFieldIDZ(fieldDZ) {
169 SetAxisList(xAxis, 'x');
170 SetAxisList(yAxis, 'y');
171 SetAxisList(zAxis, 'z');
172 }
173
174 void TrackFieldMonitorXYZ::Update(Bool_t passed, TObject* obj) {
175
176 Track* tr = (Track*) obj;
177 if (passed) {
178 ((TH3*) fHistoPassed)->Fill(tr->GetFieldVal(fFieldIDX), tr->GetFieldVal(fFieldIDY), tr->GetFieldVal(fFieldIDZ));
179 } else {
180 ((TH3*) fHistoFailed)->Fill(tr->GetFieldVal(fFieldIDX), tr->GetFieldVal(fFieldIDY), tr->GetFieldVal(fFieldIDZ));
181 }
182 }
183
184 Bool_t TrackFieldMonitorXYZ::Init(Int_t task_id) {
185 const Event* ev = DataFormatManager::Instance()->GetFormat(task_id, EFormatDepth::kNonBuffered);
186 if (ev->InheritsFrom("Hal::ComplexEvent")) {
188 ComplexEvent* tev = (ComplexEvent*) ev->GetNewEvent();
189 tr->SetEvent(tev);
190 fXaxisName = tr->GetFieldName(fFieldIDX);
191 fYaxisName = tr->GetFieldName(fFieldIDY);
192 fZaxisName = tr->GetFieldName(fFieldIDZ);
193 delete tr;
194 delete tev;
195 } else {
196 Track* tr = ev->GetNewTrack();
197 fXaxisName = tr->GetFieldName(fFieldIDX);
198 fYaxisName = tr->GetFieldName(fFieldIDY);
199 fZaxisName = tr->GetFieldName(fFieldIDZ);
200 delete tr;
201 }
202 return PropertyMonitorXYZ::Init(task_id);
203 }
204} // namespace Hal
virtual TString GetFieldName(Int_t fieldID) const
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
CutMonitorXYZ & operator=(const CutMonitorXYZ &other)
Double_t * fAxisMax
Definition CutMonitor.h:63
Int_t fCollectionID
Definition CutMonitor.h:39
Int_t * fAxisBins
Definition CutMonitor.h:43
void SetAxisList(std::initializer_list< Double_t > axis, Char_t opt)
Double_t * fAxisMin
Definition CutMonitor.h:59
ECutUpdate fUpdateRatio
Definition CutMonitor.h:83
virtual Package * Report() const
const Event * GetFormat(Int_t task_id, EFormatDepth format_depth=EFormatDepth::kAll) const
static DataFormatManager * Instance()
virtual void Update(Bool_t passed, TObject *obj)
virtual Bool_t Init(Int_t task_id)
EventFieldMonitorXYZ(Int_t fieldIDX=0, Int_t fieldDY=0, Int_t fieldDZ=0)
virtual EFormatType GetFormatType() const
Definition Event.h:266
Track * GetNewTrack() const
Definition Event.cxx:204
virtual Float_t GetFieldVal(Int_t fieldID) const
Definition Event.cxx:254
virtual Event * GetNewEvent() const
Definition Event.cxx:215
virtual TString GetFieldName(Int_t fieldID) const
Definition Event.cxx:272
void AddObject(TObject *object)
Definition Package.cxx:209
PropertyMonitorXYZ(TString xLabel="", TString yLabel="", TString zLabel="", ECutUpdate update=ECutUpdate::kEvent)
virtual Bool_t Init(Int_t task_id)
PropertyMonitorXYZ & operator=(const PropertyMonitorXYZ &other)
virtual Package * Report() const
virtual void Update(Bool_t passed, TObject *obj)
TrackFieldMonitorXYZ(Int_t fieldIDX=0, Int_t fieldDY=0, Int_t fieldDZ=0)
virtual Bool_t Init(Int_t task_id)
void SetEvent(Event *event)
Definition Track.h:337
virtual Float_t GetFieldVal(Int_t fieldID) const
Definition Track.cxx:206
virtual TString GetFieldName(Int_t fieldID) const
Definition Track.cxx:244