From 7c6ef91fd41f36bd5abfe3b5a3a366c33739a3b8 Mon Sep 17 00:00:00 2001 From: Dinyar Rabady <dinyar@cern.ch> Date: Thu, 27 Oct 2022 18:29:44 +0200 Subject: [PATCH] Micro optimisations --- src/processor.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/processor.cc b/src/processor.cc index a7985299..e09a57c3 100644 --- a/src/processor.cc +++ b/src/processor.cc @@ -110,7 +110,7 @@ inline std::pair<uint32_t, bool> StreamProcessor::ProcessOrbitHeader(char* rd_pt } // Goes through orbit worth of data and fills the output memory with the calo data corresponding to the non-empty bunchcrossings, as marked in bx_vect -StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitCalo(std::vector<unsigned int>& bx_vect, char* rd_ptr, char* wr_ptr){ +StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitCalo(const std::vector<unsigned int>& bx_vect, char* rd_ptr, char* wr_ptr){ std::pair<uint32_t, bool> orbit_header = std::pair<uint32_t, bool> {ProcessOrbitHeader(rd_ptr)};//.second is the warning test enable bit rd_ptr += 32; // +32 to account for orbit header uint32_t relbx = uint32_t{0}; @@ -121,7 +121,7 @@ StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitCalo(std::vector<un if (bl->calo0[0]==constants::beefdead){break;} // orbit trailer has been reached, end of orbit data uint32_t bx = uint32_t{bx_vect[relbx]}; uint32_t orbit_ = uint32_t{orbit_header.first}; - if (bx > 3554){orbit_--;} //fix for the fact that bx 3555 - 3564 are from the previous orbit + if (bx > 3554){--orbit_;} //fix for the fact that bx 3555 - 3564 are from the previous orbit uint32_t header = uint32_t{orbit_header.second}; //header can be added to later memcpy(wr_ptr,(char*)&header,4); wr_ptr+=4; memcpy(wr_ptr,(char*)&bx,4); wr_ptr+=4; @@ -187,7 +187,7 @@ uint32_t StreamProcessor::FillBril(char* rd_ptr, char* wr_ptr, char* end_ptr){ } // Goes through orbit worth of data and fills the output memory with the muons corresponding to the non-empty bunchcrossings, as marked in bx_vect -StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitMuon(std::vector<unsigned int>& bx_vect, char* rd_ptr, char* wr_ptr){ +StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitMuon(const std::vector<unsigned int>& bx_vect, char* rd_ptr, char* wr_ptr){ std::pair<uint32_t, bool> orbit_header = std::pair<uint32_t, bool>{ProcessOrbitHeader(rd_ptr)};//.second is the warning test enable bit rd_ptr += 32; // +32 to account for orbit header uint32_t orbit = uint32_t{orbit_header.first}; @@ -201,7 +201,7 @@ StreamProcessor::fillOrbitMetadata StreamProcessor::FillOrbitMuon(std::vector<un bool AblocksOn[8]; bool BblocksOn[8]; uint32_t bx = uint32_t {bx_vect[relbx]}; - if (bx > 3554){orbit--;} //fix for the fact that bx 3555 - 3564 are from the previous orbit + if (bx > 3554){--orbit;} //fix for the fact that bx 3555 - 3564 are from the previous orbit for (unsigned int i = 0; i < 8; i++){ uint32_t bxA = (bl->bx[i] >> shifts::bx) & masks::bx; if ((bxA != bx) && (i == 0) && (bx<3555) && control.verbosity){ //only prints warning when BX < 3555 i.e from the same orbit @@ -296,10 +296,9 @@ void StreamProcessor::process(Slice& input, Slice& out) if (!CheckFrameMultBlock(input.size())){ return; } while (endofpacket == false){ - std::vector<unsigned int> bx_vect; uint32_t orbitCount = 0; bool trailerError = false; - bx_vect = CountBX(input, rd_ptr, trailerError); + std::vector<unsigned int> bx_vect = CountBX(input, rd_ptr, trailerError); if(trailerError == true){ stats.orbit_trailer_error_count++; LOG(WARNING) << "Orbit trailer error: orbit trailer not found before end of data packet. Packet will be skipped. Orbit trailer error count = " << stats.orbit_trailer_error_count; -- GitLab