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 424 of file PixelDefectsEmulatorPostInclude.py.

425  cfg,
426  FrontEndCCDefectProb=0.1,
427  PixelDefectProb=1e-2,
428  ModuleDefectProb=1e-2,
429  CornerDefectProb=15e-2,
430  NoiseProb=0.,
431  RngPerDefectType=False,
432  DefectsInputFiles=[],
433  DefectsOutputFile=None,
434  PropagateDefectsToStatus=True,
435  HistogramFileName=None) :
436  """
437  Enables all defects according to the current expectation.
438  """
440  FrontEndCCDefectProb,
441  PixelDefectProb,
442  ModuleDefectProb,
443  CornerDefectProb,
444  NoiseProb,
445  RngPerDefectType=RngPerDefectType,
446  DefectsInputFiles=DefectsInputFiles,
447  DefectsOutputFile=DefectsOutputFile,
448  PropagateDefectsToStatus=PropagateDefectsToStatus,
449  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 329 of file PixelDefectsEmulatorPostInclude.py.

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

◆ 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 377 of file PixelDefectsEmulatorPostInclude.py.

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

◆ 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  corner_defects=makeCornerDefectParam(probability=cornerDefectProb,
252  min_rx=2.,max_rx=8.4,
253  min_ry=2.,max_ry=4.5,
254  min_sagitta=0.,max_sagitta=2.2)
255  # assume each corner has equal probability to suffer corner defects
256  # Assume number of corners with defects Poisson distributed
257  corner_defect_n_defect_corners=poissonFractions(cc_defect_prob=15e-2, max_n=4)
258 
259  return combineModuleDefects([
260  moduleDefect(bec=[-2,2],layer=[0,99], phi_range=[-99,99],eta_range=[-99,99], # select all modules
261  columns_or_strips=[800,800], # but only quads
262  side_range=[0,0], # there is only a single side
263  all_rows=False, # there is no connection between modules
264  probability=[module_defect_prob, # probability of a module to be defect
265  pixel_defect_prob, # probability of a pixel to be defect
266  quad_cc_defect_prob, # probability of a module to have at least one core-column defect
267  0. # probability of a module to have at least one defect circuit
268  ],
269  fractionsOfNDefects=[quad_fractions,[1.]], # dummy fractions for circuit defects
270  noiseProbability=noiseProbability,
271  noiseShape=noiseShape,
272  cornerDefectParam=[], # need empty lists here
273  cornerDefectNCornerFractions=[] # and here, otherwise resulting property will be non-conform,
274  ),
275  moduleDefect(bec=[-2,2],layer=[0,1], phi_range=[-99,99],eta_range=[-99,99], # select all modules
276  columns_or_strips=[384,384], # but only ring triplet modules
277  side_range=[0,0], # there is only a single side
278  all_rows=False, # there is no connection between modules
279  probability=[module_defect_prob, # probability of a module to be defect
280  pixel_defect_prob, # probability of a pixel to be defect
281  circuit_cc_defect_prob, # probability of a module to have at least one core-column defect
282  0. # probability of a module to have at least one defect circuit
283  ],
284  fractionsOfNDefects=[circuit_fractions,[1.]], # dummy fractions for circuit defects
285  noiseProbability=noiseProbability,
286  noiseShape=noiseShape,
287  cornerDefectParam=corner_defects,
288  cornerDefectNCornerFractions=corner_defect_n_defect_corners,
289  ),
290  moduleDefect(bec=[-2,2],layer=[0,1], phi_range=[-99,99],eta_range=[-99,99], # select all modules
291  columns_or_strips=[200,200], # but only barrel triplet modules
292  side_range=[0,0], # there is only a single side
293  all_rows=False, # there is no connection between modules
294  probability=[module_defect_prob, # probability of a module to be defect
295  pixel_defect_prob, # probability of a pixel to be defect
296  circuit_cc_defect_prob, # probability of a module to have at least one core-column defect
297  0. # probability of a module to have at least one defect circuit
298  ],
299  fractionsOfNDefects=[circuit_fractions,[1.]], # dummy fractions for circuit defects
300  noiseProbability=noiseProbability,
301  noiseShape=noiseShape,
302  cornerDefectParam=corner_defects,
303  cornerDefectNCornerFractions=corner_defect_n_defect_corners,
304  )
305  ])
306 

◆ 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 307 of file PixelDefectsEmulatorPostInclude.py.

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

◆ 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:50
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:22
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:138
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:377
PixelDefectsEmulatorPostInclude.makeITkPixelNoise
def makeITkPixelNoise(noiseProb=0.)
Definition: PixelDefectsEmulatorPostInclude.py:307
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:424
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:329