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

#include <ParticleRemoverAlg.h>

Inheritance diagram for ParticleRemoverAlg:
Collaboration diagram for ParticleRemoverAlg:

Public Member Functions

 ParticleRemoverAlg (const std::string &name, ISvcLocator *pSvcLocator)
 Standard constructor. More...
 
virtual ~ParticleRemoverAlg ()
 Standard destructor. More...
 
virtual StatusCode initialize ()
 Standard Gaudi initialize method called once before the event loop. More...
 
virtual StatusCode execute ()
 Standard Gaudi execute method called once for every event. More...
 
virtual StatusCode finalize ()
 Standard Gaudi finalize method called once after the event loop. More...
 
virtual StatusCode sysInitialize () override
 Override sysInitialize. More...
 
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies. More...
 
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 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 > &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

template<class CONT >
StatusCode removeParticles (const std::vector< bool > &keepParticleVec)
 Private function to perform the actualy work. More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

DataObjIDColl m_extendedExtraObjects
 
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
 
The properties that can be defined via the python job options
StringProperty m_inCont
 The input container name. More...
 
StringProperty m_separator
 The string separator between the output container name and the sytematic variation (default="___") More...
 
StringProperty m_outCont
 The output container name. More...
 
StringArrayProperty m_suffixes
 The names of all suffixes for the input and output container names. More...
 
StringArrayProperty m_viewContNames
 The names of all view containers that contain particles that we want to retain. More...
 
BooleanProperty m_resetViewConts
 Boolean to decide if the existing view containers should be re-mapped (default: true) More...
 
StringProperty m_outPrefix
 Prefix to be used for all created output view containers. More...
 

Internal members

enum  contType_t {
  UNKNOWN, PHOTON, ELECTRON, MUON,
  TAU, JET, PARITCLEFLOW, NEUTRALPARTICLE,
  TRACKPARTICLE, TRUTHPARTICLE, COMPOSITEPARTICLE, PARTICLE,
  CALOCLUSTER
}
 An enumaration for the actual container type. More...
 
std::vector< std::string > m_inContNameList
 Vector of all input container names. More...
 
std::vector< std::string > m_outContNameList
 Vector of all output container names. More...
 
std::vector< const xAOD::IParticleContainer * > m_inContList
 Vector of all input containers. More...
 
std::vector< xAOD::IParticleContainer * > m_outContList
 Vector of all output containers. More...
 
std::vector< std::vector< std::string > > m_inViewContNameListList
 Vector of all input view container names. More...
 
std::vector< std::vector< std::string > > m_outViewContNameListList
 Vector of all output view container names. More...
 
contType_t m_contType
 The variable that holds the value that we find for the input container. More...
 

Detailed Description

Definition at line 14 of file ParticleRemoverAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ contType_t

An enumaration for the actual container type.

Enumerator
UNKNOWN 
PHOTON 
ELECTRON 
MUON 
TAU 
JET 
PARITCLEFLOW 
NEUTRALPARTICLE 
TRACKPARTICLE 
TRUTHPARTICLE 
COMPOSITEPARTICLE 
PARTICLE 
CALOCLUSTER 

Definition at line 88 of file ParticleRemoverAlg.h.

88  {
89  UNKNOWN,
90  PHOTON,
91  ELECTRON,
92  MUON,
93  TAU,
94  JET,
100  PARTICLE,
102  };

Constructor & Destructor Documentation

◆ ParticleRemoverAlg()

ParticleRemoverAlg::ParticleRemoverAlg ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Standard constructor.

Definition at line 28 of file ParticleRemoverAlg.cxx.

