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