Belle II Software  release-08-01-10
caf_cdc_alignment.py
1 
8 import basf2 as b2
9 
10 import os
11 import sys
12 
13 
14 from caf.framework import CAF
15 from caf import backends
16 
17 from reconstruction import add_cosmics_reconstruction
18 
19 from alignment import setups
20 
21 b2.set_log_level(b2.LogLevel.INFO)
22 
23 
24 def main(argv):
25  print('Demonstrator of Millepede alignment of CDC layers with CAF')
26 
27  inputFiles = []
28  for file in argv[0:]:
29  inputFiles.append(os.path.abspath(file))
30 
31  if not len(inputFiles):
32  print('Usage: basf2 caf_cdc_alignment DST_FILE.root [DST_FILE2.root ... ]')
33  sys.exit(1)
34 
35  print('Input DST files:')
36  print(inputFiles)
37 
38  reco_path = b2.create_path()
39  reco_path.add_module('Progress')
40  reco_path.add_module('Gearbox')
41  reco_path.add_module('Geometry', excludedComponents=['SVD', 'PXD', 'ARICH', 'BeamPipe', 'EKLM'])
42  # Add CDC CR reconstruction.
43  add_cosmics_reconstruction(reco_path, components=['CDC'], merge_tracks=True, pruneTracks=False)
44 
45  setups.dirty_data = True
46  millepede = setups.setup_CDCLayers_GCR_Karim()
47  millepede.path = reco_path
48  calib_init = millepede.create('cdc_layers_init', inputFiles)
49  calib_init.max_iterations = 0
50  calib_init.max_files_per_collector_job = 1
51 
52  setups.dirty_data = False
53  millepede = setups.setup_CDCLayers_GCR_Karim()
54  millepede.path = reco_path
55  millepede.set_param(1.e-3, 'minPValue')
56  calib_std = millepede.create('cdc_layers_std', inputFiles)
57  calib_std.max_files_per_collector_job = 1
58 
59  calib_std.depends_on(calib_init)
60 
61  caf = CAF()
62 
63  caf.add_calibration(calib_init)
64  caf.add_calibration(calib_std)
65 
66  caf.backend = backends.Local(2)
67 
68  caf.output_dir = 'caf_output'
69  caf.run()
70 
71  print("Finished CAF Processing")
72 
73 
74 if __name__ == "__main__":
75  # Pass all arguments after script name as input files
76  main(sys.argv[1:])
Definition: main.py:1
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91