ATLAS Offline Software
Functions
PixelDefectsEmulatorPostInclude Namespace Reference

Functions

def emulateITkPixelDefects (flags, cfg, ModulePatterns=[[-2, 2, 0, 99,-99, 99,-99, 99, 0, 9999, 0, 1, 0]], DefectProbabilities=[[0., 1e-2, 1e-1, 0.]], NDefectFractionsPerPattern=[[1.,-1, 1.]], NoiseProbability=[], NoiseShape=[], CornerDefectParamsPerPattern=[], NCornerDefectFractionsPerPattern=[], RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, FillHistogramsPerPattern=False, FillEtaPhiHistogramsPerPattern=False, int MaxRandomPositionAttempts=10, str HistogramGroupName="ITkPixelDefects", str HistogramFileName="itk_pixel_defects_opt1.root", PropagateDefectsToStatus=True)
 
def emulatePixelDefects (flags, cfg, ModulePatterns=None, DefectProbabilities=None, NDefectFractionsPerPattern=None, RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, FillHistogramsPerPattern=False, FillEtaPhiHistogramsPerPattern=False, str HistogramGroupName="PixelDefects", str HistogramFileName="pixel_defects.root")
 
def poissonFractions (cc_defect_prob=1e-1, max_n=5)
 
def quadProb (circuit_prob)
 
def fractionsForExactlyNCoreColumnDefects (ExactlyNCoreColumnDefects=1)
 
def makeITkDefectsParams (quad_cc_defect_prob, quad_fractions, circuit_cc_defect_prob, circuit_fractions, pixel_defect_prob=1e-2, module_defect_prob=0., cornerDefectProb=0., noiseProbability=None, noiseShape=[])
 
def makeITkPixelNoise (noiseProb=0.)
 
def emulateITkPixelDefectsOneCC (flags, cfg, FrontEndCCDefectProb=0.1, PixelDefectProb=1e-2, NumberOfCCDefects=1, ModuleDefectProb=0., CornerDefectProb=0., NoiseProb=0., RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, PropagateDefectsToStatus=True, HistogramFileName=None)
 
def emulateITkPixelDefectsPoisson (flags, cfg, FrontEndCCDefectProb=0.1, PixelDefectProb=1e-2, ModuleDefectProb=0., CornerDefectProb=0., NoiseProb=0., RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, PropagateDefectsToStatus=True, HistogramFileName=None)
 
def emulateITkPixelDefectsDefault (flags, cfg, FrontEndCCDefectProb=0.1, PixelDefectProb=1e-2, ModuleDefectProb=1e-2, CornerDefectProb=15e-2, NoiseProb=0., RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, PropagateDefectsToStatus=True, HistogramFileName=None)
 

Function Documentation

◆ emulateITkPixelDefects()

def PixelDefectsEmulatorPostInclude.emulateITkPixelDefects (   flags,
  cfg,
  ModulePatterns = [[-2,2,0,99,-99,99,-99,99,0,9999,0,1,0]],
  DefectProbabilities = [[0.,1e-2,1e-1,0.]],
  NDefectFractionsPerPattern = [[1.,-1, 1.]],
  NoiseProbability = [],
  NoiseShape = [],
  CornerDefectParamsPerPattern = [],
  NCornerDefectFractionsPerPattern = [],
  RngPerDefectType = False,
  DefectsInputFiles = [],
  DefectsOutputFile = None,
  FillHistogramsPerPattern = False,
  FillEtaPhiHistogramsPerPattern = False,
int  MaxRandomPositionAttempts = 10,
str  HistogramGroupName = "ITkPixelDefects",
str  HistogramFileName = "itk_pixel_defects_opt1.root",
  PropagateDefectsToStatus = True 
)
Schedule conditions algorithm for emulated ITk pixel defects, and algorithms to drop RDOs overlapping with the emulated defects.
ModulePattern: criteria to match modules, which are lists of n-tuples where every two numbers of each n-tuple define a range
               to match parts of module identifiers (barrel/ec, layer/disk, eta., phi, columns, side) plus a flag (last
               element of each n-tuple), which is unused for pixel.
DefectProbabilities: list of n-tuples per criterion containing 4 probabilities: module, pixel to be defect, a module
                     to have at least one core column defect, circuit defect.
NDefectFractionsPerPattern: Fractions of exactly n-group defects (core-column, circuit) under condition that there is at least one
                            such group defect. There must be one n-tuple with fractions per criterion, and each fraction
                            n-tuple must contain for each group defect probability a non empty set of fractions of exactly 1, ... n defects.
                            Fractions for different group defects are separated by -1. There should be two sequences of
                            positive fractions separated by -1.
