ATLAS Offline Software
Functions
SCTCalib_Skeleton Namespace Reference

Functions

def setSCTCalibFlagsFromRunArgs (flags, runArgs)
 
def getRunInfoForHist ()
 
def readNoisyModulesAndStripsFromDB (flags)
 
def fromRunArgs (runArgs)
 

Function Documentation

◆ fromRunArgs()

def SCTCalib_Skeleton.fromRunArgs (   runArgs)

Definition at line 207 of file SCTCalib_Skeleton.py.

207 def fromRunArgs(runArgs):
208  from AthenaConfiguration.AllConfigFlags import initConfigFlags
209  flags = initConfigFlags()
210 
211  from PyJobTransforms.CommonRunArgsToFlags import commonRunArgsToFlags
212  commonRunArgsToFlags(runArgs, flags)
213 
214  from SCT_CalibAlgs.SCTCalibFlags import defaultSCTCalibFlags
215  defaultSCTCalibFlags(flags)
216 
217  setSCTCalibFlagsFromRunArgs(flags, runArgs)
218 
219  flags.Input.Files = runArgs.inputNames if flags.SCTCalib.ReadBS else []
220 
221  from AthenaConfiguration.Enums import Format
222  flags.Input.Format = Format.BS if flags.SCTCalib.ReadBS else None
223 
224  flags.Input.RunNumbers = [flags.SCTCalib.RunNumber]
225  SORTime, EORTime, nLB = getRunInfoForHist()
226  if not flags.SCTCalib.ReadBS:
227  flags.Input.OverrideRunNumber = True
228  flags.Input.LumiBlockNumbers = [0]
229  flags.Input.TimeStamps = [int(SORTime.split('.')[0])]
230 
231  flags.IOVDb.GlobalTag = flags.SCTCalib.ConditionsTagSTF
232  flags.GeoModel.AtlasVersion = flags.SCTCalib.GeometryTagSTF
233 
234  from AthenaConfiguration.DetectorConfigFlags import disableDetectors, allDetectors
235  disableDetectors(flags, allDetectors, toggle_geometry = True)
236  flags.Detector.EnableSCT = True
237 
238  flags.fillFromArgs()
239 
240  if flags.SCTCalib.DoNoisyStrip and flags.SCTCalib.NoisyUploadTest:
242 
243  flags.lock()
244  flags.dump()
245 
246  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
247  cfg = MainServicesCfg(flags)
248 
249  if flags.SCTCalib.ReadBS:
250  from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
251  cfg.merge(ByteStreamReadCfg(flags))
252 
253  from SCT_RawDataByteStreamCnv.SCT_RawDataByteStreamCnvConfig import SCTRawDataProviderCfg
254  cfg.merge(SCTRawDataProviderCfg(flags))
255  else:
256  from AthenaKernel.EventIdOverrideConfig import EvtIdModifierSvcCfg
257  cfg.merge(EvtIdModifierSvcCfg(flags))
258 
259 
260  from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg
261  cfg.merge(IOVDbSvcCfg(flags))
262 
263 
264  #--------------------------------------------------------------
265  # Saving ROOT histograms
266  #--------------------------------------------------------------
267  #--- Setting output prefix
268  if hasattr( runArgs, 'prefix' ) and runArgs.prefix != '':
269  prefix = runArgs.prefix+'.'
270  else:
271  prefix = ''
272 
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'" ]))
280 
281  #--------------------------------------------------------------
282  # Configuring SCTCalibAlg
283  #--------------------------------------------------------------
284  from SCT_CalibAlgs.SCTCalibAlgConfig import SCTCalibAlgCfg
285  cfg.merge(SCTCalibAlgCfg(flags, SORTime = SORTime, EORTime = EORTime, nLB = nLB, prefix = prefix))
286 
287 
288  with open('SCTCalibAlgCfg.pkl', 'wb') as f:
289  cfg.store(f)
290 
291  sc = cfg.run()
292  sys.exit(not sc.isSuccess())

