Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
FemtoEventBinsAna.cxx
1/*
2 * FemtoEventBinsAna.cxx
3 *
4 * Created on: 4 gru 2020
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "FemtoEventBinsAna.h"
10
11#include "Cout.h"
12#include "CutCollection.h"
13#include "CutContainer.h"
14#include "DataFormatManager.h"
15#include "EventBinningCut.h"
16#include "EventVirtualCut.h"
17#include "FemtoPair.h"
18#include "MemoryMapManager.h"
19#include <TList.h>
20
21
22namespace Hal {
23 FemtoEventBinsAna::FemtoEventBinsAna() : FemtoBasicAna(), fEventBinsMax(0) {}
24
25 FemtoEventBinsAna::~FemtoEventBinsAna() {}
26
27 FemtoEventBinsAna::FemtoEventBinsAna(const FemtoEventBinsAna& other) :
28 FemtoBasicAna(other), fEventBinsMax(other.fEventBinsMax), fFakeEventBinID(other.fFakeEventBinID) {
29 if (other.fEventBinningCuts.size()) {
30 fEventBinningCuts.resize(other.fEventBinningCuts.size(), nullptr);
31 for (unsigned int i = 0; i < other.fEventBinningCuts.size(); i++) {
32 if (other.fEventBinningCuts[i]) { fEventBinningCuts[i] = other.fEventBinningCuts[i]->MakeCopy(); }
33 }
34 }
35 }
36
37 Task::EInitFlag FemtoEventBinsAna::Init() {
38 if (!CheckBinningCuts()) return Task::EInitFlag::kFATAL;
39 fEventBinsMax = 0;
40 for (unsigned int i = 0; i < fEventBinningCuts.size(); i++) {
41 fEventBinningCuts[i]->SetCollectionID(i);
42 fEventBinsMax = TMath::Max(fEventBinsMax, fEventBinningCuts[i]->GetBinsNo());
43 }
44 return FemtoBasicAna::Init();
45 }
46
47 void FemtoEventBinsAna::InitMemoryMap() {
48 fMemoryMap = new MemoryMapManager(fCutContainer);
49 fMemoryMap->SetMixSize(fMixSize);
50#ifdef HAL_DEBUG
51 Cout::PrintInfo("Initialization MemoryMap", EInfo::kDebugInfo);
52#endif
53 std::vector<TString> brName;
54 if (TESTBIT(fFormatOption, eBitFormat::kReader)) {
55 brName.push_back("HalEvent.");
56 } else if (TESTBIT(fFormatOption, eBitFormat::kDirectAcesss)) {
57 TString evName = DataFormatManager::Instance()->GetFormat(GetTaskID())->ClassName();
58 brName.push_back(Form("%s.", evName.Data()));
59 brName.push_back(evName);
60 }
61 fMemoryMap->Init(fEventBinsMax, GetTaskID(), TESTBIT(fFormatOption, eBitFormat::kCompression), brName);
62 }
63
64 Int_t FemtoEventBinsAna::GetEventBin() { return fEventBinningCuts[fCurrentEventCollectionID]->CheckBin(fCurrentEvent); }
65
66 Package* FemtoEventBinsAna::Report() const {
67 Package* pack = FemtoBasicAna::Report();
68 TList* list = new TList();
69 list->SetName("EventBinCuts");
70 for (auto& rep : fEventBinningCuts) {
71 list->AddLast(rep->Report());
72 }
73 AddToAnaMetadata(pack, list);
74
75 return pack;
76 }
77
78 void FemtoEventBinsAna::ProcessEvent() {
79 const Int_t eventBin = GetEventBin();
80 fFakeEventBinID = fCurrentEventCollectionID;
81 if (eventBin < 0) return;
82 fCurrentEventCollectionID = fEventBinsMax * fFakeEventBinID + eventBin;
83 // we are using DummyEventCol to point event collection but still use
84 // fCurrentEvent to numbering cuts
85 fMemoryMap->PrepareMaps(fCurrentEventCollectionID);
86 CutCollection* cont = fCutContainer->GetEventCollection(fFakeEventBinID);
87 for (fTrackIndex = 0; fTrackIndex < fMemoryMap->GetTemporaryTotalTracksNo(); fTrackIndex++) {
88 fCurrentTrack = fCurrentEvent->GetTrack(fTrackIndex);
89 for (int j = 0; j < cont->GetNextNo(); j++) {
90 fCurrentTrackCollectionID = cont->GetNextAddr(j);
91 if (fCutContainer->PassTrack(fCurrentTrack, fCurrentTrackCollectionID)) {
92 fMemoryMap->AddTrackToMapTrack(fCurrentEventCollectionID,
93 fCurrentTrackCollectionID,
94 fTrackIndex); // load track into memory map - may be usefull at
95 // finish event
96 ProcessTrack();
97 }
98 }
99 }
100 fMemoryMap->BufferEvent(fCurrentEventCollectionID);
101 fCurrentTrackCollectionID = 0;
102 if (IdenticalParticles()) {
103#ifdef HAL_DEBUG
104 Cout::PrintInfo(Form("Finish identical event with %i tracks",
105 fMemoryMap->GetTracksNo(fCurrentEventCollectionID, fCurrentTrackCollectionID)),
106 EInfo::kDebugInfo);
107#endif
108 FinishEventIdentical();
109 } else {
110#ifdef HAL_DEBUG
111 Cout::PrintInfo(Form("Finish non-identical event with %i %i tracks",
112 fMemoryMap->GetTracksNo(fCurrentEventCollectionID, 0),
113 fMemoryMap->GetTracksNo(fCurrentEventCollectionID, 1)),
114 EInfo::kDebugInfo);
115#endif
116 FinishEventNonIdentical();
117 }
118 fCurrentEventCollectionID = fFakeEventBinID;
119 }
120
121 FemtoEventBinsAna& FemtoEventBinsAna::operator=(const FemtoEventBinsAna& other) {
122 if (this != &other) {
123 FemtoBasicAna::operator=(other);
124 for (auto i : fEventBinningCuts) {
125 if (i) delete i;
126 }
127 fEventBinningCuts.resize(0);
128 if (other.fEventBinningCuts.size()) {
129 fEventBinningCuts.resize(other.fEventBinningCuts.size(), nullptr);
130 for (unsigned int i = 0; i < other.fEventBinningCuts.size(); i++) {
131 if (other.fEventBinningCuts[i]) { fEventBinningCuts[i] = other.fEventBinningCuts[i]->MakeCopy(); }
132 }
133 }
134 fEventBinsMax = other.fEventBinsMax;
135 fFakeEventBinID = other.fFakeEventBinID;
136 }
137 return *this;
138 }
139
140 Bool_t FemtoEventBinsAna::InitArray() {
141 fCFs = new ObjectMatrix_2();
142 DividedHisto1D* h = ((FemtoCorrFunc*) fCFTemp)->GetCF(0);
143 TString name = h->GetName();
144 name.ReplaceAll("[0]", "");
145 h->SetName(name);
146 fCFs->Init(fEventCollectionsNo, fTwoTrackCollectionsNo, fCFTemp);
147 for (int i = 0; i < fEventCollectionsNo; i++) {
148 for (int j = 0; j < fTwoTrackCollectionsNo; j++) {
149 FemtoCorrFunc* corrfunc = (FemtoCorrFunc*) fCFs->At(i, j);
150 corrfunc->SetEventCollID(i);
151 corrfunc->SetPairCollID(j);
152 corrfunc->Check();
153 TString comment = Form("PairBin[%i]\n", j);
154 std::vector<Double_t> mini, maxi;
155 std::vector<TString> names;
156 fEventBinningCuts[i]->GetBinParam(i, mini, maxi, names);
157 for (int k = 0; k < (int) names.size(); k++) {
158 comment = comment + " " + names[k] + Form("[%4.2f %4.2f]\n", mini[k], maxi[k]);
159 }
160 corrfunc->SetComment(comment);
161 }
162 }
163 return kTRUE;
164 }
165
166 void FemtoEventBinsAna::AddCut(const Hal::Cut& cut, Option_t* opt) { FemtoBasicAna::AddCut(cut, opt); }
167
168 void FemtoEventBinsAna::ProcessFemtoPair() {
169 fFemtoPair->Compute();
170 Double_t weight = fCalc->GenerateWeight(fFemtoPair);
171 fFemtoPair->SetWeight(weight);
172 ((FemtoCorrFunc*) fCFs->At(fFakeEventBinID, fCurrentPairCollectionID))->FillNum(fFemtoPair);
173 }
174
175 void FemtoEventBinsAna::ProcessFemtoPair_Perfect() {
176 fFemtoPair->Compute();
177 fFemtoPair->SetWeight(1.0);
178 ((FemtoCorrFunc*) fCFs->At(fFakeEventBinID, fCurrentPairCollectionID))->FillDenPerfect(fFemtoPair);
179 }
180
181 void FemtoEventBinsAna::ProcessFemtoPair_Rotated() {
182 fFemtoPair->Compute_Rotated();
183 Double_t weight = fCalc->GenerateWeight(fFemtoPair);
184 fFemtoPair->SetWeight(weight);
185 ((FemtoCorrFunc*) fCFs->At(fFakeEventBinID, fCurrentPairCollectionID))->FillDenRotated(fFemtoPair);
186 }
187
188 void FemtoEventBinsAna::ProcessFemtoPair_Hemisphere() {
189 fFemtoPair->Compute_Hemisphere();
190 Double_t weight = fCalc->GenerateWeight(fFemtoPair);
191 fFemtoPair->SetWeight(weight);
192 ((FemtoCorrFunc*) fCFs->At(fFakeEventBinID, fCurrentPairCollectionID))->FillDenHemisphere(fFemtoPair);
193 }
194
195 void FemtoEventBinsAna::ProcessFemtoPair_Mixed() {
196 fFemtoPair->Compute_Mixed();
197 fFemtoPair->SetWeight(1.0);
198 ((FemtoCorrFunc*) fCFs->At(fFakeEventBinID, fCurrentPairCollectionID))->FillDenMixed(fFemtoPair);
199 }
200
201 void FemtoEventBinsAna::ProcessFemtoPair_Charged() {
202 fFemtoPair->Compute_Charged();
203 Double_t weight = fCalc->GenerateWeight(fFemtoPair);
204 fFemtoPair->SetWeight(weight);
205 ((FemtoCorrFunc*) fCFs->At(fFakeEventBinID, fCurrentPairCollectionID))->FillDenCharged(fFemtoPair);
206 }
207
208 Bool_t FemtoEventBinsAna::CheckBinningCuts() {
210 Int_t eventCol = fCutContainer->GetEventCollectionsNo();
211 fEventBinningCuts.resize(eventCol, nullptr);
212 auto FindBinCut = [&](int i) {
213 auto subCont = fCutContainer->GetEventCollection(i);
214 int eventCuts = subCont->GetCutNo();
215 Bool_t found = false;
216 for (int evCut = 0; evCut < eventCuts; evCut++) {
217 EventCut* ev = (EventCut*) subCont->GetCut(evCut);
218 if (dynamic_cast<EventBinningCut*>(ev)) {
219 if (fEventBinningCuts[i] == nullptr) {
220 fEventBinningCuts[i] = (EventBinningCut*) ev;
221 found = true;
222 } else {
223 TString message =
224 Form("%s %i: double event binning cut at col %i, cut %s will be ingored", __FILE__, __LINE__, i, ev->ClassName());
225 Hal::Cout::PrintInfo(message, EInfo::kError);
226 }
227 }
228 }
229 return found;
230 };
231 for (int i = 0; i < eventCol; i++) {
232 FindBinCut(i);
233 if (fEventBinningCuts[i] == nullptr) {
234 TString message = Form("%s %i: missing bining cut at col=%i, automatic cut will be added", __FILE__, __LINE__, i);
235 Hal::Cout::PrintInfo(message, EInfo::kError);
237 EventBinningCut ev(v, {1});
238 ev.SetCollectionID(i);
239 AddCut(ev);
240 bool found = FindBinCut(i);
241 if (!found) return kFALSE;
242 }
243 }
247 return kTRUE;
248 }
249
250} // namespace Hal
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
Int_t GetNextNo() const
Int_t GetNextAddr(Int_t index) const
Definition Cut.h:40
void SetCollectionID(Int_t i)
Definition Cut.h:247
void SetComment(TString comment)
void SetEventCollID(Int_t no)
void SetPairCollID(Int_t no)
virtual Bool_t Check()=0
std::vector< EventBinningCut * > fEventBinningCuts