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