Belle II Software  release-05-02-19
SpacePointTrackCand.h
1 /**************************************************************************
2 * BASF2 (Belle Analysis Framework 2) *
3 * Copyright(C) 2014 - Belle II Collaboration *
4 * *
5 * Author: The Belle II Collaboration *
6 * Contributors: Thomas Madlener, Jakob Lettenbichler *
7 * *
8 * This software is provided "as is" without any warranty. *
9 **************************************************************************/
10 
11 #pragma once
12 
13 // framework
14 #include <framework/datastore/RelationsObject.h>
15 #include <framework/core/FrameworkExceptions.h>
16 
17 // SpacePoint
18 #include <tracking/spacePointCreation/SpacePoint.h>
19 
20 // stl
21 #include <vector>
22 
23 // ROOT
24 #include <TVectorD.h>
25 #include <TMatrixD.h>
26 #include <TVector3.h>
27 
28 // USHRT_MAX
29 #include <climits>
30 
31 namespace Belle2 {
43  class SpacePointTrackCand final : public RelationsObject {
44 
45  public:
46 
50  BELLE2_DEFINE_EXCEPTION(UnsupportedDetType, "The Detector Type is not supported by this class. Supported are: PXD and SVD");
51 
55  BELLE2_DEFINE_EXCEPTION(SPTCIndexOutOfBounds, "Trying to acces a SpacePoint from a SpacePointTrackCand via an"\
56  " index that is out of bounds!");
57 
61  BELLE2_DEFINE_EXCEPTION(SPTCSortingParameterSizeInvalid,
62  "Trying to modify SortingParameters, but number of new SortingParameters differs from number of SpacePoints");
63 
70  enum RefereeStatusBit {
71  c_checkedByReferee = 1,
72  c_checkedClean = 2,
73  c_hitsOnSameSensor = 4,
77  c_removedHits = 16,
83  c_curlingTrack = 256,
86  c_isActive = 2048,
87  c_isReserved = 4096,
88  c_hasFittedRecoTrack = 1 << 13,
91  };
92 
99  SpacePointTrackCand() = default;
100 
109  explicit SpacePointTrackCand(const std::vector<const Belle2::SpacePoint*>& spacePoints, int pdgCode = 0, double charge = 0,
110  int mcTrackID = -1);
111 
112 
117  bool operator == (const SpacePointTrackCand& rhs);
118 
119 
123  const std::vector<const Belle2::SpacePoint*>& getHits() const { return m_trackSpacePoints; }
124 
128  const std::vector<const Belle2::SpacePoint*> getSortedHits() const;
129 
131  std::vector<const Belle2::SpacePoint*>::const_iterator begin() const { return m_trackSpacePoints.begin(); }
132 
134  std::vector<const Belle2::SpacePoint*>::const_iterator end() const { return m_trackSpacePoints.end(); }
135 
141  const std::vector<const Belle2::SpacePoint*> getHitsInRange(int firstInd, int lastInd) const;
142 
146  unsigned int getNHits() const { return m_trackSpacePoints.size(); }
147 
151  unsigned int size() const { return m_trackSpacePoints.size(); }
152 
156  int getPdgCode() const { return m_pdg; }
157 
161  double getChargeSeed() const { return m_q; }
162 
164  const TMatrixDSym& getCovSeed() const { return m_cov6D; }
165 
167  const TVectorD& getStateSeed() const { return m_state6D; }
168 
170  const TVector3 getPosSeed() const { return TVector3(m_state6D[0], m_state6D[1], m_state6D[2]); }
171 
173  const TVector3 getMomSeed() const { return TVector3(m_state6D[3], m_state6D[4], m_state6D[5]); }
174 
178  const std::vector<double>& getSortingParameters() const { return m_sortingParameters; }
179 
185  const std::vector<double> getSortingParametersInRange(int firstIndex, int lastIndex) const;
186 
188  int getTrackStubIndex() const { return m_iTrackStub; }
189 
193  int getMcTrackID() const { return m_MCTrackID; }
194 
198  int getMcTrackId() const { return m_MCTrackID; }
199 
204  unsigned short int getRefereeStatus(unsigned short int bitmask = USHRT_MAX) const { return m_refereeStatus & bitmask; }
205 
209  bool hasRefereeStatus(unsigned int short bitmask) const { return (m_refereeStatus & bitmask) == bitmask; }
210 
214  double getQualityIndicator() const { return m_qualityIndicator; }
215 
221 
226 
231  bool hasHitsLowDistance() const { return hasRefereeStatus(c_hitsLowDistance); }
232 
237 
242  bool hasRemovedHits() const { return hasRefereeStatus(c_removedHits); }
243 
247  bool isOutgoing() const { return m_flightDirection; }
248 
253  bool isCurling() const { return hasRefereeStatus(c_curlingTrack); }
254 
256  bool checkedForCurling() const { return m_iTrackStub != -1; }
257 
259  bool isPartOfCurlingTrack() const { return m_iTrackStub > 0; }
260 
265  void print(int debuglevel = 150, const Option_t* = "") const;
266 
272  std::string getRefereeStatusString(std::string delimiter = " ") const;
273 
277  short getFamily() const { return m_family; }
278 
282  void setFamily(short family) { m_family = family; }
283 
287  void setSortingParameters(const std::vector<double>& sortParams);
288 
292  void setPdgCode(int pdgCode);
293 
295  void setChargeSeed(double charge) { m_q = charge; }
296 
300  void set6DSeed(const TVectorD& state6D) { m_state6D = state6D; }
301 
305  void setCovSeed(const TMatrixDSym& cov) { m_cov6D = cov; }
306 
313  void setQualityIndicator(const double newIndicator) { m_qualityIndicator = newIndicator; }
314 
318  void addSpacePoint(const SpacePoint* newSP, double sortParam)
319  {
320  m_trackSpacePoints.push_back(newSP);
321  m_sortingParameters.push_back(sortParam);
322  }
323 
327  void setFlightDirection(bool direction) { m_flightDirection = direction; }
328 
330  void setTrackStubIndex(int trackStubInd) { m_iTrackStub = trackStubInd; }
331 
333  void setRefereeStatus(unsigned short int bitmask) { m_refereeStatus = bitmask; }
334 
336  void addRefereeStatus(unsigned short int bitmask) { m_refereeStatus |= bitmask; }
337 
339  void removeRefereeStatus(unsigned short int bitmask) { m_refereeStatus &= (~bitmask); }
340 
342  void clearRefereeStatus() { m_refereeStatus = 0; }
343 
346 
348  void removeSpacePoint(int indexInTrackCand);
349 
352  bool operator <(const SpacePointTrackCand& rhs) const { return m_qualityIndicator < rhs.m_qualityIndicator; }
353 
354  protected:
358  std::vector<const SpacePoint*> m_trackSpacePoints;
359 
363  std::vector<double> m_sortingParameters;
364 
365 
369  short m_family = -1;
370 
374  int m_pdg = 0;
375 
379  int m_MCTrackID = -1;
380 
384  TVectorD m_state6D = TVectorD(6);
385 
389  TMatrixDSym m_cov6D = TMatrixDSym(6);
390 
394  double m_q = 0;
395 
399  bool m_flightDirection = true;
400 
408  int m_iTrackStub = -1;
409 
413  unsigned short int m_refereeStatus = c_isActive;
414 
421  double m_qualityIndicator = 0.5;
422 
423  // last members added: RefereeStatutsBit(5), m_refereeProperties(5) m_iTrackStub(4), m_flightDirection(3), m_sortingParameters (2), m_qualityIndicator
425  };
427 }
Belle2::EvtPDLUtil::charge
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:46
Belle2::SpacePointTrackCand::getSortedHits
const std::vector< const Belle2::SpacePoint * > getSortedHits() const
get hits (space points) sorted by their respective sorting parameter
Definition: SpacePointTrackCand.cc:103
Belle2::SpacePointTrackCand::isCurling
bool isCurling() const
get if the TrackCand is curling.
Definition: SpacePointTrackCand.h:261
Belle2::SpacePointTrackCand::hasHitsOnSameSensor
bool hasHitsOnSameSensor() const
Check if the SpacePointTrackCand contains consecutive SpacePoints that are on the same sensor WARNING...
Definition: SpacePointTrackCand.h:228
Belle2::SpacePointTrackCand::getHitsInRange
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...
Definition: SpacePointTrackCand.cc:69
Belle2::SpacePointTrackCand::getQualityIndicator
double getQualityIndicator() const
returns the current status of the estimated quality of this track candidate.
Definition: SpacePointTrackCand.h:222
Belle2::SpacePointTrackCand::checkedForCurling
bool checkedForCurling() const
check if the TrackCand has been checked for Curling.
Definition: SpacePointTrackCand.h:264
Belle2::SpacePointTrackCand::operator<
bool operator<(const SpacePointTrackCand &rhs) const
Overloading the less operator to compare SPTCs based on their quality index.
Definition: SpacePointTrackCand.h:360
Belle2::SpacePointTrackCand::getMcTrackId
int getMcTrackId() const
get the MC Track ID (same writing as in genfit::TrackCand)
Definition: SpacePointTrackCand.h:206
Belle2::SpacePointTrackCand::setRefereeStatus
void setRefereeStatus(unsigned short int bitmask)
set referee status (resets the complete to the passed status!)
Definition: SpacePointTrackCand.h:341
Belle2::SpacePointTrackCand::addRefereeStatus
void addRefereeStatus(unsigned short int bitmask)
add a referee status
Definition: SpacePointTrackCand.h:344
Belle2::SpacePointTrackCand::m_cov6D
TMatrixDSym m_cov6D
global momentum plus position state (seed) covariance matrix
Definition: SpacePointTrackCand.h:397
Belle2::SpacePointTrackCand::setSortingParameters
void setSortingParameters(const std::vector< double > &sortParams)
set the sorting parameters
Definition: SpacePointTrackCand.cc:136
Belle2::SpacePointTrackCand::getMomSeed
const TVector3 getMomSeed() const
get momentum seed as TVector3
Definition: SpacePointTrackCand.h:181
Belle2::SpacePointTrackCand::removeRefereeStatus
void removeRefereeStatus(unsigned short int bitmask)
remove a referee status
Definition: SpacePointTrackCand.h:347
Belle2::RelationsInterface::ClassDef
ClassDef(RelationsInterface, 0)
defines interface for accessing relations of objects in StoreArray.
Belle2::SpacePointTrackCand::operator==
bool operator==(const SpacePointTrackCand &rhs)
Checks the equality of the pointers to the contained SpacePoints (pdg-code and charge estimate are no...
Definition: SpacePointTrackCand.cc:41
Belle2::SpacePointTrackCand::c_isActive
@ c_isActive
bit 11: SPTC is active (i.e.
Definition: SpacePointTrackCand.h:94
Belle2::SpacePointTrackCand::c_checkedSameSensors
@ c_checkedSameSensors
bit 6: It has been checked, if two consecutive SpacePoints are on the same sensor for this SPTC.
Definition: SpacePointTrackCand.h:89
Belle2::SpacePointTrackCand::setCovSeed
void setCovSeed(const TMatrixDSym &cov)
set the covariance matrix seed
Definition: SpacePointTrackCand.h:313
Belle2::SpacePointTrackCand::print
void print(int debuglevel=150, const Option_t *="") const
print the Track Candidate in its "full beauty".
Definition: SpacePointTrackCand.cc:160
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::SpacePointTrackCand::m_pdg
int m_pdg
PDG code of particle.
Definition: SpacePointTrackCand.h:382
Belle2::SpacePointTrackCand::setTrackStubIndex
void setTrackStubIndex(int trackStubInd)
set TrackStub index
Definition: SpacePointTrackCand.h:338
Belle2::SpacePointTrackCand::m_MCTrackID
int m_MCTrackID
track ID from MC simulation
Definition: SpacePointTrackCand.h:387
Belle2::SpacePointTrackCand::m_iTrackStub
int m_iTrackStub
Index of TrackStub in a curling Track Candidate.
Definition: SpacePointTrackCand.h:416
Belle2::SpacePointTrackCand::c_checkedTrueHits
@ c_checkedTrueHits
bit 5: All SpacePoints of the SPTC have a relation to at least one TrueHit.
Definition: SpacePointTrackCand.h:86
Belle2::SpacePointTrackCand::getNHits
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
Definition: SpacePointTrackCand.h:154
Belle2::SpacePointTrackCand::c_curlingTrack
@ c_curlingTrack
bit 8: SPTC is curling (resp.
Definition: SpacePointTrackCand.h:91
Belle2::SpacePointTrackCand::getSortingParametersInRange
const std::vector< double > getSortingParametersInRange(int firstIndex, int lastIndex) const
get the sorting parameters in range (indices of SpacePoints inside SpacePointTrackCand) including fir...
Definition: SpacePointTrackCand.cc:86
Belle2::SpacePointTrackCand::getRefereeStatusString
std::string getRefereeStatusString(std::string delimiter=" ") const
get the refereeStatus as a string (easier to read than an unsigned short int)
Definition: SpacePointTrackCand.cc:211
Belle2::SpacePointTrackCand::set6DSeed
void set6DSeed(const TVectorD &state6D)
set the 6D state seed
Definition: SpacePointTrackCand.h:308
Belle2::SpacePointTrackCand::end
std::vector< const Belle2::SpacePoint * >::const_iterator end() const
returns a const_iterator (end()) for easily looping over hits of SpacePointTrackCand.
Definition: SpacePointTrackCand.h:142
Belle2::SpacePointTrackCand::removeSpacePoint
void removeSpacePoint(int indexInTrackCand)
remove a SpacePoint (and its sorting parameter) from the SpacePointTrackCand
Definition: SpacePointTrackCand.cc:146
Belle2::SpacePointTrackCand::setFamily
void setFamily(short family)
assign family identifier
Definition: SpacePointTrackCand.h:290
Belle2::SpacePointTrackCand::getPdgCode
int getPdgCode() const
get pdg code
Definition: SpacePointTrackCand.h:164
Belle2::SpacePointTrackCand::getHits
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
Definition: SpacePointTrackCand.h:131
Belle2::SpacePointTrackCand::size
unsigned int size() const
get the number of hits (space points) in the track candidate
Definition: SpacePointTrackCand.h:159
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SpacePointTrackCand::begin
std::vector< const Belle2::SpacePoint * >::const_iterator begin() const
returns a const_iterator (begin()) for easily looping over hits of SpacePointTrackCand.
Definition: SpacePointTrackCand.h:139
Belle2::SpacePointTrackCand::c_singleClustersSPs
@ c_singleClustersSPs
bit 10: SPTC contains single Cluster SpacePoints.
Definition: SpacePointTrackCand.h:93
Belle2::SpacePointTrackCand::resetRefereeStatus
void resetRefereeStatus()
resets the referee status to the initial value
Definition: SpacePointTrackCand.h:353
Belle2::SpacePointTrackCand::setChargeSeed
void setChargeSeed(double charge)
Setter for assumed charge of tracked particle.
Definition: SpacePointTrackCand.h:303
Belle2::SpacePointTrackCand::setFlightDirection
void setFlightDirection(bool direction)
set the direction of flight (true is outgoing, false is ingoing).
Definition: SpacePointTrackCand.h:335
Belle2::SpacePointTrackCand::hasHitsLowDistance
bool hasHitsLowDistance() const
Check if consecutive SpacePoints are far enough apart throughout the SpacePointTrackCand WARNING: doe...
Definition: SpacePointTrackCand.h:239
Belle2::SpacePointTrackCand::m_sortingParameters
std::vector< double > m_sortingParameters
sorting Parameters, can be used to sort the SpacePoints.
Definition: SpacePointTrackCand.h:371
Belle2::SpacePointTrackCand::c_hitsOnSameSensor
@ c_hitsOnSameSensor
bit 2: SPTC has two (or more) SpacePoints on same sensor.
Definition: SpacePointTrackCand.h:81
Belle2::SpacePointTrackCand::m_state6D
TVectorD m_state6D
global momentum plus position state (seed) vector
Definition: SpacePointTrackCand.h:392
Belle2::SpacePointTrackCand::m_qualityIndicator
double m_qualityIndicator
An estimation for the quality of the track.
Definition: SpacePointTrackCand.h:429
Belle2::SpacePointTrackCand::setPdgCode
void setPdgCode(int pdgCode)
set a hypothesis for the particle by setting a pdgcode (will also set the appropriate charge)
Definition: SpacePointTrackCand.cc:128
Belle2::SpacePointTrackCand::isPartOfCurlingTrack
bool isPartOfCurlingTrack() const
check if the TrackCand is part of a curling TrackCand.
Definition: SpacePointTrackCand.h:267
Belle2::SpacePointTrackCand::hasRefereeStatus
bool hasRefereeStatus(unsigned int short bitmask) const
Check if the SpacePointTrackCand has the status characterized by the bitmask.
Definition: SpacePointTrackCand.h:217
Belle2::SpacePointTrackCand::c_removedHits
@ c_removedHits
bit 4: SpacePoints were removed from this SPTC.
Definition: SpacePointTrackCand.h:85
Belle2::SpacePointTrackCand::checkedSameSensors
bool checkedSameSensors() const
Check if the SpacePointTrackCand has been checked for consecutive hits on same sensor.
Definition: SpacePointTrackCand.h:233
Belle2::SpacePointTrackCand::getSortingParameters
const std::vector< double > & getSortingParameters() const
get the sorting parameters
Definition: SpacePointTrackCand.h:186
Belle2::SpacePointTrackCand::getChargeSeed
double getChargeSeed() const
get charge
Definition: SpacePointTrackCand.h:169
Belle2::SpacePointTrackCand::RefereeStatusBit
RefereeStatusBit
Status information that can be set to indicate several properties of the SpacePointTrackCand.
Definition: SpacePointTrackCand.h:78
Belle2::SpacePointTrackCand::getPosSeed
const TVector3 getPosSeed() const
get position seed as TVector3
Definition: SpacePointTrackCand.h:178
Belle2::SpacePointTrackCand::c_isReserved
@ c_isReserved
bit 12: SPTC is reserved (i.e.
Definition: SpacePointTrackCand.h:95
Belle2::SpacePointTrackCand::SpacePointTrackCand
SpacePointTrackCand()=default
Empty constructor with default values, including it to be active.
Belle2::SpacePointTrackCand::clearRefereeStatus
void clearRefereeStatus()
clear the referee status.
Definition: SpacePointTrackCand.h:350
Belle2::SpacePointTrackCand::checkedMinDistance
bool checkedMinDistance() const
Check if the SpacePointTrackCand has been checked for consecutive hits being far enough apart.
Definition: SpacePointTrackCand.h:244
Belle2::RelationsObject
RelationsInterface< TObject > RelationsObject
Provides interface for getting/adding relations to objects in StoreArrays.
Definition: RelationsObject.h:443
Belle2::SpacePointTrackCand::getRefereeStatus
unsigned short int getRefereeStatus(unsigned short int bitmask=USHRT_MAX) const
Return the refere status code of the SpacePointTrackCand.
Definition: SpacePointTrackCand.h:212
Belle2::SpacePointTrackCand::c_omittedClusters
@ c_omittedClusters
bit 9: Not all Clusters of the genfit::TrackCand have been used to create this SPTC.
Definition: SpacePointTrackCand.h:92
Belle2::SpacePointTrackCand::m_q
double m_q
charge of the particle in units of elementary charge
Definition: SpacePointTrackCand.h:402
Belle2::SpacePointTrackCand::c_checkedMinDistance
@ c_checkedMinDistance
bit 7: It has been checked if two consecutive SpacePoints are far enough apart.
Definition: SpacePointTrackCand.h:90
Belle2::SpacePointTrackCand::isOutgoing
bool isOutgoing() const
check if particle is outgoing (simply returns member m_flightDirection)!
Definition: SpacePointTrackCand.h:255
Belle2::SpacePointTrackCand::addSpacePoint
void addSpacePoint(const SpacePoint *newSP, double sortParam)
add a new SpacePoint and its according sorting parameter to the track candidate
Definition: SpacePointTrackCand.h:326
Belle2::SpacePointTrackCand::c_initialState
@ c_initialState
This is the initialState, which will always be set in the beginning and at reset.
Definition: SpacePointTrackCand.h:98
Belle2::SpacePointTrackCand::getStateSeed
const TVectorD & getStateSeed() const
get state seed as 6D vector
Definition: SpacePointTrackCand.h:175
Belle2::SpacePointTrackCand::getFamily
short getFamily() const
return family identifier
Definition: SpacePointTrackCand.h:285
Belle2::SpacePointTrackCand::getCovSeed
const TMatrixDSym & getCovSeed() const
get the covariance matrix seed (6D).
Definition: SpacePointTrackCand.h:172
Belle2::SpacePointTrackCand::m_trackSpacePoints
std::vector< const SpacePoint * > m_trackSpacePoints
pointers to SpacePoints in the datastore
Definition: SpacePointTrackCand.h:366
Belle2::SpacePointTrackCand::c_checkedClean
@ c_checkedClean
bit 1: SPTC shows no 'problematic' behaviour.
Definition: SpacePointTrackCand.h:80
Belle2::SpacePointTrackCand::getTrackStubIndex
int getTrackStubIndex() const
get TrackStub Index
Definition: SpacePointTrackCand.h:196
Belle2::SpacePointTrackCand::m_family
short m_family
identifier for tracks that share at least two SpacePoints.
Definition: SpacePointTrackCand.h:377
Belle2::SpacePointTrackCand::m_flightDirection
bool m_flightDirection
direction of flight.
Definition: SpacePointTrackCand.h:407
Belle2::SpacePointTrackCand::c_hasFittedRecoTrack
@ c_hasFittedRecoTrack
bit 13: SPTC is related to a RecoTrack which has a successful fit.
Definition: SpacePointTrackCand.h:96
Belle2::SpacePointTrackCand::getMcTrackID
int getMcTrackID() const
get the MC Track ID
Definition: SpacePointTrackCand.h:201
Belle2::SpacePointTrackCand::m_refereeStatus
unsigned short int m_refereeStatus
bit-field to indicate different properties that are checked by the referee module
Definition: SpacePointTrackCand.h:421
Belle2::SpacePointTrackCand::c_hitsLowDistance
@ c_hitsLowDistance
bit 3: SPTC has two (or more) SpacePoints that are not far enough apart.
Definition: SpacePointTrackCand.h:84
Belle2::SpacePointTrackCand::c_checkedByReferee
@ c_checkedByReferee
bit 0: SPTC has been checked by a Referee (all possible tests).
Definition: SpacePointTrackCand.h:79
Belle2::SpacePointTrackCand
Storage for (VXD) SpacePoint-based track candidates.
Definition: SpacePointTrackCand.h:51
Belle2::SpacePointTrackCand::setQualityIndicator
void setQualityIndicator(const double newIndicator)
sets the new status of the estimated quality of this track candidate.
Definition: SpacePointTrackCand.h:321
Belle2::SpacePointTrackCand::BELLE2_DEFINE_EXCEPTION
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.
Belle2::SpacePointTrackCand::hasRemovedHits
bool hasRemovedHits() const
Check if a SpacePointTrackCand has removed hits (i.e.
Definition: SpacePointTrackCand.h:250