ATLAS Offline Software
CaloCellPos2Ntuple.py
Go to the documentation of this file.
1 #!/bin/env python
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 
7 def CaloCellPos2NtupleCfg(flags,outputFile):
8 
10  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
11  cfg.merge(LArGMCfg(flags))
12  from TileGeoModel.TileGMConfig import TileGMCfg
13  cfg.merge(TileGMCfg(flags))
14 
15  cfg.addEventAlgo(CompFactory.CaloCellPosition2Ntuple())
16  cfg.addService(CompFactory.THistSvc(Output = ["file1 DATAFILE='"+outputFile+"' OPT='RECREATE'"]))
17 
18  return cfg
19 
20 if __name__=="__main__":
21  import sys,argparse
22  parser= argparse.ArgumentParser()
23  parser.add_argument("--loglevel", default=None, help="logging level (ALL, VERBOSE, DEBUG,INFO, WARNING, ERROR, or FATAL")
24  parser.add_argument("-r","--runnumber",default=0x7fffffff, type=int, help="run number to query the DB")
25  parser.add_argument("-l","--lbnumber",default=1, type=int, help="LB number to query the DB")
26  parser.add_argument("-d","--database",default=None, help="Database name or sqlite file name")
27  parser.add_argument("-o","--output",default="LArCellPos.root", help="output file name")
28  parser.add_argument("-f","--folder",default=None, help="database folder to read")
29  parser.add_argument("-t","--tag",default=None, help="folder-level tag to read")
30  parser.add_argument("-m","--mc", action='store_true', help="data or MC?")
31 
32 
33  (args,leftover)=parser.parse_known_args(sys.argv[1:])
34 
35  if len(leftover)>0:
36  print("ERROR, unhandled argument(s):",leftover)
37  sys.exit(-1)
38 
39  from AthenaConfiguration.AllConfigFlags import initConfigFlags
41  flags.Input.isMC = args.mc
42  flags.IOVDb.DatabaseInstance= "OFLP200" if args.mc else "CONDBR2"
43  from Campaigns.Utils import Campaign
44  flags.Input.MCCampaign=Campaign.Unknown
45  flags.LAr.doAlign=True
46 
47  flags.Input.TypedCollections=()
48 
49  flags.LAr.doHVCorr=False
50  flags.Input.RunNumbers=[args.runnumber]
51  flags.IOVDb.GlobalTag="OFLCOND-MC23-SDR-RUN3-05" if args.mc else "CONDBR2-BLKPA-2024-03"
52  from AthenaConfiguration.TestDefaults import defaultGeometryTags
53  flags.GeoModel.AtlasVersion=defaultGeometryTags.RUN3
54 
55 
56  if args.loglevel:
57  from AthenaCommon import Constants
58  if hasattr(Constants,args.loglevel):
59  flags.Exec.OutputLevel=getattr(Constants,args.loglevel)
60  else:
61  raise ValueError("Unknown log-level, allowed values are ALL, VERBOSE, DEBUG,INFO, WARNING, ERROR, FATAL")
62 
63  flags.lock()
64 
65  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
66  cfg=MainServicesCfg(flags)
67  #MC Event selector since we have no input data file
68  from McEventSelector.McEventSelectorConfig import McEventSelectorCfg
69  cfg.merge(McEventSelectorCfg(flags,
70  FirstLB=args.lbnumber,
71  EventsPerRun = 1,
72  FirstEvent = 1,
73  InitialTimeStamp = 0,
74  TimeStampInterval = 1))
75  cfg.addEventAlgo(CompFactory.xAODMaker.EventInfoCnvAlg(AODKey = 'McEventInfo'),sequenceName="AthAlgSeq")
76 
77  cfg.merge(CaloCellPos2NtupleCfg(flags,args.output))
78 
79  dbstr=None
80  if args.database:
81  dbstr="sqlite://;schema="+args.database+";dbname=" + flags.IOVDb.DatabaseInstance
82 
83  if args.tag or args.database:
84  from IOVDbSvc.IOVDbSvcConfig import addOverride
85  cfg.merge(addOverride(flags,"/LAR/LArCellPositionShift",args.tag,dbstr))
86 
87 
88  sc=cfg.run(1)
89  if sc.isSuccess():
90  sys.exit(0)
91  else:
92  sys.exit(1)
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CaloCellPos2Ntuple.CaloCellPos2NtupleCfg
def CaloCellPos2NtupleCfg(flags, outputFile)
Definition: CaloCellPos2Ntuple.py:7
python.IOVDbSvcConfig.addOverride
def addOverride(flags, folder, tag, db=None)
Definition: IOVDbSvcConfig.py:224
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.McEventSelectorConfig.McEventSelectorCfg
def McEventSelectorCfg(flags, **kwargs)
Definition: McEventSelectorConfig.py:5
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7