ATLAS Offline Software
Functions
FileMerger Namespace Reference

Functions

def MergeCalibFiles (layers)
 
def readFile (name)
 

Function Documentation

◆ MergeCalibFiles()

def FileMerger.MergeCalibFiles (   layers)

Definition at line 8 of file FileMerger.py.

8 def MergeCalibFiles(layers):
9  if(len(layers)==0):
10  print("MergeCalibFiles - ERROR no layer provided.")
11  return 1
12  mergedDict = {}
13  for i in layers:
14  mergedDict.update(readFile(("calibration_%s.txt" % i)))
15 
16 
17  mergedDict = dict(sorted(mergedDict.items()))
18  f = open("calibration_merged.txt", "w")
19  for value in mergedDict.values():
20  f.write(value)
21  f.close()
22 
23  return 0
24 
25 
26 # Function to read the calibration_XXXXX.txt file of each layer

◆ readFile()

def FileMerger.readFile (   name)

Definition at line 27 of file FileMerger.py.

27 def readFile(name):
28  mydict = {}
29  if not os.path.exists(name):
30  print("MergeCalibFiles - ERROR File name %22s not found" % name)
31  return mydict
32  else:
33  print("MergeCalibFiles - Reading: %22s"% name)
34 
35  with open(name) as fp:
36  lines = fp.readlines()
37  mod = -1
38  for line in lines:
39  # Module names for Pixel layers starts with D or L
40  if line.startswith("L") or line.startswith("D"):
41  line = line.rstrip("\n")
42  splittedline = line.split(" ")
43 
44  if int(splittedline[1]) in mydict.keys():
45  print("MergeCalibFiles - ERROR Module key exists already - Contact pixel offline team")
46  exit(1)
47  else:
48  mydict[int(splittedline[1])] = splittedline[0]+' '+splittedline[1]+"\n"
49  mod = int(splittedline[1])
50 
51  # Pixel frontends start with letter I
52  elif line.startswith("I"):
53  mydict[mod] = mydict[mod] + line
54  else:
55  print("MergeCalibFiles - ERROR Line is not a module or a frontend - Contact pixel offline team")
56  exit(1)
57 
58  return mydict
59 
60 # Just used for testing - Experts only
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
FileMerger.readFile
def readFile(name)
Definition: FileMerger.py:27
FileMerger.MergeCalibFiles
def MergeCalibFiles(layers)
Definition: FileMerger.py:8
calibdata.exit
exit
Definition: calibdata.py:236
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
Trk::open
@ open
Definition: BinningType.h:40
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567