The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::TestSuite::EvtCollectionSelector Class Reference

Definition of a small class for further pre-selections when reading an event collection. More...

Inheritance diagram for Gaudi::TestSuite::EvtCollectionSelector:
Collaboration diagram for Gaudi::TestSuite::EvtCollectionSelector:

Public Member Functions

StatusCode initialize (NTuple::Tuple *nt) override
 Initialization.
bool operator() (NTuple::Tuple *) override
 Specialized callback for NTuples.
 Selector (IInterface *svc)
 Standard constructor.
bool operator() (void *nt) override
 Default callback from interface.
Public Member Functions inherited from NTuple::Selector
 Selector (IInterface *svc)
 Standard constructor.
virtual ~Selector ()=default
 Standard Destructor.
bool firstCall () const
 Check for first call.
StatusCode initResult () const
 Access initialization status.
bool operator() (void *nt) override
 Default callback from interface.
Public Member Functions inherited from SelectStatement
 SelectStatement (const std::string &s, long typ)
 Standard Constructor initializing select string.
 SelectStatement (const std::string &s)
 Standard Constructor initializing select string.
 SelectStatement ()
 Standard Constructor initializing function call.
virtual ~SelectStatement ()
 Standard Destructor.
long type () const override
 Access the type of the object.
const std::string & criteria () const override
 Access the selection string.
void setCriteria (const std::string &crit) override
 Set the type.
void setActive (bool flag=true) override
 Change activity flag.
bool isActive () const override
 Check if selection is active.
Public Member Functions inherited from implements< ISelectStatement >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 implements ()=default
 Default constructor.
implements & operator= (const implements &)
 Assignment operator (do not touch the reference count).
unsigned long addRef () const override
 Reference Interface instance.
unsigned long release () const override
 Release Interface instance.
unsigned long refCount () const override
 Current reference count.

Protected Attributes

NTuple::Item< int > m_ntrack
NTuple::Array< float > m_trkMom
NTuple::Array< float > m_trkMomFixed
NTuple::Item< Gaudi::TestSuite::MyTrack * > m_track
int m_cut = 10
Protected Attributes inherited from NTuple::Selector
IInterface * m_parent
 reference to parent interface
bool m_firstCall
 Boolean to indicate need for initialization.
StatusCode m_status
 StatusCode indication initialization result.
Protected Attributes inherited from SelectStatement
std::string m_select
 Select string.
bool m_isActive
 Activation flag.
long m_type
 Type identifier.
Protected Attributes inherited from implements< ISelectStatement >
std::atomic_ulong m_refCount
 Reference counter.

Additional Inherited Members

Public Types inherited from implements< ISelectStatement >
using base_class
 Typedef to this class.
using extend_interfaces_base
 Typedef to the base of this class.
using iids
Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
Protected Member Functions inherited from implements< ISelectStatement >
unsigned long decRef () const override

Detailed Description

Definition of a small class for further pre-selections when reading an event collection.

Author
: M.Frank Version: 1.0

Definition at line 39 of file EvtCollectionSelector.cpp.

Member Function Documentation

◆ initialize()

StatusCode Gaudi::TestSuite::EvtCollectionSelector::initialize ( NTuple::Tuple * nt)
inlineoverridevirtual

Initialization.

Reimplemented from NTuple::Selector.

Definition at line 53 of file EvtCollectionSelector.cpp.

53 {
54 StatusCode sc = StatusCode::SUCCESS;
55 sc = nt->item( "TrkMom", m_trkMom );
56 if ( !sc.isSuccess() ) {
57 std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
58 std::cerr << "TrkMom" << std::endl;
59 return sc;
60 }
61#ifndef NO_TRKMOMFIX
62 sc = nt->item( "TrkMomFix", m_trkMomFixed );
63 if ( !sc.isSuccess() ) {
64 std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
65 std::cerr << "TrkMomFix" << std::endl;
66 return sc;
67 }
68#endif
69 sc = nt->item( "Ntrack", m_ntrack );
70 if ( !sc.isSuccess() ) {
71 std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
72 std::cerr << "Ntrack" << std::endl;
73 return sc;
74 }
75
76 sc = nt->item( "Track", m_track );
77 if ( !sc.isSuccess() ) {
78 std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
79 std::cerr << "Track" << std::endl;
80 return sc;
81 }
82
83 return sc;
84 }
NTuple::Item< Gaudi::TestSuite::MyTrack * > m_track
StatusCode item(const std::string &name, Item< TYPE > &result)
Locate a scalar Item of data to the N tuple type safe.
Definition NTuple.h:465
bool isSuccess() const
Definition StatusCode.h:302
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ operator()() [1/2]

