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