Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
PropertyMonitorXY.cxx
1/*
2 * CutMonitorObjectXY.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 "PropertyMonitorXY.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 <RtypesCore.h>
23#include <TAxis.h>
24#include <TH1.h>
25#include <TH2.h>
26#include <TString.h>
27
28
29namespace Hal {
30
32 TH1::AddDirectory(kFALSE);
33 TString title = Form("%s vs %s", Hal::Std::RemoveUnits(fYaxisName).Data(), Hal::Std::RemoveUnits(fXaxisName).Data());
34 TString name; // = Form("%s_vs_%s",
35 // fCut[0]->GetUnit(fOptionAxis[0]).Data(),fCut[1]->GetUnit(fOptionAxis[1]).Data());
36 name = "Passed";
37 fHistoPassed = new TH2D(name, title, fAxisBins[0], fAxisMin[0], fAxisMax[0], fAxisBins[1], fAxisMin[1], fAxisMax[1]);
38 fHistoPassed->GetXaxis()->SetTitle(fXaxisName);
39 fHistoPassed->GetYaxis()->SetTitle(fYaxisName);
40 name = name + "_F";
41 name = "Failed";
42 fHistoFailed = new TH2D(name, title, fAxisBins[0], fAxisMin[0], fAxisMax[0], fAxisBins[1], fAxisMin[1], fAxisMax[1]);
43 fHistoFailed->GetXaxis()->SetTitle(fXaxisName);
44 fHistoFailed->GetYaxis()->SetTitle(fYaxisName);
45 TH1::AddDirectory(kTRUE);
46 }
47
48 PropertyMonitorXY::PropertyMonitorXY(TString xLabel, TString yLabel, ECutUpdate update) :
49 CutMonitorXY(), fXaxisName(xLabel), fYaxisName(yLabel), fFormatType(EFormatType::kReco) {
50 fUpdateRatio = update;
51 }
52
54 fXaxisName = other.fXaxisName;
55 fYaxisName = other.fYaxisName;
56 fFormatType = other.fFormatType;
57 }
58
59 Bool_t PropertyMonitorXY::Init(Int_t task_id) {
60 if (fInit) {
61#ifdef HAL_DEBUG
62 Cout::PrintInfo(Form("%s is initialized ", this->ClassName()), EInfo::kDebugInfo);
63#endif
64 return kFALSE;
65 }
66 const Event* ev = DataFormatManager::Instance()->GetFormat(task_id, EFormatDepth::kNonBuffered);
67 fFormatType = ev->GetFormatType();
68 TH1::AddDirectory(kFALSE);
70 TH1::AddDirectory(kTRUE);
71 fInit = kTRUE;
72 return kTRUE;
73 }
74
76 Package* report = CutMonitorXY::Report();
77 report->AddObject(new ParameterString("AxisX", fXaxisName));
78 report->AddObject(new ParameterString("CutXName", "-"));
79 report->AddObject(new ParameterDouble("CutXMin", 0));
80 report->AddObject(new ParameterDouble("CutXMax", 0));
81 report->AddObject(new ParameterInt("CutXAxis", 0));
82 report->AddObject(new ParameterInt("CutXCollection", fCollectionID));
83 report->AddObject(new ParameterString("AxisY", fYaxisName));
84 report->AddObject(new ParameterString("CutYName", "-"));
85 report->AddObject(new ParameterDouble("CutYMin", 0));
86 report->AddObject(new ParameterDouble("CutYMax", 0));
87 report->AddObject(new ParameterInt("CutYAxis", 0));
88 report->AddObject(new ParameterInt("CutYCollection", fCollectionID));
89 return report;
90 }
91
93 if (this != &other) {
95 fXaxisName = other.fXaxisName;
96 fYaxisName = other.fYaxisName;
97 fFormatType = other.fFormatType;
98 }
99 return *this;
100 }
101
102 PropertyMonitorXY::~PropertyMonitorXY() {
103 // TODO Auto-generated destructor stub
104 }
105 //========================================================================
106 EventFieldMonitorXY::EventFieldMonitorXY(Int_t fieldIDX, Int_t fiedIDY) :
107 PropertyMonitorXY("", "", ECutUpdate::kEvent), fFieldIDX(fieldIDX), fFieldIDY(fiedIDY) {}
108
110 std::initializer_list<Double_t> xAxis,
111 Int_t fiedIDY,
112 std::initializer_list<Double_t> yAxis) :
113 PropertyMonitorXY("", "", ECutUpdate::kEvent), fFieldIDX(fieldIDX), fFieldIDY(fiedIDY) {
114 SetAxisList(xAxis, 'x');
115 SetAxisList(yAxis, 'y');
116 }
117
118 void EventFieldMonitorXY::Update(Bool_t passed, TObject* obj) {
119 Event* ev = (Event*) obj;
120 if (passed) {
121 fHistoPassed->Fill(ev->GetFieldVal(fFieldIDX), ev->GetFieldVal(fFieldIDY));
122 } else {
123 fHistoFailed->Fill(ev->GetFieldVal(fFieldIDX), ev->GetFieldVal(fFieldIDY));
124 }
125 }
126
127 Bool_t EventFieldMonitorXY::Init(Int_t task_id) {
128 const Event* ev = DataFormatManager::Instance()->GetFormat(task_id, EFormatDepth::kNonBuffered);
129 fXaxisName = ev->GetFieldName(fFieldIDX);
130 fYaxisName = ev->GetFieldName(fFieldIDY);
131 return PropertyMonitorXY::Init(task_id);
132 }
133 //========================================================================
134 TrackFieldMonitorXY::TrackFieldMonitorXY(Int_t fieldIDX, Int_t fiedIDY) :
135 PropertyMonitorXY(",", "", ECutUpdate::kTrack), fFieldIDX(fieldIDX), fFieldIDY(fiedIDY) {}
136
138 std::initializer_list<Double_t> xAxis,
139 Int_t fiedIDY,
140 std::initializer_list<Double_t> yAxis) :
141 PropertyMonitorXY("", "", ECutUpdate::kTrack), fFieldIDX(fieldIDX), fFieldIDY(fiedIDY) {
142 SetAxisList(xAxis, 'x');
143 SetAxisList(yAxis, 'y');
144 }
145
146 void TrackFieldMonitorXY::Update(Bool_t passed, TObject* obj) {
147 Track* tr = (Track*) obj;
148 if (passed) {
149 fHistoPassed->Fill(tr->GetFieldVal(fFieldIDX), tr->GetFieldVal(fFieldIDY));
150 } else {
151 fHistoFailed->Fill(tr->GetFieldVal(fFieldIDX), tr->GetFieldVal(fFieldIDY));
152 }
153 }
154
155 Bool_t TrackFieldMonitorXY::Init(Int_t task_id) {
156 const Event* ev = DataFormatManager::Instance()->GetFormat(task_id, EFormatDepth::kNonBuffered);
157 if (ev->InheritsFrom("Hal::ComplexEvent")) {
159 ComplexEvent* tev = (ComplexEvent*) ev->GetNewEvent();
160 tr->SetEvent(tev);
161 fXaxisName = tr->GetFieldName(fFieldIDX);
162 fYaxisName = tr->GetFieldName(fFieldIDY);
163 delete tr;
164 delete tev;
165 } else {
166 Track* tr = ev->GetNewTrack();
167 fXaxisName = tr->GetFieldName(fFieldIDX);
168 fYaxisName = tr->GetFieldName(fFieldIDY);
169 delete tr;
170 }
171 return PropertyMonitorXY::Init(task_id);
172 }
173} // namespace Hal
virtual TString GetFieldName(Int_t fieldID) const
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
CutMonitorXY & operator=(const CutMonitorXY &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 Bool_t Init(Int_t task_id)
virtual void Update(Bool_t passed, TObject *obj)
EventFieldMonitorXY(Int_t fieldIDX=0, Int_t fieldIDY=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
virtual Package * Report() const
PropertyMonitorXY & operator=(const PropertyMonitorXY &other)
virtual Bool_t Init(Int_t task_id)
PropertyMonitorXY(TString xLabel="", TString yLabel="", ECutUpdate update=ECutUpdate::kEvent)
TrackFieldMonitorXY(Int_t fieldIDX=0, Int_t fieldIDY=0)
virtual Bool_t Init(Int_t task_id)
virtual void Update(Bool_t passed, TObject *obj)
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