ATLAS Offline Software
egammaMaxECellAlg.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 // $Id: egammaMaxECellAlg.cxx 775884 2016-09-29 15:57:53Z ssnyder $
14 #include "egammaMaxECellAlg.h"
16 #include "xAODEgamma/Egamma.h"
19 
20 
21 namespace D3PD {
22 
23 
25  ISvcLocator* svcloc)
26  : AthAlgorithm (name, svcloc),
27  m_getter (this)
28 {
29  declareProperty ("AuxPrefix", m_auxPrefix,
30  "Prefix to add to aux data items.");
31  declareProperty ("AllowMissing", m_allowMissing = false,
32  "If true, don't complain if input objects are missing.");
33  declareProperty ("Getter", m_getter,
34  "Getter instance for the input egamma objects.");
35 }
36 
37 
42 {
43  ATH_MSG_INFO(" Starting egammaMaxECellAlg" );
44 
47  CHECK( m_getter.retrieve() );
48  CHECK( m_getter->configureD3PD<xAOD::Egamma>() );
49  return StatusCode::SUCCESS;
50 }
51 
52 
57 {
58  StatusCode sc = StatusCode::SUCCESS;
59 
60 #define DECOR(TYPE,N) xAOD::Egamma::Decorator<TYPE> N (m_auxPrefix + #N)
61  DECOR(float, maxEcell_time);
62  DECOR(float, maxEcell_energy);
63  DECOR(int, maxEcell_gain);
64  DECOR(unsigned int, maxEcell_onlId);
65  DECOR(float, maxEcell_x);
66  DECOR(float, maxEcell_y);
67  DECOR(float, maxEcell_z);
68 #undef DECOR
69 
70  CHECK( m_getter->reset (m_allowMissing) );
72  const LArOnOffIdMapping* cabling{*cablingHdl};
73  if(!cabling){
74  ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key() );
75  return StatusCode::FAILURE;
76  }
77  while (const xAOD::Egamma* eg = m_getter->next<xAOD::Egamma>())
78  {
79  const xAOD::CaloCluster *cluster = eg->caloCluster();
80 
81  maxEcell_time(*eg) = -9898.9;
82  maxEcell_energy(*eg) = -9898.9;
83  maxEcell_gain(*eg) = -1;
84  maxEcell_onlId(*eg) = 0;
85 
86  maxEcell_x(*eg) = -9898.9;
87  maxEcell_y(*eg) = -9898.9;
88  maxEcell_z(*eg) = -9898.9;
89 
90  if(cluster){
91  if(cluster->getCellLinks()){
92 
93  float emax=-9999.;
94 
95  const CaloCell* cell_maxE=0;
96  for (const CaloCell* cell : *cluster) {
97  int sampling = cell->caloDDE()->getSampling();
98  if (sampling== CaloCell_ID::EMB2 || sampling== CaloCell_ID::EME2) {
99  if ( (cell->provenance() & 0x2000) ) {
100  if (cell->energy() > emax) {
101  emax=cell->energy();
102  cell_maxE=cell;
103  }
104  }
105  }
106  }
107 
108  if(cell_maxE){
109  const CaloDetDescrElement* caloDDEl = cell_maxE->caloDDE();
110 
111  maxEcell_time(*eg) = cell_maxE->time();
112  maxEcell_energy(*eg) = cell_maxE->energy();
113  maxEcell_gain(*eg) = (int) cell_maxE->gain();
114  maxEcell_onlId(*eg) = (unsigned int) (cabling->createSignalChannelID(caloDDEl->identify())).get_compact();
115 
116  maxEcell_x(*eg) = caloDDEl->x();
117  maxEcell_y(*eg) = caloDDEl->y();
118  maxEcell_z(*eg) = caloDDEl->z();
119  }
120 
121 
122  }
123  }
124 
125  m_getter->releaseElement (eg);
126  }
127 
128  return sc;
129 }
130 
131 
132 } // namespace D3PD
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloDetDescrElement::y
float y() const
cell y
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:365
ParticleTest.eg
eg
Definition: ParticleTest.py:29
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
D3PD::egammaMaxECellAlg::m_auxPrefix
std::string m_auxPrefix
Property: Prefix to add to aux data items.
Definition: egammaMaxECellAlg.h:62
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
initialize
void initialize()
Definition: run_EoverP.cxx:894
D3PD::egammaMaxECellAlg::egammaMaxECellAlg
egammaMaxECellAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
Definition: egammaMaxECellAlg.cxx: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
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
D3PD::egammaMaxECellAlg::execute
virtual StatusCode execute()
Standard Gaudi execute method.
Definition: egammaMaxECellAlg.cxx:56
ICollectionGetterTool.h
Abstract interface to get a collection of objects and iterate over it.
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CaloCell::time
float time() const
get time (data member)
Definition: CaloCell.h:352
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloCell::energy
double energy() const
get energy (data member)
Definition: CaloCell.h:311
Egamma.h
CaloDetDescrElement::identify
Identifier identify() const override final
cell identifier
Definition: CaloDetDescrElement.cxx:64
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloCell::caloDDE
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition: CaloCell.h:305
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::egammaMaxECellAlg::m_allowMissing
bool m_allowMissing
Property: If true, don't complain if input objects are missing.
Definition: egammaMaxECellAlg.h:68
xAOD::CaloCluster_v1::getCellLinks
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
Definition: CaloCluster_v1.cxx:905
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
egammaMaxECellAlg.h
Find max E cell in middle layer for an egamma object EM Cluster and store in UserData.
D3PD::egammaMaxECellAlg::initialize
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition: egammaMaxECellAlg.cxx:41
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CaloCell::gain
CaloGain::CaloGain gain() const
get gain (data member )
Definition: CaloCell.h:345
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloDetDescrElement::x
float x() const
cell x
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:363
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
D3PD::egammaMaxECellAlg::m_getter
ToolHandle< ICollectionGetterTool > m_getter
Property: Getter for input egamma objects.
Definition: egammaMaxECellAlg.h:65
CaloDetDescrElement::z
float z() const
cell z
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:367
DECOR
#define DECOR(TYPE, N)
D3PD::egammaMaxECellAlg::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: egammaMaxECellAlg.h:60
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20