Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Functions
StripDefectsEmulatorPostInclude Namespace Reference

Functions

def emulateITkStripDefects (flags, cfg, float StripDefectProb=1e-2, float ModuleDefectProb=1e-2, float NoiseProb=0., int MaxRandomPositionAttempts=10, bool FillHistogramsPerPattern=True, bool FillEtaPhiHistogramsPerPattern=True, str HistogramGroupName="ITkStripDefects", str HistogramFileName=None, PropagateDefectsToStatus=True)
 
def emulateITkStripDefectsDefault (flags, cfg, float StripDefectProb=1e-2, float ModuleDefectProb=1e-2, float NoiseProb=0., str HistogramFileName=None, PropagateDefectsToStatus=True)
 

Function Documentation

◆ emulateITkStripDefects()

def StripDefectsEmulatorPostInclude.emulateITkStripDefects (   flags,
  cfg,
float  StripDefectProb = 1e-2,
float  ModuleDefectProb = 1e-2,
float  NoiseProb = 0.,
int  MaxRandomPositionAttempts = 10,
bool  FillHistogramsPerPattern = True,
bool  FillEtaPhiHistogramsPerPattern = True,
str  HistogramGroupName = "ITkStripDefects",
str  HistogramFileName = None,
  PropagateDefectsToStatus = True 
)
Schedule algorithms to create ITk strip defect conditions data and to emulate
defects by dropping ITk strip RDOs overlapping with such defects. ModuleDefectProb controls the number of
defect strip modules and DefectProb the number of defect strips. If a strip group is overlapping with
a single strip defect, the strip group will be split.

Definition at line 10 of file StripDefectsEmulatorPostInclude.py.

