The Gaudi Framework
master (6507eef1)
Toggle main menu visibility
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
>
16
#include <
GaudiKernel/ObjectFactory.h
>
17
#include <
GaudiKernel/Selector.h
>
18
#include <
GaudiKernel/System.h
>
19
#include <
GaudiKernel/ToStream.h
>
20
#include <
GaudiTestSuite/MyTrack.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
31
namespace
Gaudi
{
32
namespace
TestSuite
{
39
class
EvtCollectionSelector
:
public
NTuple::Selector
{
40
protected
:
41
NTuple::Item<int>
m_ntrack
;
42
NTuple::Array<float>
m_trkMom
;
43
#ifndef NO_TRKMOMFIX
44
NTuple::Array<float>
m_trkMomFixed
;
45
#endif
46
NTuple::Item<Gaudi::TestSuite::MyTrack*>
m_track
;
47
int
m_cut
= 10;
48
49
public
:
50
using
NTuple::Selector::Selector
;
51
53
StatusCode
initialize
(
NTuple::Tuple
* nt )
override
{
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
}
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
};
119
DECLARE_OBJECT_FACTORY
(
EvtCollectionSelector
)
120
}
// namespace TestSuite
121
}
// end of namespace Gaudi
EvtCollectionSelector
#define EvtCollectionSelector
Definition
EvtExtCollectionSelector.cpp:12
MyTrack.h
NTuple.h
ObjectFactory.h
DECLARE_OBJECT_FACTORY
#define DECLARE_OBJECT_FACTORY(x)
Definition
ObjectFactory.h:24
Selector.h
System.h
ToStream.h
implementation of various functions for streaming.
Gaudi::TestSuite::EvtCollectionSelector
Definition of a small class for further pre-selections when reading an event collection.
Definition
EvtCollectionSelector.cpp:39
Gaudi::TestSuite::EvtCollectionSelector::m_cut
int m_cut
Definition
EvtCollectionSelector.cpp:47
Gaudi::TestSuite::EvtCollectionSelector::m_ntrack
NTuple::Item< int > m_ntrack
Definition
EvtCollectionSelector.cpp:41
Gaudi::TestSuite::EvtCollectionSelector::initialize
StatusCode initialize(NTuple::Tuple *nt) override
Initialization.
Definition
EvtCollectionSelector.cpp:53
Gaudi::TestSuite::EvtCollectionSelector::operator()
bool operator()(NTuple::Tuple *) override
Specialized callback for NTuples.
Definition
EvtCollectionSelector.cpp:88
Gaudi::TestSuite::EvtCollectionSelector::m_trkMomFixed
NTuple::Array< float > m_trkMomFixed
Definition
EvtCollectionSelector.cpp:44
Gaudi::TestSuite::EvtCollectionSelector::m_track
NTuple::Item< Gaudi::TestSuite::MyTrack * > m_track
Definition
EvtCollectionSelector.cpp:46
Gaudi::TestSuite::EvtCollectionSelector::m_trkMom
NTuple::Array< float > m_trkMom
Definition
EvtCollectionSelector.cpp:42
NTuple::Array
Class acting as a smart pointer holding a N tuple _Item.
Definition
NTuple.h:324
NTuple::Item
Class acting as a smart pointer holding a N tuple _Item.
Definition
NTuple.h:251
NTuple::Selector
NTuple Selector class.
Definition
Selector.h:22
NTuple::Selector::Selector
Selector(IInterface *svc)
Standard constructor.
Definition
Selector.h:33
NTuple::Tuple
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition
NTuple.h:380
NTuple::Tuple::item
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
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::isSuccess
bool isSuccess() const
Definition
StatusCode.h:302
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
Gaudi::TestSuite
Definition
ConditionAccessorHolder.h:21
Gaudi::Utils::toStream
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
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition
__init__.py:1
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition
System.cpp:254
std::abs
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition
ParticleID.h:191
GaudiTestSuite
src
IO
EvtCollectionSelector.cpp
Generated on
for The Gaudi Framework by
1.17.0