Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TupleAlg2.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 // ============================================================================
12 // Include files
13 // ============================================================================
14 // STD & STL
15 // ============================================================================
16 #include <utility>
17 // ============================================================================
18 // GaudiKernel
19 // ============================================================================
22 // ============================================================================
23 // GaudiAlg
24 // ============================================================================
25 #include "GaudiAlg/GaudiTupleAlg.h"
26 #include "GaudiAlg/Tuple.h"
27 // ============================================================================
28 // local
29 // ============================================================================
30 #include "TupleDef.h"
31 // ============================================================================
32 
33 // ============================================================================
41 // ============================================================================
42 
43 class TupleAlg2 : public GaudiTupleAlg {
44 public:
46  StatusCode initialize() override {
48  if ( sc.isFailure() ) { return sc; }
49  // check for random numbers service
50  Assert( randSvc() != 0, "Random Service is not available!" );
51  //
52  return StatusCode::SUCCESS;
53  };
57  StatusCode execute() override;
58 
63  using GaudiTupleAlg::GaudiTupleAlg;
64 
65 private:
66  // copy constructor is disabled
67  TupleAlg2( const TupleAlg2& ) = delete;
68  // assignement op[erator is disabled
69  TupleAlg2& operator=( const TupleAlg2& ) = delete;
70 };
71 
72 // ============================================================================
74 // ============================================================================
75 
76 // ============================================================================
80 // ============================================================================
83  using namespace Tuples;
84  using namespace TupleExample;
85 
86  Rndm::Numbers gauss( randSvc(), Rndm::Gauss( 0.0, 1.0 ) );
87  Rndm::Numbers flat( randSvc(), Rndm::Flat( -10.0, 10.0 ) );
88  Rndm::Numbers expo( randSvc(), Rndm::Exponential( 1.0 ) );
89  Rndm::Numbers breit( randSvc(), Rndm::BreitWigner( 0.0, 1.0 ) );
90  Rndm::Numbers poisson( randSvc(), Rndm::Poisson( 2.0 ) );
91  Rndm::Numbers binom( randSvc(), Rndm::Binomial( 8, 0.25 ) );
92 
93  // ==========================================================================
94  // book and fill simple NTuple with "dublets"
95  // ==========================================================================
96  Tuple tuple1 = nTuple( "dublets", "Tuple with dublets" );
97 
98  Dublet d1 = Dublet( gauss(), gauss() );
99  Dublet d2 = Dublet( flat(), flat() );
100  Dublet d3 = Dublet( breit(), breit() );
101  Dublet d4 = Dublet( expo(), expo() );
102 
103  tuple1 << Column( "d1", d1 ) << Column( "d2", d2 ) << Column( "d3", d3 ) << Column( "d4", d4 );
104 
105  tuple1->write().ignore();
106 
107  // ==========================================================================
108  // book and fill simple NTuple with "triplets"
109  // ==========================================================================
110  Tuple tuple2 = nTuple( "triplets", "Tuple with triplets" );
111 
112  Triplet tr1;
113  tr1.first.first = gauss();
114  tr1.first.second = gauss();
115  tr1.second = gauss();
116 
117  Triplet tr2;
118  tr2.first.first = flat();
119  tr2.first.second = flat();
120  tr2.second = flat();
121 
122  tuple2 << Column( "tr1", tr1 );
123  tuple2 << Column( "tr2", tr2 );
124 
125  tuple2->write().ignore();
126 
127  return StatusCode::SUCCESS;
128 }
129 // ============================================================================
130 
131 // ============================================================================
132 // The END
133 // ============================================================================
GaudiAlg.TupleUtils.nTuple
def nTuple(dirpath, ID, ID2=None, topdir=None, LUN="FILE1")
Definition: TupleUtils.py:84
TupleAlg2::TupleAlg2
TupleAlg2(const TupleAlg2 &)=delete
Tuple.h
RndmGenerators.h
Gaudi::Algorithm::randSvc
SmartIF< IRndmGenSvc > & randSvc() const
The standard RandomGen service, Return a pointer to the service if present.
Definition: Algorithm.cpp:565
GaudiCommon< Algorithm >::Assert
void Assert(const bool ok, std::string_view message="", const StatusCode sc=StatusCode::FAILURE) const
Assertion - throw exception if the given condition is not fulfilled.
Definition: GaudiCommonImp.h:175
std::pair
IRndmGenSvc.h
GaudiTupleAlg
Definition: GaudiTupleAlg.h:51
Rndm::Flat
Parameters for the flat random number generation within boundaries [minimum, maximum].
Definition: RndmGenerators.h:253
TupleExample
Definition: TupleDef.cpp:25
TupleAlg2::initialize
StatusCode initialize() override
initialize the algorithm
Definition: TupleAlg2.cpp:46
TupleAlg2::operator=
TupleAlg2 & operator=(const TupleAlg2 &)=delete
Tuples
Definition: Maps.h:43
TupleExample::Dublet
std::pair< double, double > Dublet
Definition: TupleDef.h:45
GaudiTupleAlg.h
StatusCode
Definition: StatusCode.h:65
Rndm::Gauss
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:32
TupleDef.h
Rndm::Numbers
Random number accessor This small class encapsulates the use of the random number generator.
Definition: RndmGenerators.h:359
GaudiPython.Pythonizations.execute
execute
Definition: Pythonizations.py:578
Rndm::BreitWigner
Parameters for the BreitWigner distributed random number generation.
Definition: RndmGenerators.h:94
Tuples::Tuple
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: Tuple.h:126
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
Gaudi::Units::gauss
constexpr double gauss
Definition: SystemOfUnits.h:252
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
Tuples::TupleObj::write
StatusCode write()
write a record to NTuple
Definition: TupleObj.cpp:245
TupleAlg2
Definition: TupleAlg2.cpp:43
Rndm::Exponential
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:56
Rndm::Poisson
Parameters for the Poisson distributed random number generation with a given mean.
Definition: RndmGenerators.h:209
GaudiTuples< GaudiHistoAlg >::initialize
StatusCode initialize() override
standard initialization method
Definition: GaudiTuples.icpp:47
TupleAlg2::execute
StatusCode execute() override
the only one essential method
Definition: TupleAlg2.cpp:81
Tuples::Column
TupleColumn< ITEM > Column(std::string name, const ITEM &item)
Definition: Tuple.h:304
Rndm::Binomial
Parameters for the Binomial distributed random number generation.
Definition: RndmGenerators.h:230