10 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
12 #include <TDatabasePDG.h>
22 SpacePointTrackCand::SpacePointTrackCand(
const std::vector<const Belle2::SpacePoint*>& spacePoints,
int pdgCode,
23 double charge,
int mcTrackID)
27 m_MCTrackID = mcTrackID;
30 for (
const SpacePoint* spacePoint : spacePoints) {
31 m_trackSpacePoints.push_back(spacePoint);
32 m_sortingParameters.push_back(index);
41 const auto& lhsHits = this->getHits();
42 const auto& rhsHits = rhs.
getHits();
45 if (lhsHits.size() == 0 || rhsHits.size() == 0) {
46 B2DEBUG(80,
"At least one of the SpacePointTrackCands does not contain any SpacePoints");
51 if (lhsHits.size() != rhsHits.size()) {
52 B2DEBUG(80,
"Numbers of SpacePoints in SpacePointTrackCands do not match");
57 for (
unsigned int iSP = 0; iSP < lhsHits.size(); ++iSP) {
58 if (lhsHits[iSP] != rhsHits[iSP]) {
59 B2DEBUG(80,
"SpacePoints " << iSP <<
" do not match");
67 const std::vector<const Belle2::SpacePoint*> SpacePointTrackCand::getHitsInRange(
int firstIndex,
int lastIndex)
const
69 if (lastIndex < firstIndex) {
71 firstIndex = lastIndex;
75 if (firstIndex < 0 || uint(lastIndex) > m_trackSpacePoints.size() || uint(firstIndex) > m_trackSpacePoints.size()
77 throw SPTCIndexOutOfBounds();
79 const std::vector<const SpacePoint*> spacePoints(m_trackSpacePoints.begin() + firstIndex, m_trackSpacePoints.begin() + lastIndex);
84 const std::vector<double> SpacePointTrackCand::getSortingParametersInRange(
int firstIndex,
int lastIndex)
const
86 if (lastIndex < firstIndex) {
88 firstIndex = lastIndex;
92 if (firstIndex < 0 || uint(lastIndex) > m_sortingParameters.size() || uint(firstIndex) > m_sortingParameters.size()
94 throw SPTCIndexOutOfBounds();
96 const std::vector<double> sortingParams(m_sortingParameters.begin() + firstIndex, m_sortingParameters.begin() + lastIndex);
101 const std::vector<const SpacePoint*> SpacePointTrackCand::getSortedHits()
const
103 std::vector<std::pair<const SpacePoint*, double>> sortVector;
104 sortVector.reserve(m_trackSpacePoints.size());
105 for (
unsigned int index = 0; index < m_trackSpacePoints.size(); ++index) {
106 sortVector.push_back(std::make_pair(m_trackSpacePoints.at(index), m_sortingParameters.at(index)));
109 std::sort(sortVector.begin(), sortVector.end(), [](
const std::pair<const SpacePoint*, double>& a,
110 const std::pair<const SpacePoint*, double>& b) {
111 return a.second < b.second;
115 std::vector<const SpacePoint*> sortedSpacePoints;
117 for (
auto pair : sortVector) {
118 sortedSpacePoints.push_back(pair.first);
121 return sortedSpacePoints;
125 void SpacePointTrackCand::setPdgCode(
int pdgCode)
128 TParticlePDG* part = TDatabasePDG::Instance()->GetParticle(m_pdg);
129 m_q = part->Charge() / (3.);
133 void SpacePointTrackCand::setSortingParameters(
const std::vector<double>& sortParams)
135 if (sortParams.size() != m_sortingParameters.size())
136 throw SPTCSortingParameterSizeInvalid();
137 for (
size_t iSP = 0; iSP < sortParams.size(); ++iSP) {
138 m_sortingParameters.at(iSP) = sortParams.at(iSP);
143 void SpacePointTrackCand::removeSpacePoint(
int indexInTrackCand)
146 if (uint(indexInTrackCand) >= m_trackSpacePoints.size()) {
throw SPTCIndexOutOfBounds(); }
149 m_trackSpacePoints.erase(m_trackSpacePoints.begin() + indexInTrackCand);
150 m_sortingParameters.erase(m_sortingParameters.begin() + indexInTrackCand);
157 void SpacePointTrackCand::print(
int debuglevel,
const Option_t* option)
const
160 output <<
" ======= SpacePointTrackCand::print() ======= \n";
161 output <<
"This track candidate has " << m_trackSpacePoints.size() <<
" SpacePoints\n";
162 output <<
"mcTrackId: " << m_MCTrackID <<
"\n";
163 output <<
"seed values for 6D state : \n";
164 B2DEBUG(debuglevel, output.str());
167 output.str(std::string(
""));
171 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, debuglevel, PACKAGENAME())) { m_state6D.Print(option); }
173 output <<
"estimates of Track Candidate: \n";
174 output <<
"q = " << m_q <<
"\n";
175 output <<
"pdgCode = " << m_pdg <<
"\n";
176 output <<
", QI = " << m_qualityIndicator <<
"\n";
179 for (
const SpacePoint* spacePoint : getHits()) {
181 output <<
"SpacePoint " << nSP <<
" has Index " << spacePoint->getArrayIndex() <<
" in StoreArray " << spacePoint->getArrayName() <<
186 B2DEBUG(debuglevel, output.str());
189 output.str(std::string(
""));
192 output <<
"referee properties of this SPTC:\n";
193 output <<
"checked for SPs on same sensors: " << this->hasRefereeStatus(c_checkedSameSensors) <<
" -> result: " <<
194 this->hasRefereeStatus(c_hitsOnSameSensor) <<
"\n";
195 output <<
"checked for min distance between SPs: " << this->hasRefereeStatus(c_checkedMinDistance) <<
" -> result: " <<
196 this->hasRefereeStatus(c_hitsLowDistance) <<
"\n";
197 output <<
"checked for curling: " << this->checkedForCurling() <<
" -> result: " << this->isCurling() <<
198 ", part of a curling SPTC: " << this->isPartOfCurlingTrack() <<
"\n";
199 output <<
"direction of flight: " << m_flightDirection <<
", removed SpacePoints: " << this->hasRefereeStatus(
200 c_removedHits) <<
"\n";
201 output <<
"omitted Clusters: " << hasRefereeStatus(c_omittedClusters) <<
", single Cluster SPs: " << hasRefereeStatus(
202 c_singleClustersSPs) <<
"\n";
203 B2DEBUG(debuglevel, output.str());
208 std::string SpacePointTrackCand::getRefereeStatusString(std::string delimiter)
const
210 std::string statusString;
211 if (getRefereeStatus() == 0)
return statusString;
212 if (hasRefereeStatus(c_checkedByReferee)) statusString +=
"checkedByReferee" + delimiter;
213 if (hasRefereeStatus(c_checkedClean)) statusString +=
"checkedClean" + delimiter;
214 if (hasRefereeStatus(c_hitsOnSameSensor)) statusString +=
"hitsOnSameSensor" + delimiter;
215 if (hasRefereeStatus(c_hitsLowDistance)) statusString +=
"hitsLowDistance" + delimiter;
216 if (hasRefereeStatus(c_removedHits)) statusString +=
"removedHits" + delimiter;
217 if (hasRefereeStatus(c_checkedTrueHits)) statusString +=
"checkedTrueHits" + delimiter;
218 if (hasRefereeStatus(c_checkedSameSensors)) statusString +=
"checkedSameSensors" + delimiter;
219 if (hasRefereeStatus(c_checkedMinDistance)) statusString +=
"checkedMinDistance" + delimiter;
220 if (hasRefereeStatus(c_curlingTrack)) statusString +=
"curlingTrack" + delimiter;
221 if (hasRefereeStatus(c_omittedClusters)) statusString +=
"omittedClusters" + delimiter;
222 if (hasRefereeStatus(c_singleClustersSPs)) statusString +=
"singleClusterSPs" + delimiter;
223 if (hasRefereeStatus(c_isActive)) statusString +=
"isActive" + delimiter;
224 if (hasRefereeStatus(c_isReserved)) statusString +=
"isReserved" + delimiter;
226 statusString.erase(statusString.end() - delimiter.size(),
Storage for (VXD) SpacePoint-based track candidates.
const std::vector< const Belle2::SpacePoint * > & getHits() const
get hits (space points) of track candidate
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
bool operator==(const DecayNode &node1, const DecayNode &node2)
Compare two Decay Nodes: They are equal if All daughter decay nodes are equal or one of the daughter ...
Abstract base class for different kinds of events.