Belle II Software  release-06-02-00
RecoTrack.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/datastore/StoreArray.h>
12 #include <framework/datastore/RelationsObject.h>
13 #include <framework/core/FrameworkExceptions.h>
14 
15 #include <genfit/Track.h>
16 
17 #include <tracking/dataobjects/RecoHitInformation.h>
18 
19 #include <boost/optional.hpp>
20 
21 #include <string>
22 #include <vector>
23 
24 namespace genfit {
25  class TrackCand;
26  class AbsTrackRep;
27 }
28 
29 namespace Belle2 {
35  class RecoTrackGenfitAccess;
36 
37  BELLE2_DEFINE_EXCEPTION(NoTrackFitResult, "No track fit result available for this hit (e.g. DAF has removed it).")
38 
39 
76  class RecoTrack : public RelationsObject {
78  friend class RecoTrackGenfitAccess;
79 
80  private:
97 
98  public:
103  c_undefined,
104  c_matched,
105  c_clone,
106  c_background,
107  c_ghost
108  };
109 
125  static void registerRequiredRelations(
126  StoreArray<RecoTrack>& recoTracks,
127  std::string const& pxdHitsStoreArrayName = "",
128  std::string const& svdHitsStoreArrayName = "",
129  std::string const& cdcHitsStoreArrayName = "",
130  std::string const& bklmHitsStoreArrayName = "",
131  std::string const& eklmHitsStoreArrayName = "",
132  std::string const& recoHitInformationStoreArrayName = "");
133 
135  RecoTrack() { }
136 
150  RecoTrack(const TVector3& seedPosition, const TVector3& seedMomentum, const short int seedCharge,
151  const std::string& storeArrayNameOfCDCHits = "",
152  const std::string& storeArrayNameOfSVDHits = "",
153  const std::string& storeArrayNameOfPXDHits = "",
154  const std::string& storeArrayNameOfBKLMHits = "",
155  const std::string& storeArrayNameOfEKLMHits = "",
156  const std::string& storeArrayNameOfRecoHitInformation = "");
157 
159  RecoTrack(const RecoTrack&) = delete;
161  RecoTrack& operator=(RecoTrack const&) = delete;
162 
178  static RecoTrack* createFromTrackCand(const genfit::TrackCand& trackCand,
179  const std::string& storeArrayNameOfRecoTracks = "",
180  const std::string& storeArrayNameOfCDCHits = "",
181  const std::string& storeArrayNameOfSVDHits = "",
182  const std::string& storeArrayNameOfPXDHits = "",
183  const std::string& storeArrayNameOfBKLMHits = "",
184  const std::string& storeArrayNameOfEKLMHits = "",
185  const std::string& storeArrayNameOfRecoHitInformation = "",
186  const bool recreateSortingParameters = false
187  );
188 
192  genfit::TrackCand createGenfitTrackCand() const;
193 
198  RecoTrack* copyToStoreArrayUsing(StoreArray<RecoTrack>& storeArray, const TVector3& position,
199  const TVector3& momentum, short charge,
200  const TMatrixDSym& covariance, double timeSeed) const;
201 
206  RecoTrack* copyToStoreArrayUsingSeeds(StoreArray<RecoTrack>& storeArray) const;
207 
213  RecoTrack* copyToStoreArray(StoreArray<RecoTrack>& storeArray) const;
214 
226  size_t addHitsFromRecoTrack(const RecoTrack* recoTrack, unsigned int sortingParameterOffset = 0,
227  bool reversed = false, boost::optional<double> optionalMinimalWeight = boost::none);
228 
238  bool addCDCHit(const UsedCDCHit* cdcHit, const unsigned int sortingParameter,
239  RightLeftInformation rightLeftInformation = RightLeftInformation::c_undefinedRightLeftInformation,
240  OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
241  {
242  return addHit(cdcHit, rightLeftInformation, foundByTrackFinder, sortingParameter);
243  }
244 
253  bool addPXDHit(const UsedPXDHit* pxdHit, const unsigned int sortingParameter,
254  OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
255  {
256  return addHit(pxdHit, foundByTrackFinder, sortingParameter);
257  }
258 
267  bool addSVDHit(const UsedSVDHit* svdHit, const unsigned int sortingParameter,
268  OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
269  {
270  return addHit(svdHit, foundByTrackFinder, sortingParameter);
271  }
272 
281  bool addBKLMHit(const UsedBKLMHit* bklmHit, const unsigned int sortingParameter,
282  OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
283  {
284  return addHit(bklmHit, foundByTrackFinder, sortingParameter);
285  }
286 
295  bool addEKLMHit(const UsedEKLMHit* eklmHit, const unsigned int sortingParameter,
296  OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
297  {
298  return addHit(eklmHit, foundByTrackFinder, sortingParameter);
299  }
300 
306  template<class HitType>
308  {
309  RelationVector<RecoHitInformation> relatedHitInformationToHit = hit->template getRelationsFrom<RecoHitInformation>
310  (m_storeArrayNameOfRecoHitInformation);
311 
312  for (RecoHitInformation& recoHitInformation : relatedHitInformationToHit) {
313  // cppcheck-suppress useStlAlgorithm
314  if (recoHitInformation.getRelatedFrom<RecoTrack>(this->getArrayName()) == this) {
315  // cppcheck-suppress returnDanglingLifetime
316  return &recoHitInformation;
317  }
318  }
319 
320  return nullptr;
321  }
322 
323  // Hits Information Questioning
325  template <class HitType>
326  TrackingDetector getTrackingDetector(const HitType* hit) const
327  {
328  RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
329  return recoHitInformation->getTrackingDetector();
330  }
331 
333  template <class HitType>
335  {
336  RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
337  return recoHitInformation->getRightLeftInformation();
338  }
339 
341  template <class HitType>
342  OriginTrackFinder getFoundByTrackFinder(const HitType* hit) const
343  {
344  RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
345  return recoHitInformation->getFoundByTrackFinder();
346  }
347 
349  template <class HitType>
350  unsigned int getSortingParameter(const HitType* hit) const
351  {
352  RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
353  return recoHitInformation->getSortingParameter();
354  }
355 
357  template <class HitType>
358  void setRightLeftInformation(const HitType* hit, RightLeftInformation rightLeftInformation)
359  {
360  RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
361  recoHitInformation->setRightLeftInformation(rightLeftInformation);
362  setDirtyFlag();
363  }
364 
366  template <class HitType>
367  void setFoundByTrackFinder(const HitType* hit, OriginTrackFinder originTrackFinder)
368  {
369  RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
370  recoHitInformation->setFoundByTrackFinder(originTrackFinder);
371  }
372 
374  template <class HitType>
375  void setSortingParameter(const HitType* hit, unsigned int sortingParameter)
376  {
377  RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
378  recoHitInformation->setSortingParameter(sortingParameter);
379  setDirtyFlag();
380  }
381 
386  const genfit::TrackPoint* getCreatedTrackPoint(const RecoHitInformation* recoHitInformation) const;
387 
388  // Hits Added Questioning
390  bool hasCDCHits() const { return getRelatedFrom<UsedCDCHit>(m_storeArrayNameOfCDCHits) != nullptr; }
391 
393  bool hasSVDHits() const { return getRelatedFrom<UsedSVDHit>(m_storeArrayNameOfSVDHits) != nullptr; }
394 
396  bool hasPXDHits() const { return getRelatedFrom<UsedPXDHit>(m_storeArrayNameOfPXDHits) != nullptr; }
397 
399  bool hasBKLMHits() const { return getRelatedFrom<UsedBKLMHit>(m_storeArrayNameOfBKLMHits) != nullptr; }
400 
402  bool hasEKLMHits() const { return getRelatedFrom<UsedEKLMHit>(m_storeArrayNameOfEKLMHits) != nullptr; }
403 
405  template <class HitType>
406  bool hasHit(const HitType* hit) const
407  {
408  const RelationVector<RecoTrack>& relatedTracksToHit = hit->template getRelationsTo<RecoTrack>(getArrayName());
409  return std::find_if(relatedTracksToHit.begin(), relatedTracksToHit.end(), [this](const RecoTrack & recoTrack) {
410  return &recoTrack == this;
411  }) != relatedTracksToHit.end();
412  }
413 
414  // Hits Questioning
416  unsigned int getNumberOfCDCHits() const { return getNumberOfHitsOfGivenType<UsedCDCHit>(m_storeArrayNameOfCDCHits); }
417 
419  unsigned int getNumberOfSVDHits() const { return getNumberOfHitsOfGivenType<UsedSVDHit>(m_storeArrayNameOfSVDHits); }
420 
422  unsigned int getNumberOfPXDHits() const { return getNumberOfHitsOfGivenType<UsedPXDHit>(m_storeArrayNameOfPXDHits); }
423 
425  unsigned int getNumberOfBKLMHits() const { return getNumberOfHitsOfGivenType<UsedBKLMHit>(m_storeArrayNameOfBKLMHits); }
426 
428  unsigned int getNumberOfEKLMHits() const { return getNumberOfHitsOfGivenType<UsedEKLMHit>(m_storeArrayNameOfEKLMHits); }
429 
431  unsigned int getNumberOfTotalHits() const
432  {
433  return getNumberOfCDCHits() + getNumberOfPXDHits() +
434  getNumberOfSVDHits() + getNumberOfBKLMHits() + getNumberOfEKLMHits();
435  }
436 
438  unsigned int getNumberOfTrackingHits() const
439  {
440  return getNumberOfCDCHits() + getNumberOfPXDHits() +
441  getNumberOfSVDHits();
442  }
443 
445  std::vector<Belle2::RecoTrack::UsedCDCHit*> getCDCHitList() const { return getHitList<UsedCDCHit>(m_storeArrayNameOfCDCHits); }
446 
448  std::vector<Belle2::RecoTrack::UsedSVDHit*> getSVDHitList() const { return getHitList<UsedSVDHit>(m_storeArrayNameOfSVDHits); }
449 
451  std::vector<Belle2::RecoTrack::UsedPXDHit*> getPXDHitList() const { return getHitList<UsedPXDHit>(m_storeArrayNameOfPXDHits); }
452 
454  std::vector<Belle2::RecoTrack::UsedBKLMHit*> getBKLMHitList() const { return getHitList<UsedBKLMHit>(m_storeArrayNameOfBKLMHits); }
455 
457  std::vector<Belle2::RecoTrack::UsedEKLMHit*> getEKLMHitList() const { return getHitList<UsedEKLMHit>(m_storeArrayNameOfEKLMHits); }
458 
460  std::vector<Belle2::RecoTrack::UsedCDCHit*> getSortedCDCHitList() const { return getSortedHitList<UsedCDCHit>(m_storeArrayNameOfCDCHits); }
461 
463  std::vector<Belle2::RecoTrack::UsedSVDHit*> getSortedSVDHitList() const { return getSortedHitList<UsedSVDHit>(m_storeArrayNameOfSVDHits); }
464 
466  std::vector<Belle2::RecoTrack::UsedPXDHit*> getSortedPXDHitList() const { return getSortedHitList<UsedPXDHit>(m_storeArrayNameOfPXDHits); }
467 
469  std::vector<Belle2::RecoTrack::UsedBKLMHit*> getSortedBKLMHitList() const { return getSortedHitList<UsedBKLMHit>(m_storeArrayNameOfBKLMHits); }
470 
472  std::vector<Belle2::RecoTrack::UsedEKLMHit*> getSortedEKLMHitList() const { return getSortedHitList<UsedEKLMHit>(m_storeArrayNameOfEKLMHits); }
473 
474  // Seed Helix Functionality
476  TVector3 getPositionSeed() const
477  {
478  const TVectorD& seed = m_genfitTrack.getStateSeed();
479  return TVector3(seed(0), seed(1), seed(2));
480  }
481 
483  TVector3 getMomentumSeed() const
484  {
485  const TVectorD& seed = m_genfitTrack.getStateSeed();
486  return TVector3(seed(3), seed(4), seed(5));
487  }
488 
490  const TVectorD& getStateSeed() const
491  {
492  return m_genfitTrack.getStateSeed();
493  }
494 
496  short int getChargeSeed() const { return m_charge; }
497 
499  double getTimeSeed() const { return m_genfitTrack.getTimeSeed(); }
500 
502  std::tuple<TVector3, TVector3, short> extractTrackState() const;
503 
505  void setPositionAndMomentum(const TVector3& positionSeed, const TVector3& momentumSeed)
506  {
507  m_genfitTrack.setStateSeed(positionSeed, momentumSeed);
508  deleteFittedInformation();
509  }
510 
512  void setChargeSeed(const short int chargeSeed)
513  {
514  m_charge = chargeSeed;
515  deleteFittedInformation();
516  }
517 
519  void setTimeSeed(const double timeSeed)
520  {
521  m_genfitTrack.setTimeSeed(timeSeed);
522  deleteFittedInformation();
523  }
524 
526  const TMatrixDSym& getSeedCovariance() const { return m_genfitTrack.getCovSeed(); }
527 
529  void setSeedCovariance(const TMatrixDSym& seedCovariance) { m_genfitTrack.setCovSeed(seedCovariance); }
530 
531  // Fitting
533  bool wasFitSuccessful(const genfit::AbsTrackRep* representation = nullptr) const;
534 
536  const genfit::FitStatus* getTrackFitStatus(const genfit::AbsTrackRep* representation = nullptr) const
537  {
538  checkDirtyFlag();
539  return m_genfitTrack.getFitStatus(representation);
540  }
541 
543  bool hasTrackFitStatus(const genfit::AbsTrackRep* representation = nullptr) const;
544 
547  {
548  checkDirtyFlag();
549  return m_genfitTrack.getCardinalRep();
550  }
551 
553  const std::vector<genfit::AbsTrackRep*>& getRepresentations() const
554  {
555  checkDirtyFlag();
556  return m_genfitTrack.getTrackReps();
557  }
558 
565  genfit::AbsTrackRep* getTrackRepresentationForPDG(int pdgCode);
566 
573  std::vector<RecoHitInformation*> getRecoHitInformations(bool getSorted = false) const;
574 
579  const genfit::MeasuredStateOnPlane& getMeasuredStateOnPlaneFromFirstHit(const genfit::AbsTrackRep* representation = nullptr) const;
580 
585  const genfit::MeasuredStateOnPlane& getMeasuredStateOnPlaneFromLastHit(const genfit::AbsTrackRep* representation = nullptr) const;
586 
591  const genfit::MeasuredStateOnPlane& getMeasuredStateOnPlaneFromRecoHit(const RecoHitInformation* recoHitInfo,
592  const genfit::AbsTrackRep* representation = nullptr) const;
593 
597  const genfit::MeasuredStateOnPlane& getMeasuredStateOnPlaneClosestTo(const TVector3& closestPoint,
598  const genfit::AbsTrackRep* representation = nullptr);
599 
603  void prune();
604 
606  const std::vector<genfit::TrackPoint*>& getHitPointsWithMeasurement() const
607  {
608  checkDirtyFlag();
609  return m_genfitTrack.getPointsWithMeasurement();
610  }
611 
613  bool getDirtyFlag() const { return m_dirtyFlag; }
614 
616 
620  void setDirtyFlag(const bool& dirtyFlag = true)
621  {
622  m_dirtyFlag = dirtyFlag;
623  if (dirtyFlag) {
624  deleteFittedInformation();
625  }
626  }
627 
628  // Store Array Names
630  const std::string& getStoreArrayNameOfCDCHits() const { return m_storeArrayNameOfCDCHits; }
631 
633  const std::string& getStoreArrayNameOfSVDHits() const { return m_storeArrayNameOfSVDHits; }
634 
636  const std::string& getStoreArrayNameOfPXDHits() const { return m_storeArrayNameOfPXDHits; }
637 
639  const std::string& getStoreArrayNameOfBKLMHits() const { return m_storeArrayNameOfBKLMHits; }
640 
642  const std::string& getStoreArrayNameOfEKLMHits() const { return m_storeArrayNameOfEKLMHits; }
643 
645  const std::string& getStoreArrayNameOfRecoHitInformation() const { return m_storeArrayNameOfRecoHitInformation; }
646 
653  template<class HitType>
654  void mapOnHits(const std::string& storeArrayNameOfHits,
655  std::function<void(RecoHitInformation&, HitType*)> const& mapFunction,
656  std::function<bool(const RecoHitInformation&, const HitType*)> const& pickFunction)
657  {
658  RelationVector<RecoHitInformation> relatedHitInformation = getRelationsTo<RecoHitInformation>
659  (m_storeArrayNameOfRecoHitInformation);
660 
661  for (RecoHitInformation& hitInformation : relatedHitInformation) {
662  HitType* const hit = hitInformation.getRelatedTo<HitType>(storeArrayNameOfHits);
663  if (hit != nullptr && pickFunction(hitInformation, hit)) {
664  mapFunction(hitInformation, hit);
665  }
666  }
667  }
668 
675  template<class HitType>
676  void mapOnHits(const std::string& storeArrayNameOfHits,
677  std::function<void(const RecoHitInformation&, const HitType*)> const& mapFunction,
678  std::function<bool(const RecoHitInformation&, const HitType*)> const& pickFunction) const
679  {
680  RelationVector<RecoHitInformation> relatedHitInformation = getRelationsTo<RecoHitInformation>
681  (m_storeArrayNameOfRecoHitInformation);
682 
683  for (const RecoHitInformation& hitInformation : relatedHitInformation) {
684  const HitType* const hit = hitInformation.getRelatedTo<HitType>(storeArrayNameOfHits);
685  if (hit != nullptr && pickFunction(hitInformation, hit)) {
686  mapFunction(hitInformation, hit);
687  }
688  }
689  }
690 
696  template<class HitType>
697  void mapOnHits(const std::string& storeArrayNameOfHits,
698  std::function<void(RecoHitInformation&, HitType*)> const& mapFunction)
699  {
700  mapOnHits<HitType>(storeArrayNameOfHits, mapFunction, [](const RecoHitInformation&, const HitType*) -> bool { return true; });
701  }
702 
708  template<class HitType>
709  void mapOnHits(const std::string& storeArrayNameOfHits,
710  std::function<void(const RecoHitInformation&, const HitType*)> const& mapFunction) const
711  {
712  mapOnHits<HitType>(storeArrayNameOfHits, mapFunction, [](const RecoHitInformation&, const HitType*) -> bool { return true; });
713  }
714 
715  // Matching status
718  {
719  return m_matchingStatus;
720  }
721 
723  void setMatchingStatus(MatchingStatus matchingStatus)
724  {
725  m_matchingStatus = matchingStatus;
726  }
727 
729  float getQualityIndicator() const
730  {
731  return m_qualityIndicator;
732  }
733 
735  void setQualityIndicator(const float qualityIndicator)
736  {
737  m_qualityIndicator = qualityIndicator;
738  }
739 
747  void deleteFittedInformation();
748 
756  void deleteFittedInformationForRepresentation(const genfit::AbsTrackRep* rep);
757 
759  std::string getInfoHTML() const override;
760 
761  private:
765  short int m_charge = 1;
767  std::string m_storeArrayNameOfCDCHits = "";
769  std::string m_storeArrayNameOfSVDHits = "";
771  std::string m_storeArrayNameOfPXDHits = "";
773  std::string m_storeArrayNameOfBKLMHits = "";
775  std::string m_storeArrayNameOfEKLMHits = "";
777  std::string m_storeArrayNameOfRecoHitInformation = "";
780  bool m_dirtyFlag = true;
782  MatchingStatus m_matchingStatus = MatchingStatus::c_undefined;
784  float m_qualityIndicator = NAN;
785 
792  template<class HitType, class ...Args>
793  bool addHit(const HitType* hit, Args&& ... params)
794  {
795  if (hasHit(hit)) {
796  return false;
797  }
798 
799  StoreArray<RecoHitInformation> recoHitInformations(m_storeArrayNameOfRecoHitInformation);
800  RecoHitInformation* newRecoHitInformation = recoHitInformations.appendNew(hit, params...);
801 
802  addHitWithHitInformation(hit, newRecoHitInformation);
803 
804  return true;
805  }
806 
812  template <class HitType>
813  void addHitWithHitInformation(const HitType* hit, RecoHitInformation* recoHitInformation)
814  {
815  hit->addRelationTo(this);
816  addRelationTo(recoHitInformation);
817 
818  setDirtyFlag();
819  }
820 
822  template <class HitType>
824  {
825  RecoHitInformation* recoHitInformation = getRecoHitInformation(hit);
826  if (recoHitInformation == nullptr) {
827  B2FATAL("Queried hit is not in the reco track! Did you prune it?");
828  } else {
829  return recoHitInformation;
830  }
831  }
832 
837  template <class HitType>
838  unsigned int getNumberOfHitsOfGivenType(const std::string& storeArrayNameOfHits) const
839  {
840  return getRelationsFrom<HitType>(storeArrayNameOfHits).size();
841  }
842 
847  template<class HitType>
848  std::vector<HitType*> getSortedHitList(const std::string& storeArrayNameOfHits) const
849  {
850  const RelationVector<RecoHitInformation>& relatedHitInformation = getRelationsTo<RecoHitInformation>
851  (m_storeArrayNameOfRecoHitInformation);
852 
853  std::vector<const RecoHitInformation*> relatedHitInformationAsVector;
854  relatedHitInformationAsVector.reserve(relatedHitInformation.size());
855  for (const RecoHitInformation& hitInformation : relatedHitInformation) {
856  // cppcheck-suppress useStlAlgorithm
857  relatedHitInformationAsVector.push_back(&hitInformation);
858  }
859  std::sort(relatedHitInformationAsVector.begin(), relatedHitInformationAsVector.end(), [](const RecoHitInformation * a,
860  const RecoHitInformation * b) -> bool {
861  return a->getSortingParameter() < b->getSortingParameter();
862  });
863 
864  std::vector<HitType*> hitList;
865  hitList.reserve(relatedHitInformationAsVector.size());
866  for (const RecoHitInformation* hitInformation : relatedHitInformationAsVector) {
867  HitType* relatedHit = hitInformation->getRelatedTo<HitType>(storeArrayNameOfHits);
868  if (relatedHit != nullptr) {
869  hitList.push_back(relatedHit);
870  }
871  }
872  return hitList;
873  }
874 
879  template<class HitType>
880  std::vector<HitType*> getHitList(const std::string& storeArrayNameOfHits) const
881  {
882  RelationVector<HitType> relatedHits = getRelationsFrom<HitType>(storeArrayNameOfHits);
883  std::vector<HitType*> hitList;
884  hitList.reserve(relatedHits.size());
885  for (HitType& hit : relatedHits) {
886  // cppcheck-suppress useStlAlgorithm
887  hitList.push_back(&hit);
888  }
889  // cppcheck-suppress returnDanglingLifetime
890  return hitList;
891  }
892 
894  void checkDirtyFlag() const
895  {
896  if (m_dirtyFlag) {
897  B2DEBUG(100, "Dirty flag is set. The result may not be in sync with the latest changes. Refit the track to be sure.");
898  }
899  }
900 
903  };
904 
913  public:
920  static genfit::Track& getGenfitTrack(RecoTrack& recoTrack);
921 
936  static genfit::AbsTrackRep* createOrReturnRKTrackRep(RecoTrack& recoTrack, int PDGcode);
937  };
938 
940 }
Store one BKLM strip hit as a ROOT object.
Definition: BKLMHit2d.h:32
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
This dataobject is used only for EKLM alignment.
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
This class stores additional information to every CDC/SVD/PXD hit stored in a RecoTrack.
RightLeftInformation getRightLeftInformation() const
Get the right-left-information.
OriginTrackFinder
The TrackFinder which has added the hit to the track.
RightLeftInformation
The RightLeft information of the hit which is only valid for CDC hits.
void setSortingParameter(unsigned int sortingParameter)
Set the sorting parameter.
OriginTrackFinder getFoundByTrackFinder() const
Get which track finder has found the track.
RecoHitDetector getTrackingDetector() const
Get the detector this hit comes from.
void setRightLeftInformation(RightLeftInformation rightLeftInformation)
Set the right-left-information.
RecoHitDetector
The detector this hit comes from (which is of course also visible in the hit type)
unsigned int getSortingParameter() const
Get the sorting parameter.
void setFoundByTrackFinder(OriginTrackFinder foundByTrackFinder)
Set which track finder has found the track.
This class allows access to the genfit::Track of the RecoTrack.
Definition: RecoTrack.h:912
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
Definition: RecoTrack.cc:396
static genfit::AbsTrackRep * createOrReturnRKTrackRep(RecoTrack &recoTrack, int PDGcode)
Checks if a TrackRap for the PDG id of the RecoTrack (and its charge conjugate) does already exit and...
Definition: RecoTrack.cc:401
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
const genfit::FitStatus * getTrackFitStatus(const genfit::AbsTrackRep *representation=nullptr) const
Return the track fit status for the given representation or for the cardinal one. You are not allowed...
Definition: RecoTrack.h:536
ClassDefOverride(RecoTrack, 9)
Making this class a ROOT class.
void setChargeSeed(const short int chargeSeed)
Set the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition: RecoTrack.h:512
TrackingDetector getTrackingDetector(const HitType *hit) const
Return the tracking detector of a given hit (every type) or throws an exception of the hit is not rel...
Definition: RecoTrack.h:326
RecoHitInformation::UsedCDCHit UsedCDCHit
Copy the definitions from the RecoHitInformation to this class.
Definition: RecoTrack.h:88
void mapOnHits(const std::string &storeArrayNameOfHits, std::function< void(RecoHitInformation &, HitType *)> const &mapFunction, std::function< bool(const RecoHitInformation &, const HitType *)> const &pickFunction)
Call a function on all hits of the given type in the store array, that are related to this track.
Definition: RecoTrack.h:654
bool addBKLMHit(const UsedBKLMHit *bklmHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a bklm hit with the given information to the reco track.
Definition: RecoTrack.h:281
void mapOnHits(const std::string &storeArrayNameOfHits, std::function< void(RecoHitInformation &, HitType *)> const &mapFunction)
Call a function on all hits of the given type in the store array, that are related to this track.
Definition: RecoTrack.h:697
void mapOnHits(const std::string &storeArrayNameOfHits, std::function< void(const RecoHitInformation &, const HitType *)> const &mapFunction) const
Call a function on all hits of the given type in the store array, that are related to this track.
Definition: RecoTrack.h:709
bool addCDCHit(const UsedCDCHit *cdcHit, const unsigned int sortingParameter, RightLeftInformation rightLeftInformation=RightLeftInformation::c_undefinedRightLeftInformation, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a cdc hit with the given information to the reco track.
Definition: RecoTrack.h:238
bool hasCDCHits() const
Returns true if the track has cdc hits.
Definition: RecoTrack.h:390
unsigned int getNumberOfBKLMHits() const
Return the number of bklm hits.
Definition: RecoTrack.h:425
void mapOnHits(const std::string &storeArrayNameOfHits, std::function< void(const RecoHitInformation &, const HitType *)> const &mapFunction, std::function< bool(const RecoHitInformation &, const HitType *)> const &pickFunction) const
Call a function on all hits of the given type in the store array, that are related to this track.
Definition: RecoTrack.h:676
RecoHitInformation::RecoHitDetector TrackingDetector
Copy the definitions from the RecoHitInformation to this class.
Definition: RecoTrack.h:84
std::vector< Belle2::RecoTrack::UsedSVDHit * > getSVDHitList() const
Return an unsorted list of svd hits.
Definition: RecoTrack.h:448
bool addEKLMHit(const UsedEKLMHit *eklmHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds an eklm hit with the given information to the reco track.
Definition: RecoTrack.h:295
void setPositionAndMomentum(const TVector3 &positionSeed, const TVector3 &momentumSeed)
Set the position and momentum seed of the reco track. ATTENTION: This is not the fitted position or m...
Definition: RecoTrack.h:505
void setSortingParameter(const HitType *hit, unsigned int sortingParameter)
Set the sorting parameter or throws an exception of the hit is not related to the track....
Definition: RecoTrack.h:375
std::vector< Belle2::RecoTrack::UsedPXDHit * > getSortedPXDHitList() const
Return a sorted list of pxd hits. Sorted by the sortingParameter.
Definition: RecoTrack.h:466
bool addPXDHit(const UsedPXDHit *pxdHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a pxd hit with the given information to the reco track.
Definition: RecoTrack.h:253
RecoTrack & operator=(RecoTrack const &)=delete
Delete the copy construtr.
std::vector< Belle2::RecoTrack::UsedBKLMHit * > getBKLMHitList() const
Return an unsorted list of bklm hits.
Definition: RecoTrack.h:454
RecoHitInformation * getRecoHitInformationSafely(HitType *hit) const
Returns the reco hit information for a given hit or throws an exception if the hit is not related to ...
Definition: RecoTrack.h:823
RecoHitInformation::UsedEKLMHit UsedEKLMHit
Copy the definitions from the RecoHitInformation to this class.
Definition: RecoTrack.h:96
MatchingStatus
Enum for the matching status of this reco track (set by the matching modules in the tracking package)...
Definition: RecoTrack.h:102
const std::vector< genfit::TrackPoint * > & getHitPointsWithMeasurement() const
Return a list of measurements and track points, which can be used e.g. to extrapolate....
Definition: RecoTrack.h:606
void setRightLeftInformation(const HitType *hit, RightLeftInformation rightLeftInformation)
Set the right left information or throws an exception of the hit is not related to the track....
Definition: RecoTrack.h:358
void setDirtyFlag(const bool &dirtyFlag=true)
Set to true, if you want to rebuild the measurements and do the fit independent on changes of the hit...
Definition: RecoTrack.h:620
const std::vector< genfit::AbsTrackRep * > & getRepresentations() const
Return a list of track representations. You are not allowed to modify or delete them!
Definition: RecoTrack.h:553
unsigned int getNumberOfEKLMHits() const
Return the number of eklm hits.
Definition: RecoTrack.h:428
RightLeftInformation getRightLeftInformation(const HitType *hit) const
Return the right left information of a given hit (every type) or throws an exception of the hit is no...
Definition: RecoTrack.h:334
unsigned int getNumberOfSVDHits() const
Return the number of svd hits.
Definition: RecoTrack.h:419
OriginTrackFinder getFoundByTrackFinder(const HitType *hit) const
Return the found by track finder flag for the given hit (every type) or throws an exception of the hi...
Definition: RecoTrack.h:342
const std::string & getStoreArrayNameOfCDCHits() const
Name of the store array of the cdc hits.
Definition: RecoTrack.h:630
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
Definition: RecoTrack.h:416
bool addHit(const HitType *hit, Args &&... params)
Add a generic hit with the given parameters for the reco hit information.
Definition: RecoTrack.h:793
unsigned int getNumberOfTrackingHits() const
Return the number of cdc + svd + pxd hits.
Definition: RecoTrack.h:438
RecoHitInformation::UsedBKLMHit UsedBKLMHit
Copy the definitions from the RecoHitInformation to this class.
Definition: RecoTrack.h:94
bool hasHit(const HitType *hit) const
Returns true if the given hit is in the track.
Definition: RecoTrack.h:406
std::vector< Belle2::RecoTrack::UsedPXDHit * > getPXDHitList() const
Return an unsorted list of pxd hits.
Definition: RecoTrack.h:451
void setMatchingStatus(MatchingStatus matchingStatus)
Set the matching status (used by the TrackMatcher module)
Definition: RecoTrack.h:723
RecoTrack(const RecoTrack &)=delete
Delete the copy construtr.
unsigned int getSortingParameter(const HitType *hit) const
Return the sorting parameter for a given hit (every type) or throws an exception of the hit is not re...
Definition: RecoTrack.h:350
const std::string & getStoreArrayNameOfBKLMHits() const
Name of the store array of the bklm hits.
Definition: RecoTrack.h:639
bool hasPXDHits() const
Returns true if the track has pxd hits.
Definition: RecoTrack.h:396
const std::string & getStoreArrayNameOfSVDHits() const
Name of the store array of the svd hits.
Definition: RecoTrack.h:633
std::vector< Belle2::RecoTrack::UsedCDCHit * > getCDCHitList() const
Return an unsorted list of cdc hits.
Definition: RecoTrack.h:445
void setTimeSeed(const double timeSeed)
Set the time seed. ATTENTION: This is not the fitted time.
Definition: RecoTrack.h:519
unsigned int getNumberOfHitsOfGivenType(const std::string &storeArrayNameOfHits) const
Get the number of hits for the given hit type in the store array that are related to this track.
Definition: RecoTrack.h:838
void setFoundByTrackFinder(const HitType *hit, OriginTrackFinder originTrackFinder)
Set the found by track finder flag or throws an exception of the hit is not related to the track.
Definition: RecoTrack.h:367
TVector3 getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
Definition: RecoTrack.h:483
bool hasEKLMHits() const
Returns true if the track has eklm hits.
Definition: RecoTrack.h:402
void setSeedCovariance(const TMatrixDSym &seedCovariance)
Set the covariance of the seed. ATTENTION: This is not the fitted covariance.
Definition: RecoTrack.h:529
float getQualityIndicator() const
Get the quality index attached to this RecoTrack given by one of the reconstruction algorithms....
Definition: RecoTrack.h:729
void addHitWithHitInformation(const HitType *hit, RecoHitInformation *recoHitInformation)
Add the needed relations for adding a generic hit with the given hit information.
Definition: RecoTrack.h:813
void setQualityIndicator(const float qualityIndicator)
Set the quality index attached to this RecoTrack. 0 means likely fake.
Definition: RecoTrack.h:735
MatchingStatus getMatchingStatus() const
Return the matching status set by the TrackMatcher module.
Definition: RecoTrack.h:717
std::vector< Belle2::RecoTrack::UsedBKLMHit * > getSortedBKLMHitList() const
Return a sorted list of bklm hits. Sorted by the sortingParameter.
Definition: RecoTrack.h:469
genfit::AbsTrackRep * getCardinalRepresentation() const
Get a pointer to the cardinal track representation. You are not allowed to modify or delete it!
Definition: RecoTrack.h:546
std::vector< Belle2::RecoTrack::UsedEKLMHit * > getSortedEKLMHitList() const
Return a sorted list of eklm hits. Sorted by the sortingParameter.
Definition: RecoTrack.h:472
bool getDirtyFlag() const
This returns true, if a hit was added after the last fit and measurement creation and a refit should ...
Definition: RecoTrack.h:613
TVector3 getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
Definition: RecoTrack.h:476
const TVectorD & getStateSeed() const
Return the state seed in the form posX, posY, posZ, momX, momY, momZ. ATTENTION: This is not the fitt...
Definition: RecoTrack.h:490
const std::string & getStoreArrayNameOfRecoHitInformation() const
Name of the store array of the reco hit informations.
Definition: RecoTrack.h:645
std::vector< HitType * > getHitList(const std::string &storeArrayNameOfHits) const
Return an unsorted list of hits of the given type in the store array that are related to this track.
Definition: RecoTrack.h:880
std::vector< Belle2::RecoTrack::UsedSVDHit * > getSortedSVDHitList() const
Return a sorted list of svd hits. Sorted by the sortingParameter.
Definition: RecoTrack.h:463
const TMatrixDSym & getSeedCovariance() const
Return the covariance matrix of the seed. ATTENTION: This is not the fitted covariance.
Definition: RecoTrack.h:526
bool hasBKLMHits() const
Returns true if the track has bklm hits.
Definition: RecoTrack.h:399
const std::string & getStoreArrayNameOfPXDHits() const
Name of the store array of the pxd hits.
Definition: RecoTrack.h:636
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition: RecoTrack.h:496
const std::string & getStoreArrayNameOfEKLMHits() const
Name of the store array of the eklm hits.
Definition: RecoTrack.h:642
RecoHitInformation::RightLeftInformation RightLeftInformation
Copy the definitions from the RecoHitInformation to this class.
Definition: RecoTrack.h:82
RecoHitInformation::OriginTrackFinder OriginTrackFinder
Copy the definitions from the RecoHitInformation to this class.
Definition: RecoTrack.h:86
genfit::Track m_genfitTrack
Internal storage for the genfit track.
Definition: RecoTrack.h:763
RecoHitInformation * getRecoHitInformation(HitType *hit) const
Return the reco hit information for a generic hit from the storeArray.
Definition: RecoTrack.h:307
RecoHitInformation::UsedSVDHit UsedSVDHit
Copy the definitions from the RecoHitInformation to this class.
Definition: RecoTrack.h:90
RecoTrack()
Empty constructor for ROOT. Do not use!
Definition: RecoTrack.h:135
unsigned int getNumberOfPXDHits() const
Return the number of pxd hits.
Definition: RecoTrack.h:422
std::vector< Belle2::RecoTrack::UsedEKLMHit * > getEKLMHitList() const
Return an unsorted list of eklm hits.
Definition: RecoTrack.h:457
std::vector< HitType * > getSortedHitList(const std::string &storeArrayNameOfHits) const
Return a sorted list of hits of the given type in the store array that are related to this track.
Definition: RecoTrack.h:848
std::vector< Belle2::RecoTrack::UsedCDCHit * > getSortedCDCHitList() const
Return a sorted list of cdc hits. Sorted by the sortingParameter.
Definition: RecoTrack.h:460
bool addSVDHit(const UsedSVDHit *svdHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a svd hit with the given information to the reco track.
Definition: RecoTrack.h:267
void checkDirtyFlag() const
Helper: Check the dirty flag and produce a warning, whenever a fit result is accessed.
Definition: RecoTrack.h:894
RecoHitInformation::UsedPXDHit UsedPXDHit
Copy the definitions from the RecoHitInformation to this class.
Definition: RecoTrack.h:92
double getTimeSeed() const
Return the time seed stored in the reco track. ATTENTION: This is not the fitted time.
Definition: RecoTrack.h:499
bool hasSVDHits() const
Returns true if the track has svd hits.
Definition: RecoTrack.h:393
unsigned int getNumberOfTotalHits() const
Return the number of cdc + svd + pxd + bklm + eklm hits.
Definition: RecoTrack.h:431
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
iterator end()
Return iterator to last entry +1.
iterator begin()
Return iterator to first entry.
Defines interface for accessing relations of objects in StoreArray.
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:28
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
Class where important numbers and properties of a fit can be stored.
Definition: FitStatus.h:80
#StateOnPlane with additional covariance matrix.
Track candidate – seed values and indices.
Definition: TrackCand.h:69
Object containing AbsMeasurement and AbsFitterInfo objects.
Definition: TrackPoint.h:46
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:71
#define BELLE2_DEFINE_EXCEPTION(ClassName, Message)
Macro that defines an exception with the given message template.
Abstract base class for different kinds of events.
Defines for I/O streams used for error and debug printing.