ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ParticleSortingTool Class Reference

#include <ParticleSortingTool.h>

Inheritance diagram for ParticleSortingTool:
Collaboration diagram for ParticleSortingTool:

Public Member Functions

 ParticleSortingTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters: More...
 
virtual ~ParticleSortingTool ()
 Destructor: More...
 
virtual StatusCode initialize () override
 Athena algtool's initialize. More...
 
virtual StatusCode finalize () override
 Athena algtool's finalize. More...
 
virtual StatusCode addBranches () const final override
 Implement the method from the ISkimmingTool interface. More...
 
 DeclareInterfaceID (IAugmentationTool, 1, 0)
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

StatusCode doSort (xAOD::IParticleContainer *cont) const
 Helper method that implements the call to the right sort function. More...
 
template<class CONTAINERTYPE >
StatusCode doSortConst (ConstDataVector< CONTAINERTYPE > *cont) const
 Helper method to sort a ConstDataVector. More...
 
bool comparePt (const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
 The method to compare the particle's pt. More...
 
bool compareEta (const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
 The method to compare the particle's eta. More...
 
bool comparePhi (const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
 The method to compare the particle's phi. More...
 
bool compareMass (const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
 The method to compare the particle's mass. More...
 
bool compareEnergy (const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
 The method to compare the particle's energy. More...
 
bool compareRapidity (const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
 The method to compare the particle's rapidity. More...
 
bool compareAuxData (const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
 The method to compare an auxdata member of the particle. More...
 
bool compareDouble (double a, double b) const
 Method to compare two doubles. More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

StringProperty m_inCollKey { this, "InputContainer", "", "Input container name" }
 Input container name. More...
 
StringProperty m_outCollKey { this, "OutputContainer", "", "The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects" }
 The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects. More...
 
StringProperty m_sortVar { this, "SortVariable", "pt", "Define by what parameter to sort (default: 'pt'; allowed: 'pt', 'eta', 'phi', 'm', 'e', 'rapidity')" }
 Define by what parameter to sort (default: 'pt') More...
 
BooleanProperty m_sortDescending { this, "SortDescending", true, "Define if the container should be sorted in a descending order (default=true)" }
 Define if the container should be sorted in a descending order (default=true) More...
 
int m_sortID {0}
 Internal identifier for the type of sorting. More...
 
std::atomic< unsigned long > m_nEventsProcessed {0}
 Internal event counter. More...
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 29 of file ParticleSortingTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ParticleSortingTool()

ParticleSortingTool::ParticleSortingTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Constructor with parameters:

Definition at line 34 of file ParticleSortingTool.cxx.

36  :
38 {
39  declareInterface< DerivationFramework::IAugmentationTool >(this);
40 }

◆ ~ParticleSortingTool()

ParticleSortingTool::~ParticleSortingTool ( )
virtual

Destructor:

Definition at line 45 of file ParticleSortingTool.cxx.

46 {}

Member Function Documentation

◆ addBranches()

StatusCode ParticleSortingTool::addBranches ( ) const
finaloverridevirtual

Implement the method from the ISkimmingTool interface.

Implements DerivationFramework::IAugmentationTool.

Definition at line 122 of file ParticleSortingTool.cxx.

123 {
124  // Increase the event counter
126 
127  // Simple status message at the beginning of each event execute,
128  ATH_MSG_DEBUG ( "==> addBranches " << name() << " on " << m_nEventsProcessed << ". event..." );
129 
130  if ( m_outCollKey.value().empty() ) {
131  // Try to get the input container as non-const
132  ATH_MSG_DEBUG("Got an empty 'OutputCollection' property. "
133  << "Trying to retrieve a non-const version of the 'InputContainer'...");
134  xAOD::IParticleContainer* inCont = evtStore()->tryRetrieve<xAOD::IParticleContainer>( m_inCollKey.value() );
135  if (inCont){ ATH_CHECK( this->doSort(inCont) ); }
136  else {
137  ATH_MSG_DEBUG("We couldn't retrieve a non-const version of the input container... try const.");
138  const xAOD::IParticleContainer* inCont2 = nullptr;
139  ATH_CHECK( evtStore()->retrieve( inCont2, m_inCollKey.value()) );
140  // Now, do the copy and sorting and overwriting of all known container types
141  if (false) {
142  }
155  else {
156  ATH_MSG_ERROR("Couln't find the provided intput container in store gate for later overwriting");
157  return StatusCode::FAILURE;
158  }
159  }
160  }
161  else {
162  ATH_MSG_DEBUG("Got a non-empty 'OutputCollection' property. "
163  << "Trying to retrieve a const version of the 'InputContainer'...");
164 
165  // Now, do the copy and sorting of all known container types
166  if (false) {
167  }
180  else {
181  ATH_MSG_ERROR("Couln't find the provided intput container in store gate");
182  return StatusCode::FAILURE;
183  }
184 
185  }
186 
187  return StatusCode::SUCCESS;
188 }

◆ compareAuxData()

bool ParticleSortingTool::compareAuxData ( const xAOD::IParticle partA,
const xAOD::IParticle partB 
) const
private

The method to compare an auxdata member of the particle.

Definition at line 293 of file ParticleSortingTool.cxx.

295 {
296  SG::ConstAccessor<float> acc( this->m_sortVar.value() );
297  return this->compareDouble(acc(*partA),acc(*partB));
298 }

◆ compareDouble()

bool ParticleSortingTool::compareDouble ( double  a,
double  b 
) const
inlineprivate

Method to compare two doubles.

Definition at line 122 of file ParticleSortingTool.h.

123 {
124  if ( m_sortID < 0 ) { return CxxUtils::fpcompare::greater(a,b); }
125  else { return CxxUtils::fpcompare::less(a,b); }
126 }

◆ compareEnergy()

bool ParticleSortingTool::compareEnergy ( const xAOD::IParticle partA,
const xAOD::IParticle partB 
) const
private

The method to compare the particle's energy.

Definition at line 276 of file ParticleSortingTool.cxx.

278 {
279  const double a = partA->e();
280  const double b = partB->e();
281  return this->compareDouble(a,b);
282 }

◆ compareEta()

bool ParticleSortingTool::compareEta ( const xAOD::IParticle partA,
const xAOD::IParticle partB 
) const
private

The method to compare the particle's eta.

Definition at line 249 of file ParticleSortingTool.cxx.

251 {
252  const double a = partA->eta();
253  const double b = partB->eta();
254  return this->compareDouble(a,b);
255 }

◆ compareMass()

bool ParticleSortingTool::compareMass ( const xAOD::IParticle partA,
const xAOD::IParticle partB 
) const
private

The method to compare the particle's mass.

Definition at line 267 of file ParticleSortingTool.cxx.

269 {
270  const double a = partA->m();
271  const double b = partB->m();
272  return this->compareDouble(a,b);
273 }

◆ comparePhi()

bool ParticleSortingTool::comparePhi ( const xAOD::IParticle partA,
const xAOD::IParticle partB 
) const
private

The method to compare the particle's phi.

Definition at line 258 of file ParticleSortingTool.cxx.

260 {
261  const double a = partA->phi();
262  const double b = partB->phi();
263  return this->compareDouble(a,b);
264 }

◆ comparePt()

bool ParticleSortingTool::comparePt ( const xAOD::IParticle partA,
const xAOD::IParticle partB 
) const
private

The method to compare the particle's pt.

Definition at line 240 of file ParticleSortingTool.cxx.

242 {
243  const double a = partA->pt();
244  const double b = partB->pt();
245  return this->compareDouble(a,b);
246 }

◆ compareRapidity()

bool ParticleSortingTool::compareRapidity ( const xAOD::IParticle partA,
const xAOD::IParticle partB 
) const
private

The method to compare the particle's rapidity.

Definition at line 285 of file ParticleSortingTool.cxx.

287 {
288  const double a = partA->rapidity();
289  const double b = partB->rapidity();
290  return this->compareDouble(a,b);
291 }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ DeclareInterfaceID()

DerivationFramework::IAugmentationTool::DeclareInterfaceID ( IAugmentationTool  ,
,
 
)
inherited

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ doSort()

StatusCode ParticleSortingTool::doSort ( xAOD::IParticleContainer cont) const
private

Helper method that implements the call to the right sort function.

Definition at line 192 of file ParticleSortingTool.cxx.

193 {
194  if ( !cont ) {
195  ATH_MSG_ERROR("No container to be sorted");
196  return StatusCode::FAILURE;
197  }
198  // Actually do the sorting, using a C++11 lambda function construct
199  // to be able to use the member function here
200  if ( std::abs(m_sortID) == 1 ) {
201  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
202  return this->comparePt(a,b);
203  } );
204  }
205  else if ( std::abs(m_sortID) == 2 ) {
206  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
207  return this->compareEta(a,b);
208  } );
209  }
210  else if ( std::abs(m_sortID) == 3 ) {
211  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
212  return this->comparePhi(a,b);
213  } );
214  }
215  else if ( std::abs(m_sortID) == 4 ) {
216  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
217  return this->compareMass(a,b);
218  } );
219  }
220  else if ( std::abs(m_sortID) == 5 ) {
221  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
222  return this->compareEnergy(a,b);
223  } );
224  }
225  else if ( std::abs(m_sortID) == 6 ) {
226  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
227  return this->compareRapidity(a,b);
228  } );
229  }
230  else if ( std::abs(m_sortID) == 7 ) {
231  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
232  return this->compareAuxData(a,b);
233  } );
234  }
235 
236  return StatusCode::SUCCESS;
237 }

