ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::EGammaCookieCutClusterTool Class Reference

#include <EGammaCookieCutClusterTool.h>

Inheritance diagram for DerivationFramework::EGammaCookieCutClusterTool:
Collaboration diagram for DerivationFramework::EGammaCookieCutClusterTool:

Public Member Functions

virtual StatusCode initialize () override final
virtual StatusCode addBranches (const EventContext &ctx) const override final

Private Attributes

SG::WriteHandleKey< xAOD::CaloClusterContainerm_outClusterContainerKey
 Output cluster container.
SG::WriteHandleKey< CaloClusterCellLinkContainerm_outClusterContainerCellLinkKey
 Output cluster container cell links: should match output containter name.
SG::ReadCondHandleKey< CaloDetDescrManagerm_caloDetDescrMgrKey
 Calorimeter description.
SG::ReadHandleKey< xAOD::EgammaContainerm_SGKey_electrons
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainerm_SGKey_electrons_decorations
Gaudi::Property< int > m_maxDelEtaCells
 Size of maximum search window in eta.
Gaudi::Property< int > m_maxDelPhiCells
 Size of maximum search window in phi.
Gaudi::Property< float > m_maxDelR
 Size of cone to cookie cut on FCal.
Gaudi::Property< bool > m_fixCellWeights
 if true, use cell weights = 1 for cookie-cut cluster
Gaudi::Property< bool > m_storeOrigMom
 Decide whether or not to store input cluster moments.
Gaudi::Property< bool > m_storeCookMom
 Decide whether or not to store cooked cluster moments.
egammaClusterCookieCut::CookieCutPars m_CookieCutPars {}
std::once_flag m_Seen
unsigned short m_nDecor = 0
Gaudi::Property< std::vector< int > > m_vecM
 The cluster moments to be added.
Gaudi::Property< std::vector< std::string > > m_vecMName
 Name of the cluster moments to be added.
ToolHandleArray< CaloClusterCollectionProcessorm_clusterCorrectionTools

Detailed Description

Definition at line 21 of file EGammaCookieCutClusterTool.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::EGammaCookieCutClusterTool::addBranches ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 60 of file EGammaCookieCutClusterTool.cxx.

