运行Gauss
学习目标
- 找到运行Gauss的正确配置文件
- 生成生成器级蒙特卡洛样本、打印衰变树并生成nTuples
找到正确的文件
假设你需要知道在记录中找到的模拟样本所使用的配置文件和软件版本,例如:
/MC/2024/Beam6800GeV-2024.Q1.2-MagDown-Nu7.6-25ns-Pythia8/Sim10d/16104043/DIGI
在转换监控器(Transformation Monitor)中搜索ProductionID以找到请求,单击右键结果并选择"Show request"。在新窗口中单击右键并选择"View",将打开生产流程所有步骤的概述,其中包括所用的应用版本和配置文件。
重要提示:配置文件的顺序很重要!
'$DECFILESROOT/options/{eventnumber}.py' '$LBPYTHIA8ROOT/options/Pythia8.py'
produces the sample using Pythia 8 while '$LBPYTHIA8ROOT/options/Pythia8.py'
'$DECFILESROOT/options/{eventnumber}.py'
uses Pythia 6.
运行Gauss并创建纯生成器样本
生产系统会处理初始事件号、运行号和所用数据库标签的必要设置。在私人生产中,你需要在额外的配置文件中自行设置这些参数,例如:
from Gauss.Configuration import GenInit
GaussGen = GenInit("GaussGen")
GaussGen.FirstEventNumber = 1
GaussGen.RunNumber = 1082
from Configurables import LHCbApp
LHCbApp().DDDBtag = 'dddb-20240427'
LHCbApp().CondDBtag = 'sim10-2024.Q1.2-v1.1-md100'
LHCbApp().EvtMax = 5
假设该文件保存为Gauss-Job.py
,按照上面的示例,可通过以下命令生成样本:
./run gaudirun.py \
'$APPCONFIGOPTS/Gauss/EnableSpillover-25ns.py' \
'$APPCONFIGOPTS/Gauss/Run3-detector.py' \
'$APPCONFIGOPTS/Gauss/DataType-2024.py' \
'$DECFILESROOT/options/@{eventType}.py' \
'$LBPYTHIA8ROOT/options/Pythia8.py' \
'$APPCONFIGOPTS/Gauss/G4PL_FTFP_BERT_EmOpt2.py' \
'$APPCONFIGOPTS/Persistency/BasketSize-10.py' \
Gauss-Job.py
其中@{eventType}
需要替换为你选定的事件类型,这是LHCb对特定衰变链的描述方式。你将在衰变文件(DecFiles)课程中了解更多相关内容。
这将需要5到10分钟!
如前所述,探测器模拟速度较慢。可以生成仅包含生成器级别的样本,运行速度会更快。要仅运行生成器阶段,需添加'$GAUSSOPTS/GenStandAlone.py'
作为配置文件之一。
在这种情况下,配置会简化为:
./run gaudirun.py \
'$APPCONFIGOPTS/Gauss/DataType-2024.py' \
'$GAUSSOPTS/GenStandAlone.py' \
'$DECFILESROOT/options/@{eventType}.py' \
'$LBPYTHIA8ROOT/options/Pythia8.py' \
Gauss-Job.py
仅使用一个配置文件
你可以在'Gauss-Job.py'
的顶部通过添加以下内容来引入各种配置文件:
from Gaudi.Configuration import *
importOptions("$APPCONFIGOPTS/Gauss/Beam6500GeV-md100-2016-nu1.6.py")
# etc ...
尝试为事件类型27175000
生成仅包含生成器级别的样本。 D^{*+} \to D^{0}(\to K^{+}K^{-}\mu^{+}\mu^{-})\pi^{+}
生成nTuple
.xgen
文件可以被处理为更易用的形式------使用DaVinci通过以下文件(tupler.py
)处理为nTuple。
在EOS上可以找到包含50,000个事件类型生成事件的较大输入文件:root://eosuser.cern.ch//eos/lhcb/wg/dpa/wp7/Run3SK/simulation/Gauss-27175000-50000ev-basic.xgen
from FunTuple import FunctorCollection, FunTuple_MCParticles as FuntupleMC
import FunTuple.functorcollections as FC
from PyConf.Algorithms import PrintMCTree
import Functors as F
from Functors.math import in_range
from DaVinci import Options, make_config
from PyConf.reading import get_mc_particles, get_mc_header
from Hlt2Conf.algorithms_thor import MCParticleFilter
def main(options: Options):
# FunTuple: define fields (branches)
fields = {
"D*(2010)+": "[D*(2010)+ ==> (D0 ==> K+ K- mu+ mu-) pi+]CC",
"D0": "[D*(2010)+ ==> ^(D0 ==> K+ K- mu+ mu-) pi+]CC",
"K+": "[D*(2010)+ ==> (D0 ==> ^K+ K- mu+ mu-) pi+]CC",
"K-": "[D*(2010)+ ==> (D0 ==> K+ ^K- mu+ mu-) pi+]CC",
"mu+": "[D*(2010)+ ==> (D0 ==> K+ K- ^mu+ mu-) pi+]CC",
"mu-": "[D*(2010)+ ==> (D0 ==> K+ K- mu+ ^mu-) pi+]CC",
"pi+": "[D*(2010)+ ==> (D0 ==> K+ K- mu+ mu-) ^pi+]CC",
}
# FunTuple: define variables for the D* meson
variables_D = FunctorCollection(
{
"ETA": F.ETA,
"PHI": F.PHI,
"TAU": F.MC_LIFETIME,
"ORIGIN_VX": F.ORIGIN_VX,
"ORIGIN_VY": F.ORIGIN_VY,
"ORIGIN_VZ": F.ORIGIN_VZ,
"END_VX": F.END_VX,
"END_VY": F.END_VY,
"END_VZ": F.END_VZ,
}
)
# FunTuple: define common variables
variables_all = FunctorCollection({"PT": F.PT, "P": F.FOURMOMENTUM, "M": F.MASS})
# FunTuple: associate functor collections to field (branch) name
variables = {
"ALL": variables_all,
"D*(2010)+": variables_D,
}
# FunTuple: define input data
all_mc_particles = get_mc_particles("/Event/MC/Particles")
# FunTuple: define event-level variables using functor collections
mc_header = get_mc_header()
evt_vars = FC.MCPrimaries(mc_header=mc_header)
printMC = PrintMCTree(
MCParticles=all_mc_particles, ParticleNames=["D*(2010)+", "D*(2010)-"], OutputLevel=4
)
# now we filter that set of B particles
cut = F.require_all(in_range(1.8, F.ETA, 5.0))
filtered_mc_particles = MCParticleFilter(all_mc_particles, F.FILTER(cut))
tuple_1 = FuntupleMC(
name="Tuple",
tuple_name="DecayTree",
fields=fields,
variables=variables,
event_variables=evt_vars,
inputs=filtered_mc_particles,
)
return make_config(options, {"Tuple": [printMC, tuple_1]})
相应的文件(xgen.yaml
)是:
input_files: Gauss-27175000-Xev-202XXXXX.xgen #Change this with name of your file
input_type: ROOT
data_type: 'Upgrade'
simulation: true
conddb_tag: "sim10-2024.Q1.2-v1.1-md100" # make sure it matches the tags you used
dddb_tag: "dddb-20240427" # make sure it matches the tags you used
conditions_version: master
geometry_version: run3/2024.Q1.2-v00.00
histo_file: DV_histo_xgen.root
ntuple_file: DV_tuple_xgen.root
input_raw_format: 0.5
input_process: Gen
lumi: False
write_fsr: False
通过以下命令运行: lb-run -c best DaVinci/v64r13 lbexec tupler.py:main xgen.yaml