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