diff --git a/etc/scdaq/scdaq.conf b/etc/scdaq/scdaq.conf index 687c93560a17565de60bae5684a64e1b855c78bb..71647b673a65737d88fef183882753ea084a7ecf 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 +# prescale factor, used for *calo* data only +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/elastico.cc b/src/elastico.cc index 94349b2b98cd7be7cfc2f09761f1ec9253171ce5..17a7a5e43369d104671ff06b9dad2e7c073b47e5 100644 --- a/src/elastico.cc +++ b/src/elastico.cc @@ -98,8 +98,8 @@ void ElasticProcessor::makeCreateIndexRequest(unsigned int run){ void ElasticProcessor::makeAppendToBulkRequest(std::ostringstream &particle_data, char*c){ uint32_t *p = (uint32_t*)c; uint32_t header = *p++; - int mAcount = (header&header_masks::mAcount)>>header_shifts::mAcount; - int mBcount = (header&header_masks::mBcount)>>header_shifts::mBcount; + int mAcount = (header&packed_format_header_masks::mAcount)>>packed_format_header_shifts::mAcount; + int mBcount = (header&packed_format_header_masks::mBcount)>>packed_format_header_shifts::mBcount; uint32_t bx=*p++; uint32_t orbit=*p++; diff --git a/src/format.h b/src/format.h index d20001d145f2e4772f02715e71280ce14760a590..daaf622f811a584371a2ca7edf7868e84de4d91e 100644 --- a/src/format.h +++ b/src/format.h @@ -13,6 +13,13 @@ struct blockCalo{ uint32_t calo5[8]; }; +struct block_calo_packed{ + uint32_t header; + uint32_t bx; + uint32_t orbit; + uint32_t frame[56]; //+8 for extra word containing link number; +}; + struct blockMuon{ uint32_t orbit[8]; uint32_t bx[8]; @@ -23,16 +30,113 @@ struct blockMuon{ }; struct bx_map_frame{ -uint32_t bx_map_l[8]; + uint32_t bx_map_l[8]; }; struct orbit_trailer{ -uint32_t beefdead[8]; -uint32_t bx_map[14*8]; -uint32_t trailer1[8]; -uint32_t trailer2[8]; + uint32_t beefdead[8]; + uint32_t bx_map[14*8]; + uint32_t trailer1[8]; + uint32_t trailer2[8]; +}; + +struct shiftsCaloTau{ + static constexpr uint32_t ET = 0; + static constexpr uint32_t eta = 9; + static constexpr uint32_t phi = 17; + static constexpr uint32_t iso = 25; }; +struct masksCaloJet{ + static constexpr uint32_t ET = 0x07ff; + static constexpr uint32_t eta = 0x00ff; + static constexpr uint32_t phi = 0x00ff; +}; +struct shiftsCaloJet{ + static constexpr uint32_t ET = 0; + static constexpr uint32_t eta = 11; + static constexpr uint32_t phi = 19; +}; +struct masksCaloEGamma{ + static constexpr uint32_t ET = 0x01ff; + static constexpr uint32_t eta = 0x00ff; + static constexpr uint32_t phi = 0x00ff; + static constexpr uint32_t iso = 0x0003; +}; + +struct shiftsCaloEGamma{ + static constexpr uint32_t ET = 0; + static constexpr uint32_t eta = 9; + static constexpr uint32_t phi = 17; + static constexpr uint32_t iso = 25; +}; + +struct masksCaloTau{ + static constexpr uint32_t ET = 0x01ff; + static constexpr uint32_t eta = 0x00ff; + static constexpr uint32_t phi = 0x00ff; + static constexpr uint32_t iso = 0x0003; +}; + +struct masksCaloESums{ + static constexpr uint32_t ETEt = 0x0fff;//Et of ET object + static constexpr uint32_t ETEttem = 0x0fff; + static constexpr uint32_t ETMinBiasHF = 0x000f; + + static constexpr uint32_t HTEt = 0x0fff;//ET of HT object + static constexpr uint32_t HTtowerCount = 0x1fff; + static constexpr uint32_t HTMinBiasHF = 0x0003; + + static constexpr uint32_t ETmissEt = 0x0fff; + static constexpr uint32_t ETmissPhi = 0x00ff; + static constexpr uint32_t ETmissASYMET = 0x00ff; + static constexpr uint32_t ETmissMinBiasHF = 0x0003; + + static constexpr uint32_t HTmissEt = 0x0fff; + static constexpr uint32_t HTmissPhi = 0x00ff; + static constexpr uint32_t HTmissASYMHT = 0x00ff; + static constexpr uint32_t HTmissMinBiasHF = 0x0003; + + static constexpr uint32_t ETHFmissEt = 0x0fff; + static constexpr uint32_t ETHFmissPhi = 0x00ff; + static constexpr uint32_t ETHFmissASYMETHF = 0x00ff; + static constexpr uint32_t ETHFmissCENT = 0x0003; + + static constexpr uint32_t HTHFmissEt = 0x0fff; + static constexpr uint32_t HTHFmissPhi = 0x00ff; + static constexpr uint32_t HTHFmissASYMHTHF = 0x00ff; + static constexpr uint32_t HTHFmissCENT = 0x0003; +}; + +struct shiftsCaloESums{ + static constexpr uint32_t ETEt = 0;//Et of ET object + static constexpr uint32_t ETEttem = 12; + static constexpr uint32_t ETMinBiasHF = 28; + + static constexpr uint32_t HTEt = 0;//ET of HT object + static constexpr uint32_t HTtowerCount = 12; + static constexpr uint32_t HTMinBiasHF = 28; + + static constexpr uint32_t ETmissEt = 0; + static constexpr uint32_t ETmissPhi = 12; + static constexpr uint32_t ETmissASYMET = 20; + static constexpr uint32_t ETmissMinBiasHF = 28; + + static constexpr uint32_t HTmissEt = 0; + static constexpr uint32_t HTmissPhi = 12; + static constexpr uint32_t HTmissASYMHT = 20; + static constexpr uint32_t HTmissMinBiasHF = 28; + + static constexpr uint32_t ETHFmissEt = 0; + static constexpr uint32_t ETHFmissPhi = 12; + static constexpr uint32_t ETHFmissASYMETHF = 20; + static constexpr uint32_t ETHFmissCENT = 28; + + static constexpr uint32_t HTHFmissEt = 0; + static constexpr uint32_t HTHFmissPhi = 12; + static constexpr uint32_t HTHFmissASYMHTHF = 20; + static constexpr uint32_t HTHFmissCENT = 28; +}; struct muon{ uint32_t f; //first word @@ -46,30 +150,6 @@ struct block{ muon mu[16]; }; -//original format -/*struct masks{ - //bx word: 16 bits used for actual bx, MS 4 bits are muon type - //(0xf intermediate, 0x0 final, following 4 bits for link id) - static constexpr uint32_t bx = 0xffff; - static constexpr uint32_t interm = 0x000f; - static constexpr uint32_t linkid = 0x000f; - //masks for muon 64 bits - static constexpr uint32_t phiext = 0x03ff; - static constexpr uint32_t pt = 0x01ff; - static constexpr uint32_t qual = 0x000f; - static constexpr uint32_t etaext = 0x01ff; - static constexpr uint32_t etaextv = 0x00ff; - static constexpr uint32_t etaexts = 0x0100; - static constexpr uint32_t iso = 0x0003; - static constexpr uint32_t chrg = 0x0001; - static constexpr uint32_t chrgv = 0x0001; - static constexpr uint32_t index = 0x007f; - static constexpr uint32_t phi = 0x03ff; - static constexpr uint32_t eta = 0x01ff; - static constexpr uint32_t etav = 0x00ff; - static constexpr uint32_t etas = 0x0100; -};*/ - //run3 format --tj struct masks{ //bx word: 16 bits used for actual bx, MS 4 bits are muon type @@ -98,55 +178,66 @@ struct masks{ struct shifts{ //bx word: 16 bits used for actual bx, MS 4 bits are muon type //(0xf intermediate, 0x0 final, following 4 bits for link id) - static constexpr uint32_t bx = 0; - static constexpr uint32_t interm = 31; //updated for new run3 format //tj + static constexpr uint32_t bx = 0; + static constexpr uint32_t interm = 31; //updated for new run3 format //tj //shifts for muon 64 bits - static constexpr uint32_t phiext = 0; - static constexpr uint32_t pt = 10; - static constexpr uint32_t qual = 19; - static constexpr uint32_t etaext = 23; - static constexpr uint32_t iso = 0; - static constexpr uint32_t chrg = 2; - static constexpr uint32_t chrgv = 3; - static constexpr uint32_t index = 4; - static constexpr uint32_t phi = 11; - static constexpr uint32_t eta = 21; + static constexpr uint32_t phiext = 0; + static constexpr uint32_t pt = 10; + static constexpr uint32_t qual = 19; + static constexpr uint32_t etaext = 23; + static constexpr uint32_t iso = 0; + static constexpr uint32_t chrg = 2; + static constexpr uint32_t chrgv = 3; + static constexpr uint32_t index = 4; + static constexpr uint32_t phi = 11; + static constexpr uint32_t eta1 = 13; + static constexpr uint32_t eta2 = 22; static constexpr uint32_t ptuncon = 21; - static constexpr uint32_t impact = 30; + static constexpr uint32_t impact = 30; }; -struct header_shifts{ +struct packed_format_header_shifts{ static constexpr uint32_t bxmatch = 24; static constexpr uint32_t mAcount = 16; static constexpr uint32_t orbitmatch = 8; + static constexpr uint32_t warningTestEnabled = 8; static constexpr uint32_t mBcount = 0; }; -struct header_masks{ - static constexpr uint32_t bxmatch = 0xff << header_shifts::bxmatch; - static constexpr uint32_t mAcount = 0x0f << header_shifts::mAcount; - static constexpr uint32_t orbitmatch = 0xff << header_shifts::orbitmatch; - static constexpr uint32_t mBcount = 0x0f << header_shifts::mBcount; +struct packed_format_header_masks{ + static constexpr uint32_t bxmatch = 0x00ff << packed_format_header_shifts::bxmatch; + static constexpr uint32_t mAcount = 0x000f << packed_format_header_shifts::mAcount; + static constexpr uint32_t warningTestEnabled = 0x0001<<packed_format_header_shifts::warningTestEnabled; + static constexpr uint32_t orbitmatch = 0x00ff << packed_format_header_shifts::orbitmatch; + static constexpr uint32_t mBcount = 0x000f << packed_format_header_shifts::mBcount; }; struct gmt_scales{ static constexpr float pt_scale = 0.5; + static constexpr float ptunconstrained_scale = 1.0; static constexpr float phi_scale = static_cast<float>(2.*M_PI/576.); static constexpr float eta_scale = static_cast<float>(0.0870/8.); //9th MS bit is sign static constexpr float phi_range = M_PI; }; + +struct calo_scales{ + static constexpr float phi_scale = static_cast<float>(2.*M_PI/144.); + static constexpr float eta_scale = 0.0435; + static constexpr float et_scale = 0.5; +}; + struct constants{ - static constexpr uint32_t deadbeef = 0xdeadbeef; - static constexpr uint32_t beefdead = 0xbeefdead; - static constexpr uint32_t intermediate_marker= 0x0000000f; - static constexpr uint32_t orbit_trailer_size = 544; - static constexpr uint32_t orbit_header_size = 32; - static constexpr uint32_t dma_trailer_size = 32; + static constexpr uint32_t deadbeef = 0xdeadbeef; + static constexpr uint32_t beefdead = 0xbeefdead; + static constexpr uint32_t intermediate_marker = 0x0000000f; + static constexpr uint32_t orbit_trailer_size = 544; + static constexpr uint32_t orbit_header_size = 32; + static constexpr uint32_t dma_trailer_size = 32; //Note: total number of bytes of overhead per packet is: // (orbit_trailer_size+orbit_header_size)*NOrbitsPerDMAPacket + dma_trailer_size - static constexpr uint32_t intermediate = 0x00000001; - static constexpr uint32_t final = 0x00000001; + static constexpr uint32_t intermediate = 0x00000001; + static constexpr uint32_t final = 0x00000001; }; diff --git a/src/processor.cc b/src/processor.cc index c72340d5c38bd571cf36d917df0864c4e5449d3f..67d24dd9e2bfd63fa65a4cc9e2cb204c3fdd6d7b 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) && (prescaleFactor!=0)) { + 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(); diff --git a/test/config/scdaq-calo.conf b/test/config/scdaq-calo.conf index a1d3f0afa808af585c317c0422d9d1eb5c912f12..8d8d08abdee32d6b8ad9d0183215d26691905848 100644 --- a/test/config/scdaq-calo.conf +++ b/test/config/scdaq-calo.conf @@ -28,6 +28,9 @@ packets_per_report:200000 # number of orbits per DMA packet, in decimal NOrbitsPerDMAPacket:20 +# prescale that will be used for *calo* data only +prescale_factor:20 + ## Extra settings for "filedma" input #input_file:/dev/shm/testdata.bin diff --git a/test/config/scdaq-gmt.conf b/test/config/scdaq-gmt.conf index 74d04a5ca8329e725c3aba83d856706b96227196..cec8f07db8cfa5745822f54ef49d9f24e4aa07d1 100644 --- a/test/config/scdaq-gmt.conf +++ b/test/config/scdaq-gmt.conf @@ -28,6 +28,9 @@ packets_per_report:200000 # number of orbits per DMA packet, in decimal NOrbitsPerDMAPacket:20 +# prescale factor applied to *calo* data only +prescale_factor:20 + ## Extra settings for "filedma" input #input_file:/dev/shm/testdata.bin