29  : AthAlgorithm( name, pSvcLocator ),
30  m_inCont(""),
31  m_separator("___"),
32  m_outCont(""),
33  m_suffixes(),
35  m_resetViewConts(true),
36  m_outPrefix(""),
39  m_inContList(),
40  m_outContList(),
44 {
45  //
46  // Property declaration
47  //
48  declareProperty("Input", m_inCont, "Input container name" );
49  declareProperty("Output", m_outCont,
50  "The name of the output container with the deep copy of input objects" );
51 
52  declareProperty("Separator", m_separator,
53  "The string seperator between the output container name and the sytematic variation (default='___')" );
54 
55  declareProperty("Suffixes", m_suffixes,
56  "The names of all suffixes for the input and output container names" );
57 
58  declareProperty("SelectedViewContainers", m_viewContNames,
59  "The names of all view containers that contain particles that we want to retain" );
60 
61  declareProperty("RemapViewContainers", m_resetViewConts,
62  "Boolean to decide if the existing view containers should be re-mapped (default: true)" );
63 
64  declareProperty("OutputViewContainerPrefix", m_outPrefix,
65  "Prefix to be used for all created output view containers" );
66 }

◆ ~ParticleRemoverAlg()

ParticleRemoverAlg::~ParticleRemoverAlg ( )
virtual

Standard destructor.

Definition at line 69 of file ParticleRemoverAlg.cxx.

69 {}

Member Function Documentation

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  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< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  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< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  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< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  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  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::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< Algorithm > >::declareProperty ( Gaudi::Property< T > &  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< Algorithm > >::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; }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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; }

◆ execute()

StatusCode ParticleRemoverAlg::execute ( )
virtual

Standard Gaudi execute method called once for every event.

Definition at line 210 of file ParticleRemoverAlg.cxx.