NoiseProbability: Empty or probabilities of a pixel to produce a spurious hit.
NoiseShape: binned PDF (i.e. list of fractions) to create tot values for spurious hits.
CornerDefectParamsPerPattern: parameters for corner defects per pattern can be created with e.g. makeCornerDefectParam
NCornerDefectFractionsPerPattern: fractions of 1,..4 corner defects
FillHistogramsPerPattern: if True histograms are filled per module pattern
FillEtaPhiHistogramsPerPattern: if True also fill xy, and rz histograms of defects per module.
HistogramGroupName: None (disables histogramming) or the histogram group name must be unique
HistogramFileName: None (disables histogramming) or a file name for writing the histograms.

Definition at line 38 of file PixelDefectsEmulatorPostInclude.py.

38 def emulateITkPixelDefects(flags,
39  cfg,
40  ModulePatterns=[[-2,2,0,99,-99,99,-99,99,0,9999,0,1,0]],
41  DefectProbabilities=[[0.,1e-2,1e-1,0.]],
42  NDefectFractionsPerPattern=[[1.,-1, 1.]],
43  NoiseProbability=[],
44  NoiseShape=[],
45  CornerDefectParamsPerPattern=[],
46  NCornerDefectFractionsPerPattern=[],
47  RngPerDefectType=False,
48  DefectsInputFiles=[],
49  DefectsOutputFile=None,
50  FillHistogramsPerPattern=False,
51  FillEtaPhiHistogramsPerPattern=False,
52  MaxRandomPositionAttempts: int=10,
53  HistogramGroupName: str="ITkPixelDefects",
54  HistogramFileName: str="itk_pixel_defects_opt1.root",
55  PropagateDefectsToStatus=True) :
56  """
57  Schedule conditions algorithm for emulated ITk pixel defects, and algorithms to drop RDOs overlapping with the emulated defects.
58  ModulePattern: criteria to match modules, which are lists of n-tuples where every two numbers of each n-tuple define a range
59  to match parts of module identifiers (barrel/ec, layer/disk, eta., phi, columns, side) plus a flag (last
60  element of each n-tuple), which is unused for pixel.
61  DefectProbabilities: list of n-tuples per criterion containing 4 probabilities: module, pixel to be defect, a module
62  to have at least one core column defect, circuit defect.
63  NDefectFractionsPerPattern: Fractions of exactly n-group defects (core-column, circuit) under condition that there is at least one
64  such group defect. There must be one n-tuple with fractions per criterion, and each fraction
65  n-tuple must contain for each group defect probability a non empty set of fractions of exactly 1, ... n defects.
66  Fractions for different group defects are separated by -1. There should be two sequences of
67  positive fractions separated by -1.
68  NoiseProbability: Empty or probabilities of a pixel to produce a spurious hit.
69  NoiseShape: binned PDF (i.e. list of fractions) to create tot values for spurious hits.
70  CornerDefectParamsPerPattern: parameters for corner defects per pattern can be created with e.g. makeCornerDefectParam
71  NCornerDefectFractionsPerPattern: fractions of 1,..4 corner defects
72  FillHistogramsPerPattern: if True histograms are filled per module pattern
73  FillEtaPhiHistogramsPerPattern: if True also fill xy, and rz histograms of defects per module.
74  HistogramGroupName: None (disables histogramming) or the histogram group name must be unique
75  HistogramFileName: None (disables histogramming) or a file name for writing the histograms.
76  """
77 
78  from InDetDefectsEmulation.PixelDefectsEmulatorConfig import (
79  ITkPixelDefectsEmulatorCondAlgCfg,
80  ITkPixelDefectsEmulatorAlgCfg,
81  ITkPixelDefectsEmulatorToDetectorElementStatusCondAlgCfg,
82  DefectsHistSvcCfg
83  )
84  from AthenaCommon.Constants import INFO
85 
86  if HistogramFileName is None or len(HistogramFileName) ==0 :
87  HistogramGroupName = None
88  if HistogramGroupName is not None :
89  cfg.merge( DefectsHistSvcCfg(flags, HistogramGroup=HistogramGroupName, FileName=HistogramFileName))
90 
91  # schedule custom defects generating conditions alg
92  cfg.merge( ITkPixelDefectsEmulatorCondAlgCfg(flags,
93  # to enable histogramming:
94  HistogramGroupName=f"/{HistogramGroupName}/EmulatedDefects/" if HistogramGroupName is not None else "",
95  ModulePatterns = ModulePatterns,
96  DefectProbabilities = DefectProbabilities,
97  NDefectFractionsPerPattern = NDefectFractionsPerPattern,
98  MaxRandomPositionAttempts=MaxRandomPositionAttempts,
99  CornerDefectParamsPerPattern=CornerDefectParamsPerPattern,
100  NCornerDefectFractionsPerPattern=NCornerDefectFractionsPerPattern,
101  RngPerDefectType=RngPerDefectType,
102  DefectsInputFiles=DefectsInputFiles,
103  DefectsOutputFile=DefectsOutputFile,
104  FillHistogramsPerPattern=FillHistogramsPerPattern,
105  FillEtaPhiHistogramsPerPattern=FillEtaPhiHistogramsPerPattern,
106  CheckerBoardDefects=False,
107  OddColToggle=False,
108  OddRowToggle=False,
109  WriteKey="ITkPixelEmulatedDefects", # the default should match the key below
110  ))
111 
112  # schedule the algorithm which drops elements from the ITk Pixel RDO collection
113  cfg.merge( ITkPixelDefectsEmulatorAlgCfg(flags,
114  # prevent default cond alg from being scheduled :
115  EmulatedDefectsKey="ITkPixelEmulatedDefects",
116  ModulePatterns = ModulePatterns,
117  NoiseProbability = NoiseProbability,
118  NoiseShape = NoiseShape,
119  # to enable histogramming:
120  HistogramGroupName=f"/{HistogramGroupName}/RejectedRDOs/" if HistogramGroupName is not None else "",
121  OutputLevel=INFO))
122 
123  if PropagateDefectsToStatus :
124  # propagate defects to detector element status
126  name="ITkPixelDefectsEmulatorToDetectorElementStatusCondAlg",
127  EmulatedDefectsKey="ITkPixelEmulatedDefects",
128  WriteKey="ITkPixelDetectorElementStatusFromEmulatedDefects"))
129  pixel_det_el_status_cond_alg=cfg.getCondAlgo("ITkPixelDetectorElementStatusCondAlgNoByteStreamErrors")
130  pixel_det_el_status_cond_alg.ConditionsSummaryTool.PixelDetElStatusCondDataBaseKey="ITkPixelDetectorElementStatusFromEmulatedDefects"
131 