◆ doSortConst()

template<class CONTAINERTYPE >
StatusCode ParticleSortingTool::doSortConst ( ConstDataVector< CONTAINERTYPE > *  cont) const
private

Helper method to sort a ConstDataVector.

Definition at line 130 of file ParticleSortingTool.h.

131 {
132  if ( !cont ) {
133  ATH_MSG_ERROR("No ConstDataVector to be sorted");
134  return StatusCode::FAILURE;
135  }
136  // Actually do the sorting, using a C++11 lambda function construct
137  // to be able to use the member function here
138  if ( std::abs(m_sortID) == 1 ) {
139  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
140  return this->comparePt(a,b);
141  } );
142  }
143  else if ( std::abs(m_sortID) == 2 ) {
144  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
145  return this->compareEta(a,b);
146  } );
147  }
148  else if ( std::abs(m_sortID) == 3 ) {
149  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
150  return this->comparePhi(a,b);
151  } );
152  }
153  else if ( std::abs(m_sortID) == 4 ) {
154  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
155  return this->compareMass(a,b);
156  } );
157  }
158  else if ( std::abs(m_sortID) == 5 ) {
159  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
160  return this->compareEnergy(a,b);
161  } );
162  }
163  else if ( std::abs(m_sortID) == 6 ) {
164  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
165  return this->compareRapidity(a,b);
166  } );
167  }
168  else if ( std::abs(m_sortID) == 7 ) {
169  cont->sort( [this](const xAOD::IParticle* a, const xAOD::IParticle* b) {
170  return this->compareAuxData(a,b);
171  } );
172  }
173 
174  return StatusCode::SUCCESS;
175 }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode ParticleSortingTool::finalize ( )
overridevirtual

