10 if hasattr( runArgs,
'RunNumber' ):
11 flags.SCTCalib.RunNumber = runArgs.RunNumber
14 if hasattr( runArgs,
'EventNumber' ):
15 flags.SCTCalib.EventNumber = runArgs.EventNumber
18 if hasattr( runArgs,
'maxEvents' ):
19 flags.SCTCalib.EvtMax = runArgs.maxEvents
22 if hasattr( runArgs,
'InputType' )
and runArgs.InputType ==
'RAW':
23 flags.SCTCalib.ReadBS =
True
25 flags.SCTCalib.ReadBS =
False
28 if hasattr( runArgs,
'InputType' ):
29 flags.SCTCalib.InputType = runArgs.InputType
32 if hasattr( runArgs,
'part' ):
33 if 'doNoisyStrip' in runArgs.part:
34 flags.SCTCalib.DoNoisyStrip =
True
36 flags.SCTCalib.DoNoisyStrip =
False
37 if 'doHV' in runArgs.part:
38 flags.SCTCalib.DoHV =
True
40 flags.SCTCalib.DoHV =
False
41 if 'doDeadStrip' in runArgs.part:
42 flags.SCTCalib.DoDeadStrip =
True
44 flags.SCTCalib.DoDeadStrip =
False
45 if 'doDeadChip' in runArgs.part:
46 flags.SCTCalib.DoDeadChip =
True
48 flags.SCTCalib.DoDeadChip =
False
49 if 'doQuietStrip' in runArgs.part:
50 flags.SCTCalib.DoQuietStrip =
True
52 flags.SCTCalib.DoQuietStrip =
False
53 if 'doQuietChip' in runArgs.part:
54 flags.SCTCalib.DoQuietChip =
True
56 flags.SCTCalib.DoQuietChip =
False
57 if 'doNoiseOccupancy' in runArgs.part:
58 flags.SCTCalib.DoNoiseOccupancy =
True
60 flags.SCTCalib.DoNoiseOccupancy =
False
61 if 'doRawOccupancy' in runArgs.part:
62 flags.SCTCalib.DoRawOccupancy =
True
64 flags.SCTCalib.DoRawOccupancy =
False
65 if 'doEfficiency' in runArgs.part:
66 flags.SCTCalib.DoEfficiency =
True
68 flags.SCTCalib.DoEfficiency =
False
69 if 'doBSErrorDB' in runArgs.part:
70 flags.SCTCalib.DoBSErrorDB =
True
72 flags.SCTCalib.DoBSErrorDB =
False
73 if 'doLorentzAngle' in runArgs.part:
74 flags.SCTCalib.DoLorentzAngle =
True
76 flags.SCTCalib.DoLorentzAngle =
False
78 if hasattr( runArgs,
'splitHitMap' ):
79 if runArgs.splitHitMap == 0:
80 if flags.SCTCalib.DoNoisyStrip:
81 flags.SCTCalib.DoHitMapsLB =
True
83 flags.SCTCalib.DoHitMapsLB =
False
84 flags.SCTCalib.DoHitMaps =
True
85 flags.SCTCalib.ReadHitMaps =
False
86 if runArgs.splitHitMap == 1:
87 if flags.SCTCalib.DoNoisyStrip:
88 flags.SCTCalib.DoHitMapsLB =
True
90 flags.SCTCalib.DoHitMapsLB =
False
91 flags.SCTCalib.DoHitMaps =
True
92 flags.SCTCalib.ReadHitMaps =
True
93 elif runArgs.splitHitMap == 2:
94 flags.SCTCalib.DoHitMapsLB =
False
95 flags.SCTCalib.DoHitMaps =
False
96 flags.SCTCalib.ReadHitMaps =
True
97 if flags.SCTCalib.EvtMax != 1:
98 print(
'WARNING! EvtMax is not 1, although HitMap analysis is run!')
100 flags.SCTCalib.DoHitMapsLB =
False
101 flags.SCTCalib.DoHitMaps =
False
102 flags.SCTCalib.ReadHitMaps =
False
105 doHIST = flags.SCTCalib.DoNoiseOccupancy
or flags.SCTCalib.DoRawOccupancy
or flags.SCTCalib.DoEfficiency
or flags.SCTCalib.DoBSErrorDB
or flags.SCTCalib.DoLorentzAngle
108 if flags.SCTCalib.DoHV
and flags.SCTCalib.DataSource ==
'data':
109 flags.SCTCalib.UseDCS =
True
111 if flags.SCTCalib.DoHV
or doHIST:
112 flags.SCTCalib.UseConfiguration =
False
114 if flags.SCTCalib.DataSource ==
'geant4':
115 flags.SCTCalib.UseCalibration =
False
116 if not flags.SCTCalib.DoNoisyStrip:
117 flags.SCTCalib.UseCalibration =
False
119 if not flags.SCTCalib.DoNoisyStrip:
120 flags.SCTCalib.UseMajority =
False
122 if flags.SCTCalib.DoDeadStrip
or flags.SCTCalib.DoDeadChip:
123 flags.SCTCalib.UseBSError =
True
125 if flags.SCTCalib.DoHV
or doHIST:
126 flags.SCTCalib.DoHitMaps =
False
127 flags.SCTCalib.DoHitMapsLB =
False
129 if (flags.SCTCalib.DoDeadStrip
or flags.SCTCalib.DoDeadChip
or
130 flags.SCTCalib.DoQuietStrip
or flags.SCTCalib.DoQuietChip):
131 flags.SCTCalib.DoBSErrors =
True
135 flags.SCTCalib.InputHist = runArgs.inputNames
136 flags.SCTCalib.EvtMax = 1
139 if hasattr( runArgs,
'forceRefRunNumber' ):
140 flags.SCTCalib.ForceRefRunNumber = runArgs.forceRefRunNumber
151 if os.path.exists(
'./runInfo.txt'):
152 runInfo =
open(
'./runInfo.txt',
'r' ).
read()
153 RIlist = runInfo.split(
' ' )
158 SORTime =
'cannot retrieve SORTime'
159 EORTime =
'cannot retrieve EORTime'
160 nLB =
'cannot retrieve LB'
162 return SORTime, EORTime, nLB
170 from SCT_CalibAlgs.ReadCoolUPD4
import GetRunList, GetNumNoisyMods, GetNumNoisyStrips
172 tag = flags.SCTCalib.TagID4NoisyUploadTest
173 numRuns = flags.SCTCalib.NoisyReadNumRuns
175 print(flags.SCTCalib.RunNumber)
176 dbstring =
'ATLAS_COOLOFL_SCT/CONDBR2'
177 folder =
'/SCT/Derived/Monitoring'
178 print(
'Getting run list from ReadCoolUPD4.py %s '% dbstring)
179 RunList =
GetRunList( dbstring, folder, tag, flags.SCTCalib.RunNumber, numRuns )
180 if ( len(RunList) != 0 ):
182 print(
'---------------> Noisy strips in COOL : last ', numRuns,
' runs <---------------')
183 sumNoisyModulesInDB = 0
184 sumNoisyStripsInDB = 0
185 for i
in range( len(RunList) ):
188 print(
'[ run, modules, strips ] = [', RunList[i],
',', numNoisyModules,
',', numNoisyStrips,
']')
189 sumNoisyModulesInDB = sumNoisyModulesInDB + numNoisyModules
190 sumNoisyStripsInDB = sumNoisyStripsInDB + numNoisyStrips
191 NoisyModuleAverageInDB =
float(sumNoisyModulesInDB) /
float(len(RunList))
192 NoisyStripAverageInDB =
float(sumNoisyStripsInDB) /
float(len(RunList))
197 print(
'Average num of modules w/ >= 1 noisy strip : ', NoisyModuleAverageInDB)
198 print(
'Num of noisy strips in the last run', RunList[0],
' : ', NoisyStripLastRunInDB)
199 print(
'Average num of noisy strips in the last runs : ', NoisyStripAverageInDB)
200 print(
'----------------------------------------------------------------------')
202 flags.SCTCalib.NoisyModuleAverageInDB = NoisyModuleAverageInDB
203 flags.SCTCalib.NoisyStripLastRunInDB = NoisyStripLastRunInDB
204 flags.SCTCalib.NoisyStripAverageInDB = NoisyStripAverageInDB
208 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
211 from PyJobTransforms.CommonRunArgsToFlags
import commonRunArgsToFlags
214 from SCT_CalibAlgs.SCTCalibFlags
import defaultSCTCalibFlags
219 flags.Input.Files = runArgs.inputNames
if flags.SCTCalib.ReadBS
else []
221 from AthenaConfiguration.Enums
import Format
222 flags.Input.Format = Format.BS
if flags.SCTCalib.ReadBS
else None
224 flags.Input.RunNumbers = [flags.SCTCalib.RunNumber]
226 if not flags.SCTCalib.ReadBS:
227 flags.Input.OverrideRunNumber =
True
228 flags.Input.LumiBlockNumbers = [0]
229 flags.Input.TimeStamps = [
int(SORTime.split(
'.')[0])]
231 flags.IOVDb.GlobalTag = flags.SCTCalib.ConditionsTagSTF
232 flags.GeoModel.AtlasVersion = flags.SCTCalib.GeometryTagSTF
234 from AthenaConfiguration.DetectorConfigFlags
import disableDetectors, allDetectors
236 flags.Detector.EnableSCT =
True
240 if flags.SCTCalib.DoNoisyStrip
and flags.SCTCalib.NoisyUploadTest:
246 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
249 if flags.SCTCalib.ReadBS:
250 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
253 from SCT_RawDataByteStreamCnv.SCT_RawDataByteStreamCnvConfig
import SCTRawDataProviderCfg
256 from AthenaKernel.EventIdOverrideConfig
import EvtIdModifierSvcCfg
260 from IOVDbSvc.IOVDbSvcConfig
import IOVDbSvcCfg
268 if hasattr( runArgs,
'prefix' )
and runArgs.prefix !=
'':
269 prefix = runArgs.prefix+
'.'
273 from AthenaConfiguration.ComponentFactory
import CompFactory
274 if flags.SCTCalib.DoHitMaps:
275 cfg.addService(CompFactory.THistSvc(Output = [
"HitMaps DATAFILE='"+prefix+
"SCTHitMaps.root' OPT='RECREATE'" ]))
276 if flags.SCTCalib.DoHitMapsLB:
277 cfg.addService(CompFactory.THistSvc(Output = [
"LB DATAFILE='"+prefix+
"SCTLB.root' OPT='RECREATE'" ]))
278 if flags.SCTCalib.DoBSErrors
and flags.SCTCalib.DoHitMaps:
279 cfg.addService(CompFactory.THistSvc(Output = [
"BSErrors DATAFILE='"+prefix+
"SCTBSErrors.root' OPT='RECREATE'" ]))
284 from SCT_CalibAlgs.SCTCalibAlgConfig
import SCTCalibAlgCfg
285 cfg.merge(
SCTCalibAlgCfg(flags, SORTime = SORTime, EORTime = EORTime, nLB = nLB, prefix = prefix))
288 with open(
'SCTCalibAlgCfg.pkl',
'wb')
as f:
292 sys.exit(
not sc.isSuccess())