ATLAS Offline Software
Functions | Variables
LArHistMerge_trf Namespace Reference

Functions

def getFileMap (fname, dsname, nevts=0, guid='')
 
def getPFN (filespec)
 
def getRunLB (fname)
 
def larMerge (dataMap)
 

Variables

 picklefile = sys.argv[1][len('--argdict='):]
 main() More...
 
 f = open(picklefile, 'rb')
 
 dataMap = pickle.load(f)
 
 inputFiles = sys.argv[1][13:].split(',')
 
 outputFile = sys.argv[2][13:]
 

Function Documentation

◆ getFileMap()

def LArHistMerge_trf.getFileMap (   fname,
  dsname,
  nevts = 0,
  guid = '' 
)

Definition at line 16 of file LArHistMerge_trf.py.

16 def getFileMap(fname, dsname, nevts=0, guid='') :
17  if os.path.isfile(fname) :
18  dataMap = { 'lfn': fname,
19  'dataset' : dsname,
20  'events' : nevts
21  }
22  if guid :
23  dataMap['GUID'] = guid
24  else :
25  dataMap = {}
26  return dataMap
27 

◆ getPFN()

def LArHistMerge_trf.getPFN (   filespec)

Definition at line 31 of file LArHistMerge_trf.py.

31 def getPFN(filespec):
32  if isinstance(filespec,dict):
33  if "svcclass" in filespec:
34  os.environ["STAGE_SVCCLASS"]=filespec["svcclass"]
35  pass
36 
37  if 'pfn' in filespec:
38  return filespec['pfn']
39  else:
40  print ("ERROR: Unknown file specification (dict):")
41  print (filespec)
42  sys.exit(-1)
43 
44 
45  if isinstance(filespec,str):
46  names=filespec.split('#')
47  if len(names)!=2:
48  print ("ERROR: Unexpected file specification (string):")
49  print (filespec)
50  sys.exit(-1)
51  else:
52  return names[1]
53 
54 
55 
56 

◆ getRunLB()

def LArHistMerge_trf.getRunLB (   fname)

Definition at line 57 of file LArHistMerge_trf.py.

57 def getRunLB(fname):
58  filename=fname.split("/")[-1] #Strip off path
59  elem=filename.split(".")
60  #File name example:
61  #data11_7TeV.00190618.physics_CosmicCalo.recon.HIST.f411._lb0826._SFO-ALL._0001.1
62  if (len(elem) <6):
63  print ("ERROR: Invalid file name format. Expected at least six subfileds, got",filename)
64  sys.exit(-1)
65  pass
66 
67  step=elem[3]
68  if step != 'recon':
69  return (-1,-1)
70 
71  rnStr=elem[1]
72 
73  if not rnStr.isdigit():
74  print ("ERROR: Can't get run number, got",rnStr)
75  sys.exit(-1)
76  pass
77  run=int(rnStr,10)
78 
79  LBStr=elem[6]
80  if (len(LBStr)<4):
81  print ("ERROR: Can't get LB number, got",LBStr)
82  sys.exit(-1)
83  pass
84 
85  LBStr=LBStr[3:]
86  if not LBStr.isdigit():
87  print ("ERROR: Can't get LB number, got",LBStr)
88  sys.exit(-1)
89  pass
90 
91  LB=int(LBStr,10)
92  return (run,LB)
93 
94 

◆ larMerge()

def LArHistMerge_trf.larMerge (   dataMap)

Definition at line 95 of file LArHistMerge_trf.py.

