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=
""
104 if not (args.accsamples
or args.acccalibsamples):
110 log.warning(
"Could not get DT run info, using defaults !")
111 flags.LArSCDump.doEt=
True
113 flags.LArSCDump.nSamples=args.nsamp
115 flags.LArSCDump.nSamples=5
116 flags.LArSCDump.nEt=1
118 flags.LArSCDump.digitsKey=
"SC"
122 flags.LArSCDump.digitsKey=
""
123 for i
in range(0,len(runinfo.streamTypes())):
124 if args.EtId
and runinfo.streamTypes()[i] ==
"SelectedEnergy":
125 CKeys += [
"SC_ET_ID"]
126 flags.LArSCDump.doEt=
True
127 flags.LArSCDump.nEt=runinfo.streamLengths()[i]
128 elif args.Et
and runinfo.streamTypes()[i] ==
"Energy":
130 flags.LArSCDump.doEt=
True
131 flags.LArSCDump.nEt=runinfo.streamLengths()[i]
132 elif args.samples
and runinfo.streamTypes()[i] ==
"RawADC":
133 flags.LArSCDump.digitsKey=
"SC"
135 flags.LArSCDump.nSamples=args.nsamp
137 flags.LArSCDump.nSamples=runinfo.streamLengths()[i]
138 elif args.samplesBas
and runinfo.streamTypes()[i] ==
"ADC":
139 CKeys += [
"SC_ADC_BAS"]
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
148 if args.accsamples
or args.acccalibsamples:
149 flags.Input.OverrideRunNumber =
True
155 if args.samples
and not (
"SC" in flags.LArSCDump.digitsKey):
156 flags.LArSCDump.digitsKey=
"SC"
157 if args.samplesBas
and "SC_ADC_BAS" not in CKeys:
158 CKeys += [
"SC_ADC_BAS"]
159 flags.LArSCDump.doSamplesBas=
True
160 if args.Et
and "SC_ET" not in CKeys:
162 if args.EtId
and "SC_ET_ID" not in CKeys:
163 CKeys += [
"SC_ET_ID"]
164 if args.lheader
and "SC_LATOME_HEADER" not in CKeys:
165 CKeys += [
"SC_LATOME_HEADER"]
168 flags.LArSCDump.doRawChan=
True
169 CKeys += [
"LArRawChannels"]
170 log.info(
"Adding ROD energies")
172 log.info(
"Autoconfigured: ")
173 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)
177 flags.LAr.doAlign=
False
180 flags.Trigger.triggerConfig =
'DB'
181 flags.Trigger.L1.doCTP =
True
182 flags.Trigger.L1.doMuon =
False
183 flags.Trigger.L1.doCalo =
False
184 flags.Trigger.L1.doTopo =
False
186 flags.Trigger.enableL1CaloLegacy =
True
187 flags.Trigger.enableL1CaloPhase1 =
False
190 flags.Trigger.L1.doCalo =
True
191 flags.Trigger.triggerConfig =
'DB'
193 flags.LArSCDump.fillNoisyRO=args.noisyRO
196 flags.Exec.OutputLevel=args.olevel
203 flags.IOVDb.SqliteInput=
"/afs/cern.ch/user/p/pavol/public/EMF_otherCond.db"
204 flags.IOVDb.SqliteFolders = (
"/LAR/BadChannelsOfl/BadChannelsSC",
"/LAR/BadChannels/BadChannelsSC",
"/LAR/Identifier/OnOffIdMap",)
207 flags.dump(
'LArSCDump.*')
212 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
213 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
219 from LArCalibProcessing.LArCalibBaseConfig
import LArCalibBaseCfg
221 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
225 from LArCafJobs.LArSCDumperSkeleton
import L1CaloMenuCfg
227 from TrigDecisionTool.TrigDecisionToolConfig
import TrigDecisionToolCfg
235 from IOVDbSvc.IOVDbSvcConfig
import addOverride
236 acc.merge(
addOverride(flags,
"/LAR/Identifier/LatomeMapping",
"LARIdentifierLatomeMapping-fw6"))
238 from LArBadChannelTool.LArBadChannelConfig
import LArBadFebCfg, LArBadChannelCfg
243 acc.addCondAlgo(CompFactory.CaloAlignCondAlg(LArAlignmentStore=
"",CaloCellPositionShiftFolder=
""))
244 acc.addCondAlgo(CompFactory.CaloSuperCellAlignCondAlg())
247 from LArCalibTools.LArSC2NtupleConfig
import LArSC2NtupleCfg
248 acc.merge(
LArSC2NtupleCfg(flags, isEmf = args.emf, AddBadChannelInfo=args.bc, AddFEBTempInfo=
False, isSC=
True, isFlat=
False,
249 OffId=args.offline, AddHash=args.ahash, AddCalib=args.calib, RealGeometry=args.geom, ExpandId=args.expid,
250 NSamples=flags.LArSCDump.nSamples, FTlist=[], FillBCID=args.bcid, ContainerKey=flags.LArSCDump.digitsKey, AccContainerKey=flags.LArSCDump.accdigitsKey, AccCalibContainerKey=flags.LArSCDump.acccalibdigitsKey,
251 SCContainerKeys=CKeys, OverwriteEventNumber = args.overEvN,
252 FillRODEnergy = flags.LArSCDump.doRawChan,
253 FillLB=args.evtree, FillTriggerType = args.evtree,
254 TrigNames=[
"L1_EM3",
"L1_EM7",
"L1_EM15",
"L1_EM22VHI",
"L1_eEM5",
"L1_eEM15",
"L1_eEM22M"],
255 TrigDecisionTool=tdt, FillTriggerTowers = args.TT,
256 OutputLevel=args.olevel
259 if os.path.exists(args.outfile):
260 os.remove(args.outfile)
261 acc.addService(CompFactory.NTupleSvc(Output = [
"FILE1 DATAFILE='"+args.outfile+
"' OPT='NEW'" ]))
262 acc.setAppProperty(
"HistogramPersistency",
"ROOT")
265 if args.accsamples
or args.acccalibsamples:
266 acc.getService(
"IOVDbSvc").forceRunNumber=
int(args.run)
268 acc.getService(
"MessageSvc").defaultLimit=999999
271 log.info(
"Input files to be processed:")
272 for f
in flags.Input.Files:
274 log.info(
"Output file: ")
275 log.info(args.outfile)