Belle II Software  release-08-01-10
cluster_position_collector.py
1 #!/usr/bin/env python3
2 
3 
10 
11 # This steering file steers the collectors for the training of the PXD cluster
12 # position estimator running the CAF.
13 #
14 # Execute as: basf2 cluster_position_collector.py -n 10000000 -- --clusterkind=0
15 #
16 # The collector will create source files for training of clusterkind 0 by simulating
17 # 10 million clusters.
18 #
19 # Full set of training sources for PXD requires starting the script 4x wiht clusterkinds
20 # 0-3.
21 
22 import basf2 as b2
23 
24 if __name__ == "__main__":
25 
26  import argparse
27  parser = argparse.ArgumentParser(description="Generate training data for computing cluster shape corrections")
28  parser.add_argument('--clusterkind', dest='clusterkind', default=0, type=int,
29  help='ClusterKinds 0, 1, 2, 3 are for z55, z60, z70, z85 pixels')
30  parser.add_argument('--momentum', dest='momentum', default=1.0, type=float, help='Momentum of particle gun')
31  parser.add_argument('--pdgCode', dest='pdgCode', default=-211, type=int, help='PDG code for particle gun')
32  args = parser.parse_args()
33 
34  # In order to create source for a specific kind of clusters, we position the particle gun below
35  # a specific part of the sensors.
36  #
37  # Kinds 0-3 are clusters where all pixels have a specific pixel pitch type. Higher kinds (not yet implemented)
38  # are for cases where sensor borders are touched are the cluster neighbors masked pixels.
39  #
40  # For setting of vertex close to surface of for PXD kinds of pixels set:
41  # 55 um pitch: sensor 1.3.2 , vertex: x: [-0.2050,-0.2], y: [1.35], z: [0.7,0.7055]
42  # 60 um pitch: sensor 1.3.2 , vertex: x: [-0.2050,-0.2], y: [1.35], z: [-1.5,-1.5060]
43  # 70 um pitch: sensor 2.4.2 , vertex: x: [-0.2050,-0.2], y: [2.18], z: [0.9,0.9070]
44  # 85 um pitch: sensor 2.4.2 , vertex: x: [-0.2050,-0.2], y: [2.18], z: [-2.0,-2.0085]
45 
46  vertex_x = [-0.2050, -0.2]
47  vertex_y = [1.35]
48  vertex_z = [0.7, 0.7055]
49 
50  if args.clusterkind == 0:
51  pass
52  elif args.clusterkind == 1:
53  vertex_z = [-1.5060, -1.5]
54  elif args.clusterkind == 2:
55  vertex_y = [2.18]
56  vertex_z = [0.9, 0.9070]
57  elif args.clusterkind == 3:
58  vertex_y = [2.18]
59  vertex_z = [-2.0085, -2.0]
60 
61  # Now let's create a path to simulate our events.
62  main = b2.create_path()
63 
64  # Now let's add modules to simulate our events.
65  eventinfosetter = main.add_module("EventInfoSetter")
66  histoman = main.add_module(
67  'HistoManager',
68  histoFileName=f'PXDClusterPositionCollectorOutput_kind_{args.clusterkind:d}.root')
69  gearbox = main.add_module("Gearbox")
70  geometry = main.add_module("Geometry")
71  geometry.param({"components": ['MagneticField', 'PXD']})
72  particlegun = main.add_module("ParticleGun")
73  particlegun.param({"nTracks": 1,
74  "pdgCodes": [args.pdgCode],
75  "momentumGeneration": 'discrete',
76  "momentumParams": [args.momentum] + [1] * len([args.momentum]),
77  "thetaGeneration": 'uniformCos',
78  "thetaParams": [0, 90],
79  "phiGeneration": 'uniform',
80  "phiParams": [0, 180],
81  "xVertexGeneration": 'uniform',
82  "xVertexParams": vertex_x,
83  "yVertexGeneration": 'fixed',
84  "yVertexParams": vertex_y,
85  "zVertexGeneration": 'uniform',
86  "zVertexParams": vertex_z,
87  "independentVertices": False,
88  })
89  main.add_module("FullSim")
90  pxddigi = main.add_module("PXDDigitizer")
91  pxdclu = main.add_module("PXDClusterizer")
92  main.add_module('PXDClusterPositionCollector', granularity="all", clusterKind=args.clusterkind)
93  main.add_module("Progress")
94 
95  b2.process(main)
96  print(b2.statistics)