ATLAS Offline Software
Loading...
Searching...
No Matches
CaloGlobalRoIBuilder.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4
5// ********************************************************************
6//
7// NAME: CaloGlobalRoIBuilder.cxx
8// PACKAGE: Trigger/TrigAlgorithms/TrigCaloRec
9//
10// AUTHOR: D.O. Damazio
11// Algorithm to prepare RoIs based on the presence of cells
12// above some noise threshold
13//
14// ********************************************************************
15//
16
18#include "CxxUtils/phihelper.h"
19#include "GaudiKernel/StatusCode.h"
25
26
27// Constructor
28CaloGlobalRoIBuilder::CaloGlobalRoIBuilder(const std::string& name, ISvcLocator* pSvcLocator)
29 : AthReentrantAlgorithm(name, pSvcLocator)
30{
31};
32
33// Initialize
35{
36 ATH_MSG_DEBUG("in CaloGlobalRoIBuilder::initialize()" );
37
38 ATH_CHECK( m_inputCellsKey.initialize() );
39 ATH_CHECK( m_noiseCDOKey.initialize() );
40 ATH_CHECK(m_clusterContainerKey.initialize());
41 ATH_CHECK( m_ringerContainerKey.initialize() );
42 m_emAlgTools.retrieve().ignore();
43
44 return StatusCode::SUCCESS;
45
46}
47
48// Initialize
49StatusCode CaloGlobalRoIBuilder::execute(const EventContext& ctx) const
50{
51 ATH_MSG_DEBUG("in CaloGlobalRoIBuilder::execute()" );
52 auto cells = SG::makeHandle(m_inputCellsKey, ctx);
54 const CaloNoise *noisep = *noiseHdl;
55 ATH_MSG_VERBOSE(" Input Cells : " << cells.name() <<" of size " <<cells->size() );
57 ATH_CHECK( trigEmClusterCollection.record(std::make_unique<xAOD::TrigEMClusterContainer>(),
58 std::make_unique<xAOD::TrigEMClusterAuxContainer>()) );
59
62
63 ATH_CHECK( ringsCollection.record( std::make_unique<xAOD::TrigRingerRingsContainer>(),
64 std::make_unique<xAOD::TrigRingerRingsAuxContainer>() ) );
65
66 unsigned int clustern=0; // for linking
67 for (const auto cell : *cells ) {
68 const CaloDetDescrElement* cdde = cell->caloDDE();
69 if ( fabsf(cdde->eta()) > m_abseta_thr ) continue;
70 if ( cdde->getSampling() > m_samp_thr ) continue;
71 if (cdde->is_tile() ) continue;
72 float thr=noisep->getNoise(cdde->identifyHash(), cell->gain());
73 if ( cell->energy() > m_thr*thr ){
74 // For each hot cell, let's make ringers
75 xAOD::TrigEMCluster *ptrigEmCluster = new xAOD::TrigEMCluster();
76 trigEmClusterCollection->push_back(ptrigEmCluster);
77 ptrigEmCluster->setEnergy(cell->energy());
78 ptrigEmCluster->setEnergy(cdde->getSampling(),cell->energy());
79 ptrigEmCluster->setEt(cell->pt());
80 ptrigEmCluster->setEta(cell->eta());
81 ptrigEmCluster->setPhi(cell->phi());
82 ptrigEmCluster->setE233(thr);
83 double etaWidth(0.2);
84 double phiWidth(0.2);
85 double etamin = std::max(-2.5, cell->eta() - etaWidth);
86 double etamax = std::min(2.5, static_cast<double>(cell->eta() + etaWidth));
87 double phimin = CxxUtils::wrapToPi(cell->phi() - phiWidth);
88 double phimax = CxxUtils::wrapToPi(static_cast<double>(cell->phi() + phiWidth));
89 const TrigRoiDescriptor newroi(cell->eta(),etamin,etamax,cell->phi(),phimin,phimax);
90 // use tool only to build rings
91 std::vector<RingerReFex::RingSet> vec_rs;
92 ATH_CHECK(m_emAlgTools->prepareRinger(vec_rs,*ptrigEmCluster,newroi,ctx));
93 std::vector<float> ref_rings;
94 for (std::vector<RingerReFex::RingSet>::iterator it=vec_rs.begin(); it!=vec_rs.end(); ++it)
95 {
96 auto rings = it->rings();
97 ref_rings.insert(ref_rings.end(), rings.begin(), rings.end());
98 }
99 auto ptrigRingerRings= new xAOD::TrigRingerRings();
100 ringsCollection->push_back( ptrigRingerRings );
101 ptrigRingerRings->setRings(ref_rings);
102 auto clusLink = ElementLink<xAOD::TrigEMClusterContainer>(m_clusterContainerKey.key(),clustern++,ctx);
103 ptrigRingerRings->setEmClusterLink( clusLink );
104
105 }
106 }
107
108 return StatusCode::SUCCESS;
109}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
This class groups all DetDescr information related to a CaloCell.
IdentifierHash identifyHash() const override final
cell subcalo hash same as subcalo_hash(), but kept for backward compatibility
CaloCell_ID::CaloSample getSampling() const
cell sampling
Gaudi::Property< float > m_samp_thr
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
virtual StatusCode initialize() override
ToolHandle< RingerReFex > m_emAlgTools
SG::WriteHandleKey< xAOD::TrigEMClusterContainer > m_clusterContainerKey
Gaudi::Property< float > m_abseta_thr
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< xAOD::TrigRingerRingsContainer > m_ringerContainerKey
Gaudi::Property< float > m_thr
SG::ReadHandleKey< CaloCellContainer > m_inputCellsKey
CaloGlobalRoIBuilder(const std::string &name, ISvcLocator *pSvcLocator)
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition CaloNoise.h:34
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
void setPhi(float)
set Phi (calibrated)
void setEta(float)
set Eta (calibrated)
void setEt(float)
set Et (calibrated)
void setEnergy(float energy)
set Energy (calibrated)
void setE233(float)
set Energy in a 3x3 cluster (no calibration) around hottest cell
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition phihelper.h:24
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
TrigRingerRings_v2 TrigRingerRings
Define the latest version of the TrigRingerRings class.
TrigEMCluster_v1 TrigEMCluster
Define the latest version of the trigger EM cluster class.
Helper for azimuthal angle calculations.