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