12#include "CaloGeoHelpers/CaloSampling.h"
40 const std::string& name,
41 const ::IInterface* parent)
47 declareInterface<ICaloRingsBuilder>(
this);
63 for (
size_t rsConfIdx = 0; rsConfIdx <
m_nRingSets; ++rsConfIdx) {
65 const auto rsNLayers =
m_nLayers[rsConfIdx];
67 auto end_itr = itr + rsNLayers;
69 const auto& caloSampleItr =
reinterpret_cast<
70 std::vector<CaloSampling::CaloSample>::iterator&
72 const auto& caloSampleEndItr =
reinterpret_cast<
73 std::vector<CaloSampling::CaloSample>::iterator&
76 std::vector<CaloSampling::CaloSample> rsLayers( caloSampleItr ,
98 }
catch (
const std::runtime_error &e) {
99 ATH_MSG_ERROR(
"Could not add collection bounderies due to: " << e.what() );
101 std::ostringstream
str;
104 return StatusCode::FAILURE;
108 if (msgLevel() <= MSG::DEBUG){
109 std::ostringstream
str;
121 return StatusCode::SUCCESS;
127 return StatusCode::SUCCESS;
133 , std::size_t nReserve )
135 if ( crCont && rsCont ){
139 ATH_MSG_ERROR(
"Attempted to set CaloRingsContainer and/or RingSetContainer to invalid pointers");
140 return StatusCode::FAILURE;
151 return StatusCode::SUCCESS;
159 const double eta2 = std::fabs(cluster.
etaBE(2));
160 const double energy = cluster.
e();
162 const double cosheta = std::cosh(eta2);
163 et = (cosheta != 0.) ? energy /cosheta : 0.;
169 ATH_MSG_DEBUG(
"Skipping cluster with low energy (" <<
et <<
" MeV) .");
170 return StatusCode::SUCCESS;
179 double et = particle.pt();
184 ATH_MSG_DEBUG(
"Skipping particle with low energy (" <<
et <<
" MeV) .");
185 return StatusCode::SUCCESS;
235 if (msgLevel() <= MSG::DEBUG){
236 std::ostringstream
str;
241 return StatusCode::SUCCESS;
252 seed.setEta( cluster.
eta() );
253 seed.setPhi( cluster.
phi() );
255 return StatusCode::SUCCESS;
259 bool foundValid =
false, foundMultipleValid =
false;
261 for (
const auto layer :
rawConf.layers ) {
269 ") seedCandidate is: (" <<
270 seedCandidate.
eta() <<
"," <<
271 seedCandidate.
phi() <<
")" );
273 if ( seedCandidate.
isValid() ){
276 foundMultipleValid =
true;
283 if ( foundMultipleValid ){
284 ATH_MSG_WARNING(
"Found multiple valid seeds. Set to last valid candidate.");
286 return StatusCode::SUCCESS;
297 seed.setEta( part.eta() );
298 seed.setPhi( part.phi() );
300 return StatusCode::SUCCESS;
323 const auto nRings =
rawConf.nRings;
330 return StatusCode::FAILURE;
339 for (
const int layer :
rawConf.layers) {
342 for (
const CaloCell *cell : cells ) {
344 unsigned int ringNumber(0);
347 const float deltaEta = fabs(
348 (cell->eta() - seed.eta())
356 const float deltaGreater = std::max(deltaEta,
deltaPhi);
359 ringNumber =
static_cast<unsigned int>(std::floor(deltaGreater + .5));
360 if ( ringNumber < nRings ){
362 rs->at(ringNumber) += cell->energy()/cosh(cell->eta());
364 rs->at(ringNumber) += cell->energy();
370 return StatusCode::SUCCESS;
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
float et(const xAOD::jFexSRJetRoI *j)
Data object for each calorimeter readout cell.
This class provides the client interface for accessing the detector description information common to...
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
ElementLink implementation for ROOT usage.
bool toContainedElement(BaseConstReference data, ElementType element, IProxyDict *sg=0)
Set from element pointer and a reference to the container (storable)
virtual StatusCode buildRingSet(const xAOD::RingSetConf::RawConf &rawConf, const AtlasGeoPoint &seed, xAOD::RingSet *rs)
main method where the RingSets are built.
CaloRingsBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
~CaloRingsBuilder()
Destructor.
SG::WriteHandleKey< xAOD::RingSetContainer > m_rsContName
Name of RingSetContainer on Event StoreGate.
const xAOD::RingSetConf::RawConfCollection & rawConf() override
Extra methods:
xAOD::RingSetConf::RawConfCollection m_rsRawConfCol
holds each RingSet configuration (filled at initialize)
virtual StatusCode execute(const xAOD::IParticle &particle, ElementLink< xAOD::CaloRingsContainer > &clRingsLink) override
build CaloRings for IParticle
StatusCode getRingSetSeed(const xAOD::RingSetConf::RawConf &conf, const xAOD::CaloCluster &cluster, AtlasGeoPoint &seed)
Fill RingSet seed for CaloCluster.
SG::WriteHandleKey< xAOD::CaloRingsContainer > m_crContName
Fill RingSet seed for IParticle.
Gaudi::Property< float > m_minEnergy
Minimum particle energy to build rings (GeV)
size_t m_nRingSets
hold the number of RingSets we are building for each CaloRings
Gaudi::Property< std::vector< float > > m_etaWidth
Width of the ring in eta.
Gaudi::Property< bool > m_doTransverseEnergy
Switch to use raw cell energy instead ET.
StatusCode executeTemp(const T &input, ElementLink< xAOD::CaloRingsContainer > &crEL)
Tool protected methods:
Gaudi::Property< std::vector< unsigned int > > m_nLayers
Number of calorimeter layers in each ringset.
Gaudi::Property< float > m_cellMaxDEtaDist
Maximum cell distance in eta to seed.
xAOD::RingSetContainer * m_rsCont
Tool props (non configurables):
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode preExecute(xAOD::CaloRingsContainer *crCont, xAOD::RingSetContainer *rsCont, const std::size_t nReserve=0) override
method for working on containers
Gaudi::Property< std::vector< float > > m_phiWidth
Width of the ring in phi.
xAOD::CaloRingsContainer * m_crCont
Create and hold CaloRingsContainer for each event.
Gaudi::Property< std::vector< int > > m_layers
Calorimeter layers in each ringset.
SG::ReadHandleKey< CaloCellContainer > m_cellsContName
Name of CaloCellContainer.
AtlasGeoPoint m_lastValidSeed
last valid RingSet seed
Gaudi::Property< std::vector< unsigned int > > m_nRings
Number of rings in a ringset.
Gaudi::Property< bool > m_useShowShapeBarycenter
Switch to use shower barycenter seed for each RingSets.
virtual StatusCode finalize() override
finalize method
virtual StatusCode initialize() override
Tool main methods:
Gaudi::Property< float > m_cellMaxDPhiDist
Maximum cell distance in phi to seed.
const_pointer_type ptr()
Dereference the pointer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
float phiSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
float etaSample(const CaloSample sampling) const
Retrieve barycenter in a given sample.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
void print(std::ostream &stream) const
Print-out methods:
void addRingSetEL(const ElementLink< RingSetContainer_v1 > &rsEL)
Add ElementLink to holden vector.
Class providing the definition of the 4-vector interface.
static Ringer::CalJointLayer whichLayer(const std::vector< CaloSampling::CaloSample > &layers)
static void print(const RawConf &raw, std::ostream &stream)
Prints rawConf.
static Ringer::CalJointSection whichSection(const std::vector< CaloSampling::CaloSample > &layers)
static void addRawConfColBounderies(RawConfCollection &clRingsConf)
Add to RawConfCollection its JointLayer/JointSection bounderies.
Namespace dedicated for Ringer utilities.
RingSet_v1 RingSet
Definition of the current "RingSet version".
CaloRings_v1 CaloRings
Definition of the current "CaloRings version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
RingSetContainer_v1 RingSetContainer
Definition of the current "RingSet container version".
CaloRingsContainer_v1 CaloRingsContainer
Definition of the current "CaloRings container version".
Extra patterns decribing particle interation process.