Skip to content

Commit 8fe2230

Browse files
ddobrigkalcaliva
authored andcommitted
Synthetic flow generator added (#1721)
* Synthetic flow generator added * Add tester for synthetic flow MC (cherry picked from commit c2b733f)
1 parent bf44138 commit 8fe2230

File tree

3 files changed

+124
-0
lines changed

3 files changed

+124
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[GeneratorExternal]
2+
fileName=${O2DPG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_syntheFlow.C
3+
funcName=generator_syntheFlow()
4+
5+
[GeneratorPythia8]
6+
config=${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8_hi.cfg
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
int External()
2+
{
3+
std::string path{"o2sim_Kine.root"};
4+
5+
TFile file(path.c_str(), "READ");
6+
if (file.IsZombie())
7+
{
8+
std::cerr << "Cannot open ROOT file " << path << "\n";
9+
return 1;
10+
}
11+
12+
auto tree = (TTree *)file.Get("o2sim");
13+
if (!tree)
14+
{
15+
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
16+
return 1;
17+
}
18+
std::vector<o2::MCTrack> *tracks{};
19+
tree->SetBranchAddress("MCTrack", &tracks);
20+
21+
auto nEvents = tree->GetEntries();
22+
if (nEvents < 1)
23+
{
24+
std::cerr << "No events actually generated: not OK!";
25+
return 1;
26+
}
27+
return 0;
28+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
#include "Pythia8/Pythia.h"
3+
#include "Pythia8/HeavyIons.h"
4+
#include "FairGenerator.h"
5+
#include "FairPrimaryGenerator.h"
6+
#include "Generators/GeneratorPythia8.h"
7+
#include "TRandom3.h"
8+
#include "TParticlePDG.h"
9+
#include "TDatabasePDG.h"
10+
11+
#include <map>
12+
#include <unordered_set>
13+
14+
class GeneratorPythia8SyntheFlow : public o2::eventgen::GeneratorPythia8
15+
{
16+
public:
17+
/// Constructor
18+
GeneratorPythia8SyntheFlow() {
19+
lutGen = new o2::eventgen::FlowMapper();
20+
21+
// -------- CONFIGURE SYNTHETIC FLOW ------------
22+
// specify a v2 vs pT here
23+
TFile *filehep = new TFile("/Users/daviddc/Downloads/HEPData-ins1116150-v1-Table_1.root", "READ");
24+
TH1D *hv = (TH1D*) filehep->Get("Table 1/Hist1D_y6");
25+
26+
TFile *fileEcc = new TFile("/Users/daviddc/Downloads/eccentricityvsb.root", "READ");
27+
TH1D *hEccentricities = (TH1D*) fileEcc->Get("hEccentricities");
28+
29+
cout<<"Generating LUT for flow test"<<endl;
30+
lutGen->CreateLUT(hv, hEccentricities);
31+
cout<<"Finished creating LUT!"<<endl;
32+
// -------- END CONFIGURE SYNTHETIC FLOW ------------
33+
}
34+
35+
/// Destructor
36+
~GeneratorPythia8SyntheFlow() = default;
37+
38+
//__________________________________________________________________
39+
Bool_t generateEvent() override {
40+
41+
// Generate PYTHIA event
42+
Bool_t lPythiaOK = kFALSE;
43+
while (!lPythiaOK){
44+
lPythiaOK = mPythia.next();
45+
}
46+
47+
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48+
// loop over the entire event record and rotate all particles
49+
// synthetic flow exercise
50+
// first: get event plane
51+
float eventPlaneAngle = mPythia.info.hiInfo->phi();
52+
float impactParameter = mPythia.info.hiInfo->b();
53+
54+
for ( Long_t j=0; j < mPythia.event.size(); j++ ) {
55+
float pyphi = mPythia.event[j].phi();
56+
float pypT = mPythia.event[j].pT();
57+
58+
// calculate delta with EP
59+
float deltaPhiEP = pyphi - eventPlaneAngle;
60+
float shift = 0.0;
61+
while(deltaPhiEP<0.0){
62+
deltaPhiEP += 2*TMath::Pi();
63+
shift += 2*TMath::Pi();
64+
}
65+
while(deltaPhiEP>2*TMath::Pi()){
66+
deltaPhiEP -= 2*TMath::Pi();
67+
shift -= 2*TMath::Pi();
68+
}
69+
float newDeltaPhiEP = lutGen->MapPhi(deltaPhiEP, impactParameter, pypT);
70+
float pyphiNew = newDeltaPhiEP - shift + eventPlaneAngle;
71+
72+
if(pyphiNew>TMath::Pi())
73+
pyphiNew -= 2.0*TMath::Pi();
74+
if(pyphiNew<-TMath::Pi())
75+
pyphiNew += 2.0*TMath::Pi();
76+
mPythia.event[j].rot(0.0, pyphiNew-pyphi);
77+
}
78+
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79+
80+
return true;
81+
}
82+
83+
private:
84+
o2::eventgen::FlowMapper *lutGen; // for mapping phi angles
85+
};
86+
87+
FairGenerator *generator_syntheFlow()
88+
{
89+
return new GeneratorPythia8SyntheFlow();
90+
}

0 commit comments

Comments
 (0)