Belle II Software  release-05-01-25
DQMCorrelations.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
25 
26 from basf2 import *
27 from ROOT import Belle2
28 
29 from svd import *
30 from pxd import *
31 
32 import argparse
33 parser = argparse.ArgumentParser(description="PXD+SVD+VXD DQM correlations for Belle II + TB, show all possible histos")
34 parser.add_argument(
35  '--magnet-off',
36  dest='magnet_off',
37  action='store_const',
38  const=True,
39  default=False,
40  help='Turn off magnetic field')
41 
42 parser.add_argument('--skip-pxd-svd', dest='SkipPXDSVD', action='store_const', const=True, default=False,
43  help='Add also PXD and SVD DQM, default = True')
44 parser.add_argument('--data-output', dest='DataOutput', action='store_const', const=True, default=False,
45  help='Save data to output file, default = False')
46 parser.add_argument('--correlation-granulation', dest='CorrelationGranulation', action='store', default=1.0, type=float,
47  help='Set granulation of histogram plots, default is 1 degree, min = 0.02 degree, max = 1 degree')
48 parser.add_argument('--cut-correlation-sig-pxd', dest='CutCorrelationSigPXD', action='store', default=0, type=int,
49  help='Cut threshold of PXD signal for accepting to correlations, default = 0 ADU')
50 parser.add_argument('--cut-correlation-sig-u-svd', dest='CutCorrelationSigUSVD', action='store', default=0, type=int,
51  help='Cut threshold of SVD signal for accepting to correlations in u, default = 0 ADU')
52 parser.add_argument('--cut-correlation-sig-v-svd', dest='CutCorrelationSigVSVD', action='store', default=0, type=int,
53  help='Cut threshold of SVD signal for accepting to correlations in v, default = 0 ADU')
54 parser.add_argument('--cut-correlation-time-svd', dest='CutCorrelationTimeSVD', action='store', default=70, type=int,
55  help='Cut threshold of SVD time window for accepting to correlations, default = 70 ns')
56 
57 parser.add_argument('--use-digits', dest='UseDigits', action='store', default=0, type=int,
58  help='flag <0,1> for using digits only, no cluster information will be required, default = 0')
59 parser.add_argument('--reduce-1d-correl-histos', dest='Reduce1DCorrelHistos', action='store', default=0, type=int,
60  help='flag <0,1> for removing of 1D correlation plots from output, default = 0')
61 parser.add_argument('--reduce-2d-correl-histos', dest='Reduce2DCorrelHistos', action='store', default=0, type=int,
62  help='flag <0,1> for removing of 2D correlation plots from output, default = 0')
63 parser.add_argument('--only-23-layers-histos', dest='Only23LayersHistos', action='store', default=0, type=int,
64  help='flag <0,1> for to keep only correlation plots between layer 2 and 3 (between PXD and SVD), default = 0')
65 parser.add_argument('--save-other-histos', dest='SaveOtherHistos', action='store', default=1, type=int,
66  help='flag <0,1> for creation of correlation plots for non-neighboar layers, default = 0')
67 parser.add_argument('--unpacking', dest='unpacking', action='store_const', const=True,
68  default=False, help='Add PXD and SVD unpacking modules to the path')
69 parser.add_argument('--input-file', dest='input_file', action='store', default=None, type=str,
70  help='Name of input file')
71 parser.add_argument('--filename-histos', dest='histo_file_name', action='store',
72  default='VXD_DQM_Histograms.root', type=str,
73  help='Name of output file with histograms in dqm option is used')
74 parser.add_argument('--SkipDQM', dest='SkipDQM', action='store_const', const=True, default=False, help='Produce DQM plots')
75 parser.add_argument('--SkipDQMExpressReco', dest='SkipDQMExpressReco', action='store_const', const=True, default=False,
76  help='Skip production of ExpressReco DQM plots')
77 
78 
79 args = parser.parse_args()
80 
81 print("Final setting of arguments: ")
82 print(" SkipPXDSVD: ", args.SkipPXDSVD)
83 print(" DataOutput: ", args.DataOutput)
84 print(" CorrelationGranulation: ", args.CorrelationGranulation)
85 print(" CutCorrelationSigPXD: ", args.CutCorrelationSigPXD)
86 print(" CutCorrelationSigUSVD: ", args.CutCorrelationSigUSVD)
87 print(" CutCorrelationSigVSVD: ", args.CutCorrelationSigVSVD)
88 print(" CutCorrelationTimeSVD: ", args.CutCorrelationTimeSVD)
89 print(" UseDigits: ", args.UseDigits)
90 print(" Reduce1DCorrelHistos: ", args.Reduce1DCorrelHistos)
91 print(" Reduce2DCorrelHistos: ", args.Reduce2DCorrelHistos)
92 print(" Only23LayersHistos: ", args.Only23LayersHistos)
93 print(" SaveOtherHistos: ", args.SaveOtherHistos)
94 print(" unpacking: ", args.unpacking)
95 print(" input_file: ", args.input_file)
96 print(" histo_file_name: ", args.histo_file_name)
97 print(" SkipDQM: ", args.SkipDQM)
98 print(" SkipDQMExpressReco: ", args.SkipDQMExpressReco)
99 
100 
101 param_vxddqm = {'CutCorrelationSigPXD': args.CutCorrelationSigPXD,
102  'CutCorrelationSigUSVD': args.CutCorrelationSigUSVD,
103  'CutCorrelationSigVSVD': args.CutCorrelationSigVSVD,
104  'CutCorrelationTimeSVD': args.CutCorrelationTimeSVD,
105  'UseDigits': args.UseDigits
106  }
107 
108 # Now let's create a path to simulate our events. We need a bit of statistics but
109 # that's not too bad since we only simulate single muons
110 main = create_path()
111 main.add_module("EventInfoSetter", evtNumList=[1000])
112 main.add_module("Gearbox")
113 # we only need the vxd for this
114 if (args.magnet_off is True):
115  main.add_module("Geometry", components=['BeamPipe', 'PXD', 'SVD'])
116 else:
117  main.add_module("Geometry", components=['MagneticFieldConstant4LimitedRSVD',
118  'BeamPipe', 'PXD', 'SVD'])
119 
120 
121 main.add_module("EvtGenInput")
122 main.add_module("FullSim")
123 add_pxd_simulation(main)
124 add_svd_simulation(main)
125 add_pxd_reconstruction(main)
126 add_svd_reconstruction(main)
127 
128 if (args.SkipDQM is False):
129  histomanager = register_module('HistoManager', histoFileName=args.histo_file_name)
130  main.add_module(histomanager)
131  if (args.SkipPXDSVD is False):
132  if (args.SkipDQMExpressReco is False):
133  pxddqmExpReco = register_module('PXDDQMExpressReco')
134  svddqmExpReco = register_module('SVDDQMExpressReco')
135  main.add_module(pxddqmExpReco)
136  main.add_module(svddqmExpReco)
137 
138  if (args.SkipDQMExpressReco is False):
139  vxddqmExpReco = register_module('VXDDQMExpressReco')
140  vxddqmExpReco.param(param_vxddqm)
141  main.add_module(vxddqmExpReco)
142 
143 if (args.DataOutput is True):
144  main.add_module('RootOutput')
145 
146 
147 main.add_module("Progress")
148 
149 process(main)
150 print(statistics)