Belle II Software  release-06-00-14
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 #include <TVector3.h>
25 
26 // USHRT_MAX
27 #include <climits>
28 
29 namespace Belle2 {
41  class SpacePointTrackCand final : public RelationsObject {
42 
43  public:
44 
48  BELLE2_DEFINE_EXCEPTION(UnsupportedDetType, "The Detector Type is not supported by this class. Supported are: PXD and SVD");
49 
53  BELLE2_DEFINE_EXCEPTION(SPTCIndexOutOfBounds, "Trying to acces a SpacePoint from a SpacePointTrackCand via an"\
54  " index that is out of bounds!");
55 
59  BELLE2_DEFINE_EXCEPTION(SPTCSortingParameterSizeInvalid,
60  "Trying to modify SortingParameters, but number of new SortingParameters differs from number of SpacePoints");
61 
84  c_isActive = 2048,
85  c_isReserved = 4096,
86  c_hasFittedRecoTrack = 1 << 13,
89  };
90 
97  SpacePointTrackCand() = default;
98 
107  explicit SpacePointTrackCand(const std::vector<const Belle2::SpacePoint*>& spacePoints, int pdgCode = 0, double charge = 0,
108  int mcTrackID = -1);
109 
110 
115  bool operator == (const SpacePointTrackCand& rhs);
116 
117 
121  const std::vector<const Belle2::SpacePoint*>& getHits() const { return m_trackSpacePoints; }
122 
126  const std::vector<const Belle2::SpacePoint*> getSortedHits() const;
127 
129  std::vector<const Belle2::SpacePoint*>::const_iterator begin() const { return m_trackSpacePoints.begin(); }
130 
132  std::vector<const Belle2::SpacePoint*>::const_iterator end() const { return m_trackSpacePoints.end(); }
133 
139  const std::vector<const Belle2::SpacePoint*> getHitsInRange(int firstInd, int lastInd) const;
140 
144  unsigned int getNHits() const { return m_trackSpacePoints.size(); }
145 
149  unsigned int size() const { return m_trackSpacePoints.size(); }
150 
154  int getPdgCode() const { return m_pdg; }
155 
159  double getChargeSeed() const { return m_q; }
160 
162  const TMatrixDSym& getCovSeed() const { return m_cov6D; }
163 
165  const TVectorD& getStateSeed() const { return m_state6D; }
166 
168  const TVector3 getPosSeed() const { return TVector3(m_state6D[0], m_state6D[1], m_state6D[2]); }
169 
171  const TVector3 getMomSeed() const { return TVector3(m_state6D[3], m_state6D[4], m_state6D[5]); }
172 
176  const std::vector<double>& getSortingParameters() const { return m_sortingParameters; }
177 
183  const std::vector<double> getSortingParametersInRange(int firstIndex, int lastIndex) const;
184 
186  int getTrackStubIndex() const { return m_iTrackStub; }
187 
191  int getMcTrackID() const { return m_MCTrackID; }
192 
196  int getMcTrackId() const { return m_MCTrackID; }
197 
202  unsigned short int getRefereeStatus(unsigned short int bitmask = USHRT_MAX) const { return m_refereeStatus & bitmask; }
203 
207  bool hasRefereeStatus(unsigned int short bitmask) const { return (m_refereeStatus & bitmask) == bitmask; }
208 
212  double getQualityIndicator() const { return m_qualityIndicator; }
213 
219 
224 
230 
235 
241 
245  bool isOutgoing() const { return m_flightDirection; }
246 
251  bool isCurling() const { return hasRefereeStatus(c_curlingTrack); }
252 
254  bool checkedForCurling() const { return m_iTrackStub != -1; }
255 
257  bool isPartOfCurlingTrack() const { return m_iTrackStub > 0; }
258 
263  void print(int debuglevel = 150, const Option_t* = "") const;
264 
270  std::string getRefereeStatusString(std::string delimiter = " ") const;
271 
275  short getFamily() const { return m_family; }
276 
280  void setFamily(short family) { m_family = family; }
281 
285  void setSortingParameters(const std::vector<double>& sortParams);
286 
290  void setPdgCode(int pdgCode);
291 
293  void setChargeSeed(double charge) { m_q = charge; }
294 
298  void set6DSeed(const TVectorD& state6D) { m_state6D = state6D; }
299 
303  void setCovSeed(const TMatrixDSym& cov) { m_cov6D = cov; }
304 
311  void setQualityIndicator(const double newIndicator) { m_qualityIndicator = newIndicator; }
312 
316  void addSpacePoint(const SpacePoint* newSP, double sortParam)
317  {
318  m_trackSpacePoints.push_back(newSP);
319  m_sortingParameters.push_back(sortParam);
320  }
321 
325  void setFlightDirection(bool direction) { m_flightDirection = direction; }
326 
328  void setTrackStubIndex(int trackStubInd) { m_iTrackStub = trackStubInd; }
329 
331  void setRefereeStatus(unsigned short int bitmask) { m_refereeStatus = bitmask; }
332 
334  void addRefereeStatus(unsigned short int bitmask) { m_refereeStatus |= bitmask; }
335 
337  void removeRefereeStatus(unsigned short int bitmask) { m_refereeStatus &= (~bitmask); }
338 
341 
344 
346  void removeSpacePoint(int indexInTrackCand);
347 
350  bool operator <(const SpacePointTrackCand& rhs) const { return m_qualityIndicator < rhs.m_qualityIndicator; }
351 
352  protected:
356  std::vector<const SpacePoint*> m_trackSpacePoints;
357 
361  std::vector<double> m_sortingParameters;
362 
363 
367  short m_family = -1;
368 
372  int m_pdg = 0;
373 
377  int m_MCTrackID = -1;
378 
382  TVectorD m_state6D = TVectorD(6);
383 
387  TMatrixDSym m_cov6D = TMatrixDSym(6);
388 
392  double m_q = 0;
393 
397  bool m_flightDirection = true;
398 
406  int m_iTrackStub = -1;
407 
411  unsigned short int m_refereeStatus = c_isActive;
412 
419  double m_qualityIndicator = 0.5;
420 
421  // last members added: RefereeStatutsBit(5), m_refereeProperties(5) m_iTrackStub(4), m_flightDirection(3), m_sortingParameters (2), m_qualityIndicator
423  };
425 }
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
int getMcTrackId() const
get the MC Track ID (same writing as in genfit::TrackCand)
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.
int m_iTrackStub
Index of TrackStub in a curling Track Candidate.
void setSortingParameters(const std::vector< double > &sortParams)
set the sorting parameters
void set6DSeed(const TVectorD &state6D)
set the 6D state seed
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
std::vector< const Belle2::SpacePoint * >::const_iterator end() const
returns a const_iterator (end()) for easily looping over hits of SpacePointTrackCand.
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
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
const TVector3 getMomSeed() const
get momentum seed as TVector3
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.
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
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.
bool operator==(const SpacePointTrackCand &rhs)
Checks the equality of the pointers to the contained SpacePoints (pdg-code and charge estimate are no...
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)!
std::vector< const Belle2::SpacePoint * >::const_iterator begin() const
returns a const_iterator (begin()) for easily looping over hits of SpacePointTrackCand.
int m_MCTrackID
track ID from MC simulation
void print(int debuglevel=150, const Option_t *="") const
print the Track Candidate in its "full beauty".
int getTrackStubIndex() const
get TrackStub Index
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
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...
const TVectorD & getStateSeed() const
get state seed as 6D vector
std::string getRefereeStatusString(std::string delimiter=" ") const
get the refereeStatus as a string (easier to read than an unsigned short int)
const std::vector< double > & getSortingParameters() const
get the sorting parameters
TMatrixDSym m_cov6D
global momentum plus position state (seed) covariance matrix
double getChargeSeed() const
get charge
const TVector3 getPosSeed() const
get position seed as TVector3
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.