◆ emulateITkPixelDefectsDefault()

def PixelDefectsEmulatorPostInclude.emulateITkPixelDefectsDefault (   flags,
  cfg,
  FrontEndCCDefectProb = 0.1,
  PixelDefectProb = 1e-2,
  ModuleDefectProb = 1e-2,
  CornerDefectProb = 15e-2,
  NoiseProb = 0.,
  RngPerDefectType = False,
  DefectsInputFiles = [],
  DefectsOutputFile = None,
  PropagateDefectsToStatus = True,
  HistogramFileName = None 
)
Enables all defects according to the current expectation.

Definition at line 427 of file PixelDefectsEmulatorPostInclude.py.

428  cfg,
429  FrontEndCCDefectProb=0.1,
430  PixelDefectProb=1e-2,
431  ModuleDefectProb=1e-2,
432  CornerDefectProb=15e-2,
433  NoiseProb=0.,
434  RngPerDefectType=False,
435  DefectsInputFiles=[],
436  DefectsOutputFile=None,
437  PropagateDefectsToStatus=True,
438  HistogramFileName=None) :
439  """
440  Enables all defects according to the current expectation.
441  """
443  FrontEndCCDefectProb,
444  PixelDefectProb,
445  ModuleDefectProb,
446  CornerDefectProb,
447  NoiseProb,
448  RngPerDefectType=RngPerDefectType,
449  DefectsInputFiles=DefectsInputFiles,
450  DefectsOutputFile=DefectsOutputFile,
451  PropagateDefectsToStatus=PropagateDefectsToStatus,
452  HistogramFileName=HistogramFileName)

◆ emulateITkPixelDefectsOneCC()

def PixelDefectsEmulatorPostInclude.emulateITkPixelDefectsOneCC (   flags,
  cfg,
  FrontEndCCDefectProb = 0.1,
  PixelDefectProb = 1e-2,
  NumberOfCCDefects = 1,
  ModuleDefectProb = 0.,
  CornerDefectProb = 0.,
  NoiseProb = 0.,
  RngPerDefectType = False,
  DefectsInputFiles = [],
  DefectsOutputFile = None,
  PropagateDefectsToStatus = True,
  HistogramFileName = None 
)
Create exactly one core column defect per module where the probability is given
by module_prob, and create single pixel defects according to pixel_defect_prob

Definition at line 332 of file PixelDefectsEmulatorPostInclude.py.

