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