bool Gaudi::TestSuite::EvtCollectionSelector::operator() ( NTuple::Tuple * )
inlineoverridevirtual

Specialized callback for NTuples.

Reimplemented from NTuple::Selector.

Definition at line 88 of file EvtCollectionSelector.cpp.

88 {
89 const int n = m_ntrack;
90 std::cout << System::typeinfoName( typeid( *this ) ) << "\t -> #tracks : " << n << std::endl
91 << System::typeinfoName( typeid( *this ) ) << "\t -> Momenta(Var): ";
92 for ( int i = 0; i < std::min( 5, n ); ++i ) { std::cout << "[" << i << "]=" << m_trkMom[i] << " "; }
93#ifndef NO_TRKMOMFIX
94 std::cout << std::endl << System::typeinfoName( typeid( *this ) ) << "\t -> Momenta(Fix): ";
95 for ( int i = 0; i < std::min( 5, n ); ++i ) { std::cout << "[" << i << "]=" << m_trkMomFixed[i] << " "; }
96 for ( int i = 5; i < 99; ++i ) {
97 if ( std::abs( m_trkMomFixed[i] ) > std::numeric_limits<float>::epsilon() ) {
98 std::cout << "[" << i << "]= Error in Fixed momentum" << std::endl;
99 }
100 }
101#endif
102 std::cout << std::endl;
103 std::cout << System::typeinfoName( typeid( *this ) );
104 if ( 0 != *m_track ) {
105 std::cout << "\t -> Track : "
106 << " px=" << ( *m_track )->px() << " py=" << ( *m_track )->py() << " pz=" << ( *m_track )->pz()
107 << std::endl;
108 } else {
109 std::cout << " Track* is NULL" << std::endl;
110 }
111 //
112 const bool selected = m_cut < m_ntrack && 0 != *m_track;
113 std::cout << System::typeinfoName( typeid( *this ) ) << " SELECTED : ";
114 Gaudi::Utils::toStream( selected, std::cout ) << std::endl;
115 //
116 return selected; // RETURN
117 }
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition ToStream.h:307
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:254
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition ParticleID.h:191

◆ operator()() [2/2]

bool NTuple::Selector::operator() ( void * nt)
overridevirtual

Default callback from interface.

Overloaded callback from SelectStatement.

Reimplemented from SelectStatement.

Definition at line 41 of file Selector.cpp.

18 {
19 DataObject* p = static_cast<DataObject*>( nt );
20 bool result = false;
21 try {
22 NTuple::Tuple* tuple = dynamic_cast<NTuple::Tuple*>( p );
23 if ( tuple ) {
24 if ( m_firstCall ) {
25 m_status = initialize( tuple );
26 m_firstCall = false;
27 }
28 if ( m_status.isSuccess() ) { result = this->operator()( tuple ); }
29 }
30 } catch ( ... ) {}
31 return result;
32}
StatusCode initialize(NTuple::Tuple *nt) override
Initialization.
bool operator()(NTuple::Tuple *) override
Specialized callback for NTuples.
bool m_firstCall
Boolean to indicate need for initialization.
Definition Selector.h:27
StatusCode m_status
StatusCode indication initialization result.
Definition Selector.h:29

◆ Selector()

Standard constructor.

Definition at line 33 of file Selector.h.

33: m_parent( svc ), m_firstCall( true ) {}
IInterface * m_parent
reference to parent interface
Definition Selector.h:25

Member Data Documentation

◆ m_cut

int Gaudi::TestSuite::EvtCollectionSelector::m_cut = 10
protected

Definition at line 47 of file EvtCollectionSelector.cpp.

◆ m_ntrack

NTuple::Item<int> Gaudi::TestSuite::EvtCollectionSelector::m_ntrack
protected

Definition at line 41 of file EvtCollectionSelector.cpp.

◆ m_track

NTuple::Item<Gaudi::TestSuite::MyTrack*> Gaudi::TestSuite::EvtCollectionSelector::m_track
protected

Definition at line 46 of file EvtCollectionSelector.cpp.

◆ m_trkMom

NTuple::Array<float> Gaudi::TestSuite::EvtCollectionSelector::m_trkMom
protected

Definition at line 42 of file EvtCollectionSelector.cpp.

◆ m_trkMomFixed

NTuple::Array<float> Gaudi::TestSuite::EvtCollectionSelector::m_trkMomFixed
protected

Definition at line 44 of file EvtCollectionSelector.cpp.


The documentation for this class was generated from the following file: