ATLAS Offline Software
Loading...
Searching...
No Matches
TileCalibBlobPython_writeAutoCrFromASCII.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_writePedFromASCII.py
6# Nils Gollub <nils.gollub@cern.ch>, 2008-03-03
7# modified: Lukas Pribyl <lukas.pribyl@cern.ch>, 2008-06-27
8# modified: Yuri Smirnov <iouri.smirnov@cern.ch>, 2014-12-14
9
10import cppyy
11
12from TileCalibBlobPython import TileCalibTools
13from TileCalibBlobObjs.Classes import TileCalibUtils
14import os
15
16#=== some preparation
17from TileCalibBlobPython.TileCalibLogger import getLogger
18log = getLogger("writeAutoCr")
19import logging
20log.setLevel(logging.DEBUG)
21
22#
23#________________________________________________________________________
24def fillAutoCr(filePed, tag, since,
25 until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK)):
26
27 #=== construct folder path
28 folder = TileCalibTools.getTilePrefix(True,True)+"NOISE/AUTOCR"
29
30 #=== get full folder tag
31 folderTag = TileCalibUtils.getFullTag(folder, tag)
32
33 #=== common noise autocr defaults (no correlation)
34 default = cppyy.gbl.std.vector('float')()
35 for i in range(6):
36 default.push_back(0.)
37 defVec = cppyy.gbl.std.vector('std::vector<float>')()
38 defVec.push_back(default)
39 defVec.push_back(default)
40
41 #=====================================================
42 #=== fill
43 #=====================================================
44 writer = TileCalibTools.TileBlobWriter(db,folder,'Flt')
45 writer.setComment(os.getlogin(),"Giulio's file for LBC test n.0, 2009-02-27")
46 parser = TileCalibTools.TileASCIIParser(filePed,"AutoCr")
47
48 #=== initialize all channels and write global default
49 util = cppyy.gbl.TileCalibUtils()
50 for ros in range(util.max_ros()):
51 for drawer in range(util.getMaxDrawer(ros)):
52 writer.zeroBlob(ros,drawer)
53 calibDrawer = writer.getDrawer(0,0)
54 calibDrawer.init(defVec,1,1)
55
56 #=== loop over whole detector
57 for ros in range(1,5):
58 for mod in range(64):
59 #=== need to invalidate previous blob in DB when reading from ASCII file
60 writer.zeroBlob(ros,mod)
61 for chn in range(48):
62 values = parser.getData(ros,mod,chn)
63 if not len(values):
64 log.warning("%i/%2i/%2i/x: No value found in file", ros,mod,chn)
65 continue
66 #=== init drawer with defaults for first entry
67 calibDrawer = writer.getDrawer(ros,mod)
68 if not calibDrawer.getNObjs():
69 log.info("Initializing drawer %i/%2i\t%i", ros,mod,calibDrawer.getNObjs())
70 calibDrawer.init(defVec,48,1)
71 #=== fill in realistic values
72 for adc in range(2):
73 line = "%i/%2i/%2i/%i: " % (ros,mod,chn,adc)
74 for i in range(6):
75 value = float(values[adc*6+i])
76 calibDrawer.setData(chn,adc,i,value)
77 line += "%f " % (value,)
78
79 log.debug(line)
80 #=== register in DB
81 writer.register(since, until, folderTag)
82
83#===================================================================
84#====================== FILL DB BELOW ==============================
85#===================================================================
86
87#=== open the database
88db = TileCalibTools.openDb('SQLITE', 'CONDBR2', 'UPDATE')
89tag = "TEST-00"
90
91#=== source data
92runfrom = 0
93fillAutoCr("Tile.autoCr", tag, (runfrom,0))
94
95#=== close the database connection
96db.closeDatabase()
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.
fillAutoCr(filePed, tag, since, until=(TileCalibTools.MAXRUN, TileCalibTools.MAXLBK))