The Gaudi Framework  master (2df85225)
Loading...
Searching...
No Matches
EvtCollectionSelector.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
14
15#include <GaudiKernel/NTuple.h>
18#include <GaudiKernel/System.h>
21#include <cmath>
22
23#ifdef __ICC
24// disable icc warning #1125: function "ISelectStatement::operator()(void *)"
25// is hidden by "Gaudi::TestSuite::EvtCollectionSelector::operator()"
26// -- virtual function override intended?
27# pragma warning( disable : 1125 )
28// disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
29# pragma warning( disable : 1572 )
30#endif
31namespace Gaudi {
32 namespace TestSuite {
40 protected:
43#ifndef NO_TRKMOMFIX
45#endif
47 int m_cut = 10;
48
49 public:
51
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 }
85
86 using NTuple::Selector::operator(); // avoid hiding base-class methods
88 bool operator()( NTuple::Tuple* /* nt */ ) override {
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 }
118 };
120 } // namespace TestSuite
121} // end of namespace Gaudi
#define EvtCollectionSelector
#define DECLARE_OBJECT_FACTORY(x)
implementation of various functions for streaming.
Definition of a small class for further pre-selections when reading an event collection.
StatusCode initialize(NTuple::Tuple *nt) override
Initialization.
bool operator()(NTuple::Tuple *) override
Specialized callback for NTuples.
NTuple::Item< Gaudi::TestSuite::MyTrack * > m_track
Class acting as a smart pointer holding a N tuple _Item.
Definition NTuple.h:324
Class acting as a smart pointer holding a N tuple _Item.
Definition NTuple.h:251
NTuple Selector class.
Definition Selector.h:22
Selector(IInterface *svc)
Standard constructor.
Definition Selector.h:33
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition NTuple.h:380
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
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isSuccess() const
Definition StatusCode.h:314
constexpr static const auto SUCCESS
Definition StatusCode.h:99
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:304
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition ParticleID.h:191