#include "CbmSttHoughCellNew.h" void CbmSttHoughCellNew::AddClusterLink(CbmSttHoughCellNew *newLink) { fClusterLinks.push_back(newLink); } void CbmSttHoughCellNew::MergeClusterLinks(Bool_t merge, Int_t maximumIdentifier) { fBelongsToCluster = maximumIdentifier; vector::iterator link = fClusterLinks.begin(); while (link != fClusterLinks.end()) { (*link)->MergeClusterLinks(merge, maximumIdentifier); if (merge) { Merge(**link); (*link)->Clear(); } link++; } } void CbmSttHoughCellNew::RemoveHit(Int_t elementNumber) { fHits.erase(elementNumber); } void CbmSttHoughCellNew::Clear() { if (fHits.size()) fHits.clear(); if (fClusterLinks.size()) fClusterLinks.clear(); fBelongsToCluster = -1; } void CbmSttHoughCellNew::Merge(CbmSttHoughCellNew const &other) { for (Int_t hitsCounter = 0; hitsCounter < other.DifSize(); hitsCounter++) { fHits[other.GetHit(hitsCounter)] += other.GetHitContent(hitsCounter); } } void CbmSttHoughCellNew::AddHit(Int_t element1, Int_t element2, Int_t element3) { fHits[element1]++; fHits[element2]++; fHits[element3]++; } void CbmSttHoughCellNew::AddHit(CbmSttHoughHitNew newHit) { fHits[newHit.GetElement1()]++; fHits[newHit.GetElement2()]++; fHits[newHit.GetElement3()]++; } void CbmSttHoughCellNew::Copy(CbmSttHoughCellNew const &other) { Destroy(); fVerbose = other.IsVerbose(); for (Int_t cellCounter = 0; cellCounter < other.DifSize(); cellCounter++) { fHits[other.GetHit(cellCounter)] = other.GetHitContent(cellCounter); } for (Int_t linkCounter = 0; linkCounter < other.fClusterLinks.size(); linkCounter++) { CbmSttHoughCellNew * const newLink = other.fClusterLinks[linkCounter]; AddClusterLink(newLink); } fBelongsToCluster = other.fBelongsToCluster; fVerbose = other.fVerbose; fX = other.fX; fY = other.fY; fZ = other.fZ; } void CbmSttHoughCellNew::Destroy() { fHits.clear(); fClusterLinks.clear(); fBelongsToCluster = -1; fVerbose = kFALSE; fX = -1; fY = -1; fZ = -1; } CbmSttHoughCellNew::~CbmSttHoughCellNew() { Destroy(); } CbmSttHoughCellNew::CbmSttHoughCellNew(Int_t newX, Int_t newY, Int_t newZ) { fVerbose = kFALSE; fX = newX; fY = newY; fZ = newZ; Clear(); } CbmSttHoughCellNew::CbmSttHoughCellNew() { fVerbose = kFALSE; fX = -1; fY = -1; fZ = -1; Clear(); } CbmSttHoughCellNew::CbmSttHoughCellNew(CbmSttHoughCellNew const &other) { Destroy(); Copy(other); } void CbmSttHoughCellNew::operator=(CbmSttHoughCellNew const &other) { if (this != &other) { Destroy(); Copy(other); } } Int_t CbmSttHoughCellNew::DifSize() const { return fHits.size(); } Int_t CbmSttHoughCellNew::Size() const { Int_t retval = 0; map::const_iterator element = fHits.begin(); while (element != fHits.end()) { retval += element->second; element++; } return retval; } Int_t CbmSttHoughCellNew::GetHit(Int_t index) const { Int_t counter = 0, retval = -1; map::const_iterator element = fHits.begin(); while (element != fHits.end()) { retval = element->first; if (counter == index) break; counter++; element++; } if (element == fHits.end()) retval = -1; return retval; } Int_t CbmSttHoughCellNew::GetHitContent(Int_t index) const { Int_t counter = 0, retval = -1; map::const_iterator element = fHits.begin(); while (element != fHits.end()) { retval = element->second; if (counter == index) break; counter++; element++; } if (element == fHits.end()) retval = -1; return retval; } ClassImp(CbmSttHoughCellNew)