333  cfg,
334  FrontEndCCDefectProb=0.1,
335  PixelDefectProb=1e-2,
336  NumberOfCCDefects=1,
337  ModuleDefectProb=0.,
338  CornerDefectProb=0.,
339  NoiseProb=0.,
340  RngPerDefectType=False,
341  DefectsInputFiles=[],
342  DefectsOutputFile=None,
343  PropagateDefectsToStatus=True,
344  HistogramFileName=None) :
345  """
346  Create exactly one core column defect per module where the probability is given
347  by module_prob, and create single pixel defects according to pixel_defect_prob
348  """
349  noiseProbabilitySingle,noiseShapeSingle = makeITkPixelNoise(NoiseProb)
350  fractions=fractionsForExactlyNCoreColumnDefects(NumberOfCCDefects)
351  ModulePatterns, DefectProbabilities, NDefectFractionsPerPattern, NoiseProbability, NoiseShape,cornerDefectParam,cornerDefectFractions = makeITkDefectsParams(
352  quad_cc_defect_prob=quadProb(FrontEndCCDefectProb),
353  quad_fractions=fractions, # same fractions for quads and other modules
354  circuit_cc_defect_prob=FrontEndCCDefectProb,
355  circuit_fractions=fractions,
356  pixel_defect_prob=PixelDefectProb,
357  module_defect_prob=ModuleDefectProb,
358  cornerDefectProb=CornerDefectProb,
359  noiseProbability=noiseProbabilitySingle,
360  noiseShape=noiseShapeSingle)
361 
362  return emulateITkPixelDefects(flags,
363  cfg,
364  ModulePatterns=ModulePatterns,
365  DefectProbabilities=DefectProbabilities,
366  NDefectFractionsPerPattern=NDefectFractionsPerPattern,
367  NoiseProbability=NoiseProbability,
368  NoiseShape=NoiseShape,
369  CornerDefectParamsPerPattern=cornerDefectParam,
370  NCornerDefectFractionsPerPattern=cornerDefectFractions,
371  RngPerDefectType=RngPerDefectType,
372  DefectsInputFiles=DefectsInputFiles,
373  DefectsOutputFile=DefectsOutputFile,
374  FillHistogramsPerPattern=True,
375  FillEtaPhiHistogramsPerPattern=True,
376  PropagateDefectsToStatus=PropagateDefectsToStatus,
377  HistogramFileName=HistogramFileName)
378 
379 

◆ emulateITkPixelDefectsPoisson()

def PixelDefectsEmulatorPostInclude.emulateITkPixelDefectsPoisson (   flags,
  cfg,
  FrontEndCCDefectProb = 0.1,
  PixelDefectProb = 1e-2,
  ModuleDefectProb = 0.,
  CornerDefectProb = 0.,
  NoiseProb = 0.,
  RngPerDefectType = False,
  DefectsInputFiles = [],
  DefectsOutputFile = None,
  PropagateDefectsToStatus = True,
  HistogramFileName = None 
)
Create Poisson distributed  core column defects per module where the probability for at least one
core column defect is given by front_end_cc_defect_prob for single chip modules and larger for
quads, respectively. Single pixel defects are controlled by pixel_defect_prob

Definition at line 380 of file PixelDefectsEmulatorPostInclude.py.

381  cfg,
382  FrontEndCCDefectProb=0.1,
383  PixelDefectProb=1e-2,
384  ModuleDefectProb=0.,
385  CornerDefectProb=0.,
386  NoiseProb=0.,
387  RngPerDefectType=False,
388  DefectsInputFiles=[],
389  DefectsOutputFile=None,
390  PropagateDefectsToStatus=True,
391  HistogramFileName=None) :
392  """
393  Create Poisson distributed core column defects per module where the probability for at least one
394  core column defect is given by front_end_cc_defect_prob for single chip modules and larger for
395  quads, respectively. Single pixel defects are controlled by pixel_defect_prob
396  """
397  noiseProbabilitySingle,noiseShapeSingle = makeITkPixelNoise(NoiseProb)
398  quad_prob=quadProb(FrontEndCCDefectProb)
399  ModulePatterns, DefectProbabilities, NDefectFractionsPerPattern, NoiseProbability, NoiseShape,cornerDefectParam,cornerDefectFractions = makeITkDefectsParams(
400  quad_cc_defect_prob=quad_prob,
401  quad_fractions=poissonFractions(quad_prob),
402  circuit_cc_defect_prob=FrontEndCCDefectProb,
403  circuit_fractions=poissonFractions(FrontEndCCDefectProb),
404  pixel_defect_prob=PixelDefectProb,
405  module_defect_prob=ModuleDefectProb,
406  cornerDefectProb=CornerDefectProb,
407  noiseProbability=noiseProbabilitySingle,
408  noiseShape=noiseShapeSingle)
409 
410  return emulateITkPixelDefects(flags,
411  cfg,
412  ModulePatterns=ModulePatterns,
413  DefectProbabilities=DefectProbabilities,
414  NDefectFractionsPerPattern=NDefectFractionsPerPattern,
415  NoiseProbability=NoiseProbability,
416  NoiseShape=NoiseShape,
417  CornerDefectParamsPerPattern=cornerDefectParam,
418  NCornerDefectFractionsPerPattern=cornerDefectFractions,
419  RngPerDefectType=RngPerDefectType,
420  DefectsInputFiles=DefectsInputFiles,
421  DefectsOutputFile=DefectsOutputFile,
422  FillHistogramsPerPattern=True,
423  FillEtaPhiHistogramsPerPattern=True,
424  PropagateDefectsToStatus=PropagateDefectsToStatus,
425  HistogramFileName=HistogramFileName)
426 

◆ emulatePixelDefects()

