Skip to content

Commit

Permalink
[format] Run ruff on all python files to comply with rules
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener authored and andresailer committed Oct 1, 2024
1 parent 499f9ba commit d904a01
Show file tree
Hide file tree
Showing 18 changed files with 1,403 additions and 996 deletions.
21 changes: 13 additions & 8 deletions CaloTB/CaloTB_EPT_AHCAL/TBModel2015_steering.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,38 @@
SIM.compactFile = "../../DD4HEP/compact/TBModel2015.xml"
SIM.runType = "batch"
SIM.macroFile = "vis.mac"
#SIM.inputFiles = "mcparticles.slcio"
# SIM.inputFiles = "mcparticles.slcio"
SIM.outputFile = "DD4hep_mu-_8GeV_QGSP_BERT_10k.slcio"

SIM.numberOfEvents = 10000
SIM.skipNEvents = 0
SIM.physicsList = "QGSP_BERT"
SIM.dumpSteeringFile = "TBModel2015_dump.xml"
SIM.enableDetailedShowerMode=True
SIM.enableDetailedShowerMode = True

SIM.random.seed = "0123456789"
SIM.field.eps_min = 1*mm
SIM.part.minimalKineticEnergy = 1*MeV
SIM.field.eps_min = 1 * mm
SIM.part.minimalKineticEnergy = 1 * MeV

SIM.action.calo = "Geant4ScintillatorCalorimeterAction"

## set the particle.tbl file to add extra particles to DDsim (B-Baryons)
## use the power of python to get the file from DD4hep wherever it is
import os
if os.path.exists( os.path.join( os.environ.get("DD4hepINSTALL"), "examples/DDG4/examples/particle.tbl") ):
SIM.physics.pdgfile = os.path.join( os.environ.get("DD4hepINSTALL"), "examples/DDG4/examples/particle.tbl")

if os.path.exists(
os.path.join(os.environ.get("DD4hepINSTALL"), "examples/DDG4/examples/particle.tbl")
):
SIM.physics.pdgfile = os.path.join(
os.environ.get("DD4hepINSTALL"), "examples/DDG4/examples/particle.tbl"
)


SIM.enableGun = True
SIM.gun.particle = "mu-"
SIM.gun.energy = 8*GeV
SIM.gun.energy = 8 * GeV
SIM.gun.position = "0, 0, -1000"
SIM.gun.direction = "0,0,1"

#SIM.gun.isotrop
# SIM.gun.isotrop
SIM.gun.multiplicity = 1
14 changes: 7 additions & 7 deletions CaloTB/run_sim/ddsim_steering_00.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
SIM.compactFile = "../compact/MainTestBeamSetup.xml"
SIM.dumpSteeringFile = "dumpSteering00.xml"

SIM.field.eps_min = 1*mm
SIM.field.eps_min = 1 * mm

SIM.part.minimalKineticEnergy = 1*MeV
SIM.part.minimalKineticEnergy = 1 * MeV

SIM.physicsList = "QGSP_BERT"
SIM.enableDetailedShowerMode=True

SIM.enableDetailedShowerMode = True

SIM.enableGun = True

SIM.gun.energy = 10*GeV
SIM.gun.energy = 10 * GeV
SIM.gun.particle = "pi+"
#SIM.gun.multiplicity
# SIM.gun.multiplicity
SIM.gun.position = "0,0,-1000"
#SIM.gun.isotrop
# SIM.gun.isotrop
SIM.gun.direction = "0,0,1"
225 changes: 126 additions & 99 deletions ILD/compact/ILD_common_v02/writeAllILDCompactDescriptions.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
def writeTopCompactXml( outfile, version, name, Large, Option, SolenoidMap, AntiDID, FwdFields ):

def writeTopCompactXml(outfile, version, name, Large, Option, SolenoidMap, AntiDID, FwdFields):
# defaults for option 0, 1
# si ecal
ecal_sl1=4
ecal_sl2=10
ecal_sl1 = 4
ecal_sl2 = 10
# ahcal
hcal_sl=3
if Option==2 or Option==4: # SDHCAL
hcal_sl=1
elif Option==3 or Option==4: # ScECAL
ecal_sl1=3
ecal_sl2=11
elif Option>1:
print( 'ERROR: do not know about Option', Option)
hcal_sl = 3
if Option == 2 or Option == 4: # SDHCAL
hcal_sl = 1
elif Option == 3 or Option == 4: # ScECAL
ecal_sl1 = 3
ecal_sl2 = 11
elif Option > 1:
print("ERROR: do not know about Option", Option)
return

