|
ATLAS Offline Software
|
Go to the documentation of this file.
23 #include "Math/Vector4D.h"
45 return std::hypot(
px(),
py() );
61 return p4().Rapidity();
65 if ( accPx.isAvailable(*
this) && accPy.isAvailable(*
this)
66 && accPz.isAvailable(*
this) && accE.isAvailable(*
this) ) {
68 const double px =
static_cast<double>(accPx(*
this));
69 const double py =
static_cast<double>(accPy(*
this));
70 const double pz =
static_cast<double>(accPz(*
this));
71 const double e =
static_cast<double>(accE(*
this));
77 const std::vector<int> partIndices;
78 return p4( partIndices );
84 if ( accPx.isAvailable(*
this) && accPy.isAvailable(*
this)
85 && accPz.isAvailable(*
this) && accE.isAvailable(*
this) ) {
87 const double px =
static_cast<double>(accPx(*
this));
88 const double py =
static_cast<double>(accPy(*
this));
89 const double pz =
static_cast<double>(accPz(*
this));
90 const double e =
static_cast<double>(accE(*
this));
96 const std::vector<int> partIndices;
98 return GenVecFourMom_t(fourmom.Px(), fourmom.Py(), fourmom.Pz(), fourmom.E());
133 accPx( *
this ) =
static_cast<float>(
vec.Px());
134 accPy( *
this ) =
static_cast<float>(
vec.Py());
135 accPz( *
this ) =
static_cast<float>(
vec.Pz());
136 accE( *
this ) =
static_cast<float>(
vec.E());
178 return chargeAcc.isAvailable( *
this );
183 if ( chargeAcc.isAvailable(*
this) ) {
185 return chargeAcc(*
this);
195 throw std::runtime_error(
"Got a zero pointer to an xAOD::IParticle!");
197 if ( chargeAcc.isAvailable(*
part) ) {
212 chargeAcc(*
this) =
charge;
218 return pdgAcc.isAvailable( *
this );
241 fourMom.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
243 if ( partIndices.empty() ) {
249 throw std::runtime_error(
"Got a zero pointer to an xAOD::IParticle!");
256 double px =
met->mpx();
257 double py =
met->mpy();
262 for (
int i : partIndices ) {
265 double px =
met->mpx();
266 double py =
met->mpy();
270 throw std::runtime_error(
"Got a negative index which is not -1");
275 throw std::runtime_error(
"Got a zero pointer to an xAOD::IParticle");
286 return (this->
p4(partIndices)).Pt();
290 return (this->
p4(partIndices)).Eta();
294 return (this->
p4(partIndices)).Phi();
298 return (this->
p4(partIndices)).M();
302 return (this->
p4(partIndices)).P();
306 return (this->
p4(partIndices)).E();
310 return (this->
p4(partIndices)).Rapidity();
314 return (this->
p4(partIndices)).Px();
318 return (this->
p4(partIndices)).Py();
322 return (this->
p4(partIndices)).Pz();
326 return (this->
p4(partIndices)).Et();
349 throw std::runtime_error(
"Got a zero pointer to an xAOD::MissingET when calling mt");
351 const double mpx( metObj->
mpx() );
352 const double mpy( metObj->
mpy() );
353 const double met( metObj->
met() );
356 const double px( fourMom.Px() );
357 const double py( fourMom.Py() );
360 double mll2( fourMom.M2() );
362 mll2 = mll2 < 0.0 ? -mll2 : mll2;
363 const double etll( std::sqrt( (
px*
px +
py*
py) + mll2 ) );
369 throw std::runtime_error(
"Got an invalid mt calculation");
392 const std::vector<int>& partIndices )
const {
396 for (
const std::string&
varName : varNames ) {
398 if (
varName.empty() ) {
continue; }
401 if ( partIndices.empty() ) {
406 for (
int i : partIndices ) {
413 throw std::runtime_error(
"Got a negative index which is not -1");
431 throw std::runtime_error(
"Got a zero pointer to an xAOD::IParticle!");
434 return varAcc(*
part);
467 partLinksAcc(
"partLinks" );
476 throw std::runtime_error(
"Got a zero pointer to an xAOD::IParticle when adding constituent!");
482 if ( updateFourMom ) {
489 const std::size_t partIdx =
part->
index();
503 throw std::runtime_error(
"Got an invalid ElementLink when adding constituent!");
508 if ( updateFourMom ) {
509 this->
setP4( this->
p4() + (*partLink)->p4() );
522 bool updateFourMom ) {
523 for ( xAOD::IParticleLinkContainer::const_iterator
524 constitItr = partLinkCont.begin(),
525 constitItrEnd = partLinkCont.end();
526 constitItr != constitItrEnd;
529 this->
addPart( currentLink, updateFourMom );
537 bool updateFourMom ) {
541 throw std::runtime_error(
"Got a zero pointer to an xAOD::IParticle when adding constituent!");
545 const std::size_t partIdx =
part->
index();
556 bool updateFourMom ) {
560 throw std::runtime_error(
"Got an invalid ElementLink when adding constituent!");
566 constitItr = constitLinks.begin(),
567 constitItrEnd = constitLinks.end();
568 constitItr != constitItrEnd;
573 if ( updateFourMom ) {
574 this->
setP4( this->
p4() - (*partLink)->p4() );
580 constitLinks.erase( constitItr );
589 metLinkAcc(
"missingETLink" );
594 if ( !(metLinkAcc.isAvailable(*
this)) ) {
609 bool updateFourMom ) {
613 throw std::runtime_error(
"Got a zero pointer to xAOD::MissingET when adding it!");
617 if ( updateFourMom ) {
619 double metpx =
met->mpx();
620 double metpy =
met->mpy();
621 metP4.SetPxPyPzE( metpx, metpy, 0.0, std::sqrt(metpx*metpx + metpy*metpy) );
622 this->
setP4( this->
p4() + metP4 );
626 const std::size_t metIdx =
met->index();
644 if ( updateFourMom ) {
646 double metpx =
met->mpx();
647 double metpy =
met->mpy();
648 metP4.SetPxPyPzE( metpx, metpy, 0.0, std::sqrt(metpx*metpx + metpy*metpy) );
649 this->
setP4( this->
p4() - metP4 );
671 if ( thisMet ==
met ) {
676 if ( (*thisMet) == (*
met) ) {
689 for ( xAOD::IParticleLinkContainer::const_iterator
690 constitItr = constitLinks.begin(),
691 constitItrEnd = constitLinks.end();
692 constitItr != constitItrEnd;
695 if ( ! currentLink.
isValid() )
continue;
697 if (
part == currentPart ) {
708 for ( xAOD::IParticleLinkContainer::const_iterator
709 constitItr = constitLinks.begin(),
710 constitItrEnd = constitLinks.end();
711 constitItr != constitItrEnd;
723 if( partLinksAcc.isAvailable( *
this ) ) {
724 return partLinksAcc( *this ).size();
732 #define NUM_PARTS( FUNCNAME, OBJTYPE ) \
733 std::size_t CompositeParticle_v1::FUNCNAME() const { \
735 std::size_t nParts = this->nParts(); \
736 for ( std::size_t i=0; i<nParts; ++i ) { \
737 const xAOD::IParticle* part = this->part(i); \
738 if (!part) { throw std::runtime_error("Got a zero pointer to an xAOD::IParticle!"); } \
739 if ( part->type() == xAOD::Type::OBJTYPE ) { n += 1; } \
751 return this->nElectrons() + this->nMuons() + this->nTaus();
757 #define NUM_TRUTHPARTS( FUNCNAME, PIDMETHOD ) \
758 std::size_t CompositeParticle_v1::FUNCNAME() const { \
760 std::size_t nParts = this->nParts(); \
761 for ( std::size_t i=0; i<nParts; ++i ) { \
762 const xAOD::IParticle* part = this->part(i); \
763 if (!part) { throw std::runtime_error("Got a zero pointer to an xAOD::IParticle!"); } \
764 if ( part->type() != xAOD::Type::TruthParticle ) { continue; } \
765 const xAOD::TruthParticle* truthParticle = dynamic_cast<const xAOD::TruthParticle*>(part); \
766 if (!truthParticle) { throw std::runtime_error("Zero pointer to xAOD::TruthParticle"); } \
767 if ( PIDMETHOD(truthParticle->pdgId()) ) { n += 1; } \
778 return this->nTruthElectrons() + this->nTruthMuons() + this->nTruthTaus();
787 if ( ! constitLink.
isValid() ) {
811 template<
typename CONTTYPE>
821 throw std::runtime_error(
"Got a zero pointer to an xAOD::IParticle!");
836 const std::vector<int>& otherPartIndices,
837 bool updateFourMom )
const {
840 for (
int i : partIndices ) {
849 throw std::runtime_error(
"Got a non-valid index");
852 for (
int i : otherPartIndices ) {
858 throw std::runtime_error(
"Got a non-valid index for an other particle");
877 otherPartLinksAcc(
"otherPartLinks" );
886 throw std::runtime_error(
"Got a zero pointer to an xAOD::IParticle when adding constituent!");
891 const std::size_t partIdx =
part->
index();
905 throw std::runtime_error(
"Got an invalid ElementLink when adding constituent!");
917 for ( xAOD::IParticleLinkContainer::const_iterator
918 constitItr = partLinkCont.begin(),
919 constitItrEnd = partLinkCont.end();
920 constitItr != constitItrEnd;
934 throw std::runtime_error(
"Got a zero pointer to an xAOD::IParticle when adding constituent!");
938 const std::size_t partIdx =
part->
index();
952 throw std::runtime_error(
"Got an invalid ElementLink when adding constituent!");
960 constitItr != constitItrEnd;
977 for ( xAOD::IParticleLinkContainer::const_iterator
980 constitItr != constitItrEnd;
983 if ( ! currentLink.
isValid() )
continue;
985 if (
part == currentPart ) {
996 for ( xAOD::IParticleLinkContainer::const_iterator
999 constitItr != constitItrEnd;
1011 if( otherPartLinksAcc.isAvailable( *
this ) ) {
1012 return otherPartLinksAcc( *this ).size();
1020 #define NUM_OTHERPARTS( FUNCNAME, OBJTYPE ) \
1021 std::size_t CompositeParticle_v1::FUNCNAME() const { \
1023 std::size_t nParts = this->nOtherParts(); \
1024 for ( std::size_t i=0; i<nParts; ++i ) { \
1025 const xAOD::IParticle* part = this->otherPart(i); \
1026 if (!part) { throw std::runtime_error("Got a zero pointer to an xAOD::IParticle!"); } \
1027 if ( part->type() == xAOD::Type::OBJTYPE ) { n += 1; } \
1039 return this->nOtherElectrons() + this->nOtherMuons() + this->nOtherTaus();
1045 #define NUM_OTHERTRUTHPARTS( FUNCNAME, PIDMETHOD ) \
1046 std::size_t CompositeParticle_v1::FUNCNAME() const { \
1048 std::size_t nParts = this->nOtherParts(); \
1049 for ( std::size_t i=0; i<nParts; ++i ) { \
1050 const xAOD::IParticle* part = this->otherPart(i); \
1051 if (!part) { throw std::runtime_error("Got a zero pointer to an xAOD::IParticle!"); } \
1052 if ( part->type() != xAOD::Type::TruthParticle ) { continue; } \
1053 const xAOD::TruthParticle* truthParticle = dynamic_cast<const xAOD::TruthParticle*>(part); \
1054 if (!truthParticle) { throw std::runtime_error("Zero pointer to xAOD::TruthParticle"); } \
1055 if ( PIDMETHOD(truthParticle->pdgId()) ) { n += 1; } \
1066 return this->nOtherTruthElectrons() + this->nOtherTruthMuons() + this->nOtherTruthTaus();
1103 if( partLinksAcc.isAvailableWritable( *
this ) ) {
1105 itr = partLinksAcc( *this ).begin(),
1106 itrEnd = partLinksAcc( *this ).end();
1109 itr->toPersistent();
JetConstituentVector::iterator iterator
std::size_t nParts() const
Number of constituent particles.
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
virtual double m() const
The invariant mass of the particle.
IParticle::FourMom_t FourMom_t
Definition of the 4-momentum type.
const xAOD::IParticleLink & partLink(std::size_t index=0) const
Get the constituent IParticle number i as an ElementLink.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Helper class to provide type-safe access to aux data.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
double et() const
The transverse energy ( ) of the particle.
#define NUM_PARTS(FUNCNAME, OBJTYPE)
ConstDataVector< CONTTYPE > * parts() const
Method to return a DataVector<T>, e.g., a MuonContainer, for all the constituent particles,...
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > GenVecFourMom_t
Base 4 Momentum type (GenVector)
bool containsOther(const xAOD::IParticle *part) const
Check if a given xAOD::IParticle is an other constituent.
std::size_t nOtherParts() const
Number of other constituent particles.
#define NUM_TRUTHPARTS(FUNCNAME, PIDMETHOD)
bool contains(const xAOD::MissingET *met) const
Check if a given xAOD::MissingET object is part of this CompositeParticle.
virtual double e() const
The total energy of the particle.
virtual double rapidity() const
The true rapidity (y) of the particle.
virtual Type::ObjectType type() const =0
The type of the object as a simple enumeration.
IParticleLinkContainer_v1 IParticleLinkContainer
Define the latest version of the IParticleLinkContainer class.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
const xAOD::IParticleLinkContainer & partLinks() const
Get all constituents in one go.
std::vector< size_t > vec
Helper class to provide constant type-safe access to aux data.
double py() const
Get the py momentum component of the particle.
void setCharge(float charge)
Set the electric charge.
This class provides conversion from CSC RDO data to CSC Digits.
void addPart(const xAOD::IParticle *part, bool updateFourMom=true)
Add a particle as an additional constituent.
Class providing the definition of the 4-vector interface.
XAOD_AUXDATA_DEPRECATED bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for reading.
void removeMissingET(bool updateFourMom=true)
Remove the existing MissingET object from this CompositeParticle.
bool isValid() const
Test to see if the link can be dereferenced.
Class describing an photon
const xAOD::IParticle * part(std::size_t index=0) const
Get the constituent IParticle number i.
virtual double pt() const
The transverse momentum ( ) of the particle.
TLorentzVector FourMom_t
Definition of the 4-momentum type.
#define NUM_OTHERPARTS(FUNCNAME, OBJTYPE)
CompositeParticle_v1 CompositeParticle
Define the latest version of the composite particle class.
float weightHelper(const xAOD::IParticle *part, const xAOD::IParticle::ConstAccessor< float > &varAcc) const
This is a private helper method to calculate the weight.
virtual double phi() const
The azimuthal angle ( ) of the particle.
size_t index() const
Return the index of this element within its container.
void addOtherParts(const xAOD::IParticleLinkContainer &partLinkCont)
Add many other constituents at the same time.
void setPxPyPzE(double px, double py, double pz, double e)
Set the 4-vec.
AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(CompositeParticle_v1, float, double, px, setPx) AUXSTORE_PRIMITIVE_SETTER_WITH_CAST(CompositeParticle_v1
double mt(const std::vector< int > &partIndices, MT::Method method=MT::DEFAULT) const
Get the transverse mass.
string varName
end cluster ToT and charge
void addParts(const xAOD::IParticleLinkContainer &partLinkCont, bool updateFourMom=true)
Add many constituents at the same time Note that the 4-momentum of this CompositeParticle will be upd...
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Class describing a truth particle in the MC record.
Description of a composite particle, i.e.
Principal data object for Missing ET.
float mpx() const
Returns .
void removeOtherPart(const xAOD::IParticle *part)
Remove a particle as an other constituent from this CompostiteParticle.
CompositeParticle_v1()
Default constructor.
size_t index() const
Return the index of this element within its container.
GenVecFourMom_t genvecP4() const
The full 4-momentum of the particle : GenVector form Note: can be slower than just p4 for this class;...
#define NUM_OTHERTRUTHPARTS(FUNCNAME, PIDMETHOD)
Container for xAOD::MissingET_v1 objects.
double pz() const
Get the pz momentum component of the particle.
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
const xAOD::IParticleLinkContainer & otherPartLinks() const
Get all other constituents in one go.
double px() const
Get the px momentum component of the particle.
virtual double eta() const
The pseudorapidity ( ) of the particle.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
double p(const std::vector< int > &partIndices) const
The total 3-momentum.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
void makePrivateStore()
Create a new (empty) private store for this object.
virtual FourMom_t p4() const =0
The full 4-momentum of the particle.
void addOtherPart(const xAOD::IParticle *part)
Add a particle as an additional other constituent.
xAOD::CompositeParticle_v1 * compPart(const std::vector< int > &partIndices, const std::vector< int > &otherPartIndices=std::vector< int >{}, bool updateFourMom=true) const
Get a CompositeParticle that is build on the fly from the constituent particles associated to the ind...
float charge() const
Return the electric charge.
const xAOD::IParticleLink & otherPartLink(std::size_t index=0) const
Get the other constituent IParticle number i as an ElementLink.
DataVector adapter that acts like it holds const pointers.
void setMissingET(const xAOD::MissingET *met, bool updateFourMom=true)
Set the MissingET for this CompositeParticle.
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
void removePart(const xAOD::IParticle *part, bool updateFourMom=true)
Remove a particle as a constituent from this CompostiteParticle.
Class describing an electron.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
IParticleLink_v1 IParticleLink
Define the latest version of the IParticleLink class.
DV::const_value_type const * const_pointer
const SG::AuxVectorData * container() const
Return the container holding this element.
void setP4(const FourMom_t &vec)
Set the 4-vec.
ObjectType
Type of objects that have a representation in the xAOD EDM.
float mpy() const
Returns .
const xAOD::IParticle * otherPart(std::size_t index=0) const
Get the other constituent IParticle number i.
void toPersistent()
Function preparing the object to be persistified.
float met() const
Returns .
const xAOD::MissingET * missingET() const
Get the MissingET object that is associated with this CompositeParticle.
bool hasPdgId() const
Check if this composite particle has its charge set.
float weight(const std::vector< std::string > &varNames, const std::vector< int > &partIndices={}) const
Get the weight for this xAOD::CompositeParticle by providing a vector of variable names that will be ...
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1