forked from CMS-LUMI-POG/VdMFramework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fitResultReader.py
executable file
·40 lines (28 loc) · 1.17 KB
/
fitResultReader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import ROOT as r
import pickle, sys
class fitResultReader:
def __init__(self, fitResultFile):
self.fitResultTable = {}
with open(fitResultFile, 'rb') as f:
self.fitResultTable = pickle.load(f)
self.fitParamNames = self.fitResultTable[0]
def getFitParam(self, paramName):
if paramName not in self.fitParamNames:
print "First row of FitResultTable should be a list of strings that shows what is in the columns"
print paramName + " should be somewhere in that list"
print "This is not the case, hence probem with fitResultTable, exiting program"
sys.exit(1)
paramIndex = -99
for index, value in enumerate(self.fitParamNames):
if value.strip() == paramName:
paramIndex = index
# return value is a defaultdict(dict)
from collections import defaultdict
fitParam = defaultdict(dict)
for row in self.fitResultTable[1:]:
scanNumber = row[0]
scanName = "Scan_"+str(scanNumber)
bx = row[2]
value = row[paramIndex]
fitParam[scanName][bx] = value
return fitParam