Belle II Software development
SVDChargeSimulationImporter.py
1#!/usr/bin/env python
2
3
10
11"""
12SVD Charge Simulation Calibration importer (MC).
13Script to import charge coupling constants for simulation into a local DB
14"""
15import basf2 as b2
16from ROOT import Belle2
17from ROOT.Belle2 import SVDChargeSimCal
18import datetime
19from basf2 import conditions as b2conditions
20
21now = datetime.datetime.now()
22
23# c0,1,2,3 = coupling constants
24# APVCoupling = coupling constant at APV level
25# ew = electronWeight
26
27# L3 u/V
28ew_L3_U = 0.8828
29c0_L3_U = 0.76
30c1_L3_U = 0.42
31c2_L3_U = 0.12
32c3_L3_U = 0.08
33apvCoupling_L3_U = 0.00
34
35ew_L3_V = 0.8529
36c0_L3_V = 0.98
37c1_L3_V = 0.37
38c2_L3_V = 0
39c3_L3_V = 0
40apvCoupling_L3_V = 0.00
41
42# forward U/V
43ew_fw_U = 0.9163
44c0_fw_U = 0.82
45c1_fw_U = 0.42
46c2_fw_U = 0.09
47c3_fw_U = 0.08
48apvCoupling_fw_U = 0.00
49
50ew_fw_V = 0.9486
51c0_fw_V = 0.92
52c1_fw_V = 0.30
53c2_fw_V = 0
54c3_fw_V = 0
55apvCoupling_fw_V = 0.00
56
57# backward U/V
58ew_bk_U = 0.9128
59c0_bk_U = 0.80
60c1_bk_U = 0.42
61c2_bk_U = 0.10
62c3_bk_U = 0.08
63apvCoupling_bk_U = 0.00
64
65ew_bk_V = 0.9
66c0_bk_V = 0.94
67c1_bk_V = 0.32
68c2_bk_V = 0
69c3_bk_V = 0
70apvCoupling_bk_V = 0.00
71
72# origami U/v
73ew_or_U = 0.9138
74c0_or_U = 0.80
75c1_or_U = 0.42
76c2_or_U = 0.10
77c3_or_U = 0.08
78apvCoupling_or_U = 0.00
79
80ew_or_V = 0.9472
81c0_or_V = 0.83
82c1_or_V = 0.29
83c2_or_V = 0
84c3_or_V = 0
85apvCoupling_or_V = 0.00
86
87
89 ''' default coupling constants importer'''
90
91 def beginRun(self):
92 '''begin run'''
93
95
96 chargeSimCal = SVDChargeSimCal()
97
98 payload = Belle2.SVDChargeSimulationCalibrations.t_payload(chargeSimCal, "ChargeSimulationCalibrations_default_" +
99 str(now.isoformat()) + "_INFO:release-06_APVCouplings=0")
100
102
103 for layer in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
104 layerNumber = layer.getLayerNumber()
105 for ladder in geoCache.getLadders(layer):
106 ladderNumber = ladder.getLadderNumber()
107 for sensor in geoCache.getSensors(ladder):
108 sensorNumber = sensor.getSensorNumber()
109 for side in (0, 1):
110 print("setting ChargeSimulation for " +
111 str(layerNumber) + "." + str(ladderNumber) + "." + str(sensorNumber) + "." + str(side))
112 if side == 0: # V
113 if layerNumber == 3: # L3 V
114 apvCoupling = apvCoupling_L3_V
115 c0 = c0_L3_V
116 c1 = c1_L3_V
117 c2 = c2_L3_V
118 c3 = c3_L3_V
119 ew = ew_L3_V
120 else:
121 if sensorNumber == 1: # FW V
122 apvCoupling = apvCoupling_fw_V
123 c0 = c0_fw_V
124 c1 = c1_fw_V
125 c2 = c2_fw_V
126 c3 = c3_fw_V
127 ew = ew_fw_V
128 else:
129 if sensorNumber == layerNumber - 1: # BK V
130 apvCoupling = apvCoupling_bk_V
131 c0 = c0_bk_V
132 c1 = c1_bk_V
133 c2 = c2_bk_V
134 c3 = c3_bk_V
135 ew = ew_bk_V
136 else: # BARREL V
137 apvCoupling = apvCoupling_or_V
138 c0 = c0_or_V
139 c1 = c1_or_V
140 c2 = c2_or_V
141 c3 = c3_or_V
142 ew = ew_or_V
143 if side == 1: # U
144 if layerNumber == 3: # L3 U
145 apvCoupling = apvCoupling_L3_U
146 c0 = c0_L3_U
147 c1 = c1_L3_U
148 c2 = c2_L3_U
149 c3 = c3_L3_U
150 ew = ew_L3_U
151 else:
152 if sensorNumber == 1: # FW U
153 apvCoupling = apvCoupling_fw_U
154 c0 = c0_fw_U
155 c1 = c1_fw_U
156 c2 = c2_fw_U
157 c3 = c3_fw_U
158 ew = ew_fw_U
159 else: # BKW U
160 if sensorNumber == layerNumber - 1: # BK U
161 apvCoupling = apvCoupling_bk_U
162 c0 = c0_bk_U
163 c1 = c1_bk_U
164 c2 = c2_bk_U
165 c3 = c3_bk_U
166 ew = ew_bk_U
167 else: # BARREL U
168 apvCoupling = apvCoupling_or_U
169 c0 = c0_or_U
170 c1 = c1_or_U
171 c2 = c2_or_U
172 c3 = c3_or_U
173 ew = ew_or_U
174 # this insert does not work
175 chargeSimCal.couplingConstant['C0'] = c0
176 chargeSimCal.couplingConstant['C1'] = c1
177 chargeSimCal.couplingConstant['C2'] = c2
178 chargeSimCal.couplingConstant['C3'] = c3
179 chargeSimCal.couplingConstant['APVCoupling'] = apvCoupling
180 chargeSimCal.electronWeight = ew
181 payload.set(layerNumber, ladderNumber, sensorNumber, bool(side), 1, chargeSimCal)
182
183 Belle2.Database.Instance().storeData(Belle2.SVDChargeSimulationCalibrations.name, payload, iov)
184
185
186b2conditions.prepend_globaltag("svd_onlySVDinGeoConfiguration")
187
188main = b2.create_path()
189
190# Event info setter - execute single event
191eventinfosetter = b2.register_module('EventInfoSetter')
192eventinfosetter.param({'evtNumList': [1], 'expList': 0, 'runList': 0})
193main.add_module(eventinfosetter)
194
195main.add_module("Gearbox")
196main.add_module("Geometry")
197
198main.add_module(defaultChargeSimulationImporter())
199
200# Show progress of processing
201progress = b2.register_module('Progress')
202main.add_module(progress)
203
204# Process events
205b2.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