10 def emulateITkStripDefects(flags,
11  cfg,
12  StripDefectProb: float=1e-2,
13  ModuleDefectProb: float=1e-2,
14  NoiseProb: float=0.,
15  MaxRandomPositionAttempts: int=10,
16  FillHistogramsPerPattern: bool=True,
17  FillEtaPhiHistogramsPerPattern: bool=True,
18  HistogramGroupName: str="ITkStripDefects",
19  HistogramFileName: str=None,
20  PropagateDefectsToStatus=True) :
21  """
22  Schedule algorithms to create ITk strip defect conditions data and to emulate
23  defects by dropping ITk strip RDOs overlapping with such defects. ModuleDefectProb controls the number of
24  defect strip modules and DefectProb the number of defect strips. If a strip group is overlapping with
25  a single strip defect, the strip group will be split.
26  """
27 
28  from InDetDefectsEmulation.StripDefectsEmulatorConfig import (
29  ITkStripDefectsEmulatorCondAlgCfg,
30  ITkStripDefectsEmulatorAlgCfg,
31  ITkStripDefectsEmulatorToDetectorElementStatusCondAlgCfg,
32  DefectsHistSvcCfg,
33  moduleDefect,
34  combineModuleDefects
35  )
36  from AthenaCommon.Constants import INFO
37 
38  if HistogramFileName is None or len(HistogramFileName) ==0 :
39  HistogramGroupName = None
40  if HistogramGroupName is not None :
41  cfg.merge( DefectsHistSvcCfg(flags, HistogramGroup=HistogramGroupName, FileName=HistogramFileName))
42 
43  # dummy "fractions" for strips, module pattern are just examples, and currently all
44  # modules get the same defect probabilities irrespectively of e.g. strip length.
45  module_pattern, module_defect_prob, fractions, ignore_NoiseProbability,ignore_NoiseShape, cornerDefectParam, cornerDefectFractions = combineModuleDefects([
46  moduleDefect(bec=[-2,-2],layer=[0,99], phi_range=[-99,99],eta_range=[-99,99], # select all endcap A modules
47  side_range=[0,0,1,1], # randomly mark sides as defect. With [0,1] Both sides are marked as defect
48  all_rows=False, # if True all rows of the same un-split module are marked as defect
49  probability=[ModuleDefectProb, # probability of a module to be defect
50  StripDefectProb # probability of a strip to be defect
51  ]),
52  moduleDefect(bec=[-1,1],layer=[0,1], phi_range=[-99,99],eta_range=[-99,99], # select all barrel, layer 0,1 modules
53  side_range=[0,0,1,1], # randomly mark sides as defect. With [0,1] Both sides are marked as defect
54  all_rows=False, # if True all rows of the same un-split module are marked as defect
55  probability=[ModuleDefectProb, # probability of a module to be defect
56  StripDefectProb # probability of a strip to be defect
57  ]),
58  moduleDefect(bec=[-1,1],layer=[2,99], phi_range=[-99,99],eta_range=[-99,99], # select all other barrel layers
59  side_range=[0,0,1,1], # randomly mark sides as defect. With [0,1] Both sides are marked as defect
60  all_rows=False, # if True all rows of the same un-split module are marked as defect
61  probability=[ModuleDefectProb, # probability of a module to be defect
62  StripDefectProb # probability of a strip to be defect
63  ]),
64  moduleDefect(bec=[2,2],layer=[0,99], phi_range=[-99,99],eta_range=[-99,99], # select all endcap C modules
65  side_range=[0,0,1,1], # randomly mark sides as defect. With [0,1] Both sides are marked as defect
66  all_rows=False, # if True all rows of the same un-split module are marked as defect
67  probability=[ModuleDefectProb, # probability of a module to be defect
68  StripDefectProb # probability of a strip to be defect
69  ])])
70 
71  if NoiseProb > 0. :
72  # strip noise
73  import math
74  def norm(dist) :
75  scale = sum(dist)
76  return [elm/scale if scale > 0. else 0. for elm in dist]
77  def gaussDist(mean, width, n) :
78  scale = -1./(2*width)
79  return norm([ math.exp( scale *math.pow(i - mean,2.) ) for i in range(0,n) ])
80  # Gaussian distribution between 1 and 2
81  time_bin_dist = gaussDist(1.51,0.03,3)
82 
83  # different noise per module of different strip length
84  defects=[]
85  for length in [15093,18093,18981,23981,24092,24180,26223,27093,28980,30807,30808,31981,32223,40161,48360,54580,54581,60162] :
86  # assume noise scales with strip length but there is a constant noise
87  defects += [ moduleDefect(column_or_strip_length=[length-1,length+1],
88  probability=[],
89  noiseProbability=NoiseProb * 0.5*( 1 + length / 37627.5 ),
90  noiseShape=time_bin_dist)]
91  module_pattern_noise, ignore_module_defect_prob, ignore_fractions, NoiseProbability,NoiseShape,cornerDefectParam,cornerDefectFractions = combineModuleDefects(defects)
92  else :
93  module_pattern_noise=[]
94  NoiseProbability=[]
95  NoiseShape=[]
96 
97  # schedule custom defects generating conditions alg
98  cfg.merge( ITkStripDefectsEmulatorCondAlgCfg(flags,
99  # to enable histogramming:
100  HistogramGroupName=f"/{HistogramGroupName}/StripEmulatedDefects/" if HistogramGroupName is not None else "",
101  MaxRandomPositionAttempts=MaxRandomPositionAttempts,
102  ModulePatterns=module_pattern,
103  DefectProbabilities=module_defect_prob,
104  CornerDefectParamsPerPattern=[],
105  NCornerDefectFractionsPerPattern=[],
106  FillHistogramsPerPattern=FillHistogramsPerPattern,
107  FillEtaPhiHistogramsPerPattern=FillEtaPhiHistogramsPerPattern,
108  WriteKey="ITkStripEmulatedDefects", # the default should match the key below
109  ))
110 
111  # schedule the algorithm which drops elements from the ITk Pixel RDO collection
112  cfg.merge( ITkStripDefectsEmulatorAlgCfg(flags,
113  # prevent default cond alg from being scheduled :
114  EmulatedDefectsKey="ITkStripEmulatedDefects",
115  ModulePatterns=module_pattern_noise,
116  NoiseProbability = NoiseProbability,
117  NoiseShape = NoiseShape,
118  # to enable histogramming:
119  HistogramGroupName=f"/{HistogramGroupName}/StripRejectedRDOs/" if HistogramGroupName is not None else "",
120  OutputLevel=INFO))
121 
122  if PropagateDefectsToStatus :
123  # propagate defects to detector element status
125  name="ITkStripDefectsEmulatorToDetectorElementStatusCondAlg",
126  EmulatedDefectsKey="ITkStripEmulatedDefects",
127  WriteKey="ITkStripDetectorElementStatusFromEmulatedDefects"))
128  strip_det_el_status_cond_alg=cfg.getCondAlgo("ITkStripDetectorElementStatusCondAlgNoByteStreamErrors")
129  strip_det_el_status_cond_alg.ConditionsSummaryTool.SCTDetElStatusCondDataBaseKey="ITkStripDetectorElementStatusFromEmulatedDefects"
130 

