Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
smorovic committed Mar 6, 2023
1 parent 30717a0 commit 45dabea
Show file tree
Hide file tree
Showing 19 changed files with 748 additions and 845 deletions.
33 changes: 14 additions & 19 deletions EventFilter/Utilities/interface/DAQSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
//import InputChunk
#include "EventFilter/Utilities/interface/FedRawDataInputSource.h"


class FEDRawDataCollection;
class InputSourceDescription;
class ParameterSet;
Expand Down Expand Up @@ -83,17 +82,15 @@ class DAQSource : public edm::RawInputSource {
void reportEventsThisLumiInSource(unsigned int lumi, unsigned int events);

long initFileList();
evf::EvFDaqDirector::FileStatus getFile(unsigned int& ls,
std::string& nextFile,
uint64_t& lockWaitTime);
evf::EvFDaqDirector::FileStatus getFile(unsigned int& ls, std::string& nextFile, uint64_t& lockWaitTime);

//variables
evf::FastMonitoringService* fms_ = nullptr;
evf::EvFDaqDirector* daqDirector_ = nullptr;

const std::string dataModeConfig_;
uint64_t eventChunkSize_; // for buffered read-ahead
uint64_t maxChunkSize_; // for buffered read-ahead
uint64_t maxChunkSize_; // for buffered read-ahead
uint64_t eventChunkBlock_; // how much read(2) asks at the time
unsigned int readBlocks_;
unsigned int numBuffers_;
Expand Down Expand Up @@ -179,28 +176,26 @@ class DAQSource : public edm::RawInputSource {
std::mutex monlock_;

std::shared_ptr<DataMode> dataMode_;

};

class RawInputFile: public InputFile {
class RawInputFile : public InputFile {
public:
RawInputFile(evf::EvFDaqDirector::FileStatus status,
unsigned int lumi = 0,
std::string const& name = std::string(),
bool deleteFile = true,
int rawFd = -1,
uint64_t fileSize = 0,
uint16_t rawHeaderSize = 0,
uint32_t nChunks = 0,
int nEvents = 0,
DAQSource* parent = nullptr)
unsigned int lumi = 0,
std::string const& name = std::string(),
bool deleteFile = true,
int rawFd = -1,
uint64_t fileSize = 0,
uint16_t rawHeaderSize = 0,
uint32_t nChunks = 0,
int nEvents = 0,
DAQSource* parent = nullptr)
: InputFile(status, lumi, name, deleteFile, rawFd, fileSize, rawHeaderSize, nChunks, nEvents, nullptr),
sourceParent_(parent) {
}
sourceParent_(parent) {}
bool advance(unsigned char*& dataPosition, const size_t size);

private:
DAQSource* sourceParent_;
};

#endif // EventFilter_Utilities_DAQSource_h

23 changes: 13 additions & 10 deletions EventFilter/Utilities/interface/DAQSourceModels.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ class DAQSource;

//evf?
class DataMode {

public:
DataMode(DAQSource *daqSource): daqSource_(daqSource) {}
DataMode(DAQSource* daqSource) : daqSource_(daqSource) {}
virtual ~DataMode() = default;
virtual std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>>& makeDaqProvenanceHelpers() = 0;
virtual void readEvent(edm::EventPrincipal& eventPrincipal) = 0;
virtual int dataVersion() const = 0;
virtual void detectVersion(unsigned char* fileBuf, uint32_t fileHeaderOffset) = 0;
virtual uint32_t headerSize() const = 0;
virtual uint32_t headerSize() const = 0;
virtual bool versionCheck() const = 0;
virtual uint64_t dataBlockSize() const = 0;
virtual void makeDataBlockView(unsigned char* addr, size_t maxSize, std::vector<uint64_t> const& fileSizes, size_t fileHeaderSize) = 0;
virtual void makeDataBlockView(unsigned char* addr,
size_t maxSize,
std::vector<uint64_t> const& fileSizes,
size_t fileHeaderSize) = 0;
virtual bool nextEventView() = 0;
virtual bool checksumValid() = 0;
virtual std::string getChecksumError() const = 0;
virtual bool isRealData() const = 0;
virtual bool isRealData() const = 0;
virtual uint32_t run() const = 0;
virtual bool dataBlockCompleted() const = 0;
virtual bool requireHeader() const = 0;
Expand All @@ -55,16 +57,17 @@ class DataMode {
virtual void setDataBlockInitialized(bool) = 0;

virtual void setTCDSSearchRange(uint16_t, uint16_t) = 0;
virtual std::pair<bool, std::vector<std::string>> defineAdditionalFiles(std::string const& primaryName, bool fileListMode) const = 0;
virtual std::pair<bool, std::vector<std::string>> defineAdditionalFiles(std::string const& primaryName,
bool fileListMode) const = 0;

virtual bool isMultiDir() {return false;}
virtual bool isMultiDir() { return false; }
virtual void makeDirectoryEntries(std::vector<std::string> const& baseDirs, std::string const& runDir) = 0;
void setTesting(bool testing) {testing_ = testing;}
void setTesting(bool testing) { testing_ = testing; }

protected:
DAQSource *daqSource_;
DAQSource* daqSource_;
bool testing_ = false;
//std::vector<std::string> buPaths_;
};

#endif // EventFilter_Utilities_DAQSourceModels_h

169 changes: 72 additions & 97 deletions EventFilter/Utilities/interface/DAQSourceModelsFRD.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,58 @@
class FEDRawDataCollection;

class DataModeFRD : public DataMode {

public:
DataModeFRD(DAQSource *daqSource): DataMode(daqSource) {}
~DataModeFRD() override {};
DataModeFRD(DAQSource* daqSource) : DataMode(daqSource) {}
~DataModeFRD() override{};
std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>>& makeDaqProvenanceHelpers() override;
void readEvent(edm::EventPrincipal& eventPrincipal) override;

//non-virtual
edm::Timestamp fillFEDRawDataCollection(FEDRawDataCollection& rawData, bool& tcdsInRange, unsigned char*& tcds_pointer);
edm::Timestamp fillFEDRawDataCollection(FEDRawDataCollection& rawData,
bool& tcdsInRange,
unsigned char*& tcds_pointer);

int dataVersion() const override { return detectedFRDversion_; }
void detectVersion(unsigned char* fileBuf, uint32_t fileHeaderOffset) override {
detectedFRDversion_ = *((uint16_t*)(fileBuf + fileHeaderOffset));
}

uint32_t headerSize() const override {
return FRDHeaderVersionSize[detectedFRDversion_];
}
uint32_t headerSize() const override { return FRDHeaderVersionSize[detectedFRDversion_]; }

bool versionCheck() const override {
return detectedFRDversion_ <= FRDHeaderMaxVersion;
}
bool versionCheck() const override { return detectedFRDversion_ <= FRDHeaderMaxVersion; }

uint64_t dataBlockSize() const override {
return event_->size();
}
uint64_t dataBlockSize() const override { return event_->size(); }

void makeDataBlockView(unsigned char* addr, size_t maxSize, std::vector<uint64_t> const& fileSizes, size_t fileHeaderSize) override {
void makeDataBlockView(unsigned char* addr,
size_t maxSize,
std::vector<uint64_t> const& fileSizes,
size_t fileHeaderSize) override {
dataBlockAddr_ = addr;
dataBlockMax_ = maxSize;
eventCached_=false;
eventCached_ = false;
nextEventView();
eventCached_=true;
eventCached_ = true;
}

bool nextEventView() override;
bool checksumValid() override;
std::string getChecksumError() const override;

bool isRealData() const override {
return event_->isRealData();
}
bool isRealData() const override { return event_->isRealData(); }

uint32_t run() const override {
return event_->run();
}
uint32_t run() const override { return event_->run(); }

//true for DAQ3 FRD
bool dataBlockCompleted() const override {
return true;
}
bool dataBlockCompleted() const override { return true; }

bool requireHeader() const override {
return true;
}
bool requireHeader() const override { return true; }

bool fitToBuffer() const override {
return false;
}
bool fitToBuffer() const override { return false; }
bool dataBlockInitialized() const override { return true; }

void setDataBlockInitialized(bool) override {};

void setDataBlockInitialized(bool) override{};

void setTCDSSearchRange(uint16_t MINTCDSuTCAFEDID,uint16_t MAXTCDSuTCAFEDID) override {
void setTCDSSearchRange(uint16_t MINTCDSuTCAFEDID, uint16_t MAXTCDSuTCAFEDID) override {
MINTCDSuTCAFEDID_ = MINTCDSuTCAFEDID;
MAXTCDSuTCAFEDID_ = MAXTCDSuTCAFEDID;
}
Expand All @@ -83,32 +70,29 @@ class DataModeFRD : public DataMode {
return std::make_pair(true, std::vector<std::string>());
}

private:
std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>> daqProvenanceHelpers_;
uint16_t detectedFRDversion_ = 0;
size_t headerSize_ = 0;
std::unique_ptr<FRDEventMsgView> event_;
uint32_t crc_ = 0;
unsigned char * dataBlockAddr_ = nullptr;
size_t dataBlockMax_ = 0;
size_t fileHeaderSize_ = 0;
uint16_t MINTCDSuTCAFEDID_ = FEDNumbering::MINTCDSuTCAFEDID;
uint16_t MAXTCDSuTCAFEDID_ = FEDNumbering::MAXTCDSuTCAFEDID;
bool eventCached_ = false;
private:
std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>> daqProvenanceHelpers_;
uint16_t detectedFRDversion_ = 0;
size_t headerSize_ = 0;
std::unique_ptr<FRDEventMsgView> event_;
uint32_t crc_ = 0;
unsigned char* dataBlockAddr_ = nullptr;
size_t dataBlockMax_ = 0;
size_t fileHeaderSize_ = 0;
uint16_t MINTCDSuTCAFEDID_ = FEDNumbering::MINTCDSuTCAFEDID;
uint16_t MAXTCDSuTCAFEDID_ = FEDNumbering::MAXTCDSuTCAFEDID;
bool eventCached_ = false;
};


/*
* Demo for FRD source reading files from multiple striped destinations
*
* */


class DataModeFRDStriped : public DataMode {

public:
DataModeFRDStriped(DAQSource *daqSource): DataMode(daqSource) {}
~DataModeFRDStriped() override {};
DataModeFRDStriped(DAQSource* daqSource) : DataMode(daqSource) {}
~DataModeFRDStriped() override{};
std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>>& makeDaqProvenanceHelpers() override;
void readEvent(edm::EventPrincipal& eventPrincipal) override;

Expand All @@ -120,13 +104,9 @@ class DataModeFRDStriped : public DataMode {
detectedFRDversion_ = *((uint16_t*)(fileBuf + fileHeaderOffset));
}

uint32_t headerSize() const override {
return FRDHeaderVersionSize[detectedFRDversion_];
}
uint32_t headerSize() const override { return FRDHeaderVersionSize[detectedFRDversion_]; }

bool versionCheck() const override {
return detectedFRDversion_ <= FRDHeaderMaxVersion;
}
bool versionCheck() const override { return detectedFRDversion_ <= FRDHeaderMaxVersion; }

uint64_t dataBlockSize() const override {
//just get first event size
Expand All @@ -135,8 +115,10 @@ class DataModeFRDStriped : public DataMode {
return events_[0]->size();
}

void makeDataBlockView(unsigned char* addr, size_t maxSize, std::vector<uint64_t> const& fileSizes, size_t fileHeaderSize) override {

void makeDataBlockView(unsigned char* addr,
size_t maxSize,
std::vector<uint64_t> const& fileSizes,
size_t fileHeaderSize) override {
fileHeaderSize_ = fileHeaderSize;
numFiles_ = fileSizes.size();
//add offset address for each file payload
Expand All @@ -147,8 +129,8 @@ class DataModeFRDStriped : public DataMode {
dataBlockMaxAddrs_.clear();
dataBlockMaxAddrs_.push_back(addr + fileSizes[0] - fileHeaderSize);
auto fileAddr = addr;
for (unsigned int i=1; i < fileSizes.size(); i++) {
fileAddr += fileSizes[i-1];
for (unsigned int i = 1; i < fileSizes.size(); i++) {
fileAddr += fileSizes[i - 1];
//startAddrs_.push_back(fileAddr);
dataBlockAddrs_.push_back(fileAddr);
dataBlockMaxAddrs_.push_back(fileAddr + fileSizes[i] - fileHeaderSize);
Expand All @@ -160,7 +142,7 @@ class DataModeFRDStriped : public DataMode {
//set event cached as we set initial address here
bool result = makeEvents();
assert(result);
eventCached_=true;
eventCached_ = true;
setDataBlockInitialized(true);
}

Expand All @@ -178,53 +160,46 @@ class DataModeFRDStriped : public DataMode {
return events_[0]->run();
}

bool dataBlockCompleted() const override {
return blockCompleted_;
}

bool requireHeader() const override {
return true;
}
bool dataBlockCompleted() const override { return blockCompleted_; }

bool fitToBuffer() const override {
return true;
}
bool requireHeader() const override { return true; }

bool fitToBuffer() const override { return true; }

bool dataBlockInitialized() const override { return dataBlockInitialized_; }

void setDataBlockInitialized(bool val) override { dataBlockInitialized_ = val; };

void setTCDSSearchRange(uint16_t MINTCDSuTCAFEDID,uint16_t MAXTCDSuTCAFEDID) override {
void setTCDSSearchRange(uint16_t MINTCDSuTCAFEDID, uint16_t MAXTCDSuTCAFEDID) override {
MINTCDSuTCAFEDID_ = MINTCDSuTCAFEDID;
MAXTCDSuTCAFEDID_ = MAXTCDSuTCAFEDID;
}

void makeDirectoryEntries(std::vector<std::string> const& baseDirs, std::string const& runDir) override;

std::pair<bool, std::vector<std::string>> defineAdditionalFiles(std::string const& primaryName, bool fileListMode) const override;

private:
bool makeEvents();
std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>> daqProvenanceHelpers_;//
uint16_t detectedFRDversion_ = 0;
size_t fileHeaderSize_ = 0;
size_t headerSize_ = 0;
std::vector<std::unique_ptr<FRDEventMsgView>> events_;
std::string crcMsg_;
unsigned char * dataBlockAddr_ = nullptr;
//std::vector<unsigned char *> startAddrs_;
std::vector<unsigned char *> dataBlockAddrs_;
std::vector<unsigned char *> dataBlockMaxAddrs_;
size_t dataBlockMax_ = 0;
short numFiles_ = 0;
bool dataBlockInitialized_ = false;
bool blockCompleted_ = true;
bool eventCached_ = false;
uint16_t MINTCDSuTCAFEDID_ = FEDNumbering::MINTCDSuTCAFEDID;
uint16_t MAXTCDSuTCAFEDID_ = FEDNumbering::MAXTCDSuTCAFEDID;
std::vector<std::filesystem::path> buPaths_;

std::pair<bool, std::vector<std::string>> defineAdditionalFiles(std::string const& primaryName,
bool fileListMode) const override;

private:
bool makeEvents();
std::vector<std::shared_ptr<const edm::DaqProvenanceHelper>> daqProvenanceHelpers_; //
uint16_t detectedFRDversion_ = 0;
size_t fileHeaderSize_ = 0;
size_t headerSize_ = 0;
std::vector<std::unique_ptr<FRDEventMsgView>> events_;
std::string crcMsg_;
unsigned char* dataBlockAddr_ = nullptr;
//std::vector<unsigned char *> startAddrs_;
std::vector<unsigned char*> dataBlockAddrs_;
std::vector<unsigned char*> dataBlockMaxAddrs_;
size_t dataBlockMax_ = 0;
short numFiles_ = 0;
bool dataBlockInitialized_ = false;
bool blockCompleted_ = true;
bool eventCached_ = false;
uint16_t MINTCDSuTCAFEDID_ = FEDNumbering::MINTCDSuTCAFEDID;
uint16_t MAXTCDSuTCAFEDID_ = FEDNumbering::MAXTCDSuTCAFEDID;
std::vector<std::filesystem::path> buPaths_;
};

#endif // EventFilter_Utilities_DAQSourceModelsFRD_h

Loading

0 comments on commit 45dabea

Please sign in to comment.