ATLAS Offline Software
LArNewCalib_PhysOFCPhasePicker.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 
11  # now process the CL options and assign defaults
12  parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
13  parser.add_argument('-r','--run', dest='run', default='00408918', help='Run number string as in input filename', type=str)
14  parser.add_argument('-g','--gain', dest='gain', default="MEDIUM", help='Gain string', type=str)
15  parser.add_argument('-d','--insqlitefile', dest='insqlitefile', default="", help='Input sqlite file with PhysOFC`', type=str)
16  parser.add_argument('-e','--outrdir', dest='outrdir', default="/eos/atlas/atlascerngroupdisk/det-larg/Temp/Weekly/ntuples", help='Output root file directory', type=str)
17  parser.add_argument('-k','--outpdir', dest='outpdir', default="/eos/atlas/atlascerngroupdisk/det-larg/Temp/Weekly/poolFiles", help='Output root file directory', type=str)
18  parser.add_argument('-l','--outprefix', dest='outprefix', default="LArPhysOFCOnePhase", help='Output root file name', type=str)
19  parser.add_argument('-n','--outsqlite', dest='outsql', default="mysql_physofconephase.db", help='Output sqlite file, in pool output dir.', type=str)
20  parser.add_argument('-c','--isSC', dest='supercells', action='store_true', default=False, help='is SC data ?')
21  parser.add_argument('-b','--badchansqlite', dest='badsql', default="SnapshotBadChannel.db", help='Input sqlite file for bad channels', type=str)
22  parser.add_argument('-m','--subdet', dest='subdet', default="EMB", help='Subdetector, EMB, EMEC, HEC or FCAL', type=str)
23  parser.add_argument('-s','--side', dest='side', default="C", help='Detector side empty (means both), C or A', type=str)
24  parser.add_argument('-w','--ofcwsqlite', dest='ofcwsql', default="", help='Input sqlite file for OFC weights', type=str)
25  parser.add_argument('-t','--ofcwtag', dest='ofcwtag', default="", help='Tag for OFC weights', type=str)
26  parser.add_argument('--poolcat', dest='poolcat', default="freshConstants.xml", help='Catalog of POOL files', type=str)
27  parser.add_argument('-p','--ofcphasesqlite', dest='ofcphsql', default="/afs/cern.ch/user/p/pavol/w0/public/DB_update_22/fillDB/SCOFCPhase.db", help='Input sqlite file for OFC phases', type=str)
28  parser.add_argument('-u','--ofcphasetag', dest='ofcphtag', default="LARElecCalibOflSCOFCBinPhysShift-07", help='Tag for OFC phases', type=str)
29  parser.add_argument('--isCalib', dest='caliofc', action='store_true', default=False, help='is caliOFCs ?')
30 
31  args = parser.parse_args()
32  if help in args and args.help is not None and args.help:
33  parser.print_help()
34  sys.exit(0)
35 
36  for _, value in args._get_kwargs():
37  if value is not None:
38  print(value)
39 
40  # now set flags according parsed options
41 
42  from LArCalibProcessing.LArCalib_OFPhasePickerConfig import LArOFPhasePickerCfg,LArCaliOFPhasePickerCfg
43 
44  #Import the MainServices (boilerplate)
45  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
46 
47  #Import the flag-container that is the arguemnt to the configuration methods
48  from AthenaConfiguration.AllConfigFlags import initConfigFlags
50  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
51  addLArCalibFlags(flags,args.supercells)
52 
53  #Now we set the flags as required for this particular job:
54  #The following flags help finding the input bytestream files:
55  flags.Input.Files=[]
56  flags.LArCalib.Input.Files = [ ]
57  flags.LArCalib.Input.RunNumbers = [int(args.run),]
58  gainNumMap={"HIGH":0,"MEDIUM":1,"LOW":2}
59  flags.LArCalib.Gain=gainNumMap[args.gain.upper()]
60 
61  if args.insqlitefile.startswith('/'):
62  flags.LArCalib.Input.Database = args.insqlitefile
63  else:
64  flags.LArCalib.Input.Database = args.outpdir + "/" + args.insqlitefile
65 
66  # pileup normalisation
67  flags.LArCalib.OFC.Ncoll = 60
68 
69  # others flags settings
70  flags.LArCalib.isSC = args.supercells
71  flags.LArCalib.Input.SubDet=args.subdet
72 
73  #Configure the Bad-Channel database we are reading
74  #(the AP typically uses a snapshot in an sqlite file
75  flags.LArCalib.BadChannelDB = args.badsql
76 
77  #Output of this job
78  OutputPoolFileName = args.outprefix+"_"+args.run
79  if args.subdet != "":
80  OutputPoolFileName += "_"+args.subdet
81  OutputPoolFileName += ".pool.root"
82 
83  idx=OutputPoolFileName.find('.pool.root')
84  if idx != -1:
85  OutputRootFileName = OutputPoolFileName[0:idx]+'.root'
86  else:
87  OutputRootFileName = OutputPoolFileName+'.root'
88 
89  flags.LArCalib.Output.ROOTFile = args.outrdir + "/" + OutputRootFileName
90  flags.LArCalib.Output.POOLFile = args.outpdir + "/" + OutputPoolFileName
91  if args.outsql.startswith('/'):
92  flags.IOVDb.DBConnection="sqlite://;schema=" + args.outsql +";dbname=CONDBR2"
93  else:
94  flags.IOVDb.DBConnection="sqlite://;schema="+args.outpdir + "/" + args.outsql +";dbname=CONDBR2"
95 
96  #The global tag we are working with
97  flags.IOVDb.GlobalTag = "LARCALIB-RUN2-00"
98 
99  from AthenaConfiguration.TestDefaults import defaultGeometryTags
100  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
101 
102  #Define the global output Level:
103  from AthenaCommon.Constants import INFO
104  flags.Exec.OutputLevel = INFO
105 
106  flags.lock()
107 
108  cfg=MainServicesCfg(flags)
109 
110  if args.caliofc:
111  cfg.merge(LArCaliOFPhasePickerCfg(flags))
112  else:
113  if args.supercells:
114 
115  if args.ofcwsql and args.ofcwtag:
116  cfg.merge(LArOFPhasePickerCfg(flags,InputSCOFCPhaseDb=args.ofcphsql,SCOFCPhaseTag=args.ofcphtag,InputSCOFCWeightDb=args.ofcwsql,SCOFCWeightTag=args.ofcwtag))
117  else:
118  cfg.merge(LArOFPhasePickerCfg(flags,InputSCOFCPhaseDb=args.ofcphsql,SCOFCPhaseTag=args.ofcphtag))
119  else:
120  cfg.merge(LArOFPhasePickerCfg(flags))
121 
122  cfg.getService("MessageSvc").defaultLimit = 9999999 # all messages
123  cfg.getService("PoolSvc").WriteCatalog="xmlcatalog_file:%s"%args.poolcat
124  cfg.getService("PoolSvc").ReadCatalog+=["xmlcatalog_file:%s"%args.poolcat]
125  #run the application
126  cfg.run(1)
127 
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.LArCalib_OFPhasePickerConfig.LArOFPhasePickerCfg
def LArOFPhasePickerCfg(flags, loadInputs=True, InputSCOFCPhaseDb="/afs/cern.ch/user/p/pavol/w0/public/DB_update_22/fillDB/SCOFCPhase.db", SCOFCPhaseTag="LARElecCalibOflSCOFCBinPhysShift-07", InputSCOFCWeightDb="", SCOFCWeightTag="")
Definition: LArCalib_OFPhasePickerConfig.py:135
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:252
Constants
some useful constants -------------------------------------------------—
python.LArCalib_OFPhasePickerConfig.LArCaliOFPhasePickerCfg
def LArCaliOFPhasePickerCfg(flags, loadInputs=True, DefaultPhase=23)
Definition: LArCalib_OFPhasePickerConfig.py:181
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3