Belle II Software  release-06-00-14
eclTrackBremFinderTest.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 Test for checking if a generated bremsstrahlung cluster is assigned correctly
14 to the primary ECL cluster generated by an electron.
15 The test is quite delicate: with the current settings the check fails 10% of the times.
16 """
17 
18 import basf2 as b2
19 from ROOT import Belle2
20 from ROOT import TVector3
21 
22 import simulation
23 import reconstruction
24 
25 b2.set_random_seed(42)
26 
27 
29  """
30  Module which checks if a generated bremsstrahlung cluster is assigned correctly
31  to the primary ECL cluster generated by an electron.
32  """
33 
34  def event(self):
35  """
36  Load the one track from the data store and check if the relation to the brem cluster
37  can been set correctly.
38  """
39  clusters = Belle2.PyStoreArray("ECLClusters")
40  bremCluster = None
41  for cluster in clusters:
42  # this is the primary of the electron
43  if cluster.isTrack() and cluster.hasHypothesis(Belle2.ECLCluster.EHypothesisBit.c_nPhotons):
44  # is there a relation to our secondary cluster?
45  bremCluster = cluster.getRelated("ECLClusters")
46  # there must be a bremCluster at this point
47  assert(bremCluster)
48 
49 
50 class SearchForHits(b2.Module):
51  """
52  Module used to define the position and direction of the 'virtual' bremsstrahlung photon
53  generated by the particle gun
54  Not used at the moment (only for fit location)
55  """
56 
57  def event(self):
58  """Process event"""
59 
60  reco_tracks = Belle2.PyStoreArray("RecoTracks")
61 
62  for recoTrack in reco_tracks:
63  # hit = recoTrack.getMeasuredStateOnPlaneFromFirstHit()
64  print("!!!!!!!!!!!!!!!!!!!!!!!!!Position!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
65  hit = recoTrack.getMeasuredStateOnPlaneClosestTo(TVector3(10, 5, -2))
66  hit_pos = hit.getPos()
67  print(hit_pos.X())
68  print(hit_pos.Y())
69  print(hit_pos.Z())
70  print(hit.getMom().Phi())
71  print(hit.getMom().Theta())
72 
73 
74 # to run the framework the used modules need to be registered
75 main = b2.create_path()
76 
77 # generates 5 events (but then, the check is skipped for the 1st one)
78 main.add_module('EventInfoSetter', evtNumList=[4])
79 
80 # generates electron with given direction
81 main.add_module('ParticleGun',
82  pdgCodes=[11],
83  nTracks=1,
84  momentumGeneration='fixed',
85  momentumParams=0.5,
86  thetaGeneration='fixed',
87  thetaParams=95,
88  phiGeneration='fixed',
89  phiParams=30)
90 
91 
92 # generates a photon which characteristics are chosen that it would be a bremsstrahlung photon radiated by the electron
93 main.add_module('ParticleGun',
94  pdgCodes=[22],
95  nTracks=1,
96  momentumGeneration='fixed',
97  momentumParams=0.1,
98  thetaGeneration='fixed',
99  thetaParams=1.6614126908216453 * 180 / 3.1415,
100  phiGeneration='fixed',
101  phiParams=0.6210485691762964 * 180 / 3.1415,
102  xVertexParams=[9.27695426703659],
103  yVertexParams=[5.949838410158973],
104  zVertexParams=[-0.9875516764256207],
105  )
106 
108 
110 
111 main.add_module(CheckRelationBremClusterTestModule())
112 
113 # Process events
114 b2.process(main)
a (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:56
def add_reconstruction(path, components=None, pruneTracks=True, add_trigger_calculation=True, skipGeometryAdding=False, trackFitHypotheses=None, addClusterExpertModules=True, use_second_cdc_hits=False, add_muid_hits=False, reconstruct_cdst=None, event_abort=default_event_abort, use_random_numbers_for_hlt_prescale=True)
def add_simulation(path, components=None, bkgfiles=None, bkgOverlay=True, forceSetPXDDataReduction=False, usePXDDataReduction=True, cleanupPXDDataReduction=True, generate_2nd_cdc_hits=False, simulateT0jitter=True, isCosmics=False, FilterEvents=False, usePXDGatedMode=False, skipExperimentCheckForBG=False)
Definition: simulation.py:135