HepMC event record
Data Structures
Search engine

Data Structures

class  Filter
 Class used to define filters for search engine. More...
 
class  ATTRIBUTE
 Filter for the attributes. More...
 
class  FilterBase
 Base class for Filter class. More...
 
class  FilterList
 List of filters for the search engine. More...
 
class  FindParticles
 Search engine for GenEvent class. More...
 

Detailed Description

Using search engine module

The aim of the search engine is to provide an unified way to search through the event for any type of particles needed for the analysis without any need of iterators or specific knowledge of event structure.

Particles can be filtered based on an event or particle pointer:

FindParticles search( event, FIND_ALL );
FindParticles search( event, FIND_ALL, STATUS == 1 );
FindParticles search( particle, FIND_ALL_DESCENDANTS, STATUS == 1 );

Filters can be constructed using any natural operator:

STATUS >= 1 STATUS <= 1 STATUS != 1 ...

or boolean checks:

HAS_PRODUCTION_VERTEX, HAS_END_VERTEX, !HAS_END_VERTEX ...

They can also be used to find particles selected attribute:

FindParticles search( event, FIND_ALL, ATTRIBUTE("for_deletion") )

or with concrete value of an attribute:

shared_ptr<Attribute> our_value = make_shared<IntAttribute>(1);
FindParticles search ( event, FIND_ALL, ATTRIBUTE("some_variable") == our_value )
shared_ptr<Attribute> our_string = make_shared<StringAttribute>("test string");
FindParticles search2( event, FIND_ALL, ATTRIBUTE("some_other_attribute") == our_string )

Filters are additive:

FindParticles search( event, FIND_ALL, PDG_ID == 111 && !HAS_END_VERTEX && STATUS != 3);

Sequence point of '&&' operator is kept - if particle does not pass a filter, rest of the filters is not checked

Applying additional filters:

// Narrow down results
// Linear operation equivalent to erase-remove idiom
search.narrow_down( PDG_ID >= -6 && PDG_ID <= 6 );

Example of advanced search:

// Find all tau's that have end vertex
// but this vertex is not a self-decay vertex (does not contain tau):
FindParticles search( event, FIND_ALL, ABS_PDG_ID == 15 &&
HAS_END_VERTEX &&
!HAS_SAME_PDG_ID_DAUGHTER )

Getting the results:

// search.results() returns const vector<GenParticlePtr>
FOREACH( GenParticle *p, search.results() ) {
p->print();

Filters are type-safe. Invalid searches will not compile:

FindParticles search( event, FIND_ALL_DESCENDANTS, ... ); // fails at compile time
FindParticles search( particle, FIND_ALL, ... ); // fails at compile time

Similarly, following filters will fail at compile time:

!STATUS // Variable filter 'STATUS' cannot be used with boolean operator
PDG_ID // Variable filter 'PDG_ID' cannot be used without an operator
HAS_END_VERTEX == vertex // Boolean filter 'HAS_END_VERTEX' cannot be used with an operator other than '!'

Last update 6 Apr 2016