12 #include <tracking/spacePointCreation/SpacePointTrackCand.h>
14 #include <TDatabasePDG.h>
24 SpacePointTrackCand::SpacePointTrackCand(
const std::vector<const Belle2::SpacePoint*>& spacePoints,
int pdgCode,
25 double charge,
int mcTrackID)
29 m_MCTrackID = mcTrackID;
32 for (
const SpacePoint* spacePoint : spacePoints) {
33 m_trackSpacePoints.push_back(spacePoint);
34 m_sortingParameters.push_back(index);
43 const auto& lhsHits = this->getHits();
44 const auto& rhsHits = rhs.
getHits();
47 if (lhsHits.size() == 0 || rhsHits.size() == 0) {
48 B2DEBUG(80,
"At least one of the SpacePointTrackCands does not contain any SpacePoints");
53 if (lhsHits.size() != rhsHits.size()) {
54 B2DEBUG(80,
"Numbers of SpacePoints in SpacePointTrackCands do not match");
59 for (
unsigned int iSP = 0; iSP < lhsHits.size(); ++iSP) {
60 if (lhsHits[iSP] != rhsHits[iSP]) {
61 B2DEBUG(80,
"SpacePoints " << iSP <<
" do not match");
69 const std::vector<const Belle2::SpacePoint*> SpacePointTrackCand::getHitsInRange(
int firstIndex,
int lastIndex)
const
71 if (lastIndex < firstIndex) {
73 firstIndex = lastIndex;
77 if (firstIndex < 0 || uint(lastIndex) > m_trackSpacePoints.size() || uint(firstIndex) > m_trackSpacePoints.size()
79 throw SPTCIndexOutOfBounds();
81 const std::vector<const SpacePoint*> spacePoints(m_trackSpacePoints.begin() + firstIndex, m_trackSpacePoints.begin() + lastIndex);
86 const std::vector<double> SpacePointTrackCand::getSortingParametersInRange(
int firstIndex,
int lastIndex)
const
88 if (lastIndex < firstIndex) {
90 firstIndex = lastIndex;
94 if (firstIndex < 0 || uint(lastIndex) > m_sortingParameters.size() || uint(firstIndex) > m_sortingParameters.size()
96 throw SPTCIndexOutOfBounds();
98 const std::vector<double> sortingParams(m_sortingParameters.begin() + firstIndex, m_sortingParameters.begin() + lastIndex);
103 const std::vector<const SpacePoint*> SpacePointTrackCand::getSortedHits()
const
105 std::vector<std::pair<const SpacePoint*, double>> sortVector;
106 sortVector.reserve(m_trackSpacePoints.size());
107 for (
unsigned int index = 0; index < m_trackSpacePoints.size(); ++index) {
108 sortVector.push_back(std::make_pair(m_trackSpacePoints.at(index), m_sortingParameters.at(index)));
111 std::sort(sortVector.begin(), sortVector.end(), [](
const std::pair<const SpacePoint*, double>& a,
112 const std::pair<const SpacePoint*, double>& b) {
113 return a.second < b.second;
117 std::vector<const SpacePoint*> sortedSpacePoints;
119 for (
auto pair : sortVector) {
121 sortedSpacePoints.push_back(pair.first);
124 return sortedSpacePoints;
128 void SpacePointTrackCand::setPdgCode(
int pdgCode)
131 TParticlePDG* part = TDatabasePDG::Instance()->GetParticle(m_pdg);
132 m_q = part->Charge() / (3.);
136 void SpacePointTrackCand::setSortingParameters(
const std::vector<double>& sortParams)
138 if (sortParams.size() != m_sortingParameters.size())
139 throw SPTCSortingParameterSizeInvalid();
140 for (
size_t iSP = 0; iSP < sortParams.size(); ++iSP) {
141 m_sortingParameters.at(iSP) = sortParams.at(iSP);
146 void SpacePointTrackCand::removeSpacePoint(
int indexInTrackCand)
149 if (uint(indexInTrackCand) >= m_trackSpacePoints.size()) {
throw SPTCIndexOutOfBounds(); }
152 m_trackSpacePoints.erase(m_trackSpacePoints.begin() + indexInTrackCand);
153 m_sortingParameters.erase(m_sortingParameters.begin() + indexInTrackCand);
160 void SpacePointTrackCand::print(
int debuglevel,
const Option_t* option)
const
163 output <<
" ======= SpacePointTrackCand::print() ======= \n";
164 output <<
"This track candidate has " << m_trackSpacePoints.size() <<
" SpacePoints\n";
165 output <<
"mcTrackId: " << m_MCTrackID <<
"\n";
166 output <<
"seed values for 6D state : \n";
167 B2DEBUG(debuglevel, output.str());
170 output.str(std::string(
""));
174 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Debug, debuglevel, PACKAGENAME())) { m_state6D.Print(option); }
176 output <<
"estimates of Track Candidate: \n";
177 output <<
"q = " << m_q <<
"\n";
178 output <<
"pdgCode = " << m_pdg <<
"\n";
179 output <<
", QI = " << m_qualityIndicator <<
"\n";
182 for (
const SpacePoint* spacePoint : getHits()) {
184 output <<
"SpacePoint " << nSP <<
" has Index " << spacePoint->getArrayIndex() <<
" in StoreArray " << spacePoint->getArrayName() <<
189 B2DEBUG(debuglevel, output.str());
192 output.str(std::string(
""));
195 output <<
"referee properties of this SPTC:\n";
196 output <<
"checked for SPs on same sensors: " << this->hasRefereeStatus(c_checkedSameSensors) <<
" -> result: " <<
197 this->hasRefereeStatus(c_hitsOnSameSensor) <<
"\n";
198 output <<
"checked for min distance between SPs: " << this->hasRefereeStatus(c_checkedMinDistance) <<
" -> result: " <<
199 this->hasRefereeStatus(c_hitsLowDistance) <<
"\n";
200 output <<
"checked for curling: " << this->checkedForCurling() <<
" -> result: " << this->isCurling() <<
201 ", part of a curling SPTC: " << this->isPartOfCurlingTrack() <<
"\n";
202 output <<
"direction of flight: " << m_flightDirection <<
", removed SpacePoints: " << this->hasRefereeStatus(
203 c_removedHits) <<
"\n";
204 output <<
"omitted Clusters: " << hasRefereeStatus(c_omittedClusters) <<
", single Cluster SPs: " << hasRefereeStatus(
205 c_singleClustersSPs) <<
"\n";
206 B2DEBUG(debuglevel, output.str());
211 std::string SpacePointTrackCand::getRefereeStatusString(std::string delimiter)
const
213 std::string statusString;
214 if (getRefereeStatus() == 0)
return statusString;
215 if (hasRefereeStatus(c_checkedByReferee)) statusString +=
"checkedByReferee" + delimiter;
216 if (hasRefereeStatus(c_checkedClean)) statusString +=
"checkedClean" + delimiter;
217 if (hasRefereeStatus(c_hitsOnSameSensor)) statusString +=
"hitsOnSameSensor" + delimiter;
218 if (hasRefereeStatus(c_hitsLowDistance)) statusString +=
"hitsLowDistance" + delimiter;
219 if (hasRefereeStatus(c_removedHits)) statusString +=
"removedHits" + delimiter;
220 if (hasRefereeStatus(c_checkedTrueHits)) statusString +=
"checkedTrueHits" + delimiter;
221 if (hasRefereeStatus(c_checkedSameSensors)) statusString +=
"checkedSameSensors" + delimiter;
222 if (hasRefereeStatus(c_checkedMinDistance)) statusString +=
"checkedMinDistance" + delimiter;
223 if (hasRefereeStatus(c_curlingTrack)) statusString +=
"curlingTrack" + delimiter;
224 if (hasRefereeStatus(c_omittedClusters)) statusString +=
"omittedClusters" + delimiter;
225 if (hasRefereeStatus(c_singleClustersSPs)) statusString +=
"singleClusterSPs" + delimiter;
226 if (hasRefereeStatus(c_isActive)) statusString +=
"isActive" + delimiter;
227 if (hasRefereeStatus(c_isReserved)) statusString +=
"isReserved" + delimiter;
229 statusString.erase(statusString.end() - delimiter.size(),