Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
SimpleVnAnalysis.cxx
1/*
2 * SimpleVnAnalysis.cxx
3 *
4 * Created on: 19-10-2013
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "SimpleVnAnalysis.h"
11
12#include "Cout.h"
13#include "CutContainer.h"
14#include "DividedHisto.h"
15#include "Event.h"
16#include "Package.h"
17#include "Parameter.h"
18#include "Std.h"
19#include "Track.h"
20
21#include <TMath.h>
22#include <TString.h>
23#include <iostream>
24
25
26namespace Hal {
28 TrackAna(),
29 fBinsX(1),
30 fBinsY(1),
31 fVarX(NULL),
32 fVarY(NULL),
33 fMinX(0),
34 fMinY(0),
35 fMaxX(1),
36 fMaxY(0),
37 fN(n),
38 fPhi(0.0),
39 fNDim(2) {}
40
42 Double_t px = fCurrentTrack->GetPx();
43 Double_t py = fCurrentTrack->GetPy();
44 Double_t phi = TMath::ATan2(py, px);
45 Double_t Phi = GetPhi();
46 Double_t v2N = TMath::Cos(fN * (phi - Phi));
47 Double_t valueX = fVarX->GetVariable(fCurrentTrack);
48
49 auto div = fHistos[fCurrentTrackCollectionID];
50 switch (fNDim) {
51 case 1: {
52 div->FillNum(valueX, v2N);
53 div->FillDen(valueX, 1);
54 } break;
55 case 2: {
56 Double_t valueY = fVarY->GetVariable(fCurrentTrack);
57 ((DividedHisto2D*) div)->FillNum(valueX, valueY, v2N);
58 ((DividedHisto2D*) div)->FillDen(valueX, valueY, 1);
59 } break;
60 default: break;
61 }
62 }
63
64 void SimpleVnAnalysis::SetAxis(Int_t nbins, Double_t min, Double_t max, Char_t axis) {
65 if (min == max) {
66 min = 0;
67 max = 1;
68 }
69 if (nbins < 0) { nbins = 100; }
70
71 switch (axis) {
72 case 'x': {
73 fMinX = min;
74 fMaxX = max;
75 fBinsX = nbins;
76 } break;
77 case 'y': {
78 fMinY = min;
79 fMaxY = max;
80 fBinsY = nbins;
81 } break;
82
83 default:
84#ifdef HAL_DEBUG
85 Cout::PrintInfo(Form("Wrong SetAxis option in %s", this->ClassName()), EInfo::kLowWarning);
86#endif
87 ;
88 break;
89 }
90 }
91
92 Task::EInitFlag SimpleVnAnalysis::Init() {
93 if (TrackAna::Init() == Task::EInitFlag::kSUCCESS) {
94 // checking "fake collections"
95 if (!fVarX) {
96 Cout::PrintInfo("No FlowVariable on X", EInfo::kLowWarning);
97 return Task::EInitFlag::kFATAL;
98 }
99 if (!fVarY) {
100 Cout::PrintInfo("No FlowVariable on Y, it will be empty", EInfo::kLowWarning);
101 fVarY = new FlowVirtualVariable();
102 fNDim = 1;
103 SetAxis(1, 0, 1, 1);
104 }
105 if (!fVarX->Init(GetTaskID())) { return Task::EInitFlag::kERROR; }
106 if (!fVarY->Init(GetTaskID()) && fNDim == 2) { return Task::EInitFlag::kERROR; }
107 HistogramAxisConf axX(fVarX->GetAxisName(), fBinsX, fMinX, fMaxX);
108 fHistos = new DividedHisto1D*[fTrackCollectionsNo];
109 switch (fNDim) {
110 case 1: {
111 HistogramAxisConf axY(Form("dN/%s", fVarX->GetAxisUnit().Data()), 0, 0, 1);
112 for (int i = 0; i < fTrackCollectionsNo; i++) {
113 fHistos[i] = new DividedHisto1D(Form("V_{%i}[%i]", (int) fN, i), axX, 'D');
114 fHistos[i]->GetNum()->GetYaxis()->SetTitle(axY.GetTitle());
115 fHistos[i]->GetDen()->GetYaxis()->SetTitle(axY.GetTitle());
116 fHistos[i]->SetAxisName(Form("v_{%i RP}", (int) fN));
117 }
118 } break;
119 case 2: {
120 HistogramAxisConf axY(fVarY->GetAxisName(), fBinsY, fMinY, fMaxY);
121 HistogramAxisConf axZ(Form("dN/%s%s", fVarX->GetAxisUnit().Data(), fVarY->GetAxisUnit().Data()), 0, 0, 1);
122 for (int i = 0; i < fTrackCollectionsNo; i++) {
123 fHistos[i] = new DividedHisto2D(Form("V_{%i}[%i]", (int) fN, i), axX, axY, 'D');
124 fHistos[i]->GetNum()->GetZaxis()->SetTitle(axZ.GetTitle());
125 fHistos[i]->GetDen()->GetZaxis()->SetTitle(axZ.GetTitle());
126 fHistos[i]->SetAxisName(Form("v_{%i RP}", (int) fN));
127 };
128 break;
129 }
130 default: {
131 } break;
132 }
133 return Task::EInitFlag::kSUCCESS;
134 } else {
135 return Task::EInitFlag::kFATAL;
136 }
137 }
138
140 Package* pack = TrackAna::Report();
141 AddToAnaMetadata(pack, new ParameterString("Variable_class on X ", fVarX->ClassName()));
142 if (fNDim == 2) AddToAnaMetadata(pack, new ParameterString("Variable_class on Y", fVarY->ClassName()));
143 for (int i = 0; i < fTrackCollectionsNo; i++) {
144 pack->AddObject(fHistos[i]->Clone());
145 }
146 return pack;
147 }
148
150 for (int i = 0; i < this->fCutContainer->GetTrackCollectionsNo(); i++) {
151 this->fCutContainer->LinkCollections(ECutUpdate::kEvent, 0, ECutUpdate::kTrack, i);
152 }
153 }
154
155 Double_t SimpleVnAnalysis::GetPhi() { return fCurrentEvent->GetPhi(); }
156
160 for (int i = 1; i < fCutContainer->GetEventCollectionsNo(); i++)
161 fCutContainer->RemoveCollection(ECutUpdate::kEvent, i);
162 Cout::PrintInfo("Only 1 event cut container allowed for SimpleVnAnalysis", EInfo::kError);
163 }
164 }
165
167 fBinsX = ana.fBinsX;
168 fBinsY = ana.fBinsY;
169 fMinX = ana.fMinX;
170 fMinY = ana.fMinY;
171 fMaxX = ana.fMaxX;
172 fMaxY = ana.fMaxY;
173 fN = ana.fN;
174 fPhi = ana.fPhi;
175 fNDim = ana.fNDim;
176 if (ana.fHistos) {
177 fHistos = new DividedHisto1D*[fTrackCollectionsNo];
178 for (int i = 0; i < ana.fTrackCollectionsNo; i++) {
179 fHistos[i] = (DividedHisto1D*) ana.fHistos[i]->Clone();
180 }
181 }
182 if (ana.fVarX) fVarX = ana.fVarX->MakeCopy();
183 if (ana.fVarY) fVarY = ana.fVarY->MakeCopy();
184 }
185
186 SimpleVnAnalysis::~SimpleVnAnalysis() {
187 for (int i = 0; i < fTrackCollectionsNo; i++) {
188 delete fHistos[i];
189 }
190 delete[] fHistos;
191 }
192
193 void SimpleVnAnalysis::SetFlowVariableX(const FlowVariable& var) { fVarX = var.MakeCopy(); }
194
195 void SimpleVnAnalysis::SetFlowVariableY(const FlowVariable& var) { fVarY = var.MakeCopy(); }
196} // namespace Hal
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
void LinkCollections(ECutUpdate opt_low, Int_t in_low, ECutUpdate opt_high, Int_t in_high)
void RemoveCollection(ECutUpdate update, Int_t collection)
Int_t GetEventCollectionsNo() const
Int_t GetTrackCollectionsNo() const
void SetAxisName(TString name)
CutContainer * fCutContainer
Definition EventAna.h:78
Int_t GetTaskID() const
Definition EventAna.h:155
Event * fCurrentEvent
Definition EventAna.h:86
void AddToAnaMetadata(Package *main_pack, TObject *obj) const
Definition EventAna.cxx:239
Double_t GetPhi() const
Definition Event.h:251
virtual TString GetAxisUnit()
virtual Double_t GetVariable(Track *p)
virtual TString GetAxisName()
void AddObject(TObject *object)
Definition Package.cxx:209
virtual void CheckCutContainerCollections()
void SetAxis(Int_t nbins, Double_t min, Double_t max, Char_t axis='x')
virtual Task::EInitFlag Init()
Track * fCurrentTrack
Definition TrackAna.h:42
virtual Task::EInitFlag Init()
Definition TrackAna.cxx:48
Int_t fCurrentTrackCollectionID
Definition TrackAna.h:34
virtual Package * Report() const
Definition TrackAna.cxx:94
Int_t fTrackCollectionsNo
Definition TrackAna.h:30
virtual void CheckCutContainerCollections()
Definition TrackAna.cxx:78
Double_t GetPx() const
Definition Track.h:99
Double_t GetPy() const
Definition Track.h:104