211 {
212  ATH_MSG_DEBUG ("Executing " << name() << "...");
213  // Let's first clear some stuff
214  m_inContList.clear();
215  m_inContList.resize(m_inContNameList.size());
216  m_outContList.clear();
217 
218  // Figure out what type the input container has, if we didn't do it yet
219  if ( m_contType == UNKNOWN ){
220  if ( evtStore()->contains<xAOD::PhotonContainer>(m_inCont.value()) ){ m_contType = PHOTON; }
221  else if ( evtStore()->contains<xAOD::ElectronContainer>(m_inCont.value()) ){ m_contType = ELECTRON; }
222  else if ( evtStore()->contains<xAOD::MuonContainer>(m_inCont.value()) ){ m_contType = MUON; }
223  else if ( evtStore()->contains<xAOD::TauJetContainer>(m_inCont.value()) ){ m_contType = TAU; }
224  else if ( evtStore()->contains<xAOD::JetContainer>(m_inCont.value()) ){ m_contType = JET; }
225  else if ( evtStore()->contains<xAOD::TruthParticleContainer>(m_inCont.value()) ){ m_contType = TRUTHPARTICLE; }
226  else if ( evtStore()->contains<xAOD::CompositeParticleContainer>(m_inCont.value()) ){ m_contType = COMPOSITEPARTICLE; }
227  else if ( evtStore()->contains<xAOD::PFOContainer>(m_inCont.value()) ){ m_contType = PARITCLEFLOW; }
228  else if ( evtStore()->contains<xAOD::NeutralParticleContainer>(m_inCont.value()) ){ m_contType = NEUTRALPARTICLE; }
229  else if ( evtStore()->contains<xAOD::TrackParticleContainer>(m_inCont.value()) ){ m_contType = TRACKPARTICLE; }
230  else if ( evtStore()->contains<xAOD::ParticleContainer>(m_inCont.value()) ){ m_contType = PARTICLE; }
231  else if ( evtStore()->contains<xAOD::CaloClusterContainer>(m_inCont.value()) ){ m_contType = CALOCLUSTER; }
232  }
233  if ( m_contType == UNKNOWN ){
234  ATH_MSG_FATAL("We couldn't determine the type of the container... abort!");
235  return StatusCode::FAILURE;
236  }
237 
238  // Open the input container
239  for ( std::size_t i=0; i<m_inContNameList.size(); ++i ) {
241  }
242 
243  // Make a quick check that all input containers have the same size
244  const std::size_t inContSize = m_inContList[0]->size();
245  for ( const xAOD::IParticleContainer* inCont : m_inContList ){
246  if ( inContSize != inCont->size() ){
247  ATH_MSG_FATAL("The input container and its shallow copies don't have the same size! Aborting...");
248  return StatusCode::FAILURE;
249  }
250  }
251 
252  // Create a vector of bools with the same size as the input container. This
253  // will be used to say if we want to keep that particular object.
254  // All entries will be initialized to false.
255  std::vector<bool> keepParticleVec (inContSize, false);
256  // Now, loop over all view containers and flag the particles that we want to
257  // keep with true in the above vector of bools.
258  for ( const std::string& viewContName : m_viewContNames.value() ){
259  const xAOD::IParticleContainer* inViewCont = nullptr;
260  ATH_CHECK( evtStore()->retrieve( inViewCont, viewContName ) );
261  // Make a quick check that the provided view containers are not larger
262  if ( inViewCont->size() > inContSize ){
263  ATH_MSG_FATAL("One of the input view containers is larger than the input container... aborting.");
264  return StatusCode::FAILURE;
265  }
266  for ( const xAOD::IParticle* part : *inViewCont ){
267  const std::size_t idx = part->index();
268  keepParticleVec[idx] = true;
269  }
270  }
271 
272  // Do the heavy lifting of actually creating the new and reduced output container(s)
273  if ( m_contType == PHOTON ){
274  ATH_CHECK( this->removeParticles<xAOD::PhotonContainer>(keepParticleVec) );
275  }
276  else if ( m_contType == ELECTRON ){
277  ATH_CHECK( this->removeParticles<xAOD::ElectronContainer>(keepParticleVec) );
278  }
279  else if ( m_contType == MUON ){
280  ATH_CHECK( this->removeParticles<xAOD::MuonContainer>(keepParticleVec) );
281  }
282  else if ( m_contType == TAU ){
283  ATH_CHECK( this->removeParticles<xAOD::TauJetContainer>(keepParticleVec) );
284  }
285  else if ( m_contType == JET ){
286  ATH_CHECK( this->removeParticles<xAOD::JetContainer>(keepParticleVec) );
287  }
288  else if ( m_contType == TRUTHPARTICLE ){
289  ATH_CHECK( this->removeParticles<xAOD::TruthParticleContainer>(keepParticleVec) );
290  }
291  else if ( m_contType == COMPOSITEPARTICLE ){
292  ATH_CHECK( this->removeParticles<xAOD::CompositeParticleContainer>(keepParticleVec) );
293  }
294  else if ( m_contType == PARITCLEFLOW ){
295  ATH_CHECK( this->removeParticles<xAOD::PFOContainer>(keepParticleVec) );
296  }
297  else if ( m_contType == NEUTRALPARTICLE ){
298  ATH_CHECK( this->removeParticles<xAOD::NeutralParticleContainer>(keepParticleVec) );
299  }
300  else if ( m_contType == TRACKPARTICLE ){
301  ATH_CHECK( this->removeParticles<xAOD::TrackParticleContainer>(keepParticleVec) );
302  }
303  else if ( m_contType == PARTICLE ){
304  ATH_CHECK( this->removeParticles<xAOD::ParticleContainer>(keepParticleVec) );
305  }
306  else if ( m_contType == CALOCLUSTER ){
307  ATH_CHECK( this->removeParticles<xAOD::CaloClusterContainer>(keepParticleVec) );
308  }
309 
310  return StatusCode::SUCCESS;
311 }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::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

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51 {
52  // If we didn't find any symlinks to add, just return the collection
53  // from the base class. Otherwise, return the extended collection.
54  if (!m_extendedExtraObjects.empty()) {
56  }
57  return Algorithm::extraOutputDeps();
58 }

◆ finalize()

StatusCode ParticleRemoverAlg::finalize ( )
virtual

Standard Gaudi finalize method called once after the event loop.

Definition at line 201 of file ParticleRemoverAlg.cxx.

202 {
203  ATH_MSG_DEBUG ("Finalizing " << name() << "...");
204 
205  return StatusCode::SUCCESS;
206 }

◆ initialize()

StatusCode ParticleRemoverAlg::initialize ( )
virtual

Standard Gaudi initialize method called once before the event loop.

