ATLAS Offline Software
Loading...
Searching...
No Matches
LArCaliWaveFromTupleConfig.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 LArCaliWaveFromTupleCfg(flags,InputRootFile='PhysWave.root',
8 OutputTag='-calib-00', **kwargs):
9
10 cfg=ComponentAccumulator()
11 from AthenaCommon.Logging import logging
12 mlog = logging.getLogger( 'LArCaliWaveFromTuple' )
13 if not flags.hasCategory('LArCalib'):
14 mlog.error("We need the LArCalib flags")
15 return cfg
16
17 if flags.LArCalib.isSC:
18 mlog.info("Running for SC")
19
20 from LArCalibProcessing.LArCalibBaseConfig import LArCalibBaseCfg
21 cfg.merge(LArCalibBaseCfg(flags))
22
23 from LArCabling.LArCablingConfig import LArOnOffIdMappingCfg
24 cfg.merge(LArOnOffIdMappingCfg(flags))
25
26 if 'NtupleName' not in kwargs:
27 kwargs.setdefault('NtupleName', 'CALIWAVE')
28 if 'SkipPoints' not in kwargs:
29 kwargs.setdefault('SkipPoints', 0)
30 if 'PrefixPoints' not in kwargs:
31 kwargs.setdefault('PrefixPoints', 0)
32 if 'StoreKey' not in kwargs:
33 kwargs.setdefault('StoreKey', 'FromTuple')
34
35 algo = CompFactory.LArCaliWaveFromTuple("LArCaliWaveFromTuple", **kwargs)
36 algo.FileName = InputRootFile
37 algo.GroupingType = flags.LArCalib.GroupingType
38 algo.isSC = flags.LArCalib.isSC
39
40 cfg.addEventAlgo(algo)
41
42 if flags.LArCalib.Output.ROOTFile != "":
43
44 ntdump = CompFactory.LArCaliWaves2Ntuple( "LArCaliWaves2Ntuple" )
45 ntdump.NtupleName = "CALIWAVE"
46 ntdump.KeyList = [ kwargs['StoreKey'] ]
47 ntdump.SaveDerivedInfo = True
48 if flags.LArCalib.isSC:
49 ntdump.isSC = flags.LArCalib.isSC
50 ntdump.BadChanKey = "LArBadChannelSC"
51
52 cfg.addEventAlgo(ntdump)
53
54 cfg.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+flags.LArCalib.Output.ROOTFile+"' OPT='NEW'" ]))
55 cfg.setAppProperty("HistogramPersistency","ROOT")
56
57 if ( flags.LArCalib.Output.POOLFile != "" ):
58
59 OutputObjectSpecCaliWave = "LArCaliWaveContainer#"+kwargs['StoreKey']+"#"+ flags.LArCalib.CaliWave.Folder
60 OutputObjectSpecTagCaliWave = ''.join(flags.LArCalib.CaliWave.Folder.split('/')) + OutputTag
61
62 from RegistrationServices.OutputConditionsAlgConfig import OutputConditionsAlgCfg
63 cfg.merge(OutputConditionsAlgCfg(flags,
64 outputFile=flags.LArCalib.Output.POOLFile,
65 ObjectList=[OutputObjectSpecCaliWave],
66 IOVTagList=[OutputObjectSpecTagCaliWave],
67 Run1=flags.LArCalib.IOVStart,
68 Run2=flags.LArCalib.IOVEnd
69 ))
70
71 cfg.addService(CompFactory.IOVRegistrationSvc(RecreateFolders = True))
72
73
74 cfg.getService("IOVDbSvc").DBInstance=""
75
76 return cfg
77
78
79if __name__ == "__main__":
80
81 import argparse
82
83 # now process the CL options and assign defaults
84 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
85 parser.add_argument('-r','--run', dest='run', default=508000, help='Run number ', type=int)
86 parser.add_argument('-p','--npoints', dest='npoints', default=32, help='Number of samples to output', type=int)
87 parser.add_argument('-o','--outsqlite', dest='outsql', default="output.db", help='Output sqlite file', type=str)
88 parser.add_argument('-f','--folder', dest='folder', default="/LAR/ElecCalibOflSC/CaliWaves/CaliWave", help='Folder to fill ', type=str)
89 parser.add_argument('--infile', dest='infile', default="", help='Input root file file', type=str)
90 parser.add_argument('--poolfile', dest='poolfile', default="LArCaliWave.pool.root", help='Output pool file', type=str)
91 parser.add_argument('--rootfile', dest='rootfile', default="LArCaliWave.root", help='Output ROOT file', type=str)
92 parser.add_argument('--isSC', dest='supercells', default=False, help='is SC data ?', action='store_true')
93 parser.add_argument('-n','--ntuple', dest='ntuple', default="Data", help='Input ntuple name', type=str)
94 parser.add_argument('-t','--tag', dest='tag', default="-RUN4-EMF-00", help='Output tag suffix', type=str)
95
96 args = parser.parse_args()
97
98 for key, value in args._get_kwargs():
99 if value is not None:
100 print(key,":",value)
101
102
103 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
104 from AthenaConfiguration.AllConfigFlags import initConfigFlags
105 from LArCalibProcessing.LArCalibConfigFlags import addLArCalibFlags
106 flags=initConfigFlags()
107 addLArCalibFlags(flags,isSC=args.supercells)
108
109 flags.Input.Files=[]
110 flags.Input.RunNumbers=[args.run,]
111 flags.Input.ConditionsRunNumber=args.run
112 flags.Input.OverrideRunNumber=True
113
114 flags.LArCalib.CaliWave.Folder=args.folder
115 flags.LArCalib.Output.ROOTFile=args.rootfile
116 flags.LArCalib.Output.POOLFile=args.poolfile
117 flags.LArCalib.GroupingType="ExtendedFeedThrough"
118 flags.IOVDb.GlobalTag="LARCALIB-RUN2-00"
119 flags.IOVDb.DatabaseInstance="CONDBR2"
120 flags.IOVDb.DBConnection="sqlite://;schema="+args.outsql+";dbname=CONDBR2"
121 from AthenaConfiguration.TestDefaults import defaultGeometryTags
122 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
123
124
125 flags.lock()
126
127
128 cfg=MainServicesCfg(flags)
129 cfg.merge(LArCaliWaveFromTupleCfg(flags,InputRootFile=args.infile,NtupleName=args.ntuple, OutputTag=args.tag, NPoints=args.npoints))
130
131 cfg.run(1)
132
void print(char *figname, TCanvas *c1)
LArCaliWaveFromTupleCfg(flags, InputRootFile='PhysWave.root', OutputTag='-calib-00', **kwargs)