ATLAS Offline Software
LArNewCalib_PhysWave.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 PhysWaves`', 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="LArPhysWave", help='Output root file name', type=str)
19  parser.add_argument('-n','--outsqlite', dest='outsql', default="mysql_physwave.db", help='Output sqlite file, in pool output dir.', type=str)
20  parser.add_argument('-c','--isSC', dest='supercells', default=False, action="store_true", 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 
25  args = parser.parse_args()
26  if help in args and args.help is not None and args.help:
27  parser.print_help()
28  sys.exit(0)
29 
30  for _, value in args._get_kwargs():
31  if value is not None:
32  print(value)
33 
34  # now set flags according parsed options
35 
36  from LArCalibProcessing.LArCalib_PhysWavePredictionConfig import LArPhysWavePredictionCfg
37 
38  #Import the MainServices (boilerplate)
39  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
40 
41  #Import the flag-container that is the arguemnt to the configuration methods
42  from AthenaConfiguration.AllConfigFlags import initConfigFlags
44  from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
45 
46  addLArCalibFlags(flags, args.supercells)
47 
48  #Now we set the flags as required for this particular job:
49  #The following flags help finding the input bytestream files:
50  flags.Input.Files=[]
51  flags.LArCalib.Input.Files = [ ]
52  flags.LArCalib.Input.RunNumbers = [int(args.run),]
53  gainNumMap={"HIGH":0,"MEDIUM":1,"LOW":2}
54  flags.LArCalib.Gain=gainNumMap[args.gain.upper()]
55 
56  if args.insqlitefile.startswith("/"):
57  flags.LArCalib.Input.Database = args.insqlitefile
58  else:
59  flags.LArCalib.Input.Database = args.outpdir + "/" + args.insqlitefile
60 
61  # others flags settings
62  flags.LArCalib.Input.SubDet=args.subdet
63 
64  #Configure the Bad-Channel database we are reading
65  #(the AP typically uses a snapshot in an sqlite file
66  flags.LArCalib.BadChannelDB = args.badsql
67 
68  #Output of this job
69  OutputPoolFileName = args.outprefix+"_"+args.run
70  if args.subdet != "":
71  OutputPoolFileName += "_"+args.subdet
72  OutputPoolFileName += ".pool.root"
73 
74  idx=OutputPoolFileName.find('.pool.root')
75  if idx != -1:
76  OutputRootFileName = OutputPoolFileName[0:idx]+'.root'
77  else:
78  OutputRootFileName = OutputPoolFileName+'.root'
79 
80  flags.LArCalib.Output.ROOTFile = args.outrdir + "/" + OutputRootFileName
81  flags.LArCalib.Output.POOLFile = args.outpdir + "/" + OutputPoolFileName
82  if args.outsql.startswith("/"):
83  flags.IOVDb.DBConnection="sqlite://;schema=" + args.outsql +";dbname=CONDBR2"
84  else:
85  flags.IOVDb.DBConnection="sqlite://;schema="+args.outpdir + "/" + args.outsql +";dbname=CONDBR2"
86 
87  #The global tag we are working with
88  flags.IOVDb.GlobalTag = "LARCALIB-RUN2-00"
89 
90  from AthenaConfiguration.TestDefaults import defaultGeometryTags
91  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
92 
93  #Define the global output Level:
94  from AthenaCommon.Constants import INFO
95  flags.Exec.OutputLevel = INFO
96 
97  flags.lock()
98 
99  cfg=MainServicesCfg(flags)
100 
101  cfg.merge(LArPhysWavePredictionCfg(flags))
102 
103  cfg.printConfig(withDetails=True,printDefaults=True)
104 
105  cfg.getService("MessageSvc").defaultLimit = 9999999 # all messages
106 
107  #run the application
108  cfg.run(1)
109 
110  #Copying the FCAL phys wave to sqlite here
111  if "HEC" in args.subdet.upper():
112  copycmd='AtlCoolCopy "COOLOFL_LAR/CONDBR2" "'+flags.IOVDb.DBConnection+'" -f '+ flags.LArCalib.FCALPhysWave.Folder+' -t LARElecCalibOflPhysWavesFCALFromTB-calib-01 -of /LAR/ElecCalibOfl/PhysWaves/RTM -ot LARElecCalibOflPhysWavesRTM-RUN2-UPD3-00 -a '
113  from subprocess import getstatusoutput
114  stat,out=getstatusoutput(copycmd)
115 
116  if (stat):
117  print("ERROR could not copy the FCAL PhysWaves")
118  print(out)
119  sys.exit(-1)
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
python.LArCalib_PhysWavePredictionConfig.LArPhysWavePredictionCfg
def LArPhysWavePredictionCfg(flags)
Definition: LArCalib_PhysWavePredictionConfig.py:6
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
python.LArCalibConfigFlags.addLArCalibFlags
def addLArCalibFlags(flags, isSC=False)
Definition: LArCalibConfigFlags.py:3