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="PoolFileCatalog.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-08", help='Tag for OFC phases', type=str)
29  parser.add_argument('--Ncoll',dest='Ncoll', default=60, help='Number of MinBias collision assumed for OFCs folder', type=int)
30  parser.add_argument('--isCalib', dest='caliofc', action='store_true', default=False, help='is caliOFCs ?')
31 
32  args = parser.parse_args()
33  if help in args and args.help is not None and args.help:
34  parser.print_help()
35  sys.exit(0)
36 
37  for _, value in args._get_kwargs():
38  if value is not None:
39  print(value)
40 
41  # now set flags according parsed options
42 
43  from LArCalibProcessing.LArCalib_OFPhasePickerConfig import LArOFPhasePickerCfg,LArCaliOFPhasePickerCfg
44 
45  #Import the MainServices (boilerplate)
46  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
47 
48  #Import the flag-container that is the arguemnt to the configuration methods
49  from AthenaConfiguration.AllConfigFlags import initConfigFlags
51  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
52  addLArCalibFlags(flags,args.supercells)
53 
54  #Now we set the flags as required for this particular job:
55  #The following flags help finding the input bytestream files:
56  flags.Input.Files=[]
57  flags.LArCalib.Input.Files = [ ]
58  flags.LArCalib.Input.RunNumbers = [int(args.run),]
59  gainNumMap={"HIGH":0,"MEDIUM":1,"LOW":2}
60  flags.LArCalib.Gain=gainNumMap[args.gain.upper()]
61 
62  if args.insqlitefile.startswith('/'):
63  flags.LArCalib.Input.Database = args.insqlitefile
64  else:
65  flags.LArCalib.Input.Database = args.outpdir + "/" + args.insqlitefile
66 
67  # pileup normalisation
68  flags.LArCalib.OFC.Ncoll = args.Ncoll
69 
70  # others flags settings
71  flags.LArCalib.isSC = args.supercells
72  flags.LArCalib.Input.SubDet=args.subdet
73 
74  #Configure the Bad-Channel database we are reading
75  #(the AP typically uses a snapshot in an sqlite file
76  flags.LArCalib.BadChannelDB = args.badsql
77 
78  #Output of this job
79  OutputPoolFileName = args.outprefix+"_"+args.run
80  if args.subdet != "":
81  OutputPoolFileName += "_"+args.subdet
82  OutputPoolFileName += ".pool.root"
83 
84  idx=OutputPoolFileName.find('.pool.root')
85  if idx != -1:
86  OutputRootFileName = OutputPoolFileName[0:idx]+'.root'
87  else:
88  OutputRootFileName = OutputPoolFileName+'.root'
89 
90  flags.LArCalib.Output.ROOTFile = args.outrdir + "/" + OutputRootFileName
91  flags.LArCalib.Output.POOLFile = args.outpdir + "/" + OutputPoolFileName
92  if args.outsql.startswith('/'):
93  flags.IOVDb.DBConnection="sqlite://;schema=" + args.outsql +";dbname=CONDBR2"
94  else:
95  flags.IOVDb.DBConnection="sqlite://;schema="+args.outpdir + "/" + args.outsql +";dbname=CONDBR2"
96 
97  #The global tag we are working with
98  flags.IOVDb.GlobalTag = "LARCALIB-RUN2-00"
99 
100  from AthenaConfiguration.TestDefaults import defaultGeometryTags
101  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
102 
103  #Define the global output Level:
104  from AthenaCommon.Constants import INFO
105  flags.Exec.OutputLevel = INFO
106 
107  flags.lock()
108 
109  cfg=MainServicesCfg(flags)
110 
111  if args.caliofc:
112  cfg.merge(LArCaliOFPhasePickerCfg(flags))
113  else:
114  if args.supercells:
115 
116  if args.ofcwsql and args.ofcwtag:
117  cfg.merge(LArOFPhasePickerCfg(flags,InputSCOFCPhaseDb=args.ofcphsql,SCOFCPhaseTag=args.ofcphtag,InputSCOFCWeightDb=args.ofcwsql,SCOFCWeightTag=args.ofcwtag))
118  else:
119  cfg.merge(LArOFPhasePickerCfg(flags,InputSCOFCPhaseDb=args.ofcphsql,SCOFCPhaseTag=args.ofcphtag))
120  else:
121  cfg.merge(LArOFPhasePickerCfg(flags))
122 
123  cfg.getService("MessageSvc").defaultLimit = 9999999 # all messages
124  cfg.getService("PoolSvc").WriteCatalog="xmlcatalog_file:%s"%args.poolcat
125  cfg.getService("PoolSvc").ReadCatalog+=["xmlcatalog_file:%s"%args.poolcat]
126  #run the application
127  cfg.run(1)
128 
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:260
Constants
some useful constants -------------------------------------------------—
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
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
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3