ATLAS Offline Software
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 
17 #include "CaloGlobalRoIBuilder.h"
18 #include "CxxUtils/phihelper.h"
19 #include "GaudiKernel/StatusCode.h"
25 
26 
27 // Constructor
28 CaloGlobalRoIBuilder::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 
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
49 StatusCode CaloGlobalRoIBuilder::execute(const EventContext& ctx) const
50 {
51  ATH_MSG_DEBUG("in CaloGlobalRoIBuilder::execute()" );
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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:281
xAOD::TrigEMCluster_v1::setEta
void setEta(float)
set Eta (calibrated)
CaloGlobalRoIBuilder::CaloGlobalRoIBuilder
CaloGlobalRoIBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CaloGlobalRoIBuilder.cxx:28
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
RingerReFex.h
CaloGlobalRoIBuilder::m_inputCellsKey
SG::ReadHandleKey< CaloCellContainer > m_inputCellsKey
Definition: CaloGlobalRoIBuilder.h:43
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::TrigEMCluster_v1::setEnergy
void setEnergy(float energy)
set Energy (calibrated)
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
CxxUtils::wrapToPi
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition: phihelper.h:24
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
TrigEMCluster.h
xAOD::TrigEMCluster_v1::setE233
void setE233(float)
set Energy in a 3x3 cluster (no calibration) around hottest cell
skel.it
it
Definition: skel.GENtoEVGEN.py:407
CaloGlobalRoIBuilder::m_noiseCDOKey
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
Definition: CaloGlobalRoIBuilder.h:48
CaloGlobalRoIBuilder::m_samp_thr
Gaudi::Property< float > m_samp_thr
Definition: CaloGlobalRoIBuilder.h:51
CaloGlobalRoIBuilder::m_ringerContainerKey
SG::WriteHandleKey< xAOD::TrigRingerRingsContainer > m_ringerContainerKey
Definition: CaloGlobalRoIBuilder.h:56
CaloGlobalRoIBuilder::m_thr
Gaudi::Property< float > m_thr
Definition: CaloGlobalRoIBuilder.h:49
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CaloNoise::getNoise
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition: CaloNoise.h:34
xAOD::TrigEMCluster_v1::setPhi
void setPhi(float)
set Phi (calibrated)
CaloGlobalRoIBuilder::m_clusterContainerKey
SG::WriteHandleKey< xAOD::TrigEMClusterContainer > m_clusterContainerKey
Definition: CaloGlobalRoIBuilder.h:54
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:274
IBLCalibrationConfig.thr
thr
Definition: IBLCalibrationConfig.py:39
TrigEMClusterAuxContainer.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TrigEMCluster
TrigEMCluster_v1 TrigEMCluster
Define the latest version of the trigger EM cluster class.
Definition: Event/xAOD/xAODTrigCalo/xAODTrigCalo/TrigEMCluster.h:17
CaloGlobalRoIBuilder::m_emAlgTools
ToolHandle< RingerReFex > m_emAlgTools
Definition: CaloGlobalRoIBuilder.h:53
CaloGlobalRoIBuilder::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: CaloGlobalRoIBuilder.cxx:49
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloGlobalRoIBuilder::m_abseta_thr
Gaudi::Property< float > m_abseta_thr
Definition: CaloGlobalRoIBuilder.h:50
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CaloDetDescrElement::is_tile
bool is_tile() const
cell belongs to Tile
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:442
CaloNoise
Definition: CaloNoise.h:16
xAOD::TrigRingerRings
TrigRingerRings_v2 TrigRingerRings
Define the latest version of the TrigRingerRings class.
Definition: TrigRingerRings.h:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
CaloDetDescrElement::identifyHash
IdentifierHash identifyHash() const override final
cell subcalo hash same as subcalo_hash(), but kept for backward compatibility
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:424
CaloGlobalRoIBuilder::initialize
virtual StatusCode initialize() override
Definition: CaloGlobalRoIBuilder.cxx:34
phihelper.h
Helper for azimuthal angle calculations.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TrigEMClusterContainer.h
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
CaloDetDescrElement::getSampling
CaloCell_ID::CaloSample getSampling() const
cell sampling
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:395
xAOD::phiWidth
phiWidth
Definition: RingSetConf_v1.cxx:612
CaloGlobalRoIBuilder.h
xAOD::TrigEMCluster_v1::setEt
void setEt(float)
set Et (calibrated)
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
TrigRoiDescriptor.h
xAOD::TrigEMCluster_v1
Description of a trigger EM cluster.
Definition: TrigEMCluster_v1.h:28
LArCellBinning.etamin
etamin
Definition: LArCellBinning.py:137