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