Belle II Software development
ARICHPrintParametersFromDB.py
1#!/usr/bin/env python3
2
3
10
11# this prints parameters from the database for a given tag, experiment and run number
12
13import basf2 as b2
14from ROOT import Belle2 # noqa: make Belle2 namespace available
15from ROOT.Belle2 import ARICHDatabaseImporter
16from optparse import OptionParser
17
18parser = OptionParser()
19parser.add_option('-t', '--tag', dest='tag', default='',
20 help='database tag from which to import/export data')
21parser.add_option('-e', '--exp', dest='experiment',
22 default=-1, help='experiment')
23parser.add_option('-r', '--run', dest='run',
24 default=-1, help='run')
25parser.add_option('-o', '--object', dest='object',
26 default="", help='object to be printed')
27
28
29(options, args) = parser.parse_args()
30
31if options.object == '':
32 print("use option -o to specify the object to be printed (ARICHReconstructionPar, etc)")
33
34# set database tag
35if options.tag == 'local':
36 b2.conditions.testing_payloads = ["localdb/database.txt"]
37elif options.tag == '':
38 print("Using default tag")
39else:
40 b2.conditions.override_globaltags([options.tag])
41
42# EventInfoSetter is only needed to register EventMetaData...
43# (will try to get rid of this)
44eventinfo = b2.register_module('EventInfoSetter')
45eventinfo.initialize()
46main = b2.create_path()
47
48main.add_module(eventinfo)
49
50# load gearbox for reading parameters from xml files (by default in "arich/data")
51paramloader = b2.register_module('Gearbox')
52paramloader.initialize()
53
54b2.process(main)
55
56# run the importer
57dbImporter = ARICHDatabaseImporter()
58exp = int(options.experiment)
59run = int(options.run)
60if exp > 0 and run > 0:
61 dbImporter.setExperimentAndRun(exp, run)
62
63if options.object == 'ARICHModulesInfo':
64 dbImporter.printModulesInfo()
65elif options.object == 'ARICHSimulationPar':
66 dbImporter.printSimulationPar()
67elif options.object == 'ARICHChannelMask':
68 dbImporter.printChannelMask() # use dbImporter.printChannelMask(True) to make 2d map of active channels
69elif options.object == 'ARICHChannelMapping':
70 dbImporter.printChannelMapping()
71elif options.object == 'ARICHMergerMapping':
72 dbImporter.printMergerMapping()
73elif options.object == 'ARICHCopperMapping':
74 dbImporter.printCopperMapping()
75elif options.object == 'ARICHReconstructionPar':
76 dbImporter.printReconstructionPar()
77elif options.object == 'ARICHGlobalAlignment':
78 dbImporter.printGlobalAlignment()
79elif options.object == 'ARICHMirrorAlignment':
80 dbImporter.printMirrorAlignment()
81elif options.object == 'ARICHAeroTilesAlignment':
82 dbImporter.printAeroTilesAlignment()
83elif options.object == 'ARICHGeometryConfig':
84 # print geometry parameters of ARICH detector from the database
85 dbImporter.printGeometryConfig()
86elif options.object == 'moduleNumbering':
87 # creates file with numbering of HAPD module slots (position on detector plane -> module number)
88 dbImporter.dumpModuleNumbering()
89elif options.object == 'QEMap':
90 # creates root file with full detector plane QE map (all HAPDs) as stored in the database
91 dbImporter.dumpQEMap()
92elif options.object == 'MergerMap':
93 # creates root file with numbering of HAPD modules to mergers (position on detector plane -> merger SN)
94 # use dbImporter.dumpMergerMapping(False) to print merger ID instead SN (ID = (sector-1)*12 + merger_sector_id (1-12))
95 dbImporter.dumpMergerMapping()
96elif options.object == 'FEMappings':
97 # prints FE mappings (module to merger to copper) in json suitable format
98 dbImporter.printFEMappings()
99else:
100 print('Non-valid arich DB object!')