Belle II Software  release-08-01-10
SVDDefaultOccupancyImporter.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 SVD Default Occupancy 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 
20 now = datetime.datetime.now()
21 
22 # Phase 3 - exp 10
23 occupancy_L3 = 0.003
24 occupancy_allOtherLayers = 0.002
25 
26 
27 class defaultOccupancyImporter(b2.Module):
28  ''' default importer of strip occupancy'''
29 
30  def beginRun(self):
31  '''begin run'''
32 
34 
35  payload = Belle2.SVDOccupancyCalibrations.t_payload(-1, "OccupancyCalibrations_default_" +
36  str(now.isoformat()) + "_INFO:_testJamesBranch")
37 
39 
40  for layer in geoCache.getLayers(Belle2.VXD.SensorInfoBase.SVD):
41  layerNumber = layer.getLayerNumber()
42  for ladder in geoCache.getLadders(layer):
43  ladderNumber = ladder.getLadderNumber()
44  for sensor in geoCache.getSensors(ladder):
45  sensorNumber = sensor.getSensorNumber()
46  for side in (0, 1):
47  Nstrips = 768
48  print("setting Occupancy for " +
49  str(layerNumber) + "." + str(ladderNumber) + "." + str(sensorNumber) + "." + str(side))
50  if side == 0:
51  if layerNumber == 3: # L3
52  occupancy = occupancy_L3
53  else:
54  Nstrips = 512
55  occupancy = occupancy_allOtherLayers
56  elif side == 1: # U
57  if layerNumber == 3: # L3 U
58  occupancy = occupancy_L3
59  else:
60  occupancy = occupancy_allOtherLayers
61  else:
62  print("WARNING: sensors end!...")
63 
64  print(str(Nstrips))
65 
66  for strip in range(0, Nstrips):
67  payload.set(layerNumber, ladderNumber, sensorNumber, bool(side), strip, occupancy)
68 
69  Belle2.Database.Instance().storeData(Belle2.SVDOccupancyCalibrations.name, payload, iov)
70 
71 
72 main = b2.create_path()
73 
74 # Event info setter - execute single event
75 eventinfosetter = b2.register_module('EventInfoSetter')
76 eventinfosetter.param({'evtNumList': [1], 'expList': 0, 'runList': 0})
77 main.add_module(eventinfosetter)
78 
79 main.add_module("Gearbox")
80 main.add_module("Geometry")
81 
82 main.add_module(defaultOccupancyImporter())
83 
84 # Show progress of processing
85 progress = b2.register_module('Progress')
86 main.add_module(progress)
87 
88 # Process events
89 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