ATLAS Offline Software
Loading...
Searching...
No Matches
EventFeature Class Reference

Basic container for event feature data. More...

#include <EventFeature.h>

Collaboration diagram for EventFeature:

Public Types

enum  FeatureType {
  ETDENSITY = 0x1000 , ETDENSITY_JETAREA = 0x1100 , ETDENSITY_JETAREA_ETA = 0x1101 , ETDENSITY_ETA_WINDOWS = 0x1201 ,
  ETDENSITY_USER = 0x0010 , UNKNOWN = 0x0000 , DEFAULT = 0xffff
}
 @ More...
enum  FeatureStructureMask {
  NDATAWORDS = 0x0000007f , NDATABLOCKS = 0x00003f80 , TAGBITS = 0x0000c000 , MASKLENGTH = 0x0000ffff ,
  BITSHIFT = 0x00000007
}
 Feature structure descriptors. More...

Public Member Functions

 EventFeature ()
 Default constructor.
 EventFeature (FeatureType type, const std::string &tag, const std::vector< double > &dataList)
 Loaded constructor.
 EventFeature (FeatureType type, const std::string &tag, unsigned int dataStructure, const std::vector< double > &dataList)
 Loaded constructor.
 EventFeature (FeatureType type, const std::string &tag, unsigned int dataStructure)
 Loaded constructor.
 EventFeature (const EventFeature &feature)
 Copy constructor.
virtual ~EventFeature ()
 Destructor.
EventFeatureoperator= (const EventFeature &feature)
 Assignment operator.
const std::string & tag () const
 Retrieve feature tag.
FeatureType type () const
 Retrieve feature type.
unsigned int featureStructure () const
 Retrieve data structure descriptor.
size_t numberDataBlocks ()
 Retrieve number of data blocks.
size_t numberDataWords () const
 Retrieve number of words in data block.
const std::vector< double > & dataList () const
 Retrieve reference to vector store.
std::vector< double > & dataList ()
 Retrieve reference to vector store.
bool dataBlock (size_t blockIdx, std::vector< double > &data)
 Return one datablock.
void setTag (const std::string &tag)
 Set feature tag.
void setType (FeatureType type)
 Set feature type.
void setNumberDataBlocks (size_t nBlocks)
 Set number of blocks.
void setNumberDataWords (size_t nWords)
 Set number of data words per block.
void setDataList (const std::vector< double > &data)
 Set vector data store.
bool setDataBlock (size_t blockIdx, const std::vector< double > &data, bool replace=true)
 Set one data block.
bool addDataBlock (const std::vector< double > &data)
unsigned int buildFeatureStructure ()
 Build compressed feature structure.

Static Public Member Functions

static FeatureType featureType (const std::string &typeTag)
 Binned scalar data model.
static FeatureType featureType ()
 Default feature type.
static const std::string & featureTag (FeatureType type)
 Convert a FeatureType to a tag.
static const std::string & featureTag ()
 Default feature tag.

Private Types

typedef std::pair< size_t, size_t > index_t

Private Member Functions

void setFeatureStructure (bool updateCache=false)
 Set/update feature structure.
bool insertDataBlock (size_t startIdx, size_t endIdx, const std::vector< double > &data)
bool addDataBlock (size_t startIdx, size_t endIdx, const std::vector< double > &data)
bool indexRange (size_t startIdx, index_t &idx)

Private Attributes

FeatureType m_type
 Internal cache for feature type.
std::string m_tag
 Internal cache for feature tag.
unsigned int m_dataWords
 Internal cache data structure description (words per block)
unsigned int m_dataBlocks
 Internal cache for data structure descriptor (number of blocks)
unsigned int m_featureStructure
 Internal cache for compressed data structure descriptor.
std::vector< double > m_dataList
 Internal cache for vector data.
bool m_structureFixed
 Control flag for setting number of data words.

Static Private Attributes

static const std::map< FeatureType, std::string > m_featureTags
 Lookup for feature type and tag matches.

Detailed Description

Basic container for event feature data.

Basic container for event feature data or parameters. Each entry is characterized by the type of information, a tag, and possibly scalar (number) and/or vector (list of numbers or list of number patterns). The possible interpretation of the number patterns depends on the feature type and is usually implemented in the tool producing the EventFeature object.

Definition at line 17 of file EventFeature.h.

Member Typedef Documentation

◆ index_t

typedef std::pair<size_t,size_t> EventFeature::index_t
private

Definition at line 206 of file EventFeature.h.

Member Enumeration Documentation

◆ FeatureStructureMask

