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