Belle II Software  release-05-01-25
run_eclCosmicE_collector.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 # -----------------------------------------------------------
5 # BASF2 (Belle Analysis Framework 2)
6 # Copyright(C) 2018 Belle II Collaboration
7 #
8 # Author: The Belle II Collaboration
9 # Contributors: Christopher Hearty
10 #
11 # This software is provided "as is" without any warranty.
12 # -----------------------------------------------------------
13 
14 # Usage: basf2 -i inputFile.root run_eclCosmicE_collector.py [outputFile.root globaltag]
15 
16 # Run just the collector part of the eclCosmicE calibration, which calibrates the single crystal
17 # energy response using cosmic rays.
18 # Input file should be cosmic data in root format, including ecl digits
19 
20 # Output histograms are written to specified output file.
21 # run_eclCosmicE_algorithm.py is then used to perform calibration using these histograms, or to simply copy
22 # them to an output file.
23 
24 import os
25 import sys
26 import glob
27 import basf2 as b2
28 from ROOT import Belle2
29 from rawdata import add_unpackers
30 
31 
32 # input file
33 main = b2.create_path()
34 inputfile = '/ghi/fs01/belle2/bdata/Data/Raw/e0007/r01112/sub00/*.root'
35 main.add_module('RootInput', inputFileNames=[inputfile])
36 
37 # output file
38 outputName = "eclCosmicECollectorOutput.root"
39 narg = len(sys.argv)
40 if(narg >= 2):
41  outputName = sys.argv[1]
42 main.add_module("HistoManager", histoFileName=outputName)
43 
44 main.add_module('Progress')
45 
46 # ECL unpackers
47 add_unpackers(main, components='ECL')
48 
49 b2.set_log_level(b2.LogLevel.INFO)
50 
51 # CAF collector code
52 eclCosmicE = b2.register_module('eclCosmicECollector', logLevel=b2.LogLevel.DEBUG, debugLevel=9)
53 eclCosmicE.param('minCrysE', 0.01)
54 eclCosmicE.param('mockupL1', False)
55 eclCosmicE.param('trigThreshold', 0.1)
56 main.add_module(eclCosmicE)
57 
58 # It is possible to force the job to use the specified global tag.
59 # Default localdb is the subdirectory of current working directory
60 centralGT = "data_reprocessing_prompt_bucket3b"
61 if(narg >= 3):
62  centralGT = sys.argv[2]
63 b2.reset_database()
64 b2.use_database_chain()
65 b2.use_central_database(centralGT)
66 b2.use_local_database("localdb/database.txt")
67 
68 b2.process(main)
69 
70 print(b2.statistics)