Feature structure descriptors.

Mostly useful for T/P converter yet public for converter access

Enumerator
NDATAWORDS 
NDATABLOCKS 
TAGBITS 
MASKLENGTH 
BITSHIFT 

Definition at line 39 of file EventFeature.h.

39 { NDATAWORDS = 0x0000007f, /*<! Mask for number of
40 data words/block (max
41 accomodation 128)*/
42 NDATABLOCKS = 0x00003f80, /*<! Mask for number of
43 data blocks (max
44 accommodation 128)*/
45 TAGBITS = 0x0000c000, /*<! Mask for additional
46 tag bits (2 bits)*/
47 MASKLENGTH = 0x0000ffff, /*<! Mask for total
48 used bit range (16)*/
49 BITSHIFT = 0x00000007 }; /*<! Shift step */

◆ FeatureType

@

Type enumerators

Enumerator
ETDENSITY 
ETDENSITY_JETAREA 

FastJet density

ETDENSITY_JETAREA_ETA 

FastJet density, \( \eta \) dependent

ETDENSITY_ETA_WINDOWS 

density in sliding \( \eta \) windows

ETDENSITY_USER 

User defined density.

UNKNOWN 

Unknown type.

DEFAULT 

Default type.

Definition at line 23 of file EventFeature.h.

24 { ETDENSITY = 0x1000,
25 ETDENSITY_JETAREA = 0x1100,
26 ETDENSITY_JETAREA_ETA = 0x1101,
28 ETDENSITY_ETA_WINDOWS = 0x1201,
30 ETDENSITY_USER = 0x0010,
31 UNKNOWN = 0x0000,
32 DEFAULT = 0xffff
33 };
@ ETDENSITY_JETAREA
FastJet density
@ UNKNOWN
Unknown type.
@ ETDENSITY_JETAREA_ETA
FastJet density, dependent
@ ETDENSITY_USER
User defined density.
@ DEFAULT
Default type.
@ ETDENSITY_ETA_WINDOWS
density in sliding windows

Constructor & Destructor Documentation

◆ EventFeature() [1/5]

EventFeature::EventFeature ( )

Default constructor.

Instantiates empty data object, with defaults:

type = EventFeature::UNKNOWN; tag = "Default"; dataList = std::vector<double>();

This object also has no internal data structure (0 data words in 0 blocks).

Definition at line 53 of file EventFeature.cxx.

55 , m_tag("Default")
56 , m_dataWords(0)
57 , m_dataBlocks(0)
59 , m_dataList(std::vector<double>())
60 , m_structureFixed(false)
61{ }
std::string m_tag
Internal cache for feature tag.
std::vector< double > m_dataList
Internal cache for vector data.
unsigned int m_dataBlocks
Internal cache for data structure descriptor (number of blocks)
FeatureType m_type
Internal cache for feature type.
unsigned int m_dataWords
Internal cache data structure description (words per block)
bool m_structureFixed
Control flag for setting number of data words.
unsigned int m_featureStructure
Internal cache for compressed data structure descriptor.

◆ EventFeature() [2/5]

EventFeature::EventFeature ( FeatureType type,
const std::string & tag,
const std::vector< double > & dataList )

Loaded constructor.

Parameters
[in]typeEventFeature type
[in]tagstring identifier/tag for data
[in]dataListreference to non-modifiable data vector to be copied to internal store
Note
Flat data structure with dataList.size() words in one block.

Definition at line 63 of file EventFeature.cxx.

66 : m_type(type)
67 , m_tag(tag)
68 , m_dataWords(dataList.size())
69 , m_dataBlocks(1)
70 , m_dataList(dataList.begin(),dataList.end())
71 , m_structureFixed(true)
72{
73 this->setFeatureStructure();
74}
FeatureType type() const
Retrieve feature type.
void setFeatureStructure(bool updateCache=false)
Set/update feature structure.
const std::vector< double > & dataList() const
Retrieve reference to vector store.
const std::string & tag() const
Retrieve feature tag.

◆ EventFeature() [3/5]

EventFeature::EventFeature ( FeatureType type,
const std::string & tag,
unsigned int dataStructure,
const std::vector< double > & dataList )

Loaded constructor.

Parameters
[in]typeEventFeature type
[in]tagstring identifier/tag for data
[in]datascalar (number) data word to be stored internally
[in]dataListreference to non-modifiable data vector to be copied to internal store

Definition at line 76 of file EventFeature.cxx.

