Belle II Software development
SVDTimeGroupingConfigurationImporter.py
1#!/usr/bin/env python3
2
3
10
11
12import basf2 as b2
13from ROOT import Belle2
14import datetime
15import json
16import argparse
17
18now = datetime.datetime.now()
19
20
21def arg_parser():
22 """ argument parser """
23
24 parser = argparse.ArgumentParser(description=__doc__)
25 parser.add_argument('-j', '--json',
26 type=str,
27 help='input json file',
28 metavar='JSON')
29 return parser
30
31
32def import_parameters_to_payload(payload, alg, numberOfAcquiredSamples):
33 """ import parameters to payload """
34
35 jsonVar = param["parsFor" + str(alg) + "In" + str(numberOfAcquiredSamples) + "Samples"]
36
37 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples)._COMMENT = jsonVar["_COMMENT"]
38 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).tRange[0] = jsonVar["tRange"][0]
39 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).tRange[1] = jsonVar["tRange"][1]
40 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).rebinningFactor = jsonVar["rebinningFactor"]
41 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).fillSigmaN = jsonVar["fillSigmaN"]
42 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).limitSigma[0] = jsonVar["limitSigma"][0]
43 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).limitSigma[1] = jsonVar["limitSigma"][1]
44 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).fitRangeHalfWidth = jsonVar["fitRangeHalfWidth"]
45 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).removeSigmaN = jsonVar["removeSigmaN"]
46 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).fracThreshold = jsonVar["fracThreshold"]
47 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).maxGroups = jsonVar["maxGroups"]
48 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).expectedSignalTime[0] = jsonVar["expectedSignalTime"][0]
49 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).expectedSignalTime[1] = jsonVar["expectedSignalTime"][1]
50 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).expectedSignalTime[2] = jsonVar["expectedSignalTime"][2]
51 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).signalLifetime = jsonVar["signalLifetime"]
52 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).numberOfSignalGroups = jsonVar["numberOfSignalGroups"]
53 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).formSingleSignalGroup = jsonVar["formSingleSignalGroup"]
54 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).acceptSigmaN = jsonVar["acceptSigmaN"]
55 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).writeGroupInfo = jsonVar["writeGroupInfo"]
56 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).includeOutOfRangeClusters = jsonVar["includeOutOfRangeClusters"]
57 sigmas = jsonVar["clsSigma"]
58 for stype in range(len(sigmas)):
59 for side in [0, 1]: # 0:V, 1:U
60 payload.setTimeGroupingParameters(alg, numberOfAcquiredSamples).clsSigma[stype][side].assign(sigmas[stype][side])
61
62
64 ''' importer of the SVDTimeGrouping Configuration'''
65
66 def beginRun(self):
67 '''begin run'''
68
69 print("")
70 print("--> json INFO:")
71 print(" "+str(param["_COMMENT"]))
72 print("")
73
75
76 uniqueID = "SVDTimeGroupingConfiguration_" + str(now.isoformat())
77 uniqueID += "_in" + param["uniqueID"]["INFO"]["source"]
78 uniqueID += "_usedFor" + param["uniqueID"]["INFO"]["usedFor"]
79 uniqueID += "_" + param["uniqueID"]["INFO"]["tag"]
80 print("uniqueID ->", uniqueID)
81 print("")
82
83 payload = Belle2.SVDTimeGroupingConfiguration(uniqueID, param["_DESCRIPTION"])
84
85 for alg in ["CoG3", "ELS3", "CoG6"]:
86 for numberOfAcquiredSamples in [3, 6]:
87 import_parameters_to_payload(payload, alg, numberOfAcquiredSamples)
88
89 # write out the payload to localdb directory
90 Belle2.Database.Instance().storeData(Belle2.SVDTimeGroupingConfiguration.name, payload, iov)
91
92
93main = b2.create_path()
94
95# Argument parsing
96args = arg_parser().parse_args()
97
98# open json file
99f = open(args.json)
100param = json.load(f)
101
102
103# Event info setter - execute single event
104eventinfosetter = b2.register_module('EventInfoSetter')
105eventinfosetter.param({'evtNumList': [1], 'expList': 0, 'runList': 0})
106main.add_module(eventinfosetter)
107
108main.add_module(timeGroupingConfigurationImporter())
109
110main.add_module('Progress')
111
112b2.print_path(main)
113b2.process(main)
114print(b2.statistics)
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
This class store the reconstruction configuration of SVDTimeGrouping module.
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42