7#include "AthLinks/ElementLink.h"
55 float pt = accPt(*
this);
63 float eta = accEta(*
this);
70 float phi = accPhi(*
this);
77 float M = accM(*
this);
84 float pt = accPt(*
this);
110 accPt(*
this) =
vec.Pt();
113 accEta(*
this) =
vec.Eta();
116 accPhi(*
this) =
vec.Phi();
119 accM(*
this) =
vec.M();
141 return Type::ParticleFlow;
156 p4EM.SetPtEtaPhiM(accPt(*
this), accEta(*
this), accPhi(*
this), accM(*
this));
170 return GenVecFourMom_t(accPt(*
this), accEta(*
this), accPhi(*
this), accM(*
this));
175 accPt(*
this) =
p4EM.Pt();
178 accEta(*
this) =
p4EM.Eta();
181 accPhi(*
this) =
p4EM.Phi();
184 accM(*
this) =
p4EM.M();
209 float pt = accPt(*
this);
228 float M = accM(*
this);
238 float pt = accPt(*
this);
240 if (
pt < 0.0)
return -
p4EM().E();
241 else return p4EM().E();
252 return (fabs(this->
charge())>1
e-6);
277 const static int maxIntSize = 1000000000;
278 int internalAttribute = maxIntSize;
279 if (dummy < 0) internalAttribute *= -1;
280 if (dummy < maxIntSize && dummy > -maxIntSize) internalAttribute =
static_cast<int>(dummy);
284 float internalAttribute = anAttribute;
292 int internalAttribute;
295 else anAttribute = 0.0;
301 if( ! p_acc ) {
return false ;}
305 anAttribute =( *p_acc )( *this );
313 switch (AttributeType) {
314 case PFODetails::PFOAttributes::eflowRec_LATERAL:
315 case PFODetails::PFOAttributes::eflowRec_LONGITUDINAL:
316 case PFODetails::PFOAttributes::eflowRec_SECOND_R:
317 case PFODetails::PFOAttributes::eflowRec_CENTER_LAMBDA:
318 case PFODetails::PFOAttributes::eflowRec_FIRST_ENG_DENS:
319 case PFODetails::PFOAttributes::eflowRec_ENG_FRAC_MAX:
320 case PFODetails::PFOAttributes::eflowRec_ISOLATION:
321 case PFODetails::PFOAttributes::eflowRec_ENG_BAD_CELLS:
322 case PFODetails::PFOAttributes::eflowRec_N_BAD_CELLS:
323 case PFODetails::PFOAttributes::eflowRec_BADLARQ_FRAC:
324 case PFODetails::PFOAttributes::eflowRec_ENG_POS:
325 case PFODetails::PFOAttributes::eflowRec_SIGNIFICANCE:
326 case PFODetails::PFOAttributes::eflowRec_AVG_LAR_Q:
327 case PFODetails::PFOAttributes::eflowRec_AVG_TILE_Q:
328 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EM:
329 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EM3:
330 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC0:
331 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC:
332 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_Tile0:
333 case PFODetails::PFOAttributes::eflowRec_TIMING:
334 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_PreSamplerB:
335 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EMB1:
336 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EMB2:
337 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EMB3:
338 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_PreSamplerE:
339 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EME1:
340 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EME2:
341 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_EME3:
342 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC1:
343 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC2:
344 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_HEC3:
345 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileBar0:
346 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileBar1:
347 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileBar2:
348 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileGap1:
349 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileGap2:
350 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileGap3:
351 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileExt0:
352 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileExt1:
353 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_TileExt2:
354 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_FCAL0:
355 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_FCAL1:
356 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_FCAL2:
357 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_MINIFCAL0:
358 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_MINIFCAL1:
359 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_MINIFCAL2:
360 case PFODetails::PFOAttributes::eflowRec_LAYERENERGY_MINIFCAL3:
373 float internalAttribute =
static_cast<float>(anAttribute);
379 float internalAttribute;
381 if (
isValid) anAttribute =
static_cast<double>(internalAttribute);
388 float internalAttribute =
static_cast<float>(anAttribute);
393 template<>
bool PFO_v1::attribute(
const std::string& AttributeType,
double& anAttribute)
const {
395 float internalAttribute;
397 if (
isValid) anAttribute =
static_cast<float>(internalAttribute);
406 double myMoment = -99.0;
409 bool gotMoment = theCluster->
retrieveMoment( momentType, myMoment);
412 else if (gotMoment) {
413 theMoment =
static_cast<float>(myMoment);
426 if (!haveGotAttributeInMap)
return false;
428 bool isRetrieved = this->
attribute(myAttribute, theMoment);
538 acc(*
this) = theVertexLink;
562 std::vector<ElementLink<xAOD::IParticleContainer> > theLinks(1,theParticle);
567 std::vector<ElementLink<xAOD::IParticleContainer> > theLinks(1,theParticle);
573 if (!p_acc)
return false;
577 std::vector<ElementLink<IParticleContainer> > storedContainer = (*p_acc)(*this);
578 storedContainer.push_back(theParticle);
579 (*p_acc)(*this) = storedContainer;
588 std::vector<ElementLink<IParticleContainer> > storedContainer =
acc(*
this);
594 storedContainer.push_back(newLink);
596 acc(*
this) = storedContainer;
603 if (!p_acc)
return false;
605 (*p_acc)(*this) = theParticles;
613 if (!p_acc)
return false;
617 const std::vector<ElementLink<IParticleContainer> >& theLinks = (*p_acc)(*this);
618 std::vector<ElementLink<IParticleContainer> >
::const_iterator firstLink = theLinks.begin();
619 for (; firstLink != theLinks.end(); ++firstLink) {
620 if ( (*firstLink).isValid()) theParticles.push_back(**firstLink);
621 else theParticles.push_back(
nullptr);
633 std::vector<ElementLink<IParticleContainer> > storedContainer;
635 for (; firstParticle != theParticles.end(); ++firstParticle){
638 storedContainer.push_back( myLink );
642 acc(*
this) = storedContainer;
647 if (!
acc.isAvailable(*
this))
return false;
649 const std::vector<ElementLink<IParticleContainer> >& theLinks =
acc(*
this);
650 std::vector<ElementLink<IParticleContainer> >
::const_iterator firstLink = theLinks.begin();
651 for (; firstLink != theLinks.end(); ++firstLink) {
652 if ( (*firstLink).isValid()) theParticles.push_back(**firstLink);
653 else theParticles.push_back(
nullptr);
661 if (!p_acc)
return 0;
664 const std::vector<ElementLink<IParticleContainer> >& theLinks = (*p_acc)(*this);
665 return theLinks.size();
672 if (!p_acc)
return nullptr;
673 else if (!p_acc->
isAvailable(*
this)) {
return nullptr;}
675 const std::vector<ElementLink<IParticleContainer> >& theLinks = (*p_acc)(*this);
676 if(
index<theLinks.size()) {
680 if (
nullptr == theParticle)
return nullptr;
681 else if (Type::CaloCluster == theParticle->
type())
return static_cast<const CaloCluster*
>(theParticle);
694 if (!p_acc)
return nullptr;
695 else if (!p_acc->
isAvailable(*
this)) {
return nullptr;}
697 const std::vector<ElementLink<IParticleContainer> >& theLinks = (*p_acc)(*this);
698 if(
index<theLinks.size()) {
702 if (
nullptr == theParticle)
return nullptr;
703 else if (Type::TrackParticle == theParticle->
type())
return static_cast<const TrackParticle*
>(theParticle);
714 if (!
acc.isAvailable(*
this))
return nullptr;
717 if (tempVertexLink.
isValid())
return *
acc(*
this);
723 TVector3 theVertexVector(vertexToCorrectTo.
x(), vertexToCorrectTo.
y(), vertexToCorrectTo.
z());
729 TLorentzVector theNewVector(0.0,0.0,0.0,0.0);
730 theNewVector.SetPtEtaPhiM(this->
pt(), this->
eta(), this->
phi(), this->
m());
738 TVector3 theVertexVector(vertexToCorrectTo.
x(), vertexToCorrectTo.
y(), vertexToCorrectTo.
z());
744 TLorentzVector theNewVector(0.0,0.0,0.0,0.0);
745 theNewVector.SetPtEtaPhiM(this->
ptEM(), this->
etaEM(), this->
phiEM(), this->
mEM());
754 float clusterEta = theFourVector.Eta();
757 float radius =
centerMag/cosh(clusterEta);
759 float EtaVertexCorrection = 0.0, PhiVertexCorrection = 0.0;
760 float clusterPhi = theFourVector.Phi();
763 EtaVertexCorrection = (-vertexToCorrectTo.Z()/cosh(clusterEta) + (vertexToCorrectTo.X()*cos(clusterPhi) + vertexToCorrectTo.Y()*sin(clusterPhi))*tanh(clusterEta))/radius;
764 PhiVertexCorrection = (vertexToCorrectTo.X()*sin(clusterPhi) - vertexToCorrectTo.Y()*cos(clusterPhi))/radius;
767 float etaVertexCorrected = clusterEta + EtaVertexCorrection;
768 float p = std::sqrt(theFourVector.E()*theFourVector.E()-theFourVector.M()*theFourVector.M());
769 float ptVertexCorrected = p/cosh(etaVertexCorrected);
770 theFourVector.SetPtEtaPhiM(ptVertexCorrected, etaVertexCorrected, clusterPhi + PhiVertexCorrection, theFourVector.M());
784 std::vector<ElementLink<IParticleContainer> >& theClusterLinks = accClusters(*
this);
785 std::vector< ElementLink< IParticleContainer > >
::iterator firstClus = theClusterLinks.begin();
786 std::vector< ElementLink< IParticleContainer > >
::iterator lastClus = theClusterLinks.end();
787 for (; firstClus != lastClus; ++firstClus) firstClus->toPersistent();
796 std::vector<ElementLink<IParticleContainer> >& theTrackLinks = accTracks(*
this);
797 std::vector< ElementLink< IParticleContainer > >
::iterator firstTrack = theTrackLinks.begin();
798 std::vector< ElementLink< IParticleContainer > >
::iterator lastTrack = theTrackLinks.end();
799 for (; firstTrack != lastTrack; ++firstTrack) firstTrack->toPersistent();
809 std::vector<ElementLink<IParticleContainer> >& theShotLinks = accShots(*
this);
810 std::vector< ElementLink< IParticleContainer > >
::iterator firstShot = theShotLinks.begin();
811 std::vector< ElementLink< IParticleContainer > >
::iterator lastShot = theShotLinks.end();
812 for (; firstShot != lastShot; ++firstShot) firstShot->toPersistent();
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
std::vector< size_t > vec
const_iterator begin() const
ElementLink implementation for ROOT usage.
BaseConstReference getStorableObjectRef() const
Return a reference to the currently-referenced container object.
bool setElement(ElementType element)
Set to point to an element.
bool setStorableObject(BaseConstReference data, bool replace=false, IProxyDict *sg=0)
Set link to point to a new container (storable).
bool toPersistent()
Dummy function provinding the offline interface.
bool isValid() const
Test to see if the link can be dereferenced.
bool isAvailableWritable(ELT &e) const
Test to see if this variable exists in the store and is writable.
void makePrivateStore()
Create a new (empty) private store for this object.
SG::ConstAccessor< T, ALLOC > ConstAccessor
SG::Accessor< T, ALLOC > Accessor
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
MomentType
Enums to identify different moments.
@ DELTA_ALPHA
Angular shower axis deviation ( ) from IP-to-Center.
@ AVG_TILE_Q
Sum(E_cell_Tile^2 Q_cell_Tile)/Sum(E_cell_Tile^2)
@ SECOND_LAMBDA
Second Moment in .
@ CELL_SIGNIFICANCE
Cell significance = E/sig of the cell with the largest |E|/sig.
@ CELL_SIG_SAMPLING
CaloSample of the cell with the largest |E|/sig.
@ EM_PROBABILITY
Classification probability to be em-like.
@ LATERAL
Normalized lateral moment.
@ N_BAD_CELLS
number of bad cells
@ LONGITUDINAL
Normalized longitudinal moment.
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
@ AVG_LAR_Q
Sum(E_cell_LAr^2 Q_cell_LAr)/Sum(E_cell_LAr^2)
@ SECOND_R
Second Moment in .
@ FIRST_ENG_DENS
First Moment in E/V.
@ ENG_FRAC_CORE
Energy fraction of the sum of the hottest cells in each sampling.
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
@ SIGNIFICANCE
Cluster significance.
@ ENG_CALIB_FRAC_REST
Calibration Hit energy inside the cluster caused by other particles.
@ ENG_CALIB_FRAC_EM
Calibration Hit energy inside the cluster caused by e/gamma/pi0.
@ ENG_BAD_CELLS
Total em-scale energy of bad cells in this cluster.
@ ENG_CALIB_TOT
Calibration Hit energy inside the cluster.
@ ENG_CALIB_FRAC_HAD
Calibration Hit energy inside the cluster caused by charged pi+ and pi-.
@ ENG_POS
Total positive Energy of this cluster.
@ BADLARQ_FRAC
Energy fraction of LAr cells with quality larger than a given cut.
@ ISOLATION
Energy weighted fraction of non-clustered perimeter cells.
virtual Type::ObjectType type() const =0
The type of the object as a simple enumeration.
TLorentzVector FourMom_t
Definition of the 4-momentum type.
SG::Accessor< T, ALLOC > Accessor
Class describing a particle flow object.
bool setTrackLink(const ElementLink< xAOD::TrackParticleContainer > &theTrack)
Set a track constituent - does NOT append to existing container.
unsigned int nCaloCluster() const
Find out how many CaloCluster are linked.
virtual double ptEM() const
get EM scale pt
bool attribute(PFODetails::PFOAttributes AttributeType, T &anAttribute) const
get a PFO Variable via enum
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : GenVector version.
bool getAttributeName_FromClusterMoment(xAOD::PFODetails::PFOAttributes &myAttribute, xAOD::CaloCluster::MomentType &momentType) const
Map from cluster moment name onto PFOAttribute name.
bool addClusterLink(const ElementLink< xAOD::CaloClusterContainer > &theCluster)
Add a cluster constituent appends to existing container.
void setAttribute(PFODetails::PFOAttributes AttributeType, const T &anAttribute)
Set a PFO Variable via enum - overwrite is allowed.
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > GenVecFourMom_t
Base 4 Momentum type (GenVector version)
bool getClusterMoment(float &theMoment, xAOD::CaloCluster::MomentType momentType) const
Accessor for cluster moments.
PFO_v1()
Default constructor.
virtual double rapidity() const
The true rapidity (y) of the particle.
bool isCharged() const
is a charged PFO
bool setAssociatedParticleLinks(PFODetails::PFOParticleType ParticleType, const std::vector< ElementLink< IParticleContainer > > &theParticles)
Set a vector of PFO constituent particle types via enum - overwrite is allowed.
TLorentzVector GetVertexCorrectedFourVec(const xAOD::Vertex &vertexToCorrectTo) const
Correct 4-vector to point at a vertex.
bool setClusterLink(const ElementLink< xAOD::CaloClusterContainer > &theCluster)
Set a cluster constituent - does NOT append to existing container.
float centerMag() const
get CenterMag moment needed for vertex correction
static const int s_floatCompressionFactor
this defines the factor to compress floats by
FourMom_t p4EM() const
get EM scale 4-vector
GenVecFourMom_t genvecP4EM() const
get EM scale 4-vector
virtual double eEM() const
get EM scale energy
bool associatedParticles(PFODetails::PFOParticleType ParticleType, std::vector< const IParticle * > &theParticles) const
get a vector of PFO constituent particle types via enum
bool isJetETMissFloatForCompression(xAOD::PFODetails::PFOAttributes AttributeType) const
Performs a check as to whether a variable should be compressed.
void VertexCorrectTheFourVector(const TVector3 &vertexToCorrectTo, TLorentzVector &theFourVector) const
This does the vertex correction of neutral PFO.
void convertLink(ElementLink< IParticleContainer > &IParticleLink, const ElementLink< T > &templateLink)
Convert a generic link to an IParticleLink - perhaps this will go in a dedicated helper tool?
bool getClusterMomentFromPFO(float &theMoment, xAOD::CaloCluster::MomentType momentType) const
Gives access to cluster moments direct from the PFO - getClusterMoment calls this,...
const TrackParticle * track(unsigned int index) const
Retrieve a const pointer to a Rec::TrackParticle.
virtual double etaEM() const
get EM scale eta
virtual FourMom_t p4() const
The full 4-momentum of the particle.
void setP4(const FourMom_t &vec)
set the 4-vec
virtual double eta() const
The pseudorapidity ( ) of the particle.
TLorentzVector GetVertexCorrectedEMFourVec(const xAOD::Vertex &vertexToCorrectTo) const
Correct EM scale 4-vector to point at a vertex.
bool setAssociatedParticleLink(PFODetails::PFOParticleType ParticleType, const ElementLink< IParticleContainer > &theParticle)
Set an IParticle constituent via enum - does NOT append to existing container.
void toPersistent()
prepare all links for persistification
virtual double m() const
The invariant mass of the particle.
void setP4EM(const FourMom_t &p4EM)
set EM scale 4-vector
const xAOD::Vertex * vertex() const
Retrieve a const pointer to the xAOD::Vertex a charged PFO is associated to.
bool addAssociatedParticleLink(PFODetails::PFOParticleType ParticleType, const ElementLink< IParticleContainer > &theParticle)
Add an IParticle constituent via enum - appends to existing container.
virtual double phiEM() const
get EM scale phi
virtual double e() const
The total energy of the particle.
virtual double mEM() const
get EM scale mass
virtual double phi() const
The azimuthal angle ( ) of the particle.
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
bool setVertexLink(const ElementLink< xAOD::VertexContainer > &theVertexLink)
Set a vertex link.
virtual double pt() const
The transverse momentum ( ) of the particle.
const CaloCluster * cluster(unsigned int index) const
Retrieve a const pointer to a CaloCluster.
float z() const
Returns the z position.
float y() const
Returns the y position.
float x() const
Returns the x position.
PFOLeptonType
This enum is used to label the lepton type of the neutral PFO.
@ eflowRec_ENG_CALIB_FRAC_REST
@ eflowRec_CELL_SIG_SAMPLING
@ eflowRec_ENG_CALIB_FRAC_EM
@ eflowRec_CELL_SIGNIFICANCE
@ eflowRec_EM_PROBABILITY
@ eflowRec_FIRST_ENG_DENS
@ eflowRec_ENG_CALIB_FRAC_HAD
PFOParticleType
This enum is used to label the associated particles to the PFO object.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
setBGCode setTAP setLVL2ErrorBits bool
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
JetConstituentVector::iterator iterator
static const SG::AuxElement::Accessor< T > * constAccessor(xAOD::PFODetails::PFOAttributes variable)
static const SG::AuxElement::Accessor< std::vector< ElementLink< IParticleContainer > > > * getAccessor(PFODetails::PFOParticleType type)