79 : m_type(type)
80 , m_tag(tag)
81 , m_dataWords(nWords)
83 , m_dataList(dataList.begin(),dataList.end())
84 , m_structureFixed(true)
85{
86 this->setFeatureStructure();
87}

◆ EventFeature() [4/5]

EventFeature::EventFeature ( FeatureType type,
const std::string & tag,
unsigned int dataStructure )

Loaded constructor.

Parameters
[in]typeEventFeature type
[in]tagstring identifier/tag for data
[in]datascalar (number) data word to be stored internally
Note
Internal multiple (vector) store is set to its default value (std::vector<double>() ).

Definition at line 89 of file EventFeature.cxx.

91 : m_type(type)
92 , m_tag(tag)
93 , m_dataWords(nWords)
94 , m_dataBlocks(0)
95 , m_dataList(std::vector<double>())
96 , m_structureFixed(true)
97{
98 this->setFeatureStructure();
99}

◆ EventFeature() [5/5]

EventFeature::EventFeature ( const EventFeature & feature)

Copy constructor.

Definition at line 101 of file EventFeature.cxx.

102 : m_type(feature.m_type)
103 , m_tag(feature.m_tag)
104 , m_dataWords(feature.m_dataWords)
105 , m_dataBlocks(feature.m_dataBlocks)
106 , m_dataList(feature.dataList().begin(),feature.dataList().end())
108{
109 this->setFeatureStructure();
110}

◆ ~EventFeature()

EventFeature::~EventFeature ( )
virtual

Destructor.

Definition at line 112 of file EventFeature.cxx.

113{ }

Member Function Documentation

◆ addDataBlock() [1/2]

bool EventFeature::addDataBlock ( const std::vector< double > & data)

Definition at line 165 of file EventFeature.cxx.

166{
167 index_t idx(0,0);
168 this->indexRange(m_dataBlocks+1,idx);
169 return addDataBlock(idx.first,idx.second,data);
170}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
bool addDataBlock(const std::vector< double > &data)
bool indexRange(size_t startIdx, index_t &idx)
std::pair< size_t, size_t > index_t

◆ addDataBlock() [2/2]

bool EventFeature::addDataBlock ( size_t startIdx,
size_t endIdx,
const std::vector< double > & data )
private

Definition at line 172 of file EventFeature.cxx.

174{
176 size_t imax(std::min(endIdx-startIdx,data.size()));
177 for ( size_t i(0); i<imax; ++i ) { m_dataList[i+startIdx] = data.at(i); }
178 this->setFeatureStructure();
179 return imax>0;
180}
int imax(int i, int j)
static double nullValue()

◆ buildFeatureStructure()

unsigned int EventFeature::buildFeatureStructure ( )

Build compressed feature structure.

Definition at line 224 of file EventFeature.cxx.

225{
227 (m_dataWords&(unsigned int)NDATAWORDS) |
228 ((m_dataBlocks&(unsigned int)NDATABLOCKS)<<(unsigned int)BITSHIFT);
229 return m_featureStructure;
230}

◆ dataBlock()

bool EventFeature::dataBlock ( size_t blockIdx,
std::vector< double > & data )

Return one datablock.

Definition at line 138 of file EventFeature.cxx.

139{
140
141 // get index range
142 index_t idx(0,0);
143 if ( !this->indexRange(blockIdx,idx) ) return false;
144 // copy data
145 for ( size_t i(idx.first); i<idx.second; ++i )
146 {
147 data.push_back(m_dataList.at(i));
148 }
149 return !data.empty();
150}

◆ dataList() [1/2]

std::vector< double > & EventFeature::dataList ( )
inline

Retrieve reference to vector store.

Returns
const reference to modifiable vector data store.

Definition at line 292 of file EventFeature.h.

293{ return m_dataList; }

◆ dataList() [2/2]

const std::vector< double > & EventFeature::dataList ( ) const
inline

Retrieve reference to vector store.

Returns
const reference to non-modifiable vector data store.

Definition at line 289 of file EventFeature.h.

290{ return m_dataList; }

◆ featureStructure()

unsigned int EventFeature::featureStructure ( ) const
inline

Retrieve data structure descriptor.

Returns
Copy of data structure descriptor

Definition at line 286 of file EventFeature.h.

287{ return m_featureStructure; }

◆ featureTag() [1/2]

const std::string & EventFeature::featureTag ( )
static

Default feature tag.

Definition at line 35 of file EventFeature.cxx.

36{
37 auto it = m_featureTags.find(DEFAULT);
38 if (it == m_featureTags.end()) std::abort();
39 return it->second;
40}
static const std::map< FeatureType, std::string > m_featureTags
Lookup for feature type and tag matches.

