Skip to content
Snippets Groups Projects

Fix for VPRetinaSPmixer

Merged Giovanni Bassi requested to merge fix_VPRetinaSPmixer into master
All threads resolved!
1 file
+ 3
81
Compare changes
  • Side-by-side
  • Inline
@@ -160,90 +160,12 @@ LHCb::RawEvent VPRetinaSPmixer::operator()( const LHCb::RawEvent& rawEvent ) con
} else {
// make list of pairs of banks to combine, there are 208 sensors and 104 pairs
std::array<std::pair<LHCb::RawBank const*, LHCb::RawBank const*>, 104> bankPairs;
bankPairs.fill( {nullptr, nullptr} ); // fill with iterators to the end of the bank
// Loop over VP RawBanks
for ( auto iterBank : tBanks ) {
const unsigned int sensor = iterBank->sourceID();
const unsigned int pos = sensor / 2; // integer division to get pair pos
if ( pos > 103 ) {
warning() << "Bad sensorID (" << sensor << ") should be 0->207" << endmsg;
return result;
}
if ( ( sensor & 0x1U ) == 0x0U ) {
// first sensor in pair [even number]
bankPairs[pos].first = iterBank;
} else {
// second sensor in pair
bankPairs[pos].second = iterBank;
}
}
for ( auto iPair : bankPairs ) {
uint32_t sensor0 = 0;
LHCb::span<const uint32_t> bank0 = {};
uint32_t sensor1 = 0;
LHCb::span<const uint32_t> bank1 = {};
if ( iPair.first ) {
sensor0 = iPair.first->sourceID();
bank0 = iPair.first->range<uint32_t>();
}
if ( iPair.second ) {
sensor1 = iPair.second->sourceID();
bank1 = iPair.second->range<uint32_t>();
}
std::vector<uint32_t> mixedSP;
unsigned int pairBankSize = bank0[0] + bank1[0];
mixedSP.reserve( pairBankSize + 1 );
mixedSP.push_back( pairBankSize ); // set bank size (element 0) to sum of length of both inputs
// check if the isolated cluster bits should be set (set to zero if too many clusters)
uint32_t icf_over_mask = 0xffffffffU; // default mask is everything passes through
if ( pairBankSize > m_icf_cut ) {
icf_over_mask = 0x7fffffffU; // mask to zero bit 31
}
// skip entry 0 (bank size) when copying words into the combined bank
for ( auto isp_word = begin( bank0 ) + 1; isp_word != end( bank0 ); ++isp_word ) {
mixedSP.push_back( ( *isp_word ) & icf_over_mask );
}
// skip entry 0 (bank size) when copying words into the combined bank
for ( auto isp_word = begin( bank1 ) + 1; isp_word != end( bank1 ); ++isp_word ) {
mixedSP.push_back( ( *isp_word ) & icf_over_mask );
}
uint32_t n = mixedSP[0];
if ( n > 1 ) { // check there are at least 2 SPs
for ( uint32_t i = n - 1; i > 0; --i ) {
// pick random int from 0 to i inclusive
uint32_t j = static_cast<int>( m_rndm.shoot() * ( i + 1 ) );
std::swap( mixedSP[i + 1], mixedSP[j + 1] );
}
}
assert( mixedSP.size() == 1 + mixedSP[0] );
// see comment above for bit definitions
uint32_t bankID;
if ( ( sensor0 & 0x4 ) == 0x0 ) { // c-side has even module numbers (bit 2 is first of module index)
bankID = 0x1800; // C-side
} else {
bankID = 0x1000; // A-side
}
bankID |= ( sensor0 >> 1 ); // left shift by 1 as final bit in each superpixel
result.addBank( bankID, LHCb::RawBank::VP, VPRetinaCluster::c_SPBankVersion, mixedSP );
result.addBank( iterBank->sourceID(), LHCb::RawBank::VP, VPRetinaCluster::c_SPBankVersion,
iterBank->range<uint32_t>() );
++nBanks;
if ( msgLevel( MSG::VERBOSE ) ) {
verbose() << format( "Added bank with sourceID 0x%x containing sensors %i and %i", bankID, sensor0, sensor1 )
<< endmsg;
}
} // loop over all banks
}
}
if ( msgLevel( MSG::DEBUG ) ) debug() << "Added " << nBanks << " raw banks of retina clusters to TES" << endmsg;
Loading