Skip to content

Commit d8e0226

Browse files
authored
Add new files for synthetic flow study in OO (#2285)
* Add macro for synthetic flow study in OO * Add script file for synthetic flow study in OO * Add .ini file for synthetic flow study in OO * Update GeneratorLF_SyntheFlowOO.ini * Update generator_pythia8_syntheFlowOO.C * Update GeneratorLF_SyntheFlowOO.ini * Create GeneratorLF_SyntheFlowOO.C * Update generator_pythia8_syntheFlowOO.C
1 parent fdcd28f commit d8e0226

File tree

4 files changed

+183
-0
lines changed

4 files changed

+183
-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_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_syntheFlowOO.C
3+
funcName=generator_syntheFlowOO()
4+
5+
[GeneratorPythia8]
6+
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/common/pythia8/generator/pythia8_OO_536.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: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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+
#include "CCDB/BasicCCDBManager.h"
11+
#include "TH1F.h"
12+
#include "TH1D.h"
13+
14+
#include <map>
15+
#include <unordered_set>
16+
17+
class GeneratorPythia8SyntheFlowOO : public o2::eventgen::GeneratorPythia8
18+
{
19+
public:
20+
/// Constructor
21+
GeneratorPythia8SyntheFlowOO() {
22+
lutGen = new o2::eventgen::FlowMapper();
23+
24+
// -------- CONFIGURE SYNTHETIC FLOW ------------
25+
// establish connection to ccdb
26+
o2::ccdb::CcdbApi ccdb_api;
27+
ccdb_api.init("https://alice-ccdb.cern.ch");
28+
29+
// config was placed at midpoint of run 544122, retrieve that
30+
std::map<string, string> metadataRCT, headers;
31+
headers = ccdb_api.retrieveHeaders("RCT/Info/RunInformation/544122", metadataRCT, -1);
32+
int64_t tsSOR = atol(headers["SOR"].c_str());
33+
int64_t tsEOR = atol(headers["EOR"].c_str());
34+
int64_t midRun = 0.5*tsSOR+0.5*tsEOR;
35+
36+
map<string, string> metadata; // can be empty
37+
auto list = ccdb_api.retrieveFromTFileAny<TList>("Users/d/ddobrigk/syntheflow", metadata, midRun);
38+
39+
TH1D *hv2vspT = (TH1D*) list->FindObject("hFlowVsPt_ins1116150_v1_Table_1");
40+
TH1D *heccvsb = (TH1D*) list->FindObject("hEccentricityVsB");
41+
42+
cout<<"Generating LUT for flow test"<<endl;
43+
lutGen->CreateLUT(hv2vspT, heccvsb);
44+
cout<<"Finished creating LUT!"<<endl;
45+
// -------- END CONFIGURE SYNTHETIC FLOW ------------
46+
}
47+
48+
/// Destructor
49+
~GeneratorPythia8SyntheFlowOO() = default;
50+
51+
//__________________________________________________________________
52+
Bool_t generateEvent() override {
53+
54+
// Generate PYTHIA event
55+
Bool_t lPythiaOK = kFALSE;
56+
while (!lPythiaOK){
57+
lPythiaOK = mPythia.next();
58+
}
59+
60+
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61+
// loop over the entire event record and rotate all particles
62+
// synthetic flow exercise
63+
// first: get event plane
64+
float eventPlaneAngle = mPythia.info.hiInfo->phi();
65+
float impactParameter = mPythia.info.hiInfo->b();
66+
67+
for ( Long_t j=0; j < mPythia.event.size(); j++ ) {
68+
float pyphi = mPythia.event[j].phi();
69+
float pypT = mPythia.event[j].pT();
70+
71+
// calculate delta with EP
72+
float deltaPhiEP = pyphi - eventPlaneAngle;
73+
float shift = 0.0;
74+
while(deltaPhiEP<0.0){
75+
deltaPhiEP += 2*TMath::Pi();
76+
shift += 2*TMath::Pi();
77+
}
78+
while(deltaPhiEP>2*TMath::Pi()){
79+
deltaPhiEP -= 2*TMath::Pi();
80+
shift -= 2*TMath::Pi();
81+
}
82+
float newDeltaPhiEP = lutGen->MapPhi(deltaPhiEP, impactParameter, pypT);
83+
float pyphiNew = newDeltaPhiEP - shift + eventPlaneAngle;
84+
85+
if(pyphiNew>TMath::Pi())
86+
pyphiNew -= 2.0*TMath::Pi();
87+
if(pyphiNew<-TMath::Pi())
88+
pyphiNew += 2.0*TMath::Pi();
89+
mPythia.event[j].rot(0.0, pyphiNew-pyphi);
90+
}
91+
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92+
93+
return true;
94+
}
95+
96+
private:
97+
o2::eventgen::FlowMapper *lutGen; // for mapping phi angles
98+
};
99+
100+
FairGenerator *generator_syntheFlowOO()
101+
{
102+
auto generator = new GeneratorPythia8SyntheFlowOO();
103+
gRandom->SetSeed(0);
104+
generator->readString("Random:setSeed = on");
105+
generator->readString("Random:seed =" + std::to_string(gRandom->Integer(900000000 - 2) + 1));
106+
return generator;
107+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
#
4+
# A example workflow MC->RECO->AOD for a simple pp min bias
5+
# production, targetting test beam conditions.
6+
7+
# make sure O2DPG + O2 is loaded
8+
[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1
9+
[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1
10+
11+
# ----------- CONFIGURE --------------------------
12+
export IGNORE_VALIDITYCHECK_OF_CCDB_LOCALCACHE=1
13+
#export ALICEO2_CCDB_LOCALCACHE=.ccdb
14+
15+
16+
# ----------- START ACTUAL JOB -----------------------------
17+
18+
NWORKERS=${NWORKERS:-8}
19+
SIMENGINE=${SIMENGINE:-TGeant4}
20+
NSIGEVENTS=${NSIGEVENTS:-1}
21+
NTIMEFRAMES=${NTIMEFRAMES:-1}
22+
INTRATE=${INTRATE:-50000}
23+
SYSTEM=${SYSTEM:-OO}
24+
ENERGY=${ENERGY:-5360}
25+
CFGINIFILE=${CFGINIFILE:-"${O2DPG_ROOT}/MC/config/PWGLF/ini/GeneratorLF_SyntheFlowOO.ini"}
26+
[[ ${SPLITID} != "" ]] && SEED="-seed ${SPLITID}" || SEED=""
27+
28+
echo "NWORKERS = $NWORKERS"
29+
30+
# create workflow
31+
O2_SIM_WORKFLOW=${O2_SIM_WORKFLOW:-"${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py"}
32+
$O2_SIM_WORKFLOW -eCM ${ENERGY} -col ${SYSTEM} -gen external \
33+
-j ${NWORKERS} \
34+
-ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -interactionRate ${INTRATE} \
35+
-confKey "Diamond.width[2]=6." \
36+
${SEED} \
37+
-e ${SIMENGINE} \
38+
-ini $CFGINIFILE
39+
40+
# run workflow
41+
O2_SIM_WORKFLOW_RUNNER=${O2_SIM_WORKFLOW_RUNNER:-"${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py"}
42+
$O2_SIM_WORKFLOW_RUNNER -f workflow.json -tt aod --cpu-limit $NWORKERS

0 commit comments

Comments
 (0)