16 #include "Gaudi/Property.h"
35 const std::string&
name,
36 const IInterface*
parent ) :
46 "Location of the McEventCollection to be filtered" );
50 "Output McEventCollection location (filtered from the "
51 "McEventCollection)" );
55 "List of decay patterns the tool will try to match. \n\t"
56 "ex: 23 -> -5 + 5 to select Z bosons into bbbar pairs" );
63 "List of booleans with which the tool will setup "
64 "McVtxFilters. This will setup the McVtxFilter::matchSign "
71 "List of booleans with which the tool will setup "
72 "McVtxFilters. This will setup the "
73 "McVtxFilter::matchBranches data member." );
80 "Switch to include or not the signal_process_vertex into "
81 "the McEventCollection (default = true).\n"
82 "Note that this is close to useless as the HEPEVT structure"
83 " does not hold this kind of informations..." );
87 "Switch to fill the entire decay tree from a decay "
89 "This can be usefull to record for example the whole shower "
90 "from a gluon or a quark. In that case, you may want to add "
91 "the according PDG ids into the list of particles to keep" );
95 "List of outgoing particles from the decay vertex to "
96 "include. This property has to be configured in sync. with "
97 "the 'FillTree' one." );
99 declareInterface<IMcVtxFilterTool>(
this);
123 return StatusCode::SUCCESS;
136 if (
sc.isFailure() ||
nullptr == mcColl ) {
138 <<
"Failed to retrieve McEventCollection at : "
141 <<
"because : sc= " << (
sc.isFailure() ?
"FAILURE" :
"OK" )
142 <<
" and mcEvent= " << mcColl
144 return StatusCode::SUCCESS;
148 "filtered GenEvent");
166 <<
"\tDecay Patterns: [ ";
168 msg(MSG::INFO) << itr <<
"; ";
172 msg(MSG::INFO) <<
"Particles to keep: [";
174 msg(MSG::INFO) << itr <<
", ";
181 msg(MSG::INFO) <<
"Statistics for each filter : " <<
endmsg;
192 if (
filter->isAccepted( vtx ) ) {
208 if (
nullptr == mcColl ) {
214 std::set<int> bcToFullVtx;
217 const HepMC::GenEvent * evtSrc = (*mcColl->
begin());
222 for (
const auto& itrPart: *evtSrc) {
223 auto dcyVtx = itrPart->end_vertex();
224 if ( !dcyVtx )
continue;
226 if (bcToFullVtx.count(vtxBC)!=0)
continue;
232 if ( !(*filter)->isAccepted( dcyVtx ) )
continue;
235 bcToFullVtx.insert(vtxBC);
256 ATH_MSG_DEBUG(
"You asked to record signal_process_vertex but :" <<
endmsg <<
" there is NO signal_process_vertex in this event !!");
272 HepMC::GenEvent *
evt,
275 ATH_MSG_VERBOSE(
"In McVtxFilterTool::addVertex( vtxType= "<<vtxType<<
" )");
277 HepMC::GenVertexPtr vtx = (
evt == srcVtx->parent_event()) ? std::const_pointer_cast<HepMC3::GenVertex>(srcVtx) : nullptr ;
280 evt->add_vertex(vtx);
281 vtx->set_position( srcVtx->position() );
282 vtx->set_status( srcVtx->status() );
284 vtx->add_attribute(
"weights",srcVtx->attribute<HepMC3::VectorDoubleAttribute> (
"weights"));
288 for (
const auto&
parent: srcVtx->particles_in()) {
292 vtx->add_particle_in( mother );
293 mother->set_momentum(
parent->momentum() );
294 mother->set_generated_mass(
parent->generated_mass() );
295 mother->set_pdg_id(
parent->pdg_id() );
296 mother->set_status(
parent->status() );
303 vtx->add_particle_in( mother );
308 for (
const auto& child: srcVtx->particles_out()) {
309 HepMC::GenParticlePtr daughter = (
evt == child->parent_event()) ? std::const_pointer_cast<HepMC3::GenParticle>(child) : nullptr ;
314 << child->pdg_id() <<
"|"
319 vtx->add_particle_out( daughter );
320 daughter->set_momentum( child->momentum() );
321 daughter->set_generated_mass( child->generated_mass() );
322 daughter->set_pdg_id( child->pdg_id() );
323 daughter->set_status( child->status() );
332 auto decayVertex = child->end_vertex();
343 HepMC::GenVertex * vtx =
evt->barcode_to_vertex(srcVtx->barcode());
346 vtx->set_position( srcVtx->position() );
347 vtx->set_id( srcVtx->id() );
348 vtx->suggest_barcode( srcVtx->barcode() );
349 vtx->weights() = srcVtx->weights();
350 evt->add_vertex(vtx);
354 for ( HepMC::GenVertex::particles_in_const_iterator
parent = srcVtx->particles_in_const_begin();
355 parent != srcVtx->particles_in_const_end();
360 mother->set_momentum( (*parent)->momentum() );
361 mother->set_generated_mass( (*parent)->generated_mass() );
362 mother->set_pdg_id( (*parent)->pdg_id() );
363 mother->set_status( (*parent)->status() );
364 mother->set_flow( (*parent)->flow() );
365 mother->set_polarization( (*parent)->polarization() );
366 mother->suggest_barcode( (*parent)->barcode() );
370 vtx->add_particle_in( mother );
375 for ( HepMC::GenVertex::particles_out_const_iterator child = srcVtx->particles_out_const_begin();
376 child != srcVtx->particles_out_const_end();
379 if ( 0 == daughter ) {
385 daughter->set_momentum( (*child)->momentum() );
386 daughter->set_generated_mass( (*child)->generated_mass() );
387 daughter->set_pdg_id( (*child)->pdg_id() );
388 daughter->set_status( (*child)->status() );
389 daughter->set_flow( (*child)->flow() );
390 daughter->set_polarization( (*child)->polarization() );
391 daughter->suggest_barcode( (*child)->barcode() );
397 vtx->add_particle_out( daughter );
401 const HepMC::GenVertex * decayVertex = (*child)->end_vertex();
402 if ( 0 != decayVertex ) {
419 if (
nullptr ==
part ) {
447 <<
"In keepParticle: Don't know anything about this VtxType ["
450 <<
"We'll keep this particle [ " <<
part
451 <<
"] but : Check your jobOption !!"
466 const std::vector<std::string>& decayPatterns =
m_decayPatterns.value();
478 ( decayPatterns.size() != matchSigns.size() ||
479 decayPatterns.size() != matchBranches.size() ||
480 matchSigns.size() != matchBranches.size() ) ) {
482 error =
"Lengths of ArrayProperty configuring McVtxFilters ";
483 error +=
"are DIFFERING !!";
485 <<
"In setupFilter: " <<
error
487 <<
"\t# decayPatterns: " << decayPatterns.size() <<
endmsg
488 <<
"\t# matchSigns: " << matchSigns.size() <<
endmsg
489 <<
"\t# matchBranches: " << matchBranches.size() <<
endmsg
490 <<
"Reference size is 'decayPatterns':" <<
endmsg
491 <<
"\t==> Will fill holes with default values !" <<
endmsg
492 <<
"\t==> Will drop extra values !"
497 const unsigned int nDecayPatterns = decayPatterns.size();
501 if ( nDecayPatterns > matchSigns.size() ) {
503 const unsigned int nCount = nDecayPatterns - matchSigns.size();
504 std::fill_n( std::back_inserter(matchSigns),
509 if ( nDecayPatterns > matchBranches.size() ) {
511 const unsigned int nCount = nDecayPatterns - matchBranches.size();
512 std::fill_n( std::back_inserter(matchBranches),
517 for (
unsigned int i = 0;
i != nDecayPatterns; ++
i ) {
520 bool(matchBranches[
i]) );