Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-26 04:25:13

0001 #ifndef EventFilter_Utilities_DAQSourceModelsDTH_h
0002 #define EventFilter_Utilities_DAQSourceModelsDTH_h
0003 
0004 #include <filesystem>
0005 #include <queue>
0006 #include <regex>
0007 
0008 #include "EventFilter/Utilities/interface/DAQSourceModels.h"
0009 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
0010 #include "EventFilter/Utilities/interface/DTHHeaders.h"
0011 
0012 class FEDRawDataCollection;
0013 
0014 class DataModeDTH : public DataMode {
0015 public:
0016   DataModeDTH(DAQSource* daqSource, bool verifyChecksum) : DataMode(daqSource), verifyChecksum_(verifyChecksum) {}
0017   ~DataModeDTH() override {}
0018   std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>>& makeDaqProvenanceHelpers() override;
0019   void readEvent(edm::EventPrincipal& eventPrincipal) override;
0020 
0021   //non-virtual
0022   edm::Timestamp fillFEDRawDataCollection(FEDRawDataCollection& rawData);
0023 
0024   int dataVersion() const override { return detectedDTHversion_; }
0025   void detectVersion(unsigned char* fileBuf, uint32_t fileHeaderOffset) override {
0026     detectedDTHversion_ = 1;  //TODO: read version
0027   }
0028 
0029   uint32_t headerSize() const override { return sizeof(evf::DTHOrbitHeader_v1); }
0030 
0031   bool versionCheck() const override { return detectedDTHversion_ == 1; }
0032 
0033   uint64_t dataBlockSize() const override { return dataBlockSize_; }
0034 
0035   void makeDataBlockView(unsigned char* addr, RawInputFile* rawFile) override;
0036 
0037   bool nextEventView(RawInputFile*) override;
0038   bool blockChecksumValid() override { return checksumValid_; }
0039   bool checksumValid() override { return checksumValid_; }
0040   std::string getChecksumError() const override { return checksumError_; }
0041 
0042   bool isRealData() const { return true; }  //this flag could be added to RU/BU-generated index
0043 
0044   uint32_t run() const override { return firstOrbitHeader_->runNumber(); }
0045 
0046   bool dataBlockCompleted() const override { return blockCompleted_; }
0047 
0048   bool requireHeader() const override { return false; }
0049 
0050   bool fitToBuffer() const override { return true; }
0051 
0052   bool isMultiDir() const override { return true; }
0053 
0054   void unpackFile(RawInputFile*) override {}
0055 
0056   bool dataBlockInitialized() const override { return dataBlockInitialized_; }
0057 
0058   void setDataBlockInitialized(bool val) override { dataBlockInitialized_ = val; }
0059 
0060   void setTCDSSearchRange(uint16_t MINTCDSuTCAFEDID, uint16_t MAXTCDSuTCAFEDID) override {}
0061 
0062   void makeDirectoryEntries(std::vector<std::string> const& baseDirs,
0063                             std::vector<int> const& numSources,
0064                             std::vector<int> const& sourceIDs,
0065                             std::string const& sourceIdentifier,
0066                             std::string const& runDir) override;
0067 
0068   std::pair<bool, std::vector<std::string>> defineAdditionalFiles(std::string const& primaryName,
0069                                                                   bool fileListMode) const override;
0070 
0071   bool hasEventCounterCallback() const override { return true; }
0072   int eventCounterCallback(std::string const& name, int& fd, int64_t& fsize, uint32_t sLS, bool& found) const override;
0073 
0074 private:
0075   bool verifyChecksum_;
0076   std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>> daqProvenanceHelpers_;
0077   std::vector<std::filesystem::path> buPaths_;
0078   std::vector<int> buNumSources_;
0079   std::vector<std::string> buSourceStrings_;
0080   std::regex sid_pattern_;
0081   uint16_t detectedDTHversion_ = 0;
0082   evf::DTHOrbitHeader_v1* firstOrbitHeader_ = nullptr;
0083   uint64_t nextEventID_ = 0;
0084   std::vector<evf::DTHFragmentTrailer_v1*> eventFragments_;  //events in block (DTH trailer)
0085   //numFiles_ = 0;
0086   bool dataBlockInitialized_ = false;
0087   bool blockCompleted_ = true;
0088 
0089   std::vector<uint8_t*> addrsStart_;  //start of orbit payloads per source
0090   std::vector<uint8_t*> addrsEnd_;    //dth trailers per source (go through events from the end)
0091 
0092   bool checksumValid_ = false;
0093   std::string checksumError_;
0094   //total
0095   size_t dataBlockSize_ = 0;
0096   bool eventCached_ = false;
0097 };
0098 
0099 #endif  // EventFilter_Utilities_DAQSourceModelsDTH_h