Skip to content
Snippets Groups Projects

Patch BXnumfix

Closed Thomas Owen James requested to merge patch_BXnumfix into master
2 files
+ 20
16
Compare changes
  • Side-by-side
  • Inline

Files

@@ -70,9 +70,10 @@ std::pair<std::vector<unsigned int>, bool> StreamProcessor::CountBX(Slice& input
@@ -70,9 +70,10 @@ std::pair<std::vector<unsigned int>, bool> StreamProcessor::CountBX(Slice& input
}
}
// 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
// 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
uint32_t StreamProcessor::FillOrbit(Slice& input, Slice& out, std::vector<unsigned int>& bx_vect){
uint32_t StreamProcessor::FillOrbit(Slice& input, Slice& out, std::vector<unsigned int>& bx_vect, char* rd_ptr){
char* rd_ptr = input.begin() + 32; // +32 to account for orbit header
//char* rd_ptr = input.begin() + 32; // +32 to account for orbit header
char* wr_ptr = out.begin();
rd_ptr+=32; // +32 to account for orbit header
 
char* wr_ptr = out.begin(); // +32 to account for orbit header
uint32_t relbx = 0;
uint32_t relbx = 0;
uint32_t counts = 0;
uint32_t counts = 0;
while(relbx < bx_vect.size()){ //total number of non-empty BXs in orbit is given by bx_vect.size()
while(relbx < bx_vect.size()){ //total number of non-empty BXs in orbit is given by bx_vect.size()
@@ -85,10 +86,14 @@ uint32_t StreamProcessor::FillOrbit(Slice& input, Slice& out, std::vector<unsign
@@ -85,10 +86,14 @@ uint32_t StreamProcessor::FillOrbit(Slice& input, Slice& out, std::vector<unsign
bool AblocksOn[8];
bool AblocksOn[8];
bool BblocksOn[8];
bool BblocksOn[8];
for(unsigned int i = 0; i < 8; i++){
for(unsigned int i = 0; i < 8; i++){
 
uint32_t orbit = bl->orbit[i];
uint32_t bxA = (bl->bx[i] >> shifts::bx) & masks::bx;
uint32_t bxA = (bl->bx[i] >> shifts::bx) & masks::bx;
uint32_t bx = bx_vect[relbx];
uint32_t bx = bx_vect[relbx];
 
if((bxA != bx) && (i == 0)){
 
LOG(WARNING) << "BX mismatch, uGMT data word BX = " << std::hex << bxA <<
 
", BX extracted from trailer = "<< bx << ", orbitN is " << std::dec << orbit;
 
}
uint32_t interm = (bl->bx[i] >> shifts::interm) & masks::interm;
uint32_t interm = (bl->bx[i] >> shifts::interm) & masks::interm;
uint32_t orbit = bl->orbit[i];
bxmatch += (bx==bx_vect[relbx])<<i;
bxmatch += (bx==bx_vect[relbx])<<i;
orbitmatch += (orbit==bl->orbit[0])<<i;
orbitmatch += (orbit==bl->orbit[0])<<i;
uint32_t pt = (bl->mu1f[i] >> shifts::pt) & masks::pt;
uint32_t pt = (bl->mu1f[i] >> shifts::pt) & masks::pt;
@@ -144,7 +149,7 @@ uint32_t StreamProcessor::FillOrbit(Slice& input, Slice& out, std::vector<unsign
@@ -144,7 +149,7 @@ uint32_t StreamProcessor::FillOrbit(Slice& input, Slice& out, std::vector<unsign
return counts;
return counts;
}
}
Slice* StreamProcessor::process(Slice& input, Slice& out)
void StreamProcessor::process(Slice& input, Slice& out)
{
{
nbPackets++;
nbPackets++;
char* rd_ptr = input.begin();
char* rd_ptr = input.begin();
@@ -156,23 +161,23 @@ Slice* StreamProcessor::process(Slice& input, Slice& out)
@@ -156,23 +161,23 @@ Slice* StreamProcessor::process(Slice& input, Slice& out)
memcpy(wr_ptr,rd_ptr,input.size());
memcpy(wr_ptr,rd_ptr,input.size());
out.set_end(out.begin() + input.size());
out.set_end(out.begin() + input.size());
out.set_counts(1);
out.set_counts(1);
return &out;
return;
}
}
if (!CheckFrameMultBlock(input.size())){ return &out; }
if (!CheckFrameMultBlock(input.size())){ return; }
while (endofpacket == false){
while (endofpacket == false){
std::pair<std::vector<unsigned int>, bool> bx_vect_pair = CountBX(input, rd_ptr); // the bool (.second) is used to determine valididy of the BX count
std::pair<std::vector<unsigned int>, bool> bx_vect_pair = CountBX(input, rd_ptr); // the bool (.second) is used to determine valididy of the BX count
if(bx_vect_pair.second == false){
if(bx_vect_pair.second == false){
LOG(WARNING) << "orbit trailer not found before end of data packet. Packet will be skipped";
LOG(WARNING) << "orbit trailer not found before end of data packet. Packet will be skipped";
return &out;
return;
}
}
std::vector<unsigned int> bx_vect = bx_vect_pair.first;
std::vector<unsigned int> bx_vect = bx_vect_pair.first;
std::sort(bx_vect.begin(), bx_vect.end());
std::sort(bx_vect.begin(), bx_vect.end());
uint32_t orbitCount = FillOrbit(input, out, bx_vect);
uint32_t orbitCount = FillOrbit(input, out, bx_vect, rd_ptr);
++orbit_per_packet_count;
orbit_per_packet_count++;
rd_ptr+= 32 + bx_vect.size()*sizeof(block1) + constants::orbit_trailer_size; // 32 for orbit header, + nBXs + orbit trailer
rd_ptr+= 32 + bx_vect.size()*sizeof(block1) + constants::orbit_trailer_size; // 32 for orbit header, + nBXs + orbit trailer
wr_ptr+= orbitCount*12 + 12*bx_vect.size(); // 12 bytes for each muon/count then 12 bytes for each bx header
wr_ptr+= (orbitCount*12 + 12*bx_vect.size()); // 12 bytes for each muon/count then 12 bytes for each bx header
counts += orbitCount;
counts += orbitCount;
bx_vect.clear();
bx_vect.clear();
@@ -183,16 +188,15 @@ Slice* StreamProcessor::process(Slice& input, Slice& out)
@@ -183,16 +188,15 @@ Slice* StreamProcessor::process(Slice& input, Slice& out)
endofpacket = true;
endofpacket = true;
out.set_end(wr_ptr);
out.set_end(wr_ptr);
out.set_counts(counts);
out.set_counts(counts);
return &out;
return;
}
}
if(orbit_per_packet_count > nOrbitsPerDMAPacket){
if(orbit_per_packet_count > nOrbitsPerDMAPacket){
LOG(WARNING) << "expected DMA trailer word deadbeef, found "
LOG(WARNING) << "expected DMA trailer word deadbeef, found "
<< std::hex << *dma_trailer_word << ". Orbits per packet count "
<< std::hex << *dma_trailer_word << ". Orbits per packet count "
<< orbit_per_packet_count << ", > expected, (" << nOrbitsPerDMAPacket <<") skipping packet.";
<< orbit_per_packet_count << ", > expected, (" << nOrbitsPerDMAPacket <<") skipping packet.";
return &out;
return;
}
}
}
}
}
}
}
}
Loading