Skip to content
Snippets Groups Projects
Commit 4c69de3d authored by Thomas Strebler's avatar Thomas Strebler Committed by Johannes Elmsheuser
Browse files

Make time width configurable for VertexBeamCondPositioner

Make time width configurable for VertexBeamCondPositioner
parent c4fef274
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,7 @@ def VertexBeamCondPositionerCfg(flags, name="VertexBeamCondPositioner", **kwargs
kwargs.setdefault("RandomSvc", acc.getPrimaryAndMerge(AthRNGSvcCfg(flags)).name)
kwargs.setdefault("SimpleTimeSmearing", flags.Sim.VertexTimeSmearing)
kwargs.setdefault("TimeWidth", flags.Sim.VertexTimeWidth)
from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
acc.merge(BeamSpotCondAlgCfg(flags))
......
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
// class header include
......@@ -104,33 +104,15 @@ namespace Simulation
<< "\tWidth is (" << beamSpotHandle->beamSigma(0)
<< ", " << beamSpotHandle->beamSigma(1) << ", "
<< beamSpotHandle->beamSigma(2) << ")" << std::endl
<< "\tTime smearing is " << (m_timeSmearing ? "on" : "off") << " with width " << m_timeWidth << std::endl
<< "\tTilts are " << beamSpotHandle->beamTilt(0) << " and " << beamSpotHandle->beamTilt(1) << std::endl
<< "\tVertex Position before transform: " << *vertexSmearing);
// update with the tilt
*vertexSmearing = transform * HepGeom::Point3D<double>(*vertexSmearing);
// See if we were asked to do time smearing as well
if (m_timeSmearing){
/* This is ballpark code courtesy of Brian Amadio. He provided some functions based on beam parameters.
He provided a little trick for pulling out the beam bunch width as well. Hard coding the crossing angle
parameter for the time being, as the beam spot service doesn't really provide that yet. */
double bunch_length_z = (std::sqrt(2)*beamSpotHandle->beamSigma(2))/0.9; // 0.9 is the crossing angle reduction factor
// double tLimit = 2.*(bunch_length_z+bunch_length_z)/Gaudi::Units::c_light;
// TF1 func = TF1("func","[0]*exp((-([3]-299792458*x)^2*[2]^2-([3]+299792458*x)^2*[1]^2)/(2*[1]^2*[2]^2))",-1*tLimit,tLimit);
// func.SetParameter(0,Gaudi::Units::c_light/(M_PI*bunch_length_z*bunch_length_z));
// func.SetParameter(1,bunch_length_z);
// func.SetParameter(2,bunch_length_z);
// func.SetParameter(3,vertexSmearing->z());
// double time_offset = func.GetRandom();
// Time should be set in units of distance, which is a little funny
double time_offset = CLHEP::RandGaussZiggurat::shoot(
randomEngine, vertexSmearing->z()/Gaudi::Units::c_light,
bunch_length_z/Gaudi::Units::c_light );
vertexSmearing->setT( vertexSmearing->t() + time_offset*Gaudi::Units::c_light );
}
float vertexT = m_timeSmearing ? CLHEP::RandGaussZiggurat::shoot(randomEngine)*m_timeWidth : 0.;
vertexSmearing->setT(vertexT);
// and return it
return vertexSmearing;
......
/*
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
*/
#ifndef BEAMEFFECTS_VERTEXBEAMCONPOSITIONER_H
......@@ -54,7 +54,9 @@ namespace Simulation {
ATHRNG::RNGWrapper* m_randomEngine ATLAS_THREAD_SAFE{}; //!< Slot-local RNG
Gaudi::Property<std::string> m_randomEngineName{this, "RandomStream", "VERTEX"}; //!< Name of the random number stream
Gaudi::Property<bool> m_timeSmearing{this, "SimpleTimeSmearing", false}; //!< Do time smearing
Gaudi::Property<bool> m_timeSmearing{this, "SimpleTimeSmearing", false}; //!< Do time smearing
Gaudi::Property<float> m_timeWidth{this, "TimeWidth", 0.}; //!< Width of time for smearing
};
......
......@@ -5,7 +5,7 @@ from AthenaConfiguration.AutoConfigFlags import GetFileMD
from AthenaConfiguration.Enums import LHCPeriod
from SimulationConfig.SimEnums import BeamPipeSimMode, CalibrationRun, CavernBackground, \
LArParameterization, SimulationFlavour, TruthStrategy, VertexSource
from AthenaCommon.SystemOfUnits import m
from AthenaCommon.SystemOfUnits import m, ns
#todo? add in the explanatory text from previous implementation
......@@ -132,6 +132,15 @@ def createSimConfigFlags():
scf.addFlag("Sim.VertexTimeSmearing", lambda prevFlags:
prevFlags.GeoModel.Run >= LHCPeriod.Run4)
def _checkVertexTimeWidth(prevFlags):
default = 0.175*ns
vertexTimeWidth = default
if prevFlags.Input.Files:
vertexTimeWidth = GetFileMD(prevFlags.Input.Files).get("VertexTimeWidth", default)
return vertexTimeWidth
scf.addFlag("Sim.VertexTimeWidth", _checkVertexTimeWidth)
# G4UserActions
scf.addFlag("Sim.NRRThreshold", False)
scf.addFlag("Sim.NRRWeight", False)
......
......@@ -23,6 +23,9 @@ def fillAtlasMetadata(flags, dbFiller):
if "UseShadowEvent" in flag and not flags.Sim.UseShadowEvent:
# This flag is added temporarily to allow a new approach to quasi-stable particle simulation to be tested.
continue
if "VertexTimeWidth" in flag and not flags.Sim.VertexTimeSmearing:
# This flag is only written to metadata when vertex time smearing is enabled
continue
key = flag.split(".")[-1] #use final part of flag as the key
value = flags._get(flag)
if isinstance(value, FlagEnum):
......
run event nTopo nIdTracks nTauTracks nTaus nMuons nElec nTrueElec nFakeElec nPhot nTruePhot nFakePhot
242000 3120001 249 8 2 1 1 0 0 0 0 0 0
242000 3120002 153 6 0 0 1 0 0 0 0 0 0
242000 3120003 356 36 7 2 2 1 0 1 0 0 0
242000 3120004 170 10 5 1 0 0 0 0 0 0 0
242000 3120005 409 40 7 2 3 1 0 1 3 1 2
242000 3120001 199 6 2 1 1 0 0 0 0 0 0
242000 3120002 184 6 0 0 1 0 0 0 0 0 0
242000 3120003 380 35 3 1 2 0 0 0 0 0 0
242000 3120004 182 11 4 1 0 0 0 0 0 0 0
242000 3120005 394 36 7 2 2 1 0 1 3 2 1
......@@ -11,7 +11,7 @@
# Format is "test" : "version"
references_map = {
# Simulation
"s3761": "v4",
"s3761": "v5",
"s3779": "v2",
"s4005": "v3",
"s4006": "v3",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment