ATLAS Offline Software
IsoCloseByCorrectionTest.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentFactory import CompFactory
3 import logging
4 
5 def SetupArguments():
6  from argparse import ArgumentParser
7  parser = ArgumentParser()
8  parser.add_argument("--threads", "-t", type=int, help="number of threads", default=1)
9  parser.add_argument("--outputFile", default="IsoCloseByTestFile.root", help="File name of the output file", metavar="FILE")
10  parser.add_argument("--inputFile", "-i", default=[], help="Input file to run on ", nargs="+")
11  parser.add_argument("--dir", "-d", default=[], help="List of directories containing the root files", nargs="+")
12  parser.add_argument("--maxEvents", default=-1, type=int, help="How many events shall be run maximally")
13  parser.add_argument("--skipEvents", default=0, type=int, help="How many events shall be skipped at the beginning of the job")
14  return parser
15 
16 if __name__ == "__main__":
17  from AthenaConfiguration.AllConfigFlags import initConfigFlags
18  args = SetupArguments().parse_args()
19  flags = initConfigFlags()
20  flags.Concurrency.NumThreads = args.threads
21  flags.Concurrency.NumConcurrentEvents = args.threads # Might change this later, but good enough for the moment.
22  flags.Input.Files = [iii for ii in [i.split(',') for i in args.inputFile] for iii in ii]
23  from os import listdir
24  for direc in args.dir:
25  flags.Input.Files += ["%s/%s" % (direc, x) for x in listdir(direc) if x[x.rfind(".") + 1:] in ["root", "1"]]
26  if len(flags.Input.Files) == 0:
27  logging.warning("No input files were parsed")
28  flags.Exec.MaxEvents = args.maxEvents
29  flags.Exec.SkipEvents = args.skipEvents
30  flags.lock()
31  flags.dump()
32 
33  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
34  cfg = MainServicesCfg(flags)
35  msgService = cfg.getService('MessageSvc')
36  msgService.Format = "S:%s E:%e % F%128W%S%7W%R%T %0W%M"
37 
38  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
39  cfg.merge(PoolReadCfg(flags))
40 
41 
42  from IsolationAlgs.DerivationTrackIsoConfig import DerivationTrackIsoCfg
43  from IsolationSelection.IsolationSelectionConfig import (IsoCloseByCorrSkimmingAlgCfg, TestIsoCloseByCorrectionCfg,
44  IsolationSelectionToolCfg, IsoCloseByCorrectionToolCfg, IsoCloseByCaloDecorCfg)
45  # A selection of WP is probably needed, as only a few variables are in CP content !
46  # maybe MUON derivations can add some other ones for studies
47  listofTTVAWP = [ 'Nonprompt_All_MaxWeight' ]
48 
49  from DerivationFrameworkInDet.InDetCommonConfig import InDetCommonCfg
50  cfg.merge(InDetCommonCfg(flags,
51  DoVertexFinding = False,
52  AddPseudoTracks=False,
53  DecoLRTTTVA = False,
54  MergeLRT = False))
55  for WP in listofTTVAWP:
56  cfg.merge(DerivationTrackIsoCfg(flags, WP = WP, object_type = ('Electrons', 'Muons', 'Photons')))
57  cfg.merge(IsoCloseByCorrSkimmingAlgCfg(flags, ttva_wp = WP,
58  OutContainerKey="AssocCloseByTracks"))
59 
60  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
61  cfg.merge(LArGMCfg(flags))
62  from IsolationAlgs.IsolationSteeringDerivConfig import IsolationSteeringDerivCfg
63  cfg.merge(IsolationSteeringDerivCfg(flags))
64 
65  from MuonMomentumCorrections.MCastCfg import setupCalibratedMuonProviderCfg
66  cfg.merge(setupCalibratedMuonProviderCfg(flags))
67  from ElectronPhotonFourMomentumCorrection.EgammaCalibCfg import setupEgammaCalibProviderCfg
68  cfg.merge(setupEgammaCalibProviderCfg(flags, "ElectronProvider", Input="Electrons", Output="CalibElectrons"))
69  #cfg.merge(setupEgammaCalibProviderCfg(flags, "PhotonProvider", Input="Photons", Output="CalibPhotons"))
70  iso_tool = cfg.popToolsAndMerge(IsolationSelectionToolCfg(flags,
71  ElectronWP="PflowTight_FixedRad",
72  MuonWP="PflowTight_FixedRad",
73  InMuonContainer = "Muons",
74  InElecContainer = "Electrons"))
75  iso_corr_tool = cfg.popToolsAndMerge(IsoCloseByCorrectionToolCfg(flags,
76  BackupPrefix="vanilla",
77  IsolationSelectionTool = iso_tool,
78  SelectionDecorator = "considerInCorrection",
79  IsolationSelectionDecorator = "correctedIsol"))
80 
81  cfg.merge(IsoCloseByCaloDecorCfg(flags,
82  containers = ["Electrons", "Muons", "Photons"] ))
83 
84  cfg.merge(TestIsoCloseByCorrectionCfg(flags,
85  BackupPrefix="vanilla",
86  MuonContainer = "CalibratedMuons",
87  EleContainer = "CalibElectrons",
88  PhotContainer = "",
89  TrackKey = "AssocCloseByTracks",
90  IsolationSelectionTool = iso_tool,
91  SelectionDecorator = "considerInCorrection",
92  IsolationDecorator = "defaultIso",
93  UpdatedIsoDecorator="correctedIsol",
94  IsoCloseByCorrTool = iso_corr_tool))
95 
96  histSvc = CompFactory.THistSvc(Output=["ISOCORRECTION DATAFILE='%s', OPT='RECREATE'"%(args.outputFile)])
97  cfg.addService(histSvc)
98 
99  sc = cfg.run(flags.Exec.MaxEvents)
100  if not sc.isSuccess():
101  exit(1)
IsolationSelectionConfig.TestIsoCloseByCorrectionCfg
def TestIsoCloseByCorrectionCfg(flags, name="TestIsoCloseByAlg", suff="", **kwargs)
Definition: IsolationSelectionConfig.py:125
IsolationSteeringDerivConfig.IsolationSteeringDerivCfg
def IsolationSteeringDerivCfg(flags, name='IsolationSteeringDeriv', inType='EMPFlow')
Definition: IsolationSteeringDerivConfig.py:11
python.dummyaccess.listdir
def listdir(dirname)
Definition: dummyaccess.py:6
IsolationSelectionConfig.IsoCloseByCorrectionToolCfg
def IsoCloseByCorrectionToolCfg(flags, name="IsoCloseByCorrectionTool", ttva_wp="", **kwargs)
Definition: IsolationSelectionConfig.py:14
MCastCfg.setupCalibratedMuonProviderCfg
def setupCalibratedMuonProviderCfg(flags, name="CalibratedMuonProvider", calibMode=1, **kwargs)
Definition: MCastCfg.py:20
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
EgammaCalibCfg.setupEgammaCalibProviderCfg
def setupEgammaCalibProviderCfg(flags, name="EgammaCalibProvider", **kwargs)
Definition: EgammaCalibCfg.py:15
calibdata.exit
exit
Definition: calibdata.py:236
IsolationSelectionConfig.IsoCloseByCorrSkimmingAlgCfg
def IsoCloseByCorrSkimmingAlgCfg(flags, suff="", name="IsoCloseByCorrSkimmingAlg", ttva_wp='Nonprompt_All_MaxWeight', **kwargs)
Definition: IsolationSelectionConfig.py:29
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
IsolationSelectionConfig.IsolationSelectionToolCfg
def IsolationSelectionToolCfg(flags, name="IsolationSelectionTool", **kwargs)
Definition: IsolationSelectionConfig.py:6
IsolationSelectionConfig.IsoCloseByCaloDecorCfg
def IsoCloseByCaloDecorCfg(flags, name="IsoCloseByCaloDecor", suff="", containers=[], **kwargs)
Definition: IsolationSelectionConfig.py:111
python.InDetCommonConfig.InDetCommonCfg
def InDetCommonCfg(flags, **kwargs)
Definition: InDetCommonConfig.py:16
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
confTool.parse_args
def parse_args()
Definition: confTool.py:35
DerivationTrackIsoConfig.DerivationTrackIsoCfg
def DerivationTrackIsoCfg(flags, **jwarg)
Definition: DerivationTrackIsoConfig.py:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69