ATLAS Offline Software
egammaNbCellsGainAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id: egammaNbCellsGainAlg.cxx 775880 2016-09-29 15:35:25Z ssnyder $
13 #include "egammaNbCellsGainAlg.h"
15 #include "xAODEgamma/Egamma.h"
18 
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 egammaNbCellsGainAlg" );
44 
46  CHECK( m_getter.retrieve() );
47  CHECK( m_getter->configureD3PD<xAOD::Egamma>() );
48  return StatusCode::SUCCESS;
49 }
50 
51 
56 {
57  StatusCode sc = StatusCode::SUCCESS;
58 
59  ATH_MSG_DEBUG( " In execute: Getting egamma Objects " );
60 
61 #define DECOR(TYPE,N) xAOD::Egamma::Decorator<TYPE> N (m_auxPrefix + #N)
62  DECOR(int, nbCells_s0LowGain);
63  DECOR(int, nbCells_s0MedGain);
64  DECOR(int, nbCells_s0HighGain);
65 
66  DECOR(int, nbCells_s1LowGain);
67  DECOR(int, nbCells_s1MedGain);
68  DECOR(int, nbCells_s1HighGain);
69 
70  DECOR(int, nbCells_s2LowGain);
71  DECOR(int, nbCells_s2MedGain);
72  DECOR(int, nbCells_s2HighGain);
73 
74  DECOR(int, nbCells_s3LowGain);
75  DECOR(int, nbCells_s3MedGain);
76  DECOR(int, nbCells_s3HighGain);
77 #undef DECOR
78 
79  CHECK( m_getter->reset (m_allowMissing) );
80  while (const xAOD::Egamma* eg = m_getter->next<xAOD::Egamma>()){
81  const xAOD::CaloCluster *cluster = eg->caloCluster();
82 
83  int cell_nbcells_gainlow[4];
84  int cell_nbcells_gainmed[4];
85  int cell_nbcells_gainhgh[4];
86 
87  for(int i=0; i<4; i++){
88  cell_nbcells_gainlow[i]=0;
89  cell_nbcells_gainmed[i]=0;
90  cell_nbcells_gainhgh[i]=0;
91  }
92 
93  ATH_MSG_DEBUG(" Checking Cluster " );
94 
95  if(cluster){
96  if(cluster->getCellLinks()){
97 
98  for (const CaloCell* cell : *cluster) {
99  int sampling = cell->caloDDE()->getSampling();
100  int layer = -1;
101  switch(sampling){
104  layer=0;
105  break;
106  case CaloCell_ID::EMB1:
107  case CaloCell_ID::EME1:
108  layer=1;
109  break;
110  case CaloCell_ID::EMB2:
111  case CaloCell_ID::EME2:
112  layer=2;
113  break;
114  case CaloCell_ID::EMB3:
115  case CaloCell_ID::EME3:
116  layer=3;
117  break;
118  default:
119  break;
120  }
121 
122  if(layer < 0) continue;
123 
124  switch(cell->gain()){
125  case 0: cell_nbcells_gainhgh[layer]++; break;
126  case 1: cell_nbcells_gainmed[layer]++; break;
127  case 2: cell_nbcells_gainlow[layer]++; break;
128  default: break;
129  }
130  }
131  }
132  }
133 
134  nbCells_s0LowGain(*eg) = cell_nbcells_gainlow[0];
135  nbCells_s0MedGain(*eg) = cell_nbcells_gainmed[0];
136  nbCells_s0HighGain(*eg) = cell_nbcells_gainhgh[0];
137 
138  nbCells_s1LowGain(*eg) = cell_nbcells_gainlow[1];
139  nbCells_s1MedGain(*eg) = cell_nbcells_gainmed[1];
140  nbCells_s1HighGain(*eg) = cell_nbcells_gainhgh[1];
141 
142  nbCells_s2LowGain(*eg) = cell_nbcells_gainlow[2];
143  nbCells_s2MedGain(*eg) = cell_nbcells_gainmed[2];
144  nbCells_s2HighGain(*eg) = cell_nbcells_gainhgh[2];
145 
146  nbCells_s3LowGain(*eg) = cell_nbcells_gainlow[3];
147  nbCells_s3MedGain(*eg) = cell_nbcells_gainmed[3];
148  nbCells_s3HighGain(*eg) = cell_nbcells_gainhgh[3];
149 
150  m_getter->releaseElement (eg);
151  }
152 
153  return sc;
154 }
155 }
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ParticleTest.eg
eg
Definition: ParticleTest.py:29
D3PD::egammaNbCellsGainAlg::initialize
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition: egammaNbCellsGainAlg.cxx:41
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
initialize
void initialize()
Definition: run_EoverP.cxx:894
egammaNbCellsGainAlg.h
Number of cells with given gain by layer.
ICollectionGetterTool.h
Abstract interface to get a collection of objects and iterate over it.
D3PD::egammaNbCellsGainAlg::m_getter
ToolHandle< ICollectionGetterTool > m_getter
Property: Getter for input egamma objects.
Definition: egammaNbCellsGainAlg.h:59
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
D3PD::egammaNbCellsGainAlg::m_auxPrefix
std::string m_auxPrefix
Property: Prefix to add to aux data items.
Definition: egammaNbCellsGainAlg.h:56
D3PD::egammaNbCellsGainAlg::m_allowMissing
bool m_allowMissing
Property: If true, don't complain if input objects are missing.
Definition: egammaNbCellsGainAlg.h:62
Egamma.h
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
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloCluster.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
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
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DECOR
#define DECOR(TYPE, N)
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
D3PD::egammaNbCellsGainAlg::egammaNbCellsGainAlg
egammaNbCellsGainAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
Definition: egammaNbCellsGainAlg.cxx:24
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
D3PD::egammaNbCellsGainAlg::execute
virtual StatusCode execute()
Standard Gaudi execute method.
Definition: egammaNbCellsGainAlg.cxx:55
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56