// $Id$ // // File: DTranslationTable.h // Created: Thu Jun 27 15:33:38 EDT 2013 // Creator: davidl (on Darwin harriet.jlab.org 11.4.2 i386) // #ifndef _DTranslationTable_ #define _DTranslationTable_ #include #include #include #include #include #include #include #include "TString.h" using namespace std; class DTranslationTable{ public: DTranslationTable(); ~DTranslationTable(); // Each detector system has its own native indexing scheme. // Here, we define a class for each of them that has those // indexes. These are then used below in the DChannelInfo // class to relate them to the DAQ indexing scheme of // crate, slot, channel. struct csc_t{ uint32_t rocid; uint32_t slot; uint32_t channel; inline bool operator==(const struct csc_t &rhs) const { return (rocid==rhs.rocid) && (slot==rhs.slot) && (channel==rhs.channel); } }; enum Detector_t{ UNKNOWN_DETECTOR, BCAL, CDC, FCAL, FDC_CATHODES, FDC_WIRES, PS, PSC, SC, TAGH, TAGM, TOF }; string DetectorName(Detector_t type) const { switch(type){ case BCAL: return "BCAL"; case CDC: return "CDC"; case FCAL: return "FCAL"; case FDC_CATHODES: return "FDC_CATHODES"; case FDC_WIRES: return "FDC_WIRES"; case PS: return "PS"; case PSC: return "PSC"; case SC: return "SC"; case TAGH: return "TAGH"; case TAGM: return "TAGM"; case TOF: return "TOF"; case UNKNOWN_DETECTOR: default: return "UNKNOWN"; } } class BCALIndex_t{ public: uint32_t module; uint32_t layer; uint32_t sector; uint32_t end; inline bool operator==(const BCALIndex_t &rhs) const { return (module==rhs.module) && (layer==rhs.layer) && (sector==rhs.sector) && (end==rhs.end); } }; class CDCIndex_t{ public: uint32_t ring; uint32_t straw; inline bool operator==(const CDCIndex_t &rhs) const { return (ring==rhs.ring) && (straw==rhs.straw); } }; class FCALIndex_t{ public: uint32_t row; uint32_t col; inline bool operator==(const FCALIndex_t &rhs) const { return (row==rhs.row) && (col==rhs.col); } }; class FDC_CathodesIndex_t{ public: uint32_t package; uint32_t chamber; uint32_t view; uint32_t strip; uint32_t strip_type; inline bool operator==(const FDC_CathodesIndex_t &rhs) const { return (package==rhs.package) && (chamber==rhs.chamber) && (view==rhs.view) && (strip==rhs.strip) && (strip_type==rhs.strip_type); } }; class FDC_WiresIndex_t{ public: uint32_t package; uint32_t chamber; uint32_t wire; inline bool operator==(const FDC_WiresIndex_t &rhs) const { return (package==rhs.package) && (chamber==rhs.chamber) && (wire==rhs.wire); } }; class PSIndex_t{ public: uint32_t side; uint32_t id; inline bool operator==(const PSIndex_t &rhs) const { return (side==rhs.side) && (id==rhs.id); } }; class PSCIndex_t{ public: uint32_t id; inline bool operator==(const PSCIndex_t &rhs) const { return (id==rhs.id); } }; class SCIndex_t{ public: uint32_t sector; inline bool operator==(const SCIndex_t &rhs) const { return (sector==rhs.sector); } }; class TAGHIndex_t{ public: uint32_t id; inline bool operator==(const TAGHIndex_t &rhs) const { return (id==rhs.id); } }; class TAGMIndex_t{ public: uint32_t col; uint32_t row; inline bool operator==(const TAGMIndex_t &rhs) const { return (col==rhs.col) && (row==rhs.row); } }; class TOFIndex_t{ public: uint32_t plane; uint32_t bar; uint32_t end; inline bool operator==(const TOFIndex_t &rhs) const { return (plane==rhs.plane) && (bar==rhs.bar) && (end==rhs.end); } }; // DChannelInfo holds translation between indexing schemes // for one channel. class DChannelInfo{ public: csc_t CSC; Detector_t det_sys; union{ BCALIndex_t bcal; CDCIndex_t cdc; FCALIndex_t fcal; FDC_CathodesIndex_t fdc_cathodes; FDC_WiresIndex_t fdc_wires; PSIndex_t ps; PSCIndex_t psc; SCIndex_t sc; TAGHIndex_t tagh; TAGMIndex_t tagm; TOFIndex_t tof; }; }; // Full translation table is collection of DChannelInfo objects //map TT; void ReadOptionalROCidTranslation(void); void ReadTranslationTable(); // methods for others to search the Translation Table const DChannelInfo &GetDetectorIndex(const csc_t &in_daq_index) const; const csc_t &GetDAQIndex(const DChannelInfo &in_channel) const; protected: TString XML_FILENAME; bool NO_CCDB; string Channel2Str(const DChannelInfo &in_channel) const; }; #endif // _DTranslationTable_