61{
62
63 // For debug
64 static const std::vector<CaloSampling::CaloSample> s_sam
65 { CaloSampling::PreSamplerB, CaloSampling::EMB1,
66 CaloSampling::EMB2, CaloSampling::EMB3,
67 CaloSampling::PreSamplerE, CaloSampling::EME1,
68 CaloSampling::EME2, CaloSampling::EME3,
69 CaloSampling::TileBar0, CaloSampling::TileBar1, CaloSampling::TileBar2,
70 CaloSampling::TileExt0, CaloSampling::TileExt1, CaloSampling::TileExt2,
71 CaloSampling::TileGap1, CaloSampling::TileGap2, CaloSampling::TileGap3,
72 CaloSampling::HEC0, CaloSampling::HEC1,
73 CaloSampling::HEC2, CaloSampling::HEC3,
74 CaloSampling::FCAL0, CaloSampling::FCAL1, CaloSampling::FCAL2 };
75
76 // Create the relevant cluster output and register it.
77 SG::WriteHandle<xAOD::CaloClusterContainer> outClusterContainer(
79 ctx
80 );
82
83 SG::WriteHandle<CaloClusterCellLinkContainer> outClusterContainerCellLink(
85 ctx
86 );
87 ATH_CHECK(outClusterContainerCellLink.record(
88 std::make_unique<CaloClusterCellLinkContainer>())
89 );
90
91 // Retrieve electron container
92 SG::ReadHandle<xAOD::EgammaContainer> electronContainer(m_SGKey_electrons,
93 ctx);
94 const std::size_t nF = electronContainer.ptr()->size();
95 if (nF == 0) {
96 return StatusCode::SUCCESS;
97 }
98
99 std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decoM;
100 decoM.reserve(m_nDecor);
101 for (int i = 0; i < m_nDecor - 1; i++) {
102 decoM.emplace_back(m_SGKey_electrons_decorations[i], ctx);
103 }
104
105 if (msgLevel(MSG::DEBUG)) {
106 std::call_once(m_Seen, [this,&decoM]() {
107 for (int i = 0; i < m_nDecor - 1; i++) {
108 ATH_MSG_DEBUG("Decor " << i << " out of " << m_nDecor
110 << " " << decoM[i].decorKey());
111 }
112 });
113 }
114 SG::WriteDecorHandle<xAOD::EgammaContainer,
115 ElementLink<xAOD::CaloClusterContainer>>
117
118 // Calorimeter description.
119 SG::ReadCondHandle<CaloDetDescrManager> caloDetDescrMgrHandle{
121 };
122 ATH_CHECK(caloDetDescrMgrHandle.isValid());
123 const CaloDetDescrManager* calodetdescrmgr = *caloDetDescrMgrHandle;
124
125 // Decorate electrons
126 int iel = 0;
127 std::vector<bool> success(nF,true);
128 ATH_MSG_VERBOSE("Will analyze " << nF << " forward electrons");
129 for (const auto* electron : *electronContainer.ptr()) {
130
131 const xAOD::CaloCluster *cluster = electron->caloCluster();
132 ATH_MSG_DEBUG("Electron " << electron->index() << " cluster"
133 << " pT = " << cluster->pt()
134 << " eta = " << cluster->eta());
135
136 const DataLink<CaloCellContainer>& cellCont =
138
139 std::unique_ptr<xAOD::CaloCluster> newCluster =
140 egammaClusterCookieCut::cookieCut(*cluster, *calodetdescrmgr,
141 cellCont, m_CookieCutPars);
142
143 if (!newCluster || newCluster->getCellLinks()->size() == 0) {
144 ATH_MSG_DEBUG("No able to build a new cluster for electron "
145 << electron->index()
146 << " pT = " << electron->pt()
147 << " eta = " << electron->eta()
148 << " original cluster " << cluster->index()
149 << " pT = " << cluster->pt()
150 << " eta = " << cluster->eta()
151 << " has EME2 or FCAL0"
152 << " " << cluster->hasSampling(CaloSampling::EME2)
153 << " " << cluster->hasSampling(CaloSampling::FCAL0)
154 << " reason : "
155 << (newCluster ? " no cells in cluster" : " no cluster"));
156 if (!newCluster) {
157 ATH_MSG_VERBOSE("Energies in various samplings :");
158 for (auto s : s_sam)
159 ATH_MSG_VERBOSE("Sampling " << s << " E = " << cluster->eSample(s));
160 }
161 decoEl(*electron) = ElementLink<xAOD::CaloClusterContainer>();
162 success[iel] = false;
163 }
164
165 if (success[iel]) {
166 if (newCluster) {
167 ATH_MSG_DEBUG("Cookie cut cluster"
168 << " pT = " << newCluster->pt()
169 << " eta = " << newCluster->eta());
170 }
171 outClusterContainer->push_back(std::move(newCluster));
172 size_t index = outClusterContainer->size() - 1;
173 ElementLink<xAOD::CaloClusterContainer>
174 clusterLink(*outClusterContainer, index, ctx);
175 // Now decorate the electron with the link to cookie cut cluster
176 decoEl(*electron) = clusterLink;
177 }
178
179 // Eventually decorate the electron with the original moment
180 if (m_storeOrigMom) {
181 for (size_t i = 0; i < m_vecM.size(); i++) {
182 int indexDecor = m_storeCookMom ? 2*i+1 : i;
183 double m = 0.;
184 bool gotM = cluster->retrieveMoment(
185 static_cast<xAOD::CaloCluster::MomentType>(m_vecM[i]), m);
186 if (!gotM) {
188 << " does not exist for the original cluster");
189 }
190 decoM[indexDecor](*electron) = float(m);
191 ATH_MSG_VERBOSE("Decorated electron " << electron->index()
192 << " with original moment "
193 << i << " " << m_vecMName[i]
194 << " = " << m << " (decoration index =" << indexDecor
195 << " key = " << decoM[indexDecor].decorKey() << ")");
196 }
197 }
198 iel++;
199 }
200
201 if (!m_clusterCorrectionTools.empty()) {
202 ToolHandleArray<CaloClusterCollectionProcessor>::const_iterator
203 toolIt = m_clusterCorrectionTools.begin(),
204 toolIt_e = m_clusterCorrectionTools.end();
205 for (; toolIt != toolIt_e; ++toolIt) {
206 ATH_CHECK((*toolIt)->execute(ctx, outClusterContainer.ptr()));
207 }
208
209 if (m_storeCookMom) {
210 static const SG::AuxElement::Accessor<
211 ElementLink< xAOD::CaloClusterContainer > >
212 cookClusLinkAcc( "cookiecutClusterLink" );
213 iel = 0;
214 for (const auto* electron : *electronContainer.ptr()) {
215 const xAOD::CaloCluster *cluster = nullptr;
216 if (success[iel]) {
217 cluster = xAOD::EgammaHelpers::getCluster(electron);
218 }
219 if (success[iel] && cluster == nullptr) {
220 ATH_MSG_WARNING("CookieCut cluster was build successfully, but"
221 "could not be retrieved");
222 }
223
224 for (size_t i = 0; i < m_vecM.size(); i++) {
225 int indexDecor = m_storeOrigMom ? 2*i : i;
226 double m = 0.;
227 if (cluster) {
228 bool gotM = cluster->retrieveMoment(
229 static_cast<xAOD::CaloCluster::MomentType>(m_vecM[i]), m);
230 if (!gotM) {
232 << " does not exist for the new cluster");
233 }
234 }
235 decoM[indexDecor](*electron) = float(m);
236 ATH_MSG_VERBOSE("Decorated electron " << electron->index()
237 << " with new moment "
238 << i << " " << m_vecMName[i]
239 << " = " << m << " (decoration index = " << indexDecor
240 << " key = " << decoM[indexDecor].decorKey() << ")");
241 }
242 iel++;
243 }
244 }
245 }
246
248 ctx,
249 outClusterContainer,
250 outClusterContainerCellLink);
251
252 ATH_MSG_DEBUG("Built " << outClusterContainer.ptr()->size()
253 << " cookie cut clusters");
254
255 return StatusCode::SUCCESS;
256}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
xAOD::ElectronContainer * electronContainer
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
size_type size() const noexcept
Returns the number of elements in the collection.
ToolHandleArray< CaloClusterCollectionProcessor > m_clusterCorrectionTools
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
Calorimeter description.
Gaudi::Property< bool > m_storeOrigMom
Decide whether or not to store input cluster moments.
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_outClusterContainerCellLinkKey
Output cluster container cell links: should match output containter name.
Gaudi::Property< std::vector< std::string > > m_vecMName
Name of the cluster moments to be added.
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer > m_SGKey_electrons_decorations
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_electrons
egammaClusterCookieCut::CookieCutPars m_CookieCutPars
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outClusterContainerKey
Output cluster container.
Gaudi::Property< std::vector< int > > m_vecM
The cluster moments to be added.
Gaudi::Property< bool > m_storeCookMom
Decide whether or not to store cooked cluster moments.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
size_t index() const
Return the index of this element within its container.
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters)
virtual double eta() const
The pseudorapidity ( ) of the particle.
float eSample(const CaloSample sampling) const
MomentType
Enums to identify different moments.
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
str index
Definition DeMoScan.py:362
std::unique_ptr< xAOD::CaloCluster > cookieCut(const xAOD::CaloCluster &cluster, const CaloDetDescrManager &mgr, const DataLink< CaloCellContainer > &cellCont, const egammaClusterCookieCut::CookieCutPars &pars)
const xAOD::CaloCluster * getCluster(const xAOD::Egamma *eg, bool cook=true)
return the associated egamma cluster, that might be cookie-cut cluster (fwd electron)
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".

