Belle II Software development
BeamSpotCalibrationCAF.py
1#!/usr/bin/env python3
2
3
10
11
14
15import basf2
16
17import os
18import sys
19import multiprocessing
20
21from ROOT import Belle2
22from ROOT.Belle2 import BeamSpotAlgorithm
23
24from caf.framework import CAF, Calibration, CentralDatabase
25from caf import backends
26from caf import strategies
27
28import modularAnalysis as ana
29
30basf2.set_log_level(basf2.LogLevel.INFO)
31
32
33def BeamSpotCalibration(files, tags):
34 """
35 Function to get the BeamSpot calibration object.
36 Takes list of files and list of GTs as arguments.
37 """
38
39 path = basf2.create_path()
40 path.add_module('Progress')
41 path.add_module('RootInput')
42
43 # Select mumu decays with enough hits
44 muSelection = '[p>1.0]'
45 muSelection += ' and abs(dz)<2.0 and abs(dr)<0.5'
46 muSelection += ' and nPXDHits >=1 and nSVDHits >= 8 and nCDCHits >= 20'
47 ana.fillParticleList('mu+:BS', muSelection, path=path)
48 ana.reconstructDecay('Upsilon(4S):BS -> mu+:BS mu-:BS', '9.5<M<11.5', path=path)
49
50 # Init the BeamSpot collector and algo
51 collector = basf2.register_module('BeamSpotCollector', Y4SPListName='Upsilon(4S):BS')
52 algorithm = BeamSpotAlgorithm()
53
54 calibration = Calibration('BeamSpot',
55 collector=collector,
56 algorithms=algorithm,
57 input_files=files,
58 pre_collector_path=path,
59 database_chain=[CentralDatabase(tag) for tag in tags],
60 output_patterns=None,
61 max_files_per_collector_job=1,
62 backend_args=None
63 )
64
65 # The segmentation is done in the algorithm
66 calibration.strategies = strategies.SingleIOV
67
68 return calibration
69
70
71if __name__ == "__main__":
72 input_files = [os.path.abspath(file) for file in Belle2.Environment.Instance().getInputFilesOverride()]
73
74 if not len(input_files):
75 print("You have to specify some input file(s) (raw data or di - muon skim with raw objects)\n"
76 "using the standard basf2 command line option - i")
77 print("See: basf2 -h")
78 sys.exit(1)
79
80 beamspot = BeamSpotCalibration(input_files, ['data_reprocessing_prompt', 'online_bucket9'])
81
82 cal_fw = CAF()
83 cal_fw.add_calibration(beamspot)
84 cal_fw.backend = backends.LSF()
85
86 # Try to guess if we are at KEKCC and change the backend to Local if not
87 if multiprocessing.cpu_count() < 10:
88 cal_fw.backend = backends.Local(8)
89
90 cal_fw.run()
static Environment & Instance()
Static method to get a reference to the Environment instance.
Definition: Environment.cc:28