ATLAS Offline Software
CaloNoiseCondAlgConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from IOVDbSvc.IOVDbSvcConfig import addFolders
6 CaloNoiseCondAlg=CompFactory.CaloNoiseCondAlg
7 from AthenaCommon.Logging import logging
8 from AthenaConfiguration.AccumulatorCache import AccumulatorCache
9 
10 @AccumulatorCache
11 def CaloNoiseCondAlgCfg(flags, noisetype="totalNoise"):
12  if noisetype not in ("electronicNoise","pileupNoise","totalNoise"):
13  raise RuntimeError("Requested noise of unknown type %s" % noisetype)
14 
15  noiseAlgName="Calo_"+noisetype+"Alg"
16 
17 
18  log = logging.getLogger("CaloNoiseCondAlgCfg")
19  result=ComponentAccumulator()
20 
21  isMC=flags.Input.isMC
22  fixedLumi=flags.Calo.Noise.fixedLumiForNoise
23  useCaloLumi=flags.Calo.Noise.useCaloNoiseLumi
24 
25  #CaloNoiseCondAlg needs Identifiers ...
26  from AtlasGeoModel.GeoModelConfig import GeoModelCfg
27  gms=GeoModelCfg(flags)
28  result.merge(gms)
29 
30  #... and cabling:
31  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
32  result.merge(LArOnOffIdMappingCfg(flags))
33 
34  theCaloNoiseAlg=CaloNoiseCondAlg(noiseAlgName,OutputKey=noisetype)
35 
36  if flags.Common.isOnline:
37  log.info("Configuring CaloNoiseCondAlg for online case")
38  #online mode:
39  result.merge(addFolders(flags,"/CALO/Noise/CellNoise",'CALO_ONL',className="CondAttrListCollection"))
40  theCaloNoiseAlg.CaloNoiseFolder="/CALO/Noise/CellNoise"
41  theCaloNoiseAlg.LArNoiseFolder=""
42  theCaloNoiseAlg.TileNoiseFolder=""
43  if fixedLumi >= 0 :
44  theCaloNoiseAlg.Luminosity = fixedLumi
45  log.info("online mode: use fixed luminosity for scaling pileup noise: %f", fixedLumi)
46  else:
47  if useCaloLumi:
48  lumiFolder='/CALO/Noise/PileUpNoiseLumi'
49  result.merge(addFolders(flags,lumiFolder,'CALO',className="CondAttrListCollection"))
50  theCaloNoiseAlg.LumiFolder = lumiFolder
51  theCaloNoiseAlg.Luminosity = -1.
52  log.info("online mode: use luminosity from /CALO/Noise/PileUpNoiseLumi to scale pileup noise")
53  else:
54  theCaloNoiseAlg.Luminosity = 0.
55  log.info("online mode: ignore pileup noise")
56  pass
57  result.addCondAlgo(theCaloNoiseAlg)
58  return result
59 
60  #The not-online case:
61  if isMC:
62  log.info("Configuring CaloNoiseCondAlg for MC data processing")
63  if fixedLumi >= 0 :
64  theCaloNoiseAlg.Luminosity=fixedLumi
65  log.info("Luminosity (in 10**33) units used for pileup noise from CaloNoiseFlags : %f", fixedLumi)
66  else:
67  if useCaloLumi:
68  lumiFolder='/CALO/Ofl/Noise/PileUpNoiseLumi'
69  result.merge(addFolders(flags,lumiFolder,'CALO_OFL',className="CondAttrListCollection"))
70  log.info("offline mode: use luminosity from /CALO/Ofl/Noise/PileUpNoiseLumi to scale pileup noise")
71  theCaloNoiseAlg.LumiFolder = lumiFolder
72  theCaloNoiseAlg.Luminosity=-1.
73  else:
74  estimatedLumi=flags.Beam.estimatedLuminosity
75  theCaloNoiseAlg.Luminosity=estimatedLumi/1e+33
76  log.info(" Luminosity (in 10**33) units used for pileup noise from Beam flags: %f", theCaloNoiseAlg.Luminosity)
77 
78  theCaloNoiseAlg.LArNoiseFolder="/LAR/NoiseOfl/CellNoise"
79  result.merge(addFolders(flags,"/LAR/NoiseOfl/CellNoise","LAR_OFL",className="CondAttrListCollection"))
80  theCaloNoiseAlg.TileNoiseFolder="/TILE/OFL02/NOISE/CELL"
81  result.merge(addFolders(flags,"/TILE/OFL02/NOISE/CELL","TILE_OFL",className="CondAttrListCollection"))
82  theCaloNoiseAlg.CaloNoiseFolder="/CALO/Ofl/Noise/CellNoise"
83  result.merge(addFolders(flags,"/CALO/Ofl/Noise/CellNoise","CALO_OFL",className="CondAttrListCollection"))
84 
85  pass
86  else: # Real data case:
87  # for luminosity
88  if fixedLumi >= 0 :
89  theCaloNoiseAlg.Luminosity = fixedLumi
90  log.info("offline mode: use fixed luminosity for scaling pileup noise: %f", fixedLumi)
91  else :
92  theCaloNoiseAlg.Luminosity = -1
93  if useCaloLumi:
94  lumiFolder='/CALO/Ofl/Noise/PileUpNoiseLumi'
95  result.merge(addFolders(flags,lumiFolder,'CALO_OFL',className="CondAttrListCollection"))
96  log.info("offline mode: use luminosity from /CALO/Ofl/Noise/PileUpNoiseLumi to scale pileup noise")
97  else:
98  lumiFolder = '/TRIGGER/LUMI/LBLESTONL'
99  result.merge(addFolders(flags,lumiFolder,'TRIGGER_ONL',className="CondAttrListCollection"))
100  log.info("offline mode: use luminosity = f(Lumiblock) to scale pileup noise")
101  theCaloNoiseAlg.LumiFolder = lumiFolder
102 
103  if flags.IOVDb.DatabaseInstance=="CONDBR2": # Run2 case:
104  log.info("Configuring CaloNoiseCondAlg for Run2 real data processing")
105  theCaloNoiseAlg.CaloNoiseFolder=""
106  theCaloNoiseAlg.LArNoiseFolder="/LAR/NoiseOfl/CellNoise"
107  theCaloNoiseAlg.TileNoiseFolder="/TILE/OFL02/NOISE/CELL"
108  result.merge(addFolders(flags,"/LAR/NoiseOfl/CellNoise","LAR_OFL",className="CondAttrListCollection"))
109  result.merge(addFolders(flags,"/TILE/OFL02/NOISE/CELL","TILE_OFL",className="CondAttrListCollection"))
110 
111 
112  if flags.LAr.doHVCorr:
113  log.info("Run2 & doLArHVCorr=True: Will rescale noise automatically for HV trips")
114  theCaloNoiseAlg.useHVCorr=True
115  from LArCalibUtils.LArHVScaleConfig import LArHVScaleCfg
116  result.merge(LArHVScaleCfg(flags))
117  pass
118  pass
119  else: #COMP200 case:
120  log.info("Configuring CaloNoiseCondAlg for Run1 real data processing")
121  #The noise for runs before 2012 is a different folder:
122  theCaloNoiseAlg.CaloNoiseFolder="/CALO/Ofl/Noise/CellNoise"
123  theCaloNoiseAlg.LArNoiseFolder="/LAR/NoiseOfl/CellNoise"
124  theCaloNoiseAlg.TileNoiseFolder="/TILE/OFL02/NOISE/CELL"
125  result.merge(addFolders(flags,"/CALO/Ofl/Noise/CellNoise","CALO_OFL",className="CondAttrListCollection"))
126  result.merge(addFolders(flags,"/LAR/NoiseOfl/CellNoise","LAR_OFL",className="CondAttrListCollection"))
127  result.merge(addFolders(flags,"/TILE/OFL02/NOISE/CELL","TILE_OFL",className="CondAttrListCollection"))
128 
129 
130  pass #end of real data case
131 
132  result.addCondAlgo(theCaloNoiseAlg)
133  return result
134 
135 if __name__ == "__main__":
136  from AthenaConfiguration.AllConfigFlags import initConfigFlags
137  from AthenaConfiguration.TestDefaults import defaultTestFiles
138  flags = initConfigFlags()
139  flags.Input.Files = defaultTestFiles.ESD
140  flags.lock()
141 
142  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
143  acc=MainServicesCfg(flags)
144  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
145  acc.merge(PoolReadCfg(flags))
146 
147  acc.merge(CaloNoiseCondAlgCfg(flags))
148 
149  acc.run(10)
150 
151  #f=open('test.pkl','w')
152  #acc.store(f)
153  #f.close()
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.CaloNoiseCondAlgConfig.CaloNoiseCondAlgCfg
def CaloNoiseCondAlgCfg(flags, noisetype="totalNoise")
Definition: CaloNoiseCondAlgConfig.py:11
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
CaloNoiseCondAlg
Definition: CaloNoiseCondAlg.h:21
python.LArHVScaleConfig.LArHVScaleCfg
def LArHVScaleCfg(configFlags)
Definition: LArHVScaleConfig.py:8
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
python.GeoModelConfig.GeoModelCfg
def GeoModelCfg(flags)
Definition: GeoModelConfig.py:16