#ifndef __JDETECTOR__JPMTDEFAULTSIMULATOR__ #define __JDETECTOR__JPMTDEFAULTSIMULATOR__ #include #include "JTools/JHashMap.hh" #include "JDetector/JPMTDefaultSimulatorInterface.hh" #include "JDetector/JPMTParametersMap.hh" #include "JDetector/JDetector.hh" #include "JDetector/JPMTAnalogueSignalProcessor.hh" /** * \author mdejong */ namespace JDETECTOR {} namespace JPP { using namespace JDETECTOR; } namespace JDETECTOR { using JTOOLS::JHashMap; /** * Auxiliary container for PMT analogue signal processors in same optical module. */ struct JModuleAnalogueSignalProcessor : public std::vector { /** * Put PMT signal processor in container at given readout channel. * * \param pmt PMT readout channel * \param cpu PMT signal processor */ void put(const size_t pmt, const JPMTAnalogueSignalProcessor& cpu) { if (this->size() <= pmt) { this->resize(pmt + 1); } (*this)[pmt] = cpu; } }; /** * Default PMT simulation. * * This class implements the JPMTDefaultSimulatorInterface interface for a given detector * using the JPMTAnalogueSignalProcessor with corresponding PMT parameters. */ class JPMTDefaultSimulator : public JPMTDefaultSimulatorInterface, public JHashMap { public: /** * Default constructor. */ JPMTDefaultSimulator() {} /** * Constructor for complete detector. * * \param parameters PMT parameters * \param detector detector */ JPMTDefaultSimulator(const JPMTParametersMap& parameters, const JDetector& detector) { for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) { for (size_t pmt = 0; pmt != module->size(); ++pmt) { this->get(module->getID()).put(pmt, JPMTAnalogueSignalProcessor(parameters.getPMTParameters(JPMTIdentifier(module->getID(), pmt)))); } } } /** * Constructor for single PMT. * * \param parameters PMT parameters * \param pmt PMT identifier */ JPMTDefaultSimulator(const JPMTParameters& parameters, const JPMTIdentifier& pmt) { this->get(pmt.getID()).put(pmt.getPMTAddress(), JPMTAnalogueSignalProcessor(parameters)); } /** * Has PMT signal processor. * * \param pmt PMT identifier * \return true if this has PMT signal processor; else false */ virtual const bool hasPMTSignalProcessor(const JPMTIdentifier& pmt) const { return this->has(pmt.getID()); } /** * Get PMT signal processor. * * \param pmt PMT identifier * \return PMT signal processor */ virtual const JPMTSignalProcessorInterface& getPMTSignalProcessor(const JPMTIdentifier& pmt) const override { return this->get(pmt.getID())[pmt.getPMTAddress()]; } }; } #endif