// DetectorSimulator.h #ifndef DetectorSimulator_H #define DetectorSimulator_H // A detector simulator contains a detector and a list of layer // simulators which match the layers in the detector. // // The base simulator is constructed from the detector reference. // Subclasses add layer simulators either directly or by extraction from // other detector simulators. // // Methods to add or drop clusters invoke the corresponding method on // each of the layer simulators. // // The detector and the layer simulators are managed through // shared-ownership pointers. // // Although this class is not abstract, the constructor is hidden and // users must provide subclasses to instantiate. The expectation is that // users will add layers or detectors in the subclass constructor. // #include #include #include "ptr/Ptr.h" #include "ptr/SharedDeletePolicy.h" #include "trfutil/RandomSimulator.h" #include "Detector.h" #include "LayerSimulator.h" namespace trf { class VTrack; class DetectorSimulator; // Output stream. std::ostream& operator<<(std::ostream& stream, const DetectorSimulator& dsim); class DetectorSimulator : public RandomSimulator { public: // enums // Return status for adding layer simulators. enum ReturnStatus { OK, UNKNOWN_NAME, LAYER_MISMATCH }; public: // typedefs // Layer simulator pointers and list. typedef Detector::LayerName LayerName; typedef Detector::LayerNameCmp LayerNameCmp; typedef Ptr LayerSimulatorPtr; typedef std::map LayerSimulatorMap; private: // attributes // Detector. DetectorPtr _pdet; // Layer simulators. LayerSimulatorMap _lsims; private: // methods // output stream void ostr(std::ostream& stream) const; protected: // methods // Constructors from pointers. // We take shared ownership of the detector. DetectorSimulator(const DetectorPtr& det); // Add a layer simulator by name. // We take ownership of the layer simulator. // Name must be known to the detector. // Detector and layer simulator must reference the same layer // object. // Return nonzero for error. ReturnStatus add_layer_simulator(LayerName name, LayerSimulatorPtr plsim); // Add all the layer simulators from a detector simulator. // We do not take ownership of the detector simulator and it // may be deleted after the call. // Each name must be known to the local detector. // Detector and each layer simulator must reference the same // layer object. // Return nonzero for error. ReturnStatus add_detector_simulator(const DetectorSimulator& dsim); public: // methods // Destructor. virtual ~DetectorSimulator(); // Return the detector. const DetectorPtr& get_detector_pointer() const { return _pdet; } // Return the detector. const Detector& get_detector() const { return *_pdet; } // Return the list of generators. GeneratorList get_generators(); // Use the specified track to add clusters with each layer simulator. void add_clusters(const VTrack& trv); // Use the specified track to drop clusters with each layer simulator. void drop_clusters(); // write out the generators void print_generators(std::ostream& stream) const; public: // friends // Output stream. friend std::ostream& operator<<(std::ostream& stream, const DetectorSimulator& dsim); }; } // end namespace trf #endif