Belle II Software development
run_eclCosmicE_algorithm.py
1#!/usr/bin/env python3
2
3
10
11import sys
12import glob
13from ROOT import Belle2
14
15# Run algorithm part of the eclCosmicE calibration, which calibrates the single crystal
16# energy response using cosmic rays. Input files have been produced by eclCosmicECollector,
17# using run_eclCosmicE_collector.py
18
19# Usage: basf2 run_eclCosmicE_algorithm.py
20# or: bsub -q s -o logfile.txt 'basf2 run_eclCosmicE_algorithm.py "inputfiles*.root"'
21
22# algo.performFits = False: just copy the input histograms into the output file for debugging.
23# algo.findExpValues: True: fits are used to find the expected energy deposits
24# False: fits are used to find the crystal energy calibration constants
25
26# algo.storeConst = 0 fills database payloads ECLExpCosmicESame and ECLExpCosmicEDifferent (findExpValues=True)
27# or payload ECLCrystalEnergyCosmic (if findExpValues=False)
28# for all crystals with successful fits and writes to localdb
29# algo.storeConst = 1 fills writes the payloads only if every crystal in specified range is successful
30# algo.storeConst = -1 do not write to the database
31
32# directory to store produced constants. If not specified, use localdb subdirectory of current working directory.
33# use_local_database("/home/belle2/czhearty/CosmicCalib/workdir/localdb/database.txt",directory="/home/belle2/czhearty/CosmicCalib/workdir/localdb")
34
36
37fileNames = ['eclCosmicECollectorOutput.root']
38narg = len(sys.argv)
39if(narg == 2):
40 fileNames = glob.glob(sys.argv[1])
41print("input fileNames = ", fileNames)
42algo.setInputFileNames(fileNames)
43
44# barrel is [1153,7776]
45algo.cellIDLo = 1
46algo.cellIDHi = 8736
47algo.minEntries = 150
48algo.tRatioMin = 0.2
49algo.tRatioMax = 0.25
50algo.maxIterations = 10
51algo.performFits = True
52algo.findExpValues = False
53algo.storeConst = 0
54
55# Run algorithm after merging all input files, as opposed to one run at a time
56alg_result = algo.execute()
57print("result of eclCosmicEAlgorithm was", alg_result)
58
59# Commits a successful list of dbobjects to localdb/
60algo.commit()