Belle II Software  release-08-01-10
SVDClusterTimeShifter.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
15 
16 
17 from ROOT import Belle2
18 import basf2 as b2
19 import datetime
20 import json
21 import argparse
22 import math
23 
24 now = datetime.datetime.now()
25 
26 
27 def arg_parser():
28  """ argument parser """
29 
30  parser = argparse.ArgumentParser(description=__doc__)
31  parser.add_argument('-j', '--json',
32  type=str,
33  help='input json file',
34  metavar='JSON')
35  return parser
36 
37 
38 if __name__ == "__main__":
39 
40  # Argument parsing
41  args = arg_parser().parse_args()
42 
43  # open json file
44  f = open(args.json)
45  param = json.load(f)
46 
47  print("")
48  print("--> json INFO:")
49  print(" "+str(param["_COMMENT"]))
50  print("")
51 
53 
54  uniqueID = "SVDClusterTimeShifter_" + str(now.isoformat())
55  uniqueID += "_in-" + param["uniqueID"]["INFO"]["source"]
56  uniqueID += "_useFor-" + param["uniqueID"]["INFO"]["useFor"]
57  uniqueID += "_" + param["uniqueID"]["INFO"]["config"]
58  uniqueID += "_" + param["uniqueID"]["INFO"]["tag"]
59  print("uniqueID ->", uniqueID)
60  print("")
61 
62  payload = Belle2.SVDClusterTimeShifter(uniqueID)
63 
64  for alg in param["shiftValues"]:
65  for sType in param["shiftValues"][alg]:
66  shiftVals = param["shiftValues"][alg][sType]
67  for strip in range(len(shiftVals)):
68  val = shiftVals[strip]
69  if math.fabs(val) > 10:
70  b2.B2WARNING(f"cluster time shift ({val}) is very large for ({alg} : {sType} : size {strip + 1})")
71  payload.setClusterTimeShift(alg, sType, shiftVals)
72 
73  # write out the payload to localdb directory
74  Belle2.Database.Instance().storeData(Belle2.SVDClusterTimeShifter.name, payload, iov)
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
This class store the shift in svd time w.r.t.
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42