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;
103 const EventContext& ctx = Gaudi::Hive::currentContext();
107 if ( !
test( ctx, 0,
"test1" ).isSuccess() ) {
112 if ( !
test( ctx, 1,
"test2" ).isSuccess() ) {
117 if ( !
test( ctx, 2,
"test3" ).isSuccess() ) {
122 return allGood ? StatusCode::SUCCESS : StatusCode::FAILURE;
126 int testNum,
const std::string& testName )
128 const std::string&
test = testName;
134 if ( !
evtStore()->retrieve(particles, particlesName).isSuccess() ||
137 (
"Could not fetch particles at [" << particlesName <<
"] !!");
138 return StatusCode::RECOVERABLE;
144 if ( iparticles->size() != particles->size() ||
145 iparticles->at(0)->px() != particles->at(0)->px() ) {
147 (
"symlinked containers are corrupted: " <<
endmsg
148 <<
" #iparticles: " << iparticles->size() <<
endmsg
149 <<
" # particles: " << particles->size() <<
endmsg
150 <<
" ipx[0] = " << iparticles->at(0)->px() <<
endmsg
151 <<
" px[0] = " << particles->at(0)->px());
152 return StatusCode::RECOVERABLE;
161 const double igev = 1. / Gaudi::Units::GeV;
164 <<
" p1: px= " << decay->p1()->px() * igev <<
endmsg
165 <<
" p2: px= " << decay->p2()->px() * igev <<
endmsg
166 <<
" l1: px= " << decay->l1()->px() * igev <<
endmsg
167 <<
" l2: px= " << decay->l2()->px() * igev);
170 <<
" leg1: px= " << elephantino->leg1()->px() * igev <<
endmsg
171 <<
" leg2: px= " << elephantino->leg2()->px() * igev <<
endmsg
172 <<
" leg3: px= " << elephantino->leg3()->px() * igev <<
endmsg
173 <<
" leg4: px= " << elephantino->leg4()->px() * igev <<
endmsg
174 <<
" ear1: px= " << elephantino->ear1()->px() * igev <<
endmsg
175 <<
" ear2: px= " << elephantino->ear2()->px() * igev);
179 if (
test ==
"test1" ) {
183 }
else if (
test ==
"test2" ) {
187 }
else if (
test ==
"test3" ) {
193 return StatusCode::FAILURE;
198 (
"Decay is now: " <<
endmsg
199 <<
" p1: px= " << decay->p1()->px() * igev <<
endmsg
200 <<
" p2: px= " << decay->p2()->px() * igev <<
endmsg
201 <<
" l1: px= " << decay->l1()->px() * igev <<
endmsg
202 <<
" l2: px= " << decay->l2()->px() * igev);
205 (
"Elephantino is now: " <<
endmsg
206 <<
" leg1: px= " << elephantino->leg1()->px() * igev <<
endmsg
207 <<
" leg2: px= " << elephantino->leg2()->px() * igev <<
endmsg
208 <<
" leg3: px= " << elephantino->leg3()->px() * igev <<
endmsg
209 <<
" leg4: px= " << elephantino->leg4()->px() * igev <<
endmsg
210 <<
" ear1: px= " << elephantino->ear1()->px() * igev <<
endmsg
211 <<
" ear2: px= " << elephantino->ear2()->px() * igev);
215 return StatusCode::SUCCESS;
223 std::vector<bool> filter =
m_filter.value();
225 const double igev = 1. / Gaudi::Units::GeV;
226 msg(MSG::INFO) <<
"Particles | filter :" <<
endmsg;
227 for (
unsigned int i = 0; i != particles->size(); ++i ) {
228 const std::string kr = filter[i] ?
"keep" :
"remove";
230 << std::setw(9) << (*particles)[i]->px() * igev
234 msg(MSG::INFO) <<
"===================" <<
endmsg;
236 std::fill( filter.begin() + (filter.size() / 2),
239 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
240 std::copy( filter.begin(), filter.end(),
241 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
244 msg(MSG::INFO) <<
"... Processing [pre-thinning] ..." <<
endmsg;
245 particles.keep (filter);
246 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
250 for ( std::size_t i = 0; i != particles->size(); ++i ) {
251 std::size_t newIdx = tmp.index( i );
252 std::stringstream newIdxStr;
265 std::fill( filter.begin(),
266 filter.begin() + (filter.size() / 2),
269 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
270 std::copy( filter.begin(), filter.end(),
271 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
274 msg(MSG::INFO) <<
"... Processing [thinning] ..." <<
endmsg;
277 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
281 for ( std::size_t i = 0; i != particles->size(); ++i ) {
282 std::size_t newIdx = tmp.index( i );
283 std::stringstream newIdxStr;
294 return StatusCode::SUCCESS;
302 std::vector<bool> filter =
m_filter.value();
304 const double igev = 1. / Gaudi::Units::GeV;
305 msg(MSG::INFO) <<
"Particles | filter :" <<
endmsg;
306 for (
unsigned int i = 0; i != particles->size(); ++i ) {
307 const std::string kr = filter[i] ?
"keep" :
"remove";
309 << std::setw(9) << (*particles)[i]->px() * igev
313 msg(MSG::INFO) <<
"===================" <<
endmsg;
315 std::fill( filter.begin() + (filter.size() / 2),
318 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
319 std::copy( filter.begin(), filter.end(),
320 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
323 msg(MSG::INFO) <<
"... Processing [pre-thinning] ..." <<
endmsg;
324 particles.keep (filter);
325 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
329 for ( std::size_t i = 0; i != particles->size(); ++i ) {
330 std::size_t newIdx = tmp.index( i );
331 std::stringstream newIdxStr;
344 std::fill( filter.begin(),
345 filter.begin() + (filter.size() / 2),
348 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
349 std::copy( filter.begin(), filter.end(),
350 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
353 msg(MSG::INFO) <<
"... Processing [thinning] ..." <<
endmsg;
356 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
360 for ( std::size_t i = 0; i != particles->size(); ++i ) {
361 std::size_t newIdx = tmp.index( i );
362 std::stringstream newIdxStr;
373 return StatusCode::SUCCESS;
382 std::vector<bool> filter =
m_filter.value();
384 const double igev = 1. / Gaudi::Units::GeV;
385 msg(MSG::INFO) <<
"IParticles | filter :" <<
endmsg;
386 for (
unsigned int i = 0; i != iparticles->size(); ++i ) {
387 const std::string kr = filter[i] ?
"keep" :
"remove";
389 << std::setw(9) << (*iparticles)[i]->px() * igev
393 msg(MSG::INFO) <<
"===================" <<
endmsg;
395 std::fill( filter.begin() + (filter.size() / 2),
398 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
399 std::copy( filter.begin(), filter.end(),
400 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
403 msg(MSG::INFO) <<
"... Processing [pre-thinning] ..." <<
endmsg;
404 iparticles.
keep (filter);
405 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
409 for ( std::size_t i = 0; i != iparticles->size(); ++i ) {
410 std::size_t newIdx = tmp.index( i );
411 std::stringstream newIdxStr;
424 std::fill( filter.begin(),
425 filter.begin() + (filter.size() / 2),
428 msg(MSG::INFO) <<
"Filter [" << std::boolalpha;
429 std::copy( filter.begin(), filter.end(),
430 std::ostream_iterator<bool>(
msg(MSG::INFO).stream(),
" ") );
433 msg(MSG::INFO) <<
"... Processing [thinning] ..." <<
endmsg;
436 msg(MSG::INFO) <<
"======== Index table =========" <<
endmsg;
440 for ( std::size_t i = 0; i != iparticles->size(); ++i ) {
441 std::size_t newIdx = tmp.index( i );
442 std::stringstream newIdxStr;
453 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 with parameters:
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:
SG::ThinningHandleKey< AthExParticles > m_particlesKey2
SG::ReadHandleKeyArray< AthExIParticles > m_iparticlesKeys
SG::ReadHandleKeyArray< AthExDecay > m_decayKeys
SG::ThinningHandleKey< AthExIParticles > m_iparticlesKey3
virtual StatusCode execute() override
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.