Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:14:59

0001 #ifndef GctRawToDigi_h
0002 #define GctRawToDigi_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:    GctRawToDigi
0007 // Class:      GctRawToDigi
0008 //
0009 /**\class GctRawToDigi GctRawToDigi.cc EventFilter/GctRawToDigi/src/GctRawToDigi.cc
0010 
0011  Description: Produce GCT digis from raw data
0012 
0013  Implementation:
0014      <Notes on implementation>
0015 */
0016 //
0017 // Original Author:  Jim Brooke
0018 //         Created:  Wed Nov  1 11:57:10 CET 2006
0019 //
0020 //
0021 
0022 // system include files
0023 #include <memory>
0024 #include <ostream>
0025 #include <string>
0026 
0027 // user include files
0028 #include "FWCore/Framework/interface/Frameworkfwd.h"
0029 #include "FWCore/Framework/interface/stream/EDProducer.h"
0030 #include "FWCore/Framework/interface/Event.h"
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032 #include "FWCore/Utilities/interface/InputTag.h"
0033 
0034 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0035 
0036 #include "EventFilter/GctRawToDigi/src/GctUnpackCollections.h"
0037 #include "EventFilter/GctRawToDigi/src/GctFormatTranslateBase.h"
0038 
0039 // *******************************************************************
0040 // ***  THE UNPACK PROCESS MUST NEVER THROW ANY KIND OF EXCEPTION! ***
0041 // *******************************************************************
0042 
0043 class GctRawToDigi : public edm::stream::EDProducer<> {
0044 public:
0045   explicit GctRawToDigi(const edm::ParameterSet&);
0046   ~GctRawToDigi() override;
0047 
0048   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0049 
0050 private:  // methods
0051   void produce(edm::Event&, const edm::EventSetup&) override;
0052 
0053   /// Unpacks the raw data
0054   /*! \param invalidDataFlag - if true, then won't attempt unpack but just output empty collecions. */
0055   void unpack(const FEDRawData& d, edm::Event& e, GctUnpackCollections* const colls);
0056 
0057   /// Looks at the firmware version header in the S-Link packet and instantiates relevant format translator.
0058   /*! Returns false if it fails to instantiate a Format Translator */
0059   bool autoDetectRequiredFormatTranslator(const unsigned char* data);
0060 
0061   /// check block headers for consistency
0062   void checkHeaders();
0063 
0064   /// Prints out a list of blocks and the various numbers of trigger objects that have been unpacked from them.
0065   void doVerboseOutput(const GctBlockHeaderCollection& bHdrs, const GctUnpackCollections* const colls) const;
0066 
0067   // add an error to the error collection
0068   void addError(const unsigned code);
0069 
0070   /// method called at job end - use to print summary report
0071   virtual void endJob();
0072 
0073 private:  // members
0074   /// The maximum number of blocks we will try to unpack before thinking something is wrong
0075   static const unsigned MAX_BLOCKS = 256;
0076 
0077   // unpacking options
0078   edm::InputTag inputLabel_;  ///< FED collection label.
0079   int fedId_;                 ///< GCT FED ID.
0080 
0081   const bool
0082       hltMode_;  ///< If true, only outputs the GCT data sent to the GT (number of BXs defined by numberOfGctSamplesToUnpack_)
0083   const unsigned
0084       numberOfGctSamplesToUnpack_;  ///< Number of BXs of GCT data to unpack (assuming they are in the raw data)
0085   const unsigned
0086       numberOfRctSamplesToUnpack_;  ///< Number of BXs of RCT data to unpack (assuming they are in the raw data)
0087   const bool
0088       unpackSharedRegions_;  ///< Commissioning option: if true, where applicable the shared RCT calo regions will also be unpacked.
0089   const unsigned formatVersion_;  ///< Defines unpacker verison to be used (e.g.: "Auto-detect", "MCLegacy", "V35", etc).
0090   const bool checkHeaders_;       ///< If true, check block headers for synchronisation
0091   const bool verbose_;            ///< If true, then debug print out for each event.
0092 
0093   // format translator
0094   GctFormatTranslateBase* formatTranslator_;  ///< pointer to the block-to-digi converter
0095 
0096   // vector of unpacked block headers, for verbostity and/or sync checks
0097   GctBlockHeaderCollection blockHeaders_;
0098 
0099   // error handling
0100   static const unsigned MAX_ERR_CODE = 6;
0101   L1TriggerErrorCollection* errors_;     ///< pointer to error collection
0102   std::vector<unsigned> errorCounters_;  ///< Counts number of errors for each code (index)
0103   unsigned unpackFailures_;              ///< To count the total number of GCT unpack failures.
0104 };
0105 
0106 #endif