ATLAS Offline Software
CosmicGeneratorConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 
7 
8  xvert_low = -1000.*200. # 200 m
9  xvert_high = 1000.*200. # 200 m
10  zvert_low = -1000.*200. # 200 m
11  zvert_high = 1000.*200. # 200 m
12  radius = 10000.#barrel length ~22m
13  emin = 10.*1000. # 10 GeV
14  emax = 100.*1000. # 100 GeV
15  EminDict = {'slice1': 10.*1000., # 10 GeV
16  'slice2': 100.*1000., # 100 GeV
17  'slice3': 300.*1000., # 300 GeV
18  'slice4': 1000.*1000., # 1 TeV
19  'NONE': 10.*1000. }
20  EmaxDict = {'slice1': 100.*1000., # 100 GeV
21  'slice2': 300.*1000., # 300 GeV
22  'slice3': 1000.*1000., # 1 TeV
23  'slice4': 5000.*1000., # 5 TeV
24  'NONE': 5000.*1000. }
25  xvert_lowDict = {'slice1': -1000.*200., # 200 m
26  'slice2': -1000.*600., # 600 m
27  'slice3': -1000.*1000., # 1 km
28  'slice4': -1000.*3000., # 3 km
29  'NONE': -200000. }
30  xvert_highDict = {'slice1': 1000.*200., # 200 m
31  'slice2': 1000.*600., # 600 m
32  'slice3': 1000.*1000., # 1 km
33  'slice4': 1000.*3000., # 3 km
34  'NONE': 200000. }
35  zvert_lowDict = {'slice1': -1000.*200., # 200 m
36  'slice2': -1000.*600., # 600 m
37  'slice3': -1000.*1000., # 1 km
38  'slice4': -1000.*3000., # 3 km
39  'NONE': -200000. }
40  zvert_highDict = {'slice1': 1000.*200., # 200 m
41  'slice2': 1000.*600., # 600 m
42  'slice3': 1000.*1000., # 1 km
43  'slice4': 1000.*3000., # 3 km
44  'NONE': 200000. }
45 
46  def recalculate(self, flags):
47  if flags.Sim.CosmicPtSlice == 'Off':
48  if 'Muon' in flags.Sim.CosmicFilterVolumeNames:
49  self.xvert_low = -301700.
50  self.xvert_high = 298300.
51  self.zvert_low = -1000.*300.
52  self.zvert_high = 1000.*300.
53  self.radius = 20000.
54  if 'Pixel' in flags.Sim.CosmicFilterVolumeNames:
55  self.radius = 2000.
56  else:
57  n_value = flags.Sim.CosmicPtSlice
58  self.xvert_low = self.xvert_lowDict[n_value]
59  self.xvert_high = self.xvert_highDict[n_value]
60  self.zvert_low = self.zvert_lowDict[n_value]
61  self.zvert_high = self.zvert_highDict[n_value]
62  #self.radius =
63  self.emin = self.EminDict[n_value]
64  self.emax = self.EmaxDict[n_value]
65 
66  def CosmicEmin(self, flags):
67  """
68  """
69  self.recalculate(flags)
70  return self.emin
71 
72 
73  def CosmicEmax(self, flags):
74  """
75  """
76  self.recalculate(flags)
77  return self.emax
78 
79 
80  def CosmicLowVertex_X(self, flags):
81  """
82  """
83  self.recalculate(flags)
84  return self.xvert_low
85 
86 
87  def CosmicHighVertex_X(self, flags):
88  """
89  """
90  self.recalculate(flags)
91  return self.xvert_high
92 
93 
94  def CosmicLowVertex_Z(self, flags):
95  """
96  """
97  self.recalculate(flags)
98  return self.zvert_low
99 
100 
101  def CosmicHighVertex_Z(self, flags):
102  """
103  """
104  self.recalculate(flags)
105  return self.zvert_high
106 
107 
108  def CosmicRadius(self, flags):
109  """
110  """
111  self.recalculate(flags)
112  return self.radius
113 
114  def BedrockDX(self, flags):
115  """
116  """
117  self.recalculate(flags)
118  return (self.xvert_high - self.xvert_low)
119 
120  def BedrockDZ(self, flags):
121  """
122  """
123  self.recalculate(flags)
124  return (self.zvert_high - self.zvert_low)
125 
126  def reconfigureCavernGeometry(self, flags, cfg):
127  """
128  Note that in this coordinate frame the y-axis points upward
129  such that the cosmics arrive from upward to downward in y.
130  """
131  newSize = max( self.BedrockDX(flags) , self.BedrockDZ(flags) )
132  if (newSize > 350000.):
133  print ("Resizing bedrock (mm) to fit cosmic generator:",newSize)
134  GeoModelSvc = cfg.getService('GeoModelSvc')
135  if (newSize <= 500000) : GeoModelSvc.CavernInfraVersionOverride = 'CavernInfra-03-Bedrock500'
136  elif (newSize <= 1000000) : GeoModelSvc.CavernInfraVersionOverride = 'CavernInfra-03-Bedrock1000'
137  elif (newSize <= 1500000) : GeoModelSvc.CavernInfraVersionOverride = 'CavernInfra-03-Bedrock1500'
138  elif (newSize <= 2000000) : GeoModelSvc.CavernInfraVersionOverride = 'CavernInfra-03-Bedrock2000'
139  elif (newSize <= 3000000) : GeoModelSvc.CavernInfraVersionOverride = 'CavernInfra-03-Bedrock3000'
140  elif (newSize <= 4000000) : GeoModelSvc.CavernInfraVersionOverride = 'CavernInfra-03-Bedrock4000'
141  elif (newSize <= 5000000) : GeoModelSvc.CavernInfraVersionOverride = 'CavernInfra-03-Bedrock5000'
142  else :
143  print ("No need to resize the bedrock for cosmic generation")
144 
145 
146 
147 def CosmicGeneratorCfg(flags, name="CosmicGenerator", **kwargs):
148 
149  result = ComponentAccumulator()
150 
151  from AthenaServices.PartPropSvcConfig import PartPropSvcCfg
152  kwargs.setdefault('PartPropSvc', result.getPrimaryAndMerge(PartPropSvcCfg(flags)).name) # Property from GenBase
153 
154 
155  from RngComps.RngCompsConfig import AthRNGSvcCfg
156  kwargs.setdefault('RndmSvc', result.getPrimaryAndMerge(AthRNGSvcCfg(flags)).name)
157 
158  from CosmicGenerator.CosmicGeneratorConfig import CavernPropertyCalculator
159  theCavern = CavernPropertyCalculator()
160 
161 
173 
174  kwargs.setdefault('emin', theCavern.CosmicEmin(flags))
175  kwargs.setdefault('emax', theCavern.CosmicEmax(flags))
176  #kwargs.setdefault('emin', 10000) # default =10000 #10 GeV
177  #kwargs.setdefault('emax', 5000*1000) # 2 TeV - FIXME?!
178 
179  kwargs.setdefault('xvert_low', theCavern.CosmicLowVertex_X(flags) )
180  kwargs.setdefault('xvert_hig', theCavern.CosmicHighVertex_X(flags))
181  kwargs.setdefault('zvert_low', theCavern.CosmicLowVertex_Z(flags) )
182  kwargs.setdefault('zvert_hig', theCavern.CosmicHighVertex_Z(flags))
183  kwargs.setdefault('Radius', theCavern.CosmicRadius(flags))
184  kwargs.setdefault('yvert_val', 57300.+41000.)
185  kwargs.setdefault('ctcut', 0.)
186  kwargs.setdefault('OptimizeForCavern', True)
187  kwargs.setdefault('IPx', 0.)
188  kwargs.setdefault('IPy', 0.)
189  kwargs.setdefault('IPz', 0.)
190 
191  if len(flags.Sim.CosmicFilterVolumeNames)>0:
192  print ('Using %s Volume setup of Cosmic Generator...' % flags.Sim.CosmicFilterVolumeNames[0])
193  #special settings from Juerg Beringer
194  if 'Pixel' in flags.Sim.CosmicFilterVolumeNames:
195  kwargs.setdefault('doPathLengthCut', True) # Optimization based on box cut in pixel detector plane
196  kwargs.setdefault('energyCutThreshold', 100.) # - margin of error for energy loss calculation (in MeV)
197  kwargs.setdefault('doAimedAtPixelsCut', True) # Optimization based on box cut in pixel detector plane
198  kwargs.setdefault('pixelplane_maxx', 1150.) # - require |x| < value in mm
199  kwargs.setdefault('pixelplane_maxz', 1650.) # - require |y| < value in mm
200  kwargs.setdefault('doReweighting', True) # Whether to use reweighting for cosmic ray generation
201  kwargs.setdefault('rvert_max', 300000.) # - radius in mm for generating primary vertex
202 
203  # Random seeding
204  kwargs.setdefault("Dsid", flags.Input.RunNumbers[0]) # Could (should?) set this as Input.MCChannelNumber currently trying to match legacy config
205  #kwargs.setdefault("RandomSeed", flags.Sim.RandomSeedOffset) # No such flag in ConfigFlags. TODO Add?
206 
207  result.addEventAlgo(CompFactory.CosmicGenerator('CosmicGenerator', **kwargs))
208  return result
209 
210 
212  theCavern = CavernPropertyCalculator()
213  if flags.Sim.CosmicPtSlice != 'NONE':
214  print ("Configuring cosmic pT slice: %s" % flags.Sim.CosmicPtSlice)
215  theCavern.reconfigureCavernGeometry(flags,cfg)
CosmicGeneratorConfig.CavernPropertyCalculator.CosmicLowVertex_X
def CosmicLowVertex_X(self, flags)
Definition: CosmicGeneratorConfig.py:80
CosmicGeneratorConfig.CavernPropertyCalculator.emax
int emax
Definition: CosmicGeneratorConfig.py:14
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CosmicGeneratorConfig.CavernPropertyCalculator.xvert_low
int xvert_low
Definition: CosmicGeneratorConfig.py:8
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
CosmicGeneratorConfig.CavernPropertyCalculator.recalculate
def recalculate(self, flags)
Definition: CosmicGeneratorConfig.py:46
CosmicGeneratorConfig.CavernPropertyCalculator.reconfigureCavernGeometry
def reconfigureCavernGeometry(self, flags, cfg)
Definition: CosmicGeneratorConfig.py:126
CosmicGeneratorConfig.CavernPropertyCalculator.BedrockDZ
def BedrockDZ(self, flags)
Definition: CosmicGeneratorConfig.py:120
CosmicGeneratorConfig.CavernPropertyCalculator
Definition: CosmicGeneratorConfig.py:6
CosmicGeneratorConfig.CavernPropertyCalculator.BedrockDX
def BedrockDX(self, flags)
Definition: CosmicGeneratorConfig.py:114
CosmicGeneratorConfig.CavernPropertyCalculator.xvert_lowDict
dictionary xvert_lowDict
Definition: CosmicGeneratorConfig.py:25
CosmicGeneratorConfig.CavernPropertyCalculator.EminDict
dictionary EminDict
Definition: CosmicGeneratorConfig.py:15
CosmicGeneratorConfig.CavernPropertyCalculator.CosmicHighVertex_Z
def CosmicHighVertex_Z(self, flags)
Definition: CosmicGeneratorConfig.py:101
CosmicGeneratorConfig.CavernPropertyCalculator.zvert_low
int zvert_low
Definition: CosmicGeneratorConfig.py:10
CosmicGeneratorConfig.postIncludeCosmicGenerator
def postIncludeCosmicGenerator(flags, cfg)
Definition: CosmicGeneratorConfig.py:211
CosmicGeneratorConfig.CavernPropertyCalculator.xvert_highDict
dictionary xvert_highDict
Definition: CosmicGeneratorConfig.py:30
CosmicGeneratorConfig.CavernPropertyCalculator.CosmicEmin
def CosmicEmin(self, flags)
Definition: CosmicGeneratorConfig.py:66
CosmicGeneratorConfig.CavernPropertyCalculator.emin
int emin
Definition: CosmicGeneratorConfig.py:13
CosmicGeneratorConfig.CavernPropertyCalculator.zvert_lowDict
dictionary zvert_lowDict
Definition: CosmicGeneratorConfig.py:35
CosmicGeneratorConfig.CavernPropertyCalculator.zvert_highDict
dictionary zvert_highDict
Definition: CosmicGeneratorConfig.py:40
python.PartPropSvcConfig.PartPropSvcCfg
def PartPropSvcCfg(flags, **kwargs)
Definition: PartPropSvcConfig.py:6
CosmicGeneratorConfig.CavernPropertyCalculator.CosmicLowVertex_Z
def CosmicLowVertex_Z(self, flags)
Definition: CosmicGeneratorConfig.py:94
CosmicGeneratorConfig.CavernPropertyCalculator.radius
int radius
Definition: CosmicGeneratorConfig.py:12
CosmicGeneratorConfig.CavernPropertyCalculator.CosmicRadius
def CosmicRadius(self, flags)
Definition: CosmicGeneratorConfig.py:108
CosmicGeneratorConfig.CavernPropertyCalculator.zvert_high
int zvert_high
Definition: CosmicGeneratorConfig.py:11
CosmicGeneratorConfig.CavernPropertyCalculator.EmaxDict
dictionary EmaxDict
Definition: CosmicGeneratorConfig.py:20
CosmicGeneratorConfig.CavernPropertyCalculator.CosmicEmax
def CosmicEmax(self, flags)
Definition: CosmicGeneratorConfig.py:73
CosmicGeneratorConfig.CosmicGeneratorCfg
def CosmicGeneratorCfg(flags, name="CosmicGenerator", **kwargs)
Note that in this coordinate frame the y-axis points upward such that the cosmics arrive from upward ...
Definition: CosmicGeneratorConfig.py:147
pickleTool.object
object
Definition: pickleTool.py:30
CosmicGeneratorConfig.CavernPropertyCalculator.xvert_high
int xvert_high
Definition: CosmicGeneratorConfig.py:9
CosmicGeneratorConfig.CavernPropertyCalculator.CosmicHighVertex_X
def CosmicHighVertex_X(self, flags)
Definition: CosmicGeneratorConfig.py:87
RngCompsConfig.AthRNGSvcCfg
def AthRNGSvcCfg(flags, name="AthRNGSvc")
Definition: RngCompsConfig.py:51