◆ getRunInfoForHist()

def SCTCalib_Skeleton.getRunInfoForHist ( )

Definition at line 143 of file SCTCalib_Skeleton.py.

143 def getRunInfoForHist():
144  #--------------------------------------------------------------
145  # Read start/end time stamp and LB for HIST
146  #--------------------------------------------------------------
147  SORTime = ''
148  EORTime = ''
149  nLB = ''
150 
151  if os.path.exists('./runInfo.txt'):
152  runInfo = open( './runInfo.txt', 'r' ).read()
153  RIlist = runInfo.split( ' ' ) # RIlist[1] -> ProjTag, RIlist[5] -> DAQConfig, both not used at the moment
154  SORTime = RIlist[2]
155  EORTime = RIlist[3]
156  nLB = RIlist[4]
157  else:
158  SORTime = 'cannot retrieve SORTime'
159  EORTime = 'cannot retrieve EORTime'
160  nLB = 'cannot retrieve LB'
161 
162  return SORTime, EORTime, nLB
163 
164 

◆ readNoisyModulesAndStripsFromDB()

def SCTCalib_Skeleton.readNoisyModulesAndStripsFromDB (   flags)

Definition at line 165 of file SCTCalib_Skeleton.py.

166  #--------------------------------------------------------------
167  # Read /SCT/Derived/Monotoring in COOL
168  # - Used in a criteria for upload of NoisyStrips
169  #--------------------------------------------------------------
170  from SCT_CalibAlgs.ReadCoolUPD4 import GetRunList, GetNumNoisyMods, GetNumNoisyStrips
171 
172  tag = flags.SCTCalib.TagID4NoisyUploadTest
173  numRuns = flags.SCTCalib.NoisyReadNumRuns
174  print('RUNNUMBER')
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 ):
181  #--- List of data and average num of modules w/ >= 1 noisy strip
182  print('---------------> Noisy strips in COOL : last ', numRuns, ' runs <---------------')
183  sumNoisyModulesInDB = 0
184  sumNoisyStripsInDB = 0
185  for i in range( len(RunList) ):
186  numNoisyModules = GetNumNoisyMods( dbstring, folder, tag, RunList[i] )
187  numNoisyStrips = GetNumNoisyStrips( dbstring, folder, tag, RunList[i] )
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))
193 
194  #--- Num of noisy strips in the last run
195  NoisyStripLastRunInDB = GetNumNoisyStrips( dbstring, folder, tag, RunList[0] )
196 
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('----------------------------------------------------------------------')
201 
202  flags.SCTCalib.NoisyModuleAverageInDB = NoisyModuleAverageInDB
203  flags.SCTCalib.NoisyStripLastRunInDB = NoisyStripLastRunInDB
204  flags.SCTCalib.NoisyStripAverageInDB = NoisyStripAverageInDB
205 
206 

◆ setSCTCalibFlagsFromRunArgs()

def SCTCalib_Skeleton.setSCTCalibFlagsFromRunArgs (   flags,
  runArgs 
)

Definition at line 8 of file SCTCalib_Skeleton.py.

