Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions MC/config/PWGLF/ini/GeneratorLF_SyntheFlowOO.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[GeneratorExternal]
fileName=${O2DPG_MC_CONFIG_ROOT}/MC/config/PWGLF/pythia8/generator_pythia8_syntheFlowOO.C
funcName=generator_syntheFlowOO()

[GeneratorPythia8]
config=${O2DPG_MC_CONFIG_ROOT}/MC/config/common/pythia8/generator/pythia8_OO_536.cfg
28 changes: 28 additions & 0 deletions MC/config/PWGLF/ini/tests/GeneratorLF_SyntheFlowOO.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
int External()
{
std::string path{"o2sim_Kine.root"};

TFile file(path.c_str(), "READ");
if (file.IsZombie())
{
std::cerr << "Cannot open ROOT file " << path << "\n";
return 1;
}

auto tree = (TTree *)file.Get("o2sim");
if (!tree)
{
std::cerr << "Cannot find tree o2sim in file " << path << "\n";
return 1;
}
std::vector<o2::MCTrack> *tracks{};
tree->SetBranchAddress("MCTrack", &tracks);

auto nEvents = tree->GetEntries();
if (nEvents < 1)
{
std::cerr << "No events actually generated: not OK!";
return 1;
}
return 0;
}
107 changes: 107 additions & 0 deletions MC/config/PWGLF/pythia8/generator_pythia8_syntheFlowOO.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

#include "Pythia8/Pythia.h"
#include "Pythia8/HeavyIons.h"
#include "FairGenerator.h"
#include "FairPrimaryGenerator.h"
#include "Generators/GeneratorPythia8.h"
#include "TRandom3.h"
#include "TParticlePDG.h"
#include "TDatabasePDG.h"
#include "CCDB/BasicCCDBManager.h"
#include "TH1F.h"
#include "TH1D.h"

#include <map>
#include <unordered_set>

class GeneratorPythia8SyntheFlowOO : public o2::eventgen::GeneratorPythia8
{
public:
/// Constructor
GeneratorPythia8SyntheFlowOO() {
lutGen = new o2::eventgen::FlowMapper();

// -------- CONFIGURE SYNTHETIC FLOW ------------
// establish connection to ccdb
o2::ccdb::CcdbApi ccdb_api;
ccdb_api.init("https://alice-ccdb.cern.ch");

// config was placed at midpoint of run 564356, retrieve that
std::map<string, string> metadataRCT, headers;
headers = ccdb_api.retrieveHeaders("RCT/Info/RunInformation/564356", metadataRCT, -1);
int64_t tsSOR = atol(headers["SOR"].c_str());
int64_t tsEOR = atol(headers["EOR"].c_str());
int64_t midRun = 0.5*tsSOR+0.5*tsEOR;

map<string, string> metadata; // can be empty
auto list = ccdb_api.retrieveFromTFileAny<TList>("Users/d/ddobrigk/syntheflow", metadata, midRun);

TH1D *hv2vspT = (TH1D*) list->FindObject("hFlowVsPt_ins1116150_v1_Table_1");
TH1D *heccvsb = (TH1D*) list->FindObject("hEccentricityVsB");

cout<<"Generating LUT for flow test"<<endl;
lutGen->CreateLUT(hv2vspT, heccvsb);
cout<<"Finished creating LUT!"<<endl;
// -------- END CONFIGURE SYNTHETIC FLOW ------------
}

/// Destructor
~GeneratorPythia8SyntheFlowOO() = default;

//__________________________________________________________________
Bool_t generateEvent() override {

// Generate PYTHIA event
Bool_t lPythiaOK = kFALSE;
while (!lPythiaOK){
lPythiaOK = mPythia.next();
}

//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// loop over the entire event record and rotate all particles
// synthetic flow exercise
// first: get event plane
float eventPlaneAngle = mPythia.info.hiInfo->phi();
float impactParameter = mPythia.info.hiInfo->b();

for ( Long_t j=0; j < mPythia.event.size(); j++ ) {
float pyphi = mPythia.event[j].phi();
float pypT = mPythia.event[j].pT();

// calculate delta with EP
float deltaPhiEP = pyphi - eventPlaneAngle;
float shift = 0.0;
while(deltaPhiEP<0.0){
deltaPhiEP += 2*TMath::Pi();
shift += 2*TMath::Pi();
}
while(deltaPhiEP>2*TMath::Pi()){
deltaPhiEP -= 2*TMath::Pi();
shift -= 2*TMath::Pi();
}
float newDeltaPhiEP = lutGen->MapPhi(deltaPhiEP, impactParameter, pypT);
float pyphiNew = newDeltaPhiEP - shift + eventPlaneAngle;

if(pyphiNew>TMath::Pi())
pyphiNew -= 2.0*TMath::Pi();
if(pyphiNew<-TMath::Pi())
pyphiNew += 2.0*TMath::Pi();
mPythia.event[j].rot(0.0, pyphiNew-pyphi);
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

return true;
}

private:
o2::eventgen::FlowMapper *lutGen; // for mapping phi angles
};

FairGenerator *generator_syntheFlowOO()
{
auto generator = new GeneratorPythia8SyntheFlowOO();
gRandom->SetSeed(0);
generator->readString("Random:setSeed = on");
generator->readString("Random:seed =" + std::to_string(gRandom->Integer(900000000 - 2) + 1));
return generator;
}
42 changes: 42 additions & 0 deletions MC/run/PWGLF/run_SyntheticFlow_OO.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

#
# A example workflow MC->RECO->AOD for a simple pp min bias
# production, targetting test beam conditions.

# make sure O2DPG + O2 is loaded
[ ! "${O2DPG_ROOT}" ] && echo "Error: This needs O2DPG loaded" && exit 1
[ ! "${O2_ROOT}" ] && echo "Error: This needs O2 loaded" && exit 1

# ----------- CONFIGURE --------------------------
export IGNORE_VALIDITYCHECK_OF_CCDB_LOCALCACHE=1
#export ALICEO2_CCDB_LOCALCACHE=.ccdb


# ----------- START ACTUAL JOB -----------------------------

NWORKERS=${NWORKERS:-8}
SIMENGINE=${SIMENGINE:-TGeant4}
NSIGEVENTS=${NSIGEVENTS:-1}
NTIMEFRAMES=${NTIMEFRAMES:-1}
INTRATE=${INTRATE:-50000}
SYSTEM=${SYSTEM:-OO}
ENERGY=${ENERGY:-5360}
CFGINIFILE=${CFGINIFILE:-"${O2DPG_ROOT}/MC/config/PWGLF/ini/GeneratorLF_SyntheFlowOO.ini"}
[[ ${SPLITID} != "" ]] && SEED="-seed ${SPLITID}" || SEED=""

echo "NWORKERS = $NWORKERS"

# create workflow
O2_SIM_WORKFLOW=${O2_SIM_WORKFLOW:-"${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py"}
$O2_SIM_WORKFLOW -eCM ${ENERGY} -col ${SYSTEM} -gen external \
-j ${NWORKERS} \
-ns ${NSIGEVENTS} -tf ${NTIMEFRAMES} -interactionRate ${INTRATE} \
-confKey "Diamond.width[2]=6." \
${SEED} \
-e ${SIMENGINE} \
-ini $CFGINIFILE

# run workflow
O2_SIM_WORKFLOW_RUNNER=${O2_SIM_WORKFLOW_RUNNER:-"${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py"}
$O2_SIM_WORKFLOW_RUNNER -f workflow.json -tt aod --cpu-limit $NWORKERS