9 #include <framework/gearbox/Const.h>
12 #include <gtest/gtest.h>
15 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
36 VXD::SensorInfoBase sensorInfoBase(VXD::SensorInfoBase::PXD, aVxdID, width, length, 0.3, 2, 4, width2);
39 r1.SetAngles(45, 20, 30);
40 TGeoTranslation t1(-10, 10, 1);
41 TGeoCombiTrans c1(t1, r1);
42 TGeoHMatrix transform = c1;
45 return sensorInfoBase;
58 PXDCluster aCluster =
PXDCluster(aVxdID, 0., 0., 0.1, 0.1, 0, 0, 1, 1, 1, 1, 1, 1);
65 std::vector<const SVDCluster*> a2HitCluster = { &aUCluster, &aVCluster };
68 SVDCluster anotherUCluster =
SVDCluster(anotherVxdID,
true, 0.23, 0.1, 0.01, 0.001, 1, 1, 1, 1.0);
69 std::vector<const SVDCluster*> a1HitCluster = { &anotherUCluster };
72 const std::vector<const Belle2::SpacePoint*> aSpacePointVec = { &aPXDSpacePoint, &aSVDSpacePoint, &anotherSVDSpacePoint };
80 EXPECT_EQ(aSpacePointTC.
getNHits(), aSpacePointVec.size());
82 EXPECT_EQ(aSpacePointTC.
getPdgCode(), Const::electron.getPDGCode());
87 const std::vector<const SpacePoint*> returnSPVector = aSpacePointTC.
getHits();
88 for (
unsigned int i = 0; i < aSpacePointTC.
getNHits(); i++) {
89 EXPECT_TRUE(returnSPVector[i] == aSpacePointVec[i]);
103 PXDCluster aCluster =
PXDCluster(aVxdID, 0., 0., 0.1, 0.1, 0, 0, 1, 1, 1, 1, 1, 1);
110 std::vector<const SVDCluster*> a2HitCluster = { &aUCluster, &aVCluster };
113 SVDCluster anotherUCluster =
SVDCluster(anotherVxdID,
true, 0.23, 0.1, 0.01, 0.001, 1, 1, 1, 1.0);
114 std::vector<const SVDCluster*> a1HitCluster = { &anotherUCluster };
117 const std::vector<const Belle2::SpacePoint*> aSpacePointVec = { &aPXDSpacePoint, &aSVDSpacePoint };
118 const std::vector<const Belle2::SpacePoint*> sameSpacePointVec = { &aPXDSpacePoint, &aSVDSpacePoint };
119 const std::vector<const Belle2::SpacePoint*> anotherSpacePointVec = { &aPXDSpacePoint, &anotherSVDSpacePoint };
126 EXPECT_TRUE(aSpacePointTC == anotherSpacePointTC);
129 anotherSpacePointTC.
setPdgCode(-Const::electron.getPDGCode());
130 EXPECT_TRUE(aSpacePointTC == anotherSpacePointTC);
133 anotherSpacePointTC.
addSpacePoint(&anotherSVDSpacePoint, 1.0);
135 EXPECT_FALSE(aSpacePointTC == anotherSpacePointTC);
140 EXPECT_FALSE(aSpacePointTC == changedSVDSpacePointTC);
141 EXPECT_FALSE(changedSVDSpacePointTC == anotherSpacePointTC);
148 EXPECT_TRUE(newSpacePointTC == aSpacePointTC);
152 EXPECT_TRUE(newSpacePointTC == anotherSpacePointTC);
164 aSpacePointTC.
setPdgCode(Const::electron.getPDGCode());
167 aSpacePointTC.
setPdgCode(-Const::electron.getPDGCode());
185 PXDCluster aCluster =
PXDCluster(aVxdID1, 0., 0., 0.1, 0.1, 0, 0, 1, 1, 1, 1, 1, 1);
193 std::vector<const SVDCluster*> UVClusterVec1 = { &aUCluster, &aVCluster };
194 std::vector<const SVDCluster*> VClusterVec = { &aVCluster };
195 std::vector<const SVDCluster*> UClusterVec = { &aUCluster };
207 std::vector<const SVDCluster*> UVClusterVec2 = { &aUCluster2, &aVCluster2 };
208 std::vector<const SVDCluster*> VClusterVec2 = { &aVCluster2 };
209 std::vector<const SVDCluster*> UClusterVec2 = { &aUCluster2 };
230 EXPECT_TRUE(subTrackCand1 == shortTC1);
231 std::vector<double> sortParams1 = { 1.23, 2.34, 3.45 };
233 EXPECT_EQ(sortParams1.size(), sortParamsTC1.size());
234 for (
unsigned int i = 0; i < sortParamsTC1.size(); ++i) { EXPECT_DOUBLE_EQ(sortParams1.at(i), sortParamsTC1.at(i)); }
237 EXPECT_TRUE(subTrackCand2 == shortTC2);
238 std::vector<double> sortParams2 = { 3.45, 4.56, 5.67, 6.78 };
240 EXPECT_EQ(sortParams2.size(), sortParamsTC2.size());
241 for (
unsigned int i = 0; i < sortParamsTC2.size(); ++i) { EXPECT_DOUBLE_EQ(sortParams2.at(i), sortParamsTC2.at(i)); }
244 unsigned int nHits = fullTrackCand.
getNHits();
246 SpacePointTrackCand::SPTCIndexOutOfBounds);
249 SpacePointTrackCand::SPTCIndexOutOfBounds);
250 ASSERT_THROW(fullTrackCand.
getHitsInRange(0, 10), SpacePointTrackCand::SPTCIndexOutOfBounds);
252 SpacePointTrackCand::SPTCIndexOutOfBounds);
253 ASSERT_THROW(fullTrackCand.
getHitsInRange(2, -1), SpacePointTrackCand::SPTCIndexOutOfBounds);
255 SpacePointTrackCand::SPTCIndexOutOfBounds);
257 SpacePointTrackCand::SPTCIndexOutOfBounds);
259 SpacePointTrackCand::SPTCIndexOutOfBounds);
261 SpacePointTrackCand::SPTCIndexOutOfBounds);
274 EXPECT_EQ(SpacePointTrackCand::c_initialState, SpacePointTrackCand::c_isActive);
277 EXPECT_EQ(initialStatus, SpacePointTrackCand::c_initialState);
280 unsigned short int newStatus = 0;
281 newStatus += SpacePointTrackCand::c_checkedByReferee;
282 newStatus += SpacePointTrackCand::c_checkedTrueHits;
292 EXPECT_EQ(trackCand.
getRefereeStatus(), SpacePointTrackCand::c_initialState);
298 EXPECT_TRUE(trackCand.
hasRefereeStatus(SpacePointTrackCand::c_checkedClean));
300 EXPECT_TRUE(trackCand.
hasRefereeStatus(SpacePointTrackCand::c_hitsOnSameSensor));
301 EXPECT_FALSE(trackCand.
hasRefereeStatus(SpacePointTrackCand::c_hitsLowDistance));
304 unsigned short int expectedStatus = SpacePointTrackCand::c_checkedClean + SpacePointTrackCand::c_hitsOnSameSensor +
305 SpacePointTrackCand::c_checkedByReferee;
311 expectedStatus -= SpacePointTrackCand::c_checkedClean;
313 EXPECT_FALSE(trackCand.
hasRefereeStatus(SpacePointTrackCand::c_checkedClean));
320 EXPECT_TRUE(trackCand.
hasRefereeStatus(SpacePointTrackCand::c_hitsOnSameSensor));
328 EXPECT_TRUE(trackCand.
hasRefereeStatus(SpacePointTrackCand::c_checkedSameSensors));
339 int maxUsedStatus = pow(2, n);
344 int maxPossibleStatus = pow(2, maxN);
348 int impossibleStatus = maxPossibleStatus * 2;
375 PXDCluster aCluster =
PXDCluster(aVxdID1, 0., 0., 0.1, 0.1, 0, 0, 1, 1, 1, 1, 1, 1);
383 std::vector<const SVDCluster*> UVClusterVec1 = { &aUCluster, &aVCluster };
384 std::vector<const SVDCluster*> VClusterVec = { &aVCluster };
385 std::vector<const SVDCluster*> UClusterVec = { &aUCluster };
401 EXPECT_TRUE(expectedTC == fullTrackCand);
403 std::vector<double> expectedSortParams = { 1.23, 3.45, 4.56 };
405 EXPECT_EQ(expectedSortParams.size(), sortParams.size());
406 for (
unsigned int i = 0; i < sortParams.size(); ++i) { EXPECT_DOUBLE_EQ(sortParams.at(i), expectedSortParams.at(i)); }
420 PXDCluster aCluster =
PXDCluster(aVxdID1, 0., 0., 0.1, 0.1, 0, 0, 1, 1, 1, 1, 1, 1);
427 std::vector<const SVDCluster*> UVClusterVec1 = { &aUCluster, &aVCluster };
428 std::vector<const SVDCluster*> VClusterVec = { &aVCluster };
429 std::vector<const SVDCluster*> UClusterVec = { &aUCluster };
438 std::vector<const SVDCluster*> UVClusterVec2 = { &aUCluster2, &aVCluster2 };
439 std::vector<const SVDCluster*> VClusterVec2 = { &aVCluster2 };
440 std::vector<const SVDCluster*> UClusterVec2 = { &aUCluster2 };
471 EXPECT_TRUE(sorted == sortedConstructed);
474 EXPECT_TRUE(nothingChanged == sortedConstructed);
477 std::vector<double> sortParams1 = { 1.0, 2.0, 3.0 , 4.0, 5.0, 7.0, 6.0};
482 EXPECT_TRUE(unsorted == unsortedConstructed);
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Test class for the SpacePointTrackCand class.
VXD::SensorInfoBase createSensorInfo(VxdID aVxdID, double width=1., double length=1., double width2=-1.)
this is a small helper function to create a sensorInfo to be used
Storage for (VXD) SpacePoint-based track candidates.
void setSortingParameters(const std::vector< double > &sortParams)
set the sorting parameters
unsigned int getNHits() const
get the number of hits (space points) in the track candidate
int getPdgCode() const
get pdg code
void removeSpacePoint(int indexInTrackCand)
remove a SpacePoint (and its sorting parameter) from the SpacePointTrackCand
unsigned short int getRefereeStatus(unsigned short int bitmask=USHRT_MAX) const
Return the refere status code of the SpacePointTrackCand.
bool checkedSameSensors() const
Check if the SpacePointTrackCand has been checked for consecutive hits on same sensor.
int getMcTrackID() const
get the MC Track ID
void clearRefereeStatus()
clear the referee status.
void removeRefereeStatus(unsigned short int bitmask)
remove a referee status
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
bool isCurling() const
get if the TrackCand is curling.
bool hasHitsOnSameSensor() const
Check if the SpacePointTrackCand contains consecutive SpacePoints that are on the same sensor WARNING...
void addSpacePoint(const SpacePoint *newSP, double sortParam)
add a new SpacePoint and its according sorting parameter to the track candidate
void setRefereeStatus(unsigned short int bitmask)
set referee status (resets the complete to the passed status!)
void resetRefereeStatus()
resets the referee status to the initial value
const std::vector< const Belle2::SpacePoint * > getHitsInRange(int firstInd, int lastInd) const
get hits (SpacePoints) in range (indices of SpacePoint inside SpacePointTrackCand) including first in...
bool hasRefereeStatus(unsigned int short bitmask) const
Check if the SpacePointTrackCand has the status characterized by the bitmask.
const std::vector< double > getSortingParametersInRange(int firstIndex, int lastIndex) const
get the sorting parameters in range (indices of SpacePoints inside SpacePointTrackCand) including fir...
const std::vector< double > & getSortingParameters() const
get the sorting parameters
double getChargeSeed() const
get charge
void addRefereeStatus(unsigned short int bitmask)
add a referee status
void setPdgCode(int pdgCode)
set a hypothesis for the particle by setting a pdgcode (will also set the appropriate charge)
const std::vector< const Belle2::SpacePoint * > getSortedHits() const
get hits (space points) sorted by their respective sorting parameter
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Base class to provide Sensor Information for PXD and SVD.
void setTransformation(const TGeoHMatrix &transform, bool reco=false)
Set the transformation matrix of the Sensor.
Class to uniquely identify a any structure of the PXD and SVD.
TEST_F(SpacePointTrackCandTest, testGetSortedHits)
Test setPdgCode method, by comparing its results with the expected values for the according particles...
Abstract base class for different kinds of events.