Skip to content
Snippets Groups Projects

Draft: DO NOT MERGE Fixing the FT in DD4HEP

Closed Louis Henry requested to merge lohenry-NOTTOMERGE-fixDD4HEP into master
1 unresolved thread
12 files
+ 262
152
Compare changes
  • Side-by-side
  • Inline
Files
12
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "Detector/FT/FTChannelID.h"
#include "Event/FTLiteCluster.h"
@@ -45,27 +45,27 @@ namespace LHCb::Pr::FT {
}();
class StoreHits : public Algorithm::Transformer<Hits( const EventContext&, const FTLiteClusters&, const MatsCache& ),
Algorithm::Traits::usesConditions<MatsCache>> {
Algorithm::Traits::usesConditions<MatsCache>> {
public:
StoreHits( const std::string& name, ISvcLocator* pSvcLocator )
: Transformer( name, pSvcLocator,
{KeyValue{"HitsLocation", LHCb::FTLiteClusterLocation::Default},
: Transformer( name, pSvcLocator,
{KeyValue{"HitsLocation", LHCb::FTLiteClusterLocation::Default},
#ifdef USE_DD4HEP
KeyValue {
"FTMatsCache",
KeyValue {
"FTMatsCache",
"/world:AlgorithmSpecific-" + name + "-FTMatsCache"
}
}
#else
KeyValue{"FTMatsCache", "AlgorithmSpecific-" + name + "-FTMatsCache"}
KeyValue{"FTMatsCache", "AlgorithmSpecific-" + name + "-FTMatsCache"}
#endif
},
KeyValue{"Output", PrFTInfo::SciFiHitsLocation} ) {
},
KeyValue{"Output", PrFTInfo::SciFiHitsLocation} ) {
}
StatusCode initialize() override {
return Transformer::initialize().andThen( [&] {
addConditionDerivation<MatsCache( const DeFT& )>( {DeFTDetectorLocation::Default}, inputLocation<MatsCache>() );
} );
addConditionDerivation<MatsCache( const DeFT& )>( {DeFTDetectorLocation::Default}, inputLocation<MatsCache>() );
} );
}
Hits operator()( const EventContext&, const FTLiteClusters&, const MatsCache& ) const override;
@@ -74,17 +74,17 @@ namespace LHCb::Pr::FT {
// Counters
using SC = Gaudi::Accumulators::StatCounter<>;
using SCbuf =
Gaudi::Accumulators::Buffer<Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::atomicity::full, double>;
Gaudi::Accumulators::Buffer<Gaudi::Accumulators::StatAccumulator, Gaudi::Accumulators::atomicity::full, double>;
mutable SC m_cntTotalHits{this, "Total number of hits"};
mutable std::array<SC, 3 * 4> m_cntHitsPerLayer{
SC{this, "Hits in T1X1"}, SC{this, "Hits in T1U"}, SC{this, "Hits in T1V"}, SC{this, "Hits in T1X2"},
SC{this, "Hits in T2X1"}, SC{this, "Hits in T2U"}, SC{this, "Hits in T2V"}, SC{this, "Hits in T2X2"},
SC{this, "Hits in T3X1"}, SC{this, "Hits in T3U"}, SC{this, "Hits in T3V"}, SC{this, "Hits in T3X2"}};
SC{this, "Hits in T1X1"}, SC{this, "Hits in T1U"}, SC{this, "Hits in T1V"}, SC{this, "Hits in T1X2"},
SC{this, "Hits in T2X1"}, SC{this, "Hits in T2U"}, SC{this, "Hits in T2V"}, SC{this, "Hits in T2X2"},
SC{this, "Hits in T3X1"}, SC{this, "Hits in T3U"}, SC{this, "Hits in T3V"}, SC{this, "Hits in T3X2"}};
mutable std::array<SC, 3 * 4> m_cntXPerLayer{
SC{this, "Average X in T1X1"}, SC{this, "Average X in T1U"}, SC{this, "Average X in T1V"},
SC{this, "Average X in T1X2"}, SC{this, "Average X in T2X1"}, SC{this, "Average X in T2U"},
SC{this, "Average X in T2V"}, SC{this, "Average X in T2X2"}, SC{this, "Average X in T3X1"},
SC{this, "Average X in T3U"}, SC{this, "Average X in T3V"}, SC{this, "Average X in T3X2"}};
SC{this, "Average X in T1X1"}, SC{this, "Average X in T1U"}, SC{this, "Average X in T1V"},
SC{this, "Average X in T1X2"}, SC{this, "Average X in T2X1"}, SC{this, "Average X in T2U"},
SC{this, "Average X in T2V"}, SC{this, "Average X in T2X2"}, SC{this, "Average X in T3X1"},
SC{this, "Average X in T3U"}, SC{this, "Average X in T3V"}, SC{this, "Average X in T3X2"}};
};
DECLARE_COMPONENT_WITH_ID( StoreHits, "PrStoreSciFiHits" )
@@ -103,20 +103,20 @@ namespace LHCb::Pr::FT {
// hits are stored in the same order as the layers are in z, i.e. x-u-v-x
// hit zone order here: 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23
constexpr auto hitzones = std::array<int, PrFTInfo::NFTZones>{
xd[0], uvd[0], uvd[1], xd[1], xd[2], uvd[2], uvd[3], xd[3], xd[4], uvd[4], uvd[5], xd[5],
xu[0], uvu[0], uvu[1], xu[1], xu[2], uvu[2], uvu[3], xu[3], xu[4], uvu[4], uvu[5], xu[5]};
xd[0], uvd[0], uvd[1], xd[1], xd[2], uvd[2], uvd[3], xd[3], xd[4], uvd[4], uvd[5], xd[5],
xu[0], uvu[0], uvu[1], xu[1], xu[2], uvu[2], uvu[3], xu[3], xu[4], uvu[4], uvu[5], xu[5]};
auto bufTotalHits = m_cntTotalHits.buffer();
std::array<SCbuf, 3 * 4> bufHitsPerLayer = {
m_cntHitsPerLayer[0].buffer(), m_cntHitsPerLayer[1].buffer(), m_cntHitsPerLayer[2].buffer(),
m_cntHitsPerLayer[3].buffer(), m_cntHitsPerLayer[4].buffer(), m_cntHitsPerLayer[5].buffer(),
m_cntHitsPerLayer[6].buffer(), m_cntHitsPerLayer[7].buffer(), m_cntHitsPerLayer[8].buffer(),
m_cntHitsPerLayer[9].buffer(), m_cntHitsPerLayer[10].buffer(), m_cntHitsPerLayer[11].buffer()};
m_cntHitsPerLayer[0].buffer(), m_cntHitsPerLayer[1].buffer(), m_cntHitsPerLayer[2].buffer(),
m_cntHitsPerLayer[3].buffer(), m_cntHitsPerLayer[4].buffer(), m_cntHitsPerLayer[5].buffer(),
m_cntHitsPerLayer[6].buffer(), m_cntHitsPerLayer[7].buffer(), m_cntHitsPerLayer[8].buffer(),
m_cntHitsPerLayer[9].buffer(), m_cntHitsPerLayer[10].buffer(), m_cntHitsPerLayer[11].buffer()};
std::array<SCbuf, 3 * 4> bufXPerLayer = {
m_cntXPerLayer[0].buffer(), m_cntXPerLayer[1].buffer(), m_cntXPerLayer[2].buffer(),
m_cntXPerLayer[3].buffer(), m_cntXPerLayer[4].buffer(), m_cntXPerLayer[5].buffer(),
m_cntXPerLayer[6].buffer(), m_cntXPerLayer[7].buffer(), m_cntXPerLayer[8].buffer(),
m_cntXPerLayer[9].buffer(), m_cntXPerLayer[10].buffer(), m_cntXPerLayer[11].buffer()};
m_cntXPerLayer[0].buffer(), m_cntXPerLayer[1].buffer(), m_cntXPerLayer[2].buffer(),
m_cntXPerLayer[3].buffer(), m_cntXPerLayer[4].buffer(), m_cntXPerLayer[5].buffer(),
m_cntXPerLayer[6].buffer(), m_cntXPerLayer[7].buffer(), m_cntXPerLayer[8].buffer(),
m_cntXPerLayer[9].buffer(), m_cntXPerLayer[10].buffer(), m_cntXPerLayer[11].buffer()};
bufTotalHits += clusters.size();
for ( auto i : hitzones ) {
@@ -125,29 +125,37 @@ namespace LHCb::Pr::FT {
for ( auto quarter{0}; quarter < 2; ++quarter ) {
const auto iQuarter = bit_cast<unsigned>( i * 2 + quarter );
const auto info =
static_cast<uint8_t>( ( iQuarter >> 1 ) | ( ( ( iQuarter << 4 ) ^ ( iQuarter << 5 ) ^ 128u ) & 128u ) );
const auto qinfo =
static_cast<uint8_t>( ( iQuarter >> 1 ) | ( ( ( iQuarter << 4 ) ^ ( iQuarter << 5 ) ^ 128u ) & 128u ) );
bufHitsPerLayer[iQuarter / 4] += clusters.range( iQuarter ).size();
for ( const auto& clus : clusters.range( iQuarter ) ) {
const auto id = clus.channelID();
const auto qindx = iQuarter / 4;
const auto id = clus.channelID();
const auto hfChPitch = ( 2 * id.channel() + 1 + clus.fractionBit() ) * cache.halfChannelPitch;
const auto dieGap = id.die() * cache.dieGap;
const auto sipmPitch = id.sipm() * cache.sipmPitch;
const auto uFromChannel = cache.uBegin + hfChPitch + dieGap + sipmPitch;
const auto index = id.globalMatID();
const auto endPoint = cache.mirrorPoint[index] + cache.ddx[index] * uFromChannel;
const auto index = id.globalMatID();
assert( index < cache.mirrorPoint.size() );
assert( index < cache.ddx.size() );
auto endPoint = cache.mirrorPoint[index] + cache.ddx[index] * uFromChannel;
const auto dxdy = cache.dxdy[index];
const auto dzdy = cache.dzdy[index];
auto yMin = endPoint.y();
const auto x0 = endPoint.x() - dxdy * yMin;
bufXPerLayer[iQuarter / 4] += x0;
const auto z0 = endPoint.z() - dzdy * yMin;
auto yMax = yMin + cache.globaldy[index];
if ( id.isBottom() ) std::swap( yMin, yMax );
if ( id.isBottom() ) { std::swap( yMin, yMax ); }
bufXPerLayer[qindx] += x0;
assert( clus.pseudoSize() < 9 && "Pseudosize of cluster is > 8. Out of range." );
hits.appendColumn( ( info & 63u ) >> 1, x0, {invClusRes2[clus.pseudoSize()], dzdy, dxdy, z0},
hits.appendColumn( ( qinfo & 63u ) >> 1, x0, {invClusRes2[clus.pseudoSize()], dzdy, dxdy, z0},
{id, yMin, yMax} );
}
}
Loading