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