Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EvtCollectionSelector.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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 \***********************************************************************************/
11 // ============================================================================
15 // ============================================================================
16 #define EVTCOLLECTIONSELECTOR_CPP 1
17 // ============================================================================
18 // Include files
19 // ============================================================================
20 // GaudiKernel
21 // ============================================================================
22 #include "GaudiKernel/NTuple.h"
24 #include "GaudiKernel/Selector.h"
25 #include "GaudiKernel/System.h"
26 #include "GaudiKernel/ToStream.h"
27 // ============================================================================
28 // Local
29 // ============================================================================
30 #include "GaudiExamples/MyTrack.h"
31 // ============================================================================
32 
33 #include <cmath>
34 
35 #ifdef __ICC
36 // disable icc warning #1125: function "ISelectStatement::operator()(void *)"
37 // is hidden by "Gaudi::Examples::EvtCollectionSelector::operator()"
38 // -- virtual function override intended?
39 # pragma warning( disable : 1125 )
40 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
41 # pragma warning( disable : 1572 )
42 #endif
43 namespace Gaudi {
44  namespace Examples {
52  protected:
55 #ifndef NO_TRKMOMFIX
57 #endif
59  int m_cut = 10;
60 
61  public:
63 
67  sc = nt->item( "TrkMom", m_trkMom );
68  if ( !sc.isSuccess() ) {
69  std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
70  std::cerr << "TrkMom" << std::endl;
71  return sc;
72  }
73 #ifndef NO_TRKMOMFIX
74  sc = nt->item( "TrkMomFix", m_trkMomFixed );
75  if ( !sc.isSuccess() ) {
76  std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
77  std::cerr << "TrkMomFix" << std::endl;
78  return sc;
79  }
80 #endif
81  sc = nt->item( "Ntrack", m_ntrack );
82  if ( !sc.isSuccess() ) {
83  std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
84  std::cerr << "Ntrack" << std::endl;
85  return sc;
86  }
87 
88  sc = nt->item( "Track", m_track );
89  if ( !sc.isSuccess() ) {
90  std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
91  std::cerr << "Track" << std::endl;
92  return sc;
93  }
94 
95  return sc;
96  }
97 
98  using NTuple::Selector::operator(); // avoid hiding base-class methods
100  bool operator()( NTuple::Tuple* /* nt */ ) override {
101  const int n = m_ntrack;
102  std::cout << System::typeinfoName( typeid( *this ) ) << "\t -> #tracks : " << n << std::endl
103  << System::typeinfoName( typeid( *this ) ) << "\t -> Momenta(Var): ";
104  for ( int i = 0; i < std::min( 5, n ); ++i ) { std::cout << "[" << i << "]=" << m_trkMom[i] << " "; }
105 #ifndef NO_TRKMOMFIX
106  std::cout << std::endl << System::typeinfoName( typeid( *this ) ) << "\t -> Momenta(Fix): ";
107  for ( int i = 0; i < std::min( 5, n ); ++i ) { std::cout << "[" << i << "]=" << m_trkMomFixed[i] << " "; }
108  for ( int i = 5; i < 99; ++i ) {
110  std::cout << "[" << i << "]= Error in Fixed momentum" << std::endl;
111  }
112  }
113 #endif
114  std::cout << std::endl;
115  std::cout << System::typeinfoName( typeid( *this ) );
116  if ( 0 != *m_track ) {
117  std::cout << "\t -> Track : "
118  << " px=" << ( *m_track )->px() << " py=" << ( *m_track )->py() << " pz=" << ( *m_track )->pz()
119  << std::endl;
120  } else {
121  std::cout << " Track* is NULL" << std::endl;
122  }
123  //
124  const bool selected = m_cut < m_ntrack && 0 != *m_track;
125  std::cout << System::typeinfoName( typeid( *this ) ) << " SELECTED : ";
127  //
128  return selected; // RETURN
129  }
130  };
131  } // namespace Examples
132 } // end of namespace Gaudi
133 // ============================================================================
135 // ============================================================================
136 // The END
137 // ============================================================================
Selector.h
Gaudi::Examples::EvtCollectionSelector::operator()
bool operator()(NTuple::Tuple *) override
Specialized callback for NTuples.
Definition: EvtCollectionSelector.cpp:100
Gaudi::Examples::EvtCollectionSelector::initialize
StatusCode initialize(NTuple::Tuple *nt) override
Initialization.
Definition: EvtCollectionSelector.cpp:65
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
System.h
std::abs
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition: ParticleID.h:191
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:313
ObjectFactory.h
ToStream.h
Gaudi::Examples::EvtCollectionSelector
Definition: EvtCollectionSelector.cpp:51
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:471
Gaudi::Examples::EvtCollectionSelector::m_trkMomFixed
NTuple::Array< float > m_trkMomFixed
Definition: EvtCollectionSelector.cpp:56
DECLARE_NAMESPACE_OBJECT_FACTORY
#define DECLARE_NAMESPACE_OBJECT_FACTORY(n, x)
Definition: ObjectFactory.h:26
Gaudi::Examples
Definition: EvtColAlg.cpp:40
StatusCode
Definition: StatusCode.h:65
NTuple::Selector
NTuple Selector class.
Definition: Selector.h:39
Gaudi::Examples::EvtCollectionSelector::m_cut
int m_cut
Definition: EvtCollectionSelector.cpp:59
std::cerr
MyTrack.h
NTuple.h
Gaudi::Examples::EvtCollectionSelector::m_track
NTuple::Item< Gaudi::Examples::MyTrack * > m_track
Definition: EvtCollectionSelector.cpp:58
Gaudi::Examples::EvtCollectionSelector::m_trkMom
NTuple::Array< float > m_trkMom
Definition: EvtCollectionSelector.cpp:54
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:234
std::numeric_limits::epsilon
T epsilon(T... args)
std::min
T min(T... args)
NTuple::Selector::Selector
Selector(IInterface *svc)
Standard constructor.
Definition: Selector.h:50
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std::endl
T endl(T... args)
NTuple::Tuple
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:387
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:300
NTuple::Array< float >
EvtCollectionSelector
#define EvtCollectionSelector
Definition: EvtExtCollectionSelector.cpp:12
Gaudi::Examples::EvtCollectionSelector::m_ntrack
NTuple::Item< int > m_ntrack
Definition: EvtCollectionSelector.cpp:53
NTuple::Item< int >