diff --git a/etc/scdaq/scdaq.conf b/etc/scdaq/scdaq.conf index 687c93560a17565de60bae5684a64e1b855c78bb..c194bebbd569e923d58c4089b63de70184728b0c 100644 --- a/etc/scdaq/scdaq.conf +++ b/etc/scdaq/scdaq.conf @@ -28,6 +28,9 @@ packets_per_report:200000 # number of orbits per DMA packet, in decimal NOrbitsPerDMAPacket:20 +# number of orbits per DMA packet, in decimal +prescale_factor:20 + ## Extra settings for "filedma" input #input_file:/dev/shm/testdata.bin diff --git a/src/config.h b/src/config.h index 05972a9ce48741fa4d53af1bc63dcf2a66872517..150fb54d70a60a60c94cf77eecf3542df1db098a 100644 --- a/src/config.h +++ b/src/config.h @@ -86,6 +86,11 @@ class config { return boost::lexical_cast<uint32_t>(v.c_str()); } + uint32_t getPrescaleFactor() const { + std::string v = vmap.at("prescale_factor"); + return boost::lexical_cast<uint32_t>(v.c_str()); + } + uint32_t getNumThreads() const { std::string v = vmap.at("threads"); return boost::lexical_cast<uint32_t>(v.c_str()); diff --git a/src/controls.h b/src/controls.h index eb41c3958ee265e43e744d37483f5b070e1188d7..05d3188483810454aa17a2c32bfe92ca8438a567 100644 --- a/src/controls.h +++ b/src/controls.h @@ -13,5 +13,6 @@ struct ctrl { int packets_per_report; int n_orbits_per_dma_packet; std::atomic<uint32_t> orbit_trailer_error_count; + std::atomic<uint64_t> packet_count; }; #endif diff --git a/src/processor.cc b/src/processor.cc index b085f3e4d1a6db7547ada142047d9e9098e4b718..2bf81ac51f62106fdd6a2017c50db346d9b06483 100644 --- a/src/processor.cc +++ b/src/processor.cc @@ -10,13 +10,15 @@ #include "slice.h" StreamProcessor::StreamProcessor(size_t max_size_, bool doZS_, ProcessorType processorType_, - uint32_t nOrbitsPerDMAPacket_, ctrl &control_) + uint32_t nOrbitsPerDMAPacket_, uint32_t prescaleFactor_, + ctrl &control_) : tbb::filter(parallel), max_size(max_size_), nbPackets(0), doZS(doZS_), processorType(processorType_), nOrbitsPerDMAPacket(nOrbitsPerDMAPacket_), + prescaleFactor(prescaleFactor_), control(control_) { LOG(TRACE) << "Created transform filter at " << static_cast<void *>(this); myfile.open("example.txt"); @@ -44,9 +46,10 @@ bool StreamProcessor::CheckFrameMultBlock(size_t inputSize) { 32) % bsize != 0) { - LOG(WARNING) << "Frame size not a multiple of block size. Will be skipped. " - "Frame size = " - << inputSize << ", block size = " << bsize; + LOG(WARNING) << "Frame size not a multiple of block size after orbit headers " + "(32B*nOrbitsPerPacket), orbit trailers (544B*nOrbitsPerPacket), " + "and packet trailer (32B) have been subtracted. \n Frame size = " + << inputSize << ", block size = " << bsize << ", packet will be skipped"; return false; } return true; @@ -232,6 +235,15 @@ uint32_t StreamProcessor::FillOrbitMuon(std::vector<unsigned int> &bx_vect, char void StreamProcessor::process(Slice &input, Slice &out) { nbPackets++; + control.packet_count++; + + // Implement prescale - only for CALO + if (processorType == ProcessorType::CALO) { + if (control.packet_count % prescaleFactor != 0) { + return; + } + } + char *rd_ptr = input.begin(); char *wr_ptr = out.begin(); uint32_t counts = 0; diff --git a/src/processor.h b/src/processor.h index 201d2e17ad342729f822906992f16f66e222f19e..5120f5ba5ae44a4b7b658461f8c1dee0b1d86f62 100644 --- a/src/processor.h +++ b/src/processor.h @@ -15,12 +15,10 @@ class Slice; class StreamProcessor : public tbb::filter { - static std::atomic<uint32_t> orbit_trailer_error_count; - public: enum class ProcessorType { PASS_THROUGH, GMT, CALO }; StreamProcessor(size_t max_size_, bool doZS_, ProcessorType processorType_, - uint32_t nOrbitsPerDMAPacket_, ctrl &control); + uint32_t nOrbitsPerDMAPacket_, uint32_t prescaleFactor, ctrl &control); void *operator()(void *item) /*override*/; ~StreamProcessor(); @@ -37,6 +35,7 @@ class StreamProcessor : public tbb::filter { bool doZS; ProcessorType processorType; uint32_t nOrbitsPerDMAPacket; + uint32_t prescaleFactor; ctrl &control; }; diff --git a/src/scdaq.cc b/src/scdaq.cc index 152bb4bbfb0e7dea916baf42940e441b2ce9bb92..e9866e95b39046ac62e799a2bdbadf94134fe018 100644 --- a/src/scdaq.cc +++ b/src/scdaq.cc @@ -34,6 +34,7 @@ int run_pipeline(int nbThreads, ctrl &control, config &conf) { config::InputType input = conf.getInput(); size_t packetBufferSize = conf.getDmaPacketBufferSize(); size_t nbPacketBuffers = conf.getNumberOfDmaPacketBuffers(); + uint32_t prescaleFactor = conf.getPrescaleFactor(); // Create empty input reader, will assign later when we know what is the data // source std::shared_ptr<InputFilter> input_filter; @@ -65,7 +66,7 @@ int run_pipeline(int nbThreads, ctrl &control, config &conf) { // Create reformatter and add it to the pipeline // TODO: Created here so we are not subject of scoping, fix later... StreamProcessor stream_processor(packetBufferSize, conf.getDoZS(), conf.getProcessorType(), - conf.getNOrbitsPerDMAPacket(), control); + conf.getNOrbitsPerDMAPacket(), prescaleFactor, control); if (conf.getEnableStreamProcessor()) { pipeline.add_filter(stream_processor); } @@ -135,6 +136,7 @@ int main(int argc, char *argv[]) { control.running = false; control.run_number = 0; control.orbit_trailer_error_count = 0; + control.packet_count = 0; control.max_file_size = conf.getOutputMaxFileSize(); // in Bytes control.packets_per_report = conf.getPacketsPerReport(); control.output_force_write = conf.getOutputForceWrite();