def PixelDefectsEmulatorPostInclude.emulatePixelDefects (   flags,
  cfg,
  ModulePatterns = None,
  DefectProbabilities = None,
  NDefectFractionsPerPattern = None,
  RngPerDefectType = False,
  DefectsInputFiles = [],
  DefectsOutputFile = None,
  FillHistogramsPerPattern = False,
  FillEtaPhiHistogramsPerPattern = False,
str  HistogramGroupName = "PixelDefects",
str  HistogramFileName = "pixel_defects.root" 
)
Schedule algorithms to emulate run3 pixel defects, and algorithm to drop RDOs which overlap with these defects

Definition at line 132 of file PixelDefectsEmulatorPostInclude.py.

132 def emulatePixelDefects(flags,
133  cfg,
134  ModulePatterns=None,
135  DefectProbabilities=None,
136  NDefectFractionsPerPattern=None,
137  RngPerDefectType=False,
138  DefectsInputFiles=[],
139  DefectsOutputFile=None,
140  FillHistogramsPerPattern=False,
141  FillEtaPhiHistogramsPerPattern=False,
142  HistogramGroupName: str="PixelDefects",
143  HistogramFileName: str="pixel_defects.root") :
144  """
145  Schedule algorithms to emulate run3 pixel defects, and algorithm to drop RDOs which overlap with these defects
146  """
147  from InDetDefectsEmulation.PixelDefectsEmulatorConfig import (
148  PixelDefectsEmulatorCondAlgCfg,
149  PixelDefectsEmulatorAlgCfg,
150  DefectsHistSvcCfg
151  )
152  from AthenaCommon.Constants import INFO
153 
154  if HistogramFileName is None or len(HistogramFileName) ==0 :
155  HistogramGroupName = None
156  if HistogramGroupName is not None :
157  cfg.merge( DefectsHistSvcCfg(flags, HistogramGroup=HistogramGroupName, FileName=HistogramFileName))
158 
159  if ModulePatterns is None and DefectProbabilities is None and NDefectFractionsPerPattern is None:
160  a_module_pattern_list, a_prob_list,fractions,ignore_NoiseProbability,ignore_NoiseShape, cornerDefectParam, cornerDefectFractions = combineModuleDefects([
161  moduleDefect(bec=[-2,-2],layer=[0,99], phi_range=[-99,99],eta_range=[-99,99], # select all modules
162  columns_or_strips=[0,9999], # sensors with all kind of numbers of columns
163  side_range=[0,0], # there is only a single side
164  all_rows=False, # there is no connection between modules
165  probability=[1e-2, # probability of a module to be defect
166  1e-2, # probability of a pixel to be defect
167  0., # probability of a module to have at least one core-column defect
168  0. # probability of a module to have at least one defect circuit
169  ])
170  ])
171  ModulePatterns = a_module_pattern_list
172  DefectProbabilities = a_prob_list
173  NDefectFractionsPerPattern = fractions
174 
175  # schedule custom defects generating conditions alg
176  cfg.merge( PixelDefectsEmulatorCondAlgCfg(flags,
177  ModulePatterns = ModulePatterns,
178  DefectProbabilities = DefectProbabilities,
179  NDefectFractionsPerPattern = NDefectFractionsPerPattern,
180  CornerDefectParamsPerPattern=cornerDefectParam,
181  NCornerDefectFractionsPerPattern=cornerDefectFractions,
182  RngPerDefectType=RngPerDefectType,
183  DefectsInputFiles=DefectsInputFiles,
184  DefectsOutputFile=DefectsOutputFile,
185  FillHistogramsPerPattern=FillHistogramsPerPattern,
186  FillEtaPhiHistogramsPerPattern=FillEtaPhiHistogramsPerPattern,
187  # to enable histogramming:
188  HistogramGroupName=f"/{HistogramGroupName}/EmulatedDefects/" if HistogramGroupName is not None else "",
189  WriteKey="PixelEmulatedDefects", # the default should match the key below
190  ))
191 
192  # schedule the algorithm which drops elements from the ITk Pixel RDO collection
193  cfg.merge( PixelDefectsEmulatorAlgCfg(flags,
194  # prevent default cond alg from being scheduled :
195  EmulatedDefectsKey="PixelEmulatedDefects",
196  # to enable histogramming:
197  HistogramGroupName=f"/{HistogramGroupName}/RejectedRDOs/" if HistogramGroupName is not None else "",
198  # (prefix "/PixelDefects/" is assumed by THistSvc config)
199  OutputLevel=INFO))
200 
201 

◆ fractionsForExactlyNCoreColumnDefects()

def PixelDefectsEmulatorPostInclude.fractionsForExactlyNCoreColumnDefects (   ExactlyNCoreColumnDefects = 1)
Create fraction n-tuple, containing zero except for the element corresponding
to exactly n defects, which is set to 1.

Definition at line 227 of file PixelDefectsEmulatorPostInclude.py.

