Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
FemtoBasicAna.cxx
1/*
2 * FemtoBasicAna2.cxx
3 *
4 * Created on: 26-11-2013
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "FemtoBasicAna.h"
11
12#include "Cout.h"
13#include "CutCollection.h"
14#include "CutContainer.h"
15#include "DataFormatManager.h"
16#include "DividedHisto.h"
17#include "Event.h"
18#include "EventAna.h"
19#include "EventBinningCut.h"
20#include "EventVirtualCut.h"
21#include "FemtoConst.h"
22#include "FemtoPair.h"
23#include "MemoryMapManager.h"
24#include "ObjectMatrix.h"
25#include "Package.h"
26#include "Parameter.h"
27#include "Std.h"
28
29#include <TClonesArray.h>
30#include <TNamed.h>
31#include <TObjArray.h>
32#include <TString.h>
33
34
35namespace Hal {
37 TwoTrackAna(kTRUE),
38 fPdg1(0),
39 fPdg2(0),
40 fUseImgMomenta(kFALSE),
41 fIgnoreSign(kFALSE),
42 fFsiWeight(0.0),
43 fFemtoPair(nullptr),
44 fCalc(nullptr),
45 fFreezoutGenerator(nullptr),
46 fCFs(nullptr),
47 fCFTemp(nullptr) {
48 fMixSize = 2;
50 AddTags("femto hbt");
51 }
52
54 TwoTrackAna(ana),
55 fPdg1(ana.fPdg1),
56 fPdg2(ana.fPdg2),
57 fUseImgMomenta(ana.fUseImgMomenta),
58 fIgnoreSign(ana.fIgnoreSign),
59 fFsiWeight(ana.fFsiWeight),
60 fFemtoPair(nullptr),
61 fCalc(ana.fCalc),
62 fFreezoutGenerator(nullptr) {
63 if (ana.fCFs) { fCFs = (ObjectMatrix_2*) ana.fCFs->Clone(); }
64 if (ana.fCFTemp) { fCFTemp = (FemtoCorrFunc*) ana.fCFTemp->Clone(); }
65 if (ana.fFreezoutGenerator) { fFreezoutGenerator = ana.fFreezoutGenerator->MakeCopy(); }
66 if (ana.fFemtoPair) { fFemtoPair = (FemtoPair*) ana.fFemtoPair->Clone(); }
67 if (ana.fCalc) { fCalc = (FemtoWeightGenerator*) ana.fCalc->Clone(); }
68 }
69
72 Femto::EKinematics mode = Femto::EKinematics::kLCMS;
73 mode = fFemtoPair->GetFrame();
74 if (mode == Femto::EKinematics::kPRF) {
75 AddToAnaMetadata(pack, new ParameterString("FemtoKinematics", "PRF"));
76 } else if (mode == Femto::EKinematics::kLCMS) {
77 AddToAnaMetadata(pack, new ParameterString("FemtoKinematics", "LCMS"));
78 } else if (mode == Femto::EKinematics::kSH_LCMS) {
79 AddToAnaMetadata(pack, new ParameterString("FemtoKinematics", "LCMS+SH"));
80 } else if (mode == Femto::EKinematics::kSH_PRF) {
81 AddToAnaMetadata(pack, new ParameterString("FemtoKinematics", "PRF+SH"));
82 } else if (mode == Femto::EKinematics::kPRFL) {
83 AddToAnaMetadata(pack, new ParameterString("FemtoKinematics", "PRFL"));
84 } else if (mode == Femto::EKinematics::kPHIETA) {
85 AddToAnaMetadata(pack, new ParameterString("FemtoKinematics", "PHIETA"));
86 }
87
89 AddToAnaMetadata(pack, new ParameterString("FreezoutGenerator", "Enabled"));
91 } else {
92 AddToAnaMetadata(pack, new ParameterString("FreezoutGenerator", "Disabled"));
93 }
94 if (fCalc) AddToAnaMetadata(pack, fCalc->Report());
95 if (fPdg1 != 0) {
96 AddToAnaMetadata(pack, new ParameterInt("Assumed Pdg_{1}", fPdg1));
97 AddToAnaMetadata(pack, new ParameterInt("Assumed Pdg_{2}", fPdg2));
98 }
99 AddToAnaMetadata(pack, new ParameterBool("IgnoreSign", fIgnoreSign));
100 if (fCFs) {
101 for (int j = 0; j < fCFs->GetSize(); j++) {
102 ObjectMatrix_1* cfx_col = fCFs->Get(j);
103 for (int k = 0; k < cfx_col->GetSize(); k++) {
104 pack->AddObject(cfx_col->At(k));
105 }
106 }
107 }
108 return pack;
109 }
110
111 Task::EInitFlag FemtoBasicAna::Init() {
112 if (fPdg1 == 0 || fPdg2 == 0) {
113 Cout::PrintInfo("Assumed wrong PID = 0, pion PID will be assumed", EInfo::kLowWarning);
114 fPdg1 = fPdg2 = 211;
115 }
116 if (fPdg1 != fPdg2) { EnableNonIdentical(); }
117 Task::EInitFlag prev = TwoTrackAna::Init();
119 Cout::PrintInfo("Two track collectionsNo in signal and background are different - this might result in crash",
120 EInfo::kWarning);
121 }
122 const Event* ev = DataFormatManager::Instance()->GetFormat(GetTaskID(), EFormatDepth::kBuffered);
123 if (!ev->InheritsFrom("Hal::ComplexEvent") && fUseImgMomenta == kTRUE) {
124 Cout::PrintInfo("Can't use fake momenta with current format !", EInfo::kLowWarning);
125 fUseImgMomenta = kFALSE;
126 }
127 if (fCFTemp == nullptr) {
128 Cout::PrintInfo("No correlation function in analysis", EInfo::kError);
129 return Task::EInitFlag::kFATAL;
130 }
131 DividedHisto1D* dummy = fCFTemp->GetCF(0);
132 Femto::EKinematics kinem = Femto::EKinematics::kLCMS;
133 if (dummy->GetLabelsNo() > 0) {
134 TString label = dummy->GetLabel(0);
135 kinem = Femto::LabelToKinematics(label);
136 }
137 fFemtoPair = Femto::MakePair(kinem, fUseImgMomenta);
138 if (fFemtoPair == nullptr) {
139 Cout::PrintInfo("Something wrong is with FemtoPair it cannot be created", EInfo::kError);
140 return Task::EInitFlag::kFATAL;
141 }
142
144 fFemtoPair->SetPdg2(fPdg2);
145 fFemtoPair->Init(GetTaskID());
146 if (fIgnoreSign) {
147 if (dummy->InheritsFrom("Hal::FemtoSHCF")) {
148 Cout::PrintInfo("Cannot ignore sign with SH correlation function!", EInfo::kError);
149 } else
150 fFemtoPair->UseAbs(); // if spherical harmonics do not use abs
151 }
152 AddTags(fFemtoPair->GetTags());
153 if (fUseImgMomenta == kFALSE) { Cout::PrintInfo("Only true momenta will be used", EInfo::kDebugInfo); }
154 if (prev != Task::EInitFlag::kSUCCESS) {
155 Cout::PrintInfo("Fatal FemtoBasicAna::TwoTrackAna::Init", EInfo::kError);
156 return Task::EInitFlag::kFATAL;
157 }
158 // check weights
159 if (fCalc == nullptr) {
160 Cout::PrintInfo("Weight algorithm not configured, autoconfiguration", EInfo::kLowWarning);
162 }
163 if (fCalc->Init(GetTaskID(), fFemtoPair) == kFALSE) {
164 Cout::PrintInfo("Weight algorithm not initialized correctly", EInfo::kLowWarning);
165 }
166 // inilitalize array of histograms
167 if (InitArray() == kFALSE) {
168 Cout::PrintInfo(Form("Failed to init array in %s", ClassName()), EInfo::kError);
169 return Task::EInitFlag::kFATAL;
170 }
171 if (fCFTemp) delete fCFTemp;
172 fCFTemp = nullptr;
173 // check freezout generator
174 if (fFreezoutGenerator) {
176 AddTags("freezout");
177 }
178 // check fast cuts -------------------------------------
179 return prev;
180 }
181
183
184 void FemtoBasicAna::SetOption(Option_t* option) {
185 TString opt = option;
186 if (opt.EqualTo("ignore_sign")) {
187 fIgnoreSign = kTRUE;
188 } else if (opt.EqualTo("use_im_momenta")) {
189 fUseImgMomenta = kTRUE;
190 } else if (opt.EqualTo("background:no")) {
191 Cout::PrintInfo("This analysis must have background !", EInfo::kLowWarning);
192 return;
193 } else {
195 }
196 }
197
203
209
215
221
227
231
237
244
250
257
264
270
277
280 Int_t two_track_signal = fCutContainer->GetTwoTrackCollectionsNo();
281 Int_t two_track_background = fCutContainer->GetTwoTrackCollectionsBackgroundNo();
283 if (two_track_signal != two_track_background) {
284#ifdef HAL_DEBUG
285 Cout::PrintInfo("Different number of two-track collections in signal and background, fixing", EInfo::kDebugInfo);
286#endif
287 }
288 if (two_track_signal > two_track_background) {
289 for (int i = two_track_background; i < two_track_signal; i++) {
290 fCutContainer->RemoveCollection(ECutUpdate::kTwoTrack, i);
291 }
292 } else if (two_track_background > two_track_signal) {
293 for (int i = two_track_signal; i < two_track_background; i++) {
294 fCutContainer->RemoveCollection(ECutUpdate::kTwoTrackBackground, i);
295 }
296 }
297 }
300 }
301
303 if (fCFTemp) delete fCFTemp;
304 fCFTemp = (FemtoCorrFunc*) h->Clone();
305 }
306
308 if (fCFTemp) delete fCFTemp;
309 fCFTemp = (FemtoCorrFunc*) h.Clone();
310 }
311
312 FemtoBasicAna::~FemtoBasicAna() {
313 delete fCalc;
314 if (fCFs) delete fCFs;
316 delete fFemtoPair;
317 if (fCFTemp) delete fCFTemp;
318 }
319
325 for (int j = 0; j < cont->GetNextNo(); j++) {
330 fTrackIndex); // load track into memory map - may be usefull at
331 // finish event
332 ProcessTrack();
333 }
334 }
335 }
338 if (IdenticalParticles()) {
339#ifdef HAL_DEBUG
340 Cout::PrintInfo(Form("Finish identical event with %i tracks ",
342 EInfo::kDebugInfo);
343#endif
345 } else {
346#ifdef HAL_DEBUG
347 Cout::PrintInfo(Form("Finish identical event with %i %itracks ",
350 EInfo::kDebugInfo);
351#endif
353 }
354 }
355
357 fCFs = new ObjectMatrix_2();
358 DividedHisto1D* h = ((FemtoCorrFunc*) fCFTemp)->GetCF(0);
359 if (h->GetNum() == nullptr) {
360 Hal::Cout::PrintInfo("Histogram not found in temp func, number of bin not specified?", Hal::EInfo::kError);
361 return kFALSE;
362 }
363 TString name = h->GetName();
364 name.ReplaceAll("[0]", "");
365 h->SetName(name);
367 for (int i = 0; i < fEventCollectionsNo; i++) {
368 for (int j = 0; j < fTwoTrackCollectionsNo; j++) {
369 FemtoCorrFunc* corrfunc = (FemtoCorrFunc*) fCFs->At(i, j);
370 corrfunc->SetEventCollID(i);
371 corrfunc->SetPairCollID(j);
372 if (!corrfunc->Check()) {
373 Cout::PrintInfo(Form("Problem with %s::Check", corrfunc->ClassName()), EInfo::kError);
374 return kFALSE;
375 }
376 }
377 }
378 return kTRUE;
379 }
380
382 if (this != &other) {
384 if (fFemtoPair) {
385 delete fFemtoPair;
386 fFemtoPair = nullptr;
387 }
388 if (fCalc) {
389 delete fCalc;
390 fCalc = nullptr;
391 }
392 if (fFreezoutGenerator) {
393 delete fFreezoutGenerator;
394 fFreezoutGenerator = nullptr;
395 }
396 if (fCFs) {
397 delete fCFs;
398 fCFs = nullptr;
399 }
400 if (fCFTemp) {
401 delete fCFTemp;
402 fCFTemp = nullptr;
403 }
404 if (other.fFemtoPair) fFemtoPair = (FemtoPair*) other.fFemtoPair->Clone();
405 if (other.fCalc) fCalc = (FemtoWeightGenerator*) other.fCalc->Clone();
407 if (other.fCFTemp) fCFTemp = (FemtoCorrFunc*) other.fCFTemp;
408 if (other.fCFs) fCFs = (ObjectMatrix_2*) other.Clone();
409
410 fPdg1 = other.fPdg1;
411 fPdg2 = other.fPdg2;
413 fIgnoreSign = other.fIgnoreSign;
414 fFsiWeight = other.fFsiWeight;
415 }
416 return *this;
417 }
418} // 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
Int_t GetTwoTrackCollectionsBackgroundNo() const
void RemoveCollection(ECutUpdate update, Int_t collection)
Int_t GetTwoTrackCollectionsNo() const
CutCollection * GetEventCollection(Int_t collection) const
Bool_t PassTrack(Track *track, const Int_t collection)
const Event * GetFormat(Int_t task_id, EFormatDepth format_depth=EFormatDepth::kAll) const
static DataFormatManager * Instance()
TString GetLabel(Int_t i) const
Int_t GetLabelsNo() const
CutContainer * fCutContainer
Definition EventAna.h:78
Int_t fEventCollectionsNo
Definition EventAna.h:61
Int_t GetTaskID() const
Definition EventAna.h:155
Int_t fMixSize
Definition EventAna.h:57
Event * fCurrentEvent
Definition EventAna.h:86
void AddToAnaMetadata(Package *main_pack, TObject *obj) const
Definition EventAna.cxx:239
MemoryMapManager * fMemoryMap
Definition EventAna.h:82
Int_t fCurrentEventCollectionID
Definition EventAna.h:65
virtual void AddTags(TString tag)
Definition EventAna.cxx:304
Track * GetTrack(Int_t i) const
Definition Event.h:208
virtual void ProcessPair_Rotated()
FemtoFreezoutGenerator * fFreezoutGenerator
virtual void PreprocessFemtoPair()
virtual void PreprocessFemtoPair_Charged()
virtual Bool_t InitArray()
virtual Package * Report() const
FemtoBasicAna & operator=(const FemtoBasicAna &other)
virtual void ProcessPair_ChargedId()
virtual void PreprocessFemtoPair_Hemisphere()
virtual void ProcessPair()
virtual void SetOption(Option_t *option)
virtual void CheckCutContainerCollections()
virtual void PreprocessFemtoPair_Mixed()
virtual void ProcessEvent()
virtual void ProcessFemtoPair_Mixed()
virtual Task::EInitFlag Init()
FemtoPair * fFemtoPair
virtual void ProcessPair_Perfect()
virtual void ProcessFemtoPair_Perfect()
ObjectMatrix_2 * fCFs
FemtoWeightGenerator * fCalc
virtual void ProcessFemtoPair_Charged()
virtual void ProcessPair_Mixed()
virtual void ProcessFemtoPair_Rotated()
FemtoCorrFunc * fCFTemp
virtual void PreprocessFemtoPair_Perfect()
virtual void FinishTask()
virtual void ProcessFemtoPair_Hemisphere()
virtual void SetCorrFctn(FemtoCorrFunc *h)
virtual void ProcessFemtoPair()
virtual void ProcessPair_Hemisphere()
virtual void PreprocessFemtoPair_Rotated()
void SetEventCollID(Int_t no)
void SetPairCollID(Int_t no)
virtual Bool_t Check()=0
DividedHisto1D * GetCF(Int_t i) const
void GenerateFreezoutCooordinates(FemtoPair *Pair)
virtual Package * Report() const
void SetPdg1(Int_t val)
Definition FemtoPair.h:387
virtual void Compute_Mixed()
Definition FemtoPair.h:497
virtual void Compute_Hemisphere()=0
void SetPdg2(Int_t val)
Definition FemtoPair.h:392
virtual void Compute_Charged()
Definition FemtoPair.h:493
virtual void Compute_Rotated()=0
virtual void Compute()=0
void Build(TwoTrack *tracks)
Definition FemtoPair.h:136
void SetWeight(Double_t weight)
Definition FemtoPair.h:397
virtual Bool_t Init(Int_t task_id, FemtoPair *pair)
virtual Double_t GenerateWeight(FemtoPair *pair)
virtual FemtoWeightGenerator * Clone(const char *="") const
Int_t GetTracksNo(Int_t event_collection, Int_t track_collection) const
void AddTrackToMapTrack(Int_t event_collection, Int_t track_collection, Int_t index)
Int_t GetTemporaryTotalTracksNo() const
void BufferEvent(Int_t collection)
void PrepareMaps(Int_t collection)
virtual void ProcessTrack()
Int_t GetSize() const
TObject * At(Int_t i) const
ObjectMatrix_1 * Get(Int_t i) const
Int_t GetSize() const
TObject * At(Int_t i, Int_t j) const
virtual void Init(Int_t sizeX, Int_t sizeY, const TObject *temp)
void AddObject(TObject *object)
Definition Package.cxx:209
Track * fCurrentTrack
Definition TrackAna.h:42
Int_t fCurrentTrackCollectionID
Definition TrackAna.h:34
Int_t fTrackIndex
Definition TrackAna.h:38
TwoTrack * fCurrentSignalPair
virtual void CheckCutContainerCollections()
void EnableNonIdentical()
TwoTrack * fCurrentBackgroundPair
Int_t fTwoTrackCollectionsNo
TwoTrackAna & operator=(const TwoTrackAna &other)
virtual Package * Report() const
Int_t fTwoTrackCollectionsNoBackground
virtual void SetOption(Option_t *option)
EAnaMode fBackgroundMode
Int_t fCurrentPairCollectionID
virtual void FinishEventIdentical()
@ kNoBackgroundNID
kNoBackgroundNID
Definition TwoTrackAna.h:48
@ kNoBackgroundID
kNoBackgroundID
Definition TwoTrackAna.h:47
@ kMixedPairs
kMixedPairs
Definition TwoTrackAna.h:38
virtual void FinishTask()
virtual void FinishEventNonIdentical()
Bool_t IdenticalParticles() const
virtual Task::EInitFlag Init()