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 57bf8c679d91a0509b5e78185fd8d7ff13dc07b3..8311584db4decb9a74837f6bb4e3d86dcb3f2e8f 100644 --- a/src/config.h +++ b/src/config.h @@ -99,6 +99,11 @@ public: 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 49cdaf7f662a5694fe5b0b0a5cb53a459736bb0a..8dbdae250f65496af5f078456d3d4186f9386eab 100644 --- a/src/controls.h +++ b/src/controls.h @@ -12,5 +12,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 c72340d5c38bd571cf36d917df0864c4e5449d3f..3fa8079b74b0723cee6d591eb2041c22bdecc120 100644 --- a/src/processor.cc +++ b/src/processor.cc @@ -7,13 +7,14 @@ #include <vector> #include <algorithm> -StreamProcessor::StreamProcessor(size_t max_size_, bool doZS_, ProcessorType processorType_, uint32_t nOrbitsPerDMAPacket_, ctrl& control_) : +StreamProcessor::StreamProcessor(size_t max_size_, bool doZS_, ProcessorType processorType_, 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); @@ -43,8 +44,7 @@ bool StreamProcessor::CheckFrameMultBlock(size_t inputSize){ int bsize = sizeof(blockMuon); if((inputSize-nOrbitsPerDMAPacket*constants::orbit_trailer_size - 32*nOrbitsPerDMAPacket -32)%bsize!=0){ LOG(WARNING) - << "Frame size not a multiple of block size. Will be skipped. Frame size = " - << inputSize << ", block size = " << bsize; + << "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; @@ -194,6 +194,13 @@ 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 bcb698e711132aac8eab6a2949a99febe734f18d..b1a52866404a90a58f247c356352fbd773e4c6de 100644 --- a/src/processor.h +++ b/src/processor.h @@ -14,11 +14,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); + StreamProcessor(size_t max_size_, bool doZS_, ProcessorType processorType_, uint32_t nOrbitsPerDMAPacket_, uint32_t prescaleFactor, ctrl& control); void* operator()( void* item )/*override*/; ~StreamProcessor(); @@ -35,6 +34,7 @@ private: bool doZS; ProcessorType processorType; uint32_t nOrbitsPerDMAPacket; + uint32_t prescaleFactor; ctrl& control; }; diff --git a/src/scdaq.cc b/src/scdaq.cc index 917609abb38a6bf4aa842a12eb197e87b597c5eb..c18719af4fd042962c5002a7cddd487a6989985a 100644 --- a/src/scdaq.cc +++ b/src/scdaq.cc @@ -38,7 +38,8 @@ int run_pipeline( int nbThreads, ctrl& control, config& conf ) config::InputType input = conf.getInput(); size_t packetBufferSize = conf.getDmaPacketBufferSize(); size_t nbPacketBuffers = conf.getNumberOfDmaPacketBuffers(); - // Create empty input reader, will assign later when we know what is the data source + 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; // Create the pipeline @@ -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); + StreamProcessor stream_processor(packetBufferSize, conf.getDoZS(), conf.getProcessorType(), conf.getNOrbitsPerDMAPacket(), prescaleFactor, control); if ( conf.getEnableStreamProcessor() ) { pipeline.add_filter( stream_processor ); } @@ -140,6 +141,7 @@ if(argc < 2){ 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();