ATLAS Offline Software
Loading...
Searching...
No Matches
EventFeature.h
Go to the documentation of this file.
1// -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5*/
6
7#ifndef EVENTSHAPEEVENT_EVENTFEATURE_H
8#define EVENTSHAPEEVENT_EVENTFEATURE_H
9
10//#include "EventShapeEvent/EventShapes.h"
11
12#include <string>
13#include <vector>
14#include <algorithm>
15#include <map>
16
18{
19public:
20
24 { ETDENSITY = 0x1000,
30 ETDENSITY_USER = 0x0010,
31 UNKNOWN = 0x0000,
32 DEFAULT = 0xffff
33 };
34
39 enum FeatureStructureMask { 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 */
50
74 const std::string& tag,
75 const std::vector<double>& dataList);
85 const std::string& tag,
86 unsigned int dataStructure,
87 const std::vector<double>& dataList);
99 const std::string& tag,
100 unsigned int dataStructure);
102 EventFeature(const EventFeature& feature);
103
105 virtual ~EventFeature();
106
114 EventFeature& operator=(const EventFeature& feature);
115
120 const std::string& tag() const;
125 FeatureType type() const;
130 unsigned int featureStructure() const;
135 size_t numberDataBlocks();
140 size_t numberDataWords() const;
145 const std::vector<double>& dataList() const;
150 std::vector<double>& dataList();
151
153 bool dataBlock(size_t blockIdx,std::vector<double>& data);
154
159 void setTag(const std::string& tag);
169 void setNumberDataBlocks(size_t nBlocks);
174 void setNumberDataWords(size_t nWords);
175
180 void setDataList(const std::vector<double>& data);
182 bool setDataBlock(size_t blockIdx,const std::vector<double>& data,
183 bool replace=true);
184 bool addDataBlock(const std::vector<double>& data);
185
186 // /*! @brief Binned scalar data model
187 // *
188 // * @param[in] lmin minimum
189 // */
190 // void setBinnedData(double lmin,double lmax,double data);
191
193 static FeatureType featureType(const std::string& typeTag);
195 static FeatureType featureType();
197 static const std::string& featureTag(FeatureType type);
199 static const std::string& featureTag();
200
202 unsigned int buildFeatureStructure();
203
204private:
205
206 typedef std::pair<size_t,size_t> index_t;
207
208 // enum FeatureStructure
209 // { SCALAR = 0x1000,
210 // SCALAR_BINNED_SPARSE = 0x1001,
211 // SCALAR_BINNED_CONT = 0x1002,
212 // VECTOR = 0x0100,
213 // VECTOR_BINNED_SPARSE = 0x0101,
214 // VECTOR_BINNED_CONT = 0x0102
215 // };
216 //
217 // b00000000000000000000000001111111 = 0x007f (0...127) N_datawords
218 // b00000000000000000011111110000000 = 0x03f8 (0...127) N_datablocks
219 // b0000000000000000________________ = 16 bits
220 //
221
225 std::string m_tag;
227 unsigned int m_dataWords;
229 unsigned int m_dataBlocks;
231 unsigned int m_featureStructure;
233 std::vector<double> m_dataList;
234
240
242 static const std::map<FeatureType,std::string> m_featureTags;
243
245 void setFeatureStructure(bool updateCache=false);
246
248 bool insertDataBlock(size_t startIdx,size_t endIdx,
249 const std::vector<double>& data);
250 bool addDataBlock(size_t startIdx,size_t endIdx,const std::vector<double>&
251 data);
252
254 bool indexRange(size_t startIdx,index_t& idx);
255};
256
268// Three simple structural patterns are provided by
269// * the data object, for convenience:
270// *
271// * - type <tt>ETDENSITY_JETAREA</tt> implied structure type <tt>SCALAR</tt>
272// * - stores one number/event (global event transverse energy density
273// * - uses @c m_data cache, @c m_dataList is empty
274// * - type <tt>ETDENSITY_JETAREA_ETA</tt> implied structure
275// * <tt>SCALAR_BINNED</tt>
276// * - type <tt>ETDENSITY_ETA_WINDOWS</tt> implied structure
277// * <tt>FUNCTION_PARAMETERS</tt>
278// */
279
280inline const std::string& EventFeature::tag() const
281{ return m_tag; }
282
285
286inline unsigned int EventFeature::featureStructure() const
287{ return m_featureStructure; }
288
289inline const std::vector<double>& EventFeature::dataList() const
290{ return m_dataList; }
291
292inline std::vector<double>& EventFeature::dataList()
293{ return m_dataList; }
294
297
298inline void EventFeature::setTag(const std::string& tag)
299{ m_tag = tag; }
300
301inline void EventFeature::setDataList(const std::vector<double>& data)
302{
303 m_dataList.resize(data.size());
304 std::copy(data.begin(),data.end(),m_dataList.begin());
305 this->setFeatureStructure();
306}
307
308inline size_t EventFeature::numberDataWords() const
309{ return m_dataWords; }
310
313#endif
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Basic container for event feature data.
std::string m_tag
Internal cache for feature tag.
unsigned int buildFeatureStructure()
Build compressed feature structure.
void setType(FeatureType type)
Set feature type.
void setNumberDataWords(size_t nWords)
Set number of data words per block.
FeatureStructureMask
Feature structure descriptors.
static FeatureType featureType()
Default feature type.
FeatureType type() const
Retrieve feature type.
std::vector< double > m_dataList
Internal cache for vector data.
bool setDataBlock(size_t blockIdx, const std::vector< double > &data, bool replace=true)
Set one data block.
unsigned int featureStructure() const
Retrieve data structure descriptor.
EventFeature & operator=(const EventFeature &feature)
Assignment operator.
static const std::map< FeatureType, std::string > m_featureTags
Lookup for feature type and tag matches.
size_t numberDataBlocks()
Retrieve number of data blocks.
unsigned int m_dataBlocks
Internal cache for data structure descriptor (number of blocks)
void setNumberDataBlocks(size_t nBlocks)
Set number of blocks.
virtual ~EventFeature()
Destructor.
static const std::string & featureTag()
Default feature tag.
FeatureType m_type
Internal cache for feature type.
unsigned int m_dataWords
Internal cache data structure description (words per block)
bool addDataBlock(const std::vector< double > &data)
@ 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
void setFeatureStructure(bool updateCache=false)
Set/update feature structure.
void setTag(const std::string &tag)
Set feature tag.
bool dataBlock(size_t blockIdx, std::vector< double > &data)
Return one datablock.
size_t numberDataWords() const
Retrieve number of words in data block.
const std::vector< double > & dataList() const
Retrieve reference to vector store.
bool indexRange(size_t startIdx, index_t &idx)
bool insertDataBlock(size_t startIdx, size_t endIdx, const std::vector< double > &data)
void setDataList(const std::vector< double > &data)
Set vector data store.
std::pair< size_t, size_t > index_t
bool m_structureFixed
Control flag for setting number of data words.
unsigned int m_featureStructure
Internal cache for compressed data structure descriptor.
const std::string & tag() const
Retrieve feature tag.
EventFeature()
Default constructor.
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310