27 ISvcLocator* pSvcLocator)
58 return StatusCode::SUCCESS;
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");
76 ATH_CHECK(el_outputContainer.
record(std::make_unique<xAOD::ElectronContainer>(),
77 std::make_unique<xAOD::ElectronAuxContainer>()));
79 ATH_CHECK(ph_outputContainer.
record(std::make_unique<xAOD::PhotonContainer>(),
80 std::make_unique<xAOD::PhotonAuxContainer>()));
84 electrons->reserve(el_inputContainer->size());
85 photons->
reserve(ph_inputContainer->size());
87 ATH_MSG_VERBOSE(
"Running on " << el_inputContainer->size() <<
" electrons"
88 " and " << ph_inputContainer->size() <<
" photons");
90 std::map<size_t,std::pair<const xAOD::Egamma*,IegammaCellRecoveryTool::Info>>
95 xAOD::Electron* electron = electrons->push_back(std::make_unique<xAOD::Electron>());
103 << old_el->index() <<
" pT = " << old_el->pt());
108 if (!old_el->isolation(oiso,t)) {
112 electron->setIsolation(oiso+aET, t);
114 std::vector<float> layerEnergies(4);
115 getLayerE(info.addedCells,layerEnergies);
117 acce2(*electron) = layerEnergies[0]+layerEnergies[2];
118 acce3(*electron) = layerEnergies[1]+layerEnergies[3];
120 acce2b(*electron) = layerEnergies[0];
121 acce3b(*electron) = layerEnergies[1];
122 acce2e(*electron) = layerEnergies[2];
123 acce3e(*electron) = layerEnergies[3];
126 icegRecoveryInfo[old_el->caloCluster()->index()] =
127 std::make_pair(old_el,info);
141 << old_ph->index() <<
" pT = " << old_ph->pt());
146 if (!old_ph->isolation(oiso,t)) {
150 photon->setIsolation(oiso+aET, t);
152 std::vector<float> layerEnergies(4);
153 getLayerE(info.addedCells,layerEnergies);
155 acce2(*photon) = layerEnergies[0]+layerEnergies[2];
156 acce3(*photon) = layerEnergies[1]+layerEnergies[3];
158 acce2b(*photon) = layerEnergies[0];
159 acce3b(*photon) = layerEnergies[1];
160 acce2e(*photon) = layerEnergies[2];
161 acce3e(*photon) = layerEnergies[3];
164 icegRecoveryInfo[old_ph->caloCluster()->index()] =
165 std::make_pair(old_ph,info);
187 static const std::vector<xAOD::CaloCluster::CaloSample> caloSam{
188 CaloSampling::EMB2, CaloSampling::EMB3,
189 CaloSampling::EME2, CaloSampling::EME3 };
196 std::make_unique<CaloClusterCellLinkContainer>()));
199 ATH_CHECK(egcl_outputContainer.
record(std::make_unique<xAOD::CaloClusterContainer>(),
200 std::make_unique<xAOD::CaloClusterAuxContainer>()));
203 egClusters->
reserve(egcl_inputContainer->size());
207 egClusters->
push_back(std::make_unique<xAOD::CaloCluster>());
211 <<
" indices " << old_egcl->index() <<
" " << cluster->index());
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;
219 " for cluster with index " <<
index);
220 return StatusCode::FAILURE;
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));
234 if (doAddCell_condition1 && doAddCell_condition2) {
241 for (; cellItr != cellEnd; ++cellItr) {
243 <<
" e = " << cellItr->
e());
246 cellItr = ocellLinks->
begin();
247 cellEnd = ocellLinks->
end();
248 for (; cellItr != cellEnd; ++cellItr) {
250 <<
" e = " << cellItr->
e());
255 for (
const auto *cell : cc) {
256 int cindex = inputcells->
findIndex(cell->caloDDE()->calo_hash());
260 << cellLinks->
size());
261 cellItr = cellLinks->
begin();
262 cellEnd = cellLinks->
end();
263 for (; cellItr != cellEnd; ++cellItr) {
266 <<
" e = " << cellItr->
e());
299 egcl_outputContainer,
300 egcl_CellLinkContainer);
307 return StatusCode::SUCCESS;
313 std::vector<float>& lE)
const {
317 if (maxECell.
sc == StatusCode::FAILURE) {
322 info.etamax = maxECell.
etaCell;
323 info.phimax = maxECell.
phiCell;
327 double aE2 = info.eCells[0];
328 double aE3 = info.eCells[1];
332 <<
" added Energies in Layer 2 " << aE2 <<
" and 3 " << aE3
333 <<
" cluster index = " << clus->index());
334 double iceta = 1./std::cosh(clus->
etaBE(2));
335 aET = (aE2+aE3)*iceta;
339 << lE[0] <<
" " << lE[1] <<
" "
340 << lE[2] <<
" " << lE[3]);
342 return StatusCode::SUCCESS;
352 if (maxECell.
sc == StatusCode::FAILURE) {
356 info.etamax = maxECell.
etaCell;
357 info.phimax = maxECell.
phiCell;
361 double aE2 = info.eCells[0];
362 double aE3 = info.eCells[1];
366 <<
" added Energies in Layer 2 " << aE2 <<
" and 3 " << aE3
367 <<
" cluster index = " << clus->index());
368 double iceta = 1./std::cosh(clus->
etaBE(2));
369 aET = (aE2+aE3)*iceta;
370 return StatusCode::SUCCESS;
375 std::vector<const CaloCell*>& cells,
376 std::vector<float>& lE)
const
378 if (lE.size() != 4) {
382 for (
auto *cell : cells) {
383 int layer = cell->caloDDE()->getSampling();
384 if (layer == CaloSampling::EMB2)
386 else if (layer == CaloSampling::EMB3)
388 else if (layer == CaloSampling::EME2)
390 else if (layer == CaloSampling::EME3)
398 const EventContext& ctx)
const {
405 *egclContainer, eg->caloCluster()->index(), ctx);
406 std::vector<ElementLink<xAOD::CaloClusterContainer>> egClustersLink{
408 eg->setCaloClusterLinks(egClustersLink);
414 if (!eg->setIsolationCaloCorrection(
419 << eg->pt() <<
" " << eg->eta());
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
Container class for CaloCell.
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()
const_iterator to loop over cells belonging to a cluster
weight_t weight() const
Accessor for weight associated to this cell.
Bookkeeping of cells that make up a cluster Simplified replacement for CaloCellLink,...
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).
This class provides the client interface for accessing the detector description information common to...
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.
ElementLink implementation for ROOT usage.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
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
StatusCode execute(const EventContext &ctx) const override final
ServiceHandle< IegammaMVASvc > m_MVACalibSvc
Handle to the MVA calibration service.
SG::WriteHandleKey< xAOD::ElectronContainer > m_electronOutputKey
Name of the electron output collection.
StatusCode getCorrection(const xAOD::Egamma *eg, float &aET, std::vector< float > &lECl) const
ToolHandle< IegammaCellRecoveryTool > m_egammaCellRecoveryTool
Pointer to the egammaCellRecoveryTool.
ToolHandle< IegammaSwTool > m_clusterCorrectionTool
Tool to handle cluster corrections.
SG::ReadHandleKey< CaloCellContainer > m_CaloCellsKey
Name of the calo cell container.
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.
StatusCode initialize() override final
ToolHandle< CP::IIsolationCorrectionTool > m_IsoLeakCorrectionTool
Handle to the isolation leakage correction tool.
Gaudi::Property< bool > m_correctCluster
correct also layer energies ?
Gaudi::Property< bool > m_tpetcFix
correct topoetcone isolation ?
egammaAODFixes(const std::string &name, ISvcLocator *pSvcLocator)
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.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
bool addCell(const unsigned index, const double weight)
Method to add a cell to the cluster (Beware: Kinematics not updated!).
virtual Type::ObjectType type() const override=0
The type of the object as a simple enumeration, remains pure virtual in e/gamma.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
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
@ Photon
The object is a photon.
@ Electron
The object is an electron.
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)
@ ptCorrection
egamma ptcorrection
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.
EgammaContainer_v1 EgammaContainer
Definition of the current "egamma container version".
Electron_v1 Electron
Definition of the current "egamma version".