ATLAS Offline Software
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 
29 namespace {
33  static constexpr std::size_t N_SAMPLINGS{CaloSampling::FCAL2+1};
34 } //> end anonymous namespace
35 
36 namespace HLT { namespace MET {
37  CellFex::CellFex(const std::string& name, ISvcLocator* pSvcLocator) :
38  FexBase(name, pSvcLocator)
39  {}
40 
42  {
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 
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
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
METComponent.h
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
WriteCellNoiseToCool.icell
icell
Definition: WriteCellNoiseToCool.py:339
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
HLT::MET::CellFex::m_cellsKey
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
Input cells.
Definition: CellFex.h:73
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
HLT::MET::CellFex::m_doTwoGaussianNoise
Gaudi::Property< bool > m_doTwoGaussianNoise
Use the 'two-gaussian' noise calculation for the TileCal.
Definition: CellFex.h:88
CellFex.h
HLT::MET::FexBase
Definition: FexBase.h:47
ReadCondHandle.h
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
HLT::MET::CellFex::m_caloCellID
const CaloCell_ID * m_caloCellID
Fallback option for calo cells which don't have a detector description.
Definition: CellFex.h:111
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
SignedKinematics.h
met
Definition: IMETSignificance.h:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
HLT::MET::CellFex::fillMET
virtual StatusCode fillMET(xAOD::TrigMissingET &met, const EventContext &context, MonGroupBuilder &monitors) const override
Calculate and fill the output MET value.
Definition: CellFex.cxx:54
CaloCell_Base_ID::sampling
int sampling(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HLT::MET::CellFex::initialize
virtual StatusCode initialize() override
Initialize the fex.
Definition: CellFex.cxx:41
CaloCell_Base_ID::eta
int eta(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
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
HLT::MET::CellFex::m_negNoiseThreshold
Gaudi::Property< float > m_negNoiseThreshold
The maximum negative cell energy.
Definition: CellFex.h:84
HLT::MET::CellFex::m_absNoiseThreshold
Gaudi::Property< float > m_absNoiseThreshold
The threshold on the magnitude of the cell energy.
Definition: CellFex.h:79
HLT::MET::SignedKinematics::fromEnergyEtaPhi
static SignedKinematics fromEnergyEtaPhi(double energy, double eta, double phi)
Factory function to construct from energy, eta, phi (massless)
Definition: SignedKinematics.cxx:26
HLT::MET::FexBase::initializeBase
StatusCode initializeBase(const std::vector< std::string > &componentNames)
Initialize the base class.
Definition: FexBase.cxx:48
HLT::MET::METComponent
Helper struct to build up MET values before moving them into the EDM.
Definition: METComponent.h:40
HLT::MET::CellFex::CellFex
CellFex(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: CellFex.cxx:37
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MET
Definition: MET.py:1
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCell_Base_ID::phi
int phi(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
HLT::MET::MonGroupBuilder
Definition: MonGroupBuilder.h:45
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
xAOD::TrigMissingET_v1
Class holding the Missing ET trigger fex results.
Definition: TrigMissingET_v1.h:32
CaloCell_ID_FCS::FCAL2
@ FCAL2
Definition: FastCaloSim_CaloCell_ID.h:42
CaloSampling::getSamplingName
static std::string getSamplingName(CaloSample theSample)
Returns a string (name) for each CaloSampling.
Definition: Calorimeter/CaloGeoHelpers/Root/CaloSampling.cxx:18
WriteCellNoiseToCool.noise
noise
Definition: WriteCellNoiseToCool.py:380
HLT::MET::CellFex::m_noiseCDOKey
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
Calorimeter noise CDO (conditions data object)
Definition: CellFex.h:76