// ClusterFindAll.cpp #include "ClusterFindAll.h" #include "objstream/ObjData.hpp" #include "objstream/ObjTable.hpp" #include "trfutil/trfstream.h" #include "trfbase/Surface.h" using trf::SurfacePtr; using trf::ClusterList; using trf::ClusterFindAll; //********************************************************************** // Free functions. //********************************************************************** namespace { // Creator. ObjPtr create_ClusterFindAll(const ObjData& data) { assert( data.get_object_type() == "ClusterFindAll" ); if ( data.get_object_type() != "ClusterFindAll" ) return ObjPtr(0); SurfacePtr psrf; data.get_share_pointer("srf",psrf); if ( psrf == 0 ) return ObjPtr(0); return ObjPtr( new ClusterFindAll(psrf) ); } } //********************************************************************** // Member functions. //********************************************************************** // Return the creator. ObjCreator ClusterFindAll::get_creator() { return create_ClusterFindAll; } //********************************************************************** // output stream void ClusterFindAll::ostr(ostream& stream) const { stream << begin_object; stream << "Finder for all clusters." << new_line; stream << "Finder surface: " << *_psrf << new_line; int size = _clusters.size(); if ( size == 1 ) stream << "There is " << size << " cluster"; else stream << "Finder has " << size << " clusters"; if ( size == 0 ) stream << "."; else { stream << ":"; ClusterList::const_iterator iclu; for ( iclu=_clusters.begin(); iclu!=_clusters.end(); ++iclu ) stream << new_line << **iclu; } stream << end_object; } //********************************************************************** // constructor from surface ClusterFindAll::ClusterFindAll(const SurfacePtr& psrf) : _psrf(psrf) { } //********************************************************************** // destructor ClusterFindAll::~ClusterFindAll() { } //********************************************************************** // Write data object. ObjData ClusterFindAll::write_data() const { ObjData data("ClusterFindAll"); data.add_share_pointer("srf",_psrf); return data; } //********************************************************************** // add a cluster int ClusterFindAll::add_cluster(const ClusterPtr& pclu) { _clusters.push_back(pclu); return 0; } //********************************************************************** // drop all clusters void ClusterFindAll::drop_clusters() { _clusters.erase( _clusters.begin(), _clusters.end() ); } //********************************************************************** // Return all the clusters associated with this surface. ClusterList ClusterFindAll::get_clusters() const { return _clusters; } //********************************************************************** // Return the clusters near a track -- here we return all. ClusterList ClusterFindAll::get_clusters(const ETrack& tre) const { return _clusters; } //**********************************************************************