9#include <tracking/dataobjects/RecoTrack.h>
10#include <framework/datastore/StoreArray.h>
11#include <framework/geometry/VectorUtil.h>
13#include <framework/utilities/TestHelpers.h>
14#include <framework/gearbox/Const.h>
16#include <genfit/WireTrackCandHit.h>
81 ROOT::Math::XYZVector position(0, 1, 2);
82 ROOT::Math::XYZVector momentum(-1, -0.5, 1.123);
109 EXPECT_FALSE(m_recoTrack->hasCDCHits());
112 m_recoTrack->addCDCHit(cdcHits[0], 1);
113 m_recoTrack->addCDCHit(cdcHits[1], 0, RecoHitInformation::RightLeftInformation::c_right);
114 m_recoTrack->addCDCHit(cdcHits[2], 2);
116 EXPECT_TRUE(m_recoTrack->hasCDCHits());
118 EXPECT_TRUE(m_recoTrack->hasHit(cdcHits[0]));
119 EXPECT_TRUE(m_recoTrack->hasHit(cdcHits[1]));
120 EXPECT_TRUE(m_recoTrack->hasHit(cdcHits[2]));
122 EXPECT_FALSE(m_recoTrack->hasHit(cdcHits[4]));
124 ASSERT_EQ(m_recoTrack->getNumberOfCDCHits(), 3);
125 const std::vector<CDCHit*> addedCDCHits = m_recoTrack->getCDCHitList();
126 ASSERT_EQ(addedCDCHits.size(), 3);
127 EXPECT_EQ(addedCDCHits[0], cdcHits[0]);
128 EXPECT_EQ(addedCDCHits[1], cdcHits[1]);
129 EXPECT_EQ(addedCDCHits[2], cdcHits[2]);
131 const std::vector<CDCHit*> sortedCDCHits = m_recoTrack->getSortedCDCHitList();
132 ASSERT_EQ(sortedCDCHits.size(), 3);
133 EXPECT_EQ(sortedCDCHits[0], cdcHits[1]);
134 EXPECT_EQ(sortedCDCHits[1], cdcHits[0]);
135 EXPECT_EQ(sortedCDCHits[2], cdcHits[2]);
138 CDCHit* cdcHit = cdcHits[0];
141 EXPECT_NE(recoHitInformation,
nullptr);
142 EXPECT_EQ(recoHitInformation->
getTrackingDetector(), RecoHitInformation::RecoHitDetector::c_CDC);
143 EXPECT_EQ(recoHitInformation->
getRightLeftInformation(), RecoHitInformation::RightLeftInformation::c_undefinedRightLeftInformation);
144 EXPECT_EQ(recoHitInformation->
getFoundByTrackFinder(), RecoHitInformation::OriginTrackFinder::c_undefinedTrackFinder);
148 recoHitInformation = m_recoTrack->getRecoHitInformation(cdcHit);
149 EXPECT_NE(recoHitInformation,
nullptr);
158 EXPECT_EQ(m_recoTrack->getTrackingDetector(cdcHit), RecoHitInformation::RecoHitDetector::c_CDC);
159 EXPECT_EQ(m_recoTrack->getRightLeftInformation(cdcHit), RecoHitInformation::RightLeftInformation::c_undefinedRightLeftInformation);
160 EXPECT_EQ(m_recoTrack->getFoundByTrackFinder(cdcHit), RecoHitInformation::OriginTrackFinder::c_undefinedTrackFinder);
161 EXPECT_EQ(m_recoTrack->getSortingParameter(cdcHit), 1);
163 EXPECT_NO_THROW(m_recoTrack->setFoundByTrackFinder(cdcHit, RecoHitInformation::OriginTrackFinder::c_SegmentTrackCombiner));
164 EXPECT_NO_THROW(m_recoTrack->setRightLeftInformation(cdcHit, RecoHitInformation::RightLeftInformation::c_left));
165 EXPECT_NO_THROW(m_recoTrack->setSortingParameter(cdcHit, 3));
167 EXPECT_EQ(m_recoTrack->getFoundByTrackFinder(cdcHit), RecoHitInformation::OriginTrackFinder::c_SegmentTrackCombiner);
168 EXPECT_EQ(m_recoTrack->getRightLeftInformation(cdcHit), RecoHitInformation::RightLeftInformation::c_left);
169 EXPECT_EQ(m_recoTrack->getSortingParameter(cdcHit), 3);
174 EXPECT_B2FATAL(m_recoTrack->getTrackingDetector(cdcHit));
175 EXPECT_B2FATAL(m_recoTrack->getRightLeftInformation(cdcHit));
176 EXPECT_B2FATAL(m_recoTrack->getFoundByTrackFinder(cdcHit));
177 EXPECT_B2FATAL(m_recoTrack->getSortingParameter(cdcHit));
179 EXPECT_B2FATAL(m_recoTrack->setFoundByTrackFinder(cdcHit, RecoHitInformation::OriginTrackFinder::c_SegmentTrackCombiner));
180 EXPECT_B2FATAL(m_recoTrack->setRightLeftInformation(cdcHit, RecoHitInformation::RightLeftInformation::c_left));
188 EXPECT_FALSE(m_recoTrack->hasCDCHits());
191 m_recoTrack->addCDCHit(cdcHits[0], 1, RecoHitInformation::RightLeftInformation::c_right,
192 RecoHitInformation::OriginTrackFinder::c_MCTrackFinderPriorityHit);
193 m_recoTrack->addCDCHit(cdcHits[1], 0, RecoHitInformation::RightLeftInformation::c_right,
194 RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit);
196 m_recoTrack->addCDCHit(cdcHits[2], 2);
199 EXPECT_EQ(m_recoTrack->getRecoHitInformation(cdcHits[0])->getFoundByTrackFinder(),
200 RecoHitInformation::OriginTrackFinder::c_MCTrackFinderPriorityHit);
201 EXPECT_EQ(m_recoTrack->getRecoHitInformation(cdcHits[1])->getFoundByTrackFinder(),
202 RecoHitInformation::OriginTrackFinder::c_MCTrackFinderAuxiliaryHit);
203 EXPECT_EQ(m_recoTrack->getRecoHitInformation(cdcHits[2])->getFoundByTrackFinder(),
204 RecoHitInformation::OriginTrackFinder::c_undefinedTrackFinder);
211 genfit::TrackCand newCreatedTrackCand;
212 ROOT::Math::XYZVector position(4, 23, 5.6);
213 ROOT::Math::XYZVector momentum(4, 23, 5.6);
214 short int charge = 1;
217 newCreatedTrackCand.addHit(
new genfit::WireTrackCandHit(Const::CDC, 0, -1, 0, 0));
218 newCreatedTrackCand.addHit(
new genfit::WireTrackCandHit(Const::CDC, 1, -1, 1, 0));
219 newCreatedTrackCand.addHit(
new genfit::WireTrackCandHit(Const::CDC, 2, -1, 2, 0));
223 m_storeArrayNameOfPXDHits, m_storeArrayNameOfSVDHits, m_storeArrayNameOfCDCHits,
224 m_storeArrayNameOfBKLMHits, m_storeArrayNameOfEKLMHits,
225 m_storeArrayNameOfHitInformation);
232 ASSERT_EQ(exportedTrackCand.getNHits(), newCreatedTrackCand.getNHits());
233 EXPECT_NEAR(exportedTrackCand.getPosSeed().X(), newCreatedTrackCand.getPosSeed().X(), 1
E-10);
234 EXPECT_NEAR(exportedTrackCand.getPosSeed().Y(), newCreatedTrackCand.getPosSeed().Y(), 1
E-10);
235 EXPECT_NEAR(exportedTrackCand.getPosSeed().Z(), newCreatedTrackCand.getPosSeed().Z(), 1
E-10);
236 EXPECT_NEAR(exportedTrackCand.getMomSeed().X(), newCreatedTrackCand.getMomSeed().X(), 1
E-10);
237 EXPECT_NEAR(exportedTrackCand.getMomSeed().Y(), newCreatedTrackCand.getMomSeed().Y(), 1
E-10);
238 EXPECT_NEAR(exportedTrackCand.getMomSeed().Z(), newCreatedTrackCand.getMomSeed().Z(), 1
E-10);
239 EXPECT_EQ(exportedTrackCand.getChargeSeed(), newCreatedTrackCand.getChargeSeed());
240 EXPECT_EQ(exportedTrackCand.getHit(0)->getHitId(), newCreatedTrackCand.getHit(0)->getHitId());
241 EXPECT_EQ(exportedTrackCand.getHit(1)->getSortingParameter(), newCreatedTrackCand.getHit(1)->getSortingParameter());
242 EXPECT_EQ(exportedTrackCand.getHit(2)->getHitId(), newCreatedTrackCand.getHit(2)->getHitId());
248 EXPECT_FALSE(m_recoTrack->hasCDCHits());
252 m_recoTrack->addCDCHit(cdcHits[0], 1);
253 m_recoTrack->addCDCHit(cdcHits[1], 0, RecoHitInformation::RightLeftInformation::c_right);
254 m_recoTrack->addCDCHit(cdcHits[2], 2);
256 EXPECT_TRUE(m_recoTrack->hasCDCHits());
258 const genfit::TrackCand& exportedTrackCand = m_recoTrack->createGenfitTrackCand();
260 ASSERT_EQ(exportedTrackCand.getNHits(), m_recoTrack->getNumberOfTotalHits());
261 ASSERT_EQ(m_recoTrack->getNumberOfTotalHits(), 3);
264 m_storeArrayNameOfPXDHits, m_storeArrayNameOfSVDHits, m_storeArrayNameOfCDCHits,
265 m_storeArrayNameOfBKLMHits, m_storeArrayNameOfEKLMHits,
266 m_storeArrayNameOfHitInformation);
270 ASSERT_EQ(recoTrackFromGenfit->
getNumberOfCDCHits(), m_recoTrack->getNumberOfCDCHits());
271 const auto& cdcHitListOne = recoTrackFromGenfit->
getCDCHitList();
272 const auto& cdcHitListTwo = m_recoTrack->getCDCHitList();
273 ASSERT_EQ(cdcHitListOne.size(), 3);
274 ASSERT_EQ(cdcHitListTwo.size(), 3);
283 m_recoTrack->addCDCHit(cdcHits[0], 1);
284 m_recoTrack->addCDCHit(cdcHits[1], 0, RecoHitInformation::RightLeftInformation::c_right);
285 m_recoTrack->addCDCHit(cdcHits[2], 2);
290 auto recoTrack = recoTracks.
appendNew(m_recoTrack->getPositionSeed(), m_recoTrack->getMomentumSeed(), m_recoTrack->getChargeSeed(),
291 m_storeArrayNameOfPXDHits, m_storeArrayNameOfSVDHits, m_storeArrayNameOfCDCHits,
292 m_storeArrayNameOfBKLMHits, m_storeArrayNameOfEKLMHits,
293 m_storeArrayNameOfHitInformation);
294 EXPECT_FALSE(recoTrack->hasCDCHits());
298 recoTrack->addHitsFromRecoTrack(m_recoTrack, offset);
299 ASSERT_EQ(recoTrack->getNumberOfCDCHits(), 3);
301 size_t this_i = offset;
302 for (
auto pHit : recoTrack->getSortedCDCHitList()) {
303 auto sortParam = recoTrack->getSortingParameter(pHit);
304 ASSERT_EQ(this_i, sortParam);
314 m_recoTrack->addCDCHit(cdcHits[0], 1);
319 RecoTrack* recoTrack2 = recoTracks.
appendNew(m_recoTrack->getPositionSeed(), m_recoTrack->getMomentumSeed(),
320 m_recoTrack->getChargeSeed(),
321 m_storeArrayNameOfPXDHits, m_storeArrayNameOfSVDHits, m_storeArrayNameOfCDCHits,
322 m_storeArrayNameOfBKLMHits, m_storeArrayNameOfEKLMHits,
323 m_storeArrayNameOfHitInformation);
326 ASSERT_EQ(m_recoTrack->getRecoHitInformations().size(), 1);
327 ASSERT_EQ(m_recoTrack->getRecoHitInformations()[0]->getSortingParameter(), 1);
339 svdHits.
appendNew(
Belle2::VxdID(
"3.1.2"),
true, 1.0, 0.01, 0.1, 0.1, 5.0e4, 5.0e4, 1, 50.0, 0.1, 0);
340 svdHits.
appendNew(
Belle2::VxdID(
"4.1.2"),
true, 1.0, 0.01, 0.2, 0.1, 5.0e4, 5.0e4, 1, 50.0, 0.1, 0);
341 svdHits.
appendNew(
Belle2::VxdID(
"5.1.3"),
true, 1.0, 0.01, 0.3, 0.1, 5.0e4, 5.0e4, 1, 50.0, 0.1, 0);
342 svdHits.
appendNew(
Belle2::VxdID(
"6.1.3"),
true, 1.0, 0.01, 0.4, 0.1, 5.0e4, 5.0e4, 1, 50.0, 0.1, 0);
343 svdHits.
appendNew(
Belle2::VxdID(
"6.7.7"),
true, 1.0, 0.01, 1.0, 0.1, 5.0e4, 5.0e4, 1, 50.0, 0.1, 0);
344 svdHits.
appendNew(
Belle2::VxdID(
"5.7.4"),
true, 1.0, 0.01, 1.1, 0.1, 5.0e4, 5.0e4, 1, 50.0, 0.1, 0);
346 ROOT::Math::XYZVector momentum(0.25, 0.25, 0.05);
350 m_recoTrack->getChargeSeed(),
351 m_storeArrayNameOfPXDHits, m_storeArrayNameOfSVDHits, m_storeArrayNameOfCDCHits,
352 m_storeArrayNameOfBKLMHits, m_storeArrayNameOfEKLMHits,
353 m_storeArrayNameOfHitInformation);
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
static DataStore & Instance()
Instance of singleton Store.
void setInitializeActive(bool active)
Setter for m_initializeActive.
Test class for the RecoTrack object.
std::string m_storeArrayNameOfHitInformation
name of storeArray with hit information
std::string m_storeArrayNameOfCDCHits
name of storeArray with CDC hits
void SetUp() override
Setup a "working environment" with store arrays for the hits and the correct relations.
std::string m_storeArrayNameOfBKLMHits
name of storeArray with BKLM hits
std::string m_storeArrayNameOfRecoTracks
name of recoTracks storeArray
std::string m_storeArrayNameOfSVDHits
name of storeArray with SVD hits
RecoTrack * m_recoTrack2
pointer to other recoTrack
std::string m_storeArrayNameOfEKLMHits
name of storeArray with EKLM hits
RecoTrack * m_recoTrack
pointer to recoTrack
std::string m_storeArrayNameOfPXDHits
name of storeArray with PXD hits
This is the Reconstruction Event-Data Model Track.
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.
float getInOutArmTimeDifference()
Return the difference between the track times of the ingoing and outgoing arms.
float getOutgoingArmTime()
Return the track time of the outgoing arm.
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.
std::vector< Belle2::RecoTrack::UsedCDCHit * > getCDCHitList() const
Return an unsorted list of cdc hits.
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
bool hasOutgoingArmTime()
Check if the outgoing arm time is set.
float getIngoingArmTime()
Return the track time of the ingoing arm.
genfit::TrackCand createGenfitTrackCand() const
Create a genfit::TrackCand out of this reco track and copy all information to the track candidate.
std::vector< RecoHitInformation * > getRecoHitInformations(bool getSorted=false) const
Return a list of all RecoHitInformations associated with the RecoTrack.
bool hasIngoingArmTime()
Check if the ingoing arm time is set.
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.
bool hasSVDHits() const
Returns true if the track has svd hits.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Class to uniquely identify a any structure of the PXD and SVD.
static constexpr auto XYZToTVector
Helper function to convert XYZVector to TVector3.
Abstract base class for different kinds of events.