From 41d977134a2d2fb000e06eebbd691a836e02769d Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Tue, 10 Sep 2024 17:35:44 +0200 Subject: [PATCH] PWGHF: remove obsolete generator to avoid confusion (#1742) * PWGHF: remove obsolete generator to avoid confusion * Remove other obsolete files (cherry picked from commit 9337da9b67910061f3139cf0659ae5b50c695f5b) --- .../PWGHF/external/generator/GeneratorHF.C | 160 ------------------ MC/config/PWGHF/ini/GeneratorHF.ini | 34 ---- MC/config/PWGHF/ini/GeneratorHF_bbbar.ini | 34 ---- MC/config/PWGHF/ini/GeneratorHF_ccbar.ini | 34 ---- MC/config/PWGHF/ini/GeneratorHF_decay.ini | 18 -- MC/run/PWGHF/create_embedding_workflow.py | 19 --- MC/run/PWGHF/embedding_benchmark.sh | 36 ---- MC/run/PWGHF/run_embedding.sh | 38 ----- 8 files changed, 373 deletions(-) delete mode 100644 MC/config/PWGHF/external/generator/GeneratorHF.C delete mode 100644 MC/config/PWGHF/ini/GeneratorHF.ini delete mode 100644 MC/config/PWGHF/ini/GeneratorHF_bbbar.ini delete mode 100644 MC/config/PWGHF/ini/GeneratorHF_ccbar.ini delete mode 100644 MC/config/PWGHF/ini/GeneratorHF_decay.ini delete mode 100755 MC/run/PWGHF/create_embedding_workflow.py delete mode 100755 MC/run/PWGHF/embedding_benchmark.sh delete mode 100755 MC/run/PWGHF/run_embedding.sh diff --git a/MC/config/PWGHF/external/generator/GeneratorHF.C b/MC/config/PWGHF/external/generator/GeneratorHF.C deleted file mode 100644 index ed56c438b..000000000 --- a/MC/config/PWGHF/external/generator/GeneratorHF.C +++ /dev/null @@ -1,160 +0,0 @@ -/// \author R+Preghenella - July 2020 - -// Example of an implementation of an event generator -// that provides HF signals for embedding in background - -R__ADD_INCLUDE_PATH($PYTHIA_ROOT/include) - -#include "Pythia8/Pythia.h" - -namespace o2 -{ -namespace eventgen -{ - -class GeneratorHF : public GeneratorPythia8 -{ - - public: - GeneratorHF() : GeneratorPythia8(){}; - ~GeneratorHF() = default; - - // We initialise the local Pythia8 event where we store the particles - // of the signal event that is the sum of multiple Pythia8 events - // generated according to the generateEvent() function below. - Bool_t Init() override - { - mOutputEvent.init("(GeneratorHF output event)", &mPythia.particleData); - return GeneratorPythia8::Init(); - } - - // This function is called by the primary generator - // for each event in case we are in embedding mode. - // We use it to setup the number of signal events - // to be generated and to be embedded on the background. - void notifyEmbedding(const o2::dataformats::MCEventHeader* bkgHeader) override - { - mEvents = mFormula.Eval(bkgHeader->GetB()); - std::cout << " --- notify embedding: impact parameter is " << bkgHeader->GetB() << ", generating " << mEvents << " signal events " << std::endl; - }; - - // We override this function to be able to generate multiple - // events and build an output event that is the sum of them - // where we have stripped out only the sub-event starting from - // the c-cbar ancestor particle - Bool_t generateEvent() override - { - - // reset counter and event - mOutputEvent.reset(); - - // loop over number of events to be generated - int nEvents = 0; - while (nEvents < mEvents) { - - // generate event - if (!GeneratorPythia8::generateEvent()) - return false; - - // find the c-cbar ancestor - auto ancestor = findAncestor(mPythia.event); - if (ancestor < 0) - continue; - - // append ancestor and its daughters to the output event - selectFromAncestor(ancestor, mPythia.event, mOutputEvent); - nEvents++; - } - - if (mVerbose) - mOutputEvent.list(); - - return true; - }; - - // We override this event to import the particles from the - // output event that we have constructed as the sum of multiple - // Pythia8 sub-events as generated above - Bool_t importParticles() override - { - return GeneratorPythia8::importParticles(mOutputEvent); - } - - // search for c-cbar mother with at least one c at midrapidity - int findAncestor(Pythia8::Event& event) - { - for (int ipa = 0; ipa < event.size(); ++ipa) { - auto daughterList = event[ipa].daughterList(); - bool hasq = false, hasqbar = false, atSelectedY = false; - for (auto ida : daughterList) { - if (event[ida].id() == mPDG) - hasq = true; - if (event[ida].id() == -mPDG) - hasqbar = true; - if ((event[ida].y() > mRapidityMin) && (event[ida].y() < mRapidityMax)) - atSelectedY = true; - } - if (hasq && hasqbar && atSelectedY) - return ipa; - } - return -1; - }; - - void setPDG(int val) { mPDG = val; }; - void setRapidity(double valMin, double valMax) - { - mRapidityMin = valMin; - mRapidityMax = valMax; - }; - void setVerbose(bool val) { mVerbose = val; }; - void setFormula(std::string val) { mFormula.Compile(val.c_str()); }; - - private: - TFormula mFormula; - int mEvents = 1; - Pythia8::Event mOutputEvent; - int mPDG = 4; - double mRapidityMin = -1.5; - double mRapidityMax = 1.5; - bool mVerbose = false; -}; - -} // namespace eventgen -} // namespace o2 - -/** generator instance and settings **/ - -FairGenerator* - GeneratorHF(double rapidityMin = -1.5, double rapidityMax = 1.5, bool verbose = false) -{ - auto gen = new o2::eventgen::GeneratorHF(); - gen->setRapidity(rapidityMin, rapidityMax); - gen->setVerbose(verbose); - gen->setFormula("max(1.,120.*(x<5.)+80.*(1.-x/20.)*(x>5.)*(x<11.)+240.*(1.-x/13.)*(x>11.))"); - - return gen; -} - -FairGenerator* - GeneratorHF_ccbar(double rapidityMin = -1.5, double rapidityMax = 1.5, bool verbose = false) -{ - auto gen = new o2::eventgen::GeneratorHF(); - gen->setPDG(4); - gen->setRapidity(rapidityMin, rapidityMax); - gen->setVerbose(verbose); - gen->setFormula("max(1.,120.*(x<5.)+80.*(1.-x/20.)*(x>5.)*(x<11.)+240.*(1.-x/13.)*(x>11.))"); - - return gen; -} - -FairGenerator* - GeneratorHF_bbbar(double rapidityMin = -1.5, double rapidityMax = 1.5, bool verbose = false) -{ - auto gen = new o2::eventgen::GeneratorHF(); - gen->setPDG(5); - gen->setRapidity(rapidityMin, rapidityMax); - gen->setVerbose(verbose); - gen->setFormula("max(1.,120.*(x<5.)+80.*(1.-x/20.)*(x>5.)*(x<11.)+240.*(1.-x/13.)*(x>11.))"); - - return gen; -} diff --git a/MC/config/PWGHF/ini/GeneratorHF.ini b/MC/config/PWGHF/ini/GeneratorHF.ini deleted file mode 100644 index 3c0ea694f..000000000 --- a/MC/config/PWGHF/ini/GeneratorHF.ini +++ /dev/null @@ -1,34 +0,0 @@ -### The setup uses an external event generator -### This part sets the path of the file and the function call to retrieve it - -[GeneratorExternal] -fileName = ${O2DPG_ROOT}/MC/config/PWGHF/external/generator/GeneratorHF.C -funcName = GeneratorHF() - -### The external generator derives from GeneratorPythia8. -### This part configures the bits of the interface: configuration and user hooks - -[GeneratorPythia8] -config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8_hf.cfg -hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C -hooksFuncName = pythia8_userhooks_ccbar(-1.5,1.5) - -### The setup uses the base configuration of the decayer which is loaded from the file specified by config[0]. -### On top of the base configuration, two more sets of settings are loaded sequentially from config[1] and [2]. - -[DecayerPythia8] -config[0] = ${O2DPG_ROOT}/MC/config/common/pythia8/decayer/base.cfg -config[1] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D.cfg -config[2] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D_use4bodies.cfg - -### The setup forces some particles to be decayed by the external decayer instead of Geant. -### The PDG list of the particles is specified below. - -[SimUserDecay] -pdglist = 411 421 431 4112 4122 4232 4132 - -### The setup inhibits transport of primary particles which are produce at forward rapidity. -### The settings below only transports particles in the barrel, which is currently defined as |eta| < 2 - -[Stack] -transportPrimary = barrel diff --git a/MC/config/PWGHF/ini/GeneratorHF_bbbar.ini b/MC/config/PWGHF/ini/GeneratorHF_bbbar.ini deleted file mode 100644 index 4d4244f62..000000000 --- a/MC/config/PWGHF/ini/GeneratorHF_bbbar.ini +++ /dev/null @@ -1,34 +0,0 @@ -### The setup uses an external event generator -### This part sets the path of the file and the function call to retrieve it - -[GeneratorExternal] -fileName = ${O2DPG_ROOT}/MC/config/PWGHF/external/generator/GeneratorHF.C -funcName = GeneratorHF_bbbar() - -### The external generator derives from GeneratorPythia8. -### This part configures the bits of the interface: configuration and user hooks - -[GeneratorPythia8] -config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8_hf.cfg -hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C -hooksFuncName = pythia8_userhooks_bbbar(-1.5,1.5) - -### The setup uses the base configuration of the decayer which is loaded from the file specified by config[0]. -### On top of the base configuration, two more sets of settings are loaded sequentially from config[1] and [2]. - -[DecayerPythia8] -config[0] = ${O2DPG_ROOT}/MC/config/common/pythia8/decayer/base.cfg -config[1] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D.cfg -config[2] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D_use4bodies.cfg - -### The setup forces some particles to be decayed by the external decayer instead of Geant. -### The PDG list of the particles is specified below. - -[SimUserDecay] -pdglist = 411 421 431 4112 4122 4232 4132 - -### The setup inhibits transport of primary particles which are produce at forward rapidity. -### The settings below only transports particles in the barrel, which is currently defined as |eta| < 2 - -[Stack] -transportPrimary = barrel diff --git a/MC/config/PWGHF/ini/GeneratorHF_ccbar.ini b/MC/config/PWGHF/ini/GeneratorHF_ccbar.ini deleted file mode 100644 index 1d7e9df77..000000000 --- a/MC/config/PWGHF/ini/GeneratorHF_ccbar.ini +++ /dev/null @@ -1,34 +0,0 @@ -### The setup uses an external event generator -### This part sets the path of the file and the function call to retrieve it - -[GeneratorExternal] -fileName = ${O2DPG_ROOT}/MC/config/PWGHF/external/generator/GeneratorHF.C -funcName = GeneratorHF_ccbar() - -### The external generator derives from GeneratorPythia8. -### This part configures the bits of the interface: configuration and user hooks - -[GeneratorPythia8] -config = ${O2DPG_ROOT}/MC/config/common/pythia8/generator/pythia8_hf.cfg -hooksFileName = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/hooks/pythia8_userhooks_qqbar.C -hooksFuncName = pythia8_userhooks_ccbar(-1.5,1.5) - -### The setup uses the base configuration of the decayer which is loaded from the file specified by config[0]. -### On top of the base configuration, two more sets of settings are loaded sequentially from config[1] and [2]. - -[DecayerPythia8] -config[0] = ${O2DPG_ROOT}/MC/config/common/pythia8/decayer/base.cfg -config[1] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D.cfg -config[2] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D_use4bodies.cfg - -### The setup forces some particles to be decayed by the external decayer instead of Geant. -### The PDG list of the particles is specified below. - -[SimUserDecay] -pdglist = 411 421 431 4112 443 4122 4232 4132 4332 - -### The setup inhibits transport of primary particles which are produce at forward rapidity. -### The settings below only transports particles in the barrel, which is currently defined as |eta| < 2 - -#[Stack] -#transportPrimary = barrel diff --git a/MC/config/PWGHF/ini/GeneratorHF_decay.ini b/MC/config/PWGHF/ini/GeneratorHF_decay.ini deleted file mode 100644 index fe13bb851..000000000 --- a/MC/config/PWGHF/ini/GeneratorHF_decay.ini +++ /dev/null @@ -1,18 +0,0 @@ -### The setup uses an external event generator -### This part sets the path of the file and the function call to retrieve it - - -### The setup uses the base configuration of the decayer which is loaded from the file specified by config[0]. -### On top of the base configuration, two more sets of settings are loaded sequentially from config[1] and [2]. - -[DecayerPythia8] -config[0] = ${O2DPG_ROOT}/MC/config/common/pythia8/decayer/base.cfg -config[1] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D.cfg -config[2] = ${O2DPG_ROOT}/MC/config/PWGHF/pythia8/decayer/force_hadronic_D_use4bodies.cfg -config[3] = $O2DPG_ROOT/MC/config/PWGHF/pythia8/decayer/force_hadronic_D_forceLcChannel1.cfg -### The setup forces some particles to be decayed by the external decayer instead of Geant. -### The PDG list of the particles is specified below. - - -[Stack] -transportPrimary = barrel diff --git a/MC/run/PWGHF/create_embedding_workflow.py b/MC/run/PWGHF/create_embedding_workflow.py deleted file mode 100755 index efc2dbc6f..000000000 --- a/MC/run/PWGHF/create_embedding_workflow.py +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env python3 - -# -# A script producing a consistent MC->RECO->AOD workflow -# with optional embedding with parameters for PWGHF. -# - -import os -import sys - -# we simply delegate to main script with some PWGHF settings -command='${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 13000 -col pp -proc ccbar --embedding -interactionRate 50000 ' - -# and add given user options -for i in range(1, len(sys.argv)): - command += sys.argv[i] - command += ' ' - -os.system(command) diff --git a/MC/run/PWGHF/embedding_benchmark.sh b/MC/run/PWGHF/embedding_benchmark.sh deleted file mode 100755 index b7aa0c6ac..000000000 --- a/MC/run/PWGHF/embedding_benchmark.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# -# A example workflow MC->RECO->AOD doing signal-background embedding, meant -# to study embedding speedups. -# Background events are reused across timeframes. -# - -# 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 - -# ----------- LOAD UTILITY FUNCTIONS -------------------------- -. ${O2_ROOT}/share/scripts/jobutils.sh - -# ----------- START ACTUAL JOB ----------------------------- - -NSIGEVENTS=${NSIGEVENTS:-20} -NTIMEFRAMES=${NTIMEFRAMES:-5} -NWORKERS=${NWORKERS:-8} -NBKGEVENTS=${NBKGEVENTS:-20} -MODULES="--skipModules ZDC" -SIMENGINE=${SIMENGINE:-TGeant4} -PYPROCESS=${PYPROCESS:-ccbar} #ccbar, bbar, ... -SEED=${SEED:+-seed $SEED} - -# create workflow -${O2DPG_ROOT}/MC/bin/o2dpg_sim_workflow.py -eCM 5020 -col pp -gen pythia8 -proc ${PYPROCESS} \ - -colBkg PbPb -genBkg pythia8 -procBkg "heavy_ion" \ - -tf ${NTIMEFRAMES} -nb ${NBKGEVENTS} \ - -ns ${NSIGEVENTS} -e ${SIMENGINE} \ - -j ${NWORKERS} --embedding -interactionRate 50000 \ - --include-analysis -run 310000 ${SEED} - -# run workflow -${O2DPG_ROOT}/MC/bin/o2_dpg_workflow_runner.py -f workflow.json --cpu-limit ${CPULIMIT:-8} -tt aod diff --git a/MC/run/PWGHF/run_embedding.sh b/MC/run/PWGHF/run_embedding.sh deleted file mode 100755 index a7c373457..000000000 --- a/MC/run/PWGHF/run_embedding.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -set -x - -MODULES="PIPE ITS TPC" -BKGEVENTS=5 -SIGEVENTS=20 -NWORKERS=8 - -# generate background - -o2-sim -j ${NWORKERS} -n ${BKGEVENTS} -g pythia8hi -m ${MODULES} -o bkg \ - --configFile ${O2DPG_ROOT}/MC/config/common/ini/basic.ini \ - > logbkg 2>&1 - -# generate Pythia8 configuration - -RNDSEED=0 # [default = 0] time-based random seed -PTHATMIN=0. # [default = 0] -PTHATMAX=-1. # [default = -1] - -${O2DPG_ROOT}/MC/config/common/pythia8/utils/mkpy8cfg.py \ - --output=pythia8.cfg \ - --seed=${RNDSEED} \ - --idA=2212 \ - --idB=2212 \ - --eCM=13000. \ - --process=ccbar \ - --ptHatMin=${PTHATMIN} \ - --ptHatMax=${PTHATMAX} - -# embed signal into background - -o2-sim -j ${NWORKERS} -n ${SIGEVENTS} -g extgen -m ${MODULES} -o sgn \ - --configFile ${O2DPG_ROOT}/MC/config/PWGHF/ini/GeneratorHF.ini \ - --configKeyValues "GeneratorPythia8.config=pythia8.cfg" \ - --embedIntoFile bkg_Kine.root \ - > logsgn 2>&1