Definition at line 72 of file ParticleRemoverAlg.cxx.

73 {
74  ATH_MSG_DEBUG ("Initializing " << name() << "...");
75 
76  // Print the configuration to the log file
77  ATH_MSG_DEBUG( "Using: " << m_inCont );
78  ATH_MSG_DEBUG( "Using: " << m_outCont );
79  ATH_MSG_DEBUG( "Using: " << m_separator );
80  ATH_MSG_DEBUG( "Using: " << m_suffixes );
81  ATH_MSG_DEBUG( "Using: " << m_viewContNames );
82  ATH_MSG_DEBUG( "Using: " << m_resetViewConts );
83  ATH_MSG_DEBUG( "Using: " << m_outPrefix );
84 
85  // Perform some sanity checks on the given container names
86  if ( m_inCont.value().empty() || m_outCont.value().empty() || m_viewContNames.value().empty() ) {
87  ATH_MSG_ERROR("Wrong user setup! You need to give a valid name for both the Input, Output, and SelectedViewContainers!");
88  return StatusCode::FAILURE;
89  }
90 
91  // Abort on an unchecked systematics code
92  // StatusCode::enableFailure();
93 
94  // Build the vector of all input and output container names
95  const std::size_t totSize = 1 + m_suffixes.value().size(); // the '1' comes from the InputContainer
96  m_inContNameList.resize(totSize);
97  m_inContList.resize(totSize);
98  m_outContNameList.resize(totSize);
99  m_inContNameList[0] = m_inCont.value();
100  m_outContNameList[0] = m_outCont.value();
101  for ( std::size_t i=1; i<totSize; ++i ) {
102  const std::string& currentSuffix = m_suffixes.value()[i-1];
103  ATH_MSG_VERBOSE("Using current suffix " << currentSuffix << " to search for matching containers");
104  if ( currentSuffix.rfind( m_separator.value(),0 ) == 0 ) { // If the currentSuffix starts with m_separator.value()
105  m_inContNameList[i] = m_inCont.value() + currentSuffix;
106  m_outContNameList[i] = m_outCont.value() + currentSuffix;
107  }
108  else {
109  m_inContNameList[i] = m_inCont.value() + m_separator.value() + currentSuffix;
110  m_outContNameList[i] = m_outCont.value() + m_separator.value() + currentSuffix;
111  }
112  }
113  // Print out the matches that we found
114  if ( msgLvl(MSG::VERBOSE) ) {
115  for ( std::size_t i=0; i<m_inContNameList.size(); ++i ){
116  ATH_MSG_VERBOSE("Matched input number " << i << " with input name " << m_inContNameList[i] << " to output name " << m_outContNameList[i]);
117  }
118  }
119 
120 
121 
122  // Now, also try to map all the view container names to the input (shallow
123  // copy) containers. Set up with that the correct mapping of the new output
124  // view container names.
125  // Assume that all names where we have a suffix, but where we cannot match it
126  // to a suffix of the input container, it belongs to the origninal one.
127  if ( m_resetViewConts.value() || !(m_outPrefix.value().empty()) ){
128  ATH_MSG_VERBOSE("Going to iterate over " << totSize << " elements");
129  m_inViewContNameListList.reserve(totSize);
130  m_outViewContNameListList.reserve(totSize);
131  for ( std::size_t i=0; i<totSize; ++i ) {
132  ATH_MSG_VERBOSE("At " << i << "-th element");
133  if (i==0){
134  // This is the master container without any "___" in its name
135  std::vector<std::string> inViewNames;
136  std::vector<std::string> outViewNames;
137  for ( const std::string& inViewName : m_viewContNames.value() ){
138  ATH_MSG_VERBOSE("Looking at input view container name: " << inViewName);
139  std::size_t pos = inViewName.find(m_separator.value());
140  if ( pos == std::string::npos ){ // the separator is not found
141  ATH_MSG_VERBOSE("No seperator found");
142  inViewNames.push_back(inViewName);
143  outViewNames.push_back( m_outPrefix.value() + inViewName );
144  ATH_MSG_VERBOSE("Added input name " << inViewNames.back() << " and output name " << outViewNames.back());
145  }
146  else {
147  pos += m_separator.value().length();
148  const std::string foundSuffix = inViewName.substr(pos, std::string::npos);
149  ATH_MSG_VERBOSE("Seperator found and suffix found: " << foundSuffix);
150  // the separator is found, but the found suffix doesn't match any of the provided ones
151  if ( std::find( m_suffixes.value().begin(), m_suffixes.value().end(), foundSuffix) == m_suffixes.value().end() ){
152  inViewNames.push_back(inViewName);
153  outViewNames.push_back( m_outPrefix.value() + inViewName );
154  ATH_MSG_VERBOSE("Added2 input name " << inViewNames.back() << " and output name " << outViewNames.back());
155  }
156  }
157  }
158  m_inViewContNameListList.push_back(inViewNames);
159  m_outViewContNameListList.push_back(outViewNames);
160  }
161  else {
162  const std::string& currentSuffix = m_suffixes.value()[i-1];
163  ATH_MSG_VERBOSE("Looking at current suffix: " << currentSuffix);
164  std::vector<std::string> inViewNames;
165  std::vector<std::string> outViewNames;
166  for ( const std::string& inViewName : m_viewContNames.value() ){
167  ATH_MSG_VERBOSE("Looking at current input view container name: " << inViewName);
168  if ( inViewName.find(m_separator.value()+currentSuffix) != std::string::npos ){ // the suffix is found
169  inViewNames.push_back(inViewName);
170  outViewNames.push_back( m_outPrefix.value() + inViewName );
171  ATH_MSG_VERBOSE("Added3 input name " << inViewNames.back() << " and output name " << outViewNames.back());
172  }
173  }
174  m_inViewContNameListList.push_back(inViewNames);
175  m_outViewContNameListList.push_back(outViewNames);
176  }
177  } // End: loop over all containers
178  }
179  // Some sanity printouts
180  if ( msgLvl(MSG::VERBOSE) ) {
181  ATH_MSG_VERBOSE("Printing final input and output names...");
182  for ( std::size_t i=0; i<m_inViewContNameListList.size(); ++i ){
183  ATH_MSG_VERBOSE(" At i=" << i << "-th element");
184  const std::vector<std::string>& inViewNameList = m_inViewContNameListList[i];
185  const std::vector<std::string>& outViewNameList = m_outViewContNameListList[i];
186  ATH_MSG_VERBOSE(" Have " << inViewNameList.size() << " in view elements and " << outViewNameList.size() << " out view elements");
187  for ( std::size_t j=0; j<inViewNameList.size(); ++j ){
188  ATH_MSG_VERBOSE(" At j=" << j << "-th element");
189  const std::string& inName = inViewNameList[j];
190  const std::string& outName = outViewNameList[j];
191  ATH_MSG_VERBOSE(" Have input name " << inName << " paired with out name " << outName);
192  }
193  }
194  }
195 
196  return StatusCode::SUCCESS;
197 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

MsgStream& AthCommonMsg< Algorithm >::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< Algorithm >::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< Algorithm > >::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.

◆ removeParticles()

template<class CONT >
StatusCode ParticleRemoverAlg::removeParticles ( const std::vector< bool > &  keepParticleVec)
private

Private function to perform the actualy work.

◆ 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< Algorithm > >::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< Algorithm > >::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()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, PyAthena::Alg, and AthHistogramAlgorithm.

Definition at line 66 of file AthAlgorithm.cxx.

66  {
68 
69  if (sc.isFailure()) {
70  return sc;
71  }
72  ServiceHandle<ICondSvc> cs("CondSvc",name());
73  for (auto h : outputHandles()) {
74  if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75  // do this inside the loop so we don't create the CondSvc until needed
76  if ( cs.retrieve().isFailure() ) {
77  ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78  return StatusCode::SUCCESS;
79  }
80  if (cs->regHandle(this,*h).isFailure()) {
81  sc = StatusCode::FAILURE;
82  ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83  << " with CondSvc");
84  }
85  }
86  }
87  return sc;
88 }

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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_contType

