Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:59:32

0001 /****************************************************************************
0002 *
0003 * This is a part of the TOTEM offline software.
0004 * Authors:
0005 *   Jan Kašpar (jan.kaspar@gmail.com)
0006 *   Nicola Minafra
0007 *
0008 ****************************************************************************/
0009 
0010 #ifndef EventFilter_CTPPSRawToDigi_RawDataUnpacker
0011 #define EventFilter_CTPPSRawToDigi_RawDataUnpacker
0012 
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 
0015 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0016 #include "DataFormats/CTPPSDigi/interface/TotemFEDInfo.h"
0017 
0018 #include "EventFilter/CTPPSRawToDigi/interface/VFATFrameCollection.h"
0019 #include "EventFilter/CTPPSRawToDigi/interface/SimpleVFATFrameCollection.h"
0020 
0021 namespace pps {
0022   /// \brief Collection of code for unpacking of TOTEM raw-data.
0023   class RawDataUnpacker {
0024   public:
0025     typedef uint64_t word;
0026 
0027     /// VFAT transmission modes
0028     enum { vmCluster = 0x80, vmRaw = 0x90, vmDiamondCompact = 0xB0 };
0029 
0030     // list of headers for all words encountered in diamond data frames
0031     static constexpr unsigned int VFAT_DIAMOND_HEADER_OF_WORD_2 = 0x7800;
0032     static constexpr unsigned int VFAT_DIAMOND_HEADER_OF_WORD_3 = 0x7000;
0033     static constexpr unsigned int VFAT_DIAMOND_HEADER_OF_WORD_5 = 0x6800;
0034     static constexpr unsigned int VFAT_DIAMOND_HEADER_OF_WORD_7 = 0x6000;
0035     static constexpr unsigned int VFAT_HEADER_OF_EC = 0xC000;
0036 
0037     RawDataUnpacker() {}
0038 
0039     RawDataUnpacker(const edm::ParameterSet &conf);
0040 
0041     /// Unpack data from FED with fedId into `coll' collection.
0042     int run(int fedId,
0043             const FEDRawData &data,
0044             std::vector<TotemFEDInfo> &fedInfoColl,
0045             SimpleVFATFrameCollection &coll) const;
0046 
0047     /// Process one Opto-Rx (or LoneG) frame.
0048     int processOptoRxFrame(const word *buf,
0049                            unsigned int frameSize,
0050                            TotemFEDInfo &fedInfo,
0051                            SimpleVFATFrameCollection *fc) const;
0052 
0053     /// Process one Opto-Rx frame in serial (old) format
0054     int processOptoRxFrameSerial(const word *buffer, unsigned int frameSize, SimpleVFATFrameCollection *fc) const;
0055 
0056     /// Process one Opto-Rx frame in parallel (new) format
0057     int processOptoRxFrameParallel(const word *buffer,
0058                                    unsigned int frameSize,
0059                                    TotemFEDInfo &fedInfo,
0060                                    SimpleVFATFrameCollection *fc) const;
0061 
0062     /// Process one Opto-Rx frame that contains SAMPIC frames
0063     int processOptoRxFrameSampic(const word *buffer,
0064                                  unsigned int frameSize,
0065                                  TotemFEDInfo &fedInfo,
0066                                  SimpleVFATFrameCollection *fc) const;
0067 
0068     /// Process data from one VFAT in parallel (new) format
0069     int processVFATDataParallel(const uint16_t *buf,
0070                                 unsigned int maxWords,
0071                                 unsigned int OptoRxId,
0072                                 SimpleVFATFrameCollection *fc) const;
0073 
0074   private:
0075     unsigned char verbosity;
0076   };
0077 }  // namespace pps
0078 
0079 #endif