|
ATLAS Offline Software
|
Go to the documentation of this file.
35 const std::string&
name,
36 const IInterface*
parent ) :
41 m_sortDescending(true),
45 declareInterface< DerivationFramework::IAugmentationTool >(
this);
50 "The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects" );
53 "Define by what parameter to sort (default: 'pt'; allowed: 'pt', 'eta', 'phi', 'm', 'e', 'rapidity')" );
56 "Define if the container should be sorted in a descending order (default=true)" );
90 <<
" Assuming it's an auxdata member");
95 return StatusCode::SUCCESS;
105 return StatusCode::SUCCESS;
111 #define COPY_AND_SORT_CONTAINER( CONTAINERTYPE ) \
112 else if ( evtStore()->contains<CONTAINERTYPE>( m_inCollKey.value() ) ) { \
113 ATH_MSG_DEBUG("Trying to copy, sort, and record container of type "#CONTAINERTYPE ); \
114 const CONTAINERTYPE* inCont; \
115 ATH_CHECK( evtStore()->retrieve( inCont, m_inCollKey.value() ) ); \
116 CONTAINERTYPE* outCont = new CONTAINERTYPE( SG::VIEW_ELEMENTS ); \
117 *outCont = *inCont; \
118 ATH_CHECK( evtStore()->record ( outCont, m_outCollKey.value() ) ); \
119 ATH_CHECK( this->doSort(outCont) ); \
124 #define OVERWRITE_AND_SORT_CONTAINER( CONTAINERTYPE ) \
125 else if ( evtStore()->contains<CONTAINERTYPE>( m_inCollKey.value() ) ) { \
126 ATH_MSG_DEBUG("Trying to copy, sort, and overwrite container of type "#CONTAINERTYPE ); \
127 const CONTAINERTYPE* inCont; \
128 ATH_CHECK( evtStore()->retrieve( inCont, m_inCollKey.value() ) ); \
129 ConstDataVector<CONTAINERTYPE>* outCont = new ConstDataVector<CONTAINERTYPE>( SG::VIEW_ELEMENTS ); \
130 for ( const CONTAINERTYPE::base_value_type* inPart : *inCont ){ \
131 outCont->push_back(inPart); \
133 ATH_CHECK( evtStore()->overwrite( outCont, m_inCollKey.value() ) ); \
134 ATH_CHECK( this->doSortConst<CONTAINERTYPE>(outCont) ); \
150 <<
"Trying to retrieve a non-const version of the 'InputContainer'...");
154 ATH_MSG_DEBUG(
"We couldn't retrieve a non-const version of the input container... try const.");
173 ATH_MSG_ERROR(
"Couln't find the provided intput container in store gate for later overwriting");
174 return StatusCode::FAILURE;
179 ATH_MSG_DEBUG(
"Got a non-empty 'OutputCollection' property. "
180 <<
"Trying to retrieve a const version of the 'InputContainer'...");
198 ATH_MSG_ERROR(
"Couln't find the provided intput container in store gate");
199 return StatusCode::FAILURE;
204 return StatusCode::SUCCESS;
213 return StatusCode::FAILURE;
222 else if ( std::abs(
m_sortID) == 2 ) {
227 else if ( std::abs(
m_sortID) == 3 ) {
232 else if ( std::abs(
m_sortID) == 4 ) {
237 else if ( std::abs(
m_sortID) == 5 ) {
242 else if ( std::abs(
m_sortID) == 6 ) {
247 else if ( std::abs(
m_sortID) == 7 ) {
253 return StatusCode::SUCCESS;
260 const double a = partA->
pt();
261 const double b = partB->
pt();
269 const double a = partA->
eta();
270 const double b = partB->
eta();
278 const double a = partA->
phi();
279 const double b = partB->
phi();
287 const double a = partA->
m();
288 const double b = partB->
m();
296 const double a = partA->
e();
297 const double b = partB->
e();
def retrieve(aClass, aKey=None)
virtual StatusCode addBranches() const final override
Implement the method from the ISkimmingTool interface.
virtual ~ParticleSortingTool()
Destructor:
bool compareMass(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's mass.
bool compareAuxData(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare an auxdata member of the particle.
DataVector adapter that acts like it holds const pointers.
StringProperty m_outCollKey
The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
int m_sortID
Internal identifier for the type of sorting.
StringProperty m_sortVar
Define by what parameter to sort (default: 'pt')
virtual double rapidity() const =0
The true rapidity (y) of the particle.
#define COPY_AND_SORT_CONTAINER(CONTAINERTYPE)
bool comparePt(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's pt.
std::atomic< unsigned long > m_nEventsProcessed
Internal event counter.
Class providing the definition of the 4-vector interface.
bool compareRapidity(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's rapidity.
virtual StatusCode initialize() override
Athena algtool's initialize.
bool comparePhi(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's phi.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
bool compareEta(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's eta.
ParticleSortingTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
::StatusCode StatusCode
StatusCode definition for legacy code.
bool compareEnergy(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's energy.
BooleanProperty m_sortDescending
Define if the container should be sorted in a descending order (default=true)
virtual double pt() const =0
The transverse momentum ( ) of the particle.
StringProperty m_inCollKey
Input container name.
bool compareDouble(double a, double b) const
Method to compare two doubles.
void sort()
Sort the container.
virtual double eta() const =0
The pseudorapidity ( ) of the particle.
StatusCode doSort(xAOD::IParticleContainer *cont) const
Helper method that implements the call to the right sort function.
virtual StatusCode finalize() override
Athena algtool's finalize.
virtual double phi() const =0
The azimuthal angle ( ) of the particle.
virtual double e() const =0
The total energy of the particle.
virtual double m() const =0
The invariant mass of the particle.
#define OVERWRITE_AND_SORT_CONTAINER(CONTAINERTYPE)