diff --git a/Pr/PrAlgorithms/src/PrAddUTHitsTool.cpp b/Pr/PrAlgorithms/src/PrAddUTHitsTool.cpp index 03b96ac99ff24c3923a656e16dc6f7461a4a0a59..f029bc7d6d86f792108fed60ebbd2e13bbe91ca2 100644 --- a/Pr/PrAlgorithms/src/PrAddUTHitsTool.cpp +++ b/Pr/PrAlgorithms/src/PrAddUTHitsTool.cpp @@ -425,11 +425,17 @@ namespace LHCb::Pr { hitsInLayers.clear(); // -- This is for some sanity checks later - constexpr const auto maxSectorsPerRegion = static_cast( UTInfo::SectorNumbers::MaxSectorsPerRegion ); - constexpr const auto maxLayer = totUTLayers; - constexpr const auto maxRegion = static_cast( UTInfo::DetectorNumbers::Regions ); - [[maybe_unused]] constexpr const auto maxSectorNumber = - maxSectorsPerRegion + ( ( maxLayer - 1 ) * maxRegion + ( maxRegion - 1 ) ) * maxSectorsPerRegion; + [[maybe_unused]] constexpr const auto maxSectorNumber = 2304; + // With the new UT chID definition the sector number can go up to 2304 given the following equation + // ( ( ( ( ( ( side * static_cast( UTInfo::DetectorNumbers::HalfLayers ) + halflayer ) * + // static_cast( UTInfo::DetectorNumbers::Staves ) ) + + // stave ) * + // static_cast( UTInfo::DetectorNumbers::Faces ) + + // face ) * + // static_cast( UTInfo::DetectorNumbers::Modules ) ) + + // module ) * + // static_cast( UTInfo::DetectorNumbers::SubSectors ) + + // subsector; const auto stateX = fState.template get().x().cast(); const auto stateY = fState.template get().y().cast(); diff --git a/Pr/PrAlgorithms/src/PrDownTrack.h b/Pr/PrAlgorithms/src/PrDownTrack.h index e24e386956b871315cdfbee9c8d3769ee8572ad5..57d49bf1abf64beb1b0a0f965226f405bcdb327f 100644 --- a/Pr/PrAlgorithms/src/PrDownTrack.h +++ b/Pr/PrAlgorithms/src/PrDownTrack.h @@ -39,14 +39,12 @@ namespace Downstream { return bit_cast( LHCb::LHCbID( LHCb::Detector::UT::ChannelID( chanID ) ).lhcbID() ); } [[nodiscard]] int planeCode() const { - const auto myHits = hits->scalar(); - const auto mH = myHits[hit]; - auto lhcbid = mH.get().cast(); - auto station = ( lhcbid & static_cast( UTInfo::MasksBits::StationMask ) ) >> - static_cast( UTInfo::MasksBits::StationBits ); - auto layer = ( lhcbid & static_cast( UTInfo::MasksBits::LayerMask ) ) >> - static_cast( UTInfo::MasksBits::LayerBits ); - return 2 * ( station - 1 ) + ( layer - 1 ); + const auto myHits = hits->scalar(); + const auto mH = myHits[hit]; + + auto lhcbid = mH.get().cast(); + return ( lhcbid & static_cast( UTInfo::MasksBits::HalfLayerMask ) ) >> + static_cast( UTInfo::MasksBits::HalfLayerBits ); } [[nodiscard]] auto weight() const { const auto myHits = hits->scalar(); diff --git a/Pr/PrAlgorithms/src/PrResidualUTHits.cpp b/Pr/PrAlgorithms/src/PrResidualUTHits.cpp index 3407f86b61854638125ff7de361efd0fb9567977..aac02dfc70cc12bfcb20bb77a0713d4513b9e485 100644 --- a/Pr/PrAlgorithms/src/PrResidualUTHits.cpp +++ b/Pr/PrAlgorithms/src/PrResidualUTHits.cpp @@ -76,23 +76,29 @@ UT::HitHandler LHCb::Pr::PrResidualUTHits::operator()( Long::Tracks const& track } } - for ( int iStation = 1; iStation <= static_cast( UTInfo::DetectorNumbers::Stations ); ++iStation ) { - for ( int iLayer = 1; iLayer <= static_cast( UTInfo::DetectorNumbers::Layers ); ++iLayer ) { - for ( int iRegion = 1; iRegion <= static_cast( UTInfo::DetectorNumbers::Regions ); ++iRegion ) { - for ( int iSector = 1; iSector <= static_cast( UTInfo::DetectorNumbers::Sectors ); ++iSector ) { - for ( auto& uthit : uthithandler.hits( iStation, iLayer, iRegion, iSector ) ) { - bool used = std::any_of( usedUTHits.begin(), usedUTHits.end(), - [utid = uthit.chanID().channelID()]( const auto& id ) { return utid == id; } ); + for ( int iSide = 0; iSide < static_cast( UTInfo::DetectorNumbers::Sides ); ++iSide ) { + for ( int iLayer = 0; iLayer < static_cast( UTInfo::DetectorNumbers::HalfLayers ); ++iLayer ) { + for ( int iStave = 0; iStave < static_cast( UTInfo::DetectorNumbers::Staves ); ++iStave ) { + for ( int iFace = 0; iFace < static_cast( UTInfo::DetectorNumbers::Faces ); ++iFace ) { + for ( int iModule = 0; iModule < static_cast( UTInfo::DetectorNumbers::Modules ); ++iModule ) { + for ( int iSector = 1; iSector <= static_cast( UTInfo::DetectorNumbers::SubSectors ); ++iSector ) { + for ( auto& uthit : uthithandler.hits( iSide, iLayer, iStave, iFace, iModule, iSector ) ) { + bool used = std::any_of( usedUTHits.begin(), usedUTHits.end(), + [utid = uthit.chanID().channelID()]( const auto& id ) { return utid == id; } ); - if ( used ) continue; - const unsigned int fullChanIdx = UT::HitHandler::HitsInUT::idx( iStation, iLayer, iRegion, iSector ); - auto& aSector = utDet.getSector( uthit.chanID() ); - tmp.emplace_back( aSector, fullChanIdx, uthit.strip(), uthit.fracStrip(), uthit.chanID(), uthit.size(), - uthit.highThreshold() ); + if ( used ) continue; + const unsigned int fullChanIdx = + UT::HitHandler::HitsInUT::idx( iSide, iLayer, iStave, iFace, iModule, iSector ); + auto& aSector = utDet.getSector( uthit.chanID() ); + tmp.emplace_back( aSector, fullChanIdx, uthit.strip(), uthit.fracStrip(), uthit.chanID(), uthit.size(), + uthit.highThreshold() ); + } + } } } } } } + return tmp; } diff --git a/Pr/PrAlgorithms/src/PrStoreUTHit.cpp b/Pr/PrAlgorithms/src/PrStoreUTHit.cpp index 3204a7a62a7a0be148b37034eabff93b1ed53a2f..8673518b2047a617bc8b407c9f458da909cb4b59 100644 --- a/Pr/PrAlgorithms/src/PrStoreUTHit.cpp +++ b/Pr/PrAlgorithms/src/PrStoreUTHit.cpp @@ -77,7 +77,7 @@ namespace LHCb::Pr::UT { const auto& fullChan = cache.fullchan[geomIdx]; // FIXME: move functionality into channelID -- why is this _different_ from UTChennelID::strip() ?? - const auto strip = ( aWord.channelID() & 0x1ff ) + 1; + const auto strip = ( aWord.channelID() & 0x1ff ); #ifdef USE_DD4HEP hitHandler.emplace_back( aSector, fullChan.idx, strip, aWord.fracStripBits(), diff --git a/Pr/PrKernel/include/PrKernel/PrMutUTHits.h b/Pr/PrKernel/include/PrKernel/PrMutUTHits.h index 953a60fe8e1318127a3866abb5f46c4e9ccdd527..a97cea830ad6bf208afed98d28d329034db77596 100644 --- a/Pr/PrKernel/include/PrKernel/PrMutUTHits.h +++ b/Pr/PrKernel/include/PrKernel/PrMutUTHits.h @@ -59,13 +59,9 @@ namespace LHCb::Pr::UT { /// Retrieve the plane code auto planeCode() const { - auto id = channelID(); - auto station = ( id & static_cast( UTInfo::MasksBits::StationMask ) ) >> - static_cast( UTInfo::MasksBits::StationBits ); - auto layer = ( id & static_cast( UTInfo::MasksBits::LayerMask ) ) >> - static_cast( UTInfo::MasksBits::LayerBits ); - - return 2 * ( station - 1 ) + ( layer - 1 ); + auto id = channelID(); + return ( id & static_cast( UTInfo::MasksBits::HalfLayerMask ) ) >> + static_cast( UTInfo::MasksBits::HalfLayerBits ); } }; template diff --git a/Pr/PrKernel/include/PrKernel/UTGeomCache.h b/Pr/PrKernel/include/PrKernel/UTGeomCache.h index a48247148b559cac03fe8a9fe0d74ad2609dbe51..bc5eb8922366f853839692a7d0f24ef5f0271dfb 100644 --- a/Pr/PrKernel/include/PrKernel/UTGeomCache.h +++ b/Pr/PrKernel/include/PrKernel/UTGeomCache.h @@ -51,9 +51,10 @@ namespace LHCb::Pr::UT { if ( sectors[idx] ) throw std::runtime_error( "UTGeomCache: duplicate sector???" ); sectors[idx] = &utDet.getSector( sector ); #endif - fullchan[idx] = {static_cast( ::UT::HitHandler::HitsInUT::idx( - sector.station(), sector.layer(), sector.detRegion(), sector.sector() ) ), - static_cast( sector )}; + fullchan[idx] = { + static_cast( ::UT::HitHandler::HitsInUT::idx( + sector.side(), sector.layer(), sector.stave(), sector.face(), sector.module(), sector.sector() ) ), + static_cast( sector )}; } } } diff --git a/Pr/PrKernel/include/PrKernel/UTHitHandler.h b/Pr/PrKernel/include/PrKernel/UTHitHandler.h index 5d5f31ca3731349986186fbb076c2ae753bc85b2..61f2f7bded26b96e1dbe9c136b96a84a4abd4f0f 100644 --- a/Pr/PrKernel/include/PrKernel/UTHitHandler.h +++ b/Pr/PrKernel/include/PrKernel/UTHitHandler.h @@ -36,30 +36,41 @@ namespace UT { public: class HitsInUT { - std::array( UTInfo::DetectorNumbers::Stations ) * - static_cast( UTInfo::DetectorNumbers::Layers ) * - static_cast( UTInfo::DetectorNumbers::Regions ) * - static_cast( UTInfo::DetectorNumbers::Sectors )> + std::array( UTInfo::DetectorNumbers::Sides ) * + static_cast( UTInfo::DetectorNumbers::HalfLayers ) * + static_cast( UTInfo::DetectorNumbers::Staves ) * + static_cast( UTInfo::DetectorNumbers::Faces ) * + static_cast( UTInfo::DetectorNumbers::Modules ) * + static_cast( UTInfo::DetectorNumbers::SubSectors )> m_data = {}; public: - constexpr static int idx( unsigned int station, unsigned int layer, unsigned int region, unsigned int sector ) { - assert( station != 0 && station <= static_cast( UTInfo::DetectorNumbers::Stations ) ); - assert( layer != 0 && layer <= static_cast( UTInfo::DetectorNumbers::Layers ) ); - assert( region != 0 && region <= static_cast( UTInfo::DetectorNumbers::Regions ) ); - assert( sector != 0 && sector <= static_cast( UTInfo::DetectorNumbers::Sectors ) ); - return ( ( ( station - 1 ) * static_cast( UTInfo::DetectorNumbers::Layers ) + ( layer - 1 ) ) * - static_cast( UTInfo::DetectorNumbers::Regions ) + - ( region - 1 ) ) * - static_cast( UTInfo::DetectorNumbers::Sectors ) + - ( sector - 1 ); + 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( UTInfo::DetectorNumbers::Sides ) ); + assert( halflayer < static_cast( UTInfo::DetectorNumbers::HalfLayers ) ); + assert( stave < static_cast( UTInfo::DetectorNumbers::Staves ) ); + assert( face < static_cast( UTInfo::DetectorNumbers::Faces ) ); + assert( module < static_cast( UTInfo::DetectorNumbers::Modules ) ); + assert( subsector < static_cast( UTInfo::DetectorNumbers::SubSectors ) ); + return ( ( ( ( ( ( side * static_cast( UTInfo::DetectorNumbers::HalfLayers ) + halflayer ) * + static_cast( UTInfo::DetectorNumbers::Staves ) ) + + stave ) * + static_cast( UTInfo::DetectorNumbers::Faces ) + + face ) * + static_cast( UTInfo::DetectorNumbers::Modules ) ) + + module ) * + static_cast( UTInfo::DetectorNumbers::SubSectors ) + + subsector; } - const HitIndices& operator()( unsigned int station, unsigned int layer, unsigned int region, - unsigned int sector ) const { - return m_data[idx( station, layer, region, sector )]; + + 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 )]; } - HitIndices& operator()( unsigned int station, unsigned int layer, unsigned int region, unsigned int sector ) { - return m_data[idx( station, layer, region, sector )]; + 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 )]; } const HitIndices& operator()( unsigned int idx ) const { return m_data[idx]; } HitIndices& operator()( unsigned int idx ) { return m_data[idx]; } @@ -117,9 +128,9 @@ namespace UT { void reserve( const std::size_t nHits ) { m_allhits.reserve( nHits ); } /// Access the range for a given set of hits - [[nodiscard]] HitRange hits( unsigned int station, unsigned int layer, unsigned int region, - unsigned int sector ) const noexcept { - const auto& indices = m_indices( station, layer, region, sector ); + [[nodiscard]] HitRange hits( unsigned int side, unsigned int halflayer, unsigned int stave, unsigned int face, + unsigned int module, unsigned int subsector ) const noexcept { + const auto& indices = m_indices( side, halflayer, stave, face, module, subsector ); return LHCb::make_span( m_allhits.begin() + indices.first, m_allhits.begin() + indices.second ); } @@ -127,7 +138,7 @@ namespace UT { [[nodiscard]] const auto& hits() const { return m_allhits; } [[nodiscard]] const UT::Hit* hit( LHCb::Detector::UT::ChannelID id ) const noexcept { - auto hs = hits( id.station(), id.layer(), id.detRegion(), id.sector() ); + auto hs = hits( id.side(), id.layer(), id.stave(), id.face(), id.module(), id.sector() ); auto hit = std::find_if( hs.begin(), hs.end(), [id]( UT::Hit const& hit ) { return hit.chanID() == id; } ); return hit != hs.end() ? &*hit : nullptr; } diff --git a/Pr/PrMCTools/src/PrDownstreamDumper.cpp b/Pr/PrMCTools/src/PrDownstreamDumper.cpp index e784223eb457ef57b5474396adf43ef76909c68e..08b4c808ca6124e983d85da78feb7878d506637f 100644 --- a/Pr/PrMCTools/src/PrDownstreamDumper.cpp +++ b/Pr/PrMCTools/src/PrDownstreamDumper.cpp @@ -413,22 +413,15 @@ PrDownstreamDumper::SplitUTHits( const UT::HitHandler& const InputLinks& HitMCParticleLinks ) const { ParticleToUTHits particle_to_ut_hits; std::vector non_assoc_ut_hits; - for ( int iStation = 1; iStation < 3; ++iStation ) { - for ( int iLayer = 1; iLayer < 3; ++iLayer ) { - for ( int iRegion = 1; iRegion < 4; ++iRegion ) { - for ( int iSector = 1; iSector < 99; ++iSector ) { - for ( const auto& hit : prUTHitHandler.hits( iStation, iLayer, iRegion, iSector ) ) { - LHCb::LHCbID lhcbid = hit.lhcbID(); - auto mcparticlesrelations = HitMCParticleLinks.from( lhcbid.lhcbID() ); - if ( mcparticlesrelations.empty() ) { non_assoc_ut_hits.push_back( hit ); } - for ( const auto& mcp : mcparticlesrelations ) { - auto MCP = mcp.to(); - particle_to_ut_hits[MCP].push_back( hit ); - } - } - } - } + for ( const auto& hit : prUTHitHandler.hits() ) { + LHCb::LHCbID lhcbid = hit.lhcbID(); + auto mcparticlesrelations = HitMCParticleLinks.from( lhcbid.lhcbID() ); + if ( mcparticlesrelations.empty() ) { non_assoc_ut_hits.push_back( hit ); } + for ( const auto& mcp : mcparticlesrelations ) { + auto MCP = mcp.to(); + particle_to_ut_hits[MCP].push_back( hit ); } } + return {particle_to_ut_hits, non_assoc_ut_hits}; } diff --git a/Pr/PrMCTools/src/PrLHCbID2MCParticle.cpp b/Pr/PrMCTools/src/PrLHCbID2MCParticle.cpp index bb410a495b457d3e7916c94baa31fc7fda163883..d482d7db2be27621b66c57e282665db2ecdde031 100644 --- a/Pr/PrMCTools/src/PrLHCbID2MCParticle.cpp +++ b/Pr/PrMCTools/src/PrLHCbID2MCParticle.cpp @@ -14,8 +14,12 @@ #include "Event/MCParticle.h" #include "Event/PrHits.h" #include "Event/UTCluster.h" +#include "Event/UTDigit.h" #include "Event/VPFullCluster.h" #include "Event/VPLightCluster.h" +#include "Kernel/UTIDMapping.h" +#include "Linker/LinkedTo.h" +#include "MuonDAQ/MuonHitContainer.h" #include "PrKernel/UTHitHandler.h" #include "LHCbAlgs/Transformer.h" @@ -145,17 +149,28 @@ namespace { struct LoopOverClusters { void operator()( const UT::HitHandler& hitHandler, const LHCb::LinksByKey& clusterLink, LHCb::LinksByKey& idLink, const LHCb::MCParticles& mcParts, BufferedType& nullMCParticles_counter ) { - for ( unsigned int station = 1; station < 3; station++ ) { - for ( unsigned int layer = 1; layer < 3; layer++ ) { - for ( unsigned int region = 1; region < 4; region++ ) { - for ( unsigned int sector = 1; sector < 99; sector++ ) { - for ( const auto& hit : hitHandler.hits( station, layer, region, sector ) ) { - linkAll( clusterLink, idLink, mcParts, hit.chanID(), - {boost::numeric_cast( hit.chanID().channelID() )}, nullMCParticles_counter ); - } - } + const int utIDupper = 0x600000L; + bool utIDconvert = false; + if ( clusterLink.keyIndex().front().first > utIDupper ) utIDconvert = true; + + auto linkfunc = [&idLink, &mcParts, &hitHandler, &nullMCParticles_counter]( const LHCb::LinksByKey iLink ) { + for ( const auto& hit : hitHandler.hits() ) { + linkAll( iLink, idLink, mcParts, hit.chanID(), + {boost::numeric_cast( hit.chanID().channelID() )}, nullMCParticles_counter ); + } + }; + if ( utIDconvert ) { + // below is copy LinksByKey with old ID -> new ID: + LHCb::LinksByKey nLink{std::in_place_type, std::in_place_type, clusterLink.order()}; + for ( auto [key, _] : clusterLink.keyIndex() ) { + unsigned int clusterID = LHCb::UTIDMapping::ReconvertID( key ); + for ( const auto& [mcp, weight] : LinkedTo{&clusterLink}.weightedRange( key ) ) { + nLink.link( clusterID, &mcp, weight ); } } + linkfunc( nLink ); + } else { + linkfunc( clusterLink ); } } }; diff --git a/Pr/PrMCTools/src/PrTrackRecoDumper.cpp b/Pr/PrMCTools/src/PrTrackRecoDumper.cpp index b42a0d1f1b12a4ad58e4783592720e077575ba3a..0490810230d0505a155d0c6c269fb59d677587a0 100644 --- a/Pr/PrMCTools/src/PrTrackRecoDumper.cpp +++ b/Pr/PrMCTools/src/PrTrackRecoDumper.cpp @@ -491,38 +491,28 @@ void PrTrackRecoDumper::operator()( const Tracks& recTracks, const LHCb::VPLight } if ( id.isUT() ) { - auto ut_ID = id.utID(); - bool foundID = false; - nUTHits = nUTHits + 1; - for ( int iStation = 1; iStation < 3; ++iStation ) { - for ( int iLayer = 1; iLayer < 3; ++iLayer ) { - for ( int iRegion = 1; iRegion < 4; ++iRegion ) { - for ( int iSector = 1; iSector < 99; ++iSector ) { - for ( auto& uthit : prUTHitHandler.hits( iStation, iLayer, iRegion, iSector ) ) { - if ( uthit.chanID().channelID() == ut_ID.channelID() ) { - foundID = true; - UT_cos.push_back( uthit.cos() ); - UT_cosT.push_back( uthit.cosT() ); - UT_dxDy.push_back( uthit.dxDy() ); - UT_lhcbID.push_back( uthit.chanID().channelID() ); - UT_planeCode.push_back( uthit.planeCode() ); - UT_sinT.push_back( uthit.sinT() ); - UT_size.push_back( uthit.size() ); - UT_tanT.push_back( uthit.tanT() ); - UT_weight.push_back( uthit.weight() ); - UT_xAtYEq0.push_back( uthit.xAtYEq0() ); - UT_xAtYMid.push_back( uthit.xAtYMid() ); - UT_xMax.push_back( uthit.xMax() ); - UT_xMin.push_back( uthit.xMin() ); - UT_xT.push_back( uthit.xT() ); - UT_yBegin.push_back( uthit.yBegin() ); - UT_yEnd.push_back( uthit.yEnd() ); - break; - } - } - } - } - } + auto ut_ID = id.utID(); + bool foundID = false; + nUTHits = nUTHits + 1; + const UT::Hit* uthit = prUTHitHandler.hit( ut_ID ); + if ( uthit ) { + foundID = true; + UT_cos.push_back( uthit->cos() ); + UT_cosT.push_back( uthit->cosT() ); + UT_dxDy.push_back( uthit->dxDy() ); + UT_lhcbID.push_back( uthit->chanID().channelID() ); + UT_planeCode.push_back( uthit->planeCode() ); + UT_sinT.push_back( uthit->sinT() ); + UT_size.push_back( uthit->size() ); + UT_tanT.push_back( uthit->tanT() ); + UT_weight.push_back( uthit->weight() ); + UT_xAtYEq0.push_back( uthit->xAtYEq0() ); + UT_xAtYMid.push_back( uthit->xAtYMid() ); + UT_xMax.push_back( uthit->xMax() ); + UT_xMin.push_back( uthit->xMin() ); + UT_xT.push_back( uthit->xT() ); + UT_yBegin.push_back( uthit->yBegin() ); + UT_yEnd.push_back( uthit->yEnd() ); } if ( !foundID ) error() << "Hit not found: " << ut_ID.channelID() << endmsg; diff --git a/Pr/PrMCTools/src/PrTrackerDumper2.cpp b/Pr/PrMCTools/src/PrTrackerDumper2.cpp index aabe9c0d21423608cb0d04fb469c389a762e1156..da6e7435602bec164793956eb64dc34ac4b240f4 100644 --- a/Pr/PrMCTools/src/PrTrackerDumper2.cpp +++ b/Pr/PrMCTools/src/PrTrackerDumper2.cpp @@ -111,17 +111,8 @@ namespace { int computeNumberUTHits( const UT::HitHandler& prUTHitHandler ) { - int nbHits = 0; - for ( int iStation = 1; iStation < 3; ++iStation ) { - for ( int iLayer = 1; iLayer < 3; ++iLayer ) { - for ( int iRegion = 1; iRegion < 4; ++iRegion ) { - for ( int iSector = 1; iSector < 99; ++iSector ) { - nbHits += prUTHitHandler.hits( iStation, iLayer, iRegion, iSector ).size(); - } - } - } - } - return nbHits; + return prUTHitHandler.hits().size(); + ; } } // namespace /** @class PrTrackerDumper PrTrackerDumper2.h @@ -413,26 +404,17 @@ void PrTrackerDumper2::operator()( const LHCb::MCParticles& MCParticles, const L // See Pr/PrKernel/UTHit definitions to know the info to store std::map> UTHits_on_MCParticles; std::vector non_Assoc_UTHits; - for ( int iStation = 1; iStation < 3; ++iStation ) { - for ( int iLayer = 1; iLayer < 3; ++iLayer ) { - for ( int iRegion = 1; iRegion < 4; ++iRegion ) { - for ( int iSector = 1; iSector < 99; ++iSector ) { - for ( auto& hit : prUTHitHandler.hits( iStation, iLayer, iRegion, iSector ) ) { - LHCb::LHCbID lhcbid = hit.lhcbID(); - - auto mcparticlesrelations = HitMCParticleLinks.from( lhcbid.lhcbID() ); - if ( mcparticlesrelations.empty() ) { - non_Assoc_UTHits.push_back( hit ); - } else { - - for ( const auto& mcp : mcparticlesrelations ) { - auto MCP = mcp.to(); - //---> weightassociation = mcp.weight(); - UTHits_on_MCParticles[MCP].push_back( hit ); - } - } - } - } + for ( auto& hit : prUTHitHandler.hits() ) { + LHCb::LHCbID lhcbid = hit.lhcbID(); + + auto mcparticlesrelations = HitMCParticleLinks.from( lhcbid.lhcbID() ); + if ( mcparticlesrelations.empty() ) { + non_Assoc_UTHits.push_back( hit ); + } else { + for ( const auto& mcp : mcparticlesrelations ) { + auto MCP = mcp.to(); + //---> weightassociation = mcp.weight(); + UTHits_on_MCParticles[MCP].push_back( hit ); } } } diff --git a/Pr/PrMCTools/src/PrUTHitsChecker.cpp b/Pr/PrMCTools/src/PrUTHitsChecker.cpp index 0f5057cfcde5d3ce3196bd2a2b80dae89dab4b8e..62c79ebbd38f9f111f58f8cbc4ec3fb3c2782661 100644 --- a/Pr/PrMCTools/src/PrUTHitsChecker.cpp +++ b/Pr/PrMCTools/src/PrUTHitsChecker.cpp @@ -140,14 +140,15 @@ private: DECLARE_COMPONENT( PrUTHitsChecker ) -void PrUTHitsChecker::operator()( const UTHits& UThits, const LHCb::LinksByKey& links, const MCHits& mchits, - const MCParticles&, const DeUTDetector& DeUT ) const { +void PrUTHitsChecker::operator()( const UTHits&, const LHCb::LinksByKey& links, const MCHits& mchits, + const MCParticles&, const DeUTDetector& ) const { std::map> mcHitForId; links.applyToAllLinks( [&mcHitForId, &mchits]( unsigned int id, unsigned int mcHitKey, float ) { mcHitForId[id].emplace_back( mchits[mcHitKey] ); } ); +#if 0 // Map for MCHits and keys if ( !m_performStudy ) { const int fullChanIdx = @@ -241,4 +242,5 @@ void PrUTHitsChecker::operator()( const UTHits& UThits, const LHCb::LinksByKey& } // loop indices } // loop over channels } // if performStudy +#endif } diff --git a/Pr/PrVeloUT/src/PrUTMagnetTool.cpp b/Pr/PrVeloUT/src/PrUTMagnetTool.cpp index c5291b5f84620677d43d3f6f367825539cf2e7de..78a6dcbe40efa7e820f64f52ef779457bddd35f2 100644 --- a/Pr/PrVeloUT/src/PrUTMagnetTool.cpp +++ b/Pr/PrVeloUT/src/PrUTMagnetTool.cpp @@ -142,12 +142,14 @@ namespace LHCb::Pr { c.zCenterUT = 2484.6; float zCenterUT = 0.; - assert( utdet.nLayer() == 4 ); + assert( utdet.layerSizeOK() ); unsigned il = 0; utdet.applyToAllLayers( [&il, &zCenterUT, &c]( DeUTLayer const& layer ) { - float zlay = layer.sector( 0 ).globalCentre().Z(); - c.zLayers[il++] = zlay; - zCenterUT += zlay; + if ( ( il < c.zLayers.size() ) ) { + float zlay = layer.sector( 0 ).globalCentre().Z(); + c.zLayers[il++] = zlay; + zCenterUT += zlay; + } } ); zCenterUT /= c.zLayers.size(); diff --git a/Pr/PrVeloUT/src/PrVeloUT.cpp b/Pr/PrVeloUT/src/PrVeloUT.cpp index 2af1094417a21e4a2625505548bb0f42b62dea35..93a1867ace404706ce94d56f9b96f00c08061834 100644 --- a/Pr/PrVeloUT/src/PrVeloUT.cpp +++ b/Pr/PrVeloUT/src/PrVeloUT.cpp @@ -431,11 +431,8 @@ namespace LHCb::Pr { // -- Helper function to calculate the planeCode: 0 - 1 - 2 - 3 // -------------------------------------------------------------------- int planeCode( unsigned int id ) { - const int station = ( (unsigned int)id & static_cast( UTInfo::MasksBits::StationMask ) ) >> - static_cast( UTInfo::MasksBits::StationBits ); - const int layer = ( (unsigned int)id & static_cast( UTInfo::MasksBits::LayerMask ) ) >> - static_cast( UTInfo::MasksBits::LayerBits ); - return 2 * ( station - 1 ) + ( layer - 1 ); + return ( (unsigned int)id & static_cast( UTInfo::MasksBits::HalfLayerMask ) ) >> + static_cast( UTInfo::MasksBits::HalfLayerBits ); } // -------------------------------------------------------------------- @@ -743,11 +740,17 @@ namespace LHCb::Pr { int minLayers ) const { // -- This is for some sanity checks later - constexpr const int maxSectorsPerRegion = static_cast( UTInfo::SectorNumbers::MaxSectorsPerRegion ); - constexpr const int maxLayer = totalUTLayers; - constexpr const int maxRegion = static_cast( UTInfo::DetectorNumbers::Regions ); - [[maybe_unused]] constexpr const int maxSectorNumber = - maxSectorsPerRegion + ( ( maxLayer - 1 ) * maxRegion + ( maxRegion - 1 ) ) * maxSectorsPerRegion; + [[maybe_unused]] constexpr const int maxSectorNumber = 2304; + // With the new UT chID definition the sector number can go up to 2304 given the following equation + // ( ( ( ( ( ( side * static_cast( UTInfo::DetectorNumbers::HalfLayers ) + halflayer ) * + // static_cast( UTInfo::DetectorNumbers::Staves ) ) + + // stave ) * + // static_cast( UTInfo::DetectorNumbers::Faces ) + + // face ) * + // static_cast( UTInfo::DetectorNumbers::Modules ) ) + + // module ) * + // static_cast( UTInfo::DetectorNumbers::SubSectors ) + + // subsector; const simd::float_v tolProto{m_yTol.value()}; @@ -814,7 +817,6 @@ namespace LHCb::Pr { const auto shift = ( temp2.first == temp.second ); const auto lastIndex = shift ? temp2.second : temp.second; j += shift; - findHits( hh, yProto, ty, tx, xOnTrackProto, tolProto, xTol, hitsInLayers, yTol, firstIndex, lastIndex ); } @@ -1207,6 +1209,6 @@ namespace LHCb::Pr { trackIndex2++; } } - } + } // loop on t } } // namespace LHCb::Pr diff --git a/Tr/TrackMonitors/src/UTTrackMonitor.cpp b/Tr/TrackMonitors/src/UTTrackMonitor.cpp index 2bf735df11c400a5a7b2e0a52dec7ddb75b76278..2c72966e1cef51794f8a7547a51f5605e858ad7e 100644 --- a/Tr/TrackMonitors/src/UTTrackMonitor.cpp +++ b/Tr/TrackMonitors/src/UTTrackMonitor.cpp @@ -20,6 +20,7 @@ #include "Map.h" #include "TrackKernel/TrackFunctors.h" #include "TrackMonitorBase.h" +#include "UTDAQ/UTInfo.h" #include "UTDet/DeUTSector.h" #include "LHCbAlgs/Consumer.h" @@ -72,8 +73,16 @@ namespace { unsigned int histoBin( const LHCb::Detector::UT::ChannelID& chan ) { // convert layer and station to a flat number - unsigned int layer = ( chan.station() == 1u ? chan.layer() : ( chan.layer() + 2 ) ); - return layer * 400 + ( chan.detRegion() - 1 ) * 120 + chan.sector(); + unsigned int side = chan.side() + 1u; + return ( ( ( ( ( ( side * static_cast( UTInfo::DetectorNumbers::HalfLayers ) + chan.layer() ) * + static_cast( UTInfo::DetectorNumbers::Staves ) ) + + chan.stave() ) * + static_cast( UTInfo::DetectorNumbers::Faces ) + + chan.face() ) * + static_cast( UTInfo::DetectorNumbers::Modules ) ) + + chan.module() ) * + static_cast( UTInfo::DetectorNumbers::SubSectors ) + + chan.sector(); } } // namespace @@ -99,9 +108,9 @@ void UTTrackMonitor::operator()( LHCb::Track::Range const& tracks, LHCb::UTClust // find the IT hits on the track const auto& ids = track->lhcbIDs(); - std::vector ttHits; - ttHits.reserve( ids.size() ); - std::copy_if( ids.begin(), ids.end(), std::back_inserter( ttHits ), + std::vector utHits; + utHits.reserve( ids.size() ); + std::copy_if( ids.begin(), ids.end(), std::back_inserter( utHits ), []( const LHCb::LHCbID& id ) { return id.isUT(); } ); if ( ids.size() < m_minNumUTHits ) continue; @@ -122,9 +131,7 @@ void UTTrackMonitor::operator()( LHCb::Track::Range const& tracks, LHCb::UTClust } namespace { - size_t ttUniqueSectorID( const LHCb::Detector::UT::ChannelID& id ) { - // std::cout << "tt: " << id.station() << " " << id.layer() << " " << id.detRegion() << " " << id.sector() << - // std::endl ; + size_t utUniqueSectorID( const LHCb::Detector::UT::ChannelID& id ) { return ( id.detRegion() - 1 ) * 24 + id.sector() - 1; } } // namespace @@ -163,7 +170,7 @@ void UTTrackMonitor::fillHistograms( LHCb::Track const& track, UTClusters const& // unbiased residuals and biased residuals Detector::UT::ChannelID chan = lhcbID.utID(); - unsigned int uniquelayer = ( chan.station() - 1 ) * 2 + chan.layer() - 1; + unsigned int uniquelayer = chan.layer(); nodesByUTLayer[uniquelayer].push_back( node ); const std::string layerName = UTNames().UniqueLayerToString( chan ); @@ -256,7 +263,7 @@ void UTTrackMonitor::fillHistograms( LHCb::Track const& track, UTClusters const& -0.5, 0.5, 100 ); // this needs to be fixed: can we somehow can a consecutive ladder ID? - size_t sectorID = ttUniqueSectorID( firstnode->measurement().lhcbID().utID() ); + size_t sectorID = utUniqueSectorID( firstnode->measurement().lhcbID().utID() ); profile1D( double( sectorID ), diff, prefix + "Overlap residual versus sector ID", "Average overlap residual versus sector ID", -0.5, 47.5, 48 ); diff --git a/Tr/TrackTools/src/UTHitExpectation.cpp b/Tr/TrackTools/src/UTHitExpectation.cpp index c066737739b934076c6824f0afeea6290f3d0aa6..6d056bf94f9af6c220f0ff88c4e899098e00f2eb 100644 --- a/Tr/TrackTools/src/UTHitExpectation.cpp +++ b/Tr/TrackTools/src/UTHitExpectation.cpp @@ -142,7 +142,7 @@ StatusCode LHCb::UTHitExpectation::initialize() { if ( utDet.nStation() != 2u ) { throw GaudiException( "2 stations needed in UT", "UTHitExpectation::initialize", StatusCode::FAILURE ); } - return {utDet.station( 0 ).globalCentre().z(), utDet.station( 1 ).globalCentre().z()}; + return {utDet.zStation( 0 ), utDet.zStation( 1 )}; } ); return StatusCode::SUCCESS; } ); @@ -250,8 +250,7 @@ void LHCb::UTHitExpectation::collectHits( std::vector