Belle II Software development
SpacePointTrackCand.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// framework
12#include <framework/datastore/RelationsObject.h>
13#include <framework/core/FrameworkExceptions.h>
14
15// SpacePoint
16#include <tracking/spacePointCreation/SpacePoint.h>
17
18// stl
19#include <vector>
20
21// ROOT
22#include <TVectorD.h>
23#include <TMatrixD.h>
24
25// USHRT_MAX
26#include <climits>
27
28namespace Belle2 {
40 class SpacePointTrackCand final : public RelationsObject {
41
42 public:
43
47 BELLE2_DEFINE_EXCEPTION(UnsupportedDetType, "The Detector Type is not supported by this class. Supported are: PXD and SVD");
48
52 BELLE2_DEFINE_EXCEPTION(SPTCIndexOutOfBounds, "Trying to acces a SpacePoint from a SpacePointTrackCand via an"\
53 " index that is out of bounds!");
54
58 BELLE2_DEFINE_EXCEPTION(SPTCSortingParameterSizeInvalid,
59 "Trying to modify SortingParameters, but number of new SortingParameters differs from number of SpacePoints");
60
83 c_isActive = 2048,
84 c_isReserved = 4096,
85 c_hasFittedRecoTrack = 1 << 13,
88 };
89
97
106 explicit SpacePointTrackCand(const std::vector<const Belle2::SpacePoint*>& spacePoints, int pdgCode = 0, double charge = 0,
107 int mcTrackID = -1);
108
109
114 bool operator == (const SpacePointTrackCand& rhs) const;
115
116
120 const std::vector<const Belle2::SpacePoint*>& getHits() const { return m_trackSpacePoints; }
121
125 const std::vector<const Belle2::SpacePoint*> getSortedHits() const;
126
128 std::vector<const Belle2::SpacePoint*>::const_iterator begin() const { return m_trackSpacePoints.begin(); }
129
131 std::vector<const Belle2::SpacePoint*>::const_iterator end() const { return m_trackSpacePoints.end(); }
132
138 const std::vector<const Belle2::SpacePoint*> getHitsInRange(int firstInd, int lastInd) const;
139
143 unsigned int getNHits() const { return m_trackSpacePoints.size(); }
144
148 unsigned int size() const { return m_trackSpacePoints.size(); }
149
153 int getPdgCode() const { return m_pdg; }
154
158 double getChargeSeed() const { return m_q; }
159
161 const TMatrixDSym& getCovSeed() const { return m_cov6D; }
162
164 const TVectorD& getStateSeed() const { return m_state6D; }
165
167 const ROOT::Math::XYZVector getPosSeed() const { return ROOT::Math::XYZVector(m_state6D[0], m_state6D[1], m_state6D[2]); }
168
170 const ROOT::Math::XYZVector getMomSeed() const { return ROOT::Math::XYZVector(m_state6D[3], m_state6D[4], m_state6D[5]); }
171
175 const std::vector<double>& getSortingParameters() const { return m_sortingParameters; }
176
182 const std::vector<double> getSortingParametersInRange(int firstIndex, int lastIndex) const;
183
185 int getTrackStubIndex() const { return m_iTrackStub; }
186
190 int getMcTrackID() const { return m_MCTrackID; }
191
195 int getMcTrackId() const { return m_MCTrackID; }
196
201 unsigned short int getRefereeStatus(unsigned short int bitmask = USHRT_MAX) const { return m_refereeStatus & bitmask; }
202
206 bool hasRefereeStatus(unsigned int short bitmask) const { return (m_refereeStatus & bitmask) == bitmask; }
207
211 double getQualityIndicator() const { return m_qualityIndicator; }
212
218
223
229
234
240
244 bool isOutgoing() const { return m_flightDirection; }
245
250 bool isCurling() const { return hasRefereeStatus(c_curlingTrack); }
251
253 bool checkedForCurling() const { return m_iTrackStub != -1; }
254
256 bool isPartOfCurlingTrack() const { return m_iTrackStub > 0; }
257
262 void print(int debuglevel = 25, const Option_t* = "") const;
263
269 std::string getRefereeStatusString(std::string delimiter = " ") const;
270
274 short getFamily() const { return m_family; }
275
279 void setFamily(short family) { m_family = family; }
280
284 void setSortingParameters(const std::vector<double>& sortParams);
285
289 void setPdgCode(int pdgCode);
290
292 void setChargeSeed(double charge) { m_q = charge; }
293
297 void set6DSeed(const TVectorD& state6D) { m_state6D = state6D; }
298
302 void setCovSeed(const TMatrixDSym& cov) { m_cov6D = cov; }
303
310 void setQualityIndicator(const double newIndicator) { m_qualityIndicator = newIndicator; }
311
315 void addSpacePoint(const SpacePoint* newSP, double sortParam)
316 {
317 m_trackSpacePoints.push_back(newSP);
318 m_sortingParameters.push_back(sortParam);
319 }
320
324 void setFlightDirection(bool direction) { m_flightDirection = direction; }
325
327 void setTrackStubIndex(int trackStubInd) { m_iTrackStub = trackStubInd; }
328
330 void setRefereeStatus(unsigned short int bitmask) { m_refereeStatus = bitmask; }
331
333 void addRefereeStatus(unsigned short int bitmask) { m_refereeStatus |= bitmask; }
334
336 void removeRefereeStatus(unsigned short int bitmask) { m_refereeStatus &= (~bitmask); }
337
340
343
345 void removeSpacePoint(int indexInTrackCand);
346
350
351 protected:
355 std::vector<const SpacePoint*> m_trackSpacePoints;
356
360 std::vector<double> m_sortingParameters;
361
362
366 short m_family = -1;
367
371 int m_pdg = 0;
372
376 int m_MCTrackID = -1;
377
381 TVectorD m_state6D = TVectorD(6);
382
386 TMatrixDSym m_cov6D = TMatrixDSym(6);
387
391 double m_q = 0;
392
396 bool m_flightDirection = true;
397
405 int m_iTrackStub = -1;
406
410 unsigned short int m_refereeStatus = c_isActive;
411
418 double m_qualityIndicator = 0.5;
419
420 // last members added: RefereeStatutsBit(5), m_refereeProperties(5) m_iTrackStub(4), m_flightDirection(3), m_sortingParameters (2), m_qualityIndicator
422 };
424}
Defines interface for accessing relations of objects in StoreArray.
ClassDef(RelationsInterface, 0)
defines interface for accessing relations of objects in StoreArray.
Storage for (VXD) SpacePoint-based track candidates.
short getFamily() const
return family identifier
const ROOT::Math::XYZVector getPosSeed() const
get position seed as ROOT::Math::XYZVector
int getMcTrackId() const
get the MC Track ID (same writing as in genfit::TrackCand)
std::vector< constBelle2::SpacePoint * >::const_iterator begin() const
returns a const_iterator (begin()) for easily looping over hits of SpacePointTrackCand.
double m_q
charge of the particle in units of elementary charge
short m_family
identifier for tracks that share at least two SpacePoints.
double m_qualityIndicator
An estimation for the quality of the track.
const std::vector< double > & getSortingParameters() const
get the sorting parameters
int m_iTrackStub
Index of TrackStub in a curling Track Candidate.
void setSortingParameters(const std::vector< double > &sortParams)
set the sorting parameters
const ROOT::Math::XYZVector getMomSeed() const
get momentum seed as ROOT::Math::XYZVector
void set6DSeed(const TVectorD &state6D)
set the 6D state seed
void print(int debuglevel=25, const Option_t *="") const
print the Track Candidate in its "full beauty".
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
bool checkedMinDistance() const
Check if the SpacePointTrackCand has been checked for consecutive hits being far enough apart.
int getPdgCode() const
get pdg code
unsigned short int m_refereeStatus
bit-field to indicate different properties that are checked by the referee module
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
void removeSpacePoint(int indexInTrackCand)
remove a SpacePoint (and its sorting parameter) from the SpacePointTrackCand
BELLE2_DEFINE_EXCEPTION(SPTCIndexOutOfBounds, "Trying to acces a SpacePoint from a SpacePointTrackCand via an" " index that is out of bounds!")
Exception thrown, when trying to access SpacePoints by their index inside of SpacePointTrackCand,...
double getQualityIndicator() const
returns the current status of the estimated quality of this track candidate.
unsigned short int getRefereeStatus(unsigned short int bitmask=USHRT_MAX) const
Return the refere status code of the SpacePointTrackCand.
bool checkedSameSensors() const
Check if the SpacePointTrackCand has been checked for consecutive hits on same sensor.
void setCovSeed(const TMatrixDSym &cov)
set the covariance matrix seed
std::vector< constBelle2::SpacePoint * >::const_iterator end() const
returns a const_iterator (end()) for easily looping over hits of SpacePointTrackCand.
void setFamily(short family)
assign family identifier
int getMcTrackID() const
get the MC Track ID
void clearRefereeStatus()
clear the referee status.
void removeRefereeStatus(unsigned short int bitmask)
remove a referee status
bool m_flightDirection
direction of flight.
std::vector< const SpacePoint * > m_trackSpacePoints
pointers to SpacePoints in the datastore
bool checkedForCurling() const
check if the TrackCand has been checked for Curling.
RefereeStatusBit
Status information that can be set to indicate several properties of the SpacePointTrackCand.
@ c_curlingTrack
bit 8: SPTC is curling (resp.
@ c_checkedTrueHits
bit 5: All SpacePoints of the SPTC have a relation to at least one TrueHit.
@ c_removedHits
bit 4: SpacePoints were removed from this SPTC.
@ c_omittedClusters
bit 9: Not all Clusters of the genfit::TrackCand have been used to create this SPTC.
@ c_hitsLowDistance
bit 3: SPTC has two (or more) SpacePoints that are not far enough apart.
@ c_checkedClean
bit 1: SPTC shows no 'problematic' behaviour.
@ c_singleClustersSPs
bit 10: SPTC contains single Cluster SpacePoints.
@ c_checkedMinDistance
bit 7: It has been checked if two consecutive SpacePoints are far enough apart.
@ c_initialState
This is the initialState, which will always be set in the beginning and at reset.
@ c_hasFittedRecoTrack
bit 13: SPTC is related to a RecoTrack which has a successful fit.
@ c_isActive
bit 11: SPTC is active (i.e.
@ c_checkedSameSensors
bit 6: It has been checked, if two consecutive SpacePoints are on the same sensor for this SPTC.
@ c_checkedByReferee
bit 0: SPTC has been checked by a Referee (all possible tests).
@ c_isReserved
bit 12: SPTC is reserved (i.e.
@ c_hitsOnSameSensor
bit 2: SPTC has two (or more) SpacePoints on same sensor.
unsigned int size() const
get the number of hits (space points) in the track candidate
int m_pdg
PDG code of particle.
bool operator<(const SpacePointTrackCand &rhs) const
Overloading the less operator to compare SPTCs based on their quality index.
bool isCurling() const
get if the TrackCand is curling.
bool hasHitsOnSameSensor() const
Check if the SpacePointTrackCand contains consecutive SpacePoints that are on the same sensor WARNING...
std::vector< double > m_sortingParameters
sorting Parameters, can be used to sort the SpacePoints.
SpacePointTrackCand()=default
Empty constructor with default values, including it to be active.
BELLE2_DEFINE_EXCEPTION(UnsupportedDetType, "The Detector Type is not supported by this class. Supported are: PXD and SVD")
Exception thrown, when an Unsupported Detector Type occurs.
void addSpacePoint(const SpacePoint *newSP, double sortParam)
add a new SpacePoint and its according sorting parameter to the track candidate
void setRefereeStatus(unsigned short int bitmask)
set referee status (resets the complete to the passed status!)
void setTrackStubIndex(int trackStubInd)
set TrackStub index
bool isPartOfCurlingTrack() const
check if the TrackCand is part of a curling TrackCand.
bool isOutgoing() const
check if particle is outgoing (simply returns member m_flightDirection)!
int m_MCTrackID
track ID from MC simulation
int getTrackStubIndex() const
get TrackStub Index
void resetRefereeStatus()
resets the referee status to the initial value
BELLE2_DEFINE_EXCEPTION(SPTCSortingParameterSizeInvalid, "Trying to modify SortingParameters, but number of new SortingParameters differs from number of SpacePoints")
Exception thrown, when the size of the vector containing the spacePoints has a different size than th...
const std::vector< const Belle2::SpacePoint * > getHitsInRange(int firstInd, int lastInd) const
get hits (SpacePoints) in range (indices of SpacePoint inside SpacePointTrackCand) including first in...
bool hasRefereeStatus(unsigned int short bitmask) const
Check if the SpacePointTrackCand has the status characterized by the bitmask.
const std::vector< double > getSortingParametersInRange(int firstIndex, int lastIndex) const
get the sorting parameters in range (indices of SpacePoints inside SpacePointTrackCand) including fir...
std::string getRefereeStatusString(std::string delimiter=" ") const
get the refereeStatus as a string (easier to read than an unsigned short int)
TMatrixDSym m_cov6D
global momentum plus position state (seed) covariance matrix
bool operator==(const SpacePointTrackCand &rhs) const
Checks the equality of the pointers to the contained SpacePoints (pdg-code and charge estimate are no...
double getChargeSeed() const
get charge
const TVectorD & getStateSeed() const
get state seed as 6D vector
void setFlightDirection(bool direction)
set the direction of flight (true is outgoing, false is ingoing).
TVectorD m_state6D
global momentum plus position state (seed) vector
bool hasHitsLowDistance() const
Check if consecutive SpacePoints are far enough apart throughout the SpacePointTrackCand WARNING: doe...
void addRefereeStatus(unsigned short int bitmask)
add a referee status
void setPdgCode(int pdgCode)
set a hypothesis for the particle by setting a pdgcode (will also set the appropriate charge)
bool hasRemovedHits() const
Check if a SpacePointTrackCand has removed hits (i.e.
const std::vector< const Belle2::SpacePoint * > getSortedHits() const
get hits (space points) sorted by their respective sorting parameter
void setQualityIndicator(const double newIndicator)
sets the new status of the estimated quality of this track candidate.
void setChargeSeed(double charge)
Setter for assumed charge of tracked particle.
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
Abstract base class for different kinds of events.