Belle II Software  release-06-02-00
PXDPerformanceStructs.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <framework/gearbox/Unit.h>
12 #include <framework/gearbox/Const.h>
13 #include <framework/datastore/RelationsObject.h>
14 #include <pxd/dataobjects/PXDCluster.h>
15 #include <tracking/dataobjects/RecoTrack.h>
16 #include <tracking/dataobjects/PXDIntercept.h>
17 #include <genfit/MeasuredStateOnPlane.h>
18 #include <TVector3.h>
19 //#include <limits>
20 #include <vector>
21 #include <math.h>
22 
23 #include <pxd/utilities/PXDUtilities.h>
24 #include <mdst/dataobjects/Track.h>
25 #include <mdst/dataobjects/HitPatternCDC.h>
26 #include <mdst/dataobjects/HitPatternVXD.h>
27 
28 namespace Belle2 {
34  namespace PXD {
35 
37  struct Cluster_t {
38 
40  Cluster_t(): pxdID(0), charge(0), size(0),
41  uSize(0), vSize(0), posU(0.0), posV(0.0) {}
42 
46  void setValues(const PXDCluster& pxdCluster);
47 
49  unsigned short pxdID;
50  unsigned short charge;
51  unsigned short size;
52  unsigned short uSize;
53  unsigned short vSize;
54  float posU;
55  float posV;
56  }; // end struct Cluster_t
57 
59  struct TrackPoint_t {
60 
62  TrackPoint_t(): x(0.0), y(0.0), z(0.0),
63  tol(0.0), chargeMPV(0.0), inside(false) {}
64 
71  RecoTrack* setValues(const PXDIntercept& pxdIntercept, const std::string& recoTracksName = "",
72  const double& mass = Const::electronMass);
73 
74  float x;
75  float y;
76  float z;
81  float tol;
82  float chargeMPV;
83  bool inside;
84  }; // end struct TrackPoint_t
85 
87  struct TrackCluster_t {
89  TrackCluster_t(): usedInTrack(false), dU(INFINITY), dV(INFINITY) {}
90 
98  RecoTrack* setValues(const PXDIntercept& pxdIntercept,
99  const std::string& recoTracksName = "",
100  const std::string& pxdTrackClustersName = "PXDClustersFromTracks",
101  const double& mass = Const::electronMass);
102 
103  bool usedInTrack;
104  float dU;
105  float dV;
108  }; // end struct TrackCluster_t
109 
113  template <typename TTrackCluster>
114  struct TrackBase_t {
116  TrackBase_t(): d0(0.0), z0(0.0), phi0(0.0), pt(0.0), tanLambda(0.0),
117  d0p(0.0), z0p(0.0), nPXDHits(0), nSVDHits(0), nCDCHits(0) {}
118 
123  void setTrackVariables(const TrackFitResult* tfrPtr, const TVector3& ip);
124 
132  void setValues(const RecoTrack& recoTrack, const TVector3& ip = TVector3(0, 0, 0),
133  const std::string& recoTracksName = "",
134  const std::string& pxdInterceptsName = "",
135  const std::string& pxdTrackClustersName = "PXDClustersFromTracks"
136  );
137 
138  float d0;
139  float z0;
140  float phi0;
141  float pt;
142  float tanLambda;
143  float d0p;
144  float z0p;
145  unsigned short nPXDHits;
146  unsigned short nSVDHits;
147  unsigned short nCDCHits;
148  std::vector<TTrackCluster> trackClusters;
149  };
150 
153 
154 
158  template <typename TTrackCluster>
160  const TrackFitResult* tfrPtr, const TVector3& ip
161  )
162  {
163  if (!tfrPtr) {
164  B2ERROR("Expect the track fit result. Found Nothing!");
165  }
166  nCDCHits = tfrPtr->getHitPatternCDC().getNHits();
167  nSVDHits = tfrPtr->getHitPatternVXD().getNSVDHits();
168  nPXDHits = tfrPtr->getHitPatternVXD().getNPXDHits();
169  tanLambda = tfrPtr->getCotTheta();
170  pt = tfrPtr->getMomentum().Perp();
171  d0 = tfrPtr->getD0();
172  z0 = tfrPtr->getZ0();
173  phi0 = tfrPtr->getPhi0();
174  d0p = d0;
175  z0p = z0;
176  if (ip != TVector3(0, 0, 0)) {
177  // get a helix and change coordinate origin to ip
178  auto uHelix = tfrPtr->getUncertainHelix();
179  uHelix.passiveMoveBy(ip);
180  d0p = uHelix.getD0();
181  z0p = uHelix.getZ0();
182  }
183  }
184 
185  template <typename TTrackCluster>
187  const RecoTrack& recoTrack, const TVector3& ip,
188  const std::string& recoTracksName,
189  const std::string& pxdInterceptsName,
190  const std::string& pxdTrackClustersName
191  )
192  {
193  // get Track pointer
194  auto trackPtr = recoTrack.getRelated<Track>("Tracks");
195  if (!trackPtr) {
196  B2ERROR("Expect a track for fitted recotracks. Found nothing!");
197  }
198 
199  // get trackFitResult pointer
200  auto tfrPtr = trackPtr->getTrackFitResultWithClosestMass(
201  Const::pion); // always try to use pion as electron fit doesn't work properly.
202  setTrackVariables(tfrPtr, ip);
203 
204  //RelationVector<PXDIntercept> pxdIntercepts = recoTrack.getRelationsTo<PXDIntercept>();
205  auto pxdIntercepts = recoTrack.getRelationsTo<PXDIntercept>(pxdInterceptsName);
206  for (auto& pxdIntercept : pxdIntercepts) {
207  TTrackCluster temp;
208  // Only push a TrackCluster when setValues succeeds
209  if (temp.setValues(pxdIntercept, recoTracksName, pxdTrackClustersName))
210  trackClusters.push_back(temp);
211  }
212  }
213 
214  //} // end namespace Tuple
215  } // end namespace PXD
217 } // end namespace Belle2
static const ChargedStable pion
charged pion particle
Definition: Const.h:542
static const double electronMass
electron mass
Definition: Const.h:565
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
unsigned short getNPXDHits() const
Get total number of hits in the PXD.
unsigned short getNSVDHits() const
Get total number of hits in the SVD.
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
Definition: PXDIntercept.h:22
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
Values of the result of a track fit with a given particle hypothesis.
double getCotTheta() const
Getter for tanLambda with CDF naming convention.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
UncertainHelix getUncertainHelix() const
Conversion to framework Uncertain Helix (i.e., with covariance).
double getPhi0() const
Getter for phi0.
HitPatternVXD getHitPatternVXD() const
Getter for the hit pattern in the VXD;.
Class that bundles various TrackFitResults.
Definition: Track.h:25
double passiveMoveBy(const TVector3 &by)
Moves origin of the coordinate system (passive transformation) by the given vector.
TrackBase_t< TrackCluster_t > Track_t
Typedef TrackBase_t<TrackCluster_t> Track_t.
Abstract base class for different kinds of events.
Struct to hold variables for PXD clusters.
float posV
Local position along z.
Cluster_t()
Default constructor.
float posU
Local position in r-phi.
unsigned short pxdID
Human readable id: layer * 1000 + ladder * 10 + sensor.
void setValues(const PXDCluster &pxdCluster)
Update values from a PXDCluster.
unsigned short charge
Cluster charge in ADU.
unsigned short uSize
Cluster size in U.
unsigned short vSize
Cluster size in V.
unsigned short size
Cluster size.
Struct to hold variables from a track which contains a vector of data type like TrackCluster.
TrackBase_t()
Default constructor.
float z0
Impact parameter in z.
void setTrackVariables(const TrackFitResult *tfrPtr, const TVector3 &ip)
update track level variables from TrackFitResult
float pt
Transverse momentum.
float d0p
Corrected impact parameter in r-phi.
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.
float d0
Impact parameter in r-phi.
float phi0
Track direction in r-phi.
unsigned short nCDCHits
Number of CDC Hits.
unsigned short nSVDHits
Number of SVD Hits.
float z0p
Corrected impact parameter in z.
unsigned short nPXDHits
Number of PXD Hits.
float tanLambda
Tangent of the dip angle.
std::vector< TTrackCluster > trackClusters
Vector of track cluster structs.
Struct to hold variables for track clusters.
TrackCluster_t()
Default constructor.
float dU
Residual (meas - prediction) in U.
bool usedInTrack
True if the cluster is used in tracking.
RecoTrack * setValues(const PXDIntercept &pxdIntercept, const std::string &recoTracksName="", const std::string &pxdTrackClustersName="PXDClustersFromTracks", const double &mass=Const::electronMass)
Update values from a PXDIntercept.
Cluster_t cluster
Cluster associated to the track.
TrackPoint_t intersection
The track-module intersection.
float dV
Residual (meas - prediciton) in V.
Struct to hold variables for intersection points.
bool inside
True if it's inside the active region.
float chargeMPV
Expected charge in ADU.
RecoTrack * setValues(const PXDIntercept &pxdIntercept, const std::string &recoTracksName="", const double &mass=Const::electronMass)
Update values from a PXDCluster.
float tol
The variables below are included here as they can be calculated w.o.
float y
Global position in y.
float x
Global position in x.
TrackPoint_t()
Default constructor.
float z
Global position in z.