◆ featureTag() [2/2]

const std::string & EventFeature::featureTag ( FeatureType type)
static

Convert a FeatureType to a tag.

Definition at line 42 of file EventFeature.cxx.

43{
44 std::map<FeatureType,std::string>::const_iterator fMap(m_featureTags.find(type));
45 if (fMap != m_featureTags.end()) {
46 return fMap->second;
47 }
48 fMap = m_featureTags.find (UNKNOWN);
49 if (fMap == m_featureTags.end()) std::abort();
50 return fMap->second;
51}

◆ featureType() [1/2]

EventFeature::FeatureType EventFeature::featureType ( )
static

Default feature type.

Definition at line 24 of file EventFeature.cxx.

25{ return EventFeature::DEFAULT; }

◆ featureType() [2/2]

EventFeature::FeatureType EventFeature::featureType ( const std::string & typeTag)
static

Binned scalar data model.

Parameters
[in]lminminimum

Convert feature tag to FeatureType

Definition at line 27 of file EventFeature.cxx.

28{
29 std::map<FeatureType,std::string>::const_iterator fMap(m_featureTags.begin());
30 std::map<FeatureType,std::string>::const_iterator lMap(m_featureTags.end());
31 while ( fMap != lMap && tag != fMap->second ) { ++ fMap; }
32 return fMap != lMap ? fMap->first : UNKNOWN;
33}

◆ indexRange()

bool EventFeature::indexRange ( size_t startIdx,
index_t & idx )
private

Definition at line 232 of file EventFeature.cxx.

233{
234 this->setFeatureStructure(false);
235 size_t locIdx(startIdx*m_dataWords+m_dataBlocks);
236 if ( locIdx > m_dataList.size() ) return false;
237 idx.first = startIdx;
238 idx.second = locIdx;
239 return true;
240}

◆ insertDataBlock()

bool EventFeature::insertDataBlock ( size_t startIdx,
size_t endIdx,
const std::vector< double > & data )
private

Definition at line 182 of file EventFeature.cxx.

184{
185 size_t imax(std::min(endIdx-startIdx,data.size()));
186 for ( size_t i(0); i<imax; ++i ) { m_dataList[i+startIdx] = data.at(i); }
187 return imax>0;
188}

◆ numberDataBlocks()

size_t EventFeature::numberDataBlocks ( )
inline

Retrieve number of data blocks.

Returns
Number of data blocks

Definition at line 311 of file EventFeature.h.

312{ this->setFeatureStructure(); return m_dataBlocks; }

◆ numberDataWords()

size_t EventFeature::numberDataWords ( ) const
inline

Retrieve number of words in data block.

Returns
Number of words in data block

Definition at line 308 of file EventFeature.h.

309{ return m_dataWords; }

◆ operator=()

EventFeature & EventFeature::operator= ( const EventFeature & feature)

Assignment operator.

Copies data content from EventFeature source.

Parameters
[in]featurereference to non-modifiable EventFeature object

Definition at line 115 of file EventFeature.cxx.

116{
117 if (this != &feature) {
118 m_type = feature.m_type;
119 m_tag = feature.m_tag;
120 m_dataWords = feature.m_dataWords;
121 m_dataBlocks = feature.m_dataBlocks;
123 if ( feature.m_dataList.empty() )
124 {
125 m_dataList.clear();
126 }
127 else
128 {
129 m_dataList.resize(feature.m_dataList.size());
130 std::copy(feature.m_dataList.begin(),feature.m_dataList.end(),
131 m_dataList.begin());
132 }
133 this->setFeatureStructure();
134 }
135 return *this;
136}

◆ setDataBlock()

bool EventFeature::setDataBlock ( size_t blockIdx,
const std::vector< double > & data,
bool replace = true )

Set one data block.

Definition at line 152 of file EventFeature.cxx.

155{
156 // get index range and check if replacement
157 index_t idx(0,0);
158 bool inRange(this->indexRange(blockIdx,idx));
159 if ( inRange && !replace ) return false;
160 // replace or add
161 if ( !inRange ) return this->addDataBlock(idx.first,idx.second,data);
162 return this->insertDataBlock(idx.first,idx.second,data);
163}
bool inRange(const double *boundaries, const double value, const double tolerance=0.02)
bool insertDataBlock(size_t startIdx, size_t endIdx, const std::vector< double > &data)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

◆ setDataList()

void EventFeature::setDataList ( const std::vector< double > & data)
inline

Set vector data store.