contType_t ParticleRemoverAlg::m_contType
private

The variable that holds the value that we find for the input container.

Definition at line 105 of file ParticleRemoverAlg.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_inCont

StringProperty ParticleRemoverAlg::m_inCont
private

The input container name.

Definition at line 42 of file ParticleRemoverAlg.h.

◆ m_inContList

std::vector< const xAOD::IParticleContainer* > ParticleRemoverAlg::m_inContList
private

Vector of all input containers.

Definition at line 75 of file ParticleRemoverAlg.h.

◆ m_inContNameList

std::vector<std::string> ParticleRemoverAlg::m_inContNameList
private

Vector of all input container names.

Definition at line 69 of file ParticleRemoverAlg.h.

◆ m_inViewContNameListList

std::vector< std::vector<std::string> > ParticleRemoverAlg::m_inViewContNameListList
private

Vector of all input view container names.

Definition at line 81 of file ParticleRemoverAlg.h.

◆ m_outCont

StringProperty ParticleRemoverAlg::m_outCont
private

The output container name.

Definition at line 48 of file ParticleRemoverAlg.h.

◆ m_outContList

std::vector< xAOD::IParticleContainer* > ParticleRemoverAlg::m_outContList
private

Vector of all output containers.

Definition at line 78 of file ParticleRemoverAlg.h.

