13#include "CaloGeoHelpers/CaloSampling.h"
23#include "GaudiKernel/ThreadLocalContext.h"
45#if defined(SIMULATIONBASE) || defined(XAOD_ANALYSIS)
59 declareInterface<ICaloCellIsolationTool>(
this);
60 declareInterface<ICaloTopoClusterIsolationTool>(
this);
61 declareInterface<INeutralEFlowIsolationTool>(
this);
89 return StatusCode::FAILURE;
95 return StatusCode::FAILURE;
103 return StatusCode::FAILURE;
124 if (filename.empty()){
126 return StatusCode::FAILURE ;
128 ATH_MSG_INFO(
"Path found for pileup correction = "<< filename);
129 std::unique_ptr<TFile> f(TFile::Open(filename.c_str(),
"READ"));
137 if (filename.empty()){
139 return StatusCode::FAILURE ;
141 ATH_MSG_INFO(
"Path found for mc additional correction of pileup correction = "<< filename);
142 std::unique_ptr<TFile> g(TFile::Open(filename.c_str(),
"READ"));
151 return StatusCode::SUCCESS;
156 return StatusCode::SUCCESS;
162 const std::vector<Iso::IsolationType>& cones,
180 derefMap[ip] = &particle;
183 if (particle.type() == Type::Muon)
187 const Muon*
muon =
dynamic_cast<const Muon*
>(&particle);
194 ATH_MSG_WARNING(
"CaloCellIsolation only supported for Muons and Egamma");
202 const std::vector<Iso::IsolationType>& cones,
206 if ( cones.empty() ) {
212 if (particle.type() == Type::Muon)
222 derefMap[ip] = &particle;
232 ATH_MSG_WARNING(
"CaloTopoClusterIsolation only supported for TrackParticles and Egamma");
240 const std::vector<Iso::IsolationType>& cones,
245 if (particle.type() == Type::Muon)
255 derefMap[ip] = &particle;
265 ATH_MSG_WARNING(
"FlowElementIsolation only supported for Egamma and TrackParticle");
276 const std::vector<Iso::IsolationType>& isoTypes,
const CaloCorrection& corrlist
278 ,
double coneCoreSize
282 if( isoTypes.empty() ) {
287 unsigned int typesize = isoTypes.size();
300 ATH_MSG_WARNING(
"Unsupported isolation flavour passed, cannot calculate isolation " <<
301 static_cast<int>(theFlavour));
308 const std::vector<Iso::IsolationType>& isoTypes,
314 if( isoTypes.empty() ) {
319 unsigned int typesize = isoTypes.size();
322 std::vector<float> coneSizes;
323 coneSizes.resize(isoTypes.size());
324 for (
unsigned int is = 0; is < isoTypes.size(); is++)
337 ATH_MSG_WARNING(
"Unsupported isolation flavour passed, cannot calculate isolation " <<
static_cast<int>(theFlavour));
345 ATH_MSG_WARNING(
"Could not compute core cell energy for egamma in etcone");
360 const std::vector<Iso::IsolationType>& isoTypes,
363 double coneCoreSize)
const
366 if( isoTypes.empty() ) {
371 unsigned int typesize = isoTypes.size();
374 std::vector<float> coneSizes;
375 coneSizes.reserve(isoTypes.size());
377 for(
auto isoType : isoTypes ){
395 ATH_MSG_WARNING(
"Could not compute core cell energy for egamma in topoetcone");
402 ATH_MSG_WARNING(
"Could not apply pt correction to topoetcone isolation");
417 const std::vector<Iso::IsolationType>& isoTypes,
419 double coneCoreSize)
const
422 if( isoTypes.empty() ) {
427 ATH_MSG_WARNING(
"Only EM scale is supported by neutralEflowIsolation");
431 unsigned int typesize = isoTypes.size();
434 std::vector<float> coneSizes;
435 coneSizes.reserve(isoTypes.size());
437 for(
auto isoType : isoTypes ){
458 ATH_MSG_WARNING(
"Could not compute core cell energy for egamma in neflowisol");
469 std::string
type =
"PFlow";
482 const std::vector<Iso::IsolationType>& isoTypes,
488 if( isoTypes.empty() ) {
493 unsigned int typesize = isoTypes.size();
496 std::vector<float> coneSizes;
497 coneSizes.reserve(isoTypes.size());
499 for(
auto isoType : isoTypes ){
506 ATH_MSG_WARNING(
"TrackParticle eta = " << tp.
eta() <<
", phi = " << tp.
phi() <<
" not updated from extraplation!");
508 ATH_MSG_DEBUG(
"TrackParticle eta = " << tp.
eta() <<
", phi = " << tp.
phi() <<
", extrap eta = " <<
eta <<
", phi = " <<
phi);
519 ATH_MSG_WARNING(
"Could not compute muon core energy (cells) from neflowisol");
524 std::string
type =
"PFlow";
526 ATH_MSG_WARNING(
"Could not apply ED correction to eflow isolation for muon");
536 static const SG::AuxElement::ConstAccessor< char > Decorated(
"caloExt_Decorated");
537 static const SG::AuxElement::ConstAccessor< float >
Eta(
"caloExt_eta");
538 static const SG::AuxElement::ConstAccessor< float >
Phi(
"caloExt_phi");
539 if(Decorated.isAvailable(*tp) && Decorated(*tp)){
546 const Muon* mu =
dynamic_cast<const Muon*
>(derefMap[tp]);
548 const auto *cluster = mu->cluster();
550 float etaT = 0, phiT = 0, dphiT = 0.;
552 for(
unsigned int i=0; i<CaloSampling::Unknown; i++)
555 if(!cluster->hasSampling(s))
continue;
556 ATH_MSG_DEBUG(
"Sampling: " << i <<
"eta-phi (" << cluster->etaSample(s) <<
", " << cluster->phiSample(s) <<
")");
557 etaT += cluster->etaSample(s);
559 phiT = cluster->phiSample(s);
568 phi = phiT + dphiT/nSample;
583 std::unique_ptr<Trk::CaloExtension> caloExtensionUPtr;
588 m_caloExtTool->caloExtension(Gaudi::Hive::currentContext(), *tp);
589 caloExtension = caloExtensionUPtr.get();
594 if (!cache.isValid())
607 if(!intersections.empty()){
609 for (
unsigned int i = 0; i < intersections.size(); ++i){
612 <<
" eta-phi (" << point.eta() <<
", " << point.phi() <<
")");
615 avePoint = (1./intersections.size())*avePoint;
616 eta = avePoint.eta();
617 phi = avePoint.phi();
624 ATH_MSG_WARNING("Calo extension can not be obtained!!!");
631 const std::vector<Iso::IsolationType>& isoTypes,
636 if( isoTypes.empty() ) {
641 unsigned int typesize = isoTypes.size();
643 std::vector<float> coneSizes;
644 coneSizes.reserve(isoTypes.size());
646for(
auto isoType : isoTypes ){
653 ATH_MSG_DEBUG(
"TrackParticle eta = " << tp.
eta() <<
", phi = " << tp.
phi() <<
", extrap eta = " <<
eta <<
", phi = " <<
phi);
664 ATH_MSG_WARNING(
"Could not compute muon core energy (cells) from topoetcone");
678 const std::vector<Iso::IsolationType>& isoTypes,
690 std::vector<double> conesf;
691 double maxConeSize = -1;
692 for(
auto isoType : isoTypes ){
694 ATH_MSG_WARNING(
"Unsupported isolation type passed, cannot calculate isolation " <<
static_cast<int>(isoType));
698 conesf.push_back(cone);
699 if(cone>maxConeSize) maxConeSize = cone;
703 const double coreConeDR = coneCoreSize;
705 if(doCoreCone && maxConeSize<coreConeDR) maxConeSize = coreConeDR;
708 ATH_MSG_DEBUG(
"calculating etcone for # " << conesf.size() <<
" cones");
709 std::unique_ptr<const Rec::ParticleCellAssociation> association=
m_assoTool->particleCellAssociation(tp,maxConeSize,container);
711 ATH_MSG_DEBUG(
"failed to obtain the ParticleCellAssociation");
716 selector.preSelectAction(association->caloExtension());
717 ATH_MSG_DEBUG(
"looping over cells " << association->data().size());
718 for(
unsigned int i=0; i<conesf.size(); i++){
720 selector.setConeSize(conesf[i]);
721 for (
const auto *aCell : association->data()){
722 if( !selector.select(*aCell) )
continue;
723 if (
m_ExcludeTG3 && CaloCell_ID::TileGap3 == aCell->caloDDE()->getSampling())
continue;
726 result.etcones[i] = totE;
727 ATH_MSG_DEBUG(
"etcone raw: coneSize = " << conesf[i] <<
"; etcone = " << result.etcones[i]);
735 selector.setConeSize(coreConeDR);
736 for (
const auto *aCell : association->data()){
737 if( !selector.select(*aCell) )
continue;
738 if (
m_ExcludeTG3 && CaloCell_ID::TileGap3 == aCell->caloDDE()->getSampling())
continue;
741 std::map<Iso::IsolationCorrectionParameter,float> corecorr;
748 if(result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreCone))){
750 ATH_MSG_DEBUG(
"Applying coreCone correction for trackParticle etcone isolation.");
751 for(
unsigned int i=0;i<result.etcones.size();++i ) {
752 result.etcones[i] -= ecore;
753 ATH_MSG_DEBUG(
"i: " << i <<
" cone [before] " << result.etcones[i]+ecore <<
" cone [after] " << result.etcones[i]);
760 result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreMuon))){
771 const std::vector<Iso::IsolationType>& isoTypes,
775 std::vector<double> conesf;
776 double maxConeSize = -1;
777 for(
auto isoType : isoTypes ){
779 ATH_MSG_WARNING(
"Unsupported isolation type passed, cannot calculate isolation " <<
static_cast<int>(isoType));
783 conesf.push_back(cone);
784 if(cone>maxConeSize) maxConeSize = cone;
787 const double coreConeDR = coneCoreSize;
789 if(doCoreCone && maxConeSize<coreConeDR) maxConeSize = coreConeDR;
794 for(
unsigned int i=0; i<conesf.size(); i++) result.etcones[i] = 0;
798 std::map<Iso::IsolationCorrectionParameter,float> corecorr;
804 if(result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreCone))){
806 ATH_MSG_DEBUG(
"Applying coreCone correction for trackParticle etcone isolation.");
807 for(
unsigned int i=0;i<result.etcones.size();++i ) {
808 result.etcones[i] -= ecore;
809 ATH_MSG_DEBUG(
"i: " << i <<
" cone [before] " << result.etcones[i]+ecore <<
" cone [after] " << result.etcones[i]);
817 ATH_MSG_DEBUG(
"calculating etcone for # " << conesf.size() <<
" cones");
819 selector.preSelectAction(*muonCluster);
821 for(
unsigned int i=0; i<conesf.size(); i++){
823 selector.setConeSize(conesf[i]);
825 for(; cell_itr!=muonCluster->
end(); ++cell_itr){
826 if( !selector.select(**cell_itr) )
continue;
827 if (
m_ExcludeTG3 && CaloCell_ID::TileGap3 == (*cell_itr)->caloDDE()->getSampling())
continue;
828 totE += (*cell_itr)->et();
830 result.etcones[i] = totE;
831 ATH_MSG_DEBUG(
"etcone raw: coneSize = " << conesf[i] <<
"; etcone = " << result.etcones[i]);
838 selector.setConeSize(coreConeDR);
840 for(; cell_itr!=muonCluster->
end(); ++cell_itr){
841 if( !selector.select(**cell_itr) )
continue;
842 if (
m_ExcludeTG3 && CaloCell_ID::TileGap3 == (*cell_itr)->caloDDE()->getSampling())
continue;
843 totE += (*cell_itr)->et();
845 std::map<Iso::IsolationCorrectionParameter,float> corecorr;
852 if(result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreCone))){
854 ATH_MSG_DEBUG(
"Applying coreCone correction for trackParticle etcone isolation.");
855 for(
unsigned int i=0;i<result.etcones.size();++i ) {
856 result.etcones[i] -= ecore;
857 ATH_MSG_DEBUG(
"i: " << i <<
" cone [before] " << result.etcones[i]+ecore <<
" cone [after] " << result.etcones[i]);
864 result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreMuon))){
866 xAOD::Muon::TrackParticleType::Primary :
867 xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
878 const std::vector<Iso::IsolationType>& isoTypes,
880 if( isoTypes.empty() ) {
888 std::vector<float> coneSizes; coneSizes.resize(3);
889 std::vector<float> coneSizesSquared; coneSizesSquared.resize(3);
890 for (
unsigned int i = 0; i < isoTypes.size(); i++) {
893 coneSizesSquared[i] = dR*dR;
900 std::vector<CaloCell_ID::SUBCALO> Vec_EMCaloEnums;
904 CaloCellList EMccl(caloDDMgr,container, Vec_EMCaloEnums);
906 std::vector<CaloCell_ID::SUBCALO> Vec_HadCaloEnums;
910 CaloCellList HADccl(caloDDMgr,container, Vec_HadCaloEnums);
915 for (
unsigned int n=0; n< coneSizes.size(); n++)
916 if (coneSizes[n] > Rmax) Rmax = coneSizes[n];
921 for (
const auto *it: EMccl) {
922 double etacel=it->eta();
923 double phicel=it->phi();
925 double deleta =
eta-etacel;
927 double drcel2 = (deleta*deleta) + (delphi*delphi);
929 for (
unsigned int i = 0; i < coneSizes.size(); i++) {
930 if (drcel2 < coneSizesSquared[i])
931 result.etcones[i] += it->et();
939 for (
const auto *it: HADccl) {
941 if (
m_ExcludeTG3 && CaloCell_ID::TileGap3 == it->caloDDE()->getSampling()) {
947 double etacel = it->eta();
948 double phicel = it->phi();
950 double deleta =
eta-etacel;
952 double drcel2 = (deleta*deleta) + (delphi*delphi);
954 for (
unsigned int i = 0; i < coneSizes.size(); i++) {
955 if (drcel2 < coneSizesSquared[i])
956 result.etcones[i] += it->et();
965 std::vector<float>& coneSizes,
970 double coneCoreSize)
const
974 auto max_cone_iter=std::max_element(coneSizes.begin(), coneSizes.end());
975 float max_cone= (*max_cone_iter);
976 std::vector<const CaloCluster*> clusts;
985 if(!particlesInCone(
eta,
phi,max_cone,clusts))
989 auto clItr = container->begin();
990 auto clItrE = container->end();
991 for(; clItr != clItrE; ++clItr){
992 clusts.push_back (*clItr);
1015 std::vector<float>& coneSizes,
1018 double coneCoreSize,
1019 const Egamma *egObj)
const
1023 auto max_cone_iter=std::max_element(coneSizes.begin(), coneSizes.end());
1024 float max_cone = (*max_cone_iter);
1025 std::vector<const FlowElement*> clusts;
1027#ifndef XAOD_ANALYSIS
1037 auto clItr = container->begin();
1038 auto clItrE = container->end();
1039 for(; clItr != clItrE; ++clItr){
1040 clusts.push_back (*clItr);
1064 std::vector<float>& coneSizes,
1065 const std::vector<const CaloCluster*>& clusts)
const
1072 if(
et <= 0 || fabs(cl->eta()) > 7.0)
continue;
1075 float tilegap3_et = cl->eSample(CaloSampling::TileGap3)*st;
1079 float dEta = cl->eta()-
eta;
1080 float dr=sqrt(dPhi*dPhi+ dEta*dEta);
1082 for (
unsigned int i = 0; i < coneSizes.size(); i++) {
1083 if (dr < coneSizes[i]) {
1084 ATH_MSG_DEBUG(
"Adding topo " << cl <<
" dR = " << dr <<
" et of a topo clust et = " <<
et
1085 <<
" (calibrated " << cl->pt() <<
", tilegap et = " << tilegap3_et <<
")");
1086 result.etcones[i] +=
et;
1098 std::vector<float>& coneSizes,
1099 const std::vector<const FlowElement*>& clusts)
const
1105 float et = cl->pt();
1106 if (
et <= 0 || fabs(cl->eta()) > 7.0)
continue;
1109 float dEta = cl->eta()-
eta;
1110 float dR = sqrt(dPhi*dPhi+ dEta*dEta);
1112 for (
unsigned int i = 0; i < coneSizes.size(); i++) {
1113 if (dR < coneSizes[i]) {
1114 result.etcones[i] +=
et;
1124 const std::vector<Iso::IsolationType>& isoTypes,
1134 if ((gotIso && fabs(coreV) < 1
e-3) || !gotIso) {
1135#ifndef XAOD_ANALYSIS
1138 float eraw57=0.,
eta=0.;
1141 double seedEta = cleg->
eta0(), seedPhi = cleg->
phi0();
1147 egcCloneFor57.get()).isSuccess())
1151 if(egcCloneFor57->size()==0){
1156 eraw57 = egcCloneFor57->e();
1158 coreV = eraw57/cosh(
eta);
1159 ATH_MSG_DEBUG(
"Number of cells in 5x7 " << egcCloneFor57->size()
1160 <<
" seed eta,phi " << cleg->
eta0() <<
" " << cleg->
phi0()
1161 <<
" eraw = " << eraw57 <<
" etraw = " << coreV
1169 std::map<Iso::IsolationCorrectionParameter,float> corecorr;
1173 if (result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::core57cells))) {
1174 for (
unsigned int i = 0; i < isoTypes.size(); i++){
1175 result.etcones[i] -= coreV;
1184 float dEtaMax_core,
float dPhiMax_core,
float dR2Max_core,
1185 const std::vector<const CaloCluster*>& clusts,
bool onlyEM,
1187 const Egamma* egObj)
const
1189 ATH_MSG_DEBUG(
"In CaloIsolationTool::correctIsolationEnergy_TopoCore");
1192 float areacore = -999.;
1193 if (dEtaMax_core>0 && dPhiMax_core>0) areacore = 4*dEtaMax_core*dPhiMax_core;
1194 else if (dR2Max_core>0) areacore =
M_PI*dR2Max_core;
1195 double topoCore(0.);
1197 ATH_MSG_DEBUG(
"cl: eta " << cl->eta() <<
" phi " << cl->phi()
1200 <<
" cal E " << cl->e());
1203 if(dEtaMax_core>0 && fabs(dPhi) > dPhiMax_core)
continue;
1204 float dEta = cl->eta()-
eta;
1205 if(dPhiMax_core>0 && fabs(dEta) > dEtaMax_core)
continue;
1206 if(dR2Max_core>0 && dPhi*dPhi+dEta*dEta > dR2Max_core)
continue;
1207 ATH_MSG_DEBUG(
"dist: dPhi " << dPhi <<
" dEta " << dEta <<
" dR2 " << dPhi*dPhi+dEta*dEta);
1211 if(
et <= 0 || fabs(cl->eta()) > 7.0)
continue;
1216 if (fabs(ettg3) > 1)
1221 if(onlyEM && !fwdClus){
1222 double eEM = cl->energyBE(0)+cl->energyBE(1)+cl->energyBE(2)+cl->energyBE(3);
1229 ATH_MSG_DEBUG(
"adding in core et: " <<
et <<
" (em frac = " << emfrac <<
" dR = " << sqrt(dPhi*dPhi+dEta*dEta) <<
") total " << topoCore);
1232 double topoCoreSC(0.);
1234 double topoCoreSCem = 0;
1237 for (
unsigned int ic = 0; ic < assocClus.size(); ic++) {
1241 ATH_MSG_DEBUG(
"Adding topo " << ic <<
" ptr = " << cl <<
" contrib, pt = " << cl->pt()
1243 <<
" eta,phi = " << cl->eta() <<
" " << cl->phi()
1246 <<
" nCells = " << cluster_size(cl)
1251 topoCoreSCem -= ettg3;
1256 double eEM = cl->energyBE(0)+cl->energyBE(1)+cl->energyBE(2)+cl->energyBE(3);
1265 ATH_MSG_DEBUG(
"Including " << topoCore <<
" only em, no tg3 " << topoCoreSCem <<
" calibrated " << test <<
" in the core transverse energy of the super cluster egamma object made of "
1266 << assocClus.size() <<
" clusters with corresponding pT = " << egObj->
pt()
1267 <<
" cluster pT = " << egObj->
caloCluster()->
pt() <<
" cluster un cal pT = "
1269 <<
" nCells = " << cluster_size(egObj->
caloCluster())
1275 std::map<Iso::IsolationCorrectionParameter,float> corecorrSC;
1282 ATH_MSG_DEBUG(
"core energy, std = " << topoCore <<
" topo-assoc (full) = " << topoCoreSC <<
" topo-assoc (only em, no tg3) = " << topoCoreSCem);
1284 std::map<Iso::IsolationCorrectionParameter,float> corecorr;
1287 result.coreCorrections[
Iso::coreCone] = std::move(corecorr);
1291 if (result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreCone)) ||
1292 result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreConeSC))) {
1294 if (result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreCone)) &&
1295 !result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreConeSC)))
1297 else if (!result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreCone)) &&
1298 result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreConeSC)))
1299 toSub = topoCoreSCem;
1307 for (
unsigned int i = 0; i < result.etcones.size(); i++){
1308 result.etcones[i] -= toSub;
1309 ATH_MSG_DEBUG(
"TopoCore correction i=" << i <<
" cone [before] " << result.etcones[i]+toSub <<
" cone [after] " << result.etcones[i]);
1318 float detaMax,
float dphiMax,
1320 const std::vector<const FlowElement*>& clusts,
1321 bool onlyEM,
const Egamma* egObj)
const
1324 float pflowCore(0.);
1326 ATH_MSG_DEBUG(
"pflo: eta " << cl->eta() <<
" phi " << cl->phi() <<
" pt " << cl->pt() <<
" charge " << cl->charge());
1328 if (detaMax > 0 && fabs(dphi) > dphiMax)
continue;
1329 float deta = cl->eta()-
eta;
1330 if (dphiMax > 0 && fabs(deta) > detaMax)
continue;
1331 if (dR2Max > 0 && dphi*dphi+deta*deta > dR2Max)
continue;
1334 float et = cl->pt();
1335 if (
et <= 0 || fabs(cl->eta()) > 7.0)
continue;
1342 emfrac = std::min(1.,eEM / cl->e());
1349 ATH_MSG_DEBUG(
"pflow to be added to core: et = " <<
et <<
" (em frac = " << emfrac <<
"), total = " << pflowCore);
1353 float pflowCoreSC(0.);
1357 ATH_MSG_DEBUG(
"Number of associated neutral FE = " << fes.size());
1359 if (fe ==
nullptr) {
1363 ATH_MSG_DEBUG(
"asso pflo: eta " << fe->eta() <<
" phi " << fe->phi() <<
" pt " << fe->pt() <<
" charge " << fe->charge() <<
" index = " << fe->index());
1366 if (fe->index() == cl->index()) {
1373 ATH_MSG_DEBUG(
"asso pflo after vertex correction : eta " << afe->
eta() <<
" phi " << afe->
phi() <<
" pt " << afe->
pt());
1375 float et = afe->
pt();
1376 if (
et <= 0 || fabs(afe->
eta()) > 7.0)
continue;
1383 et -= allEne.at(17)/cosh(afe->
eta());
1387 for (
int i = 0; i <= 7; i++) eEM += allEne.at(i);
1388 double eAll = fe->e();
1390 eAll -= allEne.at(17);
1391 emfrac = std::min(1.,eEM / eAll);
1397 ATH_MSG_DEBUG(
"asso pflow to be added to core " << fe <<
" et = " <<
et <<
" (em frac = " << emfrac <<
"), total = " << pflowCoreSC);
1399 std::map<Iso::IsolationCorrectionParameter,float> corecorrSC;
1406 float areacore = -999.;
1407 if (detaMax > 0 && dphiMax > 0) areacore = 4*detaMax*dphiMax;
1408 else if (dR2Max > 0) areacore =
M_PI*dR2Max;
1410 std::map<Iso::IsolationCorrectionParameter,float> corecorr;
1413 result.coreCorrections[
Iso::coreCone] = std::move(corecorr);
1415 if (result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreCone))) {
1416 for (
unsigned int i = 0; i < result.etcones.size(); i++) {
1417 ATH_MSG_DEBUG(
"pflow, cone type " << i <<
", in cone " << result.etcones[i] <<
", subtracted " << result.etcones[i]-pflowCore);
1418 result.etcones[i] -= pflowCore;
1431 ATH_MSG_DEBUG(
"in CaloIsolationTool::correctIsolationEnergy_MuonCore ");
1435 auto muI = derefMap.find(&tp);
1437 if(muI!=derefMap.end()){
1440 ATH_MSG_WARNING(
"ET_Core of muon not found! coreMuon isolation correction will not be applied!!!");
1444 std::map<Iso::IsolationCorrectionParameter,float> corecorr;
1447 result.coreCorrections[
Iso::coreMuon] = std::move(corecorr);
1449 if (result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::coreMuon))) {
1450 for(
unsigned int i=0;i<result.etcones.size();++i ) {
1451 result.etcones[i] -= ecore;
1452 ATH_MSG_DEBUG(
"MuonCore i=" << i <<
" cone [before] " << result.etcones[i]+ecore <<
" cone [after] " << result.etcones[i]);
1461 const std::vector<Iso::IsolationType>& isoTypes)
const
1467 std::vector<float> corrvec;
1468 corrvec.resize(isoTypes.size(),0.);
1469 for (
unsigned int i = 0; i < isoTypes.size(); i++) {
1476 if (result.corrlist.calobitset.test(
static_cast<unsigned int>(
Iso::ptCorrection))) {
1477 result.etcones[i] -= corrvec[i];
1479 <<
", ptcorr = " << corrvec[i] <<
", isol pt corrected = " << result.etcones[i] );
1490 const std::vector<Iso::IsolationType>& isoTypes,
1492 const std::string&
type,
1496 std::vector<float> corrvec;
1497 corrvec.resize(isoTypes.size(),0.);
1501 if (
type ==
"PFlow") {
1503 }
else if (fwdClus !=
nullptr) {
1504 ATH_MSG_DEBUG(
"No pileup correction for forward electron isolation yet");
1519 ATH_MSG_WARNING(
"Cannot retrieve density " << esKey->
key() <<
" for isolation correction. No ED correction");
1525 std::map<xAOD::Iso::IsolationCorrectionParameter,float> ecore;
1527 if (result.corrlist.calobitset.test(
static_cast<unsigned int>(param))){
1528 if (
auto it = result.coreCorrections.find(param); it != result.coreCorrections.end()) {
1536 if (iter != ecore.end())
1539 for (
unsigned int i = 0; i < isoTypes.size(); i++) {
1541 float toSub = rho*(dR*dR*
M_PI - areacore);
1544 double areaCorr = 0;
1547 areaCorr = puZeta->second->Eval(std::abs(
eta));
1554 areaCorr -= puZetaMC->second->Eval(std::abs(
eta));
1556 ATH_MSG_WARNING(
"Requested refined eta dependent pileup correction for mc but no zeta correction provided " <<
Iso::toCString(isoTypes.at(i)));
1563 result.etcones[i] -= toSub;
1565 ATH_MSG_DEBUG(
"ED correction ("<<
type <<
")for size " << dR <<
" = " << toSub <<
" (areacore=" << areacore <<
")");
1574 unsigned int typesize) {
1576 result.corrlist = corrlist;
1577 result.coreCorrections.clear();
1578 result.noncoreCorrections.clear();
1579 result.etcones.resize(typesize,0.);
1586 const Muon*
muon =
dynamic_cast<const Muon*
>(&particle);
1590 xAOD::Muon::TrackParticleType::Primary :
1591 xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle);
1603 bool CaloIsolationTool::particlesInCone(
float eta,
float phi,
float dr, std::vector<const CaloCluster*>& output )
const {
1606 std::string m_caloClusterLocation =
"CaloCalTopoClusters";
1607 if(
evtStore()->retrieve(caloClusters, m_caloClusterLocation).isFailure()) {
1608 ATH_MSG_FATAL(
"Unable to retrieve " << m_caloClusterLocation );
1612 const float m_minPt = 1
e-3;
1615 for(
auto trk: *caloClusters){
1616 if(trk->pt()<m_minPt)
continue;
1618 float dEta =
eta-trk->eta();
1620 if(dr2<(dEta*dEta+dPhi*dPhi))
continue;
1621 output.push_back(trk);
1626 bool CaloIsolationTool::particlesInCone(
float eta,
float phi,
float dr, std::vector<const FlowElement*>& output )
const{
1629 std::string m_ClusterLocation =
"JetETMissNeutralParticleFlowObjects";
1630 if(
evtStore()->retrieve(Clusters,m_ClusterLocation).isFailure()) {
1635 const float m_minPt = 1
e-3;
1638 for(
auto trk: *Clusters){
1639 if(trk->pt()<m_minPt)
continue;
1642 if(dr2<(dEta*dEta+dPhi*dPhi))
continue;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
Helper class to provide constant type-safe access to aux data.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
ServiceHandle< StoreGateSvc > & evtStore()
Container class for CaloCell.
void select(double eta, double phi, double deta, double dphi)
CaloCell_Base_ID::SUBCALO SUBCALO
const CaloCellContainer * getCellContainer() const
Method to access underlying cell container.
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
This class provides the client interface for accessing the detector description information common to...
Helper class to provide constant type-safe access to aux data.
const_reference_type withDefault(const ELT &e, const T &deflt) const
Fetch the variable for one element, as a const reference, with a default.
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const std::string & key() const
Return the StoreGate ID for the referenced object.
Tracking class to hold the extrapolation through calorimeter Layers Both the caloEntryLayerIntersecti...
const std::vector< CurvilinearParameters > & caloLayerIntersections() const
access to the intersections with the calorimeter layers.
ClusterSize clusterSize() const
Get cluster size.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version).
const_iterator end() const
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters).
const_iterator begin() const
virtual double eta() const
The pseudorapidity ( ) of the particle.
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
CaloClusterCellLink::const_iterator const_cell_iterator
Iterator of the underlying CaloClusterCellLink (explicitly const version).
float energyBE(const unsigned layer) const
Get the energy in one layer of the EM Calo.
virtual double phi() const
The azimuthal angle ( ) of the particle.
flt_t eta0() const
Returns raw of cluster seed.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
flt_t phi0() const
Returns raw of cluster seed.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
bool isolationCaloCorrection(float &value, const Iso::IsolationFlavour flavour, const Iso::IsolationCaloCorrection corr, const Iso::IsolationCorrectionParameter param) const
Accessor for flavour and type depended Isolation Calo correction.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
uint16_t author(uint16_t bitmask=EgammaParameters::AuthorALL) const
Get author.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
virtual double pt() const override
virtual double phi() const override
The azimuthal angle ( ) of the particle.
virtual double eta() const override
The pseudorapidity ( ) of the particle.
Class providing the definition of the 4-vector interface.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Eigen::Matrix< double, 3, 1 > Vector3D
std::vector< float > getEnergiesPerSampling(const xAOD::FlowElement &fe)
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
bool dEta(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
std::vector< const xAOD::CaloCluster * > getAssociatedTopoClusters(const xAOD::CaloCluster *cluster)
Return a vector of all the topo clusters associated with the egamma cluster.
std::vector< const xAOD::FlowElement * > getAssociatedFlowElements(const xAOD::Egamma *eg, bool neutral=true, bool charged=false)
Return a vector of the flow elements associated with the egamma cluster (only neutral for default).
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
IsolationFlavour isolationFlavour(IsolationType type)
convert Isolation Type into Isolation Flavour
@ topoetcone20
Topo-cluster ET-sum.
IsolationFlavour
Enumeration for different ways of calculating isolation in xAOD files.
@ topoetcone
Topo-cluster ET-sum.
@ etcone
Calorimeter isolation.
static const char * toCString(IsolationConeSize conesize)
@ coreArea
area used to calculate this correction
@ coreEnergy
energy stored for this correction
@ ptCorrection
egamma ptcorrection
@ pileupCorrection
fully corrected
@ coreConeSC
core energy (super cluster).
@ coreCone
core energy (in dR<0.1).
@ core57cells
core 5x7 cells
float coneSize(IsolationConeSize type)
convert Isolation Size into cone size
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
FlowElementContainer_v1 FlowElementContainer
Definition of the current "pfo container version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
FlowElement_v1 FlowElement
Definition of the current "pfo version".
TrackParticle_v1 TrackParticle
Reference the current persistent version:
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.