Skip to content

Commit 06fdce0

Browse files
committed
reorganize input file and chunk classes in separate header
1 parent 5ee9ae3 commit 06fdce0

File tree

7 files changed

+6
-218
lines changed

7 files changed

+6
-218
lines changed

EventFilter/Utilities/interface/DAQSource.h

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include "EventFilter/Utilities/interface/EvFDaqDirector.h"
2222

2323
//import InputChunk
24-
#include "EventFilter/Utilities/interface/FedRawDataInputSource.h"
2524
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
25+
#include "EventFilter/Utilities/interface/SourceRawFile.h"
2626

2727
class FEDRawDataCollection;
2828
class InputSourceDescription;
@@ -182,73 +182,4 @@ class DAQSource : public edm::RawInputSource {
182182
std::shared_ptr<DataMode> dataMode_;
183183
};
184184

185-
//used by some models that use FEDRawDataCollection
186-
class UnpackedRawEventWrapper {
187-
public:
188-
UnpackedRawEventWrapper() {}
189-
~UnpackedRawEventWrapper() {}
190-
void setError(std::string msg) {
191-
errmsg_ = msg;
192-
error_ = true;
193-
}
194-
void setChecksumError(std::string msg) {
195-
errmsg_ = msg;
196-
checksumError_ = true;
197-
}
198-
void setRawData(FEDRawDataCollection* rawData) { rawData_.reset(rawData); }
199-
void setAux(edm::EventAuxiliary* aux) { aux_.reset(aux); }
200-
void setRun(uint32_t run) { run_ = run; }
201-
FEDRawDataCollection* rawData() { return rawData_.get(); }
202-
std::unique_ptr<FEDRawDataCollection>& rawDataRef() { return rawData_; }
203-
edm::EventAuxiliary* aux() { return aux_.get(); }
204-
uint32_t run() const { return run_; }
205-
bool checksumError() const { return checksumError_; }
206-
bool error() const { return error_; }
207-
std::string const& errmsg() { return errmsg_; }
208-
209-
private:
210-
std::unique_ptr<FEDRawDataCollection> rawData_;
211-
std::unique_ptr<edm::EventAuxiliary> aux_;
212-
uint32_t run_;
213-
bool checksumError_ = false;
214-
bool error_ = false;
215-
std::string errmsg_;
216-
};
217-
218-
class RawInputFile : public InputFile {
219-
public:
220-
RawInputFile(evf::EvFDaqDirector::FileStatus status,
221-
unsigned int lumi = 0,
222-
std::string const& name = std::string(),
223-
bool deleteFile = true,
224-
int rawFd = -1,
225-
uint64_t fileSize = 0,
226-
uint16_t rawHeaderSize = 0,
227-
uint32_t nChunks = 0,
228-
int nEvents = 0,
229-
DAQSource* parent = nullptr)
230-
: InputFile(status, lumi, name, deleteFile, rawFd, fileSize, rawHeaderSize, nChunks, nEvents, nullptr),
231-
sourceParent_(parent) {}
232-
bool advance(std::mutex& m, std::condition_variable& cv, unsigned char*& dataPosition, const size_t size);
233-
void advance(const size_t size) {
234-
chunkPosition_ += size;
235-
bufferPosition_ += size;
236-
}
237-
void queue(UnpackedRawEventWrapper* ec) {
238-
if (!frdcQueue_.get())
239-
frdcQueue_.reset(new std::queue<std::unique_ptr<UnpackedRawEventWrapper>>());
240-
std::unique_ptr<UnpackedRawEventWrapper> uptr(ec);
241-
frdcQueue_->push(std::move(uptr));
242-
}
243-
void popQueue(std::unique_ptr<UnpackedRawEventWrapper>& uptr) {
244-
uptr = std::move(frdcQueue_->front());
245-
frdcQueue_->pop();
246-
}
247-
248-
private:
249-
DAQSource* sourceParent_;
250-
//optional unpacked raw data queue (currently here because DAQSource controls lifetime of the RawInputfile)
251-
std::unique_ptr<std::queue<std::unique_ptr<UnpackedRawEventWrapper>>> frdcQueue_;
252-
};
253-
254185
#endif // EventFilter_Utilities_DAQSource_h

