Belle II Software development
convert_dedx_payloads.py
1
8
9import argparse
10
11import basf2
12
13
14def argument_parser():
15 '''
16 A simple argument parser.
17 '''
18 parser = argparse.ArgumentParser(description=__doc__)
19 parser.add_argument('-e', '--exp',
20 type=int,
21 required=True,
22 help='experiment number',
23 metavar='EXP')
24 parser.add_argument('-r', '--run',
25 type=int,
26 required=True,
27 help='run number',
28 metavar='RUN')
29 parser.add_argument('-g', '--globaltags',
30 type=str,
31 nargs='*',
32 required=True,
33 help='chain of globaltags to be checked',
34 metavar='GT')
35 return parser
36
37
38def set_experiment_and_run(exp_number, run_number):
39 '''
40 Set the experiment and run numbers.
41 '''
42 from ROOT import Belle2 # noqa
43 event_meta_data = Belle2.PyStoreObj('EventMetaData')
44 Belle2.DataStore.Instance().setInitializeActive(True)
45 event_meta_data.registerInDataStore()
46 event_meta_data.create(False)
47 event_meta_data.setEvent(0)
48 event_meta_data.setRun(run_number)
49 event_meta_data.setExperiment(exp_number)
50 Belle2.DataStore.Instance().setInitializeActive(False)
51
52
53def set_database(globaltags, exp_number, run_number):
54 '''
55 Set the database.
56 '''
57 from ROOT import Belle2 # noqa
59 basf2.conditions.override_globaltags()
60 for globaltag in globaltags:
61 basf2.conditions.append_globaltag(globaltag)
62 set_experiment_and_run(exp_number=int(exp_number),
63 run_number=int(run_number))
64
65
66if __name__ == "__main__":
67
68 args = argument_parser().parse_args()
69 exp_number = args.exp
70 run_number = args.run
71 globaltags = args.globaltags
72
73 # Load the objects from the database
74 from ROOT import Belle2 # noqa
75 set_database(globaltags, exp_number, run_number)
76 oldpdfs = Belle2.PyDBObj('DedxPDFs')
77 cdcpdfs = Belle2.CDCdEdxPDFs()
78 pxdpdfs = Belle2.PXDdEdxPDFs()
79 svdpdfs = Belle2.SVDdEdxPDFs()
80
81 for i in range(6): # shortcut for looping over the 6 hypotheses
82 cdcpdf = oldpdfs.getCDCPDF(i, False)
83 cdcpdfs.setPDF(cdcpdf, i, False)
84 cdcpdf_truncated = oldpdfs.getCDCPDF(i, True)
85 cdcpdfs.setPDF(cdcpdf_truncated, i, True)
86
87 pxdpdf = oldpdfs.getPXDPDF(i, False)
88 pxdpdfs.setPDF(pxdpdf, i, False)
89 pxdpdf_truncated = oldpdfs.getPXDPDF(i, True)
90 pxdpdfs.setPDF(pxdpdf_truncated, i, True)
91
92 svdpdf = oldpdfs.getSVDPDF(i, False)
93 svdpdfs.setPDF(svdpdf, i, False)
94 svdpdf_truncated = oldpdfs.getSVDPDF(i, True)
95 svdpdfs.setPDF(svdpdf_truncated, i, True)
96
98 iov = Belle2.IntervalOfValidity(exp_number, run_number, exp_number, run_number)
99 db.storeData(str(cdcpdfs.ClassName()).replace('Belle2::', ''), cdcpdfs, iov)
100 db.storeData(str(pxdpdfs.ClassName()).replace('Belle2::', ''), pxdpdfs, iov)
101 db.storeData(str(svdpdfs.ClassName()).replace('Belle2::', ''), svdpdfs, iov)
Specialized class for holding the CDC dE/dx PDFs.
Definition: CDCdEdxPDFs.h:26
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
A class that describes the interval of experiments/runs for which an object in the database is valid.
Specialized class for holding the PXD dE/dx PDFs.
Definition: PXDdEdxPDFs.h:26
Class to access a DBObjPtr from Python.
Definition: PyDBObj.h:50
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67
Specialized class for holding the SVD dE/dx PDFs.
Definition: SVDdEdxPDFs.h:26
static Database & Instance()
Instance of a singleton Database.
Definition: Database.cc:42
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:28