24 tau.clearProtoChargedPFOLinks();
27 if (tau.nTracks() == 0 or tau.nTracks() >5) {
28 return StatusCode::SUCCESS;
31 ATH_MSG_DEBUG(
"Process a new tau candidate, addreess " << &tau
32 <<
", e: " << tau.pt()
33 <<
", eta: " << tau.eta()
34 <<
", pt: " << tau.pt());
48 for (
xAOD::PFO* pfo : neutralPFOContainer) {
50 <<
", e: " << pfo->pt()
51 <<
", eta: " << pfo->eta()
52 <<
", pt: " << pfo->pt());
55 return StatusCode::SUCCESS;
61 std::vector<ElementLink<xAOD::IParticleContainer>> emptyLinks;
64 pfo->setAssociatedParticleLinks(
type, emptyLinks);
72 if (not tauTrackLink.isValid()) {
80 chargedPFOContainer.
push_back(chargedPFO);
84 chargedPFO->
setP4(tauTrack->
p4());
103 float position = -10.0;
106 std::vector<const xAOD::IParticle*> tauTrackParticles;
109 if (tauTrackParticles.empty()) {
121 ATH_MSG_WARNING(
"Failed to retrieve extrapolated chargedPFO position, will set -10.0 to " <<
detail);
131 std::map< xAOD::PFO*,std::vector< ElementLink< xAOD::IParticleContainer > > > linkMap;
135 for (
const auto& hadPFOLink : tau.hadronicPFOLinks()) {
136 if (not hadPFOLink.isValid()) {
140 ATH_MSG_DEBUG(
"hadPFO " << hadPFOLink.index() <<
", eta: " << (*hadPFOLink)->eta() <<
", phi: " << (*hadPFOLink)->phi() );
146 for(
size_t i=0; i<tau.nProtoChargedPFOs(); i++) {
147 xAOD::PFO* chargedPFO = chargedPFOContainer.
at( tau.protoChargedPFO(i)->index() );
155 chargedPFOMatch = chargedPFO;
159 if( not chargedPFOMatch ){
171 if( not linkMap.count(chargedPFOMatch) ) {
172 linkMap[chargedPFOMatch] = std::vector< ElementLink< xAOD::IParticleContainer > >();
175 linkMap[chargedPFOMatch].push_back(newHadLink);
179 for (
auto [k,v] : linkMap) {
188 std::map< xAOD::PFO*,std::vector< ElementLink< xAOD::IParticleContainer > > > linkMap;
189 for (
const auto& chargedPFOLink : tau.protoChargedPFOLinks()) {
190 if (not chargedPFOLink.isValid()) {
194 const xAOD::PFO* chargedPFO = (*chargedPFOLink);
203 for(
size_t i=0; i<tau.nProtoNeutralPFOs(); i++) {
204 xAOD::PFO* neutralPFO = neutralPFOContainer.
at( tau.protoNeutralPFO(i)->index() );
210 neutralPFOMatch = neutralPFO;
214 if (not neutralPFOMatch){
221 if (not newChargedLink.
isValid()){
226 if( not linkMap.count(neutralPFOMatch) ) {
227 linkMap[neutralPFOMatch] = std::vector< ElementLink< xAOD::IParticleContainer > >();
230 linkMap[neutralPFOMatch].push_back(newChargedLink);
234 for (
auto [k,v] : linkMap) {
245 for(
size_t i=0; i<tau.nProtoNeutralPFOs(); i++) {
246 xAOD::PFO* neutralPFO = neutralPFOContainer.
at( tau.protoNeutralPFO(i)->index() );
249 std::vector<const xAOD::IParticle*> chargedPFOs;
251 if (chargedPFOs.empty()) {
255 ATH_MSG_DEBUG(
"Associated charged PFOs: " << chargedPFOs.size() );
258 float neutralEnergy = neutralPFO->
e();
261 if( not chargedPFO ){
262 ATH_MSG_WARNING(
"Failed to downcast IParticle ptr: " << chargedParticle <<
", to ChargedPFO! " );
265 float chargedEMEnergy = chargedPFO->
e();
267 std::vector<const xAOD::IParticle*> hadPFOs;
269 for (
const auto *hadPFO : hadPFOs) {
270 chargedEMEnergy -= hadPFO->e();
273 if( chargedEMEnergy < 0.0 ) chargedEMEnergy = 0.0;
274 neutralEnergy -= chargedEMEnergy;
275 ATH_MSG_DEBUG(
"Subtracting charged energy: " << chargedEMEnergy );
277 float neutralPt = neutralEnergy / std::cosh(neutralPFO->
eta());
280 ATH_MSG_DEBUG(
"Neutral PFO pt, original: " << neutralPFO->
pt() <<
" subtracted: " << neutralPt);
281 neutralPFO->
setP4(neutralPt , neutralPFO->
eta(), neutralPFO->
phi(), neutralPFO->
m());
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ElementLink implementation for ROOT usage.
bool isValid() const
Check if the element can be found.
void createChargedPFOs(xAOD::TauJet &pTau, xAOD::PFOContainer &pChargedPFOContainer) const
create charged PFOs
void clearAssociatedParticleLinks(xAOD::PFOContainer &pfoContainer, xAOD::PFODetails::PFOParticleType type) const
Clear accosicated partcle links for the pfo container.
float getExtrapolatedPosition(const xAOD::PFO &chargedPFO, xAOD::TauJetParameters::TrackDetail detail) const
Get extrapolated position to the CAL.
void associateChargedToNeutralPFOs(const xAOD::TauJet &pTau, xAOD::PFOContainer &pNeutralPFOContainer) const
associate charged PFOs to neutral PFOs
Gaudi::Property< float > m_minNeutralPFOPt
TauPi0ClusterScaler(const std::string &name)
virtual StatusCode executeTool(xAOD::TauJet &pTau, const EventContext &ctx, xAOD::PFOContainer &pNeutralPFOContainer, xAOD::PFOContainer &pChargedPFOContainer) const override
void associateHadronicToChargedPFOs(const xAOD::TauJet &pTau, xAOD::PFOContainer &pChargedPFOContainer) const
associate hadronic PFOs to charged PFOs
Gaudi::Property< double > m_maxDeltaRNeutralCharged
void subtractChargedEnergyFromNeutralPFOs(const xAOD::TauJet &tau, xAOD::PFOContainer &pNeutralPFOContainer) const
associate charged PFOs to neutral PFOs
Class providing the definition of the 4-vector interface.
bool setTrackLink(const ElementLink< xAOD::TrackParticleContainer > &theTrack)
Set a track constituent - does NOT append to existing container.
bool associatedParticles(PFODetails::PFOParticleType ParticleType, std::vector< const IParticle * > &theParticles) const
get a vector of PFO constituent particle types via enum
void setP4(const FourMom_t &vec)
set the 4-vec
virtual double eta() const
The pseudorapidity ( ) of the particle.
bool setAssociatedParticleLink(PFODetails::PFOParticleType ParticleType, const ElementLink< IParticleContainer > &theParticle)
Set an IParticle constituent via enum - does NOT append to existing container.
virtual double m() const
The invariant mass of the particle.
void setCharge(float charge)
set charge of PFO
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
virtual double pt() const
The transverse momentum ( ) of the particle.
const CaloCluster * cluster(unsigned int index) const
Retrieve a const pointer to a CaloCluster.
bool detail(TauJetParameters::TrackDetail detail, float &value) const
virtual FourMom_t p4() const
The full 4-momentum of the particle.
const TrackParticleLinks_t & trackLinks() const
const TrackParticle * track() const
float charge() const
Returns the charge.
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
PFOParticleType
This enum is used to label the associated particles to the PFO object.
PFO_v1 PFO
Definition of the current "pfo version".
PFOContainer_v1 PFOContainer
Definition of the current "pfo container version".
TauTrack_v1 TauTrack
Definition of the current version.
TauJet_v3 TauJet
Definition of the current "tau version".