9#include <tracking/dataobjects/RecoTrack.h>
10#include <mdst/dataobjects/Track.h>
11#include <analysis/dataobjects/Particle.h>
12#include <svd/variables/SVDClusterVariables.h>
13#include <svd/dataobjects/SVDTrueHit.h>
14#include <vxd/dataobjects/VxdID.h>
30 const std::vector<Belle2::SVDCluster*> svdClusters = recoTrack->
getSVDHitList();
31 if (clusterIndex >= svdClusters.size()) {
34 return svdClusters[clusterIndex];
40 return getSVDCluster(recoTrack, clusterIndex);
44namespace Belle2::Variable {
46 double SVDClusterCharge(
const Particle* particle,
const std::vector<double>& indices)
51 if (indices.size() != 1) {
52 B2FATAL(
"Exactly one parameter (cluster index) is required.");
54 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
56 SVDCluster* svdCluster = getSVDCluster(particle, clusterIndex);
60 double SVDClusterSNR(
const Particle* particle,
const std::vector<double>& indices)
66 if (indices.size() != 1) {
67 B2FATAL(
"Exactly one parameter (cluster index) is required.");
69 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
71 SVDCluster* svdCluster = getSVDCluster(particle, clusterIndex);
75 int SVDClusterSize(
const Particle* particle,
const std::vector<double>& indices)
81 if (indices.size() != 1) {
82 B2FATAL(
"Exactly one parameter (cluster index) is required.");
84 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
86 SVDCluster* svdCluster = getSVDCluster(particle, clusterIndex);
87 return svdCluster ? svdCluster->getSize() : -1;
90 double SVDClusterTime(
const Particle* particle,
const std::vector<double>& indices)
95 if (indices.size() != 1) {
96 B2FATAL(
"Exactly one parameter (cluster index) is required.");
98 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
100 SVDCluster* svdCluster = getSVDCluster(particle, clusterIndex);
104 double SVDTrackPrime(
const Particle* particle,
const std::vector<double>& indices)
109 if (indices.size() != 1) {
110 B2FATAL(
"Exactly one parameter (cluster index) is required.");
112 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
114 const RecoTrack* recoTrack = getRecoTrack(particle);
118 const SVDCluster* svdCluster = getSVDCluster(recoTrack, clusterIndex);
122 const RecoHitInformation* recoHitInformation = recoTrack->getRecoHitInformation(svdCluster);
123 if (!recoHitInformation) {
127 genfit::MeasuredStateOnPlane measuredState = recoTrack->getMeasuredStateOnPlaneFromRecoHit(recoHitInformation);
128 return svdCluster->isUCluster()
129 ? measuredState.getState()[1]
130 : measuredState.getState()[2];
131 }
catch (
const NoTrackFitResult&) {
132 B2WARNING(
"No track fit result available for this hit!");
137 double SVDTrackPositionErrorUnbiased(
const Particle* particle,
const std::vector<double>& indices)
142 if (indices.size() != 1) {
143 B2FATAL(
"Exactly one parameter (cluster index) is required.");
145 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
147 const RecoTrack* recoTrack = getRecoTrack(particle);
151 const SVDCluster* svdCluster = getSVDCluster(recoTrack, clusterIndex);
155 const RecoHitInformation* recoHitInformation = recoTrack->getRecoHitInformation(svdCluster);
156 if (!recoHitInformation) {
159 const genfit::TrackPoint* trackPoint = recoTrack->getCreatedTrackPoint(recoHitInformation);
163 const genfit::AbsFitterInfo* fitterInfo = trackPoint->getFitterInfo();
168 genfit::MeasuredStateOnPlane unbiasedState = fitterInfo->getFittedState(
false);
169 return svdCluster->isUCluster()
170 ?
sqrt(unbiasedState.getCov()[3][3])
171 :
sqrt(unbiasedState.getCov()[4][4]);
173 B2WARNING(
"Could not compute SVDTrackPositionErrorUnbiased.");
178 double SVDTruePosition(
const Particle* particle,
const std::vector<double>& indices)
183 if (indices.size() != 1) {
184 B2FATAL(
"Exactly one parameter (cluster index) is required.");
186 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
188 SVDCluster* svdCluster = getSVDCluster(particle, clusterIndex);
193 const auto trueHit = svdCluster->getRelatedTo<Belle2::SVDTrueHit>();
198 return svdCluster->isUCluster()
203 double SVDResidual(
const Particle* particle,
const std::vector<double>& indices)
208 if (indices.size() != 1) {
209 B2FATAL(
"Exactly one parameter (cluster index) is required.");
211 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
213 const RecoTrack* recoTrack = getRecoTrack(particle);
217 const SVDCluster* svdCluster = getSVDCluster(recoTrack, clusterIndex);
221 const RecoHitInformation* recoHitInformation = recoTrack->getRecoHitInformation(svdCluster);
222 if (!recoHitInformation) {
225 const genfit::TrackPoint* trackPoint = recoTrack->getCreatedTrackPoint(recoHitInformation);
229 const genfit::AbsFitterInfo* fitterInfo = trackPoint->getFitterInfo();
234 const TVectorD residualMeasurement = fitterInfo->getResidual(0,
false).getState();
237 B2WARNING(
"Could not get track residual.");
242 int SVDLayer(
const Particle* particle,
const std::vector<double>& indices)
247 if (indices.size() != 1) {
248 B2FATAL(
"Exactly one parameter (cluster index) is required.");
250 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
252 SVDCluster* svdCluster = getSVDCluster(particle, clusterIndex);
256 const VxdID vxdId = svdCluster->getSensorID();
257 return vxdId ? vxdId.getLayerNumber() : -1;
260 int SVDLadder(
const Particle* particle,
const std::vector<double>& indices)
265 if (indices.size() != 1) {
266 B2FATAL(
"Exactly one parameter (cluster index) is required.");
268 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
270 SVDCluster* svdCluster = getSVDCluster(particle, clusterIndex);
274 const VxdID vxdId = svdCluster->getSensorID();
275 return vxdId ? vxdId.getLadderNumber() : -1;
278 int SVDSensor(
const Particle* particle,
const std::vector<double>& indices)
283 if (indices.size() != 1) {
284 B2FATAL(
"Exactly one parameter (cluster index) is required.");
286 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
288 SVDCluster* svdCluster = getSVDCluster(particle, clusterIndex);
292 const VxdID vxdId = svdCluster->getSensorID();
293 return vxdId ? vxdId.getSensorNumber() : -1;
296 bool SVDSide(
const Particle* particle,
const std::vector<double>& indices)
301 if (indices.size() != 1) {
302 B2FATAL(
"Exactly one parameter (cluster index) is required.");
304 const auto clusterIndex =
static_cast<unsigned int>(indices[0]);
306 SVDCluster* svdCluster = getSVDCluster(particle, clusterIndex);
307 return svdCluster ? svdCluster->isUCluster() :
false;
310 VARIABLE_GROUP(
"SVD Validation");
312 REGISTER_VARIABLE(
"SVDClusterCharge(i)", SVDClusterCharge,
313 "Returns the charge of the i-th SVD cluster related to the Particle.");
314 REGISTER_VARIABLE(
"SVDClusterSNR(i)", SVDClusterSNR,
315 "Returns the SNR of the i-th SVD cluster related to the Particle.");
316 REGISTER_VARIABLE(
"SVDClusterSize(i)", SVDClusterSize,
317 "Returns the size of the i-th SVD cluster related to the Particle.");
318 REGISTER_VARIABLE(
"SVDClusterTime(i)", SVDClusterTime,
319 "Returns the time of the i-th SVD cluster related to the Particle.");
320 REGISTER_VARIABLE(
"SVDTrackPrime(i)", SVDTrackPrime,
321 "Returns the tan of the incident angle projected on U/V of the i-th SVD cluster related to the Particle.");
322 REGISTER_VARIABLE(
"SVDResidual(i)", SVDResidual,
323 "Returns the track residual of the i-th SVD cluster related to the Particle.");
324 REGISTER_VARIABLE(
"SVDTrackPositionErrorUnbiased(i)", SVDTrackPositionErrorUnbiased,
325 "Returns the unbiased track position error of the i-th SVD cluster related to the Particle.");
326 REGISTER_VARIABLE(
"SVDTruePosition(i)", SVDTruePosition,
327 "Returns the true position of the i-th SVD cluster related to the Particle.");
328 REGISTER_VARIABLE(
"SVDLayer(i)", SVDLayer,
329 "Returns the layer number of the i-th SVD cluster related to the Particle. If no SVD cluster is found, returns -1.");
330 REGISTER_VARIABLE(
"SVDLadder(i)", SVDLadder,
331 "Returns the ladder number of the i-th SVD cluster related to the Particle. If no SVD cluster is found, returns -1.");
332 REGISTER_VARIABLE(
"SVDSensor(i)", SVDSensor,
333 "Returns the sensor number of the i-th SVD cluster related to the Particle. If no SVD cluster is found, returns -1.");
334 REGISTER_VARIABLE(
"SVDSide(i)", SVDSide,
335 "Returns true if the i-th SVD cluster related to the Particle is a U cluster.");
static const double doubleNaN
quiet_NaN
Class to store reconstructed particles.
This is the Reconstruction Event-Data Model Track.
std::vector< Belle2::RecoTrack::UsedSVDHit * > getSVDHitList() const
Return an unsorted list of svd hits.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Class that bundles various TrackFitResults.
static double convertValueToUnit(double value, const std::string &unitString)
Converts a floating point value from the standard framework unit to the given unit.
double sqrt(double a)
sqrt for double