ATLAS Offline Software
TileCalibBlobPython_writeIntegratorFromASCII.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 #
5 # TileCalibBlobPython_writeIntegratorFromASCII.py
6 # Lukas Pribyl <lukas.pribyl@cern.ch>, 2008-12-05
7 # change: Yuri Smirnov <iouri.smirnov@cern.ch>, 2014-12-24
8 
9 import cppyy
10 
11 from TileCalibBlobPython import TileCalibTools
12 from TileCalibBlobObjs.Classes import TileCalibUtils
13 import os
14 
15 #=== some preparation
16 from TileCalibBlobPython.TileCalibLogger import getLogger
17 log = getLogger("writeIntegrator")
18 import logging
19 log.setLevel(logging.DEBUG)
20 
21 #
22 #________________________________________________________________________
23 def fillIntegrator(fileInt, tag, since,
24  until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK)):
25 
26  #=== construct folder path
27  folder = TileCalibTools.getTilePrefix(True,True)+"INTEGRATOR"
28 
29  #=== get full folder tag
30  folderTag = TileCalibUtils.getFullTag(folder, tag)
31 
32  #=== create default values for each of the six gains 1 to 6
33  # for each gain there is:
34  # gain, error of the gain, chi2 of the fit, pedestal
35  # DAC for pedestal, sigma of pedestal distribution
36  # RMS of pedestal distribution, sigma of the RMS
37 
38  dv = []
39  dv.append(( 2.814, 0.023, -1, -1, 80, -1, -1, -1))
40  dv.append(( 26.010, 0.230, -1, -1, 80, -1, -1, -1))
41  dv.append(( 28.810, 0.240, -1, -1, 80, -1, -1, -1))
42  dv.append(( 54.810, 0.480, -1, -1, 70, -1, -1, -1))
43  dv.append(( 75.790, 0.677, -1, -1, 70, -1, -1, -1))
44  dv.append((101.800, 0.900, -1, -1, 70, -1, -1, -1))
45 
46  #=== number of integrator gains and value per gain
47  ngain = 6
48  nperg = 8
49 
50  defVec = cppyy.gbl.std.vector('std::vector<float>')()
51 
52  for i in range(ngain):
53  defaultGain = cppyy.gbl.std.vector('float')()
54  for v in dv[i]:
55  defaultGain.push_back(v)
56  defVec.push_back(defaultGain)
57 
58  #=====================================================
59  #=== fill
60  #=====================================================
61  writer = TileCalibTools.TileBlobWriter(db,folder,'Flt')
62  writer.setComment(os.getlogin(),"Jalal's values with non-zero defaults, 2008-12-05")
63  parser = TileCalibTools.TileASCIIParser(fileInt,"IntGain")
64  #=== initialize all channels and write global default
65  util = cppyy.gbl.TileCalibUtils()
66  for ros in range(util.max_ros()):
67  for drawer in range(util.getMaxDrawer(ros)):
68  writer.zeroBlob(ros,drawer)
69  calibDrawer = writer.getDrawer(0,0)
70  calibDrawer.init(defVec,1,1)
71  #=== loop over whole detector
72  for ros in range(1,5):
73  for mod in range(64):
74  #=== need to invalidate previous blob in DB when reading from ASCII file
75  writer.zeroBlob(ros,mod)
76  for chn in range(48):
77  values = parser.getData(ros,mod,chn)
78  if not len(values):
79  log.warning("%i/%2i/%2i/x: No value found in file", ros,mod,chn)
80  continue
81  #=== init drawer with defaults for first entry
82  calibDrawer = writer.getDrawer(ros,mod)
83  if not calibDrawer.getNObjs():
84  log.info("Initializing drawer %i/%2i\t%i", ros,mod,calibDrawer.getNObjs())
85  calibDrawer.init(defVec,48,1)
86 
87  #=== loop over gains
88  for adc in range(ngain):
89  line = "%i/%2i/%2i/%i: " % (ros,mod,chn,adc)
90  for v in range(nperg):
91  value = float(values[adc*nperg+v])
92  calibDrawer.setData(chn,adc,v,value)
93  line += "%f " % (value,)
94 
95  log.debug(line)
96 
97  #=== register in DB
98  writer.register(since, until, folderTag)
99 
100 
101 #===================================================================
102 #====================== FILL DB BELOW ==============================
103 #===================================================================
104 
105 #=== open the database
106 db = TileCalibTools.openDb('SQLITE', 'CONDBR2', 'UPDATE')
107 tag = "RUN2-HLT-UPD1-00"
108 
109 #=== source data file
110 fillIntegrator("/afs/cern.ch/user/l/lpribyl/CalibDB/Integrator/Calib_Int.dat", tag, (60000,0))
111 
112 #=== close the database connection
113 db.closeDatabase()
TileCalibBlobPython_writeIntegratorFromASCII.fillIntegrator
def fillIntegrator(fileInt, tag, since, until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK))
Definition: TileCalibBlobPython_writeIntegratorFromASCII.py:23
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
readCCLHist.float
float
Definition: readCCLHist.py:83
python.CaloCondLogger.getLogger
def getLogger(name="CaloCond")
Definition: CaloCondLogger.py:16
TileCalibUtils::getFullTag
static std::string getFullTag(const std::string &folder, const std::string &tag)
Returns the full tag string, composed of camelized folder name and tag part.
Definition: TileCalibUtils.cxx:33