Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:45

0001 #ifndef EventFilter_L1GlobalTriggerRawToDigi_L1GTDigiToRaw_h
0002 #define EventFilter_L1GlobalTriggerRawToDigi_L1GTDigiToRaw_h
0003 
0004 /**
0005  * \class L1GTDigiToRaw
0006  *
0007  *
0008  * Description: generate raw data from digis.
0009  *
0010  * Implementation:
0011  *    <TODO: enter implementation details>
0012  *
0013  * \author: Vasile Mihai Ghete - HEPHY Vienna -  GT
0014  * \author: Ivan Mikulec       - HEPHY Vienna - GMT
0015  *
0016  *
0017  */
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/stream/EDProducer.h"
0025 
0026 #include "FWCore/Framework/interface/Event.h"
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028 
0029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0030 #include "FWCore/Utilities/interface/InputTag.h"
0031 #include "FWCore/Utilities/interface/typedefs.h"
0032 #include "FWCore/Utilities/interface/ESGetToken.h"
0033 
0034 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0035 #include "CondFormats/L1TObjects/interface/L1GtBoardMaps.h"
0036 #include "CondFormats/DataRecord/interface/L1GtBoardMapsRcd.h"
0037 
0038 // forward declarations
0039 class FEDRawDataCollection;
0040 class L1MuGMTReadoutRecord;
0041 class L1MuGMTReadoutCollection;
0042 
0043 class L1GtfeWord;
0044 class L1GtFdlWord;
0045 class L1GtPsbWord;
0046 
0047 // class declaration
0048 class L1GTDigiToRaw : public edm::stream::EDProducer<> {
0049 public:
0050   /// constructor(s)
0051   explicit L1GTDigiToRaw(const edm::ParameterSet&);
0052 
0053 private:
0054   /// loop over events
0055   void produce(edm::Event&, const edm::EventSetup&) override;
0056 
0057   /// block packers -------------
0058 
0059   /// pack header
0060   void packHeader(unsigned char*, edm::Event&);
0061 
0062   /// pack the GTFE block
0063   /// gives the number of bunch crosses in the event, as well as the active boards
0064   /// records for inactive boards are not written in the GT DAQ record
0065   void packGTFE(const edm::EventSetup&, unsigned char*, L1GtfeWord&, cms_uint16_t activeBoardsGtValue);
0066 
0067   /// pack FDL blocks for various bunch crosses
0068   void packFDL(const edm::EventSetup&, unsigned char*, L1GtFdlWord&);
0069 
0070   /// pack PSB blocks
0071   /// packing is done in PSB class format
0072   void packPSB(const edm::EventSetup&, unsigned char*, L1GtPsbWord&);
0073 
0074   /// pack the GMT collection using packGMT (GMT record packing)
0075   unsigned int packGmtCollection(unsigned char* ptrGt, L1MuGMTReadoutCollection const* digis);
0076 
0077   /// pack a GMT record
0078   unsigned int packGMT(L1MuGMTReadoutRecord const&, unsigned char*);
0079   unsigned int flipPtQ(unsigned int);
0080 
0081   /// pack trailer word
0082   void packTrailer(unsigned char*, unsigned char*, int);
0083 
0084 private:
0085   /// FED Id for GT DAQ record
0086   /// default value defined in DataFormats/FEDRawData/src/FEDNumbering.cc
0087   int m_daqGtFedId;
0088 
0089   /// input tag for GT DAQ record
0090   const edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> m_daqGtInputToken;
0091 
0092   /// input tag for GMT record
0093   const edm::EDGetTokenT<L1MuGMTReadoutCollection> m_muGmtInputToken;
0094   const edm::InputTag m_daqGtInputTag;
0095   const edm::InputTag m_muGmtInputTag;
0096 
0097   /// EventSetup Token for L1GtBoardMaps
0098   const edm::ESGetToken<L1GtBoardMaps, L1GtBoardMapsRcd> m_l1GtBMToken;
0099 
0100   /// mask for active boards
0101   cms_uint16_t m_activeBoardsMaskGt;
0102 
0103   /// total Bx's in the event, obtained from GTFE block
0104   int m_totalBxInEvent;
0105 
0106   /// min Bx's in the event, computed after m_totalBxInEvent is obtained from GTFE block
0107   /// assume symmetrical number of BX around L1Accept
0108   int m_minBxInEvent;
0109 
0110   /// max Bx's in the event, computed after m_totalBxInEvent is obtained from GTFE block
0111   /// assume symmetrical number of BX around L1Accept
0112   int m_maxBxInEvent;
0113 
0114 private:
0115   /// verbosity level
0116   int m_verbosity;
0117   bool m_isDebugEnabled;
0118 };
0119 
0120 #endif  // EventFilter_L1GlobalTriggerRawToDigi_L1GTDigiToRaw_h