Parameters
[in]datareference to non-modifiable data vector

Definition at line 301 of file EventFeature.h.

302{
303 m_dataList.resize(data.size());
304 std::copy(data.begin(),data.end(),m_dataList.begin());
305 this->setFeatureStructure();
306}

◆ setFeatureStructure()

void EventFeature::setFeatureStructure ( bool updateCache = false)
private

Set/update feature structure.

Definition at line 211 of file EventFeature.cxx.

212{
213 if ( updateCache )
214 {
215 size_t cacheSize(m_dataWords*m_dataBlocks);
217 }
218 // update
220 // construct feature structure
221 this->buildFeatureStructure();
222}
unsigned int buildFeatureStructure()
Build compressed feature structure.
static double invalidValue()

◆ setNumberDataBlocks()

void EventFeature::setNumberDataBlocks ( size_t nBlocks)

Set number of blocks.

Parameters
[in]nBlocksnumber of data blocks

Definition at line 201 of file EventFeature.cxx.

202{
203 if ( nBlocks <= (size_t)
204 (((unsigned int)NDATABLOCKS)>>(unsigned int)BITSHIFT) )
205 {
206 m_dataBlocks = nBlocks;
207 this->setFeatureStructure(true);
208 }
209}

◆ setNumberDataWords()

void EventFeature::setNumberDataWords ( size_t nWords)

Set number of data words per block.

Parameters
[in]nWordsnumber of data words per block

Definition at line 190 of file EventFeature.cxx.

191{
192 if ( !m_structureFixed && nWords <= (unsigned int)NDATAWORDS )
193 {
194 m_dataWords = nWords;
195 m_dataBlocks = 0;
196 this->setFeatureStructure(true);
197 m_structureFixed = true;
198 }
199}

◆ setTag()

void EventFeature::setTag ( const std::string & tag)
inline

Set feature tag.

Parameters
[in]tagreference to non-modifiable tag string

Definition at line 298 of file EventFeature.h.

299{ m_tag = tag; }

◆ setType()

void EventFeature::setType ( FeatureType type)
inline

Set feature type.

Parameters
[in]typefeature type

Definition at line 295 of file EventFeature.h.

296{ m_type = type; }

◆ tag()

const std::string & EventFeature::tag ( ) const
inline

Retrieve feature tag.

Returns
const reference to non-modifiable feature tag (string).

Definition at line 280 of file EventFeature.h.

281{ return m_tag; }

◆ type()

EventFeature::FeatureType EventFeature::type ( ) const
inline

Retrieve feature type.

Returns
Copy of feature type.

Definition at line 283 of file EventFeature.h.

284{ return m_type; }

Member Data Documentation

◆ m_dataBlocks

unsigned int EventFeature::m_dataBlocks
private

Internal cache for data structure descriptor (number of blocks)

Definition at line 229 of file EventFeature.h.

◆ m_dataList

std::vector<double> EventFeature::m_dataList
private

Internal cache for vector data.

Definition at line 233 of file EventFeature.h.

◆ m_dataWords

unsigned int EventFeature::m_dataWords
private

Internal cache data structure description (words per block)

Definition at line 227 of file EventFeature.h.

◆ m_featureStructure

unsigned int EventFeature::m_featureStructure
private

Internal cache for compressed data structure descriptor.

Definition at line 231 of file EventFeature.h.

◆ m_featureTags

const std::map< EventFeature::FeatureType, std::string > EventFeature::m_featureTags
staticprivate
Initial value:
= {
{ETDENSITY, "ETDENSITY"},
{ETDENSITY_JETAREA, "ETDESNSITY_JETAREA"},
{ETDENSITY_JETAREA_ETA, "ETDENSITY_JETAREA_ETA"},
{ETDENSITY_ETA_WINDOWS, "ETDENSITY_ETA_WINDOWS"},
{ETDENSITY_USER, "ETDENSITY_USER"},
{UNKNOWN, "UNKNOWN"},
{DEFAULT, "DEFAULT"},
}

Lookup for feature type and tag matches.

Definition at line 14 of file EventFeature.h.

18{
19public:
20

◆ m_structureFixed

bool EventFeature::m_structureFixed
private

Control flag for setting number of data words.

Can only be done once!

Definition at line 239 of file EventFeature.h.

◆ m_tag

std::string EventFeature::m_tag
private

Internal cache for feature tag.

Definition at line 225 of file EventFeature.h.

◆ m_type

FeatureType EventFeature::m_type
private

Internal cache for feature type.

Definition at line 223 of file EventFeature.h.


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