Belle II Software development
SVDDefaultPulseShapeImporter.py
1#!/usr/bin/env python
2
3
10
11"""
12SVD Default PulseShape Calibration importer (MC).
13Script to Import Calibrations into a local DB
14"""
15import basf2 as b2
16from ROOT import Belle2
17from ROOT.Belle2 import SVDStripCalAmp
18import datetime
19
20
21now = datetime.datetime.now()
22
23pulseWidth = 130
24
25# gain here is actually ADUequivalent (e-/ADC)
26# we set the INVERSE of it in the payload, so that the payload actually contains the gain
27'''
28# Phase 3 - old
29gain_L3_U = 375
30gain_L3_V = 375
31gain_bkw_U = 375
32gain_bkw_V = 375
33gain_origami_U = 375
34gain_origami_V = 375
35gain_fwd_U = 375
36gain_fwd_V = 375
37'''
38# Phase 3 - matching data
39gain_L3_U = 282.5
40gain_L3_V = 275.5
41gain_bkw_U = 250.1
42gain_bkw_V = 246.6
43gain_origami_U = 271.4
44gain_origami_V = 218.8
45gain_fwd_U = 247.4
46gain_fwd_V = 245.7
47peakTime_L3_U = 67
48peakTime_L3_V = 58
49peakTime_bkw_U = 66
50peakTime_bkw_V = 52
51peakTime_origami_U = 66
52peakTime_origami_V = 52
53peakTime_fwd_U = 60
54peakTime_fwd_V = 51
55
56
58 '''default pulse shape calibrations importer'''
59
60 def beginRun(self):
61 '''begin run'''
62
64
65 # gain, peakTime,
66 tmp_calAmp = SVDStripCalAmp()
67 tmp_calAmp.gain = 275 # set after the loop on sensors
68 tmp_calAmp.peakTime = 75 # set after the loop on sensors
69 tmp_calAmp.pulseWidth = pulseWidth
71 tmp_calAmp, "PulseShapeCalibrations_default_" + str(now.isoformat()) +
72 "_INFO:_peakTime=fromPhase3calibrations_pulseWidth=130_gain=fromPhase3calibrations")
73
75
76 for layer in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
77 layerNumber = layer.getLayerNumber()
78 for ladder in geoCache.getLadders(layer):
79 ladderNumber = ladder.getLadderNumber()
80 for sensor in geoCache.getSensors(ladder):
81 sensorNumber = sensor.getSensorNumber()
82 for side in (0, 1):
83 Nstrips = 768
84 print("setting PulseShape for " +
85 str(layerNumber) + "." + str(ladderNumber) + "." + str(sensorNumber) + "." + str(side))
86 if side == 0: # V
87 if layerNumber == 3: # L3 V
88 gain = gain_L3_V
89 peakTime = peakTime_L3_V
90 else:
91 Nstrips = 512
92 if sensorNumber == 1: # FW V
93 gain = gain_fwd_V
94 peakTime = peakTime_fwd_V
95 else: # BKW V
96 if sensorNumber == layerNumber - 1: # FW V
97 gain = gain_bkw_V
98 peakTime = peakTime_bkw_V
99 else: # BARREL V
100 gain = gain_origami_V
101 peakTime = peakTime_origami_V
102 if side == 1: # U
103 if layerNumber == 3: # L3 U
104 gain = gain_L3_U
105 peakTime = peakTime_L3_U
106 else:
107 if sensorNumber == 1: # FW U
108 gain = gain_fwd_U
109 peakTime = peakTime_fwd_U
110 else: # BKW U
111 if sensorNumber == layerNumber - 1: # FW U
112 gain = gain_bkw_U
113 peakTime = peakTime_bkw_U
114 else: # BARREL U
115 gain = gain_origami_U
116 peakTime = peakTime_origami_U
117
118 tmp_calAmp.gain = 1 / gain
119 tmp_calAmp.peakTime = peakTime
120
121 # print(str(Nstrips))
122 for strip in range(0, Nstrips):
123 # print("setting Gain for strip " + str(strip) + " to " + str(tmp_calAmp.gain))
124
125 calAmp_payload.set(layerNumber, ladderNumber, sensorNumber, bool(side), strip, tmp_calAmp)
126
127 Belle2.Database.Instance().storeData(Belle2.SVDPulseShapeCalibrations.calAmp_name, calAmp_payload, iov)
128
129
130b2.conditions.prepend_globaltag("svd_onlySVDinGeoConfiguration")
131
132main = b2.create_path()
133
134# Event info setter - execute single event
135eventinfosetter = b2.register_module('EventInfoSetter')
136eventinfosetter.param({'evtNumList': [1], 'expList': 0, 'runList': 0})
137main.add_module(eventinfosetter)
138
139main.add_module("Gearbox")
140main.add_module("Geometry")
141
142main.add_module(defaultPulseShapeImporter())
143
144# Show progress of processing
145progress = b2.register_module('Progress')
146main.add_module(progress)
147
148# Process events
149b2.process(main)
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
base class for calibrations classes
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42