EventFilter/Utilities/interface/DAQSourceModels.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
#include "DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h"
2525

2626
//import InputChunk
27-
#include "EventFilter/Utilities/interface/FedRawDataInputSource.h"
27+
#include "EventFilter/Utilities/interface/SourceRawFile.h"
2828

29+
class RawInputFile;
30+
class UnpackedRawEventWrapper;
2931
class DAQSource;
3032

3133
//evf?

EventFilter/Utilities/interface/EvFDaqDirector.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ class SystemBounds;
3333
class GlobalContext;
3434
class StreamID;
3535

36-
class InputFile;
37-
struct InputChunk;
38-
3936
namespace edm {
4037
class PathsAndConsumesOfModulesBase;
4138
class ProcessContext;

EventFilter/Utilities/interface/FedRawDataInputSource.h

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -186,148 +186,6 @@ class FedRawDataInputSource : public edm::RawInputSource {
186186
std::mutex monlock_;
187187
};
188188

189-
struct InputChunk {
190-
unsigned char* buf_;
191-
InputChunk* next_ = nullptr;
192-
uint64_t size_;
193-
uint64_t usedSize_ = 0;
194-
//unsigned int index_;
195-
uint64_t offset_;
196-
unsigned int fileIndex_;
197-
std::atomic<bool> readComplete_;
198-
199-
InputChunk(uint64_t size) : size_(size) {
200-
buf_ = new unsigned char[size_];
201-
reset(0, 0, 0);
202-
}
203-
void reset(uint64_t newOffset, uint64_t toRead, unsigned int fileIndex) {
204-
offset_ = newOffset;
205-
usedSize_ = toRead;
206-
fileIndex_ = fileIndex;
207-
readComplete_ = false;
208-
}
209-
210-
bool resize(uint64_t wantedSize, uint64_t maxSize) {
211-
if (wantedSize > maxSize)
212-
return false;
213-
if (size_ < wantedSize) {
214-
size_ = uint64_t(wantedSize * 1.05);
215-
delete[] buf_;
216-
buf_ = new unsigned char[size_];
217-
}
218-
return true;
219-
}
220-
221-
~InputChunk() { delete[] buf_; }
222-
};
223-
224-
class InputFile {
225-
public:
226-
FedRawDataInputSource* parent_;
227-
evf::EvFDaqDirector::FileStatus status_;
228-
unsigned int lumi_;
229-
std::string fileName_;
230-
//used by DAQSource
231-
std::vector<std::string> fileNames_;
232-
std::vector<uint64_t> diskFileSizes_;
233-
std::vector<uint64_t> bufferOffsets_;
234-
std::vector<uint64_t> fileSizes_;
235-
std::vector<unsigned int> fileOrder_;
236-
bool deleteFile_;
237-
int rawFd_;
238-
uint64_t fileSize_;
239-
uint16_t rawHeaderSize_;
240-
uint16_t nChunks_;
241-
uint16_t numFiles_;
242-
int nEvents_;
243-
unsigned int nProcessed_;
244-
245-
tbb::concurrent_vector<InputChunk*> chunks_;
246-
247-
uint32_t bufferPosition_ = 0;
248-
uint32_t chunkPosition_ = 0;
249-
unsigned int currentChunk_ = 0;
250-
251-
InputFile(evf::EvFDaqDirector::FileStatus status,
252-
unsigned int lumi = 0,
253-
std::string const& name = std::string(),
254-
bool deleteFile = true,
255-
int rawFd = -1,
256-
uint64_t fileSize = 0,
257-
uint16_t rawHeaderSize = 0,
258-
uint16_t nChunks = 0,
259-
int nEvents = 0,
260-
FedRawDataInputSource* parent = nullptr)
261-
: parent_(parent),
262-
status_(status),
263-
lumi_(lumi),
264-
fileName_(name),
265-
deleteFile_(deleteFile),
266-
rawFd_(rawFd),
267-
fileSize_(fileSize),
268-
rawHeaderSize_(rawHeaderSize),
269-
nChunks_(nChunks),
270-
numFiles_(1),
271-
nEvents_(nEvents),
272-
nProcessed_(0) {
273-
fileNames_.push_back(name);
274-
fileOrder_.push_back(fileOrder_.size());
275-
diskFileSizes_.push_back(fileSize);
276-
fileSizes_.push_back(0);
277-
bufferOffsets_.push_back(0);
278-
chunks_.reserve(nChunks_);
279-
for (unsigned int i = 0; i < nChunks; i++)
280-
chunks_.push_back(nullptr);
281-
}
282-
virtual ~InputFile();
283-
284-
void setChunks(uint16_t nChunks) {
285-
nChunks_ = nChunks;
286-
chunks_.clear();
287-
chunks_.reserve(nChunks_);
288-
for (unsigned int i = 0; i < nChunks_; i++)
289-
chunks_.push_back(nullptr);
290-
}
291-
292-
void appendFile(std::string const& name, uint64_t size) {
293-
size_t prevOffset = bufferOffsets_.back();
294-
size_t prevSize = diskFileSizes_.back();
295-
numFiles_++;
296-
fileNames_.push_back(name);
297-
fileOrder_.push_back(fileOrder_.size());
298-
diskFileSizes_.push_back(size);
299-
fileSizes_.push_back(0);
300-
bufferOffsets_.push_back(prevOffset + prevSize);
301-
}
302-
303-
bool waitForChunk(unsigned int chunkid) {
304-
//some atomics to make sure everything is cache synchronized for the main thread
305-
return chunks_[chunkid] != nullptr && chunks_[chunkid]->readComplete_;
306-
}
307-
bool advance(std::mutex& m, std::condition_variable& cv, unsigned char*& dataPosition, const size_t size);
308-
bool advanceSimple(unsigned char*& dataPosition, const size_t size) {
309-
size_t currentLeft = chunks_[currentChunk_]->size_ - chunkPosition_;
310-
if (currentLeft < size)
311-
return true;
312-
dataPosition = chunks_[currentChunk_]->buf_ + chunkPosition_;
313-
chunkPosition_ += size;
314-
bufferPosition_ += size;
315-
return false;
316-
}
317-
void resetPos() {
318-
chunkPosition_ = 0;
319-
bufferPosition_ = 0;
320-
}
321-
void moveToPreviousChunk(const size_t size, const size_t offset);
322-
void rewindChunk(const size_t size);
323-
void unsetDeleteFile() { deleteFile_ = false; }
324-
void randomizeOrder(std::default_random_engine& rng) {
325-
std::shuffle(std::begin(fileOrder_), std::end(fileOrder_), rng);
326-
}
327-
uint64_t currentChunkSize() const { return chunks_[currentChunk_]->size_; }
328-
int64_t fileSizeLeft() const { return (int64_t)fileSize_ - (int64_t)bufferPosition_; }
329-
};
330-
331189
#endif // EventFilter_Utilities_FedRawDataInputSource_h
332190

333191
/// emacs configuration

EventFilter/Utilities/interface/SourceRawFile.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class UnpackedRawEventWrapper {
4646
std::string errmsg_;
4747
};
4848

49-
50-
5149
struct InputChunk {
5250
unsigned char* buf_;
5351
InputChunk* next_ = nullptr;

EventFilter/Utilities/src/DAQSource.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <unistd.h>
66
#include <vector>
77

8+
#include "EventFilter/Utilities/interface/SourceRawFile.h"
89
#include "EventFilter/Utilities/interface/DAQSource.h"
910
#include "EventFilter/Utilities/interface/DAQSourceModels.h"
1011
#include "EventFilter/Utilities/interface/DAQSourceModelsFRD.h"

EventFilter/Utilities/src/FedRawDataInputSource.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "EventFilter/Utilities/interface/GlobalEventNumber.h"
3232

33+
#include "EventFilter/Utilities/interface/SourceRawFile.h"
3334
#include "EventFilter/Utilities/interface/FedRawDataInputSource.h"
3435

3536
#include "EventFilter/Utilities/interface/SourceCommon.h"

0 commit comments

Comments
 (0)