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