8 print (
"""Change the run number in a pool file.
9 Probably only works correctly for simple, single-run MC files.
11 Usage: changerun.py NEWRUN INFILE OUTFILE
14 newrun = int (sys.argv[1])
22 os.environ[
'_ATHENABARCODEIMPL_JOBUUID'] = uuid.uuid1().hex
25 from PyUtils.Helpers
import ROOT6Setup
28 ROOT.DataModelAthenaPool.CLHEPConverters.initialize()
34 cl = ROOT.TClass.GetClass(
'Analysis::TruthInfo_p1')
37 f2=ROOT.TFile(outfile,
'RECREATE')
41 kk = [k.GetName()
for k
in f1.GetListOfKeys()]
43 if k
in [
'CollectionTree',
'MetaData']:
continue
51 types = ifo.GetTypes()
52 elts = ifo.GetElements()
53 for i
in range(ifo.GetNdata()):
54 if elts[i].GetName() ==
'm_athenabarcode' and types[i] == 217:
56 for bb
in b.GetListOfBranches():
59 for b
in t2.GetListOfBranches():
63 for i
in range(t1.GetEntries()):
65 oldrun = t1.EventInfo_p3_McEventInfo.m_AllTheData[1]
66 t1.EventInfo_p3_McEventInfo.m_AllTheData[1] = newrun
72 if xrun <= 0
or xrun > 1000000:
return x
73 return ((xrun-oldrun) + newrun) * (1<<32) + (x & ((1<<32)-1))
76 for i
in range(m1.GetEntries()):
78 for b
in m1.GetListOfBranches():
80 if bn.startswith (
'IOVMetaDataContainer_'):
81 pv = getattr (m1, bn).m_payload.m_payloadVec
83 if p.m_hasRunLumiBlockTime:
84 p.m_start = adjust_run (p.m_start)
85 p.m_stop = adjust_run (p.m_stop)
86 for pa
in p.m_attrLists:
88 r.m_start = adjust_run (r.m_start)
89 r.m_stop = adjust_run (r.m_stop)