CMS 3D CMS Logo

GCP_TkAlMap.py
Go to the documentation of this file.
1 import sys
2 import copy
3 import time
4 import argparse
5 from Alignment.OfflineValidation.TkAlMap import TkAlMap
6 
7 def parser():
8  parser = argparse.ArgumentParser(description = "Parse AllInOne config to TkAlMap. Only ment for condor jobs.", formatter_class=argparse.RawTextHelpFormatter)
9  parser.add_argument("config", metavar='config', type=str, action="store", help="Global AllInOneTool config (json/yaml format)")
10  return parser.parse_args()
11 
12 def main():
13  print('*---------------------------------------*')
14  print('| GCP TkAlMap |')
15  print('*---------------------------------------*')
16 
17  # Get arguments
18  args = parser()
19 
20  # Get configuration
21  with open(args.config, 'r') as configFile:
22  if args.config.split('.')[-1] == 'json':
23  config = json.load(configFile)
24 
25  elif args.config.split('.')[-1] == 'yaml':
26  config = yaml.load(configFile, Loader=yaml.Loader)
27 
28  else:
29  raise Exception('Unknown config extension "{}". Please use json/yaml format!'.format(args.config.split('.')[-1]))
30 
31  # Init variables
32  var_list = ['dr', 'dx', 'dy', 'dz', 'rdphi', 'dphi', 'dalpha', 'dbeta', 'dgamma', 'du', 'dv', 'dw', 'da', 'db', 'dg']
33  var_ranges = {}
34  for var in var_list:
35  var_ranges[var] = [None, None]
36 
37  # Digest
38  al_ref = config['alignments']['ref']['title']
39  al_comp = config['alignments']['comp']['title']
40  in_file = config['input']
41  out_dir = config['output']
42  phase = 1
43  auto_tk = True
44  if 'detector_phase' in config['validation']['GCP']:
45  phase = int(config['validation']['GCP']['detector_phase'])
46  auto_tk = False
47  palette = 2
48  if 'map_palette' in config['validation']['GCP']: palette = int(config['validation']['GCP']['map_palette'])
49  save_png = False
50  if 'save_png' in config['validation']['GCP']: save_png = config['validation']['GCP']['save_png']
51  save_pdf = True
52  if 'save_pdf' in config['validation']['GCP']: save_pdf = config['validation']['GCP']['save_pdf']
53 
54  print('Current setup:')
55  print(' - reference alingment : '+al_ref)
56  print(' - compared alingment : '+al_comp)
57  print(' - tracker version : phase '+str(phase))
58  print(' - auto detect tracker version : '+str(auto_tk))
59  print(' - color palette : '+str(palette))
60  print(' - input root file : '+in_file)
61  print(' - output directory : '+out_dir)
62  print(' - saving as png : '+str(save_png))
63  print(' - saving as pdf : '+str(save_pdf))
64  print('')
65  print('Active plots:')
66  print(' - plot 4 sigma capped values : '+str(do_4scap))
67  print(' - plot default range capped values : '+str(do_drange))
68  print(' - plot un-capped values : '+str(do_frange))
69  print(' - plot full detector : '+str(do_full))
70  print(' - plot pixel detector : '+str(do_pixel))
71  print(' - plot strips detector : '+str(do_strips))
72  print('')
73  print('Changed default ranges:')
74  for var in var_ranges:
75  if var_ranges[var][0] is None and var_ranges[var][1] is None: continue
76  prt_srt = ' - '+var+'\t: [ '
77  if var_ranges[var][0] is None: prt_srt += 'default'
78  else: prt_srt += str(var_ranges[var][0])
79  prt_srt += '\t, '
80  if var_ranges[var][1] is None: prt_srt += 'default'
81  else: prt_srt += str(var_ranges[var][1])
82  prt_srt += '\t]'
83  print(prt_srt)
84 
85  print('Loading maps')
86  TkMap_full = TkAlMap('test', title, in_file, use_default_range=False, two_sigma_cap=False, GEO_file=geometry_file, tracker='full', palette=palette, check_tracker=auto_tk)
87  TkMap_pixel = TkAlMap('test', title, in_file, use_default_range=False, two_sigma_cap=False, GEO_file=geometry_file, tracker='pixel', palette=palette, check_tracker=auto_tk)
88  TkMap_strips = TkAlMap('test', title, in_file, use_default_range=False, two_sigma_cap=False, GEO_file=geometry_file, tracker='strips', palette=palette, check_tracker=auto_tk)
89  TkMap_cap_full = TkAlMap('test', title, in_file, use_default_range=False, two_sigma_cap=True, GEO_file=geometry_file, tracker='full', palette=palette, check_tracker=auto_tk)
90  TkMap_cap_pixel = TkAlMap('test', title, in_file, use_default_range=False, two_sigma_cap=True, GEO_file=geometry_file, tracker='pixel', palette=palette, check_tracker=auto_tk)
91  TkMap_cap_strips = TkAlMap('test', title, in_file, use_default_range=False, two_sigma_cap=True, GEO_file=geometry_file, tracker='strips', palette=palette, check_tracker=auto_tk)
92  TkMap_drange_full = TkAlMap('test', title, in_file, use_default_range=True, two_sigma_cap=False, GEO_file=geometry_file, tracker='full', palette=palette, check_tracker=auto_tk)
93  TkMap_drange_pixel = TkAlMap('test', title, in_file, use_default_range=True, two_sigma_cap=False, GEO_file=geometry_file, tracker='pixel', palette=palette, check_tracker=auto_tk)
94  TkMap_drange_strips = TkAlMap('test', title, in_file, use_default_range=True, two_sigma_cap=False, GEO_file=geometry_file, tracker='strips', palette=palette, check_tracker=auto_tk)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def parser()
Definition: GCP_TkAlMap.py:7
def main()
Definition: GCP_TkAlMap.py:12
#define str(s)