Athena algtool's finalize.

Definition at line 84 of file ParticleSortingTool.cxx.

85 {
86  ATH_MSG_DEBUG ("Finalizing " << name() << "...");
87 
88  return StatusCode::SUCCESS;
89 }

◆ initialize()

StatusCode ParticleSortingTool::initialize ( )
overridevirtual

Athena algtool's initialize.

Definition at line 52 of file ParticleSortingTool.cxx.

53 {
54  ATH_MSG_DEBUG ("Initializing " << name() << "...");
55 
56  // Print out the used configuration
57  ATH_MSG_DEBUG ( " using = " << m_inCollKey );
58  ATH_MSG_DEBUG ( " using = " << m_outCollKey );
59 
60  // initialize the counters
61  m_sortID = 0;
63 
64  // Figure out how to sort
65  if ( m_sortVar.value() == "pt" ) { m_sortID = 1; }
66  else if ( m_sortVar.value() == "eta" ) { m_sortID = 2; }
67  else if ( m_sortVar.value() == "phi" ) { m_sortID = 3; }
68  else if ( m_sortVar.value() == "m" ) { m_sortID = 4; }
69  else if ( m_sortVar.value() == "e" ) { m_sortID = 5; }
70  else if ( m_sortVar.value() == "rapidity" ) { m_sortID = 6; }
71  else {
72  ATH_MSG_INFO("Didn't find a valid value for SortVariable=" << m_sortVar.value() << "."
73  << " Assuming it's an auxdata member");
74  m_sortID = 7;
75  }
76  if ( m_sortDescending.value() ) { m_sortID *= -1; }
77 
78  return StatusCode::SUCCESS;
79 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_inCollKey

StringProperty ParticleSortingTool::m_inCollKey { this, "InputContainer", "", "Input container name" }
private

Input container name.

Definition at line 102 of file ParticleSortingTool.h.

◆ m_nEventsProcessed

std::atomic<unsigned long> ParticleSortingTool::m_nEventsProcessed {0}
mutableprivate

Internal event counter.

Definition at line 117 of file ParticleSortingTool.h.

◆ m_outCollKey

StringProperty ParticleSortingTool::m_outCollKey { this, "OutputContainer", "", "The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects" }
private

The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects.

Definition at line 105 of file ParticleSortingTool.h.

◆ m_sortDescending

BooleanProperty ParticleSortingTool::m_sortDescending { this, "SortDescending", true, "Define if the container should be sorted in a descending order (default=true)" }
private

Define if the container should be sorted in a descending order (default=true)

Definition at line 111 of file ParticleSortingTool.h.

◆ m_sortID

int ParticleSortingTool::m_sortID {0}
private

Internal identifier for the type of sorting.

Definition at line 114 of file ParticleSortingTool.h.

◆ m_sortVar

StringProperty ParticleSortingTool::m_sortVar { this, "SortVariable", "pt", "Define by what parameter to sort (default: 'pt'; allowed: 'pt', 'eta', 'phi', 'm', 'e', 'rapidity')" }
private

Define by what parameter to sort (default: 'pt')

Definition at line 108 of file ParticleSortingTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ParticleSortingTool::compareMass
bool compareMass(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's mass.
Definition: ParticleSortingTool.cxx:267
ParticleSortingTool::compareAuxData
bool compareAuxData(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare an auxdata member of the particle.
Definition: ParticleSortingTool.cxx:293
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ParticleSortingTool::m_outCollKey
StringProperty m_outCollKey
The name of the output container (with SG::VIEW_ELEMENTS) with the sorted copy of input objects.
Definition: ParticleSortingTool.h:105
ParticleSortingTool::m_sortID
int m_sortID
Internal identifier for the type of sorting.
Definition: ParticleSortingTool.h:114
ParticleSortingTool::m_sortVar
StringProperty m_sortVar
Define by what parameter to sort (default: 'pt')
Definition: ParticleSortingTool.h:108
xAOD::IParticle::rapidity
virtual double rapidity() const =0
The true rapidity (y) of the particle.
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
COPY_AND_SORT_CONTAINER
#define COPY_AND_SORT_CONTAINER(CONTAINERTYPE)
Definition: ParticleSortingTool.cxx:94
ParticleSortingTool::comparePt
bool comparePt(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's pt.
Definition: ParticleSortingTool.cxx:240
SG::ConstAccessor< float >
ParticleSortingTool::m_nEventsProcessed
std::atomic< unsigned long > m_nEventsProcessed
Internal event counter.
Definition: ParticleSortingTool.h:117
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
ParticleSortingTool::compareRapidity
bool compareRapidity(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's rapidity.
Definition: ParticleSortingTool.cxx:285
CxxUtils::fpcompare::greater
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition: fpcompare.h:140
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
ParticleSortingTool::comparePhi
bool comparePhi(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's phi.
Definition: ParticleSortingTool.cxx:258
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ParticleSortingTool::compareEta
bool compareEta(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's eta.
Definition: ParticleSortingTool.cxx:249
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ParticleSortingTool::compareEnergy
bool compareEnergy(const xAOD::IParticle *partA, const xAOD::IParticle *partB) const
The method to compare the particle's energy.
Definition: ParticleSortingTool.cxx:276
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
ParticleSortingTool::m_sortDescending
BooleanProperty m_sortDescending
Define if the container should be sorted in a descending order (default=true)
Definition: ParticleSortingTool.h:111
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
xAOD::IParticle::pt
virtual double pt() const =0
The transverse momentum ( ) of the particle.
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
ParticleSortingTool::m_inCollKey
StringProperty m_inCollKey
Input container name.
Definition: ParticleSortingTool.h:102
CxxUtils::fpcompare::less
bool less(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition: fpcompare.h:166
ParticleSortingTool::compareDouble
bool compareDouble(double a, double b) const
Method to compare two doubles.
Definition: ParticleSortingTool.h:122
DataVector::sort
void sort()
Sort the container.
a
TList * a
Definition: liststreamerinfos.cxx:10
h
xAOD::IParticle::eta
virtual double eta() const =0
The pseudorapidity ( ) of the particle.
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:629
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
ParticleSortingTool::doSort
StatusCode doSort(xAOD::IParticleContainer *cont) const
Helper method that implements the call to the right sort function.
Definition: ParticleSortingTool.cxx:192
xAOD::IParticle::phi
virtual double phi() const =0
The azimuthal angle ( ) of the particle.
xAOD::IParticle::e
virtual double e() const =0
The total energy of the particle.
fitman.k
k
Definition: fitman.py:528
xAOD::IParticle::m
virtual double m() const =0
The invariant mass of the particle.
OVERWRITE_AND_SORT_CONTAINER
#define OVERWRITE_AND_SORT_CONTAINER(CONTAINERTYPE)
Definition: ParticleSortingTool.cxx:107