◆ m_outContNameList

std::vector<std::string> ParticleRemoverAlg::m_outContNameList
private

Vector of all output container names.

Definition at line 72 of file ParticleRemoverAlg.h.

◆ m_outPrefix

StringProperty ParticleRemoverAlg::m_outPrefix
private

Prefix to be used for all created output view containers.

Definition at line 60 of file ParticleRemoverAlg.h.

◆ m_outViewContNameListList

std::vector< std::vector<std::string> > ParticleRemoverAlg::m_outViewContNameListList
private

Vector of all output view container names.

Definition at line 84 of file ParticleRemoverAlg.h.

◆ m_resetViewConts

BooleanProperty ParticleRemoverAlg::m_resetViewConts
private

Boolean to decide if the existing view containers should be re-mapped (default: true)

Definition at line 57 of file ParticleRemoverAlg.h.

◆ m_separator

StringProperty ParticleRemoverAlg::m_separator
private

The string separator between the output container name and the sytematic variation (default="___")

Definition at line 45 of file ParticleRemoverAlg.h.

◆ m_suffixes

StringArrayProperty ParticleRemoverAlg::m_suffixes
private

The names of all suffixes for the input and output container names.

Definition at line 51 of file ParticleRemoverAlg.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_viewContNames

StringArrayProperty ParticleRemoverAlg::m_viewContNames
private

The names of all view containers that contain particles that we want to retain.

Definition at line 54 of file ParticleRemoverAlg.h.


