5from AthenaPython.PyAthena
import Alg, py_svc, StatusCode
6from AthenaCommon.Logging
import logging
11 def __init__(self,name='ReadDataHeaderAlg', totalEvents=0):
12 super(ReadDataHeaderAlg,self).
__init__(name=name)
18 self.
sg = py_svc(
'StoreGateSvc')
19 return StatusCode.Success
22 if self.
sg.
contains(
'DataHeader',
'EventSelector'):
23 dh = self.
sg.retrieve(
'DataHeader',
'EventSelector')
26 if self.
nevt % 100 == 0:
27 logging.info(f
'DataHeader Size {sz} in event #{self.nevt}')
31 logging.debug(f
' >> Key {it.getKey()} : Token {it.getToken().toString()}')
34 logging.debug(
' >> Successfully read through the DataHeader')
36 logging.error(f
' >> Negative DataHeader size ({sz})!')
37 return StatusCode.Failure
39 logging.error(
'Could NOT find the DataHeader!')
40 return StatusCode.Failure
42 return StatusCode.Success
49 logging.error(f
'Expected {self.totalEvents} events but processed {self.nevt}!')
50 logging.error(
'This most likely means we could not process some events successfully!')
51 return StatusCode.Failure
53 return StatusCode.Success
56if __name__ ==
'__main__':
58 Example usage: readDataHeader.py --filesInput=DAOD_PHYS.pool.root --evtMax=10 --loglevel=DEBUG
62 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
63 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
67 flags = initConfigFlags()
72 if flags.Exec.MaxEvents < 0:
74 from AthenaConfiguration.AutoConfigFlags
import GetFileMD
75 for filename
in flags.Input.Files:
76 totalEvents += GetFileMD(filename).
get(
'nentries', 0)
78 totalEvents = flags.Exec.MaxEvents
81 cfg = MainServicesCfg(flags)
84 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
85 cfg.merge(PoolReadCfg(flags))
88 cfg.addEventAlgo(
ReadDataHeaderAlg(
'ReadDataHeaderAlg', totalEvents=totalEvents), sequenceName =
'AthAllAlgSeq')
93 sys.exit(
not sc.isSuccess())
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring