#ifndef _mevt_Module_h_ #define _mevt_Module_h_ #include #include #include #include #include #include #include // forward declaration used for friendship namespace io { class Module_ROOT; } namespace mevt { /** * \class Module Module.h "mevt/Module.h" * \brief Module level event data. * * \author Rodolfo Federico Gamarra * \date 08 Mar 2009 * \ingroup mevt */ class Module { /* * On the detector level the hierarchy was split in * Module->FrontEnd->Channel * Module->PMT->Pixel * because there was some common information at the * PMT or FrontEnd level. * In the event level having a PMT or FrontEnd doesn't * seem worth (or even proper) because the data * will have to be associated a the Channel or Pixel level. * * So we cut corners and hold the Channels here without * the circumlocution of the FrontEnd. In any case, * if in the future the FrontEnd need arises, these methods * here accesing the Channel will be a shorcut to those * in the FrontEnd. */ typedef evt::ComponentGroup InternalScintillatorCollection; typedef evt::ComponentGroup InternalChannelCollection; public: /** * \name Members for management of contained channels. */ //@{ typedef InternalChannelCollection::ComponentConstIterator ChannelConstIterator; typedef InternalChannelCollection::ComponentIterator ChannelIterator; /** * \name Trace of integrated signal. */ //@{ utl::TraceUSI& GetDynodeTrace(); const utl::TraceUSI& GetDynodeTrace() const; void MakeDynodeTrace(); bool HasDynodeTrace() const; Channel& GetChannel(const int cId) { return fChannels.Get(cId); } const Channel& GetChannel(const int cId) const { return fChannels.Get(cId); } void MakeChannel(const int cId) { fChannels.Make(cId); } bool HasChannel(const int cId) const { return fChannels.Has(cId); } int GetNumberOfChannels() const { return fChannels.GetNumberOf(); } ChannelConstIterator ChannelsBegin() const { return fChannels.Begin(); } ChannelConstIterator ChannelsEnd() const { return fChannels.End(); } ChannelIterator ChannelsBegin() { return fChannels.Begin(); } ChannelIterator ChannelsEnd() { return fChannels.End(); } /** * \name Members for management of contained scintillators. */ //@{ typedef InternalScintillatorCollection::ComponentConstIterator ScintillatorConstIterator; typedef InternalScintillatorCollection::ComponentIterator ScintillatorIterator; Scintillator& GetScintillator(const int sId) { return fScintillators.Get(sId); } const Scintillator& GetScintillator(const int sId) const { return fScintillators.Get(sId); } void MakeScintillator(const int sId) { fScintillators.Make(sId); } bool HasScintillator(const int sId) const { return fScintillators.Has(sId); } int GetNumberOfScintillators() const { return fScintillators.GetNumberOf(); } ScintillatorConstIterator ScintillatorsBegin() const { return fScintillators.Begin(); } ScintillatorConstIterator ScintillatorsEnd() const { return fScintillators.End(); } ScintillatorIterator ScintillatorsBegin() { return fScintillators.Begin(); } ScintillatorIterator ScintillatorsEnd() { return fScintillators.End(); } //@} /** * \name Module simulation data. */ //@{ ModuleSimData& GetSimData() { return *fSimData; } const ModuleSimData& GetSimData() const { return *fSimData; } void MakeSimData(); bool HasSimData() const { return fSimData; } //! \name Methods for setting/getting status flags //@{ void SetCandidate() { fRecStatus = eCandidate; } bool IsCandidate() const { return fRecStatus == eCandidate; } void SetSilent() { fRecStatus = eSilent; } bool IsSilent() const { return fRecStatus == eSilent; } void SetRejected(std::string reason = "") { fRecStatus = eRejected; fRejectionReason = reason; } bool IsRejected() const { return fRecStatus == eRejected; } std::string GetRejectionReason() const { return fRejectionReason; } void SetChannelMask( const std::bitset<64> mask ) { fChannelMask = mask; } size_t GetNumberOfActiveChannels() const { return fChannelMask.size()-fChannelMask.count(); } //@} /** * \name Module reconstruction data. */ //@{ ModuleRecData& GetRecData() { return *fRecData; } const ModuleRecData& GetRecData() const { return *fRecData; } void MakeRecData(); bool HasRecData() const { return fRecData; } //@ int GetId() const { return fId; } // Implicit ones. //Module(const Module& module); //Module& operator=(const Module& module); private: /** * \brief The muon module status * * The status of the module indicates if it will be used * in the reconstruction. Candidates modules are used * and rejected modules are skipped. The module level status * has is used in conjunction to the counter level status * in the reconstruction. See the note about the muon counter status. */ enum ModuleReconstructionStatus { eUndefined = 0, eCandidate, eSilent, eRejected }; Module(); ~Module(); /** * \brief Constructs the Module with the given identificator. */ Module(int mId) : fId(mId) { fRecStatus = eUndefined; } /** * \brief Friendship to allow creation. * */ friend class evt::ComponentGroup; /** * \brief Friendship for destruction. * * Depends on evt::ComponentGroup innards. */ template friend void boost::checked_delete(T*); /** * \brief Friendship for persistency in ROOT * * Implemented originally for requirements to persist the status. * Can be extended to other fields eventually. */ friend class io::Module_ROOT; void SetRecStatus( int s ) { fRecStatus = static_cast(s); } int fId; ModuleReconstructionStatus fRecStatus; std::string fRejectionReason; InternalScintillatorCollection fScintillators; InternalChannelCollection fChannels; utl::ShadowPtr fSimData; utl::ShadowPtr fRecData; utl::ShadowPtr fDynodeTrace; std::bitset<64> fChannelMask; // mask of working channels 0 = working, 1 = not working }; } // namespace mevt #endif