95 def larMerge(dataMap) :
96 
97  print ("\n##################################################################")
98  print ( "## ATLAS Tier0 LAr CAF file Merging ##")
99  print ( "##################################################################\n")
100 
101  print ("\nFull Tier-0 run options:\n")
102  pprint.pprint(dataMap)
103 
104  inputList = []
105 
106  badLBs=set()
107 
108  inFiles=dataMap['inputHistFiles']
109 
110 
111  if len(inFiles)>0:
112  firstFile=getPFN(inFiles[0])
113  runnumber=getRunLB(firstFile)[0]
114  if runnumber==-1:
115  print ("Encountered pre-merged file, no bad-LB checking done" )
116  else:
117  print ("Found run number",runnumber)
118  badLBs=getLBsToIgnore(runnumber)
119 
120 
121  for val in inFiles:
122  pfn=getPFN(val)
123  if len(badLBs)>0:
124  LB=getRunLB(pfn)[1]
125  if LB in badLBs:
126  print ("Ignoring bad LumiBlock",LB)
127  continue
128  inputList.append(pfn)
129  sys.stdout.flush()
130  #print ("\ninputLArFiles list:\n")
131  #pprint.pprint(inputList)
132 
133  #Write input file list to temporary file:
134  templist=open("inputfiles.txt","w")
135  for infile in inputList:
136  templist.write(infile+"\n")
137  pass
138  templist.close()
139 
140 
141  # output file
142  outputDSName = dataMap['outputLArHistFile'].split('#')[0]
143  outputFile = dataMap['outputLArHistFile'].split('#')[1]
144 
145  print ('\nOutput file name:', outputFile)
146 
147  retcode = 0
148 
149  cmd="LArQuickHistMerge.exe -i inputfiles.txt " + outputFile
150 
151  try:
152  retcode = subprocess.call(cmd, shell=True)
153  print ('retcode =',retcode)
154  if retcode != 0 :
155  retcode = 62601
156  acronym = "LARQUICKHISTMEGE PROBLEM"
157  except OSError as e :
158  retcode = 62600
159  print (e)
160  acronym = "SUBPROCESS EXECUTION PROBLEM"
161  pass
162 
163  if retcode==0:
164  cmd ="DQWebDisplay.py " + outputFile +" LArDisplay 111"
165  print ("Attempt to run",cmd)
166  try:
167  retcodeDQM = subprocess.call(cmd, shell=True)
168  print ('retcode =',retcodeDQM)
169  except Exception as e:
170  print ("Attempt failed with exception")
171  print (e)
172 
173 
174  # get info for report gpickle file
175  if retcode == 0 :
176  outputMap = getFileMap(outputFile, outputDSName, nevts=0)
177  outFiles = [ outputMap ]
178  acronym = 'OK'
179  else:
180  outFiles = []
181  outputMap = {}
182  print ("ERROR: problem in LAr Histogram merging!")
183  if retcode == 62600 :
184  acronym = 'TRF_LAR_FILE_INPUT_ERROR'
185  elif retcode == 62601 :
186  acronym = 'TRF_LAR_MERGE_ERROR'
187 
188 
189 
190  # assemble job report map, pickle it
191  outMap = { 'prodsys': { 'trfCode': retcode,
192  'trfAcronym': acronym,
193  'jobOutputs': outFiles,
194  'jobInputs': inFiles,
195  }
196  }
197  f = open('jobReport.gpickle', 'wb')
198  pickle.dump(outMap, f)
199  f.close()
200 
201  print ("\n##################################################################")
202  print ( "## End of job.")
203  print ( "##################################################################\n")
204 
205 
206 

Variable Documentation

◆ dataMap

dictionary LArHistMerge_trf.dataMap = pickle.load(f)

Definition at line 218 of file LArHistMerge_trf.py.

◆ f

LArHistMerge_trf.f = open(picklefile, 'rb')

Definition at line 217 of file LArHistMerge_trf.py.

◆ inputFiles

LArHistMerge_trf.inputFiles = sys.argv[1][13:].split(',')

Definition at line 222 of file LArHistMerge_trf.py.

◆ outputFile

LArHistMerge_trf.outputFile = sys.argv[2][13:]

Definition at line 223 of file LArHistMerge_trf.py.

◆ picklefile

LArHistMerge_trf.picklefile = sys.argv[1][len('--argdict='):]

main()

Definition at line 214 of file LArHistMerge_trf.py.

LArHistMerge_trf.getRunLB
def getRunLB(fname)
Definition: LArHistMerge_trf.py:57
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
GetLBsToIgnore.getLBsToIgnore
def getLBsToIgnore(runnum, burstsFromCosmic=True, bulkProcessing=False, dropNonReady=True)
Definition: GetLBsToIgnore.py:21
LArHistMerge_trf.getPFN
def getPFN(filespec)
Definition: LArHistMerge_trf.py:31
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
LArHistMerge_trf.getFileMap
def getFileMap(fname, dsname, nevts=0, guid='')
Definition: LArHistMerge_trf.py:16
LArHistMerge_trf.larMerge
def larMerge(dataMap)
Definition: LArHistMerge_trf.py:95
Trk::open
@ open
Definition: BinningType.h:40
Trk::split
@ split
Definition: LayerMaterialProperties.h:38