Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /****************************************************************************
0002  *
0003  * This is a part of the TOTEM offline software.
0004  * Authors: 
0005  *
0006  ****************************************************************************/
0007 
0008 #ifndef EventFilter_CTPPSRawToDigi_CTPPSTotemDataFormatter_h
0009 #define EventFilter_CTPPSRawToDigi_CTPPSTotemDataFormatter_h
0010 
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "DataFormats/Common/interface/DetSetVector.h"
0013 
0014 #include "CondFormats/PPSObjects/interface/TotemDAQMapping.h"
0015 
0016 #include "DataFormats/CTPPSDigi/interface/TotemRPDigi.h"
0017 #include "DataFormats/CTPPSDigi/interface/TotemVFATStatus.h"
0018 #include "DataFormats/CTPPSDigi/interface/CTPPSDiamondDigi.h"
0019 
0020 #include "FWCore/Utilities/interface/typedefs.h"
0021 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0022 #include "DataFormats/FEDRawData/interface/FEDHeader.h"
0023 #include "DataFormats/FEDRawData/interface/FEDTrailer.h"
0024 #include <cstdint>
0025 #include <vector>
0026 #include <map>
0027 #include "FWCore/Framework/interface/ESHandle.h"
0028 #include "DataFormats/CTPPSDigi/interface/TotemVFATStatus.h"
0029 #include "EventFilter/CTPPSRawToDigi/interface/VFATFrame.h"
0030 #include "FWCore/Framework/interface/EventSetup.h"
0031 
0032 //brief Collection of code to convert TOTEM raw data into digi.
0033 
0034 class FEDRawData;
0035 class CTPPSTotemDigiToRaw;
0036 
0037 class CTPPSTotemDataFormatter {
0038 private:
0039   typedef uint16_t Word16;
0040   typedef uint32_t Word32;
0041   typedef uint64_t Word64;
0042 
0043   int m_WordCounter;
0044   int m_DigiCounter;
0045 
0046 public:
0047   typedef std::unordered_map<int, FEDRawData> RawData;
0048   typedef std::vector<TotemRPDigi> DetDigis;
0049   typedef std::unordered_map<cms_uint32_t, DetDigis> Digis;
0050 
0051   CTPPSTotemDataFormatter(std::map<TotemFramePosition, TotemVFATInfo> const& mapping);
0052 
0053   int nWords() const { return m_WordCounter; }
0054   int nDigis() const { return m_DigiCounter; }
0055 
0056   struct PPSStripIndex {
0057     uint32_t id;
0058     unsigned int hwid;
0059     short unsigned int fedid;
0060     short unsigned int idxinfiber;
0061     short unsigned int gohid;
0062   };
0063 
0064   void formatRawData(unsigned int lvl1_ID,
0065                      RawData& fedRawData,
0066                      const Digis& digis,
0067                      std::vector<PPSStripIndex> v_iDdet2fed);
0068 
0069   static bool compare(const PPSStripIndex& a, const PPSStripIndex& b) { return a.id < b.id; }
0070 
0071   std::string print(const Word64& word) const;
0072 };
0073 
0074 #endif