// LayerStat.cpp #include "LayerStat.h" #include "trfutil/trfstream.h" #include "trfbase/Miss.h" #include "LayerPtr.h" #include "ClusterFinder.h" #include "ClusterContainerStandard.h" using std::map; using trf::LayerPtr; using trf::Miss; using trf::MissPtr; using trf::ClusterList; using trf::ClusterContainer; using trf::ClusterContainerStandard; using trf::LayerStat; //********************************************************************** // Local data. const ClusterContainerStandard _empty_box; //********************************************************************** //********************************************************************** // Methods. //********************************************************************** // default constructor LayerStat::LayerStat() : _player(0) { reset(); } //********************************************************************** // constructor from a layer LayerStat::LayerStat(const Layer& layer) : _player(&layer) { reset(); } //********************************************************************** // copy constructor LayerStat::LayerStat(const LayerStat& rhs) : _player(rhs._player), _at_exit(rhs._at_exit), _pmiss( rhs._pmiss ), _pfinder( rhs._pfinder ), _layer_state(rhs._layer_state) { } //********************************************************************** // assignment operator LayerStat& LayerStat::operator=(const LayerStat& rhs) { if ( this == &rhs ) return *this; _player = rhs._player; _at_exit = rhs._at_exit; _pmiss = rhs._pmiss; _pfinder = rhs._pfinder; _layer_state = rhs._layer_state; return *this; } //********************************************************************** // destructor LayerStat::~LayerStat() { } //********************************************************************** // output stream void LayerStat::ostr(ostream& stream) const { stream << begin_object; stream << "LayerStat is "; if ( ! _at_exit ) stream << "not "; stream << "at exit." << new_line; // Display the miss, finder and state. if ( _pmiss ) stream << *_pmiss << new_line; else stream << "No miss." << new_line; if ( _pfinder ) stream << *_pfinder << new_line; else stream << "No cluster finder." << new_line; stream << "Layer state: " << _layer_state; stream << end_object; } //********************************************************************** // Reset the flags, the miss, the finder and the state. void LayerStat::reset() { _at_exit = false; _pmiss = 0; _pfinder = 0; _layer_state = 0; } //********************************************************************** // set the miss void LayerStat::set_miss(const Miss& miss) { _pmiss = miss.new_copy(); } //********************************************************************** // drop the miss void LayerStat::unset_miss() { _pmiss = 0; } //********************************************************************** // Return all the clusters associated with this surface in the layer. // Default here is to return all clusters from the last layer in the // nest. ClusterList LayerStat::get_clusters() const { if ( ! _pfinder ) return ClusterList(); return _pfinder->get_clusters(); } //********************************************************************** // Return all the clusters near the specified track associated with // the track's surface in the current layer or its descendants. // Default here is to return all clusters from the last layer in the // nest. Generate CutRecords. const ClusterContainer& LayerStat:: get_clusters(const ETrack& tre, const CutRecord* pcut_record, map* precs) const { if ( ! _pfinder ) return _empty_box; return _pfinder->get_cluster_container(tre, pcut_record, precs); } //********************************************************************** // output stream ostream& trf::operator<<(ostream& stream, const LayerStat& lstat) { lstat.ostr(stream); return stream; } //**********************************************************************