ATLAS Offline Software
Functions | Variables
LArMerge_tf Namespace Reference

Functions

def getSubFileMap (fname, nevts=0)
 
def larMerge (dataMap)
 

Variables

 jsonfile = sys.argv[1][len('--argJSON='):]
 main() More...
 
 f = open(jsonfile, 'r')
 
 dataMap = json.load(f)
 
 inputFiles = sys.argv[1][13:].split(',')
 
 outputFile = sys.argv[2][13:]
 

Function Documentation

◆ getSubFileMap()

def LArMerge_tf.getSubFileMap (   fname,
  nevts = 0 
)

Definition at line 27 of file LArMerge_tf.py.

27 def getSubFileMap(fname, nevts=0) :
28  if os.path.isfile(fname) :
29  sz = os.path.getsize(fname)
30  map = { 'name': fname,
31  'file_size' : sz,
32  'nentries' : nevts,
33  }
34  else :
35  map = {}
36  return map
37 
38 

◆ larMerge()

def LArMerge_tf.larMerge (   dataMap)

Definition at line 42 of file LArMerge_tf.py.

42 def larMerge(dataMap) :
43 
44  tstart = time.time()
45 
46  print("\n##################################################################")
47  print( "## ATLAS Tier0 LAr CAF file Merging ##")
48  print( "##################################################################\n")
49 
50  # initialize exit values
51  exitCode = 0
52  exitAcronym = 'OK'
53  exitMsg = 'trf finished OK'
54  dt=0
55  nEvents=0
56  outFiles = []
57  inFiles = []
58 
59  print("\nFull Tier-0 run options:\n")
60  pprint.pprint(dataMap)
61 
62  inputList = []
63  inputDSName = dataMap['inputLArFiles'][0]['dsn']
64 
65  for fdict in dataMap['inputLArFiles'] :
66  inputList.append(fdict['lfn'])
67 
68  print("\ninputLArFiles list:\n")
69  pprint.pprint(inputList)
70 
71  # output file
72  outputDSName = dataMap['outputLArFile'].split('#')[0]
73  outputFile = dataMap['outputLArFile'].split('#')[1]
74 
75  print('\nOutput file name:', outputFile)
76 
77  cmdline=["LArSamplesMerge"]
78  for fileName in inputList:
79  if os.access(fileName,os.R_OK):
80  cmdline.append(fileName)
81  else:
82  print('ERROR : could not open file', fileName)
83  exitCode = 74001
84  exitAcronym = 'TRF_LAR_FILE_INPUT_ERROR'
85  exitMsg = 'LAr input file not accessible'
86  break
87  pass
88 
89  if (exitCode==0):
90  writepath=os.path.split(outputFile)[0]
91  if writepath=="": writepath="./"
92  if (os.access(writepath,os.W_OK)):
93  cmdline.append(outputFile)
94  else:
95  print("ERROR, not allowed to write to oututfile", outputFile)
96  exitCode = 74002
97  exitAcronym = 'TRF_LAR_MERGE_ERROR'
98  exitMsg = 'LAR merging error'
99  pass
100 
101  if (exitCode==0):
102 
103  logfile=open("log.LArMerge","w")
104 
105  try:
106  subprocess.check_call(cmdline,stdout=logfile,stderr=subprocess.STDOUT)
107  except Exception as e:
108  print("ERROR exectution of subprocess failed")
109  print(e)
110  exitAcronym = 'TRF_LAR_MERGE_ERROR'
111  exitMsg = 'LAR merging error'
112  exitCode=1
113 
114  logfile.close()
115  logfile=open("log.LArMerge","r")
116 
117  for line in logfile:
118  print(line,)
119  if line.startswith("Open file "):
120  linetok=line.split(" ")
121  inFiles.append(getSubFileMap(linetok[2],nevts=int(linetok[4])))
122  if line.startswith("Wrote output file "):
123  linetok=line.split(" ")
124  nEvents=int(linetok[5])
125  outFiles.append(getSubFileMap(linetok[3], nevts=nEvents))
126  logfile.close()
127  dt = int(time.time() - tstart)
128  # assemble job report map, json it
129  outMap = { 'exitAcronym' : exitAcronym,
130  'exitCode' : exitCode,
131  'exitMsg' : exitMsg,
132  'files' : { 'output' : [{ 'dataset' : outputDSName,
133  'subFiles' : outFiles
134  },],
135  'input' : [{ 'dataset' : inputDSName,
136  'subFiles' : inFiles
137  }
138  ] },
139  'resource' : { 'transform' : { 'processedEvents' : int(nEvents), 'wallTime' : dt} }
140  }
141 
142  f = open('jobReport.json', 'w')
143  json.dump(outMap, f)
144  f.close()
145 
146  print("\n##################################################################")
147  print( "## End of job.")
148  print( "##################################################################\n")
149 
150  print(outMap)
151 

Variable Documentation

◆ dataMap

dictionary LArMerge_tf.dataMap = json.load(f)

Definition at line 164 of file LArMerge_tf.py.

◆ f

LArMerge_tf.f = open(jsonfile, 'r')

Definition at line 163 of file LArMerge_tf.py.

◆ inputFiles

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

Definition at line 168 of file LArMerge_tf.py.

◆ jsonfile

LArMerge_tf.jsonfile = sys.argv[1][len('--argJSON='):]

main()

Definition at line 160 of file LArMerge_tf.py.

◆ outputFile

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

Definition at line 169 of file LArMerge_tf.py.

CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LArMerge_tf.larMerge
def larMerge(dataMap)
Definition: LArMerge_tf.py:42
Trk::open
@ open
Definition: BinningType.h:40
LArMerge_tf.getSubFileMap
def getSubFileMap(fname, nevts=0)
Definition: LArMerge_tf.py:27
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
Trk::split
@ split
Definition: LayerMaterialProperties.h:38