Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
MultiHead Struct Reference

#include <MultiHead.hh>

Inheritance diagram for MultiHead:
std::vector< Head > TObject JAANET::JMultiHead

Public Member Functions

 MultiHead ()
 Default constructor.
 
virtual ~MultiHead ()
 Virtual destructor.
 
const_iterator find (const uuid_t &uuid, const bool useCache=false) const
 Find header with given UUID.
 
const_iterator find (const Evt &event, const bool useCache=false) const
 Find the header corresponding to the given event.
 
bool insert (const Head &header)
 Insert the given header.
 
size_t join (const MultiHead &multiHead)
 Join given MultiHead object with this MultiHead object.
 
 ClassDef (MultiHead, 1)
 

Static Public Member Functions

static void actionAtFileOpen (int version)
 Action method at file open.
 

Static Public Attributes

static int ROOT_IO_VERSION = -1
 Streamer version as obtained from ROOT file.
 

Detailed Description

Author
bjung

Definition at line 17 of file MultiHead.hh.

Constructor & Destructor Documentation

◆ MultiHead()

MultiHead::MultiHead ( )
inline

Default constructor.

Definition at line 24 of file MultiHead.hh.

24 :
26 TObject()
27 {}

◆ ~MultiHead()

virtual MultiHead::~MultiHead ( )
inlinevirtual

Virtual destructor.

Definition at line 33 of file MultiHead.hh.

34 {}

Member Function Documentation

◆ find() [1/2]

const_iterator MultiHead::find ( const uuid_t & uuid,
const bool useCache = false ) const
inline

Find header with given UUID.


Note: The parameter useCache can be toggled on for faster lookup.
This should not be used if your MultiHead object is modified between look-ups.

Parameters
uuidheader UUID
useCacheuse caching for faster look-up
Returns
header with given UUID

Definition at line 47 of file MultiHead.hh.

49 {
50 using namespace std;
51
52 static struct Cache
53 {
54 Cache() { uuid_clear(this->uuid); }
55
56 const_iterator it;
57 uuid_t uuid;
58 } cache;
59
60 if (!useCache) {
61
62 for (cache.it = this->cbegin(); cache.it != this->cend(); ++cache.it) {
63
64 const Head& head = *cache.it;
65 string uuid_str = head.at(Head::tags::UUID);
66
67 uuid_str.erase(remove_if(uuid_str.begin(), uuid_str.end(), ::isspace), uuid_str.end());
68
69 uuid_parse(uuid_str.c_str(), cache.uuid);
70
71 if (uuid_compare(uuid, cache.uuid) == 0) {
72 return cache.it;
73 }
74 }
75
76 return this->end();
77
78 } else {
79
80 if (uuid_compare(uuid, cache.uuid) == 0) {
81 return cache.it;
82 } else {
83 return find(uuid, false);
84 }
85 }
86 }
static constexpr const char *const UUID
Definition Head.hh:67
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...
Definition Head.hh:65
const_iterator find(const uuid_t &uuid, const bool useCache=false) const
Find header with given UUID.
Definition MultiHead.hh:47

◆ find() [2/2]

const_iterator MultiHead::find ( const Evt & event,
const bool useCache = false ) const
inline

Find the header corresponding to the given event.

Note: The parameter useCache can be toggled on for faster lookup.
This should not be used if your MultiHead object is modified between look-ups.

Parameters
eventevent
useCacheuse caching for faster look-up
Returns
header corresponding to the given event

Definition at line 98 of file MultiHead.hh.

100 {
101 return find(event.header_uuid, useCache);
102 }
uuid_t header_uuid
UUID of header containing the event-weight information.
Definition Evt.hh:35

◆ insert()

bool MultiHead::insert ( const Head & header)
inline

Insert the given header.

Parameters
headerheader
Returns
true if insertion was successful; else false

Definition at line 111 of file MultiHead.hh.

112 {
113 using namespace std;
114
115 string uuid_str = header.at(Head::tags::UUID);
116 uuid_str.erase(remove_if(uuid_str.begin(), uuid_str.end(), ::isspace), uuid_str.end());
117
118 uuid_t uuid;
119 uuid_parse(uuid_str.c_str(), uuid);
120
121 if (uuid_is_null(uuid) == 0 && find(uuid) == this->cend()) {
122
123 this->push_back(header);
124
125 return true;
126 }
127
128 return false;
129 }

◆ join()

size_t MultiHead::join ( const MultiHead & multiHead)
inline

Join given MultiHead object with this MultiHead object.

Parameters
multiHeadMultiHead object
Returns
number of inserted headers

Definition at line 138 of file MultiHead.hh.

139 {
140 using namespace std;
141
142 size_t n = 0;
143
144 for (const_iterator i = multiHead.cbegin(); i != multiHead.cend(); ++i) {
145 n += (size_t) this->insert(*i);
146 }
147
148 return n;
149 }
const int n
Definition JPolint.hh:791
bool insert(const Head &header)
Insert the given header.
Definition MultiHead.hh:111

◆ actionAtFileOpen()

static void MultiHead::actionAtFileOpen ( int version)
inlinestatic

Action method at file open.

Parameters
versionversion

Definition at line 157 of file MultiHead.hh.

158 {
159 ROOT_IO_VERSION = version;
160 }
static int ROOT_IO_VERSION
Streamer version as obtained from ROOT file.
Definition MultiHead.hh:163

◆ ClassDef()

MultiHead::ClassDef ( MultiHead ,
1  )

Member Data Documentation

◆ ROOT_IO_VERSION

int MultiHead::ROOT_IO_VERSION = -1
static

Streamer version as obtained from ROOT file.

Definition at line 163 of file MultiHead.hh.


The documentation for this struct was generated from the following files: