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 15 of file LArHistMerge_trf.py.

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

◆ getPFN()

def LArHistMerge_trf.getPFN (   filespec)

Definition at line 30 of file LArHistMerge_trf.py.

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

◆ getRunLB()

def LArHistMerge_trf.getRunLB (   fname)

Definition at line 56 of file LArHistMerge_trf.py.

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

◆ larMerge()

def LArHistMerge_trf.larMerge (   dataMap)

Definition at line 94 of file LArHistMerge_trf.py.

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

Variable Documentation

◆ dataMap

dictionary LArHistMerge_trf.dataMap = pickle.load(f)

Definition at line 217 of file LArHistMerge_trf.py.

◆ f

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

Definition at line 216 of file LArHistMerge_trf.py.

◆ inputFiles

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

Definition at line 221 of file LArHistMerge_trf.py.

◆ outputFile

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

Definition at line 222 of file LArHistMerge_trf.py.

◆ picklefile

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

main()

Definition at line 213 of file LArHistMerge_trf.py.

LArHistMerge_trf.getRunLB
def getRunLB(fname)
Definition: LArHistMerge_trf.py:56
GetLBsToIgnore.getLBsToIgnore
def getLBsToIgnore(runnum, burstsFromCosmic=True, bulkProcessing=False, dropNonReady=True)
Definition: GetLBsToIgnore.py:20
LArHistMerge_trf.getPFN
def getPFN(filespec)
Definition: LArHistMerge_trf.py:30
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:15
LArHistMerge_trf.larMerge
def larMerge(dataMap)
Definition: LArHistMerge_trf.py:94
Trk::open
@ open
Definition: BinningType.h:40
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
Trk::split
@ split
Definition: LayerMaterialProperties.h:38