227 def fractionsForExactlyNCoreColumnDefects(ExactlyNCoreColumnDefects=1) :
228  """
229  Create fraction n-tuple, containing zero except for the element corresponding
230  to exactly n defects, which is set to 1.
231  """
232  return [ 0. if idx != ExactlyNCoreColumnDefects else 1. for idx in range(1,ExactlyNCoreColumnDefects+1) ]
233 

◆ makeITkDefectsParams()

def PixelDefectsEmulatorPostInclude.makeITkDefectsParams (   quad_cc_defect_prob,
  quad_fractions,
  circuit_cc_defect_prob,
  circuit_fractions,
  pixel_defect_prob = 1e-2,
  module_defect_prob = 0.,
  cornerDefectProb = 0.,
  noiseProbability = None,
  noiseShape = [] 
)
Create different defects for quads and single chip modules, where the corresponding modules are selected by
the number of offline columns

Definition at line 234 of file PixelDefectsEmulatorPostInclude.py.

234 def makeITkDefectsParams( quad_cc_defect_prob,
235  quad_fractions,
236  circuit_cc_defect_prob,
237  circuit_fractions,
238  pixel_defect_prob=1e-2,
239  module_defect_prob=0.,
240  cornerDefectProb=0.,
241  noiseProbability=None,
242  noiseShape=[]) :
243  """
244  Create different defects for quads and single chip modules, where the corresponding modules are selected by
245  the number of offline columns
246  """
247  # corner defects:
248  # - 50% of ~30% of the 3D modules have disconnected corners area 2-4mm x 2-2.5mm,
249  # - roughly circular shape with a sagitta (defined by circle crossing sensor edges) of ~0-2mm,
250  # - impact on all 3D sensors which are all single chip modules i.e. modules with 384 or 400 columns
251  # Update: after defect mitigation, new measurement of remaining defects: 4.1mm x 1.3 sagitta 0.44 (representative?)
252  corner_defects=makeCornerDefectParam(probability=cornerDefectProb,
253  min_rx=2.,max_rx=5.,
254  min_ry=0.5,max_ry=1.5,
255  min_sagitta=0.2,max_sagitta=0.5)
256  # assume each corner has equal probability to suffer corner defects
257  # Assume number of corners with defects Poisson distributed
258  # According to the information on JIRA https://its.cern.ch/jira/browse/ATLITKSW-302 only bottom of
259  # sensors suffers such defects (currently not taken into account
260  corner_defect_n_defect_corners=poissonFractions(cc_defect_prob=15e-2, max_n=4)
261 
262  return combineModuleDefects([
263  moduleDefect(bec=[-2,2],layer=[0,99], phi_range=[-99,99],eta_range=[-99,99], # select all modules
264  columns_or_strips=[800,800], # but only quads
265  side_range=[0,0], # there is only a single side
266  all_rows=False, # there is no connection between modules
267  probability=[module_defect_prob, # probability of a module to be defect
268  pixel_defect_prob, # probability of a pixel to be defect
269  quad_cc_defect_prob, # probability of a module to have at least one core-column defect
270  0. # probability of a module to have at least one defect circuit
271  ],
272  fractionsOfNDefects=[[1.], quad_fractions,[1.]], # dummy fractions for cell and circuit defects
273  noiseProbability=noiseProbability,
274  noiseShape=noiseShape,
275  cornerDefectParam=[], # need empty lists here
276  cornerDefectNCornerFractions=[] # and here, otherwise resulting property will be non-conform,
277  ),
278  moduleDefect(bec=[-2,2],layer=[0,1], phi_range=[-99,99],eta_range=[-99,99], # select all modules
279  columns_or_strips=[384,384], # but only ring triplet modules
280  side_range=[0,0], # there is only a single side
281  all_rows=False, # there is no connection between modules
282  probability=[module_defect_prob, # probability of a module to be defect
283  pixel_defect_prob, # probability of a pixel to be defect
284  circuit_cc_defect_prob, # probability of a module to have at least one core-column defect
285  0. # probability of a module to have at least one defect circuit
286  ],
287  fractionsOfNDefects=[[1.], circuit_fractions,[1.]], # dummy fractions for cell and circuit defects
288  noiseProbability=noiseProbability,
289  noiseShape=noiseShape,
290  cornerDefectParam=corner_defects,
291  cornerDefectNCornerFractions=corner_defect_n_defect_corners,
292  ),
293  moduleDefect(bec=[-2,2],layer=[0,1], phi_range=[-99,99],eta_range=[-99,99], # select all modules
294  columns_or_strips=[200,200], # but only barrel triplet modules
295  side_range=[0,0], # there is only a single side
296  all_rows=False, # there is no connection between modules
297  probability=[module_defect_prob, # probability of a module to be defect
298  pixel_defect_prob, # probability of a pixel to be defect
299  circuit_cc_defect_prob, # probability of a module to have at least one core-column defect
300  0. # probability of a module to have at least one defect circuit
301  ],
302  fractionsOfNDefects=[[1.],circuit_fractions,[1.]], # dummy fractions for cell and circuit defects
303  noiseProbability=noiseProbability,
304  noiseShape=noiseShape,
305  cornerDefectParam=corner_defects,
306  cornerDefectNCornerFractions=corner_defect_n_defect_corners,
307  )
308  ])
309 

