ATLAS Offline Software
CaloGlobalRoIBuilder.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2023 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"
19 #include "GaudiKernel/StatusCode.h"
20 #include "CxxUtils/phihelper.h"
24 
25 // Constructor
26 CaloGlobalRoIBuilder::CaloGlobalRoIBuilder(const std::string& name, ISvcLocator* pSvcLocator)
27  : AthReentrantAlgorithm(name, pSvcLocator)
28 {
29 };
30 
31 // Initialize
33 {
34  ATH_MSG_DEBUG("in CaloGlobalRoIBuilder::initialize()" );
35 
38  ATH_CHECK(m_clusterContainerKey.initialize());
39  ATH_CHECK( m_ringerContainerKey.initialize() );
40  m_emAlgTools.retrieve().ignore();
41 
42  return StatusCode::SUCCESS;
43 
44 }
45 
46 // Initialize
47 StatusCode CaloGlobalRoIBuilder::execute(const EventContext& ctx) const
48 {
49  ATH_MSG_DEBUG("in CaloGlobalRoIBuilder::execute()" );
52  const CaloNoise *noisep = *noiseHdl;
53  ATH_MSG_VERBOSE(" Input Cells : " << cells.name() <<" of size " <<cells->size() );
55  ATH_CHECK( trigEmClusterCollection.record(std::make_unique<xAOD::TrigEMClusterContainer>(),
56  std::make_unique<xAOD::TrigEMClusterAuxContainer>()) );
57 
60 
61  ATH_CHECK( ringsCollection.record( std::make_unique<xAOD::TrigRingerRingsContainer>(),
62  std::make_unique<xAOD::TrigRingerRingsAuxContainer>() ) );
63 
64  unsigned int clustern=0; // for linking
65  for (const auto cell : *cells ) {
66  const CaloDetDescrElement* cdde = cell->caloDDE();
67  if ( fabsf(cdde->eta()) > m_abseta_thr ) continue;
68  if ( cdde->getSampling() > m_samp_thr ) continue;
69  if (cdde->is_tile() ) continue;
70  float thr=noisep->getNoise(cdde->identifyHash(), cell->gain());
71  if ( cell->energy() > m_thr*thr ){
72  // For each hot cell, let's make ringers
73  xAOD::TrigEMCluster *ptrigEmCluster = new xAOD::TrigEMCluster();
74  trigEmClusterCollection->push_back(ptrigEmCluster);
75  ptrigEmCluster->setEnergy(cell->energy());
76  ptrigEmCluster->setEnergy(cdde->getSampling(),cell->energy());
77  ptrigEmCluster->setEt(cell->pt());
78  ptrigEmCluster->setEta(cell->eta());
79  ptrigEmCluster->setPhi(cell->phi());
80  double etaWidth(0.2);
81  double phiWidth(0.2);
82  double etamin = std::max(-2.5, cell->eta() - etaWidth);
83  double etamax = std::min(2.5, static_cast<double>(cell->eta() + etaWidth));
84  double phimin = CxxUtils::wrapToPi(cell->phi() - phiWidth);
85  double phimax = CxxUtils::wrapToPi(static_cast<double>(cell->phi() + phiWidth));
86  const TrigRoiDescriptor newroi(cell->eta(),etamin,etamax,cell->phi(),phimin,phimax);
87  // use tool only to build rings
88  std::vector<RingerReFex::RingSet> vec_rs;
89  ATH_CHECK(m_emAlgTools->prepareRinger(vec_rs,*ptrigEmCluster,newroi,ctx));
90  std::vector<float> ref_rings;
91  for (std::vector<RingerReFex::RingSet>::iterator it=vec_rs.begin(); it!=vec_rs.end(); ++it)
92  {
93  auto rings = it->rings();
94  ref_rings.insert(ref_rings.end(), rings.begin(), rings.end());
95  }
96  auto ptrigRingerRings= new xAOD::TrigRingerRings();
97  ringsCollection->push_back( ptrigRingerRings );
98  ptrigRingerRings->setRings(ref_rings);
99  auto clusLink = ElementLink<xAOD::TrigEMClusterContainer>(m_clusterContainerKey.key(),clustern++,ctx);
100  ptrigRingerRings->setEmClusterLink( clusLink );
101 
102  }
103  }
104 
105  return StatusCode::SUCCESS;
106 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
xAOD::TrigEMCluster_v1::setEta
void setEta(float)
set Eta (calibrated)
CaloGlobalRoIBuilder::CaloGlobalRoIBuilder
CaloGlobalRoIBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Definition: CaloGlobalRoIBuilder.cxx:26
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
max
#define max(a, b)
Definition: cfImp.cxx:41
RingerReFex.h
CaloGlobalRoIBuilder::m_inputCellsKey
SG::ReadHandleKey< CaloCellContainer > m_inputCellsKey
Definition: CaloGlobalRoIBuilder.h:50
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::TrigEMCluster_v1::setEnergy
void setEnergy(float energy)
set Energy (calibrated)
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
skel.it
it
Definition: skel.GENtoEVGEN.py:396
CaloGlobalRoIBuilder::m_noiseCDOKey
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
Definition: CaloGlobalRoIBuilder.h:55
CaloGlobalRoIBuilder::m_samp_thr
Gaudi::Property< float > m_samp_thr
Definition: CaloGlobalRoIBuilder.h:58
CaloGlobalRoIBuilder::m_ringerContainerKey
SG::WriteHandleKey< xAOD::TrigRingerRingsContainer > m_ringerContainerKey
Definition: CaloGlobalRoIBuilder.h:63
CaloGlobalRoIBuilder::m_thr
Gaudi::Property< float > m_thr
Definition: CaloGlobalRoIBuilder.h:56
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:61
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
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:60
CaloGlobalRoIBuilder::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: CaloGlobalRoIBuilder.cxx:47
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloGlobalRoIBuilder::m_abseta_thr
Gaudi::Property< float > m_abseta_thr
Definition: CaloGlobalRoIBuilder.h:57
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
min
#define min(a, b)
Definition: cfImp.cxx:40
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:221
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:32
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:76
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
xAOD::TrigEMCluster_v1
Description of a trigger EM cluster.
Definition: TrigEMCluster_v1.h:28
LArCellBinning.etamin
etamin
Definition: LArCellBinning.py:137
TrigRoiDescriptorCollection.h