Belle II Software development
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 <limits>
19#include <vector>
20#include <math.h>
21
22#include <mdst/dataobjects/Track.h>
23#include <mdst/dataobjects/HitPatternCDC.h>
24#include <mdst/dataobjects/HitPatternVXD.h>
25
26namespace Belle2 {
32 namespace PXD {
33
35 struct Cluster_t {
36
38 Cluster_t(): pxdID(0), charge(0), size(0),
39 uSize(0), vSize(0), posU(0.0), posV(0.0) {}
40
44 void setValues(const PXDCluster& pxdCluster);
45
47 unsigned short pxdID;
48 unsigned short charge;
49 unsigned short size;
50 unsigned short uSize;
51 unsigned short vSize;
52 float posU;
53 float posV;
54 }; // end struct Cluster_t
55
57 struct TrackPoint_t {
58
60 TrackPoint_t(): x(0.0), y(0.0), z(0.0),
61 tol(0.0), chargeMPV(0.0), inside(false) {}
62
69 RecoTrack* setValues(const PXDIntercept& pxdIntercept, const std::string& recoTracksName = "",
70 const double& mass = Const::electronMass);
71
72 float x;
73 float y;
74 float z;
79 float tol;
80 float chargeMPV;
81 bool inside;
82 }; // end struct TrackPoint_t
83
87 TrackCluster_t(): usedInTrack(false), dU(INFINITY), dV(INFINITY) {}
88
96 RecoTrack* setValues(const PXDIntercept& pxdIntercept,
97 const std::string& recoTracksName = "",
98 const std::string& pxdTrackClustersName = "PXDClustersFromTracks",
99 const double& mass = Const::electronMass);
100
102 float dU;
103 float dV;
106 }; // end struct TrackCluster_t
107
111 template <typename TTrackCluster>
112 struct TrackBase_t {
114 TrackBase_t(): d0(0.0), z0(0.0), phi0(0.0), pt(0.0), tanLambda(0.0),
115 d0p(0.0), z0p(0.0), nPXDHits(0), nSVDHits(0), nCDCHits(0) {}
116
121 void setTrackVariables(const TrackFitResult* tfrPtr, const ROOT::Math::XYZVector& ip);
122
130 void setValues(const RecoTrack& recoTrack, const ROOT::Math::XYZVector& ip = ROOT::Math::XYZVector(0, 0, 0),
131 const std::string& recoTracksName = "",
132 const std::string& pxdInterceptsName = "",
133 const std::string& pxdTrackClustersName = "PXDClustersFromTracks"
134 );
135
136 float d0;
137 float z0;
138 float phi0;
139 float pt;
140 float tanLambda;
141 float d0p;
142 float z0p;
143 unsigned short nPXDHits;
144 unsigned short nSVDHits;
145 unsigned short nCDCHits;
146 std::vector<TTrackCluster> trackClusters;
147 };
148
151
152
156 template <typename TTrackCluster>
158 const TrackFitResult* tfrPtr, const ROOT::Math::XYZVector& ip
159 )
160 {
161 if (!tfrPtr) {
162 B2ERROR("Expect the track fit result. Found Nothing!");
163 }
164 nCDCHits = tfrPtr->getHitPatternCDC().getNHits();
165 nSVDHits = tfrPtr->getHitPatternVXD().getNSVDHits();
166 nPXDHits = tfrPtr->getHitPatternVXD().getNPXDHits();
167 tanLambda = tfrPtr->getCotTheta();
168 pt = tfrPtr->getMomentum().Rho();
169 d0 = tfrPtr->getD0();
170 z0 = tfrPtr->getZ0();
171 phi0 = tfrPtr->getPhi0();
172 d0p = d0;
173 z0p = z0;
174 if (ip != ROOT::Math::XYZVector(0, 0, 0)) {
175 // get a helix and change coordinate origin to ip
176 auto uHelix = tfrPtr->getUncertainHelix();
177 uHelix.passiveMoveBy(ip);
178 d0p = uHelix.getD0();
179 z0p = uHelix.getZ0();
180 }
181 }
182
183 template <typename TTrackCluster>
185 const RecoTrack& recoTrack, const ROOT::Math::XYZVector& ip,
186 const std::string& recoTracksName,
187 const std::string& pxdInterceptsName,
188 const std::string& pxdTrackClustersName
189 )
190 {
191 // get Track pointer
192 auto trackPtr = recoTrack.getRelated<Track>("Tracks");
193 if (!trackPtr) {
194 B2ERROR("Expect a track for fitted recotracks. Found nothing!");
195 }
196
197 // get trackFitResult pointer
198 auto tfrPtr = trackPtr->getTrackFitResultWithClosestMass(
199 Const::pion); // always try to use pion as electron fit doesn't work properly.
200 setTrackVariables(tfrPtr, ip);
201
202 //RelationVector<PXDIntercept> pxdIntercepts = recoTrack.getRelationsTo<PXDIntercept>();
203 auto pxdIntercepts = recoTrack.getRelationsTo<PXDIntercept>(pxdInterceptsName);
204 for (auto& pxdIntercept : pxdIntercepts) {
205 TTrackCluster temp;
206 // Only push a TrackCluster when setValues succeeds
207 if (temp.setValues(pxdIntercept, recoTracksName, pxdTrackClustersName))
208 trackClusters.push_back(temp);
209 }
210 }
211
212 //} // end namespace Tuple
213 } // end namespace PXD
215} // end namespace Belle2
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
static const double electronMass
electron mass
Definition: Const.h:685
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
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
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.