ATLAS Offline Software
Loading...
Searching...
No Matches
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 $
12
13
14#include "egammaMaxECellAlg.h"
16#include "xAODEgamma/Egamma.h"
19
20
21namespace D3PD {
22
23
24egammaMaxECellAlg::egammaMaxECellAlg (const std::string& name,
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
45 CHECK( AthAlgorithm::initialize() );
46 CHECK( m_cablingKey.initialize() );
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
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Abstract interface to get a collection of objects and iterate over it.
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
float time() const
get time (data member)
Definition CaloCell.h:368
double energy() const
get energy (data member)
Definition CaloCell.h:327
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
Definition CaloCell.h:321
CaloGain::CaloGain gain() const
get gain (data member )
Definition CaloCell.h:361
This class groups all DetDescr information related to a CaloCell.
Identifier identify() const override final
cell identifier
virtual StatusCode initialize()
Standard Gaudi initialize method.
bool m_allowMissing
Property: If true, don't complain if input objects are missing.
virtual StatusCode execute()
Standard Gaudi execute method.
egammaMaxECellAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
std::string m_auxPrefix
Property: Prefix to add to aux data items.
ToolHandle< ICollectionGetterTool > m_getter
Property: Getter for input egamma objects.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
#define DECOR(TYPE, N)
Find max E cell in middle layer for an egamma object EM Cluster and store in UserData.
Block filler tool for noisy FEB information.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17