ATLAS Offline Software
PixelDefectsEmulatorPostInclude.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 # can be added as a post include to a Reco_tf
4 # --postInclude "PixelDefectsEmulatorPostInclude.emulateITkPixelDefects"
5 # or
6 # --postExec "from InDetDefectsEmulation.PixelDefectsEmulatorPostInclude import emulateITkPixelDefects;
7 # emulateITkPixelDefects(flags,cfg,DefectProbability=1e-3,CoreColumnDefectProbability=0.01);"
9  cfg,
10  CoreColumnDefectProbability: float=0.01,
11  DefectProbability: float=1e-4,
12  HistogramGroupName: str="ITkPixelDefects",
13  HistogramFileName: str="itk_pixel_defects.root") :
14  from InDetDefectsEmulation.PixelDefectsEmulatorConfig import (
15  ITkPixelDefectsEmulatorCondAlgCfg,
16  ITkPixelDefectsEmulatorAlgCfg,
17  DefectsHistSvcCfg
18  )
19  from AthenaCommon.Constants import INFO
20 
21  if HistogramFileName is None or len(HistogramFileName) ==0 :
22  HistogramGroupName = None
23  if HistogramGroupName is not None :
24  cfg.merge( DefectsHistSvcCfg(flags, HistogramGroup=HistogramGroupName, FileName=HistogramFileName))
25 
26  # schedule custom defects generating conditions alg
27  cfg.merge( ITkPixelDefectsEmulatorCondAlgCfg(flags,
28  # to enable histogramming:
29  HistogramGroupName=f"/{HistogramGroupName}/EmulatedDefects/" if HistogramGroupName is not None else "",
30  CoreColumnDefectProbability=CoreColumnDefectProbability, # probability for a core column to have a defect
31  # (this is not the probability of a module to have a core column defect. The latter
32  # is presumably a probability like computed by probColGroupDefect(0.1, 400/8.)
33  # def probColGroupDefect(prob_col_group_defect_per_mod, n_col_groups) :
34  # # prob of at least one defect per module : prob of not no-defect per module
35  # return 1. - pow( (1-prob_col_group_defect_per_mod), 1/(n_col_groups))
36  # probability of a pixel to be defect:
37  DefectProbability=DefectProbability,
38  WriteKey="ITkPixelEmulatedDefects", # the default should match the key below
39  ))
40 
41  # schedule the algorithm which drops elements from the ITk Pixel RDO collection
42  cfg.merge( ITkPixelDefectsEmulatorAlgCfg(flags,
43  # prevent default cond alg from being scheduled :
44  EmulatedDefectsKey="ITkPixelEmulatedDefects",
45  # to enable histogramming:
46  HistogramGroupName=f"/{HistogramGroupName}/RejectedRDOs/" if HistogramGroupName is not None else "",
47  # (prefix "/PixelDefects/" is assumed by THistSvc config)
48  OutputLevel=INFO))
49 
50 
52  cfg,
53  DefectProbability: float=1e-4,
54  HistogramGroupName: str="PixelDefects",
55  HistogramFileName: str="pixel_defects.root") :
56  from InDetDefectsEmulation.PixelDefectsEmulatorConfig import (
57  PixelDefectsEmulatorCondAlgCfg,
58  PixelDefectsEmulatorAlgCfg,
59  DefectsHistSvcCfg
60  )
61  from AthenaCommon.Constants import INFO
62 
63  if HistogramFileName is None or len(HistogramFileName) ==0 :
64  HistogramGroupName = None
65  if HistogramGroupName is not None :
66  cfg.merge( DefectsHistSvcCfg(flags, HistogramGroup=HistogramGroupName, FileName=HistogramFileName))
67 
68  # schedule custom defects generating conditions alg
69  cfg.merge( PixelDefectsEmulatorCondAlgCfg(flags,
70  # to enable histogramming:
71  HistogramGroupName=f"/{HistogramGroupName}/EmulatedDefects/" if HistogramGroupName is not None else "",
72  CoreColumnDefectProbability=0., # Does not make sense for run3 pixels
73  DefectProbability=DefectProbability,
74  WriteKey="PixelEmulatedDefects", # the default should match the key below
75  ))
76 
77  # schedule the algorithm which drops elements from the ITk Pixel RDO collection
78  cfg.merge( PixelDefectsEmulatorAlgCfg(flags,
79  # prevent default cond alg from being scheduled :
80  EmulatedDefectsKey="PixelEmulatedDefects",
81  # to enable histogramming:
82  HistogramGroupName=f"/{HistogramGroupName}/RejectedRDOs/" if HistogramGroupName is not None else "",
83  # (prefix "/PixelDefects/" is assumed by THistSvc config)
84  OutputLevel=INFO))
85 
PixelDefectsEmulatorConfig.DefectsHistSvcCfg
ComponentAccumulator DefectsHistSvcCfg(flags, str HistogramGroup="PixelDefects", str FileName='pixel_defects.root')
Definition: PixelDefectsEmulatorConfig.py:24
PixelDefectsEmulatorConfig.PixelDefectsEmulatorCondAlgCfg
ComponentAccumulator PixelDefectsEmulatorCondAlgCfg(flags, str name="PixelDefectsEmulatorCondAlg", **dict kwargs)
Definition: PixelDefectsEmulatorConfig.py:36
PixelDefectsEmulatorConfig.PixelDefectsEmulatorAlgCfg
ComponentAccumulator PixelDefectsEmulatorAlgCfg(flags, str name="ITkPixelDefectsEmulatorAlg", **dict kwargs)
Definition: PixelDefectsEmulatorConfig.py:65
PixelDefectsEmulatorConfig.ITkPixelDefectsEmulatorCondAlgCfg
ComponentAccumulator ITkPixelDefectsEmulatorCondAlgCfg(flags, str name="ITkPixelDefectsEmulatorCondAlg", **dict kwargs)
Definition: PixelDefectsEmulatorConfig.py:49
PixelDefectsEmulatorConfig.ITkPixelDefectsEmulatorAlgCfg
ComponentAccumulator ITkPixelDefectsEmulatorAlgCfg(flags, str name="ITkPixelDefectsEmulatorAlg", **dict kwargs)
Definition: PixelDefectsEmulatorConfig.py:85
Constants
some useful constants -------------------------------------------------—
PixelDefectsEmulatorPostInclude.emulatePixelDefects
def emulatePixelDefects(flags, cfg, float DefectProbability=1e-4, str HistogramGroupName="PixelDefects", str HistogramFileName="pixel_defects.root")
Definition: PixelDefectsEmulatorPostInclude.py:51
PixelDefectsEmulatorPostInclude.emulateITkPixelDefects
def emulateITkPixelDefects(flags, cfg, float CoreColumnDefectProbability=0.01, float DefectProbability=1e-4, str HistogramGroupName="ITkPixelDefects", str HistogramFileName="itk_pixel_defects.root")
Definition: PixelDefectsEmulatorPostInclude.py:8