5 from AthenaConfiguration.ComponentFactory
import CompFactory
6 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
8 if __name__==
'__main__':
13 from AthenaCommon
import Logging
14 log = Logging.logging.getLogger(
'LArSC2Ntuple' )
16 parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
18 parser.add_argument(
'-i',
'--indir', dest=
'indir', default=
"/eos/atlas/atlastier0/rucio/data_test/calibration_pulseall/00414414/data_test.00414414.calibration_pulseall.daq.RAW/", help=
'input files dir', type=str)
19 parser.add_argument(
'-p',
'--inprefix', dest=
'inpref', default=
"data_test", help=
'Input filenames prefix', type=str)
20 parser.add_argument(
'-y',
'--inppatt', dest=
'inppatt', default=
"lb3512", help=
'Input filenames pattern', type=str)
21 parser.add_argument(
'-f',
'--infile', dest=
'infile', default=
"", help=
'Input filename (if given indir and inprefix are ignored', type=str)
22 parser.add_argument(
'-r',
'--run', dest=
'run', default=0, help=
'Run number (if not given trying to judge from input file name)', type=int)
23 parser.add_argument(
'-m',
'--maxev', dest=
'maxev', default=-1, help=
'Max number of events to dump', type=int)
24 parser.add_argument(
'-x',
'--outlevel', dest=
'olevel', default=5, help=
'OuputLevel for dumping algo', type=int)
25 parser.add_argument(
'-o',
'--outfile', dest=
'outfile', default=
"Digits.root", help=
'Output root filename', type=str)
26 parser.add_argument(
'-s',
'--addSamples', dest=
'samples', default=
False, help=
'Add Samples to output ntuple', action=
"store_true")
27 parser.add_argument(
'-a',
'--addSampBas', dest=
'samplesBas', default=
False, help=
'Add ADC_BAS to output ntuple', action=
"store_true")
28 parser.add_argument(
'--addAccSamples', dest=
'accsamples', default=
False, help=
'work on accumulated samples', action=
"store_true")
29 parser.add_argument(
'--addAccCalibSamples', dest=
'acccalibsamples', default=
False, help=
'work on accumulated samples', action=
"store_true")
30 parser.add_argument(
'-z',
'--addEt', dest=
'Et', default=
False, help=
'Add ET to output ntuple', action=
"store_true")
31 parser.add_argument(
'-g',
'--addEtId', dest=
'EtId', default=
False, help=
'Add ET_ID to output ntuple', action=
"store_true")
32 parser.add_argument(
'-l',
'--noLatHeader', dest=
'lheader', default=
True, help=
'Add LATOME Header to output ntuple', action=
'store_false')
33 parser.add_argument(
'-b',
'--noBCID', dest=
'bcid', default=
True, help=
'Add BCID info to output ntuple', action=
'store_false')
34 parser.add_argument(
'-e',
'--expandId', dest=
'expid', default=
False, help=
'Expand online Id to fields', action=
'store_true')
35 parser.add_argument(
'-n',
'--nsamp', dest=
'nsamp', default=0, help=
'Number of samples to dump', type=int)
36 parser.add_argument(
'-c',
'--overEvNumber', dest=
'overEvN', default=
False, help=
'Overwrite event number', action=
'store_true')
37 parser.add_argument(
'-d',
'--addHash', dest=
'ahash', default=
False, help=
'Add hash number to output ntuple', action=
'store_true')
38 parser.add_argument(
'-j',
'--addOffline', dest=
'offline', default=
False, help=
'Add offline Id to output ntuple', action=
'store_true')
39 parser.add_argument(
'-k',
'--addCalib', dest=
'calib', default=
False, help=
'Add calib. info to output ntuple', action=
'store_true')
40 parser.add_argument(
'-t',
'--addGeom', dest=
'geom', default=
False, help=
'Add real geom info to output ntuple', action=
'store_true')
41 parser.add_argument(
'-u',
'--noBC', dest=
'bc', default=
False, help=
'Add Bad. chan info to output ntuple', action=
'store_true')
42 parser.add_argument(
'-w',
'--addROD', dest=
'rod', default=
False, help=
'Add ROD energies sum to output ntuple', action=
'store_true')
43 parser.add_argument(
'-v',
'--addEvTree', dest=
'evtree', default=
False, help=
'Add tree with per event info to output ntuple', action=
'store_true')
44 parser.add_argument(
'-q',
'--addNoisyRO', dest=
'noisyRO', default=
False, help=
'Add reco and info from LArNoisyROSummary to output ntuple', action=
'store_true')
45 parser.add_argument(
'--addTT', dest=
'TT', default=
False, help=
'Add info from LArTriggerTowers to output ntuple', action=
'store_true')
46 parser.add_argument(
'--EMF', dest=
'emf', default=
False, help=
'Is it for EMF', action=
'store_true')
47 parser.add_argument(
'--FW6', dest=
'fw6', default=
False, help=
'Is it for fw v. 6', action=
'store_true')
49 args = parser.parse_args()
50 if help
in args
and args.help
is not None and args.help:
54 for _, value
in args._get_kwargs():
59 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
61 if args.accsamples
or args.acccalibsamples:
62 from LArCalibProcessing.LArCalibConfigFlags
import addLArCalibFlags
65 from LArCafJobs.LArSCDumperFlags
import addSCDumpFlags
69 if (args.accsamples
or args.acccalibsamples)
and (args.samples
or args.samplesBas):
70 log.error(
'Could not dump both samples and accumulated calib samples')
72 if args.accsamples
and args.acccalibsamples:
73 log.error(
'Could not dump both accsamples and acc calib samples')
76 if len(args.infile) > 0:
77 flags.Input.Files = [args.infile]
78 elif len(args.inppatt) > 0:
79 from LArCalibProcessing.GetInputFiles
import GetInputFilesFromPattern
82 from LArCalibProcessing.GetInputFiles
import GetInputFilesFromPrefix
86 flags.Input.RunNumbers = [args.run]
89 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
90 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
93 flags.LArSCDump.accdigitsKey=
"accSC"
95 flags.LArSCDump.accdigitsKey=
""
96 if args.acccalibsamples:
97 flags.LArSCDump.acccalibdigitsKey=
"acccalibSC"
99 flags.LArSCDump.acccalibdigitsKey=
""
101 flags.LArSCDump.digitsKey=
""
102 if not (args.accsamples
or args.acccalibsamples):
107 log.info(
"Got DT run info !")
109 log.warning(
"Could not get DT run info, using defaults !")
110 flags.LArSCDump.doEt=
True
112 flags.LArSCDump.nSamples=args.nsamp
114 flags.LArSCDump.nSamples=5
115 flags.LArSCDump.nEt=1
117 flags.LArSCDump.digitsKey=
"SC"
121 flags.LArSCDump.digitsKey=
""
122 for i
in range(0,len(runinfo.streamTypes())):
123 if args.EtId
and runinfo.streamTypes()[i] ==
"SelectedEnergy":
124 CKeys += [
"SC_ET_ID"]
125 flags.LArSCDump.doEt=
True
126 flags.LArSCDump.nEt=runinfo.streamLengths()[i]
127 elif args.Et
and runinfo.streamTypes()[i] ==
"Energy":
129 flags.LArSCDump.doEt=
True
130 flags.LArSCDump.nEt=runinfo.streamLengths()[i]
131 elif args.samples
and runinfo.streamTypes()[i] ==
"RawADC":
132 flags.LArSCDump.digitsKey=
"SC"
134 flags.LArSCDump.nSamples=args.nsamp
136 flags.LArSCDump.nSamples=runinfo.streamLengths()[i]
137 elif args.samplesBas
and runinfo.streamTypes()[i] ==
"ADC":
138 CKeys += [
"SC_ADC_BAS"]
139 flags.LArSCDump.doSamplesBas=
True
141 flags.LArSCDump.nSamples=args.nsamp
143 flags.LArSCDump.nSamples=runinfo.streamLengths()[i]
144 if args.nsamp > 0
and args.nsamp < flags.LArSCDump.nSamples:
145 flags.LArSCDump.nSamples=args.nsamp
149 flags.LArSCDump.accdigitsKey =
"accSC"
150 flags.Input.OverrideRunNumber =
True
156 if args.samples
and not (
"SC" in flags.LArSCDump.digitsKey):
157 flags.LArSCDump.digitsKey=
"SC"
158 if args.samplesBas
and "SC_ADC_BAS" not in CKeys:
159 CKeys += [
"SC_ADC_BAS"]
160 flags.LArSCDump.doSamplesBas=
True
161 if args.Et
and "SC_ET" not in CKeys:
163 if args.EtId
and "SC_ET_ID" not in CKeys:
164 CKeys += [
"SC_ET_ID"]
165 if args.lheader
and "SC_LATOME_HEADER" not in CKeys:
166 CKeys += [
"SC_LATOME_HEADER"]
169 flags.LArSCDump.doRawChan=
True
170 CKeys += [
"LArRawChannels"]
171 log.info(
"Adding ROD energies")
173 log.info(
"Autoconfigured: ")
174 log.info(
"nSamples: %d nEt: %d digitsKey %s accdigitsKey %s acccalibdigitsKey %s",flags.LArSCDump.nSamples, flags.LArSCDump.nEt, flags.LArSCDump.digitsKey, flags.LArSCDump.accdigitsKey, flags.LArSCDump.acccalibdigitsKey)
178 flags.LAr.doAlign=
False
181 flags.Trigger.triggerConfig =
'DB'
182 flags.Trigger.L1.doCTP =
True
183 flags.Trigger.L1.doMuon =
False
184 flags.Trigger.L1.doCalo =
False
185 flags.Trigger.L1.doTopo =
False
187 flags.Trigger.enableL1CaloLegacy =
True
188 flags.Trigger.enableL1CaloPhase1 =
False
191 flags.Trigger.L1.doCalo =
True
192 flags.Trigger.triggerConfig =
'DB'
194 flags.LArSCDump.fillNoisyRO=args.noisyRO
197 flags.Exec.OutputLevel=args.olevel
204 flags.IOVDb.SqliteInput=
"/afs/cern.ch/user/p/pavol/public/EMF_otherCond.db"
205 flags.IOVDb.SqliteFolders = (
"/LAR/BadChannelsOfl/BadChannelsSC",
"/LAR/BadChannels/BadChannelsSC",
"/LAR/Identifier/OnOffIdMap",)
208 flags.dump(
'LArSCDump.*')
213 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
214 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
220 from LArCalibProcessing.LArCalibBaseConfig
import LArCalibBaseCfg
222 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
226 from LArCafJobs.LArSCDumperSkeleton
import L1CaloMenuCfg
228 from TrigDecisionTool.TrigDecisionToolConfig
import TrigDecisionToolCfg
236 from IOVDbSvc.IOVDbSvcConfig
import addOverride
237 acc.merge(
addOverride(flags,
"/LAR/Identifier/LatomeMapping",
"LARIdentifierLatomeMapping-fw6"))
239 from LArBadChannelTool.LArBadChannelConfig
import LArBadFebCfg, LArBadChannelCfg
244 acc.addCondAlgo(CompFactory.CaloAlignCondAlg(LArAlignmentStore=
"",CaloCellPositionShiftFolder=
""))
245 acc.addCondAlgo(CompFactory.CaloSuperCellAlignCondAlg())
248 from LArCalibTools.LArSC2NtupleConfig
import LArSC2NtupleCfg
249 acc.merge(
LArSC2NtupleCfg(flags, isEmf = args.emf, AddBadChannelInfo=args.bc, AddFEBTempInfo=
False, isSC=
True, isFlat=
False,
250 OffId=args.offline, AddHash=args.ahash, AddCalib=args.calib, RealGeometry=args.geom, ExpandId=args.expid,
251 NSamples=flags.LArSCDump.nSamples, FTlist=[], FillBCID=args.bcid, ContainerKey=flags.LArSCDump.digitsKey, AccContainerKey=flags.LArSCDump.accdigitsKey, AccCalibContainerKey=flags.LArSCDump.acccalibdigitsKey,
252 SCContainerKeys=CKeys, OverwriteEventNumber = args.overEvN,
253 FillRODEnergy = flags.LArSCDump.doRawChan,
254 FillLB=args.evtree, FillTriggerType = args.evtree,
255 TrigNames=[
"L1_EM3",
"L1_EM7",
"L1_EM15",
"L1_EM22VHI",
"L1_eEM5",
"L1_eEM15",
"L1_eEM22M"],
256 TrigDecisionTool=tdt, FillTriggerTowers = args.TT,
257 OutputLevel=args.olevel
260 if os.path.exists(args.outfile):
261 os.remove(args.outfile)
262 acc.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+args.outfile+
"' OPT='NEW'" ]))
263 acc.setAppProperty(
"HistogramPersistency",
"ROOT")
266 if args.accsamples
or args.acccalibsamples:
267 acc.getService(
"IOVDbSvc").forceRunNumber=
int(args.run)
269 acc.getService(
"MessageSvc").defaultLimit=999999
272 log.info(
"Input files to be processed:")
273 for f
in flags.Input.Files:
275 log.info(
"Output file: ")
276 log.info(args.outfile)