ATLAS Offline Software
LArClusterCellDumperConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 """Define functions for LAr Cluster Cell Dumper with ComponentAccumulator"""
3 
4 # utilities
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaCommon.Logging import logging
8 from AthenaConfiguration.Enums import LHCPeriod
9 
10 def EventReaderAlgCfg(flags, name="EventReaderAlgCfg", **kwargs):
11  from IOVDbSvc.IOVDbSvcConfig import addFolders
12 
13  acc = ComponentAccumulator()
14 
15  isMC = flags.Input.isMC
16 
17  # -- Dump variables Selection --
18  kwargs.setdefault("doAssocTopoCluster711Dump", False) # dump the 7x11 window built from the hottest cell in an electron cluster.
19  kwargs.setdefault("doClusterDump", False) # Dump only a cluster container. (override the electron cluster)
20  kwargs.setdefault("doPhotonDump", False) # Perform a photon particle dump based on offline Photons Container.
21  kwargs.setdefault("doTruthEventDump", isMC) # Dump the Truth Event variables.
22  kwargs.setdefault("doTruthPartDump", isMC) # Perform a truth particle dump.
23  kwargs.setdefault("doLArEMBHitsDump", isMC) # Dump MC Hits for LAr EMB partition.
24 
25  kwargs.setdefault("skipEmptyEvents", True) # If true, do not fill the event that has no reco electrons.
26  kwargs.setdefault("noBadCells", False) # If True, skip the cells tagged as badCells/channels.
27  kwargs.setdefault("printCellsClus", False) # Debugging
28 
29  # Electrons and crosstalk studies
30  kwargs.setdefault("electronEtaCut", 1.4) # Electron |eta| cut value
31  kwargs.setdefault("doTagAndProbe", True) # select by tag and probe method, electron pairs (start the chain of selection: track + T&P)
32  kwargs.setdefault("doElecSelectByTrackOnly", True) # select only single electrons which pass track criteria (only track), overrides T&P
33  kwargs.setdefault("getAssociatedTopoCluster", True) # Get the topo cluster associated to a super cluster, which was linked to an Electron
34  kwargs.setdefault("getLArCalibConstants", True) # Get the LAr calorimeter calibration constants, related to cells energy and time (online and offline).
35  kwargs.setdefault("etMinProbe", 15) # Min electron Pt value for Zee probe selection loose (GeV).
36  kwargs.setdefault("etMinTag", 15) # Min Et value for the electrons in Zee tag selection (GeV).
37  kwargs.setdefault("minZeeMassTP", 66) # Minimum value of Zee mass for checking the TP pairs (GeV).
38  kwargs.setdefault("maxZeeMassTP", 116) # Maximum value of Zee mass for checking the TP pairs (GeV).
39 
40  # Containers
41  kwargs.setdefault("EventInfoContainerKey" , "EventInfo")
42  kwargs.setdefault("PrimaryVertexContainerKey" , "PrimaryVertices")
43  kwargs.setdefault("CaloClusterContainerKey" , "CaloCalTopoClusters")
44  kwargs.setdefault("TruthParticleContainerKey" , "TruthParticles")
45  kwargs.setdefault("ElectronContainerKey" , "Electrons")
46  kwargs.setdefault("TruthEventContainerKey" , "TruthEvents")
47  kwargs.setdefault("LArEMBHitContainerKey" , "LArHitEMB_ClusterThinned")
48  kwargs.setdefault("LArRawChannelContainerKey" , "LArRawChannels_ClusterThinned")
49  kwargs.setdefault("CaloCellContainerKey" , "AllCalo_ClusterThinned")
50  kwargs.setdefault("LArDigitContainerKey" , "LArDigitContainer_ClusterThinned")
51 
52  if (kwargs.get("doElecSelectByTrackOnly")):
53  kwargs.setdefault("MyElectronSelectionKey" , "MySelectedElectrons")
54  else:
55  kwargs.setdefault("MyElectronSelectionKey" , "MyTagAndProbeElectrons")
56 
57  kwargs.setdefault("isMC", isMC) # set to True in case of MC sample.
58 
59  #------------------------------------------------------------------------------------------------------
60  # Condition Database Access
61  #------------------------------------------------------------------------------------------------------
62 
63  # ## LArIDMapping
64  from LArCabling.LArCablingConfig import LArFebRodMappingCfg, LArOnOffIdMappingCfg
65  acc.merge (LArFebRodMappingCfg (flags))
66  acc.merge (LArOnOffIdMappingCfg (flags))
67 
68 
69  from CaloCellCorrection.CaloCellCorrectionConfig import CaloCellPedestalCorrCfg
70  acc.popToolsAndMerge(CaloCellPedestalCorrCfg(flags))
71 
72  obj = "AthenaAttributeList"
73 
74 
75  if not isMC:
76 
77  if 'COMP200' in flags.IOVDb.DatabaseInstance:
78  obj='LArDSPThresholdsComplete'
79  dbString = 'COMP200'
80  fldThr='/LAR/Configuration/DSPThreshold/Thresholds'
81  obj='LArDSPThresholdsComplete'
82 
83  kwargs.setdefault("Run2DSPThresholdsKey", fldThr)
84  acc.merge(addFolders(flags,fldThr, "LAR_ONL", className=obj, db=dbString))
85 
86  else: # Run2
87  fldThr="/LAR/Configuration/DSPThresholdFlat/Thresholds"
88  fldOflEneResc="/LAR/CellCorrOfl/EnergyCorr"
89  fsampl="/LAR/ElecCalibMC/fSampl"
90  dbString="CONDBR2"
91 
92  kwargs.setdefault("Run2DSPThresholdsKey", fldThr)#flags.EventReaderAlg.Run2DSPThresholdsKey)
93  kwargs.setdefault("OflEneRescalerKey", fldOflEneResc)#flags.EventReaderAlg.OflEneRescalerKey)
94  kwargs.setdefault("fSamplKey", fsampl)
95 
96  acc.merge(addFolders(flags,fldThr, "LAR_ONL", className=obj, db=dbString))
97  acc.merge(addFolders(flags,[fldOflEneResc,], "LAR_OFL", className="AthenaAttributeList"))
98 
99  from LArConfiguration.LArElecCalibDBConfig import LArElecCalibDBCfg
100  acc.merge(LArElecCalibDBCfg(flags, ["OFC", "Pedestal", "Shape"]))
101 
102 
103  else:
104  from LArRecUtils.LArRecUtilsConfig import LArOFCCondAlgCfg
105  acc.merge(LArOFCCondAlgCfg(flags))
106 
107  if flags.GeoModel.Run is LHCPeriod.Run1: # back to flat threshold
108  fldThr = ''
109  else: # Run2
110  dbString="OFLP200"
111  fldThr=""
112  fldOflEneResc=""
113 
114  kwargs.setdefault("Run2DSPThresholdsKey",fldThr)
115  kwargs.setdefault("OflEneRescalerKey", fldOflEneResc)
116 
117 
118  from LArRecUtils.LArADC2MeVCondAlgConfig import LArADC2MeVCondAlgCfg
119  acc.merge(LArADC2MeVCondAlgCfg(flags))
120 
121  from LArBadChannelTool.LArBadChannelConfig import LArBadChannelCfg, LArBadFebCfg
122  acc.merge(LArBadFebCfg(flags))
123  acc.merge(LArBadChannelCfg(flags))
124 
125 
126  EventReaderAlg = CompFactory.EventReaderAlg(name, **kwargs)
127  acc.addEventAlgo(EventReaderAlg)
128 
129  return acc
130 
131 
132 def CaloCablingAndGeometryCfg(flags,name='CaloCablingAndGeometryCfg',**kwargs):
133  mlog = logging.getLogger('CaloCablingAndGeometryCfg...')
134 
135  from LArCabling.LArCablingConfig import LArFebRodMappingCfg, LArOnOffIdMappingCfg
136  from AtlasGeoModel.GeoModelConfig import GeoModelCfg
137 
138  acc = ComponentAccumulator()
139 
140  acc.merge(LArFebRodMappingCfg (flags))
141  acc.merge(LArOnOffIdMappingCfg (flags))
142  acc.merge(GeoModelCfg(flags))
143 
144  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
145  acc.merge(LArGMCfg(flags))
146 
147  from TileGeoModel.TileGMConfig import TileGMCfg
148  acc.merge(TileGMCfg(flags))
149 
150  mlog.info("CaloCablingAndGeometryCfg added to CA.")
151 
152  return acc
153 
154 
155 def CaloNoiseCfg(flags,name='CaloNoiseCfg',**kwargs):
156  from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
157  from CaloRec.CaloBCIDCoeffsCondAlgConfig import CaloBCIDCoeffsCondAlgCfg
158 
159  acc = ComponentAccumulator()
160 
161  acc.merge(CaloNoiseCondAlgCfg(flags,noisetype="totalNoise"))
162  acc.merge(CaloNoiseCondAlgCfg(flags,noisetype="electronicNoise"))
163  acc.merge(CaloNoiseCondAlgCfg(flags,noisetype="pileupNoise"))
164 
165  acc.merge (CaloBCIDCoeffsCondAlgCfg (flags))
166 
167  if flags.Input.isMC:
168  from LumiBlockComps.BunchCrossingCondAlgConfig import BunchCrossingCondAlgCfg
169  acc.merge (BunchCrossingCondAlgCfg(flags))
170  else:
171  from LumiBlockComps.LuminosityCondAlgConfig import LuminosityCondAlgCfg
172  acc.merge (LuminosityCondAlgCfg (flags))
173 
174  return acc
175 
176 def LArClusterCellDumperCfg(flags, name='LArClusterCellDumperCfg'):
177 
178  mlog = logging.getLogger('LArClusterCellDumperCfg')
179  mlog.info("merging LArClusterCellDumperCfg config files...")
180 
181  CaloNoise = CaloNoiseCfg(flags)
182  CaloCablingAndGeo = CaloCablingAndGeometryCfg(flags)
183  EventReaderAlg = EventReaderAlgCfg(flags)
184 
185  acc = ComponentAccumulator()
186 
187  acc.merge(CaloNoise)
188  acc.merge(CaloCablingAndGeo)
189  acc.merge(EventReaderAlg)
190 
191  mlog.info("All algorithms merged successfully!")
192 
193  return acc
194 
195 if __name__ == "__main__":
196  mlog = logging.getLogger('LArClusterCellDumperCfg')
197 
198  from AthenaConfiguration.AllConfigFlags import initConfigFlags
199  flags = initConfigFlags()
200  from AthenaConfiguration.TestDefaults import defaultTestFiles
201  flags.Input.Files = defaultTestFiles.ESD
202  flags.Exec.MaxEvents = 50
203  flags.Common.MsgSuppression = False
204 
205  flags.fillFromArgs()
206  flags.lock()
207 
208  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
209  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
210  acc = MainServicesCfg(flags)
211 
212  acc.merge(PoolReadCfg(flags)) # athena service required for POOL file reading
213  acc.addService(CompFactory.THistSvc(
214  Output = ["rec DATAFILE='dumper_outputMC.root', OPT='RECREATE'"]))
215  acc.merge(LArClusterCellDumperCfg(flags))
216 
217  mlog.info("Executing LArClusterCellDumperCfg...")
218 
219  import sys
220  sys.exit(acc.run().isFailure())
python.LArElecCalibDBConfig.LArElecCalibDBCfg
def LArElecCalibDBCfg(flags, condObjs)
Definition: LArElecCalibDBConfig.py:47
python.LArRecUtilsConfig.LArOFCCondAlgCfg
def LArOFCCondAlgCfg(flags, name='LArOFCCondAlg', **kwargs)
Definition: LArRecUtilsConfig.py:33
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.LArADC2MeVCondAlgConfig.LArADC2MeVCondAlgCfg
def LArADC2MeVCondAlgCfg(flags)
Definition: LArADC2MeVCondAlgConfig.py:6
python.LArBadChannelConfig.LArBadChannelCfg
def LArBadChannelCfg(configFlags, tag=None, isSC=False)
Definition: LArBadChannelConfig.py:8
CaloCellCorrectionConfig.CaloCellPedestalCorrCfg
def CaloCellPedestalCorrCfg(configFlags)
Definition: CaloCellCorrectionConfig.py:8
LArClusterCellDumperConfig.LArClusterCellDumperCfg
def LArClusterCellDumperCfg(flags, name='LArClusterCellDumperCfg')
Definition: LArClusterCellDumperConfig.py:176
python.LArBadChannelConfig.LArBadFebCfg
def LArBadFebCfg(configFlags, tag=None)
Definition: LArBadChannelConfig.py:45
python.BunchCrossingCondAlgConfig.BunchCrossingCondAlgCfg
def BunchCrossingCondAlgCfg(flags)
Definition: BunchCrossingCondAlgConfig.py:8
python.CaloNoiseCondAlgConfig.CaloNoiseCondAlgCfg
def CaloNoiseCondAlgCfg(flags, noisetype="totalNoise")
Definition: CaloNoiseCondAlgConfig.py:11
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
LArClusterCellDumperConfig.CaloNoiseCfg
def CaloNoiseCfg(flags, name='CaloNoiseCfg', **kwargs)
Definition: LArClusterCellDumperConfig.py:155
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
LArClusterCellDumperConfig.EventReaderAlgCfg
def EventReaderAlgCfg(flags, name="EventReaderAlgCfg", **kwargs)
Definition: LArClusterCellDumperConfig.py:10
LArClusterCellDumperConfig.CaloCablingAndGeometryCfg
def CaloCablingAndGeometryCfg(flags, name='CaloCablingAndGeometryCfg', **kwargs)
Definition: LArClusterCellDumperConfig.py:132
python.GeoModelConfig.GeoModelCfg
def GeoModelCfg(flags)
Definition: GeoModelConfig.py:16
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7