◆ makeITkPixelNoise()

def PixelDefectsEmulatorPostInclude.makeITkPixelNoise (   noiseProb = 0.)
For NoiseProb>0. create phantasie noise tot shape, with mean at zero width of 0.7
truncated below a tot of 1.

Definition at line 310 of file PixelDefectsEmulatorPostInclude.py.

310 def makeITkPixelNoise(noiseProb=0.) :
311  """
312  For NoiseProb>0. create phantasie noise tot shape, with mean at zero width of 0.7
313  truncated below a tot of 1.
314  """
315  if noiseProb > 0. :
316  import math
317  def norm(dist) :
318  scale = sum(dist)
319  return [elm/scale if scale > 0. else 0. for elm in dist]
320  def gaussDist(mean, width, n) :
321  scale = -1./(2*width)
322  return norm([ math.exp( scale *math.pow(i - mean,2.) ) for i in range(0,n) ])
323 
324  # Guassian tot distribution with mean of 0 but tot >=1
325  noiseShape=[ 0. ] + gaussDist(-1,0.7,4)
326  else :
327  noiseProb=None
328  noiseShape=[]
329  return noiseProb,noiseShape
330 
331 

◆ poissonFractions()

def PixelDefectsEmulatorPostInclude.poissonFractions (   cc_defect_prob = 1e-1,
  max_n = 5 
)
Create fractions for exactly 1..max_n defects, under the condition that
the probability for at least one such defects is cc_defect_prob, and
assuming that the fractions are Poisson distributed.

Definition at line 202 of file PixelDefectsEmulatorPostInclude.py.

202 def poissonFractions(cc_defect_prob=1e-1, max_n=5) :
203  """
204  Create fractions for exactly 1..max_n defects, under the condition that
205  the probability for at least one such defects is cc_defect_prob, and
206  assuming that the fractions are Poisson distributed.
207  """
208  if cc_defect_prob > 0. :
209  def PoissonProb(expected, n) :
210  return math.pow(expected,n)*math.exp(-expected)/math.gamma(n+1)
211  def norm(fractions) :
212  Norm = 1./sum (fractions)
213  return [Norm*elm for elm in fractions ]
214  expectation=-math.log(1-cc_defect_prob)
215  return norm([ PoissonProb(expectation,i) for i in range(1,max_n+1) ])
216  else :
217  return [1.]
218 

◆ quadProb()

def PixelDefectsEmulatorPostInclude.quadProb (   circuit_prob)
Compute the defect probability for a quad module from the probabilities
of a single chip module, assuming that the defect is a "feature" of the
chip.

Definition at line 219 of file PixelDefectsEmulatorPostInclude.py.

