/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/BOOST/TofSim/TofSim-00-02-33/dat/TofPmtBrSvc.py

Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 class TofPmtBrSvc:
00004   def __init__(self):
00005     import os
00006     self.__rootPath = os.getenv('TOFSIMROOT') + '/dat/'
00007     self.__file = open(self.__rootPath + 'srcTofPmtBr.txt', 'r')
00008     self.__fileLines = self.__file.readlines()
00009     self.__file.close()
00010 
00011   def do(self, no, key, value): 
00012     upperKey = key.upper()
00013     oldLines = self.__fileLines
00014     
00015     upperKeys = oldLines[1].upper()
00016     keys = upperKeys.split()
00017     keyNo = 0
00018     wantKey = 0
00019     for eachKey in keys:
00020       if eachKey == upperKey:
00021         wantKey = keyNo
00022         break
00023       keyNo = keyNo + 1
00024     
00025     oldLine = oldLines[no + 2]
00026     oldValues = oldLine.split()
00027     newValues = []
00028     for i in xrange(oldValues.__len__()):
00029       if i == wantKey:
00030         newValues.append(value)
00031       else:
00032         newValues.append(oldValues[i])
00033     newLine = ' '.join(newValues)
00034     newLine = newLine + '\n'
00035     
00036     self.__fileLines = []
00037     for i in xrange(2):
00038       self.__fileLines.append(oldLines[i])
00039     for i in xrange(oldLines[2:].__len__()):
00040       if i == no:
00041         self.__fileLines.append(newLine)
00042       else:
00043         self.__fileLines.append(oldLines[i + 2])
00044 
00045   def write(self):
00046     outFile = open(self.__rootPath + 'TofPmtBr.txt', 'w')
00047     outFile.writelines(self.__fileLines)
00048     outFile.close()
00049 
00050 
00051 if __name__ == '__main__':
00052   tofPmtBrSvc = TofPmtBrSvc()
00053   listPmt = ['EPMTgain', 'WPMTgain']
00054   for i in xrange(176):
00055     for eachPmt in listPmt:
00056       tofPmtBrSvc.do(i, eachPmt, '3.0e5')
00057   tofPmtBrSvc.write()

Generated on Tue Nov 29 23:14:31 2016 for BOSS_7.0.2 by  doxygen 1.4.7