◆ initialize()

StatusCode DerivationFramework::EGammaCookieCutClusterTool::initialize ( )
finaloverridevirtual

Definition at line 21 of file EGammaCookieCutClusterTool.cxx.

22{
23 ATH_MSG_VERBOSE("initialize() ...");
24
25 ATH_CHECK(m_caloDetDescrMgrKey.initialize());
26
27 ATH_MSG_DEBUG("Will store cookie cut clusters in this container "
31
32 ATH_MSG_DEBUG("Using " << m_SGKey_electrons << " for electrons");
33 ATH_CHECK(m_SGKey_electrons.initialize());
34
36 ATH_MSG_DEBUG("Initialize nDecor = " << m_nDecor);
38 if (msgLvl(MSG::DEBUG)) {
39 ATH_MSG_DEBUG("Decorations for " << m_SGKey_electrons.key());
40 for (const auto& s : m_SGKey_electrons_decorations)
41 { ATH_MSG_DEBUG(s.key()); }
42 }
43
44 m_CookieCutPars.maxDelEta = m_maxDelEtaCells * cellEtaSize * 0.5;
45 m_CookieCutPars.maxDelPhi = m_maxDelPhiCells * cellPhiSize * 0.5;
47 m_CookieCutPars.fixCellWeights = m_fixCellWeights;
48
49 // Retrieve cluster moment maker in case we cookie cut and want to recompute
50 if (!m_clusterCorrectionTools.empty()) {
52 m_CookieCutPars.recomputeMoments = true;
53 }
54
55 return StatusCode::SUCCESS;
56}
Gaudi::Property< bool > m_fixCellWeights
if true, use cell weights = 1 for cookie-cut cluster
Gaudi::Property< int > m_maxDelEtaCells
Size of maximum search window in eta.
Gaudi::Property< int > m_maxDelPhiCells
Size of maximum search window in phi.
Gaudi::Property< float > m_maxDelR
Size of cone to cookie cut on FCal.

Member Data Documentation

◆ m_caloDetDescrMgrKey

SG::ReadCondHandleKey<CaloDetDescrManager> DerivationFramework::EGammaCookieCutClusterTool::m_caloDetDescrMgrKey
private
Initial value:
{
this,
"CaloDetDescrManager",
"CaloDetDescrManager",
"SG Key for CaloDetDescrManager in the Condition Store"
}

Calorimeter description.

Definition at line 50 of file EGammaCookieCutClusterTool.h.

50 {
51 this,
52 "CaloDetDescrManager",
53 "CaloDetDescrManager",
54 "SG Key for CaloDetDescrManager in the Condition Store"
55 };

◆ m_clusterCorrectionTools

ToolHandleArray<CaloClusterCollectionProcessor> DerivationFramework::EGammaCookieCutClusterTool::m_clusterCorrectionTools
private
Initial value:
{
this,
"ClusterMomentMaker",
{},
"The moment maker"
}

Definition at line 141 of file EGammaCookieCutClusterTool.h.

141 {
142 this,
143 "ClusterMomentMaker",
144 {},
145 "The moment maker"
146 };

◆ m_CookieCutPars

egammaClusterCookieCut::CookieCutPars DerivationFramework::EGammaCookieCutClusterTool::m_CookieCutPars {}
private

Definition at line 120 of file EGammaCookieCutClusterTool.h.

120{};

◆ m_fixCellWeights

Gaudi::Property<bool> DerivationFramework::EGammaCookieCutClusterTool::m_fixCellWeights
private
Initial value:
{
this,
"FixCellWeights",
false,
"Fix cell weights to one for the cookie-cut cluster"
}

if true, use cell weights = 1 for cookie-cut cluster

Definition at line 97 of file EGammaCookieCutClusterTool.h.

97 {
98 this,
99 "FixCellWeights",
100 false,
101 "Fix cell weights to one for the cookie-cut cluster"
102 };

◆ m_maxDelEtaCells

Gaudi::Property<int> DerivationFramework::EGammaCookieCutClusterTool::m_maxDelEtaCells
private
Initial value:
{
this,
"MaxWindowDelEtaCells",
3,
"Size of maximum search window in eta"
}

Size of maximum search window in eta.

Definition at line 73 of file EGammaCookieCutClusterTool.h.

73 {
74 this,
75 "MaxWindowDelEtaCells",
76 3,
77 "Size of maximum search window in eta"
78 };

◆ m_maxDelPhiCells

Gaudi::Property<int> DerivationFramework::EGammaCookieCutClusterTool::m_maxDelPhiCells
private
Initial value:
{
this,
"MaxWindowDelPhiCells",
3,
"Size of maximum search window in phi"
}

Size of maximum search window in phi.

Definition at line 81 of file EGammaCookieCutClusterTool.h.

81 {
82 this,
83 "MaxWindowDelPhiCells",
84 3,
85 "Size of maximum search window in phi"
86 };

◆ m_maxDelR

Gaudi::Property<float> DerivationFramework::EGammaCookieCutClusterTool::m_maxDelR
private
Initial value:
{
this,
"MaxWindowDelR",
0.3,
"Cone size to collect cells around hottest-cell FCAL"
}

Size of cone to cookie cut on FCal.

Definition at line 89 of file EGammaCookieCutClusterTool.h.

89 {
90 this,
91 "MaxWindowDelR",
92 0.3,
93 "Cone size to collect cells around hottest-cell FCAL"
94 };

◆ m_nDecor

unsigned short DerivationFramework::EGammaCookieCutClusterTool::m_nDecor = 0
private

Definition at line 123 of file EGammaCookieCutClusterTool.h.

◆ m_outClusterContainerCellLinkKey

SG::WriteHandleKey<CaloClusterCellLinkContainer> DerivationFramework::EGammaCookieCutClusterTool::m_outClusterContainerCellLinkKey
private
Initial value:
{
this,
"ClusterContainerLinksName",
"ForwardElectronCookieCutClusters_links",
"Name of the output cluster container cell links container"
}

Output cluster container cell links: should match output containter name.

Definition at line 42 of file EGammaCookieCutClusterTool.h.

42 {
43 this,
44 "ClusterContainerLinksName",
45 "ForwardElectronCookieCutClusters_links",
46 "Name of the output cluster container cell links container"
47 };

◆ m_outClusterContainerKey

SG::WriteHandleKey<xAOD::CaloClusterContainer> DerivationFramework::EGammaCookieCutClusterTool::m_outClusterContainerKey
private
Initial value:
{
this,
"ClusterContainerName",
"ForwardElectronCookieCutClusters",
"Name of the output cookie cut cluster container"
}

Output cluster container.

Definition at line 34 of file EGammaCookieCutClusterTool.h.

34 {
35 this,
36 "ClusterContainerName",
37 "ForwardElectronCookieCutClusters",
38 "Name of the output cookie cut cluster container"
39 };

◆ m_Seen

std::once_flag DerivationFramework::EGammaCookieCutClusterTool::m_Seen
mutableprivate

Definition at line 122 of file EGammaCookieCutClusterTool.h.

◆ m_SGKey_electrons

SG::ReadHandleKey<xAOD::EgammaContainer> DerivationFramework::EGammaCookieCutClusterTool::m_SGKey_electrons
private
Initial value:
{
this,
"SGKey_electrons",
"ForwardElectrons",
"SG key of electron container"
}

Definition at line 57 of file EGammaCookieCutClusterTool.h.

57 {
58 this,
59 "SGKey_electrons",
60 "ForwardElectrons",
61 "SG key of electron container"
62 };

◆ m_SGKey_electrons_decorations

SG::WriteDecorHandleKeyArray<xAOD::EgammaContainer> DerivationFramework::EGammaCookieCutClusterTool::m_SGKey_electrons_decorations
private
Initial value:
{
this,
"SGKey_electrons_decorations",
"SG keys for electrons decorations"
}
SG::ReadHandleKey< xAOD::EgammaContainer > m_SGKey_electrons

Definition at line 65 of file EGammaCookieCutClusterTool.h.

65 {
66 this,
67 "SGKey_electrons_decorations",
69 "SG keys for electrons decorations"
70 };

◆ m_storeCookMom

Gaudi::Property<bool> DerivationFramework::EGammaCookieCutClusterTool::m_storeCookMom
private
Initial value:
{
this,
"StoreCookedMoments",
false,
"Decorate also with the moments from the cookie-cut cluster"
}

Decide whether or not to store cooked cluster moments.

Definition at line 113 of file EGammaCookieCutClusterTool.h.

113 {
114 this,
115 "StoreCookedMoments",
116 false,
117 "Decorate also with the moments from the cookie-cut cluster"
118 };

◆ m_storeOrigMom

Gaudi::Property<bool> DerivationFramework::EGammaCookieCutClusterTool::m_storeOrigMom
private
Initial value:
{
this,
"StoreInputMoments",
false,
"Decorate also with the moments from the original cluster"
}

Decide whether or not to store input cluster moments.

Definition at line 105 of file EGammaCookieCutClusterTool.h.

105 {
106 this,
107 "StoreInputMoments",
108 false,
109 "Decorate also with the moments from the original cluster"
110 };

◆ m_vecM

Gaudi::Property<std::vector<int> > DerivationFramework::EGammaCookieCutClusterTool::m_vecM
private
Initial value:
{
this,
"Moments",
{},
"The moments to be added"
}

The cluster moments to be added.

Definition at line 126 of file EGammaCookieCutClusterTool.h.

126 {
127 this,
128 "Moments",
129 {},
130 "The moments to be added"
131 };

◆ m_vecMName

Gaudi::Property<std::vector<std::string> > DerivationFramework::EGammaCookieCutClusterTool::m_vecMName
private
Initial value:
{
this,
"MomentNames",
{},
"The names of the moments to be added"
}

Name of the cluster moments to be added.

Definition at line 134 of file EGammaCookieCutClusterTool.h.

134 {
135 this,
136 "MomentNames",
137 {},
138 "The names of the moments to be added"
139 };

The documentation for this class was generated from the following files: