52 ATH_MSG_ERROR(
"Wrong user setup! You need to give a valid name for both the Input, Output, and SelectedViewContainers!");
53 return StatusCode::FAILURE;
60 const std::size_t totSize = 1 +
m_suffixes.value().size();
66 for ( std::size_t i=1; i<totSize; ++i ) {
67 const std::string& currentSuffix =
m_suffixes.value()[i-1];
68 ATH_MSG_VERBOSE(
"Using current suffix " << currentSuffix <<
" to search for matching containers");
69 if ( currentSuffix.rfind(
m_separator.value(),0 ) == 0 ) {
79 if (
msgLvl(MSG::VERBOSE) ) {
96 for ( std::size_t i=0; i<totSize; ++i ) {
100 std::vector<std::string> inViewNames;
101 std::vector<std::string> outViewNames;
103 ATH_MSG_VERBOSE(
"Looking at input view container name: " << inViewName);
104 std::size_t pos = inViewName.find(
m_separator.value());
105 if ( pos == std::string::npos ){
107 inViewNames.push_back(inViewName);
108 outViewNames.push_back(
m_outPrefix.value() + inViewName );
109 ATH_MSG_VERBOSE(
"Added input name " << inViewNames.back() <<
" and output name " << outViewNames.back());
113 const std::string foundSuffix = inViewName.substr(pos, std::string::npos);
117 inViewNames.push_back(inViewName);
118 outViewNames.push_back(
m_outPrefix.value() + inViewName );
119 ATH_MSG_VERBOSE(
"Added2 input name " << inViewNames.back() <<
" and output name " << outViewNames.back());
127 const std::string& currentSuffix =
m_suffixes.value()[i-1];
129 std::vector<std::string> inViewNames;
130 std::vector<std::string> outViewNames;
132 ATH_MSG_VERBOSE(
"Looking at current input view container name: " << inViewName);
133 if ( inViewName.find(
m_separator.value()+currentSuffix) != std::string::npos ){
134 inViewNames.push_back(inViewName);
135 outViewNames.push_back(
m_outPrefix.value() + inViewName );
136 ATH_MSG_VERBOSE(
"Added3 input name " << inViewNames.back() <<
" and output name " << outViewNames.back());
145 if (
msgLvl(MSG::VERBOSE) ) {
151 ATH_MSG_VERBOSE(
" Have " << inViewNameList.size() <<
" in view elements and " << outViewNameList.size() <<
" out view elements");
152 for ( std::size_t j=0; j<inViewNameList.size(); ++j ){
154 const std::string& inName = inViewNameList[j];
155 const std::string& outName = outViewNameList[j];
156 ATH_MSG_VERBOSE(
" Have input name " << inName <<
" paired with out name " << outName);
161 return StatusCode::SUCCESS;
170 return StatusCode::SUCCESS;
199 ATH_MSG_FATAL(
"We couldn't determine the type of the container... abort!");
200 return StatusCode::FAILURE;
211 if ( inContSize != inCont->size() ){
212 ATH_MSG_FATAL(
"The input container and its shallow copies don't have the same size! Aborting...");
213 return StatusCode::FAILURE;
220 std::vector<bool> keepParticleVec (inContSize,
false);
227 if ( inViewCont->
size() > inContSize ){
228 ATH_MSG_FATAL(
"One of the input view containers is larger than the input container... aborting.");
229 return StatusCode::FAILURE;
232 const std::size_t idx = part->index();
233 keepParticleVec[idx] =
true;
275 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Handle mappings between names and auxid_t.
Interface for factory objects that create vectors.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
ServiceHandle< StoreGateSvc > & evtStore()
bool msgLvl(const MSG::Level lvl) const
size_type size() const noexcept
Returns the number of elements in the collection.
Gaudi::Property< std::vector< std::string > > m_suffixes
The names of all suffixes for the input and output container names.
std::vector< std::vector< std::string > > m_inViewContNameListList
Vector of all input view container names.
std::vector< std::vector< std::string > > m_outViewContNameListList
Vector of all output view container names.
StatusCode removeParticles(const std::vector< bool > &keepParticleVec)
Private function to perform the actualy work.
Gaudi::Property< bool > m_resetViewConts
Boolean to decide if the existing view containers should be re-mapped (default: true)
std::vector< xAOD::IParticleContainer * > m_outContList
Vector of all output containers.
virtual StatusCode initialize()
Standard Gaudi initialize method called once before the event loop.
std::vector< std::string > m_outContNameList
Vector of all output container names.
ParticleRemoverAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Gaudi::Property< std::string > m_separator
The string separator between the output container name and the sytematic variation (default="___")
virtual StatusCode execute()
Standard Gaudi execute method called once for every event.
virtual StatusCode finalize()
Standard Gaudi finalize method called once after the event loop.
virtual ~ParticleRemoverAlg()
Standard destructor.
Gaudi::Property< std::vector< std::string > > m_viewContNames
The names of all view containers that contain particles that we want to retain.
std::vector< std::string > m_inContNameList
Vector of all input container names.
contType_t m_contType
The variable that holds the value that we find for the input container.
std::vector< const xAOD::IParticleContainer * > m_inContList
Vector of all input containers.
Gaudi::Property< std::string > m_outCont
The output container name.
Gaudi::Property< std::string > m_outPrefix
Prefix to be used for all created output view containers.
Gaudi::Property< std::string > m_inCont
The input container name.
Class providing the definition of the 4-vector interface.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.