Belle II Software  release-08-01-10
run_eclMuMuE.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # Usage: basf2 run_eclMuMuE.py
13 # Energy calibration of (part of) the ecl using muon pairs.
14 # Runs within the CAF framework.
15 # Calls both collector and algorithm stages of the calibration;
16 # run_eclMuMuE_collector.py and run_eclMuMuE_algorithm.py run the two stages as separate jobs for
17 # debugging purposes.
18 # Input file should be e+e- --> mu+mu- including ecl digits and track extrapolation.
19 # Production version (but not this version) should call required reconstruction modules.
20 # Primary output is a histogram of calibration constant vs cellID0;
21 # output file RootOutput.root contains many additional diagnostic histograms.
22 
23 import basf2 as b2
24 
25 from ROOT.Belle2 import eclMuMuEAlgorithm
26 from caf.framework import Calibration, CAF
27 
28 # Specify the input
29 import glob
30 inputFileNames = glob.glob('/nfs/dust/belle2/user/ferber/data/kkmc_mumu/kkmc-mumu-1485213008/*.root')
31 print(inputFileNames)
32 b2.set_log_level(b2.LogLevel.INFO)
33 
34 # The collector module
35 eclMuMuE = b2.register_module('eclMuMuECollector')
36 eclMuMuE.param('minPairMass', 9.0)
37 eclMuMuE.param('minTrackLength', 30.)
38 eclMuMuE.param('MaxNeighborAmp', 200.)
39 # 3 axial SL = [24,134]; 4 axial SL = [30,126]
40 eclMuMuE.param('thetaLabMinDeg', 24.)
41 eclMuMuE.param('thetaLabMaxDeg', 134.)
42 # Can fill histograms with MC true deposited energy if eclCalDigits have been stored
43 eclMuMuE.param('useTrueEnergy', False)
44 
45 # Set up the modules needed for geometry and track extrapolation by the collector module
46 pre_path = b2.create_path()
47 gearbox = b2.register_module('Gearbox')
48 pre_path.add_module(gearbox)
49 geometry = b2.register_module('Geometry')
50 pre_path.add_module(geometry)
51 pre_path.add_module('SetupGenfitExtrapolation')
52 ext = b2.register_module('Ext')
53 pdgcodes = [13]
54 ext.param('pdgCodes', pdgcodes)
55 pre_path.add_module(ext)
56 
57 # Specify the algorithm. barrel is cells [1152,7775]; barrel plus one endcap ring is [1008,7919]
58 algorithm = eclMuMuEAlgorithm()
59 algorithm.cellIDLo = 1008
60 algorithm.cellIDHi = 7919
61 algorithm.minEntries = 150
62 algorithm.maxIterations = 10
63 algorithm.tRatioMin = 0.2
64 algorithm.tRatioMax = 0.25
65 algorithm.performFits = True
66 
67 # Create a single calibration from a collector module name + algorithm + input files
68 cal = Calibration(name='eclMuMuECalibration', collector=eclMuMuE, algorithms=algorithm, input_files=inputFileNames)
69 cal.pre_collector_path = pre_path
70 
71 # Create a CAF instance and add the calibration to it.
72 cal_fw = CAF()
73 cal_fw.add_calibration(cal)
74 cal_fw.output_dir = 'fullBG'
75 cal_fw.run()