Commit be592cbc authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Adapted to changes in Calo code due to DD4hep integration

parent 47829c3a
Pipeline #3099429 passed with stages
in 21 seconds
......@@ -25,7 +25,8 @@ namespace StoreCaloUtils {
class DigitFromCalo {
public:
explicit DigitFromCalo( const int calo ) : m_calo( calo ) {}
explicit DigitFromCalo( const std::string& calo ) : DigitFromCalo( CaloCellCode::CaloNumFromName( calo ) ) {}
explicit DigitFromCalo( const std::string& calo )
: DigitFromCalo( LHCb::Calo::CellCode::CaloNumFromName( calo ) ) {}
inline bool operator()( const LHCb::CaloDigit* digit ) const {
return digit && ( ( (int)digit->cellID().calo() ) == m_calo );
}
......
......@@ -513,8 +513,8 @@ const std::vector<const LHCb::CaloHypo*> BremAdder::getBrem( LHCb::Particle cons
// Reject if the brem candidate is also the electron cluster candidate
const LHCb::CaloPosition* photonPos = photonHypo->position();
if ( NULL != photonPos ) {
const Gaudi::XYZPoint photonPoint( photonPos->x(), photonPos->y(), photonPos->z() );
const LHCb::CaloCellID& photonCell = m_calo->Cell( photonPoint );
const Gaudi::XYZPoint photonPoint( photonPos->x(), photonPos->y(), photonPos->z() );
const LHCb::Calo::CellID& photonCell = m_calo->Cell( photonPoint );
if ( NULL != electronHypo &&
proto->info( LHCb::ProtoParticle::additionalInfo::CaloChargedID, 0 ) == photonCell.all() ) {
debug() << " Electron and Brem candidates are the same calo - nothing to add " << endmsg;
......
......@@ -177,7 +177,7 @@ namespace {
}
/// insert IDs from CaloCellID
template <class PREDICATE>
inline std::size_t insert( _LHCbIDs& ids, const LHCb::CaloCellID& id, PREDICATE good ) {
inline std::size_t insert( _LHCbIDs& ids, const LHCb::Calo::CellID& id, PREDICATE good ) {
return !good( id ) ? 0 : ids.insert( id ).second ? 1 : 0;
}
/// insert IDs from set
......
......@@ -51,7 +51,7 @@ namespace LHCb {
const CaloCluster* cluster() const { return m_cluster; }
double e() const { return cluster()->e(); }
const LHCb::CaloCluster::Position& position() const { return cluster()->position(); }
const LHCb::CaloCellID& seed() const { return cluster()->seed(); }
const LHCb::Calo::CellID& seed() const { return cluster()->seed(); }
private:
const CaloCluster* m_cluster = nullptr;
......
......@@ -1006,7 +1006,7 @@ StatusCode ParticleFlow::treatNeutralHadronsAndIsolatedPhotons( std::vector<LHCb
*/
verbose() << "In treat neutRAL HADRON " << endmsg;
for ( auto iclu = m_PFCaloClusters.begin(); m_PFCaloClusters.end() != iclu; ++iclu ) {
if ( ( *iclu ).second->seed().calo() != CaloCellCode::HcalCalo ) {
if ( ( *iclu ).second->seed().calo() != LHCb::Calo::CellCode::HcalCalo ) {
if ( ( *iclu ).second->status() != LHCb::PFCaloCluster::Available ) continue;
verbose() << "tag aa" << endmsg;
......@@ -1158,8 +1158,9 @@ StatusCode ParticleFlow::treatNeutralRecovery( std::vector<LHCb::PFParticle*>& P
std::vector<LHCb::PFCaloCluster*> SuperClusters;
std::vector<const LHCb::PFParticle*> SuperParticles;
// Check the cluster type
int CaloType = ( ( *i_pfClu ).second->seed().calo() == CaloCellCode::HcalCalo ) ? LHCb::PFParticle::ClustHCAL
: LHCb::PFParticle::ClustECAL;
int CaloType = ( ( *i_pfClu ).second->seed().calo() == LHCb::Calo::CellCode::HcalCalo )
? LHCb::PFParticle::ClustHCAL
: LHCb::PFParticle::ClustECAL;
// To keep track of the iteration, store the iterator at each level of the hierarchy, the last particle of the
// level, and the corresponding cluster
std::vector<std::vector<const LHCb::PFParticle*>> partLists_level;
......@@ -1198,8 +1199,9 @@ StatusCode ParticleFlow::treatNeutralRecovery( std::vector<LHCb::PFParticle*>& P
bool iterated = false;
while ( !iterated ) {
// LEVEL UP If next level calo exists and it has not yet been treated
CaloType = ( originCalo_level[level]->seed().calo() == CaloCellCode::HcalCalo ) ? LHCb::PFParticle::ClustHCAL
: LHCb::PFParticle::ClustECAL;
CaloType = ( originCalo_level[level]->seed().calo() == LHCb::Calo::CellCode::HcalCalo )
? LHCb::PFParticle::ClustHCAL
: LHCb::PFParticle::ClustECAL;
CaloType = ( CaloType - LHCb::PFParticle::ClustECAL + 1 ) % 2 + LHCb::PFParticle::ClustECAL;
if ( partLists_level[level][it]->info( CaloType, -100. ) > -1 &&
m_PFCaloClusters.find( partLists_level[level][it]->info( CaloType, -100. ) ) != m_PFCaloClusters.end() &&
......@@ -1274,7 +1276,7 @@ StatusCode ParticleFlow::createHiddenNeutral( const std::vector<LHCb::PFCaloClus
Barycenter[4] += e * pos.y() / pos.z();
Barycenter[5] += e;
auto nSat = numberOfSaturatedCells( i_c->cluster() );
if ( i_c->seed().calo() == CaloCellCode::HcalCalo )
if ( i_c->seed().calo() == LHCb::Calo::CellCode::HcalCalo )
nSatCellHCAL += nSat;
else
nSatCellECAL += nSat;
......@@ -1495,7 +1497,7 @@ ParticleFlow::checkClustersForNeutralRecovery( LHCb::PFParticle&
}
int ParticleFlow::numberOfSaturatedCells( const LHCb::CaloCluster* cluster ) {
const DeCalorimeter* calo = ( cluster->seed().calo() == CaloCellCode::HcalCalo ? m_hcal : m_ecal );
const DeCalorimeter* calo = ( cluster->seed().calo() == LHCb::Calo::CellCode::HcalCalo ? m_hcal : m_ecal );
const auto& entries = cluster->entries();
return std::count_if( begin( entries ), end( entries ), [calo]( const auto& entry ) {
const LHCb::CaloDigit* digit = entry.digit();
......
......@@ -27,6 +27,7 @@
#include "CaloDet/DeCalorimeter.h"
#include "CaloUtils/Calo2Track.h"
#include "CaloUtils/CaloAlgUtils.h"
#include "DetDesc/IDetectorElement.h"
#include "Event/CaloCluster.h"
#include "Event/CaloDigit.h"
#include "Event/CaloHypo.h"
......@@ -1215,13 +1216,13 @@ LHCb::Particle* ParticleFlow4Jets::MakeNeuralParticle( int clusterID, int calo,
double x( 0. ), y( 0. ), z( 0. );
if ( calo == 0 ) {
LHCb::CaloCellID cellID;
LHCb::Calo::CellID cellID;
cellID.setAll( clusterID );
x = m_ecal->cellX( cellID );
y = m_ecal->cellY( cellID );
z = m_ecal->cellZ( cellID );
} else {
LHCb::CaloCellID cellID;
LHCb::Calo::CellID cellID;
cellID.setAll( clusterID );
x = m_hcal->cellX( cellID );
y = m_hcal->cellY( cellID );
......
......@@ -598,10 +598,10 @@ namespace {
Decays::IDecay::Tree m_tree;
LoKi::Dicts::FinderDicts_<const LHCb::Particle*> m_finderDicts;
// =======================================================================
LHCb::CaloDigit::Vector m_calo_1;
LHCb::CaloDigit::Set m_calo_2;
LHCb::CaloCellID::Vector m_calo_3;
LHCb::CaloCellID::Set m_calo_4;
LHCb::CaloDigit::Vector m_calo_1;
LHCb::CaloDigit::Set m_calo_2;
std::vector<LHCb::Calo::CellID> m_calo_3;
std::set<LHCb::Calo::CellID> m_calo_4;
// =======================================================================
};
// ==========================================================================
......
......@@ -96,14 +96,14 @@ namespace LoKi {
* @param gamma (INPUT) the particle
* @returh seed cell
* @see LHCb::Particle
* @see LHCb::CaloCellID
* @see LHCb::Calo::CellID
* @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
* @date 2009-11-28
*/
inline LHCb::CaloCellID cellID( const LHCb::Particle* gamma ) {
if ( 0 == gamma ) { return LHCb::CaloCellID(); } // RETURN
inline LHCb::Calo::CellID cellID( const LHCb::Particle* gamma ) {
if ( 0 == gamma ) { return LHCb::Calo::CellID(); } // RETURN
const LHCb::CaloCluster* cl = cluster( gamma );
if ( 0 == cl ) { return LHCb::CaloCellID(); } // RETURN
if ( 0 == cl ) { return LHCb::Calo::CellID(); } // RETURN
return cl->seed();
}
// ========================================================================
......
......@@ -166,7 +166,7 @@ unsigned int LoKi::Photons::getDigits( const LHCb::Particle* gamma, LHCb::CaloDi
*/
// ============================================================================
double LoKi::Photons::energyFrom( const LHCb::Particle* gamma, const std::string& calo ) {
LHCb::CaloDataFunctor::DigitFromCalo detector( CaloCellCode::CaloNumFromName( calo ) );
LHCb::CaloDataFunctor::DigitFromCalo detector( LHCb::Calo::CellCode::CaloNumFromName( calo ) );
return energyFrom( gamma, detector );
}
// ============================================================================
......@@ -180,7 +180,7 @@ double LoKi::Photons::energyFrom( const LHCb::Particle* gamma, const std::string
*/
// ============================================================================
double LoKi::Photons::seedEnergyFrom( const LHCb::Particle* gamma, const std::string& calo ) {
LHCb::CaloDataFunctor::DigitFromCalo detector( CaloCellCode::CaloNumFromName( calo ) );
LHCb::CaloDataFunctor::DigitFromCalo detector( LHCb::Calo::CellCode::CaloNumFromName( calo ) );
return seedEnergyFrom( gamma, detector );
}
// ============================================================================
......
......@@ -197,11 +197,11 @@ StatusCode MergedPi0Maker::makeParticles( LHCb::Particle::Vector& particles ) {
}
const Gaudi::XYZPoint point( hypoPos->x(), hypoPos->y(), hypoPos->z() );
LHCb::CaloCellID cellID = m_calo->Cell( point );
double CellSize = m_calo->cellSize( cellID );
double zpos = m_calo->cellZ( cellID );
double epi0 = pi0Momentum.e();
double dmin = ( epi0 * CellSize > 0 ) ? zpos * 2. * m_Mass / epi0 / CellSize
LHCb::Calo::CellID cellID = m_calo->Cell( point );
double CellSize = m_calo->cellSize( cellID );
double zpos = m_calo->cellZ( cellID );
double epi0 = pi0Momentum.e();
double dmin = ( epi0 * CellSize > 0 ) ? zpos * 2. * m_Mass / epi0 / CellSize
: +9999.; // rare FPE ( hypo outside Calo acceptance ?)
if ( m_ggDistCut < dmin ) { continue; }
......
......@@ -587,11 +587,11 @@ namespace LHCb::Phys::ParticleMakers {
if ( !hypoPos ) ++m_null_caloposition;
const Gaudi::XYZPoint hypoPoint( hypoPos->x(), hypoPos->y(), hypoPos->z() );
LHCb::CaloCellID cellID = DECalo.Cell( hypoPoint );
double CellSize = DECalo.cellSize( cellID );
double zpos = DECalo.cellZ( cellID );
double epi0 = pi0Momentum.e();
double dmin = ( epi0 * CellSize > 0 ) ? zpos * 2. * m_partProp->mass() / epi0 / CellSize
LHCb::Calo::CellID cellID = DECalo.Cell( hypoPoint );
double CellSize = DECalo.cellSize( cellID );
double zpos = DECalo.cellZ( cellID );
double epi0 = pi0Momentum.e();
double dmin = ( epi0 * CellSize > 0 ) ? zpos * 2. * m_partProp->mass() / epi0 / CellSize
: +9999.; // rare FPE ( hypo outside Calo acceptance ?)
if ( m_ggDistCut < dmin ) return {};
......
......@@ -84,9 +84,11 @@ std::vector<LHCb::LHCbID> ParticleTisTos::projectTrack( const Track& track ) {
if ( track.closestState( m_hcalDeCal->plane( CaloPlane::ShowerMax ) ).z() > 5000.0 ) {
if ( m_track2calo->match( &track, geometry, DeCalorimeterLocation::Hcal ) ) {
if ( m_track2calo->isValid() ) { // is matched cellid valid
const LHCb::CaloCellID centerCell = m_track2calo->caloCellID();
const LHCb::Calo::CellID centerCell = m_track2calo->caloCellID();
cells3x3.push_back( centerCell );
for ( LHCb::CaloCellID cell : m_hcalDeCal->neighborCells( centerCell ) ) { cells3x3.push_back( cell ); };
for ( LHCb::Calo::CellID cell : m_hcalDeCal->neighborCells( centerCell ) ) {
cells3x3.push_back( cell );
};
}
}
}
......@@ -105,9 +107,11 @@ std::vector<LHCb::LHCbID> ParticleTisTos::projectTrack( const Track& track ) {
if ( track.closestState( m_ecalDeCal->plane( CaloPlane::ShowerMax ) ).z() > 5000.0 ) {
if ( m_track2calo->match( &track, geometry, DeCalorimeterLocation::Ecal ) ) { // play with 3rd parameter?
if ( m_track2calo->isValid() ) { // is matched cellid valid
const LHCb::CaloCellID centerCell = m_track2calo->caloCellID();
const LHCb::Calo::CellID centerCell = m_track2calo->caloCellID();
cells3x3.push_back( centerCell );
for ( LHCb::CaloCellID cell : m_ecalDeCal->neighborCells( centerCell ) ) { cells3x3.push_back( cell ); };
for ( LHCb::Calo::CellID cell : m_ecalDeCal->neighborCells( centerCell ) ) {
cells3x3.push_back( cell );
};
}
}
}
......@@ -139,31 +143,28 @@ std::vector<LHCb::LHCbID> ParticleTisTos::protoParticleHits( const ProtoParticle
if ( msgLevel( MSG::VERBOSE ) ) verbose() << " protoParticleHits ECAL VIA CaloHypo " << endmsg;
// new Apr 6, 2012: collect calo cell IDs from ProtoParticle::ExtraInfo if available
LHCb::CaloCellID caloCell( LHCb::CaloCellID::ContentType( 0 ) );
bool caloOK( false );
LHCb::Calo::CellID caloCell( (unsigned int)0 );
bool caloOK( false );
if ( 0 != onit ) {
caloOK = true; // don't care about calo info for charged if not found (we also project tracks!)
if ( m_caloClustForCharged )
caloCell = LHCb::CaloCellID(
LHCb::CaloCellID::ContentType( pp.info( LHCb::ProtoParticle::additionalInfo::CaloChargedID, 0 ) ) );
caloCell = LHCb::Calo::CellID( (unsigned int)pp.info( LHCb::ProtoParticle::additionalInfo::CaloChargedID, 0 ) );
// deb info() << " charged " << caloCell.all() << endmsg;
} else {
if ( m_caloClustForNeutral ) {
caloCell = LHCb::CaloCellID(
LHCb::CaloCellID::ContentType( pp.info( LHCb::ProtoParticle::additionalInfo::CaloNeutralID, 0 ) ) );
caloCell = LHCb::Calo::CellID( (unsigned int)pp.info( LHCb::ProtoParticle::additionalInfo::CaloNeutralID, 0 ) );
// deb info() << " neutral " << caloCell.all() << endmsg;
} else {
caloOK = true; // don't want calo info for neutrals
}
}
// deb caloCell = LHCb::CaloCellID( LHCb::CaloCellID::ContentType(0) );
if ( caloCell.all() != 0 ) {
caloOK = true;
hits.push_back( caloCell );
if ( extend ) {
if ( m_ecalDeCal == 0 ) { m_ecalDeCal = getDet<DeCalorimeter>( DeCalorimeterLocation::Ecal ); }
for ( LHCb::CaloCellID cell : m_ecalDeCal->neighborCells( caloCell ) ) { hits.push_back( cell ); }
for ( LHCb::Calo::CellID cell : m_ecalDeCal->neighborCells( caloCell ) ) { hits.push_back( cell ); }
}
// ExtraInfo failed: dig into CaloHypo and Clusters only in case of neutrals when requsted
} else if ( 0 == onit && m_caloClustForNeutral ) {
......@@ -177,7 +178,7 @@ std::vector<LHCb::LHCbID> ParticleTisTos::protoParticleHits( const ProtoParticle
// deb info() << " inside hypo" << endmsg;
if ( hypo->clusters().size() > 0 ) {
// deb info() << " inside hypo passed clusters " << endmsg;
LHCb::CaloCellID centerCell, centerCell1, dummyCell;
LHCb::Calo::CellID centerCell, centerCell1, dummyCell;
// next if always false: left in for historical reasons
if ( 0 != onit && m_caloClustForCharged ) {
if ( LHCb::CaloHypo::Hypothesis::EmCharged == hypo->hypothesis() ) {
......@@ -226,13 +227,13 @@ std::vector<LHCb::LHCbID> ParticleTisTos::protoParticleHits( const ProtoParticle
hits.push_back( centerCell );
if ( extend ) {
if ( m_ecalDeCal == 0 ) { m_ecalDeCal = getDet<DeCalorimeter>( DeCalorimeterLocation::Ecal ); }
for ( LHCb::CaloCellID cell : m_ecalDeCal->neighborCells( centerCell ) ) { hits.push_back( cell ); }
for ( LHCb::Calo::CellID cell : m_ecalDeCal->neighborCells( centerCell ) ) { hits.push_back( cell ); }
}
if ( !( centerCell1 == dummyCell ) ) {
hits.push_back( centerCell1 );
if ( extend ) {
if ( m_ecalDeCal == 0 ) { m_ecalDeCal = getDet<DeCalorimeter>( DeCalorimeterLocation::Ecal ); }
for ( LHCb::CaloCellID cell : m_ecalDeCal->neighborCells( centerCell ) ) { hits.push_back( cell ); }
for ( LHCb::Calo::CellID cell : m_ecalDeCal->neighborCells( centerCell ) ) { hits.push_back( cell ); }
}
}
}
......
......@@ -137,9 +137,9 @@ unsigned int TisTos::hitMatchType( const LHCbID& id ) {
} else if ( id.isMuon() ) {
return kMuon;
} else if ( id.isCalo() ) {
if ( id.caloID().calo() == CaloCellCode::CaloIndex::HcalCalo ) {
if ( id.caloID().calo() == LHCb::Calo::CellCode::Index::HcalCalo ) {
return kHcal;
} else if ( id.caloID().calo() == CaloCellCode::CaloIndex::EcalCalo ) {
} else if ( id.caloID().calo() == LHCb::Calo::CellCode::Index::EcalCalo ) {
return kEcal;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment