ATLAS Offline Software
Loading...
Searching...
No Matches
LArSCDumperSkeleton.py
Go to the documentation of this file.
1# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3import sys
4import os
5
6from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags
7from PyJobTransforms.TransformUtils import processPreExec, processPreInclude, processPostExec, processPostInclude
8from LArCalibTools.LArSC2NtupleConfig import LArSC2NtupleCfg
9from AthenaConfiguration.MainServicesConfig import MainServicesCfg
10
11def L1CaloMenuCfg(flags):
12
13
14 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
15
16 acc=ComponentAccumulator()
17 from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg, HLTConfigSvcCfg, L1PrescaleCondAlgCfg, HLTPrescaleCondAlgCfg
18 from TrigT1ResultByteStream.TrigT1ResultByteStreamConfig import L1TriggerByteStreamDecoderCfg
19
20 acc.merge( L1TriggerByteStreamDecoderCfg(flags) )
21 acc.merge( L1ConfigSvcCfg(flags) )
22 acc.merge( HLTConfigSvcCfg(flags) )
23 acc.merge( L1PrescaleCondAlgCfg(flags) )
24 acc.merge( HLTPrescaleCondAlgCfg(flags) )
25
26
27 from TrigConfigSvc.TrigConfigSvcCfg import BunchGroupCondAlgCfg
28 acc.merge( BunchGroupCondAlgCfg( flags ) )
29
30 from AthenaConfiguration.ComponentFactory import CompFactory
31 tdm = CompFactory.getComp('TrigDec::TrigDecisionMakerMT')()
32 tdm.doL1 = True
33 tdm.doHLT = False
34 acc.addEventAlgo( tdm, 'AthAlgSeq' )
35
36 return acc
37
38
39def fromRunArgs(runArgs):
40
41 from AthenaCommon.Logging import logging
42 mlog_SCD = logging.getLogger( 'LArSCDumpSkeleton' )
43
44 from AthenaConfiguration.AllConfigFlags import initConfigFlags
45 flags=initConfigFlags()
46
47 from LArCafJobs.LArSCDumperFlags import addSCDumpFlags
48 addSCDumpFlags(flags)
49
50 commonRunArgsToFlags(runArgs, flags)
51
52 processPreInclude(runArgs, flags)
53 processPreExec(runArgs, flags)
54
55 flags.Input.Files=runArgs.inputBSFile
56 flags.LArSCDump.outputNtup=runArgs.outputNTUP_SCMONFile
57
58 # real geom not working yet
59 flags.LArSCDump.doGeom=False
60
61 if hasattr(runArgs,"ETThresh"):
62 flags.LArSCDump.ETThresh=float(runArgs.ETThresh)
63
64 if hasattr(runArgs,"ETThreshMain"):
65 flags.LArSCDump.ETThreshMain=float(runArgs.ETThreshMain)
66
67 from LArConditionsCommon.LArRunFormat import getLArDTInfoForRun
68 try:
69 runinfo=getLArDTInfoForRun(flags.Input.RunNumbers[0], connstring="COOLONL_LAR/CONDBR2")
70 except Exception:
71 mlog_SCD.warning("Could not get DT run info, using defaults !")
72 flags.LArSCDump.doEt=True
73 flags.LArSCDump.nSamples=5
74 flags.LArSCDump.nEt=1
75 CKeys=["SC_ET"]
76 fw=5
77 else:
78 fw=runinfo.FWversion()
79 CKeys=[]
80 flags.LArSCDump.digitsKey=""
81 for i in range(0,len(runinfo.streamTypes())):
82 if runinfo.streamTypes()[i] == "SelectedEnergy":
83 CKeys += ["SC_ET_ID"]
84 flags.LArSCDump.doEt=True
85 flags.LArSCDump.nEt=runinfo.streamLengths()[i]
86 elif runinfo.streamTypes()[i] == "Energy":
87 CKeys += ["SC_ET"]
88 flags.LArSCDump.doEt=True
89 flags.LArSCDump.nEt=runinfo.streamLengths()[i]
90 elif runinfo.streamTypes()[i] == "RawADC":
91 flags.LArSCDump.digitsKey="SC"
92 flags.LArSCDump.nSamples=runinfo.streamLengths()[i]
93 elif runinfo.streamTypes()[i] == "ADC":
94 CKeys += ["SC_ADC_BAS"]
95 flags.LArSCDump.nSamples=runinfo.streamLengths()[i]
96
97 finally:
98 flags.LArSCDump.doRawChan=True
99 flags.LArSCDump.fillNoisyRO=False
100 CKeys+=["LArRawChannels"]
101
102 mlog_SCD.debug("CKeys generated %s",str(CKeys))
103
104 flags.Trigger.triggerConfig = 'DB'
105 flags.Trigger.L1.doCTP = True
106 flags.Trigger.L1.doMuon = False
107 flags.Trigger.L1.doCalo = False
108 flags.Trigger.L1.doTopo = False
109
110 flags.Trigger.enableL1CaloLegacy = True
111 flags.Trigger.enableL1CaloPhase1 = True
112
113 # To respect --athenaopts
114 flags.fillFromArgs()
115
116 flags.lock()
117
118 cfg=MainServicesCfg(flags)
119 cfg.merge(L1CaloMenuCfg(flags))
120
121 from TrigDecisionTool.TrigDecisionToolConfig import TrigDecisionToolCfg
122 tdt = cfg.getPrimaryAndMerge(TrigDecisionToolCfg(flags))
123
124 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
125 cfg.merge(LArGMCfg(flags))
126
127 if fw==6:
128 from IOVDbSvc.IOVDbSvcConfig import addOverride
129 cfg.merge(addOverride(flags,"/LAR/Identifier/LatomeMapping","LARIdentifierLatomeMapping-fw6"))
130
131 if flags.LArSCDump.doBC:
132 # FIXME should be SC version
133 from LArBadChannelTool.LArBadChannelConfig import LArBadFebCfg, LArBadChannelCfg
134 cfg.merge(LArBadChannelCfg(flags))
135 cfg.merge(LArBadFebCfg(flags))
136
137 from LArCellRec.LArTimeVetoAlgConfig import LArTimeVetoAlgCfg
138 cfg.merge(LArTimeVetoAlgCfg(flags))
139
140 cfg.merge(LArSC2NtupleCfg(flags, AddBadChannelInfo=flags.LArSCDump.doBC, AddFEBTempInfo=False, isSC=True, isFlat=False,
141 OffId=flags.LArSCDump.doOfflineId, AddHash=flags.LArSCDump.doHash, AddCalib=flags.LArSCDump.doCalib,
142 RealGeometry=flags.LArSCDump.doGeom, ExpandId=flags.LArSCDump.expandId, BadChanKey="LArBadChannelSC", # from LArCond2NtupleBase
143 NSamples=flags.LArSCDump.nSamples, FTlist=[], FillBCID=flags.LArSCDump.doBCID, ContainerKey=flags.LArSCDump.digitsKey, # from LArDigits2Ntuple
144 SCContainerKeys=CKeys, OverwriteEventNumber = flags.LArSCDump.overwriteEvN, Net=flags.LArSCDump.nEt,
145 FillRODEnergy = flags.LArSCDump.doRawChan, FillLB = True, FillTriggerType = True,
146 ETThreshold = flags.LArSCDump.ETThresh, ETThresholdMain = flags.LArSCDump.ETThreshMain, ADCThreshold=int(runArgs.ADCThresh),
147 TrigNames=["L1_EM3","L1_EM7","L1_EM15","L1_EM22VHI","L1_eEM5","L1_eEM15","L1_eEM22M"],
148 TrigDecisionTool=tdt,
149 OutputLevel=2))
150
151 if os.path.exists(flags.LArSCDump.outputNtup):
152 os.remove(flags.LArSCDump.outputNtup)
153 from AthenaConfiguration.ComponentFactory import CompFactory
154 cfg.addService(CompFactory.NTupleSvc(Output = [ "FILE1 DATAFILE='"+flags.LArSCDump.outputNtup+"' OPT='NEW'" ]))
155 cfg.setAppProperty("HistogramPersistency","ROOT")
156
157
158 processPostInclude(runArgs, flags, cfg)
159 processPostExec(runArgs, flags, cfg)
160
161 #example how to dump the stores
162 #cfg.getService("StoreGateSvc").Dump=True
163 #from AthenaCommon.Constants import DEBUG
164 #cfg.getService("MessageSvc").OutputLevel=DEBUG
165 # Run the final accumulator
166 sc = cfg.run()
167 sys.exit(not sc.isSuccess())