Belle II Software  release-08-01-10
SVDDefaultNoiseImporter.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 SVD Default Noise Calibration importer (MC).
14 Script to Import Calibrations into a local DB
15 """
16 import basf2 as b2
17 from ROOT import Belle2
18 import datetime
19 from basf2 import conditions as b2conditions
20 
21 now = datetime.datetime.now()
22 
23 '''
24 # Phase 3 - scaled with 375
25 noise_L3_U = 2.48
26 noise_L3_V = 1.81
27 noise_bkw_U = 2.08
28 noise_bkw_V = 1.81
29 noise_origami_U = 2.40
30 noise_origami_V = 1.33
31 noise_fwd_U = 2.00
32 noise_fwd_V = 1.81
33 '''
34 # Phase 3 - scaled with rescaled gain
35 noise_L3_U = 3.29
36 noise_L3_V = 2.46
37 noise_bkw_U = 3.12
38 noise_bkw_V = 2.75
39 noise_origami_U = 3.32
40 noise_origami_V = 2.28
41 noise_fwd_U = 3.03
42 noise_fwd_V = 2.76
43 '''
44 # TestBeam
45 noise_L3_U = 2.51
46 noise_L3_V = 1.73
47 noise_bkw_U = -1
48 noise_bkw_V = -1
49 noise_origami_U = 2.88
50 noise_origami_V = 1.73
51 noise_fwd_U = -1
52 noise_fwd_V = -1
53 '''
54 
55 
56 class defaultNoiseImporter(b2.Module):
57  ''' default strip noise importer'''
58 
59  def beginRun(self):
60  '''begin run'''
61 
63 
64  payload = Belle2.SVDNoiseCalibrations.t_payload(-1, "NoiseCalibrations_default_" +
65  str(now.isoformat()) + "_INFO:_fromPhase3calibrations")
66 
68 
69  for layer in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
70  layerNumber = layer.getLayerNumber()
71  for ladder in geoCache.getLadders(layer):
72  ladderNumber = ladder.getLadderNumber()
73  for sensor in geoCache.getSensors(ladder):
74  sensorNumber = sensor.getSensorNumber()
75  for side in (0, 1):
76  Nstrips = 768
77  print("setting Noise for " +
78  str(layerNumber) + "." + str(ladderNumber) + "." + str(sensorNumber) + "." + str(side))
79  if side == 0: # V
80  if layerNumber == 3: # L3 V
81  noise = noise_L3_V
82  else:
83  Nstrips = 512
84  if sensorNumber == 1: # FW V
85  noise = noise_fwd_V
86  else: # BKW V
87  if sensorNumber == layerNumber - 1: # FW V
88  noise = noise_bkw_V
89  else: # BARREL V
90  noise = noise_origami_V
91  if side == 1: # U
92  if layerNumber == 3: # L3 U
93  noise = noise_L3_U
94  else:
95  if sensorNumber == 1: # FW U
96  noise = noise_fwd_U
97  else: # BKW U
98  if sensorNumber == layerNumber - 1: # FW U
99  noise = noise_bkw_U
100  else: # BARREL U
101  noise = noise_origami_U
102 
103  print(str(Nstrips))
104  for strip in range(0, Nstrips):
105  payload.set(layerNumber, ladderNumber, sensorNumber, bool(side), strip, noise)
106 
107  Belle2.Database.Instance().storeData(Belle2.SVDNoiseCalibrations.name, payload, iov)
108 
109 
110 b2conditions.prepend_globaltag("svd_onlySVDinGeoConfiguration")
111 
112 main = b2.create_path()
113 
114 # Event info setter - execute single event
115 eventinfosetter = b2.register_module('EventInfoSetter')
116 eventinfosetter.param({'evtNumList': [1], 'expList': 0, 'runList': 0})
117 main.add_module(eventinfosetter)
118 
119 main.add_module("Gearbox")
120 main.add_module("Geometry")
121 
122 main.add_module(defaultNoiseImporter())
123 
124 # Show progress of processing
125 progress = b2.register_module('Progress')
126 main.add_module(progress)
127 
128 # Process events
129 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