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 *   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 #include "CondFormats/PPSObjects/interface/TotemT2FramePosition.h"
0021 
0022 namespace pps {
0023   /// \brief Collection of code for unpacking of TOTEM raw-data.
0024   class RawDataUnpacker {
0025   public:
0026     typedef uint64_t word;
0027 
0028     /// VFAT transmission modes
0029     enum { vmCluster = 0x80, vmRaw = 0x90, vmDiamondCompact = 0xB0 };
0030 
0031     // list of headers for all words encountered in diamond data frames
0032     static constexpr unsigned int VFAT_DIAMOND_HEADER_OF_WORD_2 = 0x7800;
0033     static constexpr unsigned int VFAT_DIAMOND_HEADER_OF_WORD_3 = 0x7000;
0034     static constexpr unsigned int VFAT_DIAMOND_HEADER_OF_WORD_5 = 0x6800;
0035     static constexpr unsigned int VFAT_DIAMOND_HEADER_OF_WORD_7 = 0x6000;
0036     static constexpr unsigned int VFAT_HEADER_OF_EC = 0xC000;
0037 
0038     RawDataUnpacker() {}
0039 
0040     RawDataUnpacker(const edm::ParameterSet &conf);
0041 
0042     /// Unpack data from FED with fedId into `coll' collection.
0043     int run(int fedId,
0044             const FEDRawData &data,
0045             std::vector<TotemFEDInfo> &fedInfoColl,
0046             SimpleVFATFrameCollection &coll) const;
0047 
0048     /// Process one Opto-Rx (or LoneG) frame.
0049     int processOptoRxFrame(const word *buf,
0050                            unsigned int frameSize,
0051                            TotemFEDInfo &fedInfo,
0052                            SimpleVFATFrameCollection *fc) const;
0053 
0054     /// Process one Opto-Rx frame in serial (old) format
0055     int processOptoRxFrameSerial(const word *buffer, unsigned int frameSize, SimpleVFATFrameCollection *fc) const;
0056 
0057     /// Process one Opto-Rx frame in parallel (new) format
0058     int processOptoRxFrameParallel(const word *buffer,
0059                                    unsigned int frameSize,
0060                                    TotemFEDInfo &fedInfo,
0061                                    SimpleVFATFrameCollection *fc) const;
0062 
0063     /// Process one Opto-Rx frame that contains SAMPIC frames
0064     int processOptoRxFrameSampic(const word *buffer,
0065                                  unsigned int frameSize,
0066                                  TotemFEDInfo &fedInfo,
0067                                  SimpleVFATFrameCollection *fc) const;
0068 
0069     /// Process data from one VFAT in parallel (new) format
0070     int processVFATDataParallel(const uint16_t *buf,
0071                                 unsigned int maxWords,
0072                                 unsigned int OptoRxId,
0073                                 SimpleVFATFrameCollection *fc) const;
0074 
0075   private:
0076     unsigned char verbosity;
0077   };
0078 }  // namespace pps
0079 
0080 #endif