8 def setSCTCalibFlagsFromRunArgs(flags, runArgs):
9  #--- Reading RunNumber from FileName
10  if hasattr( runArgs, 'RunNumber' ):
11  flags.SCTCalib.RunNumber = runArgs.RunNumber
12 
13  #--- Reading EventNumber from FileName
14  if hasattr( runArgs, 'EventNumber' ):
15  flags.SCTCalib.EventNumber = runArgs.EventNumber
16 
17  #--- Setting MaxEvents from runArguments
18  if hasattr( runArgs, 'maxEvents' ):
19  flags.SCTCalib.EvtMax = runArgs.maxEvents
20 
21  #--- Setting ReadBS from runArguments
22  if hasattr( runArgs, 'InputType' ) and runArgs.InputType == 'RAW':
23  flags.SCTCalib.ReadBS = True
24  else:
25  flags.SCTCalib.ReadBS = False
26 
27  #--- Setting InputType from runArguments
28  if hasattr( runArgs, 'InputType' ):
29  flags.SCTCalib.InputType = runArgs.InputType
30 
31  #--- Setting which algorithms to be run
32  if hasattr( runArgs, 'part' ):
33  if 'doNoisyStrip' in runArgs.part:
34  flags.SCTCalib.DoNoisyStrip = True
35  else:
36  flags.SCTCalib.DoNoisyStrip = False
37  if 'doHV' in runArgs.part:
38  flags.SCTCalib.DoHV = True
39  else:
40  flags.SCTCalib.DoHV = False
41  if 'doDeadStrip' in runArgs.part:
42  flags.SCTCalib.DoDeadStrip = True
43  else:
44  flags.SCTCalib.DoDeadStrip = False
45  if 'doDeadChip' in runArgs.part:
46  flags.SCTCalib.DoDeadChip = True
47  else:
48  flags.SCTCalib.DoDeadChip = False
49  if 'doQuietStrip' in runArgs.part:
50  flags.SCTCalib.DoQuietStrip = True
51  else:
52  flags.SCTCalib.DoQuietStrip = False
53  if 'doQuietChip' in runArgs.part:
54  flags.SCTCalib.DoQuietChip = True
55  else:
56  flags.SCTCalib.DoQuietChip = False
57  if 'doNoiseOccupancy' in runArgs.part:
58  flags.SCTCalib.DoNoiseOccupancy = True
59  else:
60  flags.SCTCalib.DoNoiseOccupancy = False
61  if 'doRawOccupancy' in runArgs.part:
62  flags.SCTCalib.DoRawOccupancy = True
63  else:
64  flags.SCTCalib.DoRawOccupancy = False
65  if 'doEfficiency' in runArgs.part:
66  flags.SCTCalib.DoEfficiency = True
67  else:
68  flags.SCTCalib.DoEfficiency = False
69  if 'doBSErrorDB' in runArgs.part:
70  flags.SCTCalib.DoBSErrorDB = True
71  else:
72  flags.SCTCalib.DoBSErrorDB = False
73  if 'doLorentzAngle' in runArgs.part:
74  flags.SCTCalib.DoLorentzAngle = True
75  else:
76  flags.SCTCalib.DoLorentzAngle = False
77 
78  if hasattr( runArgs, 'splitHitMap' ):
79  if runArgs.splitHitMap == 0:
80  if flags.SCTCalib.DoNoisyStrip:
81  flags.SCTCalib.DoHitMapsLB = True
82  else:
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
89  else:
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!')
99  else:
100  flags.SCTCalib.DoHitMapsLB = False
101  flags.SCTCalib.DoHitMaps = False
102  flags.SCTCalib.ReadHitMaps = False
103 
104  #--- set flag for algs which use HIST
105  doHIST = flags.SCTCalib.DoNoiseOccupancy or flags.SCTCalib.DoRawOccupancy or flags.SCTCalib.DoEfficiency or flags.SCTCalib.DoBSErrorDB or flags.SCTCalib.DoLorentzAngle
106 
107  #--- set flag for DCSConditionsSvc
108  if flags.SCTCalib.DoHV and flags.SCTCalib.DataSource == 'data':
109  flags.SCTCalib.UseDCS = True
110  #--- set flag for ConfigurationConditionsSvc
111  if flags.SCTCalib.DoHV or doHIST:
112  flags.SCTCalib.UseConfiguration = False
113  #--- set flag for ReadCalibDataSvc
114  if flags.SCTCalib.DataSource == 'geant4':
115  flags.SCTCalib.UseCalibration = False
116  if not flags.SCTCalib.DoNoisyStrip:
117  flags.SCTCalib.UseCalibration = False
118  #--- set flag for MajorityConditionsSvc
119  if not flags.SCTCalib.DoNoisyStrip:
120  flags.SCTCalib.UseMajority = False
121  #--- set flag for ByteStreamErrorsSvc
122  if flags.SCTCalib.DoDeadStrip or flags.SCTCalib.DoDeadChip:
123  flags.SCTCalib.UseBSError = True
124  #--- set flag for creating hitmaps
125  if flags.SCTCalib.DoHV or doHIST:
126  flags.SCTCalib.DoHitMaps = False
127  flags.SCTCalib.DoHitMapsLB = False
128  #--- set flag for creating BSErrors map
129  if (flags.SCTCalib.DoDeadStrip or flags.SCTCalib.DoDeadChip or
130  flags.SCTCalib.DoQuietStrip or flags.SCTCalib.DoQuietChip):
131  flags.SCTCalib.DoBSErrors = True
132 
133  #--- force input HIST file list and EvtMax to 1 when reading HIST
134  if doHIST:
135  flags.SCTCalib.InputHist = runArgs.inputNames
136  flags.SCTCalib.EvtMax = 1
137 
138  #--- force reference run to current run number when checking information uploaded to COOL for previous runs
139  if hasattr( runArgs, 'forceRefRunNumber' ):
140  flags.SCTCalib.ForceRefRunNumber = runArgs.forceRefRunNumber
141 
142 
read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
python.SCT_RawDataByteStreamCnvConfig.SCTRawDataProviderCfg
def SCTRawDataProviderCfg(flags, prefix="InDet", suffix="", **kwargs)
Definition: SCT_RawDataByteStreamCnvConfig.py:30
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
SCTCalib_Skeleton.setSCTCalibFlagsFromRunArgs
def setSCTCalibFlagsFromRunArgs(flags, runArgs)
Definition: SCTCalib_Skeleton.py:8
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.DetectorConfigFlags.disableDetectors
def disableDetectors(flags, detectors, toggle_geometry=False)
Definition: DetectorConfigFlags.py:426
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.CommonRunArgsToFlags.commonRunArgsToFlags
def commonRunArgsToFlags(runArgs, configFlags)
Definition: CommonRunArgsToFlags.py:12
python.IOVDbSvcConfig.IOVDbSvcCfg
def IOVDbSvcCfg(flags, **kwargs)
Definition: IOVDbSvcConfig.py:19
SCTCalib_Skeleton.getRunInfoForHist
def getRunInfoForHist()
Definition: SCTCalib_Skeleton.py:143
SCTCalibFlags.defaultSCTCalibFlags
def defaultSCTCalibFlags(flags, **kwargs)
Definition: SCTCalibFlags.py:6
SCTCalib_Skeleton.fromRunArgs
def fromRunArgs(runArgs)
Definition: SCTCalib_Skeleton.py:207
ReadCoolUPD4.GetRunList
def GetRunList(dbstring, folder, tag, runNumber, k)
Definition: ReadCoolUPD4.py:63
ReadCoolUPD4.GetNumNoisyMods
def GetNumNoisyMods(dbstring, folder, tag, runNumber)
Definition: ReadCoolUPD4.py:110
Trk::open
@ open
Definition: BinningType.h:40
ReadCoolUPD4.GetNumNoisyStrips
def GetNumNoisyStrips(dbstring, folder, tag, runNumber)
Definition: ReadCoolUPD4.py:130
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
SCTCalib_Skeleton.readNoisyModulesAndStripsFromDB
def readNoisyModulesAndStripsFromDB(flags)
Definition: SCTCalib_Skeleton.py:165
SCTCalibAlgConfig.SCTCalibAlgCfg
def SCTCalibAlgCfg(flags, SORTime, EORTime, nLB, prefix, name='SCTCalibAlg', **kwargs)
Definition: SCTCalibAlgConfig.py:106
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.EventIdOverrideConfig.EvtIdModifierSvcCfg
def EvtIdModifierSvcCfg(flags, name="EvtIdModifierSvc", **kwargs)
Definition: EventIdOverrideConfig.py:130
readCCLHist.float
float
Definition: readCCLHist.py:83