Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DCCDATAUNPACKER_HH
0002 #define DCCDATAUNPACKER_HH
0003 
0004 /*
0005  *\ Class DCCDataUnpacker
0006  *
0007  * This class takes care of unpacking ECAL's raw data info.
0008  * A gateway for all blocks unpackers and committing collections to the Event
0009  * DCCEBEventBlock and DCCEEEventBlock are used here
0010  *
0011  * \file DCCDataUnpacker.h
0012  *
0013  * \author N. Almeida
0014  * \author G. Franzoni
0015  *
0016 */
0017 //C++
0018 #include <fstream>
0019 #include <iostream>
0020 #include <string>
0021 #include <vector>
0022 #include <map>
0023 #include <cstdio>
0024 #include <cstdint>
0025 #include <atomic>
0026 
0027 //DATA DECODER
0028 
0029 #include "DCCEventBlock.h"
0030 
0031 #include <DataFormats/EcalDigi/interface/EcalDigiCollections.h>
0032 #include <DataFormats/EcalDigi/interface/EcalPnDiodeDigi.h>
0033 
0034 #include <DataFormats/EcalDetId/interface/EcalDetIdCollections.h>
0035 #include <DataFormats/EcalRawData/interface/EcalRawDataCollections.h>
0036 
0037 #include <DataFormats/FEDRawData/interface/FEDRawData.h>
0038 #include <DataFormats/FEDRawData/interface/FEDNumbering.h>
0039 #include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h>
0040 
0041 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
0042 
0043 class EcalElectronicsMapper;
0044 class DCCEventBlock;
0045 class DCCEBEventBlock;
0046 class DCCEEEventBlock;
0047 class EcalRawToDigi;
0048 
0049 class DCCDataUnpacker {
0050 public:
0051   DCCDataUnpacker(EcalElectronicsMapper*,
0052                   bool hU,
0053                   bool srpU,
0054                   bool tccU,
0055                   bool feU,
0056                   bool memU,
0057                   bool syncCheck,
0058                   bool feIdCheck,
0059                   bool forceToKeepFRdata);
0060   ~DCCDataUnpacker();
0061   /**
0062      Unpack data from a buffer
0063   */
0064   void unpack(const uint64_t* buffer, size_t bufferSize, unsigned int smId, unsigned int fedId);
0065 
0066   /**
0067     Set the collection pointers
0068   */
0069 
0070   void setEBDigisCollection(std::unique_ptr<EBDigiCollection>* x) { ebDigis_ = x; }
0071 
0072   void setEEDigisCollection(std::unique_ptr<EEDigiCollection>* x) { eeDigis_ = x; }
0073 
0074   void setDccHeadersCollection(std::unique_ptr<EcalRawDataCollection>* x) { dccHeaders_ = x; }
0075 
0076   void setEBSrFlagsCollection(std::unique_ptr<EBSrFlagCollection>* x) { ebSrFlags_ = x; }
0077 
0078   void setEESrFlagsCollection(std::unique_ptr<EESrFlagCollection>* x) { eeSrFlags_ = x; }
0079 
0080   void setEcalTpsCollection(std::unique_ptr<EcalTrigPrimDigiCollection>* x) { ecalTps_ = x; }
0081 
0082   void setEcalPSsCollection(std::unique_ptr<EcalPSInputDigiCollection>* x) { ecalPSs_ = x; }
0083 
0084   void setInvalidGainsCollection(std::unique_ptr<EBDetIdCollection>* x) { invalidGains_ = x; }
0085 
0086   void setInvalidGainsSwitchCollection(std::unique_ptr<EBDetIdCollection>* x) { invalidGainsSwitch_ = x; }
0087 
0088   void setInvalidChIdsCollection(std::unique_ptr<EBDetIdCollection>* x) { invalidChIds_ = x; }
0089 
0090   // EE
0091   void setInvalidEEGainsCollection(std::unique_ptr<EEDetIdCollection>* x) { invalidEEGains_ = x; }
0092 
0093   void setInvalidEEGainsSwitchCollection(std::unique_ptr<EEDetIdCollection>* x) { invalidEEGainsSwitch_ = x; }
0094 
0095   void setInvalidEEChIdsCollection(std::unique_ptr<EEDetIdCollection>* x) { invalidEEChIds_ = x; }
0096   // EE
0097 
0098   void setInvalidTTIdsCollection(std::unique_ptr<EcalElectronicsIdCollection>* x) { invalidTTIds_ = x; }
0099 
0100   void setInvalidZSXtalIdsCollection(std::unique_ptr<EcalElectronicsIdCollection>* x) { invalidZSXtalIds_ = x; }
0101 
0102   void setInvalidBlockLengthsCollection(std::unique_ptr<EcalElectronicsIdCollection>* x) { invalidBlockLengths_ = x; }
0103 
0104   void setPnDiodeDigisCollection(std::unique_ptr<EcalPnDiodeDigiCollection>* x) { pnDiodeDigis_ = x; }
0105 
0106   void setInvalidMemTtIdsCollection(std::unique_ptr<EcalElectronicsIdCollection>* x) { invalidMemTtIds_ = x; }
0107 
0108   void setInvalidMemBlockSizesCollection(std::unique_ptr<EcalElectronicsIdCollection>* x) { invalidMemBlockSizes_ = x; }
0109 
0110   void setInvalidMemChIdsCollection(std::unique_ptr<EcalElectronicsIdCollection>* x) { invalidMemChIds_ = x; }
0111 
0112   void setInvalidMemGainsCollection(std::unique_ptr<EcalElectronicsIdCollection>* x) { invalidMemGains_ = x; }
0113 
0114   /**
0115    Get the collection pointers
0116   */
0117 
0118   std::unique_ptr<EBDigiCollection>* ebDigisCollection() { return ebDigis_; }
0119 
0120   std::unique_ptr<EEDigiCollection>* eeDigisCollection() { return eeDigis_; }
0121 
0122   std::unique_ptr<EcalTrigPrimDigiCollection>* ecalTpsCollection() { return ecalTps_; }
0123 
0124   std::unique_ptr<EcalPSInputDigiCollection>* ecalPSsCollection() { return ecalPSs_; }
0125 
0126   std::unique_ptr<EBSrFlagCollection>* ebSrFlagsCollection() { return ebSrFlags_; }
0127 
0128   std::unique_ptr<EESrFlagCollection>* eeSrFlagsCollection() { return eeSrFlags_; }
0129 
0130   std::unique_ptr<EcalRawDataCollection>* dccHeadersCollection() { return dccHeaders_; }
0131 
0132   std::unique_ptr<EBDetIdCollection>* invalidGainsCollection() { return invalidGains_; }
0133 
0134   std::unique_ptr<EBDetIdCollection>* invalidGainsSwitchCollection() { return invalidGainsSwitch_; }
0135 
0136   std::unique_ptr<EBDetIdCollection>* invalidChIdsCollection() { return invalidChIds_; }
0137 
0138   //EE
0139   std::unique_ptr<EEDetIdCollection>* invalidEEGainsCollection() { return invalidEEGains_; }
0140 
0141   std::unique_ptr<EEDetIdCollection>* invalidEEGainsSwitchCollection() { return invalidEEGainsSwitch_; }
0142 
0143   std::unique_ptr<EEDetIdCollection>* invalidEEChIdsCollection() { return invalidEEChIds_; }
0144   //EE
0145 
0146   std::unique_ptr<EcalElectronicsIdCollection>* invalidTTIdsCollection() { return invalidTTIds_; }
0147 
0148   std::unique_ptr<EcalElectronicsIdCollection>* invalidZSXtalIdsCollection() { return invalidZSXtalIds_; }
0149 
0150   std::unique_ptr<EcalElectronicsIdCollection>* invalidBlockLengthsCollection() { return invalidBlockLengths_; }
0151 
0152   std::unique_ptr<EcalElectronicsIdCollection>* invalidMemTtIdsCollection() { return invalidMemTtIds_; }
0153 
0154   std::unique_ptr<EcalElectronicsIdCollection>* invalidMemBlockSizesCollection() { return invalidMemBlockSizes_; }
0155 
0156   std::unique_ptr<EcalElectronicsIdCollection>* invalidMemChIdsCollection() { return invalidMemChIds_; }
0157 
0158   std::unique_ptr<EcalElectronicsIdCollection>* invalidMemGainsCollection() { return invalidMemGains_; }
0159 
0160   std::unique_ptr<EcalPnDiodeDigiCollection>* pnDiodeDigisCollection() { return pnDiodeDigis_; }
0161 
0162   /**
0163    Get the ECAL electronics Mapper
0164   */
0165   const EcalElectronicsMapper* electronicsMapper() const { return electronicsMapper_; }
0166 
0167   /**
0168    Functions to work with Channel Status DB
0169   */
0170   void setChannelStatusDB(const EcalChannelStatusMap* chdb) { chdb_ = chdb; }
0171   // return status of given crystal
0172   // https://twiki.cern.ch/twiki/bin/view/CMS/EcalChannelStatus#Assigning_Channel_status
0173   uint16_t getChannelStatus(const DetId& id) const;
0174   // return low 5 bits of status word
0175   uint16_t getChannelValue(const DetId& id) const;
0176   uint16_t getChannelValue(const int fed, const int ccu, const int strip, const int xtal) const;
0177   // return status of given CCU
0178   uint16_t getCCUValue(const int fed, const int ccu) const;
0179 
0180   /**
0181   Get the associated event
0182   */
0183   DCCEventBlock* currentEvent() { return currentEvent_; }
0184 
0185   static std::atomic<bool> silentMode_;
0186 
0187 protected:
0188   // Data collections pointers
0189   std::unique_ptr<EBDigiCollection>* ebDigis_;
0190   std::unique_ptr<EEDigiCollection>* eeDigis_;
0191   std::unique_ptr<EcalTrigPrimDigiCollection>* ecalTps_;
0192   std::unique_ptr<EcalPSInputDigiCollection>* ecalPSs_;
0193   std::unique_ptr<EcalRawDataCollection>* dccHeaders_;
0194   std::unique_ptr<EBDetIdCollection>* invalidGains_;
0195   std::unique_ptr<EBDetIdCollection>* invalidGainsSwitch_;
0196   std::unique_ptr<EBDetIdCollection>* invalidChIds_;
0197   //EE
0198   std::unique_ptr<EEDetIdCollection>* invalidEEGains_;
0199   std::unique_ptr<EEDetIdCollection>* invalidEEGainsSwitch_;
0200   std::unique_ptr<EEDetIdCollection>* invalidEEChIds_;
0201   //EE
0202   std::unique_ptr<EBSrFlagCollection>* ebSrFlags_;
0203   std::unique_ptr<EESrFlagCollection>* eeSrFlags_;
0204   std::unique_ptr<EcalElectronicsIdCollection>* invalidTTIds_;
0205   std::unique_ptr<EcalElectronicsIdCollection>* invalidZSXtalIds_;
0206   std::unique_ptr<EcalElectronicsIdCollection>* invalidBlockLengths_;
0207 
0208   std::unique_ptr<EcalElectronicsIdCollection>* invalidMemTtIds_;
0209   std::unique_ptr<EcalElectronicsIdCollection>* invalidMemBlockSizes_;
0210   std::unique_ptr<EcalElectronicsIdCollection>* invalidMemChIds_;
0211   std::unique_ptr<EcalElectronicsIdCollection>* invalidMemGains_;
0212   std::unique_ptr<EcalPnDiodeDigiCollection>* pnDiodeDigis_;
0213 
0214   EcalElectronicsMapper* electronicsMapper_;
0215   const EcalChannelStatusMap* chdb_;
0216   DCCEventBlock* currentEvent_;
0217   DCCEBEventBlock* ebEventBlock_;
0218   DCCEEEventBlock* eeEventBlock_;
0219 };
0220 
0221 #endif