ATLAS Offline Software
Loading...
Searching...
No Matches
LArPhysWaveFromAsciiConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentFactory import CompFactory
4from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5
6
7def LArPhysWaveFromAsciiCfg(flags,InputFile='',hasIndex=False, **kwargs):
8
9 cfg=ComponentAccumulator()
10 from AthenaCommon.Logging import logging
11 mlog = logging.getLogger( 'LArPhysWaveFromAscii' )
12 if not flags.hasCategory('LArCalib'):
13 mlog.error("We need the LArCalib flags")
14 return cfg
15
16 if flags.LArCalib.isSC:
17 mlog.info("Running for SC")
18
19 from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg
20 cfg.merge(LArCalibBaseCfg(flags))
21
22 from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
23 cfg.merge(LArOnOffIdMappingCfg(flags))
24
25 if 'SkipPoints' not in kwargs:
26 kwargs.setdefault('SkipPoints', 0)
27 if 'PrefixPoints' not in kwargs:
28 kwargs.setdefault('PrefixPoints', 0)
29 if 'StoreKey' not in kwargs:
30 kwargs.setdefault('StoreKey', 'LArPhysWaveSCMeasured')
31
32 algo = CompFactory.LArPhysWaveFromAscii("LArPhysWaveFromAscii", **kwargs)
33 algo.InputFile = InputFile
34 algo.GroupingType = flags.LArCalib.GroupingType
35 algo.isSC = flags.LArCalib.isSC
36 algo.Index = hasIndex
37
38 cfg.addEventAlgo(algo)
39
40 if flags.LArCalib.Output.ROOTFile != "":
41
42 ntdump = CompFactory.LArPhysWaves2Ntuple( "LArPhysWaves2Ntuple" )
43 ntdump.NtupleName = "PHYSWAVE"
44 ntdump.KeyList = [ kwargs['StoreKey'] ]
45 ntdump.SaveDerivedInfo = True
46 if flags.LArCalib.isSC:
47 ntdump.isSC = flags.LArCalib.isSC
48 ntdump.BadChanKey = "LArBadChannelSC"
49
50 cfg.addEventAlgo(ntdump)
51
52 cfg.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+flags.LArCalib.Output.ROOTFile+"' OPT='NEW'" ]))
53 cfg.setAppProperty("HistogramPersistency","ROOT")
54
55 if ( flags.LArCalib.Output.POOLFile != "" ):
56
57 OutputObjectSpecPhysWave = "LArPhysWaveContainer#"+kwargs['StoreKey']+"#"+ flags.LArCalib.PhysWave.Folder
58 OutputObjectSpecTagPhysWave = ''.join(flags.LArCalib.PhysWave.Folder.split('/')) + "-test-00"
59
60 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
61 cfg.merge(OutputConditionsAlgCfg(flags,
62 outputFile=flags.LArCalib.Output.POOLFile,
63 ObjectList=[OutputObjectSpecPhysWave],
64 IOVTagList=[OutputObjectSpecTagPhysWave],
65 Run1=flags.LArCalib.IOVStart,
66 Run2=flags.LArCalib.IOVEnd
67 ))
68
69 cfg.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = True))
70
71
72 cfg.getService("IOVDbSvc").DBInstance=""
73
74 return cfg
75
76
77if __name__ == "__main__":
78 import argparse
79
80 # now process the CL options and assign defaults
81 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
82 parser.add_argument('-r','--run', dest='run', default=508000, help='Run number ', type=int)
83 parser.add_argument('-o','--outsqlite', dest='outsql', default="output.db", help='Output sqlite file', type=str)
84 parser.add_argument('-f','--folder', dest='folder', default="/LAR/ElecCalibOflSC/PhysWaves/Measured", help='Folder to fill ', type=str)
85 parser.add_argument('--infile', dest='infile', default="", help='Input text file file', type=str)
86 parser.add_argument('--poolfile', dest='poolfile', default="LArPhysWave_SC.pool.root", help='Output pool file', type=str)
87 parser.add_argument('--rootfile', dest='rootfile', default="LArPhysWave_SC.root", help='Output ROOT file', type=str)
88 parser.add_argument('--isSC', dest='supercells', default=False, help='is SC data ?', action='store_true')
89 parser.add_argument('--hasIndex', dest='index', default=False, help='has index in input ?', action='store_true')
90
91 args = parser.parse_args()
92
93 for _, value in args._get_kwargs():
94 if value is not None:
95 print(_,":",value)
96
97 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
98 from AthenaConfiguration.AllConfigFlags import initConfigFlags
99 from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
100 flags=initConfigFlags()
101 addLArCalibFlags(flags,isSC=True)
102
103 flags.Input.Files=[]
104 flags.Input.RunNumbers=[args.run,]
105 flags.Input.ConditionsRunNumber=args.run
106 flags.Input.OverrideRunNumber=True
107 from AthenaConfiguration.TestDefaults import defaultGeometryTags
108 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
109
110 flags.LArCalib.PhysWave.Folder=args.folder
111 flags.LArCalib.Output.ROOTFile=args.rootfile
112 flags.LArCalib.Output.POOLFile=args.poolfile
113 if args.supercells:
114 flags.LArCalib.GroupingType="SuperCells"
115 else:
116 flags.LArCalib.GroupingType="ExtendedSubDetector"
117 flags.IOVDb.DBConnection="sqlite://;schema="+args.outsql+";dbname=CONDBR2"
118 flags.IOVDb.GlobalTag="LARCALIB-RUN2-00"
119 flags.IOVDb.DatabaseInstance="CONDBR2"
120
121 #flags.fillFromArgs()
122 flags.lock()
123
124
125 cfg=MainServicesCfg(flags)
126 cfg.merge(LArPhysWaveFromAsciiCfg(flags,InputFile=args.infile,hasIndex=args.index))
127
128 cfg.run(1)
129
void print(char *figname, TCanvas *c1)
LArPhysWaveFromAsciiCfg(flags, InputFile='', hasIndex=False, **kwargs)