The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
NTupleImplementation.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
\***********************************************************************************/
11
#include <
GaudiKernel/IDataSelector.h
>
12
#include <
GaudiKernel/INTupleSvc.h
>
13
#include <
GaudiKernel/ISelectStatement.h
>
14
#include <
GaudiKernel/NTupleImplementation.h
>
15
16
namespace
NTuple
{
17
TupleImp::TupleImp
( std::string
title
) :
m_title
(
std
::move(
title
) ) {}
18
TupleImp::~TupleImp
() {
19
for
(
auto
& i :
m_items
) i->release();
20
}
21
23
StatusCode
TupleImp::attachSelector
(
ISelectStatement
* sel ) {
24
m_pSelector
= sel;
25
return
StatusCode::SUCCESS
;
26
}
27
29
ISelectStatement
*
TupleImp::selector
() {
return
m_pSelector
.get(); }
30
32
void
TupleImp::reset
() {
33
for
(
auto
& i :
m_items
) i->reset();
34
}
35
37
INTupleItem
*
TupleImp::i_find
(
const
std::string&
name
)
const
{
38
auto
i = std::find_if( std::begin(
m_items
), std::end(
m_items
),
39
[&]( ItemContainer::const_reference j ) {
return
j->name() ==
name
; } );
40
return
i != std::end(
m_items
) ?
const_cast<
INTupleItem
*
>
( *i ) :
nullptr
;
41
}
42
44
StatusCode
TupleImp::add
(
INTupleItem
*
item
) {
45
if
(
item
) {
46
INTupleItem
* i =
i_find
(
item
->name() );
47
if
( !i ) {
48
m_items
.push_back(
item
);
49
return
StatusCode::SUCCESS
;
50
}
51
}
52
return
StatusCode::FAILURE
;
53
}
54
56
StatusCode
TupleImp::remove
(
const
std::string&
name
) {
57
INTupleItem
* i =
i_find
(
name
);
58
return
i ?
remove
( i ) :
StatusCode::FAILURE
;
59
}
60
62
StatusCode
TupleImp::remove
(
INTupleItem
*
item
) {
63
auto
i = std::find( std::begin(
m_items
), std::end(
m_items
),
item
);
64
if
( i == std::end(
m_items
) )
return
StatusCode::FAILURE
;
65
m_items
.erase( i );
66
item
->release();
67
return
StatusCode::SUCCESS
;
68
}
69
70
char
*
TupleImp::setBuffer
( std::unique_ptr<
char
[]>&& buff ) {
71
m_buffer
= std::move( buff );
72
return
m_buffer
.get();
73
}
74
75
char
*
TupleImp::setBuffer
(
char
* buff ) {
76
m_buffer
.reset( buff );
77
return
m_buffer
.get();
78
}
79
80
StatusCode
TupleImp::write
() {
return
m_ntupleSvc
->writeRecord(
this
); }
82
StatusCode
TupleImp::writeRecord
() {
return
m_ntupleSvc
->writeRecord(
this
); }
84
StatusCode
TupleImp::read
() {
return
m_ntupleSvc
->readRecord(
this
); }
86
StatusCode
TupleImp::readRecord
() {
return
m_ntupleSvc
->readRecord(
this
); }
88
StatusCode
TupleImp::save
() {
return
m_ntupleSvc
->save(
this
); }
89
}
// namespace NTuple
IDataSelector.h
INTupleSvc.h
ISelectStatement.h
NTupleImplementation.h
DataObject::name
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition
DataObject.cpp:72
INTupleItem
NTuple interface class definition.
Definition
INTuple.h:32
ISelectStatement
A select statement can either contain.
Definition
ISelectStatement.h:38
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
NTuple::TupleImp::save
StatusCode save() override
Save the NTuple.
Definition
NTupleImplementation.cpp:88
NTuple::TupleImp::i_find
INTupleItem * i_find(const std::string &name) const override
Internally used by abstract classes.
Definition
NTupleImplementation.cpp:37
NTuple::TupleImp::setBuffer
virtual char * setBuffer(std::unique_ptr< char[]> &&buff)
Set N tuple data buffer.
Definition
NTupleImplementation.cpp:70
NTuple::TupleImp::write
StatusCode write() override
Write record of the NTuple (Shortcut of writeRecord).
Definition
NTupleImplementation.cpp:80
NTuple::TupleImp::TupleImp
TupleImp(const TupleImp &)=delete
Standard Copy Constructor.
NTuple::TupleImp::title
const std::string & title() const override
Object title.
Definition
NTupleImplementation.h:58
NTuple::TupleImp::selector
ISelectStatement * selector() override
Access selector.
Definition
NTupleImplementation.cpp:29
NTuple::TupleImp::attachSelector
StatusCode attachSelector(ISelectStatement *sel) override
Attach selector.
Definition
NTupleImplementation.cpp:23
NTuple::TupleImp::readRecord
StatusCode readRecord() override
Read record of the NTuple.
Definition
NTupleImplementation.cpp:86
NTuple::TupleImp::writeRecord
StatusCode writeRecord() override
Write record of the NTuple.
Definition
NTupleImplementation.cpp:82
NTuple::TupleImp::add
StatusCode add(INTupleItem *item) override
Add an item row to the N tuple.
Definition
NTupleImplementation.cpp:44
NTuple::TupleImp::m_pSelector
SmartIF< ISelectStatement > m_pSelector
Possibly hanging selector.
Definition
NTupleImplementation.h:32
NTuple::TupleImp::reset
void reset() override
Reset all entries to their default values.
Definition
NTupleImplementation.cpp:32
NTuple::TupleImp::remove
StatusCode remove(INTupleItem *item) override
Remove an item row (identified by pointer) from the N tuple.
Definition
NTupleImplementation.cpp:62
NTuple::TupleImp::m_items
ItemContainer m_items
Container with N tuple _Columns.
Definition
NTupleImplementation.h:26
NTuple::TupleImp::m_title
std::string m_title
N tuple title.
Definition
NTupleImplementation.h:30
NTuple::TupleImp::~TupleImp
~TupleImp() override
Standard Destructor.
Definition
NTupleImplementation.cpp:18
NTuple::TupleImp::m_buffer
std::unique_ptr< char[]> m_buffer
Buffer.
Definition
NTupleImplementation.h:34
NTuple::TupleImp::m_ntupleSvc
INTupleSvc * m_ntupleSvc
Reference to N-tuple service used.
Definition
NTupleImplementation.h:36
NTuple::TupleImp::read
StatusCode read() override
Read record of the NTuple (Shortcut of readRecord).
Definition
NTupleImplementation.cpp:84
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
NTuple
NTuple name space.
Definition
INTupleSvc.h:16
std
STL namespace.
GaudiKernel
src
Lib
NTupleImplementation.cpp
Generated on
for The Gaudi Framework by
1.17.0