62 {
63
64 static const SG::AuxElement::Accessor<float> acce2("Eadded_Lr2");
65 static const SG::AuxElement::Accessor<float> acce3("Eadded_Lr3");
66 static const SG::AuxElement::Accessor<float> acce2b("Eadded_Lr2b");
67 static const SG::AuxElement::Accessor<float> acce3b("Eadded_Lr3b");
68 static const SG::AuxElement::Accessor<float> acce2e("Eadded_Lr2e");
69 static const SG::AuxElement::Accessor<float> acce3e("Eadded_Lr3e");
70
73 SG::ReadHandle<xAOD::PhotonContainer> ph_inputContainer(
m_photonInputKey,ctx);
75
76 ATH_CHECK(el_outputContainer.record(std::make_unique<xAOD::ElectronContainer>(),
77 std::make_unique<xAOD::ElectronAuxContainer>()));
78
79 ATH_CHECK(ph_outputContainer.record(std::make_unique<xAOD::PhotonContainer>(),
80 std::make_unique<xAOD::PhotonAuxContainer>()));
81
84 electrons->reserve(el_inputContainer->size());
85 photons->
reserve(ph_inputContainer->size());
86
87 ATH_MSG_VERBOSE(
"Running on " << el_inputContainer->size() <<
" electrons"
88 " and " << ph_inputContainer->size() << " photons");
89
90 std::map<size_t,std::pair<const xAOD::Egamma*,IegammaCellRecoveryTool::Info>>
91 icegRecoveryInfo;
92
93
97
99 float aET = 0;
100 IegammaCellRecoveryTool::Info
info{};
103 << old_el->index() << " pT = " << old_el->pt());
104 }
107 float oiso = 9e9;
108 if (!old_el->isolation(oiso,t)) {
111 }
112 electron->setIsolation(oiso+aET, t);
113 }
114 std::vector<float> layerEnergies(4);
116
117 acce2(*electron) = layerEnergies[0]+layerEnergies[2];
118 acce3(*electron) = layerEnergies[1]+layerEnergies[3];
119
120 acce2b(*electron) = layerEnergies[0];
121 acce3b(*electron) = layerEnergies[1];
122 acce2e(*electron) = layerEnergies[2];
123 acce3e(*electron) = layerEnergies[3];
124
126 icegRecoveryInfo[old_el->caloCluster()->index()] =
127 std::make_pair(old_el,info);
128 }
129 }
130 }
131
135
137 float aET = 0;
138 IegammaCellRecoveryTool::Info
info{};
141 << old_ph->index() << " pT = " << old_ph->pt());
142 }
145 float oiso = 9e9;
146 if (!old_ph->isolation(oiso,t)) {
149 }
150 photon->setIsolation(oiso+aET, t);
151 }
152 std::vector<float> layerEnergies(4);
154
155 acce2(*photon) = layerEnergies[0]+layerEnergies[2];
156 acce3(*photon) = layerEnergies[1]+layerEnergies[3];
157
158 acce2b(*photon) = layerEnergies[0];
159 acce3b(*photon) = layerEnergies[1];
160 acce2e(*photon) = layerEnergies[2];
161 acce3e(*photon) = layerEnergies[3];
162
164 icegRecoveryInfo[old_ph->caloCluster()->index()] =
165 std::make_pair(old_ph,info);
166 }
167 }
168 }
169
170
174 }
175
176
177
179
180
181 SG::ReadCondHandle<CaloDetDescrManager> caloDetDescrMgrHandle{
183 };
185 const CaloDetDescrManager*
mgr = *caloDetDescrMgrHandle;
186
187 static const std::vector<xAOD::CaloCluster::CaloSample> caloSam{
188 CaloSampling::EMB2, CaloSampling::EMB3,
189 CaloSampling::EME2, CaloSampling::EME3 };
190
191 SG::ReadHandle<xAOD::CaloClusterContainer> egcl_inputContainer(
m_egClusInputKey,ctx);
192
193 SG::WriteHandle<CaloClusterCellLinkContainer> egcl_CellLinkContainer(
196 std::make_unique<CaloClusterCellLinkContainer>()));
197
198 SG::WriteHandle<xAOD::CaloClusterContainer> egcl_outputContainer(
m_egClusOutputKey,ctx);
199 ATH_CHECK(egcl_outputContainer.record(std::make_unique<xAOD::CaloClusterContainer>(),
200 std::make_unique<xAOD::CaloClusterAuxContainer>()));
201
203 egClusters->
reserve(egcl_inputContainer->size());
204
207 egClusters->
push_back(std::make_unique<xAOD::CaloCluster>());
208 *cluster=*old_egcl;
209
211 <<
" indices " << old_egcl->index() <<
" " << cluster->
index());
212
213 size_t index = old_egcl->index();
214 std::vector<const CaloCell*>
cc;
215 if (icegRecoveryInfo.find(index) != icegRecoveryInfo.end()) {
216 cc = icegRecoveryInfo[
index].second.addedCells;
217 } else {
219 " for cluster with index " << index);
220 return StatusCode::FAILURE;
221 }
222
223 bool doAddCell_condition1 =
cc.size() > 0;
225 float addedE2 = icegRecoveryInfo[
index].second.eCells[0];
226 bool doAddCell_condition2 = addedE2 > 0 ||
227 addedE2 + old_egcl->energyBE(2) > 0;
228 if (!doAddCell_condition2) {
230 "Cluster should be corrected, but the additional energy in S2 "
231 << addedE2 << " is too negative w.r.t. original one " <<
232 old_egcl->energyBE(2));
233 }
234 if (doAddCell_condition1 && doAddCell_condition2) {
237
239 CaloClusterCellLink::const_iterator cellItr = cellLinks->
begin();
240 CaloClusterCellLink::const_iterator cellEnd = cellLinks->
end();
241 for (; cellItr != cellEnd; ++cellItr) {
243 <<
" e = " << cellItr->
e());
244 }
245 const CaloClusterCellLink* ocellLinks = old_egcl->getCellLinks();
246 cellItr = ocellLinks->
begin();
247 cellEnd = ocellLinks->
end();
248 for (; cellItr != cellEnd; ++cellItr) {
250 <<
" e = " << cellItr->
e());
251 }
252
253 const CaloCellContainer* inputcells =
255 for (const auto *cell : cc) {
256 int cindex = inputcells->
findIndex(
cell->caloDDE()->calo_hash());
258 }
260 << cellLinks->
size());
261 cellItr = cellLinks->
begin();
262 cellEnd = cellLinks->
end();
263 for (; cellItr != cellEnd; ++cellItr) {
266 <<
" e = " << cellItr->
e());
267 }
269
271
275
282 }
288
290
292 *eg).isFailure()) {
294 }
295 }
296 }
298 ctx,
299 egcl_outputContainer,
300 egcl_CellLinkContainer);
305 }
306
307 return StatusCode::SUCCESS;
308}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
virtual double e() const override final
get energy (data member) (synonym to method energy()
weight_t weight() const
Accessor for weight associated to this cell.
const CaloCellContainer * getCellContainer() const
Method to access underlying cell container.
const_iterator end() const
const end method
size_t size() const
size method
const_iterator begin() const
const begin method
static void calculateKine(xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
Helper class to calculate cluster kinematics based on cells.
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_t index() const
Return the index of this element within its container.
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_egClusCellLinkOutputKey
Key of the output cluster container cell links: name taken from containter name; only dummy configura...
Gaudi::Property< bool > m_ambiguityFix
correct ambiguity links ?
void getLayerE(std::vector< const CaloCell * > &cells, std::vector< float > &lE) const
StatusCode getCorrectionC(const xAOD::Egamma *eg, float &aET, IegammaCellRecoveryTool::Info &info) const
ServiceHandle< IegammaMVASvc > m_MVACalibSvc
Handle to the MVA calibration service.
SG::WriteHandleKey< xAOD::ElectronContainer > m_electronOutputKey
Name of the electron output collection.
ToolHandle< IegammaSwTool > m_clusterCorrectionTool
Tool to handle cluster corrections.
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_egClusOutputKey
Name of the egamma cluster output collection.
void rebuildLink(xAOD::EgammaContainer *egC, xAOD::CaloClusterContainer *egclC, const EventContext &ctx) const
SG::ReadHandleKey< xAOD::PhotonContainer > m_photonInputKey
Name of the photon input collection.
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronInputKey
Name of the electron input collection.
SG::WriteHandleKey< xAOD::PhotonContainer > m_photonOutputKey
Name of the photon output collection.
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_egClusInputKey
Name of the egamma cluster input collection.
Gaudi::Property< bool > m_correctCluster
correct also layer energies ?
Gaudi::Property< bool > m_tpetcFix
correct topoetcone isolation ?
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
Key for calo detector description manager.
void setRawEta(flt_t)
Set for signal state UNCALIBRATED.
void setAltPhi(flt_t)
Set for signal state ALTCALIBRATED.
void setRawPhi(flt_t)
Set for signal state UNCALIBRATED.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
void setRawE(flt_t)
Set Energy for signal state UNCALIBRATED.
virtual double eta() const
The pseudorapidity ( ) of the particle.
void setAltEta(flt_t)
Set for signal state ALTCALIBRATED.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
CaloClusterCellLink * getOwnCellLinks()
Get a pointer to the owned CaloClusterCellLink object (non-const version)
void setAltE(flt_t)
Set Energy for signal state ALTCALIBRATED.
bool addCell(const unsigned index, const double weight)
Method to add a cell to the cluster (Beware: Kinematics not updated!)
void calculate(xAOD::Electron &electron)
void doAmbiguityLinks(const EventContext &ctx, DataVector< SrcT > *srcContainer, DataVector< DestT > *destContainer)
void fillPositionsInCalo(xAOD::CaloCluster *cluster, const CaloDetDescrManager &mgr)
Function to decorate the calo cluster with position variables.
void refineEta1Position(xAOD::CaloCluster *cluster, const CaloDetDescrManager &mgr)
function to refine position in eta1
bool isBarrel(const xAOD::Egamma *eg)
return true if the cluster is in the barrel
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
@ topoetcone20
Topo-cluster ET-sum.
static const char * toCString(IsolationConeSize conesize)
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Egamma_v1 Egamma
Definition of the current "egamma version".
Photon_v1 Photon
Definition of the current "egamma version".
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Electron_v1 Electron
Definition of the current "egamma version".