ATLAS Offline Software
GetCaloLCWPerformance.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 #
5 
6 if __name__=='__main__':
7 
8  import os,sys
9  import argparse
10  import subprocess
11  from AthenaCommon import Logging
12  log = Logging.logging.getLogger( 'GetCaloLCWPerformanc' )
13 
14 
15  from AthenaConfiguration.AllConfigFlags import initConfigFlags
16  flags = initConfigFlags()
17  from CaloLocalHadCalib.LCWConfigFlags import addLCWFlags
18  addLCWFlags(flags)
19 
20  parser = flags.getArgumentParser()
21  # here we extend the parser
22  parser.add_argument('--doLocalCalib', default=False, help="Run LCW during reclustering",action="store_true")
23  parser.add_argument('--doCalibHitMoments', default=False, help="Run calib moments during reclustering",action="store_true")
24  parser.add_argument('--doCellWeight', default=False, help="Run cell weighting during reclustering",action="store_true")
25 
26  parser.add_argument('--noiseLumi', default=60*0.1724*50/25, help="Lumi used for noise computation (mu*0.1724*50/bunch_spacing)",type=float)
27 
28  args = flags.fillFromArgs(parser=parser)
29 
30  if help in args and args.help is not None and args.help:
31  parser.print_help()
32  sys.exit(0)
33 
34  for _, value in args._get_kwargs():
35  if value is not None:
36  log.debug(value)
37 
38 
39  # now set flags according parsed options
40 
41  # for debugging
42  from AthenaCommon.Constants import DEBUG
43  flags.Exec.OutputLevel=DEBUG
44 
45  # redo topo clusters on LC scale
46  flags.Calo.TopoCluster.doTopoClusterLocalCalib = args.doLocalCalib
47  flags.Calo.TopoCluster.doCellWeightCalib = args.doCellWeight
48  flags.Calo.TopoCluster.doCalibHitMoments = args.doCalibHitMoments
49 
50  flags.Digitization.HighGainEMECIW = False
51  flags.Calo.Noise.fixedLumiForNoise = args.noiseLumi
52  flags.Calo.Noise.useCaloNoiseLumi=False
53 
54  flags.lock()
55 
56  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
57  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
58 
59  cfg = MainServicesCfg(flags)
60  cfg.merge(PoolReadCfg(flags))
61 
62  from CaloRec.CaloTopoClusterConfig import CaloTopoClusterCfg
63  cfg.merge(CaloTopoClusterCfg(flags))
64 
65  topoAlg = cfg.getEventAlgo("CaloCalTopoClustersMaker")
66  topoAlg.ClusterCorrectionTools.__getitem__("TopoCalibMoments").MatchDmType = 1 # 1=loose, 2=medium (default), 3=tight
67  topoAlg.ClusterCorrectionTools.__getitem__("TopoCalibMoments").MomentsNames += ["ENG_CALIB_OUT_L"]
68  topoAlg.ClusterCorrectionTools.__getitem__("TopoCalibMoments").CalibrationHitContainerNames = ["LArCalibrationHitInactive","LArCalibrationHitActive","TileCalibHitActiveCell","TileCalibHitInactiveCell"]
69  topoAlg.ClusterCorrectionTools.__getitem__("TopoCalibMoments").DMCalibrationHitContainerNames = ["LArCalibrationHitDeadMaterial_DEAD","LArCalibrationHitInactive_DEAD","LArCalibrationHitActive_DEAD","TileCalibHitDeadMaterial"]
70 
71  # here add snapshots
72  from CaloRec.CaloTopoClusterConfig import addSnapshot
73  addSnapshot(topoAlg,"OOCPi0Calib","CaloOOCTopoCluster")
74  addSnapshot(topoAlg,"LocalCalib","CaloWTopoCluster")
75 
76  from CaloLocalHadCalib.CaloLCWPerformanceConfig import GetLCWPerfCfg
77  cfg.merge(GetLCWPerfCfg(flags))
78 
79  # configure output
80  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
81  myItemList = ['EventInfo#*', "McEventCollection#TruthEvent",
82  'xAOD::CaloClusterContainer#CaloCalTopoClusters',
83  'xAOD::CaloClusterAuxContainer#CaloCalTopoClustersAux.']
84 
85  cfg.merge( OutputStreamCfg(flags,"StreamDPD", ItemList=myItemList,
86  disableEventTag=True, takeItemsFromInput=False))
87 
88  # remove the default folders
89  from CaloLocalHadCalib.CaloLCWPerformanceConfig import blockFolder
90  blockFolder(cfg,"/CALO/Ofl/HadCalibration2/CaloEMFrac")
91  blockFolder(cfg,"/CALO/Ofl/HadCalibration2/H1ClusterCellWeights")
92  blockFolder(cfg,"/CALO/Ofl/HadCalibration2/CaloOutOfCluster")
93  blockFolder(cfg,"/CALO/Ofl/HadCalibration2/CaloOutOfClusterPi0")
94  blockFolder(cfg,"/CALO/Ofl/HadCalibration2/CaloDMCorr2")
95 
96 
97 
98  # LCW folders from sqlite files
99  clFolders=( ("/CALO/HadCalibration2/CaloEMFrac<tag>CaloEMFrac2-R3S-2021-02-00-00-FTFP-BERT-DT25-EPOS-A3-OFC25-MU60</tag>", "myclwooc.db","CaloLocalHadCoeff"),
100  ("/CALO/HadCalibration2/H1ClusterCellWeights<tag>CaloH1CellWeights2-R3S-2021-02-00-00-FTFP-BERT-DT25-EPOS-A3-OFC25-MU60</tag>", "myclwooc.db","CaloLocalHadCoeff"),
101  ("/CALO/HadCalibration2/CaloOutOfCluster<tag>CaloHadOOCCorr2-R3S-2021-02-00-00-FTFP-BERT-DT25-EPOS-A3-OFC25-MU60</tag>", "myclwooc.db","CaloLocalHadCoeff"),
102  ("/CALO/HadCalibration2/CaloOutOfClusterPi0<tag>CaloHadOOCCorrPi02-R3S-2021-02-00-00-FTFP-BERT-DT25-EPOS-A3-OFC25-MU60</tag>", "myclwooc.db","CaloLocalHadCoeff"),
103  ("/CALO/HadCalibration2/CaloDMCorr2<tag>CaloHadDMCorr2-R3S-2021-02-00-00-FTFP-BERT-DT25-EPOS-A3-OFC25-MU60</tag>", "myDm.db","CaloLocalHadCoeff") )
104  from IOVDbSvc.IOVDbSvcConfig import addFolderList
105  cfg.merge(addFolderList(flags, clFolders, db="OFLP200"))
106 
107  # for debugging purposes:
108  cfg.getService("StoreGateSvc").Dump=True
109  cfg.getService("MessageSvc").defaultLimit=999999
110 
111  cfg.run(10)
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
python.IOVDbSvcConfig.addFolderList
def addFolderList(flags, listOfFolderInfoTuple, extensible=False, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:99
python.CaloTopoClusterConfig.addSnapshot
def addSnapshot(topomaker, corrName, contName)
Definition: CaloTopoClusterConfig.py:470
CaloLCWPerformanceConfig.GetLCWPerfCfg
def GetLCWPerfCfg(flags)
Definition: CaloLCWPerformanceConfig.py:23
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
python.CaloTopoClusterConfig.CaloTopoClusterCfg
def CaloTopoClusterCfg(flags, cellsname="AllCalo", clustersname=None, clustersnapname="CaloTopoClusters")
Definition: CaloTopoClusterConfig.py:318
LCWConfigFlags.addLCWFlags
def addLCWFlags(flags)
Definition: LCWConfigFlags.py:3
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
CaloLCWPerformanceConfig.blockFolder
def blockFolder(ca, folder)
Definition: CaloLCWPerformanceConfig.py:9
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69