219 def quadProb(circuit_prob) :
220  """
221  Compute the defect probability for a quad module from the probabilities
222  of a single chip module, assuming that the defect is a "feature" of the
223  chip.
224  """
225  return 1-math.pow(1-circuit_prob,4) # not (no defect core column on none of the sensors)
226 
PixelDefectsEmulatorConfig.ITkPixelDefectsEmulatorToDetectorElementStatusCondAlgCfg
ComponentAccumulator ITkPixelDefectsEmulatorToDetectorElementStatusCondAlgCfg(flags, str name="ITkPixelDefectsEmulatorToDetectorElementStatusCondAlgCfg", **dict kwargs)
Definition: PixelDefectsEmulatorConfig.py:115
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:56
PlotCalibFromCool.norm
norm
Definition: PlotCalibFromCool.py:100
PixelDefectsEmulatorConfig.PixelDefectsEmulatorCondAlgCfg
ComponentAccumulator PixelDefectsEmulatorCondAlgCfg(flags, str name="PixelDefectsEmulatorCondAlg", **dict kwargs)
Definition: PixelDefectsEmulatorConfig.py:34
PixelDefectsEmulatorPostInclude.fractionsForExactlyNCoreColumnDefects
def fractionsForExactlyNCoreColumnDefects(ExactlyNCoreColumnDefects=1)
Definition: PixelDefectsEmulatorPostInclude.py:227
PixelDefectsEmulatorConfig.ITkPixelDefectsEmulatorCondAlgCfg
ComponentAccumulator ITkPixelDefectsEmulatorCondAlgCfg(flags, str name="ITkPixelDefectsEmulatorCondAlg", **dict kwargs)
Definition: PixelDefectsEmulatorConfig.py:55
StripDefectsEmulatorConfig.makeCornerDefectParam
def makeCornerDefectParam(probability=1e-1, min_rx=0., max_rx=4e-3, min_ry=0., max_ry=4e-3, min_sagitta=0., max_sagitta=2e-3)
Definition: StripDefectsEmulatorConfig.py:28
PixelDefectsEmulatorPostInclude.emulateITkPixelDefects
def emulateITkPixelDefects(flags, cfg, ModulePatterns=[[-2, 2, 0, 99,-99, 99,-99, 99, 0, 9999, 0, 1, 0]], DefectProbabilities=[[0., 1e-2, 1e-1, 0.]], NDefectFractionsPerPattern=[[1.,-1, 1.]], NoiseProbability=[], NoiseShape=[], CornerDefectParamsPerPattern=[], NCornerDefectFractionsPerPattern=[], RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, FillHistogramsPerPattern=False, FillEtaPhiHistogramsPerPattern=False, int MaxRandomPositionAttempts=10, str HistogramGroupName="ITkPixelDefects", str HistogramFileName="itk_pixel_defects_opt1.root", PropagateDefectsToStatus=True)
Definition: PixelDefectsEmulatorPostInclude.py:38
PixelDefectsEmulatorPostInclude.makeITkDefectsParams
def makeITkDefectsParams(quad_cc_defect_prob, quad_fractions, circuit_cc_defect_prob, circuit_fractions, pixel_defect_prob=1e-2, module_defect_prob=0., cornerDefectProb=0., noiseProbability=None, noiseShape=[])
Definition: PixelDefectsEmulatorPostInclude.py:234
PixelDefectsEmulatorConfig.PixelDefectsEmulatorAlgCfg
ComponentAccumulator PixelDefectsEmulatorAlgCfg(flags, str name="PixelDefectsEmulatorAlg", **dict kwargs)
Definition: PixelDefectsEmulatorConfig.py:75
PixelDefectsEmulatorPostInclude.emulatePixelDefects
def emulatePixelDefects(flags, cfg, ModulePatterns=None, DefectProbabilities=None, NDefectFractionsPerPattern=None, RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, FillHistogramsPerPattern=False, FillEtaPhiHistogramsPerPattern=False, str HistogramGroupName="PixelDefects", str HistogramFileName="pixel_defects.root")
Definition: PixelDefectsEmulatorPostInclude.py:132
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
StripDefectsEmulatorConfig.combineModuleDefects
def combineModuleDefects(defects)
Definition: StripDefectsEmulatorConfig.py:151
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
PixelDefectsEmulatorConfig.ITkPixelDefectsEmulatorAlgCfg
ComponentAccumulator ITkPixelDefectsEmulatorAlgCfg(flags, str name="ITkPixelDefectsEmulatorAlg", **dict kwargs)
Definition: PixelDefectsEmulatorConfig.py:95
Constants
some useful constants -------------------------------------------------—
PixelDefectsEmulatorPostInclude.quadProb
def quadProb(circuit_prob)
Definition: PixelDefectsEmulatorPostInclude.py:219
PixelDefectsEmulatorPostInclude.emulateITkPixelDefectsPoisson
def emulateITkPixelDefectsPoisson(flags, cfg, FrontEndCCDefectProb=0.1, PixelDefectProb=1e-2, ModuleDefectProb=0., CornerDefectProb=0., NoiseProb=0., RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, PropagateDefectsToStatus=True, HistogramFileName=None)
Definition: PixelDefectsEmulatorPostInclude.py:380
PixelDefectsEmulatorPostInclude.makeITkPixelNoise
def makeITkPixelNoise(noiseProb=0.)
Definition: PixelDefectsEmulatorPostInclude.py:310
PixelDefectsEmulatorPostInclude.emulateITkPixelDefectsDefault
def emulateITkPixelDefectsDefault(flags, cfg, FrontEndCCDefectProb=0.1, PixelDefectProb=1e-2, ModuleDefectProb=1e-2, CornerDefectProb=15e-2, NoiseProb=0., RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, PropagateDefectsToStatus=True, HistogramFileName=None)
Definition: PixelDefectsEmulatorPostInclude.py:427
PixelDefectsEmulatorPostInclude.poissonFractions
def poissonFractions(cc_defect_prob=1e-1, max_n=5)
Definition: PixelDefectsEmulatorPostInclude.py:202
PixelDefectsEmulatorPostInclude.emulateITkPixelDefectsOneCC
def emulateITkPixelDefectsOneCC(flags, cfg, FrontEndCCDefectProb=0.1, PixelDefectProb=1e-2, NumberOfCCDefects=1, ModuleDefectProb=0., CornerDefectProb=0., NoiseProb=0., RngPerDefectType=False, DefectsInputFiles=[], DefectsOutputFile=None, PropagateDefectsToStatus=True, HistogramFileName=None)
Definition: PixelDefectsEmulatorPostInclude.py:332