The documentation for this class was generated from the following files:
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ParticleRemoverAlg::m_outContNameList
std::vector< std::string > m_outContNameList
Vector of all output container names.
Definition: ParticleRemoverAlg.h:72
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ParticleRemoverAlg::PARITCLEFLOW
@ PARITCLEFLOW
Definition: ParticleRemoverAlg.h:95
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ParticleRemoverAlg::m_outViewContNameListList
std::vector< std::vector< std::string > > m_outViewContNameListList
Vector of all output view container names.
Definition: ParticleRemoverAlg.h:84
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
ParticleRemoverAlg::m_contType
contType_t m_contType
The variable that holds the value that we find for the input container.
Definition: ParticleRemoverAlg.h:105
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ParticleRemoverAlg::m_suffixes
StringArrayProperty m_suffixes
The names of all suffixes for the input and output container names.
Definition: ParticleRemoverAlg.h:51
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
AthCommonMsg< Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
ParticleRemoverAlg::UNKNOWN
@ UNKNOWN
Definition: ParticleRemoverAlg.h:89
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
ParticleRemoverAlg::PHOTON
@ PHOTON
Definition: ParticleRemoverAlg.h:90
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ParticleRemoverAlg::NEUTRALPARTICLE
@ NEUTRALPARTICLE
Definition: ParticleRemoverAlg.h:96
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
ParticleRemoverAlg::COMPOSITEPARTICLE
@ COMPOSITEPARTICLE
Definition: ParticleRemoverAlg.h:99
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
AthCommonDataStore
Definition: AthCommonDataStore.h:52
AthAlgorithm::sysInitialize
virtual StatusCode sysInitialize() override
Override sysInitialize.
Definition: AthAlgorithm.cxx:66
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
lumiFormat.i
int i
Definition: lumiFormat.py:92
ParticleRemoverAlg::TAU
@ TAU
Definition: ParticleRemoverAlg.h:93
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ParticleRemoverAlg::m_resetViewConts
BooleanProperty m_resetViewConts
Boolean to decide if the existing view containers should be re-mapped (default: true)
Definition: ParticleRemoverAlg.h:57
ParticleRemoverAlg::m_viewContNames
StringArrayProperty m_viewContNames
The names of all view containers that contain particles that we want to retain.
Definition: ParticleRemoverAlg.h:54
ParticleRemoverAlg::m_inContNameList
std::vector< std::string > m_inContNameList
Vector of all input container names.
Definition: ParticleRemoverAlg.h:69
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ParticleRemoverAlg::JET
@ JET
Definition: ParticleRemoverAlg.h:94
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
ParticleRemoverAlg::ELECTRON
@ ELECTRON
Definition: ParticleRemoverAlg.h:91
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
ParticleRemoverAlg::m_outCont
StringProperty m_outCont
The output container name.
Definition: ParticleRemoverAlg.h:48
TestSUSYToolsAlg.outName
string outName
Definition: TestSUSYToolsAlg.py:181
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ParticleRemoverAlg::m_inViewContNameListList
std::vector< std::vector< std::string > > m_inViewContNameListList
Vector of all input view container names.
Definition: ParticleRemoverAlg.h:81
ParticleRemoverAlg::CALOCLUSTER
@ CALOCLUSTER
Definition: ParticleRemoverAlg.h:101
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
ParticleRemoverAlg::m_inContList
std::vector< const xAOD::IParticleContainer * > m_inContList
Vector of all input containers.
Definition: ParticleRemoverAlg.h:75
AthAlgorithm::m_extendedExtraObjects
DataObjIDColl m_extendedExtraObjects
Definition: AthAlgorithm.h:79
a
TList * a
Definition: liststreamerinfos.cxx:10
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ParticleRemoverAlg::PARTICLE
@ PARTICLE
Definition: ParticleRemoverAlg.h:100
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
ParticleRemoverAlg::m_outContList
std::vector< xAOD::IParticleContainer * > m_outContList
Vector of all output containers.
Definition: ParticleRemoverAlg.h:78
AthAlgorithm::AthAlgorithm
AthAlgorithm()
Default constructor:
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
LHEF::Writer
Pythia8::Writer Writer
Definition: Prophecy4fMerger.cxx:12
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14
ParticleRemoverAlg::m_separator
StringProperty m_separator
The string separator between the output container name and the sytematic variation (default="___")
Definition: ParticleRemoverAlg.h:45
ParticleRemoverAlg::m_outPrefix
StringProperty m_outPrefix
Prefix to be used for all created output view containers.
Definition: ParticleRemoverAlg.h:60
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
ParticleRemoverAlg::TRACKPARTICLE
@ TRACKPARTICLE
Definition: ParticleRemoverAlg.h:97
ParticleRemoverAlg::MUON
@ MUON
Definition: ParticleRemoverAlg.h:92
fitman.k
k
Definition: fitman.py:528
ParticleRemoverAlg::TRUTHPARTICLE
@ TRUTHPARTICLE
Definition: ParticleRemoverAlg.h:98
ParticleRemoverAlg::m_inCont
StringProperty m_inCont
The input container name.
Definition: ParticleRemoverAlg.h:42
ServiceHandle< ICondSvc >