11#ifndef EVENTUTILS_PARTICLESORTINGTOOL_H
12#define EVENTUTILS_PARTICLESORTINGTOOL_H 1
43 const std::string& name,
44 const IInterface* parent );
53 virtual StatusCode
finalize()
override;
57 virtual StatusCode
addBranches(
const EventContext& ctx)
const final override;
68 template<
class CONTAINERTYPE>
102 StringProperty
m_inCollKey{
this,
"InputContainer",
"",
"Input container name" };
105 StringProperty
m_outCollKey{
this,
"OutputContainer",
"",
"The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects" };
108 StringProperty
m_sortVar{
this,
"SortVariable",
"pt",
"Define by what parameter to sort (default: 'pt'; allowed: 'pt', 'eta', 'phi', 'm', 'e', 'rapidity')" };
111 BooleanProperty
m_sortDescending{
this,
"SortDescending",
true,
"Define if the container should be sorted in a descending order (default=true)" };
129template<
class CONTAINERTYPE>
134 return StatusCode::FAILURE;
143 else if ( std::abs(
m_sortID) == 2 ) {
148 else if ( std::abs(
m_sortID) == 3 ) {
153 else if ( std::abs(
m_sortID) == 4 ) {
158 else if ( std::abs(
m_sortID) == 5 ) {
163 else if ( std::abs(
m_sortID) == 6 ) {
168 else if ( std::abs(
m_sortID) == 7 ) {
174 return StatusCode::SUCCESS;
DataVector adapter that acts like it holds const pointers.
DataVector adapter that acts like it holds const pointers.
StatusCode doSortConst(ConstDataVector< CONTAINERTYPE > *cont) const
Helper method to sort a ConstDataVector.
StatusCode doSort(xAOD::IParticleContainer *cont) const
Helper method that implements the call to the right sort function.
StringProperty m_inCollKey
Input container name.
bool compareEnergy(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's energy.
virtual ~ParticleSortingTool()
Destructor:
bool compareAuxData(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare an auxdata member of the particle.
BooleanProperty m_sortDescending
Define if the container should be sorted in a descending order (default=true)
int m_sortID
Internal identifier for the type of sorting.
std::atomic< unsigned long > m_nEventsProcessed
Internal event counter.
StringProperty m_sortVar
Define by what parameter to sort (default: 'pt')
bool comparePt(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's pt.
ParticleSortingTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual StatusCode addBranches(const EventContext &ctx) const final override
Implement the method from the ISkimmingTool interface.
bool compareRapidity(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's rapidity.
bool compareEta(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's eta.
StringProperty m_outCollKey
The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects.
virtual StatusCode initialize() override
Athena algtool's initialize.
bool compareDouble(double a, double b) const
Method to compare two doubles.
bool compareMass(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's mass.
virtual StatusCode finalize() override
Athena algtool's finalize.
bool comparePhi(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's phi.
Class providing the definition of the 4-vector interface.
Workaround x86 precision issues for FP inequality comparisons.
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
bool less(double a, double b)
Compare two FP numbers, working around x87 precision issues.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.