The Gaudi Framework  v36r16 (ea80daf8)
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 #ifdef __ICC
33 // disable icc warning #1125: function "ISelectStatement::operator()(void *)"
34 // is hidden by "Gaudi::Examples::EvtCollectionSelector::operator()"
35 // -- virtual function override intended?
36 # pragma warning( disable : 1125 )
37 // disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
38 # pragma warning( disable : 1572 )
39 #endif
40 namespace Gaudi {
41  namespace Examples {
49  protected:
52 #ifndef NO_TRKMOMFIX
54 #endif
56  int m_cut = 10;
57 
58  public:
60 
64  sc = nt->item( "TrkMom", m_trkMom );
65  if ( !sc.isSuccess() ) {
66  std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
67  std::cerr << "TrkMom" << std::endl;
68  return sc;
69  }
70 #ifndef NO_TRKMOMFIX
71  sc = nt->item( "TrkMomFix", m_trkMomFixed );
72  if ( !sc.isSuccess() ) {
73  std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
74  std::cerr << "TrkMomFix" << std::endl;
75  return sc;
76  }
77 #endif
78  sc = nt->item( "Ntrack", m_ntrack );
79  if ( !sc.isSuccess() ) {
80  std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
81  std::cerr << "Ntrack" << std::endl;
82  return sc;
83  }
84 
85  sc = nt->item( "Track", m_track );
86  if ( !sc.isSuccess() ) {
87  std::cerr << "EvtCollectionSelector: initialize " << sc << std::endl;
88  std::cerr << "Track" << std::endl;
89  return sc;
90  }
91 
92  return sc;
93  }
94 
95  using NTuple::Selector::operator(); // avoid hiding base-class methods
97  bool operator()( NTuple::Tuple* /* nt */ ) override {
98  const int n = m_ntrack;
99  std::cout << System::typeinfoName( typeid( *this ) ) << "\t -> #tracks : " << n << std::endl
100  << System::typeinfoName( typeid( *this ) ) << "\t -> Momenta(Var): ";
101  for ( int i = 0; i < std::min( 5, n ); ++i ) { std::cout << "[" << i << "]=" << m_trkMom[i] << " "; }
102 #ifndef NO_TRKMOMFIX
103  std::cout << std::endl << System::typeinfoName( typeid( *this ) ) << "\t -> Momenta(Fix): ";
104  for ( int i = 0; i < std::min( 5, n ); ++i ) { std::cout << "[" << i << "]=" << m_trkMomFixed[i] << " "; }
105  for ( int i = 5; i < 99; ++i ) {
106  if ( m_trkMomFixed[i] != 0.f ) { std::cout << "[" << i << "]= Error in Fixed momentum" << std::endl; }
107  }
108 #endif
109  std::cout << std::endl;
110  std::cout << System::typeinfoName( typeid( *this ) );
111  if ( 0 != *m_track ) {
112  std::cout << "\t -> Track : "
113  << " px=" << ( *m_track )->px() << " py=" << ( *m_track )->py() << " pz=" << ( *m_track )->pz()
114  << std::endl;
115  } else {
116  std::cout << " Track* is NULL" << std::endl;
117  }
118  //
119  const bool selected = m_cut < m_ntrack && 0 != *m_track;
120  std::cout << System::typeinfoName( typeid( *this ) ) << " SELECTED : ";
122  //
123  return selected; // RETURN
124  }
125  };
126  } // namespace Examples
127 } // end of namespace Gaudi
128 // ============================================================================
130 // ============================================================================
131 // The END
132 // ============================================================================
Selector.h
Gaudi::Examples::EvtCollectionSelector::operator()
bool operator()(NTuple::Tuple *) override
Specialized callback for NTuples.
Definition: EvtCollectionSelector.cpp:97
Gaudi::Examples::EvtCollectionSelector::initialize
StatusCode initialize(NTuple::Tuple *nt) override
Initialization.
Definition: EvtCollectionSelector.cpp:62
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
System.h
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:48
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:53
DECLARE_NAMESPACE_OBJECT_FACTORY
#define DECLARE_NAMESPACE_OBJECT_FACTORY(n, x)
Definition: ObjectFactory.h:26
Gaudi::Examples
Definition: ConditionAccessorHolder.h:21
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:56
std::cerr
MyTrack.h
NTuple.h
Gaudi::Examples::EvtCollectionSelector::m_track
NTuple::Item< Gaudi::Examples::MyTrack * > m_track
Definition: EvtCollectionSelector.cpp:55
Gaudi::Examples::EvtCollectionSelector::m_trkMom
NTuple::Array< float > m_trkMom
Definition: EvtCollectionSelector.cpp:51
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:235
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:299
NTuple::Array< float >
EvtCollectionSelector
#define EvtCollectionSelector
Definition: EvtExtCollectionSelector.cpp:12
Gaudi::Examples::EvtCollectionSelector::m_ntrack
NTuple::Item< int > m_ntrack
Definition: EvtCollectionSelector.cpp:50
NTuple::Item< int >