ATLAS Offline Software
Loading...
Searching...
No Matches
CellFex.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4
5/******************************************************************************
6 * @package Trigger/TrigAlgorithms/TrigEFMissingET
7 * @file CellFex.cxx
8 *
9 * Implementation of the cell fex class
10 * @author Jon Burr
11 *****************************************************************************/
12
13#include "CellFex.h"
17#include "CaloGeoHelpers/CaloSampling.h"
18#include <array>
19#include <numeric>
20
21// TODO - we should check a couple of things
22// - What is the 'prefetch' used by the TopoClusterMaker? Do we need to use it?
23// - Should we be using the 2-Gaussian noise estimate or not? (Right now we do)
24// - Should we be skipping 'bad' cells in the loop? (Right now we include them
25// in the sum)
26// - Previously we had the bytestream error flag in the output objects. I can't
27// tell if there's any equivalent in the new access mechanism
28
29namespace {
33 static constexpr std::size_t N_SAMPLINGS{CaloSampling::FCAL2+1};
34} //> end anonymous namespace
35
36namespace HLT { namespace MET {
37 CellFex::CellFex(const std::string& name, ISvcLocator* pSvcLocator) :
38 FexBase(name, pSvcLocator)
39 {}
40
42 {
43 CHECK( m_cellsKey.initialize() );
44 CHECK( m_noiseCDOKey.initialize() );
45 CHECK( detStore()->retrieve(m_caloCellID, "CaloCell_ID") );
46 // Build up the list of component names
47 std::vector<std::string> componentNames;
48 componentNames.reserve(N_SAMPLINGS);
49 for (std::size_t ii = 0; ii < N_SAMPLINGS; ++ii)
50 componentNames.push_back(CaloSampling::getSamplingName(ii) );
51 return initializeBase(componentNames);
52 }
53
54 StatusCode CellFex::fillMET(
56 const EventContext& context,
57 MonGroupBuilder&) const
58 {
59 // Retrieve the inputs
60 auto cells = SG::makeHandle(m_cellsKey, context);
61 if (!cells.isValid())
62 {
63 ATH_MSG_ERROR("Failed to retrieve " << m_cellsKey);
64 return StatusCode::FAILURE;
65 }
66 // NB - there's no makeHandle overload for ReadCondHandle
67 SG::ReadCondHandle noiseCDO(m_noiseCDOKey, context);
68 if (!noiseCDO.isValid())
69 {
70 ATH_MSG_ERROR("Failed to retrieve " << m_noiseCDOKey);
71 return StatusCode::FAILURE;
72 }
73
74 // Prepare the individual components
75 std::array<METComponent, N_SAMPLINGS> sums;
76 // Iterate over the calorimeter cells
77 for (const CaloCell* icell : *cells) {
78 // Get the noise. The two different calls are equivalent for LAr cells,
79 // but do differ for the TileCal. As far as I can see, the 'two Gaussian'
80 // approach is the more recommended one.
81 float noise = m_doTwoGaussianNoise ?
82 noiseCDO->getEffectiveSigma(icell->ID(), icell->gain(), icell->energy() ) :
83 noiseCDO->getNoise(icell->ID(), icell->gain() );
84 // Noise selections, first |E| < T1*S
85 if (m_absNoiseThreshold > 0 &&
86 std::abs(icell->energy() ) < m_absNoiseThreshold*noise)
87 continue;
88 // Then E > -T2*S
89 if (m_negNoiseThreshold > 0 &&
90 icell->energy() < -m_negNoiseThreshold*noise)
91 continue;
92 // What about bad cells?
93 if (const CaloDetDescrElement* dde = icell->caloDDE() ) {
94 // Get the right component
95 METComponent& sum = sums.at(dde->getSampling() );
97 icell->energy(), dde->eta(), dde->phi() );
98 }
99 else {
100 auto id = icell->ID();
101 METComponent& sum = sums.at(m_caloCellID->sampling(id) );
103 icell->energy(), m_caloCellID->eta(id), m_caloCellID->phi(id) );
104 }
105 }
106 // Save the full sum
107 std::accumulate(sums.begin(), sums.end(), METComponent{}).fillMET(met);
108 // Save each component
109 for (std::size_t ii = 0; ii < N_SAMPLINGS; ++ii)
110 sums.at(ii).fillMETComponent(ii, met);
111
112 return StatusCode::SUCCESS;
113 }
114} } //> end namespace HLT::MET
#define ATH_MSG_ERROR(x)
#define CHECK(...)
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This class groups all DetDescr information related to a CaloCell.
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
Calorimeter noise CDO (conditions data object)
Definition CellFex.h:50
virtual StatusCode fillMET(xAOD::TrigMissingET &met, const EventContext &context, MonGroupBuilder &monitors) const override
Calculate and fill the output MET value.
Definition CellFex.cxx:54
Gaudi::Property< float > m_absNoiseThreshold
The threshold on the magnitude of the cell energy.
Definition CellFex.h:53
const CaloCell_ID * m_caloCellID
Fallback option for calo cells which don't have a detector description.
Definition CellFex.h:85
Gaudi::Property< float > m_negNoiseThreshold
The maximum negative cell energy.
Definition CellFex.h:58
virtual StatusCode initialize() override
Initialize the fex.
Definition CellFex.cxx:41
CellFex(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition CellFex.cxx:37
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
Input cells.
Definition CellFex.h:47
Gaudi::Property< bool > m_doTwoGaussianNoise
Use the 'two-gaussian' noise calculation for the TileCal.
Definition CellFex.h:62
FexBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition FexBase.cxx:43
StatusCode initializeBase(const std::vector< std::string > &componentNames)
Initialize the base class.
Definition FexBase.cxx:48
Helper struct to build up MET values before moving them into the EDM.
static SignedKinematics fromEnergyEtaPhi(double energy, double eta, double phi)
Factory function to construct from energy, eta, phi (massless)
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
TrigMissingET_v1 TrigMissingET
Define the most recent version of the TrigMissingET class.