ATLAS Offline Software
LArCellBinning_test.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 AthenaPython.PyAthenaComps import Alg, StatusCode
5 import ROOT
6 import sys
7 
8 def checkHistoBinning(filename,runnumber):
9  nMultipleHits=0
10  nNoHit=0
11  f=ROOT.TFile.Open(filename)
12  layers=["EMBPA", "EMBPC", "EMB1A", "EMB1C", "EMB2A", "EMB2C", "EMB3A", "EMB3C",
13  "HEC0A", "HEC0C", "HEC1A", "HEC1C", "HEC2A", "HEC2C", "HEC3A", "HEC3C",
14  "EMECPA", "EMECPC", "EMEC1A", "EMEC1C", "EMEC2A", "EMEC2C", "EMEC3A", "EMEC3C",
15  "FCAL1A", "FCAL1C", "FCAL2A", "FCAL2C", "FCAL3A", "FCAL3C"]
16 
17 
18  for layer in layers:
19  histpath="run_%i/CaloMonitoring/LArCellMon_NoTrigSel/2d_Occupancy/CellOccupancyVsEtaPhi_%s_noEth_rndm_CSCveto"%(runnumber,layer)
20  hist=f.Get(histpath)
21  print ("Checking Histogram",hist)
22  print ("\tBinning x:",hist.GetNbinsX(),"y:",hist.GetNbinsY())
23  for x in range (hist.GetNbinsX()):
24  for y in range (hist.GetNbinsY()):
25  n=hist.GetBinContent(x,y)
26  if (n>1):
27  print ("ERROR multiple hits in ",layer,x,y,n)
28  nMultipleHits+=1
29  elif (n!=1):
30  nNoHit+=1
31  print ("WARNING no hit in ", layer,x,y,n)
32  print ("Summary")
33  print ("\tNumber of bins not corresponding to any cell:",nNoHit)
34  print ("\tNumber of bins corresponding to multiple cells:",nMultipleHits)
35 
36  return nMultipleHits
37 
38 class CreateDataAlg (Alg):
39  def execute (self):
40  ctx = self.getContext()
41  mgr = self.condStore['CaloDetDescrManager'].find (ctx.eventID())
42  ccc = ROOT.CaloCellContainer()
43  for i in range (mgr.element_size()):
44  elem = mgr.get_element (ROOT.IdentifierHash (i))
45  cc=ROOT.CaloCell(elem,10000,0,0,0)
46  ccc.push_back (cc)
47  ROOT.SetOwnership (cc, False)
48  ccc.order()
49  ccc.updateCaloIterators()
50  self.msg.info("Recorded CaloCellContainer %i",ccc.size())
51  self.evtStore.record (ccc, 'AllCalo')
52 
53  return StatusCode.Success
54 
55 
56 
57 def testCfg (flags):
58  result = ComponentAccumulator()
59 
60  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
61  from TileGeoModel.TileGMConfig import TileGMCfg
62  result.merge(LArGMCfg(flags))
63  result.merge(TileGMCfg(flags))
64 
65  from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
66  result.merge(LArOnOffIdMappingCfg(flags))
67 
68  result.addEventAlgo (CreateDataAlg ('CreateDataAlg'),sequenceName="AthAlgSeq")
69  from CaloMonitoring.LArCellMonAlg import LArCellMonConfig
70  result.merge( LArCellMonConfig(flags) )
71 
72  alg=result.getEventAlgo("LArCellMonAlg")
73  alg.useReadyFilterTool=False
74  alg.useBadLBTool=False
75  alg.useLArCollisionFilterTool=False
76  alg.useLArNoisyAlg=False
77  alg.useBeamBackgroundRemoval=False
78  return result
79 
80 
81 if __name__ == "__main__":
82  from AthenaConfiguration.AllConfigFlags import initConfigFlags
83  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
84  flags = initConfigFlags()
85  flags.Input.Files = defaultTestFiles.RAW_RUN3
86  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
87  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN3_DATA
88  flags.Output.HISTFileName = 'LArCellMonOutput.root'
89  flags.DQ.useTrigger = False
90  flags.fillFromArgs()
91  flags.lock()
92  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
93  acc = MainServicesCfg(flags)
94 
95  from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg, HLTConfigSvcCfg, L1PrescaleCondAlgCfg, HLTPrescaleCondAlgCfg
96  from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig import L1TriggerByteStreamDecoderCfg
97 
98  acc.merge( L1TriggerByteStreamDecoderCfg(flags) )
99  acc.merge( L1ConfigSvcCfg(flags) )
100  acc.merge( HLTConfigSvcCfg(flags) )
101  acc.merge( L1PrescaleCondAlgCfg(flags) )
102  acc.merge( HLTPrescaleCondAlgCfg(flags) )
103 
104  from TrigConfigSvc.TrigConfigSvcCfg import BunchGroupCondAlgCfg
105  acc.merge( BunchGroupCondAlgCfg( flags ) )
106  acc.merge (testCfg (flags))
107 
108  sc=acc.run(1)
109  if (sc.isFailure()): sys.exit(1)
110 
111 
112  retval=checkHistoBinning(flags.Output.HISTFileName,431493)
113  if retval!=0:
114  sys.exit(1)
115  else:
116  sys.exit(0)
grepfile.info
info
Definition: grepfile.py:38
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.TrigConfigSvcCfg.HLTPrescaleCondAlgCfg
def HLTPrescaleCondAlgCfg(flags)
Definition: TrigConfigSvcCfg.py:329
python.BunchGroupCondAlgConfig.BunchGroupCondAlgCfg
def BunchGroupCondAlgCfg(flags)
Definition: BunchGroupCondAlgConfig.py:14
LArCellBinning_test.CreateDataAlg
Definition: LArCellBinning_test.py:38
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
LArCablingConfig.LArOnOffIdMappingCfg
def LArOnOffIdMappingCfg(configFlags)
Definition: LArCablingConfig.py:62
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
LArCellBinning_test.CreateDataAlg.execute
def execute(self)
Definition: LArCellBinning_test.py:39
python.TrigConfigSvcCfg.L1PrescaleCondAlgCfg
def L1PrescaleCondAlgCfg(flags)
Definition: TrigConfigSvcCfg.py:273
python.TrigConfigSvcCfg.L1ConfigSvcCfg
def L1ConfigSvcCfg(flags)
Definition: TrigConfigSvcCfg.py:198
LArCellBinning_test.testCfg
def testCfg(flags)
Definition: LArCellBinning_test.py:57
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
LArCellBinning_test.checkHistoBinning
def checkHistoBinning(filename, runnumber)
Definition: LArCellBinning_test.py:8
python.TrigConfigSvcCfg.HLTConfigSvcCfg
def HLTConfigSvcCfg(flags)
Definition: TrigConfigSvcCfg.py:231
LArCellMonAlg.LArCellMonConfig
def LArCellMonConfig(flags)
Definition: LArCellMonAlg.py:5
TrigT1ResultByteStreamConfig.L1TriggerByteStreamDecoderCfg
def L1TriggerByteStreamDecoderCfg(flags, returnEDM=False)
Definition: TrigT1ResultByteStreamConfig.py:132
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7