Belle II Software development
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#include <framework/geometry/VectorUtil.h>
15
16#include <genfit/Track.h>
17
18#include <tracking/dataobjects/RecoHitInformation.h>
19
20#include <Math/Vector3D.h>
21
22#include <optional>
23#include <string>
24#include <vector>
25
26namespace genfit {
27 class TrackCand;
28 class AbsTrackRep;
29}
30
31namespace Belle2 {
36
38
39 BELLE2_DEFINE_EXCEPTION(NoTrackFitResult, "No track fit result available for this hit (e.g. DAF has removed it).")
40 BELLE2_DEFINE_EXCEPTION(NoStateOnPlaneFound, "No measured state on plane for any track point found.")
41
79 class RecoTrack : public RelationsObject {
82
83 private:
100
101 public:
106 c_undefined, //until the matcher module sets it
107 c_matched, // hit pattern and charge are both correct
108 c_matchedWrongCharge, // hit pattern is correct, but the charge is wrong
109 c_clone, //a clone with the correct charge
110 c_cloneWrongCharge, //a clone with the wrong charge
111 c_background,
112 c_ghost
113 };
114
130 static void registerRequiredRelations(
131 StoreArray<RecoTrack>& recoTracks,
132 std::string const& pxdHitsStoreArrayName = "",
133 std::string const& svdHitsStoreArrayName = "",
134 std::string const& cdcHitsStoreArrayName = "",
135 std::string const& bklmHitsStoreArrayName = "",
136 std::string const& eklmHitsStoreArrayName = "",
137 std::string const& recoHitInformationStoreArrayName = "");
138
141
155 RecoTrack(const ROOT::Math::XYZVector& seedPosition, const ROOT::Math::XYZVector& seedMomentum, const short int seedCharge,
156 const std::string& storeArrayNameOfPXDHits = "",
157 const std::string& storeArrayNameOfSVDHits = "",
158 const std::string& storeArrayNameOfCDCHits = "",
159 const std::string& storeArrayNameOfBKLMHits = "",
160 const std::string& storeArrayNameOfEKLMHits = "",
161 const std::string& storeArrayNameOfRecoHitInformation = "");
162
164 RecoTrack(const RecoTrack&) = delete;
166 RecoTrack& operator=(RecoTrack const&) = delete;
167
183 static RecoTrack* createFromTrackCand(const genfit::TrackCand& trackCand,
184 const std::string& storeArrayNameOfRecoTracks = "",
185 const std::string& storeArrayNameOfPXDHits = "",
186 const std::string& storeArrayNameOfSVDHits = "",
187 const std::string& storeArrayNameOfCDCHits = "",
188 const std::string& storeArrayNameOfBKLMHits = "",
189 const std::string& storeArrayNameOfEKLMHits = "",
190 const std::string& storeArrayNameOfRecoHitInformation = "",
191 const bool recreateSortingParameters = false
192 );
193
197 genfit::TrackCand createGenfitTrackCand() const;
198
203 RecoTrack* copyToStoreArrayUsing(StoreArray<RecoTrack>& storeArray, const ROOT::Math::XYZVector& position,
204 const ROOT::Math::XYZVector& momentum, short charge,
205 const TMatrixDSym& covariance, double timeSeed) const;
206
212
219
231 size_t addHitsFromRecoTrack(const RecoTrack* recoTrack, unsigned int sortingParameterOffset = 0,
232 bool reversed = false, std::optional<double> optionalMinimalWeight = std::nullopt);
233
243 bool addCDCHit(const UsedCDCHit* cdcHit, const unsigned int sortingParameter,
244 RightLeftInformation rightLeftInformation = RightLeftInformation::c_undefinedRightLeftInformation,
245 OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
246 {
247 return addHit(cdcHit, rightLeftInformation, foundByTrackFinder, sortingParameter);
248 }
249
258 bool addPXDHit(const UsedPXDHit* pxdHit, const unsigned int sortingParameter,
259 OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
260 {
261 return addHit(pxdHit, foundByTrackFinder, sortingParameter);
262 }
263
272 bool addSVDHit(const UsedSVDHit* svdHit, const unsigned int sortingParameter,
273 OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
274 {
275 return addHit(svdHit, foundByTrackFinder, sortingParameter);
276 }
277
286 bool addBKLMHit(const UsedBKLMHit* bklmHit, const unsigned int sortingParameter,
287 OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
288 {
289 return addHit(bklmHit, foundByTrackFinder, sortingParameter);
290 }
291
300 bool addEKLMHit(const UsedEKLMHit* eklmHit, const unsigned int sortingParameter,
301 OriginTrackFinder foundByTrackFinder = OriginTrackFinder::c_undefinedTrackFinder)
302 {
303 return addHit(eklmHit, foundByTrackFinder, sortingParameter);
304 }
305
311 template<class HitType>
313 {
314 RelationVector<RecoHitInformation> relatedHitInformationToHit = hit->template getRelationsFrom<RecoHitInformation>
316
317 for (RecoHitInformation& recoHitInformation : relatedHitInformationToHit) {
318 if (recoHitInformation.getRelatedFrom<RecoTrack>(this->getArrayName()) == this) {
319 return &recoHitInformation;
320 }
321 }
322
323 return nullptr;
324 }
325
326 // Hits Information Questioning
328 template <class HitType>
329 TrackingDetector getTrackingDetector(const HitType* hit) const
330 {
331 RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
332 return recoHitInformation->getTrackingDetector();
333 }
334
336 template <class HitType>
338 {
339 RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
340 return recoHitInformation->getRightLeftInformation();
341 }
342
344 template <class HitType>
345 OriginTrackFinder getFoundByTrackFinder(const HitType* hit) const
346 {
347 RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
348 return recoHitInformation->getFoundByTrackFinder();
349 }
350
352 template <class HitType>
353 unsigned int getSortingParameter(const HitType* hit) const
354 {
355 RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
356 return recoHitInformation->getSortingParameter();
357 }
358
360 template <class HitType>
361 void setRightLeftInformation(const HitType* hit, RightLeftInformation rightLeftInformation)
362 {
363 RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
364 recoHitInformation->setRightLeftInformation(rightLeftInformation);
365 setDirtyFlag();
366 }
367
369 template <class HitType>
370 void setFoundByTrackFinder(const HitType* hit, OriginTrackFinder originTrackFinder)
371 {
372 RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
373 recoHitInformation->setFoundByTrackFinder(originTrackFinder);
374 }
375
377 template <class HitType>
378 void setSortingParameter(const HitType* hit, unsigned int sortingParameter)
379 {
380 RecoHitInformation* recoHitInformation = getRecoHitInformationSafely(hit);
381 recoHitInformation->setSortingParameter(sortingParameter);
382 setDirtyFlag();
383 }
384
389 const genfit::TrackPoint* getCreatedTrackPoint(const RecoHitInformation* recoHitInformation) const;
390
391 // Hits Added Questioning
394
397
400
403
406
408 template <class HitType>
409 bool hasHit(const HitType* hit) const
410 {
411 const RelationVector<RecoTrack>& relatedTracksToHit = hit->template getRelationsTo<RecoTrack>(getArrayName());
412 return std::find_if(relatedTracksToHit.begin(), relatedTracksToHit.end(), [this](const RecoTrack & recoTrack) {
413 return &recoTrack == this;
414 }) != relatedTracksToHit.end();
415 }
416
417 // Hits Questioning
420
423
426
429
432
439
441 unsigned int getNumberOfTrackingHits() const
442 {
444 }
445
447 std::vector<Belle2::RecoTrack::UsedPXDHit*> getPXDHitList() const { return getHitList<UsedPXDHit>(m_storeArrayNameOfPXDHits); }
448
450 std::vector<Belle2::RecoTrack::UsedSVDHit*> getSVDHitList() const { return getHitList<UsedSVDHit>(m_storeArrayNameOfSVDHits); }
451
453 std::vector<Belle2::RecoTrack::UsedCDCHit*> getCDCHitList() const { return getHitList<UsedCDCHit>(m_storeArrayNameOfCDCHits); }
454
456 std::vector<Belle2::RecoTrack::UsedBKLMHit*> getBKLMHitList() const { return getHitList<UsedBKLMHit>(m_storeArrayNameOfBKLMHits); }
457
459 std::vector<Belle2::RecoTrack::UsedEKLMHit*> getEKLMHitList() const { return getHitList<UsedEKLMHit>(m_storeArrayNameOfEKLMHits); }
460
462 std::vector<Belle2::RecoTrack::UsedPXDHit*> getSortedPXDHitList() const { return getSortedHitList<UsedPXDHit>(m_storeArrayNameOfPXDHits); }
463
465 std::vector<Belle2::RecoTrack::UsedSVDHit*> getSortedSVDHitList() const { return getSortedHitList<UsedSVDHit>(m_storeArrayNameOfSVDHits); }
466
468 std::vector<Belle2::RecoTrack::UsedCDCHit*> getSortedCDCHitList() const { return getSortedHitList<UsedCDCHit>(m_storeArrayNameOfCDCHits); }
469
471 std::vector<Belle2::RecoTrack::UsedBKLMHit*> getSortedBKLMHitList() const { return getSortedHitList<UsedBKLMHit>(m_storeArrayNameOfBKLMHits); }
472
474 std::vector<Belle2::RecoTrack::UsedEKLMHit*> getSortedEKLMHitList() const { return getSortedHitList<UsedEKLMHit>(m_storeArrayNameOfEKLMHits); }
475
476 // Seed Helix Functionality
478 ROOT::Math::XYZVector getPositionSeed() const
479 {
480 const TVectorD& seed = m_genfitTrack.getStateSeed();
481 return ROOT::Math::XYZVector(seed(0), seed(1), seed(2));
482 }
483
485 ROOT::Math::XYZVector getMomentumSeed() const
486 {
487 const TVectorD& seed = m_genfitTrack.getStateSeed();
488 return ROOT::Math::XYZVector(seed(3), seed(4), seed(5));
489 }
490
492 const TVectorD& getStateSeed() const
493 {
494 return m_genfitTrack.getStateSeed();
495 }
496
503 const genfit::Track& getGenfitTrack() const {return m_genfitTrack;}
504
506 short int getChargeSeed() const { return m_charge; }
507
509 double getTimeSeed() const { return m_genfitTrack.getTimeSeed(); }
510
513 {
515 return m_outgoingArmTime;
516 }
517
524
527 {
529 return m_ingoingArmTime;
530 }
531
538
545
553
556 {
557 return m_hasIngoingArmTime;
558 }
559
562 {
564 }
565
571
574 {
576 }
577
582 void flipTrackDirectionAndCharge(const genfit::AbsTrackRep* representation = nullptr);
583
585 std::tuple<ROOT::Math::XYZVector, ROOT::Math::XYZVector, short> extractTrackState() const;
586
588 void setPositionAndMomentum(const ROOT::Math::XYZVector& positionSeed, const ROOT::Math::XYZVector& momentumSeed)
589 {
590 m_genfitTrack.setStateSeed(XYZToTVector(positionSeed), XYZToTVector(momentumSeed));
592 }
593
595 void setChargeSeed(const short int chargeSeed)
596 {
597 m_charge = chargeSeed;
599 }
600
602 void setTimeSeed(const double timeSeed)
603 {
604 m_genfitTrack.setTimeSeed(timeSeed);
606 }
607
609 const TMatrixDSym& getSeedCovariance() const { return m_genfitTrack.getCovSeed(); }
610
612 void setSeedCovariance(const TMatrixDSym& seedCovariance) { m_genfitTrack.setCovSeed(seedCovariance); }
613
614 // Fitting
616 bool wasFitSuccessful(const genfit::AbsTrackRep* representation = nullptr) const;
617
619 const genfit::FitStatus* getTrackFitStatus(const genfit::AbsTrackRep* representation = nullptr) const
620 {
622 return m_genfitTrack.getFitStatus(representation);
623 }
624
626 bool hasTrackFitStatus(const genfit::AbsTrackRep* representation = nullptr) const;
627
629 genfit::AbsTrackRep* getCardinalRepresentation() const
630 {
632 return m_genfitTrack.getCardinalRep();
633 }
634
636 const std::vector<genfit::AbsTrackRep*>& getRepresentations() const
637 {
639 return m_genfitTrack.getTrackReps();
640 }
641
648 genfit::AbsTrackRep* getTrackRepresentationForPDG(int pdgCode) const;
649
656 std::vector<RecoHitInformation*> getRecoHitInformations(bool getSorted = false) const;
657
662 const genfit::MeasuredStateOnPlane& getMeasuredStateOnPlaneFromFirstHit(const genfit::AbsTrackRep* representation = nullptr) const;
663
668 const genfit::MeasuredStateOnPlane& getMeasuredStateOnPlaneFromLastHit(const genfit::AbsTrackRep* representation = nullptr) const;
669
674 const genfit::MeasuredStateOnPlane& getMeasuredStateOnPlaneFromRecoHit(const RecoHitInformation* recoHitInfo,
675 const genfit::AbsTrackRep* representation = nullptr) const;
676
680 const genfit::MeasuredStateOnPlane& getMeasuredStateOnPlaneClosestTo(const ROOT::Math::XYZVector& closestPoint,
681 const genfit::AbsTrackRep* representation = nullptr);
682
686 void prune();
687
692 void estimateArmTime();
693
702 bool isOutgoingArm(RecoHitInformation::RecoHitDetector pre = RecoHitInformation::RecoHitDetector::c_undefinedTrackingDetector,
703 RecoHitInformation::RecoHitDetector post = RecoHitInformation::RecoHitDetector::c_undefinedTrackingDetector);
704
706 const std::vector<genfit::TrackPoint*>& getHitPointsWithMeasurement() const
707 {
709 return m_genfitTrack.getPointsWithMeasurement();
710 }
711
713 bool getDirtyFlag() const { return m_dirtyFlag; }
714
716
720 void setDirtyFlag(const bool& dirtyFlag = true)
721 {
722 m_dirtyFlag = dirtyFlag;
723 if (dirtyFlag) {
725 }
726 }
727
728 // Store Array Names
730 const std::string& getStoreArrayNameOfPXDHits() const { return m_storeArrayNameOfPXDHits; }
731
733 const std::string& getStoreArrayNameOfSVDHits() const { return m_storeArrayNameOfSVDHits; }
734
736 const std::string& getStoreArrayNameOfCDCHits() const { return m_storeArrayNameOfCDCHits; }
737
739 const std::string& getStoreArrayNameOfBKLMHits() const { return m_storeArrayNameOfBKLMHits; }
740
742 const std::string& getStoreArrayNameOfEKLMHits() const { return m_storeArrayNameOfEKLMHits; }
743
746
749 {
750 const uint recoHitInformationSize = getRecoHitInformations().size();
751 for (auto RecoHitInfo : getRecoHitInformations()) {
752 // The "-1" ensures that the sorting parameter still is in range 0...size-1 instead of 1...size
753 RecoHitInfo->setSortingParameter(recoHitInformationSize - RecoHitInfo->getSortingParameter() - 1);
754 }
755 }
756
763 template<class HitType>
764 void mapOnHits(const std::string& storeArrayNameOfHits,
765 std::function<void(RecoHitInformation&, HitType*)> const& mapFunction,
766 std::function<bool(const RecoHitInformation&, const HitType*)> const& pickFunction)
767 {
770
771 for (RecoHitInformation& hitInformation : relatedHitInformation) {
772 HitType* const hit = hitInformation.getRelatedTo<HitType>(storeArrayNameOfHits);
773 if (hit != nullptr && pickFunction(hitInformation, hit)) {
774 mapFunction(hitInformation, hit);
775 }
776 }
777 }
778
785 template<class HitType>
786 void mapOnHits(const std::string& storeArrayNameOfHits,
787 std::function<void(const RecoHitInformation&, const HitType*)> const& mapFunction,
788 std::function<bool(const RecoHitInformation&, const HitType*)> const& pickFunction) const
789 {
792
793 for (const RecoHitInformation& hitInformation : relatedHitInformation) {
794 const HitType* const hit = hitInformation.getRelatedTo<HitType>(storeArrayNameOfHits);
795 if (hit != nullptr && pickFunction(hitInformation, hit)) {
796 mapFunction(hitInformation, hit);
797 }
798 }
799 }
800
806 template<class HitType>
807 void mapOnHits(const std::string& storeArrayNameOfHits,
808 std::function<void(RecoHitInformation&, HitType*)> const& mapFunction)
809 {
810 mapOnHits<HitType>(storeArrayNameOfHits, mapFunction, [](const RecoHitInformation&, const HitType*) -> bool { return true; });
811 }
812
818 template<class HitType>
819 void mapOnHits(const std::string& storeArrayNameOfHits,
820 std::function<void(const RecoHitInformation&, const HitType*)> const& mapFunction) const
821 {
822 mapOnHits<HitType>(storeArrayNameOfHits, mapFunction, [](const RecoHitInformation&, const HitType*) -> bool { return true; });
823 }
824
825 // Matching status
828 {
829 return m_matchingStatus;
830 }
831
834 {
835 m_matchingStatus = matchingStatus;
836 }
837
840 {
841 return m_qualityIndicator;
842 }
843
845 void setQualityIndicator(const float qualityIndicator)
846 {
847 m_qualityIndicator = qualityIndicator;
848 }
849
852 {
854 }
855
857 void setFlipQualityIndicator(const float qualityIndicator)
858 {
859 m_flipqualityIndicator = qualityIndicator;
860 }
861
863 {
865 }
866
868 void set2ndFlipQualityIndicator(const float qualityIndicator)
869 {
870 m_2ndFlipqualityIndicator = qualityIndicator;
871 }
872
879 void deleteFittedInformation();
880
888 void deleteFittedInformationForRepresentation(const genfit::AbsTrackRep* rep);
889
891 std::string getInfoHTML() const override;
892
893 private:
895 genfit::Track m_genfitTrack;
897 short int m_charge = 1;
917 float m_outgoingArmTime = NAN;
921 float m_ingoingArmTime = NAN;
925 MatchingStatus m_matchingStatus = MatchingStatus::c_undefined;
932 bool m_dirtyFlag = true;
939
946 template<class HitType, class ...Args>
947 bool addHit(const HitType* hit, Args&& ... params)
948 {
949 if (hasHit(hit)) {
950 return false;
951 }
952
954 RecoHitInformation* newRecoHitInformation = recoHitInformations.appendNew(hit, params...);
955
956 addHitWithHitInformation(hit, newRecoHitInformation);
957
958 return true;
959 }
960
966 template <class HitType>
967 void addHitWithHitInformation(const HitType* hit, RecoHitInformation* recoHitInformation)
968 {
969 hit->addRelationTo(this);
970 addRelationTo(recoHitInformation);
971
972 m_isArmTimeComputed = false;
973 m_hasIngoingArmTime = false;
974 m_hasOutgoingArmTime = false;
975 m_outgoingArmTime = NAN;
976 m_ingoingArmTime = NAN;
979
980 setDirtyFlag();
981 }
982
984 template <class HitType>
986 {
987 RecoHitInformation* recoHitInformation = getRecoHitInformation(hit);
988 if (recoHitInformation == nullptr) {
989 B2FATAL("Queried hit is not in the reco track! Did you prune it?");
990 } else {
991 return recoHitInformation;
992 }
993 }
994
999 template <class HitType>
1000 unsigned int getNumberOfHitsOfGivenType(const std::string& storeArrayNameOfHits) const
1001 {
1002 return getRelationsFrom<HitType>(storeArrayNameOfHits).size();
1003 }
1004
1009 template<class HitType>
1010 std::vector<HitType*> getSortedHitList(const std::string& storeArrayNameOfHits) const
1011 {
1014
1015 std::vector<const RecoHitInformation*> relatedHitInformationAsVector;
1016 relatedHitInformationAsVector.reserve(relatedHitInformation.size());
1017 for (const RecoHitInformation& hitInformation : relatedHitInformation) {
1018 // cppcheck-suppress useStlAlgorithm
1019 relatedHitInformationAsVector.push_back(&hitInformation);
1020 }
1021 std::sort(relatedHitInformationAsVector.begin(), relatedHitInformationAsVector.end(), [](const RecoHitInformation * a,
1022 const RecoHitInformation * b) -> bool {
1023 return a->getSortingParameter() < b->getSortingParameter();
1024 });
1025
1026 std::vector<HitType*> hitList;
1027 hitList.reserve(relatedHitInformationAsVector.size());
1028 for (const RecoHitInformation* hitInformation : relatedHitInformationAsVector) {
1029 HitType* relatedHit = hitInformation->getRelatedTo<HitType>(storeArrayNameOfHits);
1030 if (relatedHit != nullptr) {
1031 hitList.push_back(relatedHit);
1032 }
1033 }
1034 return hitList;
1035 }
1036
1041 template<class HitType>
1042 std::vector<HitType*> getHitList(const std::string& storeArrayNameOfHits) const
1043 {
1044 RelationVector<HitType> relatedHits = getRelationsFrom<HitType>(storeArrayNameOfHits);
1045 std::vector<HitType*> hitList;
1046 hitList.reserve(relatedHits.size());
1047 for (HitType& hit : relatedHits) {
1048 // cppcheck-suppress useStlAlgorithm
1049 hitList.push_back(&hit);
1050 }
1051 return hitList;
1052 }
1053
1061
1063 void checkDirtyFlag() const
1064 {
1065 if (m_dirtyFlag) {
1066 B2DEBUG(100, "Dirty flag is set. The result may not be in sync with the latest changes. Refit the track to be sure.");
1067 }
1068 }
1069
1072 };
1073
1082 public:
1089 static genfit::Track& getGenfitTrack(RecoTrack& recoTrack);
1090
1098 static void swapGenfitTrack(RecoTrack& recoTrack, const genfit::Track* track);
1099
1114 static genfit::AbsTrackRep* createOrReturnRKTrackRep(RecoTrack& recoTrack, int PDGcode);
1115 };
1116
1118}
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.
CDCHit UsedCDCHit
Define, use of CDC hits as CDC hits (for symmetry).
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.
EKLMAlignmentHit UsedEKLMHit
Define, use of EKLMHit2d as EKLM hits.
RecoHitDetector
The detector this hit comes from (which is of course also visible in the hit type)
KLMHit2d UsedBKLMHit
Define, use of KLMHit2d as BKLM hits.
PXDCluster UsedPXDHit
Define, use of clusters or true hits for PXD.
SVDCluster UsedSVDHit
Define, use of clusters or true hits for SVD.
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:1081
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
Definition RecoTrack.cc:404
static void swapGenfitTrack(RecoTrack &recoTrack, const genfit::Track *track)
Set the genfit track of a Recotrack copying the information from another genfit track.
Definition RecoTrack.cc:399
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:409
This is the Reconstruction Event-Data Model Track.
Definition RecoTrack.h:79
size_t addHitsFromRecoTrack(const RecoTrack *recoTrack, unsigned int sortingParameterOffset=0, bool reversed=false, std::optional< double > optionalMinimalWeight=std::nullopt)
Add all hits from another RecoTrack to this RecoTrack.
Definition RecoTrack.cc:240
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:595
RecoTrack & operator=(RecoTrack const &)=delete
Delete the copy construtr.
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:329
RecoHitInformation::UsedCDCHit UsedCDCHit
Copy the definitions from the RecoHitInformation to this class.
Definition RecoTrack.h:91
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:764
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:636
const TMatrixDSym & getSeedCovariance() const
Return the covariance matrix of the seed. ATTENTION: This is not the fitted covariance.
Definition RecoTrack.h:609
std::vector< Belle2::RecoTrack::UsedSVDHit * > getSortedSVDHitList() const
Return a sorted list of svd hits. Sorted by the sortingParameter.
Definition RecoTrack.h:465
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:286
float m_2ndFlipqualityIndicator
Quality index for flipping.
Definition RecoTrack.h:915
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:807
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:819
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:243
void deleteFittedInformation()
Delete all fitted information for all representations.
Definition RecoTrack.cc:462
float getInOutArmTimeDifference()
Return the difference between the track times of the ingoing and outgoing arms.
Definition RecoTrack.h:540
std::vector< Belle2::RecoTrack::UsedPXDHit * > getPXDHitList() const
Return an unsorted list of pxd hits.
Definition RecoTrack.h:447
float getOutgoingArmTime()
Return the track time of the outgoing arm.
Definition RecoTrack.h:512
float m_ingoingArmTimeError
Error of the track time of the ingoing arm.
Definition RecoTrack.h:923
bool hasCDCHits() const
Returns true if the track has cdc hits.
Definition RecoTrack.h:399
unsigned int getNumberOfBKLMHits() const
Return the number of bklm hits.
Definition RecoTrack.h:428
const std::string & getStoreArrayNameOfEKLMHits() const
Name of the store array of the eklm hits.
Definition RecoTrack.h:742
float m_flipqualityIndicator
Quality index for flipping.
Definition RecoTrack.h:913
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:786
std::vector< Belle2::RecoTrack::UsedSVDHit * > getSVDHitList() const
Return an unsorted list of svd hits.
Definition RecoTrack.h:450
RecoHitInformation::RecoHitDetector TrackingDetector
Copy the definitions from the RecoHitInformation to this class.
Definition RecoTrack.h:87
static RecoTrack * createFromTrackCand(const genfit::TrackCand &trackCand, const std::string &storeArrayNameOfRecoTracks="", const std::string &storeArrayNameOfPXDHits="", const std::string &storeArrayNameOfSVDHits="", const std::string &storeArrayNameOfCDCHits="", const std::string &storeArrayNameOfBKLMHits="", const std::string &storeArrayNameOfEKLMHits="", const std::string &storeArrayNameOfRecoHitInformation="", const bool recreateSortingParameters=false)
Create a reco track from a genfit::TrackCand and save it to the given store array.
Definition RecoTrack.cc:97
void setPositionAndMomentum(const ROOT::Math::XYZVector &positionSeed, const ROOT::Math::XYZVector &momentumSeed)
Set the position and momentum seed of the reco track. ATTENTION: This is not the fitted position or m...
Definition RecoTrack.h:588
std::string m_storeArrayNameOfCDCHits
Store array name of added CDC hits.
Definition RecoTrack.h:903
friend class RecoTrackGenfitAccess
The RecoTrackGenfitAccess need to access the genfit track (which is intended)!
Definition RecoTrack.h:81
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:300
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:378
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:258
std::vector< Belle2::RecoTrack::UsedCDCHit * > getSortedCDCHitList() const
Return a sorted list of cdc hits. Sorted by the sortingParameter.
Definition RecoTrack.h:468
std::vector< Belle2::RecoTrack::UsedBKLMHit * > getBKLMHitList() const
Return an unsorted list of bklm hits.
Definition RecoTrack.h:456
std::vector< Belle2::RecoTrack::UsedCDCHit * > getCDCHitList() const
Return an unsorted list of cdc hits.
Definition RecoTrack.h:453
const std::string & getStoreArrayNameOfSVDHits() const
Name of the store array of the svd hits.
Definition RecoTrack.h:733
void estimateArmTime()
This function calculates the track time of the ingoing and outgoing arms and their difference.
Definition RecoTrack.cc:633
MatchingStatus m_matchingStatus
Flag used in the MCRecoTracksMatcherModule.
Definition RecoTrack.h:925
ROOT::Math::XYZVector getPositionSeed() const
Return the position seed stored in the reco track. ATTENTION: This is not the fitted position.
Definition RecoTrack.h:478
bool m_hasIngoingArmTime
Internal storage of the final ingoing arm time is set.
Definition RecoTrack.h:936
RecoHitInformation::UsedEKLMHit UsedEKLMHit
Copy the definitions from the RecoHitInformation to this class.
Definition RecoTrack.h:99
MatchingStatus
Enum for the matching status of this reco track (set by the matching modules in the tracking package)...
Definition RecoTrack.h:105
int m_nSVDHitsOfOutgoingArm
Number of SVD clusters of the outgoing arm.
Definition RecoTrack.h:927
bool m_hasOutgoingArmTime
Internal storage of the final outgoing arm time is set.
Definition RecoTrack.h:938
genfit::AbsTrackRep * getCardinalRepresentation() const
Get a pointer to the cardinal track representation. You are not allowed to modify or delete it!
Definition RecoTrack.h:629
const std::string & getStoreArrayNameOfPXDHits() const
Name of the store array of the pxd hits.
Definition RecoTrack.h:730
float m_outgoingArmTime
Track time of the outgoing arm.
Definition RecoTrack.h:917
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:361
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:1010
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:720
std::vector< Belle2::RecoTrack::UsedEKLMHit * > getSortedEKLMHitList() const
Return a sorted list of eklm hits. Sorted by the sortingParameter.
Definition RecoTrack.h:474
std::string m_storeArrayNameOfBKLMHits
Store array name of added BKLM hits.
Definition RecoTrack.h:905
unsigned int getNumberOfEKLMHits() const
Return the number of eklm hits.
Definition RecoTrack.h:431
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:337
unsigned int getNumberOfSVDHits() const
Return the number of svd hits.
Definition RecoTrack.h:422
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:345
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
Definition RecoTrack.h:425
int getNSVDHitsOfIngoingArm()
Return the number of clusters used to estimate the ingoing arm time.
Definition RecoTrack.h:573
bool addHit(const HitType *hit, Args &&... params)
Add a generic hit with the given parameters for the reco hit information.
Definition RecoTrack.h:947
unsigned int getNumberOfTrackingHits() const
Return the number of cdc + svd + pxd hits.
Definition RecoTrack.h:441
short int m_charge
Storage for the charge. All other helix parameters are saved in the genfit::Track.
Definition RecoTrack.h:897
RecoHitInformation::UsedBKLMHit UsedBKLMHit
Copy the definitions from the RecoHitInformation to this class.
Definition RecoTrack.h:97
float getIngoingArmTimeError()
Return the error of the track time of the ingoing arm.
Definition RecoTrack.h:533
bool hasHit(const HitType *hit) const
Returns true if the given hit is in the track.
Definition RecoTrack.h:409
void setMatchingStatus(MatchingStatus matchingStatus)
Set the matching status (used by the TrackMatcher module)
Definition RecoTrack.h:833
std::vector< Belle2::RecoTrack::UsedEKLMHit * > getEKLMHitList() const
Return an unsorted list of eklm hits.
Definition RecoTrack.h:459
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:1042
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:353
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:985
bool hasPXDHits() const
Returns true if the track has pxd hits.
Definition RecoTrack.h:393
ClassDefOverride(RecoTrack, 15)
Making this class a ROOT class.
RecoTrack * copyToStoreArrayUsingSeeds(StoreArray< RecoTrack > &storeArray) const
Append a new RecoTrack to the given store array and copy its general properties, but not the hits the...
Definition RecoTrack.cc:524
const std::string & getStoreArrayNameOfBKLMHits() const
Name of the store array of the bklm hits.
Definition RecoTrack.h:739
void setTimeSeed(const double timeSeed)
Set the time seed. ATTENTION: This is not the fitted time.
Definition RecoTrack.h:602
bool hasOutgoingArmTime()
Check if the outgoing arm time is set.
Definition RecoTrack.h:561
bool m_dirtyFlag
Bool is hits were added to track after fitting and the measurements should be recalculated.
Definition RecoTrack.h:932
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:1000
float getOutgoingArmTimeError()
Return the error of the track time of the outgoing arm.
Definition RecoTrack.h:519
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:370
float getIngoingArmTime()
Return the track time of the ingoing arm.
Definition RecoTrack.h:526
bool hasEKLMHits() const
Returns true if the track has eklm hits.
Definition RecoTrack.h:405
genfit::TrackCand createGenfitTrackCand() const
Create a genfit::TrackCand out of this reco track and copy all information to the track candidate.
Definition RecoTrack.cc:178
void setSeedCovariance(const TMatrixDSym &seedCovariance)
Set the covariance of the seed. ATTENTION: This is not the fitted covariance.
Definition RecoTrack.h:612
float getQualityIndicator() const
Get the quality index attached to this RecoTrack given by one of the reconstruction algorithms....
Definition RecoTrack.h:839
const std::string & getStoreArrayNameOfRecoHitInformation() const
Name of the store array of the reco hit information.
Definition RecoTrack.h:745
float get2ndFlipQualityIndicator() const
Get the 2nd flipping quality attached to this RecoTrack as a reference for flipping.
Definition RecoTrack.h:862
int m_nSVDHitsOfIngoingArm
Number of SVD clusters of the ingoing arm.
Definition RecoTrack.h:929
void set2ndFlipQualityIndicator(const float qualityIndicator)
Set the 2nd flipping quality attached to this RecoTrack.
Definition RecoTrack.h:868
RecoHitInformation * getRecoHitInformation(HitType *hit) const
Return the reco hit information for a generic hit from the storeArray.
Definition RecoTrack.h:312
void setFlipQualityIndicator(const float qualityIndicator)
Set the 1st flipping quality attached to this RecoTrack.
Definition RecoTrack.h:857
RecoTrack * copyToStoreArray(StoreArray< RecoTrack > &storeArray) const
Append a new RecoTrack to the given store array and copy its general properties, but not the hits the...
Definition RecoTrack.cc:529
void addHitWithHitInformation(const HitType *hit, RecoHitInformation *recoHitInformation)
Add the needed relations for adding a generic hit with the given hit information and reset track time...
Definition RecoTrack.h:967
RecoTrack * copyToStoreArrayUsing(StoreArray< RecoTrack > &storeArray, const ROOT::Math::XYZVector &position, const ROOT::Math::XYZVector &momentum, short charge, const TMatrixDSym &covariance, double timeSeed) const
Append a new RecoTrack to the given store array and copy its general properties, but not the hits the...
Definition RecoTrack.cc:510
void setQualityIndicator(const float qualityIndicator)
Set the quality index attached to this RecoTrack. 0 means likely fake.
Definition RecoTrack.h:845
float m_qualityIndicator
Quality index for classification of fake vs. MC-matched Tracks.
Definition RecoTrack.h:911
std::vector< RecoHitInformation * > getRecoHitInformations(bool getSorted=false) const
Return a list of all RecoHitInformations associated with the RecoTrack.
Definition RecoTrack.cc:557
MatchingStatus getMatchingStatus() const
Return the matching status set by the TrackMatcher module.
Definition RecoTrack.h:827
bool m_isArmTimeComputed
true if the arms times are already computed, false otherwise
Definition RecoTrack.h:934
std::string m_storeArrayNameOfSVDHits
Store array name of added SVD hits.
Definition RecoTrack.h:901
std::vector< Belle2::RecoTrack::UsedBKLMHit * > getSortedBKLMHitList() const
Return a sorted list of bklm hits. Sorted by the sortingParameter.
Definition RecoTrack.h:471
const std::string & getStoreArrayNameOfCDCHits() const
Name of the store array of the cdc hits.
Definition RecoTrack.h:736
float m_ingoingArmTime
Track time of the ingoing arm.
Definition RecoTrack.h:921
std::vector< Belle2::RecoTrack::UsedPXDHit * > getSortedPXDHitList() const
Return a sorted list of pxd hits. Sorted by the sortingParameter.
Definition RecoTrack.h:462
float getInOutArmTimeDifferenceError()
Return the error of the difference between the track times of the ingoing and outgoing arms.
Definition RecoTrack.h:547
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:713
void revertRecoHitInformationSorting()
Revert the sorting order of the RecoHitInformation.
Definition RecoTrack.h:748
bool hasBKLMHits() const
Returns true if the track has bklm hits.
Definition RecoTrack.h:402
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition RecoTrack.h:506
bool hasIngoingArmTime()
Check if the ingoing arm time is set.
Definition RecoTrack.h:555
float getFlipQualityIndicator() const
Get the 1st flipping quality attached to this RecoTrack as a reference for flipping.
Definition RecoTrack.h:851
RecoHitInformation::RightLeftInformation RightLeftInformation
Copy the definitions from the RecoHitInformation to this class.
Definition RecoTrack.h:85
float m_outgoingArmTimeError
Error of the track time of the outgoing arm.
Definition RecoTrack.h:919
RecoHitInformation::OriginTrackFinder OriginTrackFinder
Copy the definitions from the RecoHitInformation to this class.
Definition RecoTrack.h:89
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:492
ROOT::Math::XYZVector getMomentumSeed() const
Return the momentum seed stored in the reco track. ATTENTION: This is not the fitted momentum.
Definition RecoTrack.h:485
genfit::Track m_genfitTrack
Internal storage for the genfit track.
Definition RecoTrack.h:895
int getNSVDHitsOfOutgoingArm()
Return the number of clusters used to estimate the outgoing arm time.
Definition RecoTrack.h:567
RecoHitInformation::UsedSVDHit UsedSVDHit
Copy the definitions from the RecoHitInformation to this class.
Definition RecoTrack.h:93
std::string m_storeArrayNameOfEKLMHits
Store array name of added EKLM hits.
Definition RecoTrack.h:907
RecoTrack()
Empty constructor for ROOT. Do not use!
Definition RecoTrack.h:140
unsigned int getNumberOfPXDHits() const
Return the number of pxd hits.
Definition RecoTrack.h:419
std::string m_storeArrayNameOfPXDHits
Store array name of added PXD hits.
Definition RecoTrack.h:899
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:272
void checkDirtyFlag() const
Helper: Check the dirty flag and produce a warning, whenever a fit result is accessed.
Definition RecoTrack.h:1063
const genfit::Track & getGenfitTrack() const
Returns genfit track.
Definition RecoTrack.h:503
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:619
RecoHitInformation::UsedPXDHit UsedPXDHit
Copy the definitions from the RecoHitInformation to this class.
Definition RecoTrack.h:95
double getTimeSeed() const
Return the time seed stored in the reco track. ATTENTION: This is not the fitted time.
Definition RecoTrack.h:509
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:706
bool hasSVDHits() const
Returns true if the track has svd hits.
Definition RecoTrack.h:396
std::string m_storeArrayNameOfRecoHitInformation
Store array of added RecoHitInformation.
Definition RecoTrack.h:909
void swapArmTimes()
Swap arm times, booleans and nSVDHits.
Definition RecoTrack.h:1055
unsigned int getNumberOfTotalHits() const
Return the number of cdc + svd + pxd + bklm + eklm hits.
Definition RecoTrack.h:434
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.
void addRelationTo(const RelationsInterface< TObject > *object, float weight=1.0, const std::string &namedRelation="") const
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
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
static constexpr auto XYZToTVector
Helper function to convert XYZVector to TVector3.
Definition VectorUtil.h:26
#define BELLE2_DEFINE_EXCEPTION(ClassName, Message)
Macro that defines an exception with the given message template.
RelationsInterface< TObject > RelationsObject
Provides interface for getting/adding relations to objects in StoreArrays.
Abstract base class for different kinds of events.