if FwdFields!=250 and FwdFields!=500 and FwdFields!=1000 and FwdFields!=0:
print( 'ERROR: do not know about FwdFields at energy', FwdFields)
if FwdFields != 250 and FwdFields != 500 and FwdFields != 1000 and FwdFields != 0:
print("ERROR: do not know about FwdFields at energy", FwdFields)
return

outfile.write('<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"\n')
outfile.write(' xmlns:xs="http://www.w3.org/2001/XMLSchema"\n')
outfile.write(' xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">\n')
outfile.write(' <info name="'+name+'"\n')
outfile.write(
' xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">\n'
)
outfile.write(' <info name="' + name + '"\n')
outfile.write(' title="ILD multi-technology model used for the optimisation"\n')
outfile.write(' author="F. Gaede, S.Lu, D.Jeans"\n')
outfile.write(' url="http://ilcsoft.desy.de"\n')
outfile.write(' status="experimental"\n')
outfile.write(' version="v'+version+'">\n')
outfile.write(' <comment>ILD simulation models used for detector optimisation </comment>\n')
outfile.write(' </info>\n')
outfile.write(' <includes>\n')
outfile.write(' version="v' + version + '">\n')
outfile.write(" <comment>ILD simulation models used for detector optimisation </comment>\n")
outfile.write(" </info>\n")
outfile.write(" <includes>\n")
outfile.write(' <gdmlFile ref="../ILD_common_v02/elements.xml"/>\n')
outfile.write(' <gdmlFile ref="../ILD_common_v02/materials.xml"/>\n')
outfile.write(' </includes>\n')
outfile.write(' <define>\n')
outfile.write(" </includes>\n")
outfile.write(" <define>\n")
if Large:
outfile.write(' <include ref="../ILD_common_v02/top_defs_ILD_l5_v02.xml"/>\n')
else:
Expand All @@ -52,23 +53,35 @@ def writeTopCompactXml( outfile, version, name, Large, Option, SolenoidMap, Anti
outfile.write(' <include ref="../ILD_common_v02/services_defs.xml"/>\n')
outfile.write(' <include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/>\n')
outfile.write(' <include ref="../ILD_common_v02/limits.xml"/>\n')
outfile.write(' <!-- Readout slice in ecal for reconstruction -->\n')
outfile.write(' <constant name="Ecal_readout_segmentation_slice0" value="'+str(ecal_sl1)+'"/>\n')
outfile.write(' <constant name="Ecal_readout_segmentation_slice1" value="'+str(ecal_sl2)+'"/>\n')
outfile.write(' <!-- Readout slice in hcal for reconstruction -->\n')
outfile.write(' <constant name="Hcal_readout_segmentation_slice" value="'+str(hcal_sl)+'"/>\n')
outfile.write(' </define>\n')
outfile.write(' <limits>\n')
outfile.write(" <!-- Readout slice in ecal for reconstruction -->\n")
outfile.write(
' <constant name="Ecal_readout_segmentation_slice0" value="' + str(ecal_sl1) + '"/>\n'
)
outfile.write(
' <constant name="Ecal_readout_segmentation_slice1" value="' + str(ecal_sl2) + '"/>\n'
)
outfile.write(" <!-- Readout slice in hcal for reconstruction -->\n")
outfile.write(
' <constant name="Hcal_readout_segmentation_slice" value="' + str(hcal_sl) + '"/>\n'
)
outfile.write(" </define>\n")
outfile.write(" <limits>\n")
outfile.write(' <limitset name="cal_limits">\n')
outfile.write(' <limit name="step_length_max" particles="*" value="cal_steplimit_val" unit="cal_steplimit_unit" />\n')
outfile.write(' </limitset>\n')
outfile.write(
' <limit name="step_length_max" particles="*" value="cal_steplimit_val" unit="cal_steplimit_unit" />\n'
)
outfile.write(" </limitset>\n")
outfile.write(' <limitset name="TPC_limits">\n')
outfile.write(' <limit name="step_length_max" particles="*" value="tpc_steplimit_val" unit="tpc_steplimit_unit" />\n')
outfile.write(' </limitset>\n')
outfile.write(
' <limit name="step_length_max" particles="*" value="tpc_steplimit_val" unit="tpc_steplimit_unit" />\n'
)
outfile.write(" </limitset>\n")
outfile.write(' <limitset name="Tracker_limits">\n')
outfile.write(' <limit name="step_length_max" particles="*" value="tracker_steplimit_val" unit="tracker_steplimit_unit" />\n')
outfile.write(' </limitset>\n')
outfile.write(' </limits>\n')
outfile.write(
' <limit name="step_length_max" particles="*" value="tracker_steplimit_val" unit="tracker_steplimit_unit" />\n'
)
outfile.write(" </limitset>\n")
outfile.write(" </limits>\n")
outfile.write(' <include ref="../ILD_common_v02/display.xml"/>\n')
outfile.write(' <include ref="../ILD_common_v02/Beampipe_o1_v01_01.xml"/>\n')
outfile.write(' <include ref="../ILD_common_v02/vxd07.xml"/>\n')
Expand All @@ -80,7 +93,7 @@ def writeTopCompactXml( outfile, version, name, Large, Option, SolenoidMap, Anti
outfile.write(' <include ref="../ILD_common_v02/SEcal06_hybrid_Endcaps.xml"/>\n')
outfile.write(' <include ref="../ILD_common_v02/SEcal05_siw_ECRing.xml"/>\n')
outfile.write(' <include ref="../ILD_common_v02/SHcalSc04_Barrel_v04.xml"/>\n')

if Large:
outfile.write(' <include ref="../ILD_common_v02/SHcalSc04_Endcaps_v01_LARGE.xml"/>\n')
else:
Expand All @@ -94,10 +107,10 @@ def writeTopCompactXml( outfile, version, name, Large, Option, SolenoidMap, Anti
outfile.write(' <include ref="../ILD_common_v02/BeamCal08.xml"/>\n')
outfile.write(' <include ref="../ILD_common_v02/coil03.xml"/>\n')
outfile.write(' <include ref="../ILD_common_v02/SServices00.xml"/>\n')
outfile.write(' <plugins>\n')
outfile.write(" <plugins>\n")
outfile.write(' <plugin name="DD4hepVolumeManager"/>\n')
outfile.write(' <plugin name="InstallSurfaceManager"/>\n')
outfile.write(' </plugins>\n')
outfile.write(" </plugins>\n")

if SolenoidMap:
if Large:
Expand All @@ -113,89 +126,103 @@ def writeTopCompactXml( outfile, version, name, Large, Option, SolenoidMap, Anti
else:
outfile.write(' <include ref="../ILD_common_v02/Field_AntiDID_Map_s.xml"/>\n')

if FwdFields>0:
outfile.write(' <include ref="../ILD_common_v02/Field_FwdMagnets_Ideal_'+str(FwdFields)+'GeV.xml"/>\n')
if FwdFields > 0:
outfile.write(
' <include ref="../ILD_common_v02/Field_FwdMagnets_Ideal_'
+ str(FwdFields)
+ 'GeV.xml"/>\n'
)

outfile.write("</lccdd>\n")


outfile.write('</lccdd>\n')
# -----------------------------------------------------

#-----------------------------------------------------

def getVersionParameters(version):
vparams={}
if version==2:
vparams['SolenoidMap']=False
vparams['AntiDID']=False
vparams['FwdFields']=0
elif version==3:
vparams['SolenoidMap']=True
vparams['AntiDID']=False
vparams['FwdFields']=250
elif version==4:
vparams['SolenoidMap']=True
vparams['AntiDID']=False
vparams['FwdFields']=500
elif version==5:
vparams['SolenoidMap']=True
vparams['AntiDID']=True
vparams['FwdFields']=250
elif version==6:
vparams['SolenoidMap']=True
vparams['AntiDID']=True
vparams['FwdFields']=500
elif version==7:
vparams['SolenoidMap']=True
vparams['AntiDID']=False
vparams['FwdFields']=1000
elif version==8:
vparams['SolenoidMap']=True
vparams['AntiDID']=True
vparams['FwdFields']=1000
vparams = {}
if version == 2:
vparams["SolenoidMap"] = False
vparams["AntiDID"] = False
vparams["FwdFields"] = 0
elif version == 3:
vparams["SolenoidMap"] = True
vparams["AntiDID"] = False
vparams["FwdFields"] = 250
elif version == 4:
vparams["SolenoidMap"] = True
vparams["AntiDID"] = False
vparams["FwdFields"] = 500
elif version == 5:
vparams["SolenoidMap"] = True
vparams["AntiDID"] = True
vparams["FwdFields"] = 250
elif version == 6:
vparams["SolenoidMap"] = True
vparams["AntiDID"] = True
vparams["FwdFields"] = 500
elif version == 7:
vparams["SolenoidMap"] = True
vparams["AntiDID"] = False
vparams["FwdFields"] = 1000
elif version == 8:
vparams["SolenoidMap"] = True
vparams["AntiDID"] = True
vparams["FwdFields"] = 1000
else:
print( 'ERROR: unknown version requested:',version,'!!')
print("ERROR: unknown version requested:", version, "!!")
return vparams

if version<10:
vparams['vString']='0'+str(version)
if version < 10:
vparams["vString"] = "0" + str(version)
else:
vparams['vString']=str(version)
vparams["vString"] = str(version)

return vparams


#-----------------------------------------------------
# -----------------------------------------------------

import os

prename='ILD' # for the real thing
prename = "ILD" # for the real thing
# prename='test' # for testing

topdir='../'
mainoutdirname=prename+'_sl5_v02'
mainoutdir=topdir+mainoutdirname
topdir = "../"
mainoutdirname = prename + "_sl5_v02"
mainoutdir = topdir + mainoutdirname

if not os.path.exists(mainoutdir):
os.makedirs(mainoutdir)

for version in range(2, 9):
vparams=getVersionParameters(version)
vparams = getVersionParameters(version)
for Large in (True, False):
for Option in range(0,5):

modelname=prename+'_'
for Option in range(0, 5):
modelname = prename + "_"
if Large:
modelname=modelname+'l'
modelname = modelname + "l"
else:
modelname=modelname+'s'
modelname=modelname+'5_'

if Option>0:
modelname=modelname+'o'+str(Option)+'_'

modelname=modelname+'v'+vparams['vString']

outfile=open(mainoutdir+'/'+modelname+'.xml','w')
writeTopCompactXml( outfile, version=vparams['vString'], name=modelname, Large=Large, Option=Option, SolenoidMap=vparams['SolenoidMap'], AntiDID=vparams['AntiDID'], FwdFields=vparams['FwdFields'] )
modelname = modelname + "s"
modelname = modelname + "5_"

if Option > 0:
modelname = modelname + "o" + str(Option) + "_"

modelname = modelname + "v" + vparams["vString"]

outfile = open(mainoutdir + "/" + modelname + ".xml", "w")
writeTopCompactXml(
outfile,
version=vparams["vString"],
name=modelname,
Large=Large,
Option=Option,
SolenoidMap=vparams["SolenoidMap"],
AntiDID=vparams["AntiDID"],
FwdFields=vparams["FwdFields"],
)
outfile.close()
if not os.path.exists( topdir+modelname ):
os.symlink( mainoutdirname, topdir+modelname )

if not os.path.exists(topdir + modelname):
os.symlink(mainoutdirname, topdir + modelname)
9 changes: 5 additions & 4 deletions ILD/doc/latex/ILD_envelopeDict.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
python dictionary with parameters extracted from: /data/ilcsoft/HEAD/lcgeo/HEAD/ILD/compact/ILD_o1_v05/ILD_o1_v05.xml
"""
values={}
"""
python dictionary with parameters extracted from: /data/ilcsoft/HEAD/lcgeo/HEAD/ILD/compact/ILD_o1_v05/ILD_o1_v05.xml
"""

values = {}
values["VXD_inner_radius"] = 16.0
values["VXD_outer_radius"] = 60.0
values["VXD_half_length"] = 177.6
Expand Down
Loading

0 comments on commit d904a01

Please sign in to comment.