Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:12

0001 #ifndef RctRawToDigi_h
0002 #define RctRawToDigi_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    RctRawToDigi
0007 // Class:      RctRawToDigi
0008 //
0009 /**\class RctRawToDigi RctRawToDigi.cc EventFilter/RctRawToDigi/src/RctRawToDigi.cc
0010 
0011  Description: Produce RCT digis from raw data
0012 
0013  Implementation:
0014      <Notes on implementation>
0015 */
0016 
0017 // system include files
0018 #include <memory>
0019 #include <ostream>
0020 #include <string>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 #include "FWCore/Framework/interface/stream/EDProducer.h"
0025 #include "FWCore/Framework/interface/Event.h"
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027 #include "FWCore/Utilities/interface/InputTag.h"
0028 
0029 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0030 #include "EventFilter/RctRawToDigi/src/RctUnpackCollections.h"
0031 #include "EventFilter/RctRawToDigi/src/RCTInfo.hh"
0032 #include "EventFilter/RctRawToDigi/src/CTP7Format.hh"
0033 #include "EventFilter/L1TRawToDigi/interface/AMCSpec.h"
0034 #include "EventFilter/RctRawToDigi/src/RctDataDecoder.hh"
0035 
0036 // *******************************************************************
0037 // ***  THE UNPACK PROCESS MUST NEVER THROW ANY KIND OF EXCEPTION! ***
0038 // *******************************************************************
0039 
0040 class RctRawToDigi : public edm::stream::EDProducer<> {
0041 public:
0042   explicit RctRawToDigi(const edm::ParameterSet &);
0043   ~RctRawToDigi() override;
0044 
0045   //do we need this?
0046   //static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0047 
0048 private:  // methods
0049   void produce(edm::Event &, const edm::EventSetup &) override;
0050 
0051   /// Unpacks the raw data
0052   /*! \param invalidDataFlag - if true, then won't attempt unpack but just output empty collecions. */
0053   void unpack(const FEDRawData &d, edm::Event &e, RctUnpackCollections *const colls);
0054 
0055   void unpackCTP7(const uint32_t *data, const unsigned block_id, const unsigned size, RctUnpackCollections *const colls);
0056 
0057   bool decodeLinkID(const uint32_t inputValue, uint32_t &crateNumber, uint32_t &linkNumber, bool &even);
0058 
0059   bool printAll(const unsigned char *data, const unsigned size);
0060   /// Looks at the firmware version header in the S-Link packet and instantiates relevant format translator.
0061   /// check block headers for consistency
0062   void checkHeaders();
0063 
0064   /// method called at job end - use to print summary report
0065   virtual void endJob();
0066 
0067 private:  // members
0068   // SLink Header Size: 64bits
0069   static const unsigned sLinkHeaderSize_ = 8;
0070 
0071   // SLink Trailer Size: 64bits
0072   static const unsigned sLinkTrailerSize_ = 8;
0073 
0074   // SLink Header Size: two 64bit words
0075   static const unsigned amc13HeaderSize_ = 16;
0076 
0077   // SLink Trailer Size: 64bits
0078   static const unsigned amc13TrailerSize_ = 8;
0079 
0080   // CTP7 Header Size: 64bits
0081   static const unsigned ctp7HeaderSize_ = 8;
0082 
0083   // CTP7 Trailer Size: 64bits
0084   static const unsigned ctp7TrailerSize_ = 8;
0085 
0086   /// The maximum number of blocks we will try to unpack before thinking something is wrong
0087   static const unsigned MAX_DATA = 4680;
0088 
0089   /// The minimum number of blocks we will try to unpack before thinking something is wrong (really this should be 920, to be tested)
0090   static const unsigned MIN_DATA = 900;
0091 
0092   // unpacking options
0093   edm::InputTag inputLabel_;  ///< FED collection label.
0094   int fedId_;                 ///< RCT FED ID.
0095 
0096   const bool verbose_;  ///< If true, then debug print out for each event.
0097 
0098   // vector of unpacked block headers, for verbostity and/or sync checks
0099   //RctBlockHeaderCollection blockHeaders_;
0100 
0101   // error handling
0102   static const unsigned MAX_ERR_CODE = 6;
0103   L1TriggerErrorCollection *errors_;     ///< pointer to error collection
0104   std::vector<unsigned> errorCounters_;  ///< Counts number of errors for each code (index)
0105   unsigned unpackFailures_;              ///< To count the total number of RCT unpack failures.
0106 };
0107 
0108 #endif