Belle II Software  release-08-01-10
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 <mdst/dataobjects/Track.h>
24 #include <mdst/dataobjects/HitPatternCDC.h>
25 #include <mdst/dataobjects/HitPatternVXD.h>
26 
27 namespace Belle2 {
33  namespace PXD {
34 
36  struct Cluster_t {
37 
39  Cluster_t(): pxdID(0), charge(0), size(0),
40  uSize(0), vSize(0), posU(0.0), posV(0.0) {}
41 
45  void setValues(const PXDCluster& pxdCluster);
46 
48  unsigned short pxdID;
49  unsigned short charge;
50  unsigned short size;
51  unsigned short uSize;
52  unsigned short vSize;
53  float posU;
54  float posV;
55  }; // end struct Cluster_t
56 
58  struct TrackPoint_t {
59 
61  TrackPoint_t(): x(0.0), y(0.0), z(0.0),
62  tol(0.0), chargeMPV(0.0), inside(false) {}
63 
70  RecoTrack* setValues(const PXDIntercept& pxdIntercept, const std::string& recoTracksName = "",
71  const double& mass = Const::electronMass);
72 
73  float x;
74  float y;
75  float z;
80  float tol;
81  float chargeMPV;
82  bool inside;
83  }; // end struct TrackPoint_t
84 
86  struct TrackCluster_t {
88  TrackCluster_t(): usedInTrack(false), dU(INFINITY), dV(INFINITY) {}
89 
97  RecoTrack* setValues(const PXDIntercept& pxdIntercept,
98  const std::string& recoTracksName = "",
99  const std::string& pxdTrackClustersName = "PXDClustersFromTracks",
100  const double& mass = Const::electronMass);
101 
102  bool usedInTrack;
103  float dU;
104  float dV;
107  }; // end struct TrackCluster_t
108 
112  template <typename TTrackCluster>
113  struct TrackBase_t {
115  TrackBase_t(): d0(0.0), z0(0.0), phi0(0.0), pt(0.0), tanLambda(0.0),
116  d0p(0.0), z0p(0.0), nPXDHits(0), nSVDHits(0), nCDCHits(0) {}
117 
122  void setTrackVariables(const TrackFitResult* tfrPtr, const ROOT::Math::XYZVector& ip);
123 
131  void setValues(const RecoTrack& recoTrack, const ROOT::Math::XYZVector& ip = ROOT::Math::XYZVector(0, 0, 0),
132  const std::string& recoTracksName = "",
133  const std::string& pxdInterceptsName = "",
134  const std::string& pxdTrackClustersName = "PXDClustersFromTracks"
135  );
136 
137  float d0;
138  float z0;
139  float phi0;
140  float pt;
141  float tanLambda;
142  float d0p;
143  float z0p;
144  unsigned short nPXDHits;
145  unsigned short nSVDHits;
146  unsigned short nCDCHits;
147  std::vector<TTrackCluster> trackClusters;
148  };
149 
152 
153 
157  template <typename TTrackCluster>
159  const TrackFitResult* tfrPtr, const ROOT::Math::XYZVector& ip
160  )
161  {
162  if (!tfrPtr) {
163  B2ERROR("Expect the track fit result. Found Nothing!");
164  }
165  nCDCHits = tfrPtr->getHitPatternCDC().getNHits();
166  nSVDHits = tfrPtr->getHitPatternVXD().getNSVDHits();
167  nPXDHits = tfrPtr->getHitPatternVXD().getNPXDHits();
168  tanLambda = tfrPtr->getCotTheta();
169  pt = tfrPtr->getMomentum().Rho();
170  d0 = tfrPtr->getD0();
171  z0 = tfrPtr->getZ0();
172  phi0 = tfrPtr->getPhi0();
173  d0p = d0;
174  z0p = z0;
175  if (ip != ROOT::Math::XYZVector(0, 0, 0)) {
176  // get a helix and change coordinate origin to ip
177  auto uHelix = tfrPtr->getUncertainHelix();
178  uHelix.passiveMoveBy(ip);
179  d0p = uHelix.getD0();
180  z0p = uHelix.getZ0();
181  }
182  }
183 
184  template <typename TTrackCluster>
186  const RecoTrack& recoTrack, const ROOT::Math::XYZVector& ip,
187  const std::string& recoTracksName,
188  const std::string& pxdInterceptsName,
189  const std::string& pxdTrackClustersName
190  )
191  {
192  // get Track pointer
193  auto trackPtr = recoTrack.getRelated<Track>("Tracks");
194  if (!trackPtr) {
195  B2ERROR("Expect a track for fitted recotracks. Found nothing!");
196  }
197 
198  // get trackFitResult pointer
199  auto tfrPtr = trackPtr->getTrackFitResultWithClosestMass(
200  Const::pion); // always try to use pion as electron fit doesn't work properly.
201  setTrackVariables(tfrPtr, ip);
202 
203  //RelationVector<PXDIntercept> pxdIntercepts = recoTrack.getRelationsTo<PXDIntercept>();
204  auto pxdIntercepts = recoTrack.getRelationsTo<PXDIntercept>(pxdInterceptsName);
205  for (auto& pxdIntercept : pxdIntercepts) {
206  TTrackCluster temp;
207  // Only push a TrackCluster when setValues succeeds
208  if (temp.setValues(pxdIntercept, recoTracksName, pxdTrackClustersName))
209  trackClusters.push_back(temp);
210  }
211  }
212 
213  //} // end namespace Tuple
214  } // end namespace PXD
216 } // end namespace Belle2
static const ChargedStable pion
charged pion particle
Definition: Const.h:652
static const double electronMass
electron mass
Definition: Const.h:676
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:79
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.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
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 ROOT::Math::XYZVector &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.
float pt
Transverse momentum.
float d0p
Corrected impact parameter in r-phi.
float d0
Impact parameter in r-phi.
float phi0
Track direction in r-phi.
unsigned short nCDCHits
Number of CDC Hits.
void setTrackVariables(const TrackFitResult *tfrPtr, const ROOT::Math::XYZVector &ip)
update track level variables from TrackFitResult
unsigned short nSVDHits
Number of SVD Hits.
float z0p
Corrected impact parameter in z.
unsigned short nPXDHits
Number of PXD Hits.
void setValues(const RecoTrack &recoTrack, const ROOT::Math::XYZVector &ip=ROOT::Math::XYZVector(0, 0, 0), const std::string &recoTracksName="", const std::string &pxdInterceptsName="", const std::string &pxdTrackClustersName="PXDClustersFromTracks")
Update values from a RecoTrack.
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.