18#include "Gaudi/Property.h"
19#include "GaudiKernel/SystemOfUnits.h"
42 ISvcLocator* pSvcLocator ) :
52 "Input location of particles (to be thinned)" );
56 "Filter to apply on Particles (true == keep element)" );
57 std::vector<bool> filter( 10,
false );
73 for (
int i = 0; i < 3; i++) {
74 std::ostringstream
ss;
75 std::print (
ss,
"_test{}", (i+1));
92 return StatusCode::SUCCESS;
98 return StatusCode::SUCCESS;
106 if ( !
test( ctx, 0,
"test1" ).isSuccess() ) {
111 if ( !
test( ctx, 1,
"test2" ).isSuccess() ) {
116 if ( !
test( ctx, 2,
"test3" ).isSuccess() ) {
121 return allGood ? StatusCode::SUCCESS : StatusCode::FAILURE;
125 int testNum,
const std::string& testName )
127 const std::string&
test = testName;
133 if ( !
evtStore()->retrieve(particles, particlesName).isSuccess() ||
136 (
"Could not fetch particles at [{}] !!", particlesName);
137 return StatusCode::RECOVERABLE;
143 if ( iparticles->size() != particles->size() ||
144 iparticles->at(0)->px() != particles->at(0)->px() ) {
150 return StatusCode::RECOVERABLE;
159 const double igev = 1. / Gaudi::Units::GeV;
168 ATH_MSG_INFO(
" leg1: px= {}", elephantino->leg1()->px() * igev);
169 ATH_MSG_INFO(
" leg2: px= {}", elephantino->leg2()->px() * igev);
170 ATH_MSG_INFO(
" leg3: px= {}", elephantino->leg3()->px() * igev);
171 ATH_MSG_INFO(
" leg4: px= {}", elephantino->leg4()->px() * igev);
172 ATH_MSG_INFO(
" ear1: px= {}", elephantino->ear1()->px() * igev);
173 ATH_MSG_INFO(
" ear2: px= {}", elephantino->ear2()->px() * igev);
177 if (
test ==
"test1" ) {
181 }
else if (
test ==
"test2" ) {
185 }
else if (
test ==
"test3" ) {
191 return StatusCode::FAILURE;
202 ATH_MSG_INFO(
" leg1: px= {}", elephantino->leg1()->px() * igev);
203 ATH_MSG_INFO(
" leg2: px= {}", elephantino->leg2()->px() * igev);
204 ATH_MSG_INFO(
" leg3: px= {}", elephantino->leg3()->px() * igev);
205 ATH_MSG_INFO(
" leg4: px= {}", elephantino->leg4()->px() * igev);
206 ATH_MSG_INFO(
" ear1: px= {}", elephantino->ear1()->px() * igev);
207 ATH_MSG_INFO(
" ear2: px= {}", elephantino->ear2()->px() * igev);
211 return StatusCode::SUCCESS;
219 std::vector<bool> filter =
m_filter.value();
221 const double igev = 1. / Gaudi::Units::GeV;
223 for (
unsigned int i = 0; i != particles->size(); ++i ) {
224 const std::string kr = filter[i] ?
"keep" :
"remove";
225 ATH_MSG_INFO(
"{:9} | {}", (*particles)[i]->px() * igev, kr);
229 std::fill( filter.begin() + (filter.size() / 2),
235 particles.keep (filter);
240 for ( std::size_t i = 0; i != particles->size(); ++i ) {
241 std::size_t newIdx = tmp.index( i );
250 std::fill( filter.begin(),
251 filter.begin() + (filter.size() / 2),
263 for ( std::size_t i = 0; i != particles->size(); ++i ) {
264 std::size_t newIdx = tmp.index( i );
271 return StatusCode::SUCCESS;
279 std::vector<bool> filter =
m_filter.value();
281 const double igev = 1. / Gaudi::Units::GeV;
283 for (
unsigned int i = 0; i != particles->size(); ++i ) {
284 const std::string kr = filter[i] ?
"keep" :
"remove";
285 ATH_MSG_INFO(
"{:9} | {}",(*particles)[i]->px() * igev, kr);
289 std::fill( filter.begin() + (filter.size() / 2),
295 particles.keep (filter);
300 for ( std::size_t i = 0; i != particles->size(); ++i ) {
301 std::size_t newIdx = tmp.index( i );
310 std::fill( filter.begin(),
311 filter.begin() + (filter.size() / 2),
323 for ( std::size_t i = 0; i != particles->size(); ++i ) {
324 std::size_t newIdx = tmp.index( i );
331 return StatusCode::SUCCESS;
340 std::vector<bool> filter =
m_filter.value();
342 const double igev = 1. / Gaudi::Units::GeV;
344 for (
unsigned int i = 0; i != iparticles->size(); ++i ) {
345 const std::string kr = filter[i] ?
"keep" :
"remove";
346 ATH_MSG_INFO(
"{:9} | {}", (*iparticles)[i]->px() * igev, kr);
350 std::fill( filter.begin() + (filter.size() / 2),
356 iparticles.
keep (filter);
361 for ( std::size_t i = 0; i != iparticles->size(); ++i ) {
362 std::size_t newIdx = tmp.index( i );
371 std::fill( filter.begin(),
372 filter.begin() + (filter.size() / 2),
384 for ( std::size_t i = 0; i != iparticles->size(); ++i ) {
385 std::size_t newIdx = tmp.index( i );
392 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
An STL vector of pointers that by default owns its pointed-to elements.
Handle class for reading from StoreGate.
Hold thinning decisions for one container.
Handle for requesting thinning for a data object.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
StringProperty m_elephantinoName
Elephantino input location.
StatusCode test(const EventContext &ctx, int testNum, const std::string &testName)
Exercise the following thinning tests: [testName = "test1"] retrieve a AthExParticles container remov...
StatusCode doThinningTest2(const EventContext &ctx, const SG::ThinningHandleKey< AthExParticles > &particlesKey) const
Apply the real thinning.
StringProperty m_particlesName
Particles input location.
virtual StatusCode initialize() override
SG::ReadHandleKeyArray< AthExElephantino > m_elephantinoKeys
SG::ThinningHandleKey< AthExParticles > m_particlesKey1
StringProperty m_decayName
Decay input location.
WriteThinnedData(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
SG::ThinningHandleKey< AthExParticles > m_particlesKey2
SG::ReadHandleKeyArray< AthExIParticles > m_iparticlesKeys
SG::ReadHandleKeyArray< AthExDecay > m_decayKeys
SG::ThinningHandleKey< AthExIParticles > m_iparticlesKey3
BooleanArrayProperty m_filter
Filter to apply on the Particles.
StatusCode doThinningTest3(const EventContext &ctx, const SG::ThinningHandleKey< AthExIParticles > &iparticlesKey) const
Apply the real thinning.
StatusCode doThinningTest1(const EventContext &ctx, const SG::ThinningHandleKey< AthExParticles > &particlesKey) const
Apply the real thinning.
virtual ~WriteThinnedData()
Destructor:
virtual StatusCode finalize() override
Hold thinning decisions for one container.
static const std::size_t RemovedIdx
Flag used to show that an index has been thinned away.
const ThinningDecision & decision() const
Return the thinning object we're building.
void keep(size_t ndx)
Mark that index ndx in the container should be kept (not thinned away).
HandleKey object for adding thinning to an object.
Handle for requesting thinning for a data object.