9#include "FemtoEventBinsAna.h"
12#include "CutCollection.h"
13#include "CutContainer.h"
14#include "DataFormatManager.h"
15#include "EventBinningCut.h"
16#include "EventVirtualCut.h"
18#include "MemoryMapManager.h"
23 FemtoEventBinsAna::FemtoEventBinsAna() : FemtoBasicAna(), fEventBinsMax(0) {}
25 FemtoEventBinsAna::~FemtoEventBinsAna() {}
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(); }
37 Task::EInitFlag FemtoEventBinsAna::Init() {
38 if (!CheckBinningCuts())
return Task::EInitFlag::kFATAL;
40 for (
unsigned int i = 0; i < fEventBinningCuts.size(); i++) {
41 fEventBinningCuts[i]->SetCollectionID(i);
42 fEventBinsMax = TMath::Max(fEventBinsMax, fEventBinningCuts[i]->GetBinsNo());
44 return FemtoBasicAna::Init();
47 void FemtoEventBinsAna::InitMemoryMap() {
49 fMemoryMap->SetMixSize(fMixSize);
51 Cout::PrintInfo(
"Initialization MemoryMap", EInfo::kDebugInfo);
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);
61 fMemoryMap->Init(fEventBinsMax, GetTaskID(), TESTBIT(fFormatOption, eBitFormat::kCompression), brName);
64 Int_t FemtoEventBinsAna::GetEventBin() {
return fEventBinningCuts[fCurrentEventCollectionID]->CheckBin(fCurrentEvent); }
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());
73 AddToAnaMetadata(pack, list);
78 void FemtoEventBinsAna::ProcessEvent() {
79 const Int_t eventBin = GetEventBin();
80 fFakeEventBinID = fCurrentEventCollectionID;
81 if (eventBin < 0)
return;
82 fCurrentEventCollectionID = fEventBinsMax * fFakeEventBinID + eventBin;
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++) {
91 if (fCutContainer->PassTrack(fCurrentTrack, fCurrentTrackCollectionID)) {
92 fMemoryMap->AddTrackToMapTrack(fCurrentEventCollectionID,
93 fCurrentTrackCollectionID,
100 fMemoryMap->BufferEvent(fCurrentEventCollectionID);
101 fCurrentTrackCollectionID = 0;
102 if (IdenticalParticles()) {
104 Cout::PrintInfo(Form(
"Finish identical event with %i tracks",
105 fMemoryMap->GetTracksNo(fCurrentEventCollectionID, fCurrentTrackCollectionID)),
108 FinishEventIdentical();
111 Cout::PrintInfo(Form(
"Finish non-identical event with %i %i tracks",
112 fMemoryMap->GetTracksNo(fCurrentEventCollectionID, 0),
113 fMemoryMap->GetTracksNo(fCurrentEventCollectionID, 1)),
116 FinishEventNonIdentical();
118 fCurrentEventCollectionID = fFakeEventBinID;
122 if (
this != &other) {
123 FemtoBasicAna::operator=(other);
124 for (
auto i : fEventBinningCuts) {
127 fEventBinningCuts.resize(0);
134 fEventBinsMax = other.fEventBinsMax;
135 fFakeEventBinID = other.fFakeEventBinID;
140 Bool_t FemtoEventBinsAna::InitArray() {
143 TString name = h->GetName();
144 name.ReplaceAll(
"[0]",
"");
146 fCFs->Init(fEventCollectionsNo, fTwoTrackCollectionsNo, fCFTemp);
147 for (
int i = 0; i < fEventCollectionsNo; i++) {
148 for (
int j = 0; j < fTwoTrackCollectionsNo; j++) {
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]);
166 void FemtoEventBinsAna::AddCut(
const Hal::Cut& cut, Option_t* opt) { FemtoBasicAna::AddCut(cut, opt); }
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);
175 void FemtoEventBinsAna::ProcessFemtoPair_Perfect() {
176 fFemtoPair->Compute();
177 fFemtoPair->SetWeight(1.0);
178 ((
FemtoCorrFunc*) fCFs->At(fFakeEventBinID, fCurrentPairCollectionID))->FillDenPerfect(fFemtoPair);
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);
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);
195 void FemtoEventBinsAna::ProcessFemtoPair_Mixed() {
196 fFemtoPair->Compute_Mixed();
197 fFemtoPair->SetWeight(1.0);
198 ((
FemtoCorrFunc*) fCFs->At(fFakeEventBinID, fCurrentPairCollectionID))->FillDenMixed(fFemtoPair);
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);
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++) {
219 if (fEventBinningCuts[i] ==
nullptr) {
224 Form(
"%s %i: double event binning cut at col %i, cut %s will be ingored", __FILE__, __LINE__, i, ev->ClassName());
231 for (
int i = 0; i < eventCol; 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);
240 bool found = FindBinCut(i);
241 if (!found)
return kFALSE;
static void PrintInfo(TString text, Hal::EInfo status)
Int_t GetNextAddr(Int_t index) const
void SetCollectionID(Int_t i)
void SetComment(TString comment)
void SetEventCollID(Int_t no)
void SetPairCollID(Int_t no)
std::vector< EventBinningCut * > fEventBinningCuts