Skip to content
Snippets Groups Projects
Commit 95f09d16 authored by decianm's avatar decianm
Browse files

streamline definitions: take numbers from UTInfo, adapt namespaces, move...

streamline definitions: take numbers from UTInfo, adapt namespaces, move calculation of full sector ID to UTDAQHelper
parent b8862d5d
No related branches found
No related tags found
1 merge request!3421Streamline code for UT tracking code
Pipeline #5614407 passed
......@@ -19,6 +19,7 @@
#include "LHCbAlgs/Transformer.h"
#include "PrKernel/UTGeomCache.h"
#include "PrKernel/UTHitHandler.h"
#include "UTDAQ/UTInfo.h"
#include "UTDet/DeUTDetector.h"
#include "fmt/format.h"
#include <cassert>
......@@ -66,7 +67,9 @@ namespace LHCb::Pr::UT {
// make local decoder
if ( bank->size() == 0 ) continue;
auto decode = [&hitHandler, geomOffset = bank->sourceID() * UTGeomCache::NSectorPerBoard,
auto decode = [&hitHandler,
geomOffset =
bank->sourceID() * static_cast<unsigned>( UTInfo::SectorNumbers::MaxSectorsPerBoard ),
&cache]( auto decoder_range ) {
for ( const auto& aWord : decoder_range ) {
const std::size_t geomIdx = geomOffset + ( aWord.channelID() / 512 );
......@@ -88,15 +91,15 @@ namespace LHCb::Pr::UT {
aWord.hasHighThreshold() );
}
};
switch ( UTDAQ::version{bank->version()} ) {
case UTDAQ::version::v5:
switch ( ::UTDAQ::version{bank->version()} ) {
case ::UTDAQ::version::v5:
if ( !isCluster )
decode( UTDecoder<UTDAQ::version::v5>{*bank}.posRange() );
decode( UTDecoder<::UTDAQ::version::v5>{*bank}.posRange() );
else
decode( UTDecoder<UTDAQ::version::v5>{*bank}.posAdcRange( isAdcMax, stripMax ) );
decode( UTDecoder<::UTDAQ::version::v5>{*bank}.posAdcRange( isAdcMax, stripMax ) );
break;
case UTDAQ::version::v4:
decode( UTDecoder<UTDAQ::version::v4>{*bank}.posRange() );
case ::UTDAQ::version::v4:
decode( UTDecoder<::UTDAQ::version::v4>{*bank}.posRange() );
break;
default:
throw std::runtime_error{"unknown version of the RawBank"}; /* OOPS: unknown format */
......
......@@ -21,20 +21,18 @@
namespace LHCb::Pr::UT {
struct UTGeomCache {
static constexpr int NSectorPerBoard = 6;
static constexpr int NSectorAllBoard = 240 * NSectorPerBoard;
/// Faster access to sectors
#ifdef USE_DD4HEP
std::array<DeUTSector, NSectorAllBoard> sectors{};
std::array<DeUTSector, UTInfo::MaxSectorsAllBoards> sectors{};
#else
std::array<DeUTSector const*, NSectorAllBoard> sectors{};
std::array<DeUTSector const*, UTInfo::MaxSectorsAllBoards> sectors{};
#endif
struct FullChan {
unsigned int idx{0};
unsigned int chanID{0};
};
std::array<FullChan, NSectorAllBoard> fullchan;
std::array<FullChan, UTInfo::MaxSectorsAllBoards> fullchan;
UTGeomCache() = default;
UTGeomCache( const DeUTDetector& utDet, const IUTReadoutTool& ro, const IUTReadoutTool::ReadoutInfo& roInfo ) {
......@@ -42,8 +40,9 @@ namespace LHCb::Pr::UT {
for ( unsigned int srcId = 0; srcId < ro.nBoard( &roInfo ); srcId++ ) {
for ( const auto& [idx, sector] :
range::enumerate( ro.findBySourceID( srcId, &roInfo ),
ro.TELLNumberToSourceID( srcId + 1, &roInfo ) * UTGeomCache::NSectorPerBoard ) ) {
assert( idx < NSectorAllBoard );
ro.TELLNumberToSourceID( srcId + 1, &roInfo ) *
static_cast<unsigned>( UTInfo::SectorNumbers::MaxSectorsPerBoard ) ) ) {
assert( idx < UTInfo::MaxSectorsAllBoards );
#ifdef USE_DD4HEP
if ( sectors[idx].isValid() ) throw std::runtime_error( "UTGeomCache: duplicate sector???" );
sectors[idx] = utDet.getSector( sector );
......@@ -51,10 +50,9 @@ namespace LHCb::Pr::UT {
if ( sectors[idx] ) throw std::runtime_error( "UTGeomCache: duplicate sector???" );
sectors[idx] = &utDet.getSector( sector );
#endif
fullchan[idx] = {
static_cast<unsigned int>( ::UT::HitHandler::HitsInUT::idx(
sector.side(), sector.layer(), sector.stave(), sector.face(), sector.module(), sector.sector() ) ),
static_cast<unsigned int>( sector )};
fullchan[idx] = {LHCb::UTDAQ::sectorFullID( sector.side(), sector.layer(), sector.stave(), sector.face(),
sector.module(), sector.sector() ),
sector.channelID()};
}
}
}
......
......@@ -13,6 +13,7 @@
#include "Kernel/EventLocalAllocator.h"
#include "Kernel/STLExtensions.h"
#include "PrKernel/UTHit.h"
#include "UTDAQ/UTDAQHelper.h"
#include "UTDAQ/UTInfo.h"
#include <cassert>
#include <cstdint>
......@@ -36,41 +37,16 @@ namespace UT {
public:
class HitsInUT {
std::array<HitIndices, static_cast<int>( UTInfo::DetectorNumbers::Sides ) *
static_cast<int>( UTInfo::DetectorNumbers::HalfLayers ) *
static_cast<int>( UTInfo::DetectorNumbers::Staves ) *
static_cast<int>( UTInfo::DetectorNumbers::Faces ) *
static_cast<int>( UTInfo::DetectorNumbers::Modules ) *
static_cast<int>( UTInfo::DetectorNumbers::SubSectors )>
m_data = {};
std::array<HitIndices, UTInfo::NSectors> m_data = {};
public:
constexpr static int idx( unsigned int side, unsigned int halflayer, unsigned int stave, unsigned int face,
unsigned int module, unsigned int subsector ) {
assert( side < static_cast<int>( UTInfo::DetectorNumbers::Sides ) );
assert( halflayer < static_cast<int>( UTInfo::DetectorNumbers::HalfLayers ) );
assert( stave < static_cast<int>( UTInfo::DetectorNumbers::Staves ) );
assert( face < static_cast<int>( UTInfo::DetectorNumbers::Faces ) );
assert( module < static_cast<int>( UTInfo::DetectorNumbers::Modules ) );
assert( subsector < static_cast<int>( UTInfo::DetectorNumbers::SubSectors ) );
return ( ( ( ( ( ( side * static_cast<int>( UTInfo::DetectorNumbers::HalfLayers ) + halflayer ) *
static_cast<int>( UTInfo::DetectorNumbers::Staves ) ) +
stave ) *
static_cast<int>( UTInfo::DetectorNumbers::Faces ) +
face ) *
static_cast<int>( UTInfo::DetectorNumbers::Modules ) ) +
module ) *
static_cast<int>( UTInfo::DetectorNumbers::SubSectors ) +
subsector;
}
const HitIndices& operator()( unsigned int side, unsigned int halflayer, unsigned int stave, unsigned int face,
unsigned int module, unsigned int subsector ) const {
return m_data[idx( side, halflayer, stave, face, module, subsector )];
return m_data[LHCb::UTDAQ::sectorFullID( side, halflayer, stave, face, module, subsector )];
}
HitIndices& operator()( unsigned int side, unsigned int halflayer, unsigned int stave, unsigned int face,
unsigned int module, unsigned int subsector ) {
return m_data[idx( side, halflayer, stave, face, module, subsector )];
return m_data[LHCb::UTDAQ::sectorFullID( side, halflayer, stave, face, module, subsector )];
}
const HitIndices& operator()( unsigned int idx ) const { return m_data[idx]; }
HitIndices& operator()( unsigned int idx ) { return m_data[idx]; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment