10#include "FemtoConst.h"
14#include "FemtoDPhiDEta.h"
15#include "FemtoPairKinematics.h"
17#include "FemtoWeightGenerator.h"
18#include "FemtoWeightGeneratorLednicky.h"
23#include <TDatabasePDG.h>
24#include <TLorentzVector.h>
30 Bool_t IsPairIdentical(EPairType pt) {
32 case EPairType::kPionPlusPionPlus: {
35 case EPairType::kPionZeroPionZero: {
38 case EPairType::kKaonZeroKaonZero: {
41 case EPairType::kPionPlusKaonPlus: {
44 case EPairType::kProtonProton: {
47 case EPairType::kNeutronNeutron: {
50 case EPairType::kLambdaLambda: {
53 case EPairType::kSigmaPlusSigmaPlus: {
56 case EPairType::kSigmaZeroSigmaZero: {
59 default:
return kFALSE;
break;
63 std::pair<Int_t, Int_t> PairTypeToPid(EPairType pt) {
64 std::pair<Int_t, Int_t> pair;
66 case EPairType::kUnknown: {
68 case EPairType::kPionPlusPionPlus: {
69 pair.first = Const::PionPlusPID();
70 pair.second = Const::PionPlusPID();
72 case EPairType::kPionPlusPionMinus: {
73 pair.first = Const::PionPlusPID();
74 pair.second = -Const::PionPlusPID();
76 case EPairType::kKaonPlusKaonPlus: {
77 pair.first = Const::KaonPlusPID();
78 pair.second = Const::KaonPlusPID();
80 case EPairType::kKaonPlusKaonMinus: {
81 pair.first = Const::KaonPlusPID();
82 pair.second = -Const::KaonPlusPID();
85 case EPairType::kProtonProton: {
86 pair.first = Const::ProtonPID();
87 pair.second = Const::ProtonPID();
89 case EPairType::kProtonAntiproton: {
90 pair.first = Const::ProtonPID();
91 pair.second = -Const::ProtonPID();
93 case EPairType::kPionPlusKaonPlus: {
94 pair.first = Const::PionPlusPID();
95 pair.second = Const::KaonPlusPID();
97 case EPairType::kPionPlusKaonMinus: {
98 pair.first = Const::PionPlusPID();
99 pair.second = -Const::KaonPlusPID();
102 case EPairType::kPionPlusProton: {
103 pair.first = Const::PionPlusPID();
104 pair.second = Const::ProtonPID();
106 case EPairType::kPionPlusAntiproton: {
107 pair.first = Const::PionPlusPID();
108 pair.second = -Const::ProtonPID();
110 case EPairType::kKaonPlusProton: {
111 pair.first = Const::KaonPlusPID();
112 pair.second = Const::ProtonPID();
114 case EPairType::kKaonPlusAntiproton: {
115 pair.first = Const::KaonPlusPID();
116 pair.second = -Const::ProtonPID();
119 case EPairType::kProtonLambda: {
120 pair.first = Const::ProtonPID();
121 pair.second = Const::LambdaPID();
123 case EPairType::kLambdaLambda: {
124 pair.first = Const::LambdaPID();
125 pair.second = Const::LambdaPID();
127 case EPairType::kKaonZeroKaonZero: {
128 pair.first = Const::KaonZeroShortPID();
129 pair.second = Const::KaonZeroShortPID();
131 case EPairType::kKaonZeroKaonZeroBar: {
132 pair.first = Const::KaonZeroShortPID();
133 pair.second = -Const::KaonZeroShortPID();
137 case EPairType::kNeutronNeutron: {
138 pair.first = Const::NeutronPID();
139 pair.second = Const::NeutronPID();
141 case EPairType::kNeutronProton: {
142 pair.first = Const::NeutronPID();
143 pair.second = Const::ProtonPID();
145 case EPairType::kPionZeroPionZero: {
146 pair.first = Const::PionZeroPID();
147 pair.second = Const::PionZeroPID();
149 case EPairType::kNeutronLambda: {
150 pair.first = Const::NeutronPID();
151 pair.second = Const::LambdaPID();
154 case EPairType::kProtonSigmaPlus: {
155 pair.first = Const::ProtonPID();
156 pair.second = Const::SigmaPlusPID();
158 case EPairType::kProtonAntiSigmaPlus: {
159 pair.first = Const::NeutronPID();
160 pair.second = -Const::SigmaPlusPID();
162 case EPairType::kProtonAntiLambda: {
163 pair.first = Const::ProtonPID();
164 pair.second = -Const::LambdaPID();
166 case EPairType::kSigmaPlusSigmaPlus: {
167 pair.first = Const::SigmaPlusPID();
168 pair.second = Const::SigmaPlusPID();
170 case EPairType::kSigmaPlusAntiSigmaPlus: {
171 pair.first = Const::SigmaPlusPID();
172 pair.second = -Const::SigmaPlusPID();
174 case EPairType::kProtonXiZero: {
175 pair.first = Const::ProtonPID();
176 pair.second = Const::XiZeroPID();
178 case EPairType::kNeutronXiMinus: {
179 pair.first = Const::NeutronPID();
180 pair.second = Const::XiMinusPID();
182 case EPairType::kProtonXIMInus: {
183 pair.first = Const::ProtonPID();
184 pair.second = Const::XiMinusPID();
187 case EPairType::kNeutronXiZero: {
188 pair.first = Const::NeutronPID();
189 pair.second = Const::XiZeroPID();
191 case EPairType::kProtonSigmaZero: {
192 pair.first = Const::ProtonPID();
193 pair.second = Const::SigmaZeroPID();
195 case EPairType::kSigmaZeroSigmaZero: {
196 pair.first = Const::SigmaZeroPID();
197 pair.second = Const::SigmaZeroPID();
199 case EPairType::kLambdaSigmaZero: {
200 pair.first = Const::LambdaPID();
201 pair.second = Const::SigmaZeroPID();
203 case EPairType::kLambdaAntiLambda: {
204 pair.first = Const::LambdaPID();
205 pair.second = -Const::LambdaPID();
211 EPairType PidToPairType(Int_t pid1, Int_t pid2) {
219 case 211:
return EPairType::kPionPlusPionPlus;
break;
220 case -211:
return EPairType::kPionPlusPionMinus;
break;
221 case 321:
return EPairType::kPionPlusKaonPlus;
break;
222 case -321:
return EPairType::kPionPlusKaonMinus;
break;
223 case 2212:
return EPairType::kPionPlusProton;
break;
224 case -2212:
return EPairType::kPionPlusAntiproton;
break;
229 case 321:
return EPairType::kKaonPlusKaonPlus;
break;
230 case -321:
return EPairType::kKaonPlusKaonMinus;
break;
231 case 2212:
return EPairType::kKaonPlusProton;
break;
232 case -2212:
return EPairType::kKaonPlusAntiproton;
break;
238 case 2212:
return EPairType::kProtonProton;
break;
239 case -2212:
return EPairType::kProtonAntiproton;
break;
240 case 3122:
return EPairType::kProtonLambda;
break;
241 case 2112:
return EPairType::kNeutronProton;
break;
242 case 3222:
return EPairType::kProtonSigmaPlus;
break;
243 case -3222:
return EPairType::kProtonAntiSigmaPlus;
break;
244 case -3122:
return EPairType::kProtonAntiLambda;
break;
245 case 3322:
return EPairType::kProtonXiZero;
break;
246 case 3312:
return EPairType::kProtonXIMInus;
break;
247 case 3212:
return EPairType::kProtonSigmaZero;
break;
252 case 2112:
return EPairType::kNeutronNeutron;
break;
253 case 3122:
return EPairType::kNeutronLambda;
break;
254 case 2212:
return EPairType::kNeutronProton;
break;
255 case 3312:
return EPairType::kNeutronXiMinus;
break;
256 case 3322:
return EPairType::kNeutronXiZero;
break;
261 case 3122:
return EPairType::kLambdaLambda;
break;
262 case -3122:
return EPairType::kLambdaAntiLambda;
break;
263 case 3212:
return EPairType::kLambdaSigmaZero;
break;
268 case 310:
return EPairType::kKaonZeroKaonZero;
break;
269 case -310:
return EPairType::kKaonZeroKaonZeroBar;
break;
274 if (pid2 == 111)
return EPairType::kPionZeroPionZero;
280 return EPairType::kSigmaPlusAntiSigmaPlus;
283 return EPairType::kSigmaPlusSigmaPlus;
288 if (pid2 == 3212)
return EPairType::kSigmaZeroSigmaZero;
291 return EPairType::kUnknown;
294 TString PairTypeToString(EPairType type) {
296 case EPairType::kUnknown: {
298 case EPairType::kPionPlusPionPlus: {
301 case EPairType::kPionPlusPionMinus: {
304 case EPairType::kKaonPlusKaonPlus: {
307 case EPairType::kKaonPlusKaonMinus: {
311 case EPairType::kProtonProton: {
314 case EPairType::kProtonAntiproton: {
317 case EPairType::kPionPlusKaonPlus: {
320 case EPairType::kPionPlusKaonMinus: {
324 case EPairType::kPionPlusProton: {
327 case EPairType::kPionPlusAntiproton: {
330 case EPairType::kKaonPlusProton: {
333 case EPairType::kKaonPlusAntiproton: {
337 case EPairType::kProtonLambda: {
340 case EPairType::kLambdaLambda: {
343 case EPairType::kKaonZeroKaonZero: {
346 case EPairType::kKaonZeroKaonZeroBar: {
349 case EPairType::kNeutronNeutron: {
352 case EPairType::kNeutronProton: {
355 case EPairType::kPionZeroPionZero: {
358 case EPairType::kNeutronLambda: {
361 case EPairType::kProtonSigmaPlus: {
364 case EPairType::kProtonAntiSigmaPlus: {
367 case EPairType::kProtonAntiLambda: {
370 case EPairType::kSigmaPlusSigmaPlus: {
373 case EPairType::kSigmaPlusAntiSigmaPlus: {
374 return "SIg+AntiSig+";
376 case EPairType::kProtonXiZero: {
379 case EPairType::kNeutronXiMinus: {
382 case EPairType::kProtonXIMInus: {
386 case EPairType::kNeutronXiZero: {
389 case EPairType::kProtonSigmaZero: {
392 case EPairType::kSigmaZeroSigmaZero: {
395 case EPairType::kLambdaSigmaZero: {
398 case EPairType::kLambdaAntiLambda: {
405 FemtoPair* MakePair(EKinematics frame, Bool_t use_fake) {
407 case EKinematics::kPRF:
return new FemtoPairPRF(use_fake);
break;
408 case EKinematics::kLCMS:
return new FemtoPairLCMS(use_fake);
break;
409 case EKinematics::kSH_LCMS:
return new FemtoPairLCMS_SH(use_fake);
break;
410 case EKinematics::kSH_PRF:
return new FemtoPairPRF_SH(use_fake);
break;
411 case EKinematics::kPHIETA:
return new FemtoPairDPhiDEta(use_fake);
break;
412 case EKinematics::kPRFL:
return new FemtoPairPRFL(use_fake);
break;
413 default:
return NULL;
break;
417 TString KinematicsToLabel(EKinematics kin) {
419 case EKinematics::kPRF:
return "prf";
break;
420 case EKinematics::kLCMS:
return "lcms";
break;
421 case EKinematics::kSH_LCMS:
return "sh_lcms";
break;
422 case EKinematics::kSH_PRF:
return "sh_prf";
break;
423 case EKinematics::kPHIETA:
return "dphideta";
break;
424 case EKinematics::kPRFL:
return "prfl";
break;
425 default:
return "";
break;
429 EKinematics LabelToKinematics(TString label) {
430 if (label.EqualTo(
"prf")) {
431 return EKinematics::kPRF;
432 }
else if (label.EqualTo(
"lcms")) {
433 return EKinematics::kLCMS;
434 }
else if (label.EqualTo(
"sh_prf")) {
435 return EKinematics::kSH_PRF;
436 }
else if (label.EqualTo(
"sh_lcms")) {
437 return EKinematics::kSH_LCMS;
438 }
else if (label.EqualTo(
"dphideta")) {
439 return EKinematics::kPHIETA;
441 return EKinematics::kLCMS;
444 DividedHisto1D* GetHistoFromXML(XMLNode* nod) {
445 if (nod ==
nullptr)
return nullptr;
446 XMLNode* frame = nod->GetChild(
"Frame");
447 XMLNode* name = nod->GetChild(
"Name");
448 XMLNode* type = nod->GetChild(
"Type");
450 Int_t bins[3] = {100, 100, 100};
451 Double_t min[3] = {0, 0, 0}, max[3] = {1, 1, 1};
452 TString axes[3] = {
"Xaxis",
"Xaxis",
"Zaxis"};
453 for (
int i = 0; i < 3; i++) {
454 XMLNode* xaxis = nod->GetChild(axes[i]);
455 if (xaxis !=
nullptr) {
456 XMLAttrib* binsXml = xaxis->GetAttrib(
"bins");
457 XMLAttrib* minXml = xaxis->GetAttrib(
"min");
458 XMLAttrib* maxXml = xaxis->GetAttrib(
"max");
459 if (binsXml) bins[i] = binsXml->GetValue().Atoi();
460 if (minXml) min[i] = minXml->GetValue().Atof();
461 if (maxXml) max[i] = maxXml->GetValue().Atof();
465 EKinematics Frame = EKinematics::kLCMS;
466 if (frame) Frame = CodeLabelToKinematics(frame->GetValue());
468 TString cfName =
"cf";
469 if (name !=
nullptr) cfName = name->GetValue();
470 if (type ==
nullptr)
return nullptr;
471 TString classType = type->GetValue();
472 if (classType.EqualTo(
"Femto1DCF")) {
473 return new Femto1DCF(cfName, bins[0], min[0], max[0], Frame);
474 }
else if (classType.EqualTo(
"Femto3DCF")) {
475 return new Femto3DCF(cfName, bins[0], min[0], max[0], bins[1], min[1], max[1], bins[2], min[2], max[2], Frame);
476 }
else if (classType.EqualTo(
"FemtoSHCF")) {
477 XMLNode* lXml = nod->GetChild(
"L");
479 if (lXml) L = lXml->GetValue().Atoi();
480 return new FemtoSHCF(cfName, L, bins[0], min[0], max[0], Frame);
481 }
else if (classType.EqualTo(
"FemtoDPhiDEta")) {
482 return new FemtoDPhiDEta(cfName, bins[0], bins[1], min[1], max[1]);
484 std::cout <<
"Cannot create correlation function from this node" << std::endl;
488 EKinematics CodeLabelToKinematics(TString label) {
489 if (label.Contains(
"Hal::")) { label.ReplaceAll(
"Hal::",
""); }
490 if (label.Contains(
"Femto::")) { label.ReplaceAll(
"Femto::",
""); }
491 if (label.Contains(
"EKinematics::")) { label.ReplaceAll(
"EKinematics::",
""); }
492 if (label.EqualTo(
"kPRF")) {
493 return EKinematics::kPRF;
494 }
else if (label.EqualTo(
"kLCMS")) {
495 return EKinematics::kLCMS;
496 }
else if (label.EqualTo(
"kSH_PRF")) {
497 return EKinematics::kSH_PRF;
498 }
else if (label.EqualTo(
"kSH_LCMS")) {
499 return EKinematics::kSH_LCMS;
500 }
else if (label.EqualTo(
"kPHIETA")) {
501 return EKinematics::kPHIETA;
503 return EKinematics::kLCMS;
506 TString KinematicsToAxisLabel(EKinematics kin, Int_t ax, Int_t ndim) {
508 case EKinematics::kPRF: {
512 case 0:
return "k* [GeV/c]";
break;
513 case 1:
return "dN_{pairs}/dk*";
break;
514 case 3:
return "CF(k*)";
break;
519 case 0:
return "k*_{out} [GeV/c]";
break;
520 case 1:
return "k*_{side} [GeV/c]";
break;
521 case 2:
return "k*_{long} [GeV/c]";
break;
522 case 3:
return "CF(k*)";
break;
527 case EKinematics::kLCMS: {
531 case 0:
return "q_{inv} [GeV/c]";
break;
532 case 1:
return "dN_{pairs}/dq_{inv}";
break;
533 case 3:
return "CF(q_{inv})";
break;
538 case 0:
return "q_{out} [GeV/c]";
break;
539 case 1:
return "q_{side} [GeV/c]";
break;
540 case 2:
return "q_{long} [GeV/c]";
break;
541 case 3:
return "CF(q)";
break;
546 case EKinematics::kSH_PRF: {
548 case 0:
return "k* [GeV/c]";
break;
549 case 1:
return "#phi*";
break;
550 case 2:
return "#theta*";
break;
551 case 3:
return "CF(k*)";
break;
554 case EKinematics::kSH_LCMS: {
556 case 0:
return "q_{inv} [GeV/c]";
break;
557 case 1:
return "#phi_{inv}";
break;
558 case 2:
return "#theta_{inv}";
break;
559 case 3:
return "CF(q_{inv})";
break;
562 case EKinematics::kPHIETA: {
564 case 0:
return "#Delta#phi";
break;
565 case 1:
return "#Delta#eta";
break;
566 case 2:
return "dN_{pairs}/dN_{#Delta#phi#Delta#eta}";
break;
567 case 3:
return "C(#Delta#phi,#Delta#eta)";
break;
571 case EKinematics::kPRFL: {
575 case 0:
return "k* [GeV/c]";
576 case 1:
return "dN_{pairs}/dk*";
577 case 3:
return "CF(k*)";
582 case 0:
return "k*_{out} [GeV/c]";
583 case 1:
return "k*_{side} [GeV/c]";
584 case 2:
return "k*_{long} [GeV/c]";
585 case 3:
return "CF(k*)";
594 void FillRandomPair(FemtoPair& p, Int_t pid1, Int_t pid2, Double_t sigmaq, Double_t sigmar) {
595 auto pdg = TDatabasePDG::Instance();
596 Double_t m1 = pdg->GetParticle(pid1)->Mass();
597 Double_t m2 = pdg->GetParticle(pid2)->Mass();
598 TLorentzVector p1, p2;
599 auto rgaus = [](Double_t s) {
return gRandom->Gaus(0, s); };
600 p1.SetXYZM(rgaus(sigmaq), rgaus(sigmaq), rgaus(sigmaq), m1);
601 p2.SetXYZM(rgaus(sigmaq), rgaus(sigmaq), rgaus(sigmaq), m2);
602 p.SetTrueMomenta(p1, p2);
603 p.SetMomenta(p1, p2);
604 TLorentzVector x1(rgaus(sigmar), rgaus(sigmar), rgaus(sigmar), 0);
605 TLorentzVector x2(rgaus(sigmar), rgaus(sigmar), rgaus(sigmar), 0);
606 p.SetFreezouts(x1, x2);
609 void FillRandomKinematics(FemtoPair& p,
const TVector3& sum,
const TVector3& diff, EKinematics kin) {
610 Double_t m1 = p.GetM1();
611 Double_t m2 = p.GetM2();
612 Double_t ms = m1 + m2;
613 TLorentzVector summ(sum.X(), sum.Y(), sum.Z(), TMath::Sqrt(ms * ms + sum.Mag2()));
615 Double_t vz = summ.Z() / summ.E();
616 summ.Boost(0, 0, -vz);
617 Double_t phi = summ.Phi();
619 case EKinematics::kLCMS: {
620 TLorentzVector p1(diff.X() * 0.5, diff.Y() * 0.5, diff.Z() * 0.5, TMath::Sqrt(m1 * m1 + diff.Mag2() * 0.25));
621 TLorentzVector p2(-diff.X() * 0.5, -diff.Y() * 0.5, -diff.Z() * 0.5, TMath::Sqrt(m2 * m2 + diff.Mag2() * 0.25));
626 p.SetTrueMomenta(p1, p2);
627 p.SetMomenta(p1, p2);
629 case EKinematics::kPRF: {
630 TLorentzVector p1(diff.X(), diff.Y(), diff.Z(), TMath::Sqrt(m1 * m1 + diff.Mag2()));
631 TLorentzVector p2(-diff.X(), -diff.Y(), -diff.Z(), TMath::Sqrt(m2 * m2 + diff.Mag2()));
632 Double_t ptboost = summ.BoostVector().Pt();
633 p1.Boost(ptboost, 0, 0);
634 p2.Boost(ptboost, 0, 0);
639 p.SetTrueMomenta(p1, p2);
640 p.SetMomenta(p1, p2);
643 std::cout << __FILE__ <<
" " << __LINE__ <<
" unsupported frame" << std::endl;
654 ECFType GetCFType(TObject* obj) {
655 if (!obj)
return ECFType::kUnkown;
656 if (
dynamic_cast<Hal::FemtoSHCF*
>(obj)) {
return ECFType::kSpherical; }
657 if (
dynamic_cast<Hal::Femto1DCF*
>(obj)) {
return ECFType::kOneDim; }
658 if (
dynamic_cast<Hal::Femto3DCF*
>(obj)) {
return ECFType::kThreeDim; }
660 return ECFType::kUnkown;
663 FemtoWeightGenerator* GetWeightGeneratorFromXLM(XMLNode* nod) {
664 XMLNode* weightType = nod->GetChild(
"Type");
665 if (!weightType)
return nullptr;
666 TClass* weightClass = TClass::GetClass(weightType->GetValue(), 1, 0);
667 FemtoWeightGenerator* w =
static_cast<FemtoWeightGenerator*
>(weightClass->New());
668 if (!w)
return nullptr;
669 XMLNode* pairType = nod->GetChild(
"PairType");
670 TString val = pairType->GetValue();
671 std::vector<TString> str = Hal::Std::ExplodeString(val,
';');
672 if (str.size() == 2) {
673 Int_t pid1 = str[0].Atoi();
674 Int_t pid2 = str[1].Atoi();
675 w->SetPairType(Femto::PidToPairType(pid1, pid2));
677 FemtoWeightGeneratorLednicky* lednicky =
dynamic_cast<FemtoWeightGeneratorLednicky*
>(w);
679 lednicky->SetStrongOff();
680 lednicky->SetCoulOff();
681 lednicky->SetQuantumOff();
683 XMLNode* quantum = nod->GetChild(
"QuantumOn");
684 XMLNode* strong = nod->GetChild(
"StrongOn");
685 XMLNode* coul = nod->GetChild(
"CoulombOn");
687 if (quantum->GetValue() ==
"kTRUE") lednicky->SetQuantumOn();
690 if (strong->GetValue() ==
"kTRUE") lednicky->SetStrongOn();
693 if (coul->GetValue() ==
"kTRUE") lednicky->SetCoulOn();
704 fConsA = (c2 - d2) * (c2 - d2);
705 fConsB = -2.0 * (c2 + d2);
710 const Double_t kstar2 = kstar * kstar;
711 const Double_t E1 = TMath::Sqrt(kstar2 + fA2);
712 const Double_t E2 = TMath::Sqrt(kstar2 + fB2);
713 const Double_t E = E1 + E2;
714 const Double_t E_2 = E * E;
715 return TMath::Sqrt(fConsA + fConsB * E_2 + E_2 * E_2) / (2.0 * E);
void ReInit(Double_t a, Double_t b, Double_t c, Double_t d)
Double_t Calculate(Double_t kstar) const