Belle II Software  release-05-01-25
collector_only.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import basf2 as b2
5 
6 import sys
7 from sys import argv
8 # logging.package("calibration").log_level = LogLevel.DEBUG
9 # logging.package("calibration").debug_level = 100
10 b2.set_log_level(b2.LogLevel.INFO)
11 
12 if len(argv) == 2:
13  data_dir = argv[1]
14 else:
15  print("Usage: basf2 collector_only.py <data directory>")
16  sys.exit(1)
17 
18 main = b2.create_path()
19 main.add_module("RootInput", inputFileNames=[data_dir + "/*.root"])
20 # HistoManager must be used right after RootInput
21 main.add_module('HistoManager', histoFileName="CollectorOutput.root", workDirName=".")
22 # Granularity can be 'run' or 'all'. If it's 'run' the collector objects are separated into different
23 # objects. If it's 'all' then a single object is used for all runs.
24 # main.add_module("CaTest", granularity="all")
25 main.add_module("CaTest", granularity="run")
26 # Notice that there is NO RootOutput module required anymore, although you could include it if you wanted
27 b2.process(main)
28 # The Collector Module memory can look weirdly high with default statistics printing. If you want to view the memory
29 # statistics of a collector use this command, Otherwise just do the normal print(statistics)
30 print(b2.statistics(b2.statistics.TOTAL))
31 print(b2.statistics)