ATLAS Offline Software
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 {
19 public:
20 
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  };
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 
62  EventFeature();
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);
164  void setType(FeatureType type);
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 
204 private:
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 
280 inline const std::string& EventFeature::tag() const
281 { return m_tag; }
282 
284 { return m_type; }
285 
286 inline unsigned int EventFeature::featureStructure() const
287 { return m_featureStructure; }
288 
289 inline const std::vector<double>& EventFeature::dataList() const
290 { return m_dataList; }
291 
292 inline std::vector<double>& EventFeature::dataList()
293 { return m_dataList; }
294 
296 { m_type = type; }
297 
298 inline void EventFeature::setTag(const std::string& tag)
299 { m_tag = tag; }
300 
301 inline 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 
308 inline size_t EventFeature::numberDataWords() const
309 { return m_dataWords; }
310 
312 { this->setFeatureStructure(); return m_dataBlocks; }
313 #endif
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
EventFeature::m_featureTags
static const std::map< FeatureType, std::string > m_featureTags
Lookup for feature type and tag matches.
Definition: EventFeature.h:242
EventFeature::numberDataWords
size_t numberDataWords() const
Retrieve number of words in data block.
Definition: EventFeature.h:308
EventFeature::m_structureFixed
bool m_structureFixed
Control flag for setting number of data words.
Definition: EventFeature.h:239
EventFeature::ETDENSITY_ETA_WINDOWS
@ ETDENSITY_ETA_WINDOWS
density in sliding windows
Definition: EventFeature.h:28
EventFeature::m_type
FeatureType m_type
Internal cache for feature type.
Definition: EventFeature.h:223
EventFeature::numberDataBlocks
size_t numberDataBlocks()
Retrieve number of data blocks.
Definition: EventFeature.h:311
EventFeature::m_dataBlocks
unsigned int m_dataBlocks
Internal cache for data structure descriptor (number of blocks)
Definition: EventFeature.h:229
EventFeature::addDataBlock
bool addDataBlock(const std::vector< double > &data)
Definition: EventFeature.cxx:158
EventFeature::featureType
static FeatureType featureType()
Default feature type.
Definition: EventFeature.cxx:24
EventFeature
Basic container for event feature data.
Definition: EventFeature.h:18
EventFeature::DEFAULT
@ DEFAULT
Default type.
Definition: EventFeature.h:32
EventFeature::setType
void setType(FeatureType type)
Set feature type.
Definition: EventFeature.h:295
EventFeature::type
FeatureType type() const
Retrieve feature type.
Definition: EventFeature.h:283
EventFeature::buildFeatureStructure
unsigned int buildFeatureStructure()
Build compressed feature structure.
Definition: EventFeature.cxx:217
EventFeature::NDATABLOCKS
@ NDATABLOCKS
Definition: EventFeature.h:42
EventFeature::m_tag
std::string m_tag
Internal cache for feature tag.
Definition: EventFeature.h:225
EventFeature::m_featureStructure
unsigned int m_featureStructure
Internal cache for compressed data structure descriptor.
Definition: EventFeature.h:231
EventFeature::indexRange
bool indexRange(size_t startIdx, index_t &idx)
Definition: EventFeature.cxx:225
EventFeature::index_t
std::pair< size_t, size_t > index_t
Definition: EventFeature.h:206
EventFeature::UNKNOWN
@ UNKNOWN
Unknown type.
Definition: EventFeature.h:31
EventFeature::ETDENSITY_USER
@ ETDENSITY_USER
User defined density.
Definition: EventFeature.h:30
EventFeature::TAGBITS
@ TAGBITS
Definition: EventFeature.h:45
EventFeature::setNumberDataWords
void setNumberDataWords(size_t nWords)
Set number of data words per block.
Definition: EventFeature.cxx:183
EventFeature::setDataList
void setDataList(const std::vector< double > &data)
Set vector data store.
Definition: EventFeature.h:301
EventFeature::ETDENSITY_JETAREA_ETA
@ ETDENSITY_JETAREA_ETA
FastJet density, dependent
Definition: EventFeature.h:26
EventFeature::ETDENSITY
@ ETDENSITY
Definition: EventFeature.h:24
EventFeature::EventFeature
EventFeature()
Default constructor.
Definition: EventFeature.cxx:46
EventFeature::insertDataBlock
bool insertDataBlock(size_t startIdx, size_t endIdx, const std::vector< double > &data)
Definition: EventFeature.cxx:175
EventFeature::m_dataWords
unsigned int m_dataWords
Internal cache data structure description (words per block)
Definition: EventFeature.h:227
EventFeature::operator=
EventFeature & operator=(const EventFeature &feature)
Assignment operator.
Definition: EventFeature.cxx:108
EventFeature::~EventFeature
virtual ~EventFeature()
Destructor.
Definition: EventFeature.cxx:105
EventFeature::setDataBlock
bool setDataBlock(size_t blockIdx, const std::vector< double > &data, bool replace=true)
Set one data block.
Definition: EventFeature.cxx:145
EventFeature::FeatureType
FeatureType
@
Definition: EventFeature.h:24
EventFeature::tag
const std::string & tag() const
Retrieve feature tag.
Definition: EventFeature.h:280
EventFeature::featureStructure
unsigned int featureStructure() const
Retrieve data structure descriptor.
Definition: EventFeature.h:286
EventFeature::BITSHIFT
@ BITSHIFT
Definition: EventFeature.h:49
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
EventFeature::m_dataList
std::vector< double > m_dataList
Internal cache for vector data.
Definition: EventFeature.h:233
EventFeature::dataBlock
bool dataBlock(size_t blockIdx, std::vector< double > &data)
Return one datablock.
Definition: EventFeature.cxx:131
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
EventFeature::FeatureStructureMask
FeatureStructureMask
Feature structure descriptors.
Definition: EventFeature.h:39
calibdata.copy
bool copy
Definition: calibdata.py:27
EventFeature::MASKLENGTH
@ MASKLENGTH
Definition: EventFeature.h:47
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
EventFeature::setNumberDataBlocks
void setNumberDataBlocks(size_t nBlocks)
Set number of blocks.
Definition: EventFeature.cxx:194
EventFeature::ETDENSITY_JETAREA
@ ETDENSITY_JETAREA
FastJet density
Definition: EventFeature.h:25
EventFeature::featureTag
static const std::string & featureTag()
Default feature tag.
Definition: EventFeature.cxx:35
EventFeature::setFeatureStructure
void setFeatureStructure(bool updateCache=false)
Set/update feature structure.
Definition: EventFeature.cxx:204
EventFeature::dataList
const std::vector< double > & dataList() const
Retrieve reference to vector store.
Definition: EventFeature.h:289
EventFeature::NDATAWORDS
@ NDATAWORDS
Definition: EventFeature.h:39
EventFeature::setTag
void setTag(const std::string &tag)
Set feature tag.
Definition: EventFeature.h:298