26 std::vector<ElementLink<xAOD::PFOContainer>>
empty;
32 return StatusCode::SUCCESS;
36 std::vector<const xAOD::PFO*> shotPFOs;
41 shotPFOs.push_back(shotPFO);
51 std::vector<const xAOD::CaloCluster*> good_pi0s;
52 for (TLorentzVector clusterP4;
const xAOD::CaloCluster* cluster: pi0ClusterContainer){
55 clusterP4 = vertexedCluster.
p4();
58 clusterP4 = cluster->p4();
63 good_pi0s.push_back(cluster);
67 std::map<unsigned, const xAOD::CaloCluster*> shotToClusterMap =
getShotToClusterMap(shotPFOs, good_pi0s);
73 clusterP4 = vertexedCluster.
p4();
76 clusterP4 = cluster->p4();
81 neutralPFOContainer.
push_back(neutralPFO);
84 neutralPFO->
setP4(clusterP4.Pt(), clusterP4.Eta(), clusterP4.Phi(), 0.);
95 std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = tau.
vertexedClusters();
97 TLorentzVector clusterP4 = vertexedCluster.p4();
100 if((clusterP4.E()<=0.) || (clusterP4.DeltaR(tauAxis) >
m_maxDeltaRNeutral) )
continue;
102 double clusterEnergyHad = 0.;
110 ATH_MSG_DEBUG(
"The cell links of the tau cluster is unavailable due to reconstruction from AOD");
115 for (; cellLink != cellLinks->
end(); ++cellLink) {
118 int sampling = cell->caloDDE()->getSampling();
119 if (sampling < 8)
continue;
122 double cellEnergy = cell->e() * cellLink.
weight();
123 clusterEnergyHad += cellEnergy;
127 if(clusterEnergyHad <= 0.)
continue;
131 hadronicPFOContainer.
push_back(hadronicPFO);
141 return StatusCode::SUCCESS;
147 std::vector<const xAOD::CaloCluster*>& goodPi0s)
const {
148 std::map<unsigned, const xAOD::CaloCluster*> shotToClusterMap;
152 int seedHashInt = -1;
153 if (!shotPFO->
attribute(xAOD::PFODetails::PFOAttributes::tauShots_seedHash, seedHashInt)) {
154 ATH_MSG_WARNING(
"Couldn't find seed hash. Set it to -1, no cluster will be associated to shot.");
158 float weightInCluster = -1.;
159 float weightInPreviousCluster = -1;
164 weightInCluster = -1.;
168 for (; cellLink != cellLinks->
end(); ++cellLink) {
172 if (cell->caloDDE()->calo_hash() != seedHash)
continue;
174 weightInCluster = cellLink.
weight();
179 if (weightInCluster < 0)
continue;
182 if (weightInPreviousCluster < 0) {
185 shotToClusterMap[
index] = cluster;
186 weightInPreviousCluster = weightInCluster;
192 if (weightInCluster > weightInPreviousCluster) {
193 shotToClusterMap[
index] = cluster;
201 return shotToClusterMap;
207 const std::map<unsigned, const xAOD::CaloCluster*>& shotToClusterMap,
209 std::vector<unsigned> shotsMatchedToCluster;
214 if (
iterator == shotToClusterMap.end())
continue;
215 if (
iterator->second != &pi0Cluster)
continue;
217 shotsMatchedToCluster.push_back(
index);
220 return shotsMatchedToCluster;
226 const std::vector<unsigned>& shotsInCluster)
const {
227 int totalPhotons = 0;
232 if (! shotPFO->
attribute(xAOD::PFODetails::PFOAttributes::tauShots_nPhotons, nPhotons)) {
235 totalPhotons += nPhotons;
242 std::vector<int> &nPosECells,
243 float &coreEnergyEM1,
244 std::vector<float> &deltaEtaFirstMom,
245 std::vector<float> &deltaEtaSecondMom)
const {
247 float totalEnergyEM1 = 0.;
248 std::vector<float> totalEnergy (3, 0.);
252 for (; cellLink != cellLinks->
end(); ++cellLink) {
256 int sampling = cell->caloDDE()->getSampling();
257 int layer = sampling%4;
258 if (layer >= 3)
continue;
261 float cellEnergy_weighted = cell->e() * cellLink.
weight();
262 if (cellEnergy_weighted <= 0)
continue;
266 float deltaEta = cell->eta() - cluster.
eta();
268 deltaEtaFirstMom[layer] += deltaEta * cellEnergy_weighted;
269 deltaEtaSecondMom[layer] += deltaEta * deltaEta * cellEnergy_weighted;
270 totalEnergy[layer] += cellEnergy_weighted;
273 if (sampling != 1 && sampling != 5)
continue;
275 totalEnergyEM1 += cellEnergy_weighted;
279 if(std::abs(
deltaPhi) > 0.05 || std::abs(deltaEta) > 2 * 0.025/8.)
continue;
280 coreEnergyEM1 += cellEnergy_weighted;
283 for (
int layer=0; layer < 3; ++layer) {
284 if (totalEnergy[layer] != 0.) {
285 deltaEtaFirstMom[layer]/=std::abs(totalEnergy[layer]);
286 deltaEtaSecondMom[layer]/=std::abs(totalEnergy[layer]);
289 deltaEtaFirstMom[layer]=0.;
290 deltaEtaSecondMom[layer]=0.;
294 coreEnergyEM1 = (totalEnergyEM1 > 0.) ? coreEnergyEM1/totalEnergyEM1 : 0.;
301 const std::vector<const xAOD::PFO*>& shotPFOs,
302 const std::map<unsigned, const xAOD::CaloCluster*>& shotToClusterMap,
308 neutralPFO.
setAttribute<
int>(xAOD::PFODetails::PFOAttributes::nPi0Proto, -1);
311 double CENTER_MAG = 0.0;
315 neutralPFO.
setCenterMag(
static_cast<float>(CENTER_MAG));
319 int NHitsInEM1 =
getNPhotons(shotPFOs, shotsInCluster);
320 neutralPFO.
setAttribute<
int>(xAOD::PFODetails::PFOAttributes::cellBased_NHitsInEM1, NHitsInEM1);
323 float eEM1 = cluster.
eSample(CaloSampling::EMB1) + cluster.
eSample(CaloSampling::EME1);
324 neutralPFO.
setAttribute<
float>(xAOD::PFODetails::PFOAttributes::cellBased_energy_EM1, eEM1);
326 float eEM2 = cluster.
eSample(CaloSampling::EMB2) + cluster.
eSample(CaloSampling::EME2);
327 neutralPFO.
setAttribute<
float>(xAOD::PFODetails::PFOAttributes::cellBased_energy_EM2, eEM2);
330 std::vector<float> deltaEtaFirstMom (3, 0.);
331 std::vector<float> deltaEtaSecondMom (3, 0.);
332 std::vector<int> nPosECells(3, 0);
333 float EM1CoreFrac = 0.;
335 getClusterVariables(cluster, nPosECells, EM1CoreFrac, deltaEtaFirstMom, deltaEtaSecondMom);
338 neutralPFO.
setAttribute<
int>(xAOD::PFODetails::PFOAttributes::cellBased_NPosECells_PS, nPosECells.at(0));
339 neutralPFO.
setAttribute<
int>(xAOD::PFODetails::PFOAttributes::cellBased_NPosECells_EM1, nPosECells.at(1));
340 neutralPFO.
setAttribute<
int>(xAOD::PFODetails::PFOAttributes::cellBased_NPosECells_EM2, nPosECells.at(2));
343 neutralPFO.
setAttribute<
float>(xAOD::PFODetails::PFOAttributes::cellBased_EM1CoreFrac, EM1CoreFrac);
346 neutralPFO.
setAttribute<
float>(xAOD::PFODetails::PFOAttributes::cellBased_firstEtaWRTClusterPosition_EM1, deltaEtaFirstMom.at(1));
347 neutralPFO.
setAttribute<
float>(xAOD::PFODetails::PFOAttributes::cellBased_firstEtaWRTClusterPosition_EM2, deltaEtaFirstMom.at(2));
350 neutralPFO.
setAttribute<
float>(xAOD::PFODetails::PFOAttributes::cellBased_secondEtaWRTClusterPosition_EM1, deltaEtaSecondMom.at(1));
351 neutralPFO.
setAttribute<
float>(xAOD::PFODetails::PFOAttributes::cellBased_secondEtaWRTClusterPosition_EM2, deltaEtaSecondMom.at(2));
356 const std::array< std::pair<Moment, Attribute>, 12> momentAttributePairs {{
357 {Moment::FIRST_ETA, Attribute::cellBased_FIRST_ETA},
358 {Moment::SECOND_R, Attribute::cellBased_SECOND_R},
359 {Moment::SECOND_LAMBDA, Attribute::cellBased_SECOND_LAMBDA},
360 {Moment::DELTA_PHI, Attribute::cellBased_DELTA_PHI},
361 {Moment::DELTA_THETA, Attribute::cellBased_DELTA_THETA},
362 {Moment::CENTER_LAMBDA, Attribute::cellBased_CENTER_LAMBDA},
363 {Moment::LATERAL, Attribute::cellBased_LATERAL},
364 {Moment::LONGITUDINAL, Attribute::cellBased_LONGITUDINAL},
365 {Moment::ENG_FRAC_EM, Attribute::cellBased_ENG_FRAC_EM},
366 {Moment::ENG_FRAC_MAX, Attribute::cellBased_ENG_FRAC_MAX},
367 {Moment::ENG_FRAC_CORE, Attribute::cellBased_ENG_FRAC_CORE},
368 {Moment::SECOND_ENG_DENS, Attribute::cellBased_SECOND_ENG_DENS}
371 for (
const auto& [moment, attribute] : momentAttributePairs) {
376 neutralPFO.
setAttribute(attribute,
static_cast<float>(value));
385 std::vector<ElementLink<xAOD::IParticleContainer>> shotlinks;
389 if (!shotElementLink.
isValid()) {
392 shotlinks.push_back(shotElementLink);
398 return StatusCode::SUCCESS;
404 double clusterEnergyHad,
406 double clusterPtHad = clusterEnergyHad/std::cosh(cluster.
eta());
407 hadronicPFO.
setP4(clusterPtHad, cluster.
eta(), cluster.
phi(), 0.);
409 return StatusCode::SUCCESS;
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
static const Attributes_t empty
Data object for each calorimeter readout cell.
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_iterator end() const
const end method
const_iterator begin() const
const begin method
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ElementLink implementation for ROOT usage.
bool toContainedElement(BaseConstReference container, ElementType element)
Set link to point to given element (slowest).
bool isValid() const
Check if the element can be found.
This is a "hash" representation of an Identifier.
Gaudi::Property< double > m_maxDeltaRJetClust
void getClusterVariables(const xAOD::CaloCluster &cluster, std::vector< int > &nPosECells, float &coreEnergyEM1, std::vector< float > &deltaEtaFirstMom, std::vector< float > &secondEtaWRTClusterPositionInLayer) const
eta moment in PS, EM1 and EM2 w.r.t cluster eta
StatusCode configureNeutralPFO(const xAOD::CaloCluster &cluster, const xAOD::CaloClusterContainer &pi0ClusterContainer, const xAOD::TauJet &tau, const std::vector< const xAOD::PFO * > &shotPFOs, const std::map< unsigned, const xAOD::CaloCluster * > &shotsInCluster, xAOD::PFO &neutralPFO) const
Configure the neutral PFO.
Gaudi::Property< double > m_clusterEtCut
virtual StatusCode executePi0ClusterCreator(xAOD::TauJet &pTau, xAOD::PFOContainer &neutralPFOContainer, xAOD::PFOContainer &hadronicClusterPFOContainer, const xAOD::CaloClusterContainer &pi0CaloClusContainer) const override
Gaudi::Property< double > m_recoFromAOD
StatusCode configureHadronicPFO(const xAOD::CaloVertexedTopoCluster &cluster, double clusterEnergyHad, xAOD::PFO &hadronicPFO) const
Configure the haronic PFO.
Gaudi::Property< double > m_maxDeltaRNeutral
std::map< unsigned, const xAOD::CaloCluster * > getShotToClusterMap(const std::vector< const xAOD::PFO * > &shotVector, std::vector< const xAOD::CaloCluster * > &goodpi0Vecor) const
std::vector< unsigned > getShotsMatchedToCluster(const std::vector< const xAOD::PFO * > &shotVector, const std::map< unsigned, const xAOD::CaloCluster * > &clusterToShotMap, const xAOD::CaloCluster &pi0Cluster) const
int getNPhotons(const std::vector< const xAOD::PFO * > &shotVector, const std::vector< unsigned > &shotsInCluster) const
TauPi0ClusterCreator(const std::string &name)
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 eta() const
The pseudorapidity ( ) of the particle.
float eSample(const CaloSample sampling) const
virtual double phi() const
The azimuthal angle ( ) of the particle.
MomentType
Enums to identify different moments.
@ CENTER_MAG
Cluster Centroid ( ).
virtual FourMom_t p4() const final
The full 4-momentum of the particle.
virtual double phi() const final
The azimuthal angle ( ) of the particle.
virtual double eta() const final
The pseudorapidity ( ) of the particle.
Evaluate cluster kinematics with a different vertex / signal state.
bool attribute(PFODetails::PFOAttributes AttributeType, T &anAttribute) const
get a PFO Variable via enum
void setAttribute(PFODetails::PFOAttributes AttributeType, const T &anAttribute)
Set a PFO Variable via enum - overwrite is allowed.
bool setAssociatedParticleLinks(PFODetails::PFOParticleType ParticleType, const std::vector< ElementLink< IParticleContainer > > &theParticles)
Set a vector of PFO constituent particle types via enum - overwrite is allowed.
bool setClusterLink(const ElementLink< xAOD::CaloClusterContainer > &theCluster)
Set a cluster constituent - does NOT append to existing container.
void setCenterMag(float CenterMag)
set CenterMag moment needed for vertex correction
void setP4(const FourMom_t &vec)
set the 4-vec
void setBDTPi0Score(float BDTPi0Score)
set BDT Score used to classify clusters as Pi0 like or not
void setCharge(float charge)
set charge of PFO
std::vector< xAOD::CaloVertexedTopoCluster > vertexedClusters() const
void setHadronicPFOLinks(const PFOLinks_t &hadronicPFOs)
size_t nShotPFOs() const
Get the number of shot PFO particles associated with this tau.
const PFO * shotPFO(size_t i) const
Get the pointer to a given shot PFO associated with this tau.
const PFOLinks_t & shotPFOLinks() const
const Vertex * vertex() const
void setProtoNeutralPFOLinks(const PFOLinks_t &protoNeutralPFOs)
void addHadronicPFOLink(const ElementLink< PFOContainer > &pfo)
add a hadronic PFO to the tau
void addProtoNeutralPFOLink(const ElementLink< PFOContainer > &pfo)
add a cellbased_neutral PFO to the tau
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
PFO_v1 PFO
Definition of the current "pfo version".
PFOContainer_v1 PFOContainer
Definition of the current "pfo container version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Vertex_v1 Vertex
Define the latest version of the vertex class.
TauJet_v3 TauJet
Definition of the current "tau version".
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.