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 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() ) {
146 (
"symlinked containers are corrupted: " <<
endmsg
147 <<
" #iparticles: " << iparticles->size() <<
endmsg
148 <<
" # particles: " << particles->size() <<
endmsg
149 <<
" ipx[0] = " << iparticles->at(0)->px() <<
endmsg
150 <<
" px[0] = " << particles->at(0)->px());
151 return StatusCode::RECOVERABLE;
160 const double igev = 1. / Gaudi::Units::GeV;
163 <<
" p1: px= " << decay->p1()->px() * igev <<
endmsg
164 <<
" p2: px= " << decay->p2()->px() * igev <<
endmsg
165 <<
" l1: px= " << decay->l1()->px() * igev <<
endmsg
166 <<
" l2: px= " << decay->l2()->px() * igev);
169 <<
" leg1: px= " << elephantino->leg1()->px() * igev <<
endmsg
170 <<
" leg2: px= " << elephantino->leg2()->px() * igev <<
endmsg
171 <<
" leg3: px= " << elephantino->leg3()->px() * igev <<
endmsg
172 <<
" leg4: px= " << elephantino->leg4()->px() * igev <<
endmsg
173 <<
" ear1: px= " << elephantino->ear1()->px() * igev <<
endmsg
174 <<
" ear2: px= " << elephantino->ear2()->px() * igev);
178 if (
test ==
"test1" ) {
182 }
else if (
test ==
"test2" ) {
186 }
else if (
test ==
"test3" ) {
192 return StatusCode::FAILURE;
197 (
"Decay is now: " <<
endmsg
198 <<
" p1: px= " << decay->p1()->px() * igev <<
endmsg
199 <<
" p2: px= " << decay->p2()->px() * igev <<
endmsg
200 <<
" l1: px= " << decay->l1()->px() * igev <<
endmsg
201 <<
" l2: px= " << decay->l2()->px() * igev);
204 (
"Elephantino is now: " <<
endmsg
205 <<
" leg1: px= " << elephantino->leg1()->px() * igev <<
endmsg
206 <<
" leg2: px= " << elephantino->leg2()->px() * igev <<
endmsg
207 <<
" leg3: px= " << elephantino->leg3()->px() * igev <<
endmsg
208 <<
" leg4: px= " << elephantino->leg4()->px() * igev <<
endmsg
209 <<
" ear1: px= " << elephantino->ear1()->px() * igev <<
endmsg
210 <<
" ear2: px= " << elephantino->ear2()->px() * igev);
214 return StatusCode::SUCCESS;
222 std::vector<bool> filter =
m_filter.value();
224 const double igev = 1. / Gaudi::Units::GeV;
225 msg(MSG::INFO) <<
"Particles | filter :" <<
endmsg;
226 for (
unsigned int i = 0; i != particles->size(); ++i ) {
227 const std::string kr = filter[i] ?
"keep" :
"remove";
229 << std::setw(9) << (*particles)[i]->px() * igev
233 msg(MSG::INFO) <<
"===================" <<
endmsg;
235 std::fill( filter.begin() + (filter.size() / 2),
238 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
239 std::copy( filter.begin(), filter.end(),
240 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
243 msg(MSG::INFO) <<
"... Processing [pre-thinning] ..." <<
endmsg;
244 particles.keep (filter);
245 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
249 for ( std::size_t i = 0; i != particles->size(); ++i ) {
250 std::size_t newIdx = tmp.index( i );
251 std::stringstream newIdxStr;
264 std::fill( filter.begin(),
265 filter.begin() + (filter.size() / 2),
268 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
269 std::copy( filter.begin(), filter.end(),
270 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
273 msg(MSG::INFO) <<
"... Processing [thinning] ..." <<
endmsg;
276 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
280 for ( std::size_t i = 0; i != particles->size(); ++i ) {
281 std::size_t newIdx = tmp.index( i );
282 std::stringstream newIdxStr;
293 return StatusCode::SUCCESS;
301 std::vector<bool> filter =
m_filter.value();
303 const double igev = 1. / Gaudi::Units::GeV;
304 msg(MSG::INFO) <<
"Particles | filter :" <<
endmsg;
305 for (
unsigned int i = 0; i != particles->size(); ++i ) {
306 const std::string kr = filter[i] ?
"keep" :
"remove";
308 << std::setw(9) << (*particles)[i]->px() * igev
312 msg(MSG::INFO) <<
"===================" <<
endmsg;
314 std::fill( filter.begin() + (filter.size() / 2),
317 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
318 std::copy( filter.begin(), filter.end(),
319 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
322 msg(MSG::INFO) <<
"... Processing [pre-thinning] ..." <<
endmsg;
323 particles.keep (filter);
324 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
328 for ( std::size_t i = 0; i != particles->size(); ++i ) {
329 std::size_t newIdx = tmp.index( i );
330 std::stringstream newIdxStr;
343 std::fill( filter.begin(),
344 filter.begin() + (filter.size() / 2),
347 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
348 std::copy( filter.begin(), filter.end(),
349 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
352 msg(MSG::INFO) <<
"... Processing [thinning] ..." <<
endmsg;
355 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
359 for ( std::size_t i = 0; i != particles->size(); ++i ) {
360 std::size_t newIdx = tmp.index( i );
361 std::stringstream newIdxStr;
372 return StatusCode::SUCCESS;
381 std::vector<bool> filter =
m_filter.value();
383 const double igev = 1. / Gaudi::Units::GeV;
384 msg(MSG::INFO) <<
"IParticles | filter :" <<
endmsg;
385 for (
unsigned int i = 0; i != iparticles->size(); ++i ) {
386 const std::string kr = filter[i] ?
"keep" :
"remove";
388 << std::setw(9) << (*iparticles)[i]->px() * igev
392 msg(MSG::INFO) <<
"===================" <<
endmsg;
394 std::fill( filter.begin() + (filter.size() / 2),
397 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
398 std::copy( filter.begin(), filter.end(),
399 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
402 msg(MSG::INFO) <<
"... Processing [pre-thinning] ..." <<
endmsg;
403 iparticles.
keep (filter);
404 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
408 for ( std::size_t i = 0; i != iparticles->size(); ++i ) {
409 std::size_t newIdx = tmp.index( i );
410 std::stringstream newIdxStr;
423 std::fill( filter.begin(),
424 filter.begin() + (filter.size() / 2),
427 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
428 std::copy( filter.begin(), filter.end(),
429 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
432 msg(MSG::INFO) <<
"... Processing [thinning] ..." <<
endmsg;
435 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
439 for ( std::size_t i = 0; i != iparticles->size(); ++i ) {
440 std::size_t newIdx = tmp.index( i );
441 std::stringstream newIdxStr;
452 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(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.