Belle II Software  release-05-01-25
PXDPerformanceStructs.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2021 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Qingyuan Liu *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/gearbox/Unit.h>
14 #include <framework/gearbox/Const.h>
15 #include <framework/datastore/RelationsObject.h>
16 #include <pxd/dataobjects/PXDCluster.h>
17 #include <tracking/dataobjects/RecoTrack.h>
18 #include <tracking/dataobjects/PXDIntercept.h>
19 #include <genfit/MeasuredStateOnPlane.h>
20 #include <TVector3.h>
21 //#include <limits>
22 #include <vector>
23 #include <math.h>
24 
25 #include <pxd/utilities/PXDUtilities.h>
26 #include <mdst/dataobjects/Track.h>
27 #include <mdst/dataobjects/HitPatternCDC.h>
28 #include <mdst/dataobjects/HitPatternVXD.h>
29 
30 namespace Belle2 {
36  namespace PXD {
37 
39  struct Cluster_t {
40 
42  Cluster_t(): pxdID(0), charge(0), size(0),
43  uSize(0), vSize(0), posU(0.0), posV(0.0) {}
44 
48  void setValues(const PXDCluster& pxdCluster);
49 
51  unsigned short pxdID;
52  unsigned short charge;
53  unsigned short size;
54  unsigned short uSize;
55  unsigned short vSize;
56  float posU;
57  float posV;
58  }; // end struct Cluster_t
59 
61  struct TrackPoint_t {
62 
64  TrackPoint_t(): x(0.0), y(0.0), z(0.0),
65  tol(0.0), chargeMPV(0.0) {}
66 
72  RecoTrack* setValues(const PXDIntercept& pxdIntercept, const std::string recoTracksName = "");
73 
74  float x;
75  float y;
76  float z;
81  float tol;
82  float chargeMPV;
83  }; // end struct TrackPoint_t
84 
85  struct TrackCluster_t {
87  TrackCluster_t(): usedInTrack(false), dU(INFINITY), dV(INFINITY) {}
88 
95  RecoTrack* setValues(const PXDIntercept& pxdIntercept,
96  const std::string recoTracksName = "",
97  const std::string pxdTrackClustersName = "PXDClustersFromTracks");
98 
99  bool usedInTrack;
100  float dU;
101  float dV;
104  }; // end struct TrackCluster_t
105 
109  template <typename TTrackCluster>
110  struct TrackBase_t {
112  TrackBase_t(): d0(0.0), z0(0.0), phi0(0.0), pt(0.0), tanLambda(0.0),
113  d0p(0.0), z0p(0.0), nPXDHits(0), nSVDHits(0), nCDCHits(0) {}
114 
119  void setValues(const RecoTrack& recoTrack, const TVector3& ip = TVector3(0, 0, 0),
120  const std::string recoTracksName = "",
121  const std::string pxdInterceptsName = "",
122  const std::string pxdTrackClustersName = "PXDClustersFromTracks"
123  );
124 
125  float d0;
126  float z0;
127  float phi0;
128  float pt;
129  float tanLambda;
130  float d0p;
131  float z0p;
132  unsigned short nPXDHits;
133  unsigned short nSVDHits;
134  unsigned short nCDCHits;
135  std::vector<TTrackCluster> trackClusters;
136  };
137 
139 
140 
144  template <typename TTrackCluster>
146  const RecoTrack& recoTrack, const TVector3& ip,
147  const std::string recoTracksName,
148  const std::string pxdInterceptsName,
149  const std::string pxdTrackClustersName
150  )
151  {
152  // get Track pointer
153  auto trackPtr = recoTrack.getRelated<Track>("Tracks");
154  if (!trackPtr) {
155  B2ERROR("Expect a track for fitted recotracks. Found nothing!");
156  }
157 
158  // get trackFitResult pointer
159  auto tfrPtr = trackPtr->getTrackFitResultWithClosestMass(Const::pion);
160  if (!tfrPtr) {
161  B2ERROR("expect a track fit result for pion. Found Nothing!");
162  }
163  nCDCHits = tfrPtr->getHitPatternCDC().getNHits();
164  nSVDHits = tfrPtr->getHitPatternVXD().getNSVDHits();
165  nPXDHits = tfrPtr->getHitPatternVXD().getNPXDHits();
166  tanLambda = tfrPtr->getCotTheta();
167  pt = tfrPtr->getMomentum().Perp();
168  d0 = tfrPtr->getD0();
169  z0 = tfrPtr->getZ0();
170  phi0 = tfrPtr->getPhi0();
171  d0p = d0;
172  z0p = z0;
173  if (ip != TVector3(0, 0, 0)) {
174  // get a helix and change coordinate origin to ip
175  auto uHelix = tfrPtr->getUncertainHelix();
176  uHelix.passiveMoveBy(ip);
177  d0p = uHelix.getD0();
178  z0p = uHelix.getZ0();
179  }
180 
181  //RelationVector<PXDIntercept> pxdIntercepts = recoTrack.getRelationsTo<PXDIntercept>();
182  auto pxdIntercepts = recoTrack.getRelationsTo<PXDIntercept>(pxdInterceptsName);
183  for (auto& pxdIntercept : pxdIntercepts) {
184  TTrackCluster temp;
185  // Only push a TrackCluster when setValues succeeds
186  if (temp.setValues(pxdIntercept, recoTracksName, pxdTrackClustersName))
187  trackClusters.push_back(temp);
188  }
189  }
190 
191  //} // end namespace Tuple
192  } // end namespace PXD
194 } // end namespace Belle2
Belle2::PXD::Cluster_t::charge
unsigned short charge
Cluster charge in ADU.
Definition: PXDPerformanceStructs.h:60
Belle2::PXD::TrackCluster_t::TrackCluster_t
TrackCluster_t()
Default constructor.
Definition: PXDPerformanceStructs.h:95
Belle2::PXD::TrackPoint_t::setValues
RecoTrack * setValues(const PXDIntercept &pxdIntercept, const std::string recoTracksName="")
Update values from a PXDCluster.
Definition: PXDPerformanceStructs.cc:42
Belle2::PXD::TrackBase_t::setValues
void setValues(const RecoTrack &recoTrack, const TVector3 &ip=TVector3(0, 0, 0), const std::string recoTracksName="", const std::string pxdInterceptsName="", const std::string pxdTrackClustersName="PXDClustersFromTracks")
Update values from a RecoTrack.
Definition: PXDPerformanceStructs.h:153
Belle2::PXD::TrackBase_t::d0p
float d0p
Corrected impact parameter in r-phi.
Definition: PXDPerformanceStructs.h:138
Belle2::PXD::TrackBase_t::pt
float pt
Transverse momentum.
Definition: PXDPerformanceStructs.h:136
Belle2::PXD::TrackCluster_t::intersection
TrackPoint_t intersection
The track-module intersection.
Definition: PXDPerformanceStructs.h:111
Belle2::PXD::Cluster_t::uSize
unsigned short uSize
Cluster size in U.
Definition: PXDPerformanceStructs.h:62
Belle2::PXD::TrackPoint_t::chargeMPV
float chargeMPV
Expected charge in ADU.
Definition: PXDPerformanceStructs.h:90
Belle2::PXD::Cluster_t::posU
float posU
Local position in r-phi.
Definition: PXDPerformanceStructs.h:64
Belle2::PXD::TrackBase_t::nCDCHits
unsigned short nCDCHits
Number of CDC Hits.
Definition: PXDPerformanceStructs.h:142
Belle2::RelationsInterface::getRelated
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
Definition: RelationsObject.h:280
Belle2::PXD::TrackBase_t::z0p
float z0p
Corrected impact parameter in z.
Definition: PXDPerformanceStructs.h:139
Belle2::PXD::Cluster_t::size
unsigned short size
Cluster size.
Definition: PXDPerformanceStructs.h:61
Belle2::PXD::Cluster_t::posV
float posV
Local position along z.
Definition: PXDPerformanceStructs.h:65
Belle2::PXD::TrackCluster_t::dU
float dU
Residual (meas - prediction) in U.
Definition: PXDPerformanceStructs.h:108
Belle2::PXD::TrackPoint_t
Struct to hold variables for intersection points.
Definition: PXDPerformanceStructs.h:69
Belle2::PXD::TrackCluster_t::cluster
Cluster_t cluster
Cluster associated to the track.
Definition: PXDPerformanceStructs.h:110
Belle2::RelationsInterface::getRelationsTo
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
Definition: RelationsObject.h:199
Belle2::PXD::Cluster_t::Cluster_t
Cluster_t()
Default constructor.
Definition: PXDPerformanceStructs.h:50
Belle2::PXD::TrackBase_t::z0
float z0
Impact parameter in z.
Definition: PXDPerformanceStructs.h:134
Belle2::PXD::Cluster_t::vSize
unsigned short vSize
Cluster size in V.
Definition: PXDPerformanceStructs.h:63
Belle2::PXD::TrackCluster_t::dV
float dV
Residual (meas - prediciton) in V.
Definition: PXDPerformanceStructs.h:109
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::Const::pion
static const ChargedStable pion
charged pion particle
Definition: Const.h:535
Belle2::PXD::TrackPoint_t::tol
float tol
The variables below are included here as they can be calculated w.o.
Definition: PXDPerformanceStructs.h:89
Belle2::PXD::TrackBase_t
Struct to hold variables from a track which contains a vector of data type like TrackCluster.
Definition: PXDPerformanceStructs.h:118
Belle2::PXD::TrackPoint_t::y
float y
Global position in y.
Definition: PXDPerformanceStructs.h:83
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PXD::TrackBase_t::phi0
float phi0
Track direction in r-phi.
Definition: PXDPerformanceStructs.h:135
Belle2::PXD::TrackBase_t::d0
float d0
Impact parameter in r-phi.
Definition: PXDPerformanceStructs.h:133
Belle2::PXD::TrackPoint_t::TrackPoint_t
TrackPoint_t()
Default constructor.
Definition: PXDPerformanceStructs.h:72
Belle2::PXD::Cluster_t
Struct to hold variables for PXD clusters.
Definition: PXDPerformanceStructs.h:47
Belle2::PXD::TrackCluster_t::setValues
RecoTrack * setValues(const PXDIntercept &pxdIntercept, const std::string recoTracksName="", const std::string pxdTrackClustersName="PXDClustersFromTracks")
Update values from a PXDIntercept.
Definition: PXDPerformanceStructs.cc:80
Belle2::PXD::TrackCluster_t::usedInTrack
bool usedInTrack
True if the cluster is used in tracking.
Definition: PXDPerformanceStructs.h:107
Belle2::PXD::Cluster_t::pxdID
unsigned short pxdID
Human readable id: layer * 1000 + ladder * 10 + sensor.
Definition: PXDPerformanceStructs.h:59
Belle2::PXD::Cluster_t::setValues
void setValues(const PXDCluster &pxdCluster)
Update values from a PXDCluster.
Definition: PXDPerformanceStructs.cc:31
Belle2::PXD::TrackBase_t::TrackBase_t
TrackBase_t()
Default constructor.
Definition: PXDPerformanceStructs.h:120
Belle2::PXD::TrackBase_t::tanLambda
float tanLambda
Tangent of the dip angle.
Definition: PXDPerformanceStructs.h:137
Belle2::PXD::TrackBase_t::nSVDHits
unsigned short nSVDHits
Number of SVD Hits.
Definition: PXDPerformanceStructs.h:141
Belle2::Track
Class that bundles various TrackFitResults.
Definition: Track.h:35
Belle2::PXDIntercept
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
Definition: PXDIntercept.h:32
Belle2::PXD::TrackCluster_t
Definition: PXDPerformanceStructs.h:93
Belle2::PXD::TrackBase_t::nPXDHits
unsigned short nPXDHits
Number of PXD Hits.
Definition: PXDPerformanceStructs.h:140
Belle2::PXD::TrackPoint_t::x
float x
Global position in x.
Definition: PXDPerformanceStructs.h:82
Belle2::PXD::TrackPoint_t::z
float z
Global position in z.
Definition: PXDPerformanceStructs.h:84