◆ emulateITkStripDefectsDefault()

def StripDefectsEmulatorPostInclude.emulateITkStripDefectsDefault (   flags,
  cfg,
float  StripDefectProb = 1e-2,
float  ModuleDefectProb = 1e-2,
float  NoiseProb = 0.,
str  HistogramFileName = None,
  PropagateDefectsToStatus = True 
)

Definition at line 131 of file StripDefectsEmulatorPostInclude.py.

132  cfg,
133  StripDefectProb: float=1e-2,
134  ModuleDefectProb: float=1e-2,
135  NoiseProb: float=0.,
136  HistogramFileName: str=None,
137  PropagateDefectsToStatus=True) :
138  emulateITkStripDefects(flags,cfg,
139  StripDefectProb=StripDefectProb,
140  ModuleDefectProb=ModuleDefectProb,
141  NoiseProb=NoiseProb,
142  HistogramFileName=HistogramFileName,
143  PropagateDefectsToStatus=PropagateDefectsToStatus)
PixelDefectsEmulatorConfig.DefectsHistSvcCfg
ComponentAccumulator DefectsHistSvcCfg(flags, str HistogramGroup="PixelDefects", str FileName='pixel_defects.root')
Definition: PixelDefectsEmulatorConfig.py:23
StripDefectsEmulatorConfig.moduleDefect
def moduleDefect(bec=[-2, 2], layer=[0, 8], eta_range=[-99, 99], phi_range=[-99, 99], columns_or_strips=[0, 2000], column_or_strip_length=[0, 1000000], side_range=[0, 1], all_rows=True, probability=[1e-2], fractionsOfNDefects=[], noiseProbability=None, noiseShape=[], cornerDefectParam=None, cornerDefectNCornerFractions=None)
Definition: StripDefectsEmulatorConfig.py:50
PlotCalibFromCool.norm
norm
Definition: PlotCalibFromCool.py:100
StripDefectsEmulatorPostInclude.emulateITkStripDefects
def emulateITkStripDefects(flags, cfg, float StripDefectProb=1e-2, float ModuleDefectProb=1e-2, float NoiseProb=0., int MaxRandomPositionAttempts=10, bool FillHistogramsPerPattern=True, bool FillEtaPhiHistogramsPerPattern=True, str HistogramGroupName="ITkStripDefects", str HistogramFileName=None, PropagateDefectsToStatus=True)
Definition: StripDefectsEmulatorPostInclude.py:10
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
StripDefectsEmulatorConfig.combineModuleDefects
def combineModuleDefects(defects)
Definition: StripDefectsEmulatorConfig.py:138
StripDefectsEmulatorConfig.ITkStripDefectsEmulatorCondAlgCfg
ComponentAccumulator ITkStripDefectsEmulatorCondAlgCfg(flags, str name="ITkStripDefectsEmulatorCondAlg", **dict kwargs)
Definition: StripDefectsEmulatorConfig.py:198
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
StripDefectsEmulatorConfig.ITkStripDefectsEmulatorToDetectorElementStatusCondAlgCfg
ComponentAccumulator ITkStripDefectsEmulatorToDetectorElementStatusCondAlgCfg(flags, str name="ITkStripDefectsEmulatorToDetectorElementStatusCondAlgCfg", **dict kwargs)
Definition: StripDefectsEmulatorConfig.py:262
StripDefectsEmulatorPostInclude.emulateITkStripDefectsDefault
def emulateITkStripDefectsDefault(flags, cfg, float StripDefectProb=1e-2, float ModuleDefectProb=1e-2, float NoiseProb=0., str HistogramFileName=None, PropagateDefectsToStatus=True)
Definition: StripDefectsEmulatorPostInclude.py:131
StripDefectsEmulatorConfig.ITkStripDefectsEmulatorAlgCfg
ComponentAccumulator ITkStripDefectsEmulatorAlgCfg(flags, str name="ITkStripDefectsEmulatorAlg", **dict kwargs)
Definition: StripDefectsEmulatorConfig.py:238