ATLAS Offline Software
Loading...
Searching...
No Matches
createTRTPIDTool Namespace Reference

Functions

 store_PID_to_folder (db, values_list)
 read_PID_txt (input_file_name)
 main ()

Variables

str __author__ = 'mborodin'
str FOLDER_NAME = '/TRT/Calib/PID_vector'
str TAG_NAME = 'TRTCalibPID_vector_Data15_noArCFs_noZR_00-01'
 level
 _logger = logging.getLogger('createPIDTool')

Function Documentation

◆ main()

createTRTPIDTool.main ( )

Definition at line 96 of file createTRTPIDTool.py.

96def main():
97
98 if len(sys.argv) != 3:
99 print "Usage: %s input_file connection_string" % sys.argv[0]
100 return -1
101 values_dict = read_PID_txt(sys.argv[1])
102 print "\nREAD OVER"
103 connect_string = sys.argv[2]
104 _logger.info("data from file: %s" % values_dict)
105 #print values_dict
106 try:
107 dbSvc = cool.DatabaseSvcFactory.databaseService()
108 _logger.debug('dropping database %s' % connect_string)
109 dbSvc.dropDatabase( connect_string )
110 _logger.debug('creating database')
111 db = dbSvc.createDatabase( connect_string )
112 except Exception,e:
113 _logger.error("Problem with database: %s" % e)
114 return -1
115 store_PID_to_folder(db, values_dict)
116 db.closeDatabase()
117
int main()
Definition hello.cxx:18

◆ read_PID_txt()

createTRTPIDTool.read_PID_txt ( input_file_name)
Read data from input txt file in awful format
:param input_file_name: input file path

Definition at line 63 of file createTRTPIDTool.py.

63def read_PID_txt(input_file_name):
64 """
65 Read data from input txt file in awful format
66 :param input_file_name: input file path
67 """
68 output_list=[]
69 with open(input_file_name,'r') as input_file:
70 for line in input_file:
71# print line
72 #line = line.replace(' ','').replace("\n",'')
73 line = line.replace("\n",'')
74 if line and (line.find('#')==-1):
75 #elements = line.split(',')
76 elements = line.split()
77 print elements
78
79 if len(elements) > 5:
80 #Why?!
81 barrel_or_endcap = elements[2].replace('EndcapWheels','EW')
82 electrons = elements[3].replace('Electrons','Elecs')
83 ChannelName = elements[4] + '_' +elements[1] + '_' + elements[2] + '_' +elements[0] + '_' + elements[3]
84 #ChannelName = elements[4] + '_' + elements[2] + '_' +elements[1] + '_' +elements[0] + '_' + elements[3]
85 #output_list.append(((elements[1]+'_'+barrel_or_endcap+'_'+electrons),map(float,elements[8:])))
86 print elements[0:4]
87 print ChannelName
88 # print elements[5:]
89 output_list.append(( ChannelName ,map(float,elements[5:])))
90 else:
91 print "SIZE OF THE LINE ODD. CHECK!!! "
92 print line
93 return output_list
94
95
STL class.
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

◆ store_PID_to_folder()

createTRTPIDTool.store_PID_to_folder ( db,
values_list )
Function to create folder FOLDER_NAME in db with channels and input data from values_list with tag TAG_NAME
:param db: Open cool db
:param values_list: list of tuples ('channel name', valus array)

Definition at line 27 of file createTRTPIDTool.py.

27def store_PID_to_folder(db,values_list):
28 """
29 Function to create folder FOLDER_NAME in db with channels and input data from values_list with tag TAG_NAME
30 :param db: Open cool db
31 :param values_list: list of tuples ('channel name', valus array)
32
33 """
34 spec = cool.RecordSpecification()
35 spec.extend('array_value',cool.StorageType.Float)
36 _logger.info('Create folder %s' % FOLDER_NAME)
37 folder_spec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION,
38 spec,
39 cool.PayloadMode.VECTORPAYLOAD)
40 folder = db.createFolder(FOLDER_NAME, folder_spec,
41 ' <timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="55403898"/></addrHeader><typeName>CondAttrListVec</typeName>',
42 True)
43
44 for index, channel_name in enumerate(values_list):
45 folder.createChannel(index,channel_name[0])
46 print '%i - %s' % (index, channel_name[0])
47 folder.setupStorageBuffer()
48 for index, channel_values in enumerate(values_list):
49 _logger.info('Store data from %s' % channel_values[0])
50 values = channel_values[1]
51 # print channel_values[0]
52 # print channel_values[1]
53 vector = cool.IRecordVector()
54 for value in values:
55 # print value
56 data = cool.PyCool.Helpers.IRecordPtr(spec)
57 data.get()['array_value'] = value
58 vector.push_back(data)
59 folder.storeObject(0,cool.ValidityKeyMax, vector, index, TAG_NAME )
60 folder.flushStorageBuffer()
61
62

Variable Documentation

◆ __author__

str createTRTPIDTool.__author__ = 'mborodin'
private

Definition at line 3 of file createTRTPIDTool.py.

◆ _logger

createTRTPIDTool._logger = logging.getLogger('createPIDTool')
protected

Definition at line 21 of file createTRTPIDTool.py.

◆ FOLDER_NAME

str createTRTPIDTool.FOLDER_NAME = '/TRT/Calib/PID_vector'

Definition at line 11 of file createTRTPIDTool.py.

◆ level

createTRTPIDTool.level

Definition at line 20 of file createTRTPIDTool.py.

◆ TAG_NAME

str createTRTPIDTool.TAG_NAME = 'TRTCalibPID_vector_Data15_noArCFs_noZR_00-01'

Definition at line 12 of file createTRTPIDTool.py.