10#include "ChargedFluctuationsAna.h"
13#include "CutContainer.h"
14#include "CutsAndMonitors.h"
15#include "DataFormat.h"
16#include "DataFormatManager.h"
18#include "EventVirtualCut.h"
19#include "MemoryMapManager.h"
24#include <TCollection.h>
30 ChargedFluctuationsAna::ChargedFluctuationsAna() :
35 fEventPar(DataFieldID::Event::EBasic::kEventZero),
39 fHistogram(nullptr) {}
41 void ChargedFluctuationsAna::ProcessEvent() {
42 Int_t step = fCurrentEventCollectionID * 8;
43 Double_t evProperty = fCurrentEvent->GetFieldVal(fEventPar);
44 for (
int j = 0; j < fTrackColsHalf * 2; j++) {
48 for (
int i = 0; i < fMemoryMap->GetTemporaryTotalTracksNo(); i++) {
49 fCurrentTrack = fCurrentEvent->GetTrack(i);
50 for (
int j = 0; j < fTrackColsHalf * 2; j++) {
51 if (fCutContainer->PassTrack(fCurrentTrack, j + step)) ++fCounts[j];
54 for (
int j = 0; j < fTrackColsHalf * 2; j += 2) {
55 fHistogram->Fill(fCurrentEventCollectionID, j, fCounts[2 * j], fCounts[2 * j + 1], evProperty);
59 Task::EInitFlag ChargedFluctuationsAna::Init() {
60 if (TrackAna::Init() == Task::EInitFlag::kFATAL)
return Task::EInitFlag::kFATAL;
61 fTrackColsHalf = fCutContainer->GetTrackCollectionsNo() / fCutContainer->GetEventCollectionsNo();
62 if (fTrackColsHalf % 2 == 1)
return Task::EInitFlag::kFATAL;
63 fCounts.resize(fTrackColsHalf);
64 fTrackColsHalf = fTrackColsHalf / 2;
66 fHistogram->Init(fEventCollectionsNo, fTrackColsHalf, fBins, fMin, fMax, fBins, fMin, fMax, fEventBins, fEventMin, fEventMax);
67 const Event* ev = DataFormatManager::Instance()->GetFormat(GetTaskID());
69 for (
int i = 0; i < fEventCollectionsNo; i++) {
70 TString eventName = Form(
"Event [%i]", i);
71 if (i < (
int) fEventLabels.size()) { eventName = fEventLabels[i]; }
72 for (
int j = 0; j < fTrackColsHalf; j++) {
73 Int_t posColl = 2 * j;
74 Int_t negColl = 2 * j + 1;
75 TString trackNameA = Form(
"Track [%i]", posColl);
76 TString trackNameB = Form(
"Track [%i]", negColl);
77 if (posColl < (
int) fTrackLabels.size()) { trackNameA = fTrackLabels[posColl]; }
78 if (negColl < (
int) fTrackLabels.size()) { trackNameB = fTrackLabels[negColl]; }
80 TH3D* h = fHistogram->At(i, j);
81 h->SetTitle(Form(
"%s %s vs %s", eventName.Data(), trackNameA.Data(), trackNameB.Data()));
82 h->SetName(h->GetTitle());
83 h->GetXaxis()->SetTitle(Form(
"N_{%s}", trackNameA.Data()));
84 h->GetYaxis()->SetTitle(Form(
"N_{%s}", trackNameB.Data()));
85 h->GetZaxis()->SetTitle(Form(
"%s", parName.Data()));
88 return Task::EInitFlag::kSUCCESS;
91 Package* ChargedFluctuationsAna::Report()
const {
92 Package* report = TrackAna::Report();
93 for (
int i = 0; i < fHistogram->GetSize(); i++) {
94 for (
int j = 0; j < fHistogram->Get(i)->GetSize(); j++) {
101 void ChargedFluctuationsAna::SetTrackHistogramAxis(Int_t bins, Double_t min, Double_t max) {
107 void ChargedFluctuationsAna::CheckCutContainerCollections() {
108 fEventCollectionsNo = fCutContainer->GetEventCollectionsNo();
109 fTrackCollectionsNo = fCutContainer->GetTrackCollectionsNo();
111 if (fTrackCollectionsNo % 2 == 0) {
112 for (
int i = 1; i < fEventCollectionsNo; i++) {
113 for (
int j = 0; j < fTrackCollectionsNo; j++) {
114 fCutContainer->ReplicateCollection(ECutUpdate::kTrack, j, fTrackCollectionsNo * i + j);
118 Cout::PrintInfo(
"wrong number of track collections, this might result in crash", EInfo::kError);
122 TString ChargedFluctuationsAna::HistoTitle(Int_t
id, TString pattern)
const {
123 return Form(
"%s [%i];dN/%s^{+};dN/d%s^{-}", pattern.Data(),
id, pattern.Data(), pattern.Data());
126 TString ChargedFluctuationsAna::HistoName(Int_t
id, TString pattern)
const {
127 return Form(
"Distribution of %s in [%i]", pattern.Data(),
id);
131 void ChargedFluctuationsAna::AddCut(
const Cut& cut, Option_t* opt) {
132 if (cut.InheritsFrom(
"Hal::TrackCut"))
return;
133 TrackAna::AddCut(cut, opt);
136 ChargedFluctuationsAna::~ChargedFluctuationsAna() {
137 if (fHistogram) {
delete fHistogram; }
141 void ChargedFluctuationsAna::SetEventLabels(
const std::initializer_list<TString>& init) {
142 std::initializer_list<TString>::iterator it;
143 for (it = init.begin(); it != init.end(); ++it) {
144 fEventLabels.push_back(*it);
148 void ChargedFluctuationsAna::SetTrackLabels(
const std::initializer_list<TString>& init) {
149 std::initializer_list<TString>::iterator it;
150 for (it = init.begin(); it != init.end(); ++it) {
151 fTrackLabels.push_back(*it);
155 void ChargedFluctuationsAna::SetEventHistogramAxis(Int_t bins, Double_t min, Double_t max) {
161 TString ChargedFluctuationsAna::CleanOpt(Option_t* opt, Int_t cut)
const {
162 TString newOpt = opt;
163 TPRegexp reg(
"{[x0-9]*}");
164 reg.Substitute(newOpt,
"",
"g");
165 while (newOpt.Contains(
"++"))
166 newOpt = newOpt.ReplaceAll(
"++",
"+");
167 if (newOpt.BeginsWith(
"+")) newOpt = newOpt(1, newOpt.Length() - 1);
168 if (newOpt.EndsWith(
"+")) newOpt = newOpt(0, newOpt.Length() - 1);
169 if (cut < 0)
return newOpt;
170 if (newOpt.Length() > 0)
171 newOpt = Form(
"%s+{%i}", newOpt.Data(), cut);
173 newOpt = Form(
"{%i}", cut);
177 void ChargedFluctuationsAna::AddCut(
const TrackCut& pos,
const TrackCut& neg, Option_t* opt) {
179 Cout::PrintInfo(
"cannot add two cuts with the same collection ID by ChargedFluctuationsAna::AddCut!", EInfo::kLowWarning);
182 Cout::PrintInfo(
"cannot add two cuts with delta collection ID!=1 by ChargedFluctuationsAna::AddCut!", EInfo::kLowWarning);
184 TString option = CleanOpt(opt, -1);
185 TrackAna::AddCut(pos, opt);
186 TrackAna::AddCut(neg, opt);
189 void ChargedFluctuationsAna::SetEventprop(Int_t evProp) { fEventPar = evProp; }
191 void ChargedFluctuationsAna::AddCutsAndMonitors(
const CutsAndMonitors& posTrack,
195 Cout::PrintInfo(
"cannot add two cuts with the same collection ID by NicaChargedFluctuationsAna::AddCut!",
199 Cout::PrintInfo(
"cannot add two cuts with delta collection ID!=1 by NicaChargedFluctuationsAna::AddCut!",
202 for (
int iCut = 0; iCut < posTrack.
GetNCuts(); iCut++) {
205 for (
int iCut = 0; iCut < negTrack.
GetNCuts(); iCut++) {
Int_t GetCollectionID() const
Int_t GetNCutMonitors() const
TString GetCutOption(Int_t i) const
const CutMonitor * GetMonitor(Int_t i) const
const Cut * GetCut(Int_t i) const
TString GetCutMonitorOption(Int_t i) const
virtual TString GetFieldName(Int_t fieldID) const
void AddObject(TObject *object)