CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/EventFilter/GctRawToDigi/src/GctFormatTranslateBase.h

Go to the documentation of this file.
00001 #ifndef GctFormatTranslateBase_h_
00002 #define GctFormatTranslateBase_h_
00003 
00004 // C++ includes
00005 #include <map>
00006 #include <utility>
00007 #include <string>
00008 
00009 // CMSSW includes
00010 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00011 #include "L1Trigger/TextToDigi/src/SourceCardRouting.h"
00012 #include "EventFilter/GctRawToDigi/src/GctBlockHeader.h"
00013 #include "EventFilter/GctRawToDigi/src/GctUnpackCollections.h"
00014 
00015 
00029 class GctFormatTranslateBase
00030 {
00031 public:
00032 
00034 
00036   explicit GctFormatTranslateBase(bool hltMode = false, bool unpackSharedRegions = false);
00037   
00038   virtual ~GctFormatTranslateBase(); 
00039   
00041   void setUnpackCollections(GctUnpackCollections * const collections) { m_collections = collections; }
00042   
00043   // Set the bunch crossing ID that will be put into the block headers when packing raw data (i.e. Digi -> Raw).
00044   void setPackingBxId(uint32_t bxId) { m_packingBxId = bxId; }
00045   
00046   // Set the event ID that will be put into the block headers when packing raw data (i.e. Digi -> Raw).
00047   void setPackingEventId(uint32_t eventId) { m_packingEventId = eventId; }
00048 
00050   virtual GctBlockHeader generateBlockHeader(const unsigned char * data) const = 0;
00051   
00053   const std::string& getBlockDescription(const GctBlockHeader& header) const;
00054 
00056   virtual bool convertBlock(const unsigned char * d, const GctBlockHeader& hdr) = 0;
00057 
00058 protected:
00059  
00060   /* PROTECTED TYPDEFS, ENUMS, AND CLASS CONSTANTS. */
00061 
00063 
00064   enum EmCandCatagory { NON_ISO_EM_CANDS, ISO_EM_CANDS, NUM_EM_CAND_CATEGORIES };
00065 
00067 
00068   enum JetCandCategory { TAU_JETS, FORWARD_JETS, CENTRAL_JETS, NUM_JET_CATEGORIES };
00069 
00070   typedef std::map<unsigned int, unsigned int> BlockLengthMap;   
00071   typedef std::pair<unsigned int, unsigned int> BlockLengthPair; 
00072   typedef std::map<unsigned int, std::string> BlockNameMap;   
00073   typedef std::pair<unsigned int, std::string> BlockNamePair; 
00074 
00076   typedef std::map<unsigned int, unsigned int> BlkToRctCrateMap;
00077 
00083   typedef std::pair<unsigned int, unsigned int> IsoBoundaryPair;
00084   
00086   typedef std::map<unsigned int, IsoBoundaryPair> BlockIdToEmCandIsoBoundMap;
00087 
00088 
00089   /* PROTECTED METHODS */
00090 
00091   /* Static data member access methods */
00092   virtual BlockLengthMap& blockLengthMap() = 0; 
00093   virtual const BlockLengthMap& blockLengthMap() const = 0; 
00094   
00095   virtual BlockNameMap& blockNameMap() = 0;  
00096   virtual const BlockNameMap& blockNameMap() const = 0;  
00097   
00098   virtual BlkToRctCrateMap& rctEmCrateMap() = 0;  
00099   virtual const BlkToRctCrateMap& rctEmCrateMap() const = 0;  
00100  
00101   virtual BlkToRctCrateMap& rctJetCrateMap() = 0;  
00102   virtual const BlkToRctCrateMap& rctJetCrateMap() const = 0;  
00103 
00104   virtual BlockIdToEmCandIsoBoundMap& internEmIsoBounds() = 0;  
00105   virtual const BlockIdToEmCandIsoBoundMap& internEmIsoBounds() const = 0;  
00106 
00107 
00108   /* Data member access methods */
00109   GctUnpackCollections * const colls() const { return m_collections; } 
00110   bool hltMode() const { return m_hltMode; }  
00111   bool unpackSharedRegions() const { return m_unpackSharedRegions; }  
00112   const SourceCardRouting& srcCardRouting() const { return m_srcCardRouting; } 
00113   const uint32_t packingBxId() const { return m_packingBxId; } 
00114   const uint32_t packingEventId() const { return m_packingEventId; } 
00115 
00116 
00117   /* Other general methods */
00119   L1GctJetCandCollection * const gctJets(const unsigned cat) const;
00120 
00122   virtual uint32_t generateRawHeader(const uint32_t blockId,
00123                                      const uint32_t nSamples,
00124                                      const uint32_t bxId,
00125                                      const uint32_t eventId) const = 0;
00126 
00128 
00129   void writeRawHeader(unsigned char * data, uint32_t blockId, uint32_t nSamples) const;
00130 
00132   bool checkBlock(const GctBlockHeader& hdr) const;
00133   
00135   void blockDoNothing(const unsigned char * d, const GctBlockHeader& hdr) {}
00136   
00137 
00138 private:
00139 
00140   /* PRIVATE STATIC CONSTS */
00141   static const std::string INVALID_BLOCK_HEADER_STR;
00142 
00143   /* PRIVATE MEMBER DATA */
00144 
00146   GctUnpackCollections * m_collections;  
00147 
00149   bool m_hltMode;
00150   
00152 
00153   bool m_unpackSharedRegions;
00154 
00156   SourceCardRouting m_srcCardRouting;
00157   
00159   uint32_t m_packingBxId;
00160   
00162   uint32_t m_packingEventId;
00163 
00164 };
00165 
00166 #endif /* GctFormatTranslateBase_h_ */