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