ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Attributes | Friends | List of all members
JetKeyDescriptorInstance Class Reference

#include <JetKeyDescriptor.h>

Collaboration diagram for JetKeyDescriptorInstance:

Public Types

typedef std::string category_t
 
typedef std::string key_t
 
typedef std::vector< key_tkeystore_t
 
typedef std::vector< keystore_tstorelist_t
 
typedef std::vector< category_tcatlist_t
 

Public Member Functions

virtual ~JetKeyDescriptorInstance ()
 
size_t getIndex (const category_t &cat, const key_t &key, bool createIfMissing=true)
 
size_t getIndex (const category_t &cat, const key_t &key) const
 
const key_tgetKey (const category_t &cat, size_t index) const
 
const std::vector< key_t > & getKeys (const category_t &cat) const
 
const std::vector< category_t > & getCategories () const
 
bool isValid (size_t index) const
 
void printOut (MsgStream &msgStream) const
 
JetKeyDescriptorgetKeyStore ()
 

Static Public Member Functions

static JetKeyDescriptorInstanceinstance ()
 

Protected Member Functions

 JetKeyDescriptorInstance (bool create=true)
 
void createKeyStore () const
 

Protected Attributes

JetKeyDescriptorm_Stores
 
const JetKeyDescriptorm_ConstStores
 

Static Private Attributes

static const size_t m_invalid = size_t(-1)
 
static const std::string m_notFound = "unknown"
 
static const std::vector< key_tm_invalidKeys
 
static const bool m_persistified = false
 

Friends

class JetKeyDescriptor
 
class JetCollection
 
class JetKeyDescriptorCnv_p1
 
class JetCollectionCnv_p2
 
class JetCollectionCnv_p3
 
class JetCollectionCnv_p4
 
class JetCollectionCnv_p5
 
class JetCollectionCnv_p6
 

Detailed Description

Theses classes implement a mapping between string and index used by jets. they are used for jet moments, jet associations, etc... There are 2 classes :

///////////////////////////////////////////////////////

Definition at line 99 of file JetKeyDescriptor.h.

Member Typedef Documentation

◆ category_t

Definition at line 113 of file JetKeyDescriptor.h.

◆ catlist_t

Definition at line 118 of file JetKeyDescriptor.h.

◆ key_t

typedef std::string JetKeyDescriptorInstance::key_t

Definition at line 114 of file JetKeyDescriptor.h.

◆ keystore_t

Definition at line 116 of file JetKeyDescriptor.h.

◆ storelist_t

Definition at line 117 of file JetKeyDescriptor.h.

Constructor & Destructor Documentation

◆ ~JetKeyDescriptorInstance()

JetKeyDescriptorInstance::~JetKeyDescriptorInstance ( )
virtualdefault

◆ JetKeyDescriptorInstance()

JetKeyDescriptorInstance::JetKeyDescriptorInstance ( bool  create = true)
protected

Definition at line 23 of file JetKeyDescriptor.cxx.

23  :
24  m_Stores(nullptr),
25  m_ConstStores(nullptr)
26 {
27  // create a JetKeyDescriptorInstance :
28  if (create) createKeyStore();
29 }

Member Function Documentation

◆ createKeyStore()

void JetKeyDescriptorInstance::createKeyStore ( ) const
protected

Definition at line 34 of file JetKeyDescriptor.cxx.

34  {
35  if (m_ConstStores) {
36  throw std::runtime_error ("Attempt to modify const JetKeyDescriptor");
37  }
38  m_Stores = new JetKeyDescriptor();
40 }

◆ getCategories()

const std::vector< JetKeyDescriptorInstance::category_t > & JetKeyDescriptorInstance::getCategories ( ) const
inline

Definition at line 176 of file JetKeyDescriptor.h.

177 {
178  if(bool(m_ConstStores))
179  return m_ConstStores->m_catStore;
180  static const std::vector<JetKeyDescriptorInstance::category_t> v;
181  return v;
182 }

◆ getIndex() [1/2]

size_t JetKeyDescriptorInstance::getIndex ( const category_t cat,
const key_t key 
) const

Definition at line 111 of file JetKeyDescriptor.cxx.

113 {
114  if ( ! bool(m_ConstStores) ) {
115  return m_invalid;
116  }
117 
118  // first find category
119  catlist_t::const_iterator
120  fCat(std::find(m_ConstStores->m_catStore.begin(),m_ConstStores->m_catStore.end(),cat));
121  if ( fCat == m_ConstStores->m_catStore.end() )
122  return m_invalid;
123  else
124  {
125  size_t iCat = fCat - m_ConstStores->m_catStore.begin();
126 
127  if ( iCat < m_ConstStores->m_keyStore.size() ) // really impossible!
128  {
129  keystore_t::const_iterator fKey(std::find((m_ConstStores->m_keyStore[iCat]).begin(),
130  (m_ConstStores->m_keyStore[iCat]).end(),
131  key));
132  if ( fKey == (m_ConstStores->m_keyStore[iCat]).end() )
133  return m_invalid;
134  else
135  {
136  return fKey - (m_ConstStores->m_keyStore[iCat]).begin();
137  }
138  }
139  // should never be reached!
140  return m_invalid;
141  }
142 }

◆ getIndex() [2/2]

size_t JetKeyDescriptorInstance::getIndex ( const category_t cat,
const key_t key,
bool  createIfMissing = true 
)

Definition at line 47 of file JetKeyDescriptor.cxx.

50 {
51  //std::cout <<" getIndex cat="<<cat<<" key="<<key<<" has store ="<< m_Stores << " if missing="<< createIfMissing << std::endl;
52  if ( ! bool(m_ConstStores) ) {
53  if ( createIfMissing )
55  else
56  return m_invalid;
57  }
58 
59  // std::cout <<& m_Stores->m_catStore << " Cat store size="<< m_Stores->m_catStore.size() << std::endl;
60  // first find category
61  catlist_t::const_iterator
62  fCat(std::find(m_ConstStores->m_catStore.begin(),m_ConstStores->m_catStore.end(),cat));
63  if ( fCat == m_ConstStores->m_catStore.end() ) {
64  if ( createIfMissing )
65  {
66  if (!m_Stores) {
68  }
69  // cppcheck-suppress nullPointerRedundantCheck; false positive
70  m_Stores->m_catStore.push_back(cat);
71  keystore_t kStore; kStore.push_back(key);
72  // cppcheck-suppress nullPointerRedundantCheck; false positive
73  m_Stores->m_keyStore.push_back(kStore);
74  return 0;
75  }
76  else
77  return m_invalid;
78  }
79  else
80  {
81  size_t iCat = fCat - m_ConstStores->m_catStore.begin();
82 
83  if ( iCat < m_ConstStores->m_keyStore.size() ) // really impossible!
84  {
85  keystore_t::const_iterator fKey(std::find((m_ConstStores->m_keyStore[iCat]).begin(),
86  (m_ConstStores->m_keyStore[iCat]).end(),
87  key));
88  if ( fKey == (m_ConstStores->m_keyStore[iCat]).end() )
89  if ( createIfMissing )
90  {
91  if (!m_Stores) {
93  }
94  // cppcheck-suppress nullPointerRedundantCheck; false positive
95  (m_Stores->m_keyStore[iCat]).push_back(key);
96  // cppcheck-suppress nullPointerRedundantCheck; false positive
97  return (m_Stores->m_keyStore[iCat]).size()-1;
98  }
99  else
100  return m_invalid;
101  else
102  {
103  return fKey - (m_ConstStores->m_keyStore[iCat]).begin();
104  }
105  }
106  // should never be reached!
107  return m_invalid;
108  }
109 }

◆ getKey()

const JetKeyDescriptorInstance::key_t & JetKeyDescriptorInstance::getKey ( const category_t cat,
size_t  index 
) const

Definition at line 161 of file JetKeyDescriptor.cxx.

163 {
164  if ( ! bool(m_ConstStores) ) createKeyStore();
165  // find category
166  catlist_t::const_iterator fCat(std::find(m_ConstStores->m_catStore.begin(),
167  m_ConstStores->m_catStore.end(),
168  cat));
169  if ( fCat == m_ConstStores->m_catStore.end() ) return m_notFound;
170  // find key
171  size_t iCat(fCat-m_ConstStores->m_catStore.begin());
172  return index < (m_ConstStores->m_keyStore[iCat]).size()
173  ? (m_ConstStores->m_keyStore[iCat])[index]
174  : m_notFound;
175 }

◆ getKeys()

const std::vector< JetKeyDescriptorInstance::key_t > & JetKeyDescriptorInstance::getKeys ( const category_t cat) const

Definition at line 178 of file JetKeyDescriptor.cxx.

179 {
180  if ( ! bool(m_ConstStores) )
181  return m_invalidKeys;
182  catlist_t::const_iterator fCat(std::find(m_ConstStores->m_catStore.begin(),
183  m_ConstStores->m_catStore.end(),
184  cat));
185  if ( fCat != m_ConstStores->m_catStore.end() )
186  {
187  size_t aInd(fCat-m_ConstStores->m_catStore.begin());
188  return m_ConstStores->m_keyStore[aInd];
189  }
190  else
191  {
192  return m_invalidKeys;
193  }
194 }

◆ getKeyStore()

JetKeyDescriptor * JetKeyDescriptorInstance::getKeyStore ( )

Definition at line 42 of file JetKeyDescriptor.cxx.

42  {
43  if( ! bool(m_Stores) ) createKeyStore();
44  return m_Stores;
45 }

◆ instance()

static JetKeyDescriptorInstance* JetKeyDescriptorInstance::instance ( )
inlinestatic

Definition at line 123 of file JetKeyDescriptor.h.

124  {
126  return &instance;
127  }

◆ isValid()

bool JetKeyDescriptorInstance::isValid ( size_t  index) const
inline

Definition at line 170 of file JetKeyDescriptor.h.

171 {
172  return index != m_invalid;
173 }

◆ printOut()

void JetKeyDescriptorInstance::printOut ( MsgStream &  msgStream) const

Definition at line 144 of file JetKeyDescriptor.cxx.

145 {
146  if ( ! bool(m_ConstStores) ) return;
147 
148  msgStream << "Number of categories: " << m_ConstStores->m_catStore.size() << endmsg;
149  for ( size_t i=0;i<m_ConstStores->m_catStore.size();i++ )
150  {
151  msgStream << m_ConstStores->m_catStore[i] << " Number of keys: "
152  << (m_ConstStores->m_keyStore[i]).size() << endmsg;
153  for ( size_t j=0;j<(m_ConstStores->m_keyStore[i]).size();j++ )
154  {
155  msgStream << " index: " << j << " key <" << (m_ConstStores->m_keyStore[i])[j]
156  << ">" << endmsg;
157  }
158  }
159 }

Friends And Related Function Documentation

◆ JetCollection

friend class JetCollection
friend

Definition at line 102 of file JetKeyDescriptor.h.

◆ JetCollectionCnv_p2

friend class JetCollectionCnv_p2
friend

Definition at line 104 of file JetKeyDescriptor.h.

◆ JetCollectionCnv_p3

friend class JetCollectionCnv_p3
friend

Definition at line 105 of file JetKeyDescriptor.h.

◆ JetCollectionCnv_p4

friend class JetCollectionCnv_p4
friend

Definition at line 106 of file JetKeyDescriptor.h.

◆ JetCollectionCnv_p5

friend class JetCollectionCnv_p5
friend

Definition at line 107 of file JetKeyDescriptor.h.

◆ JetCollectionCnv_p6

friend class JetCollectionCnv_p6
friend

Definition at line 108 of file JetKeyDescriptor.h.

◆ JetKeyDescriptor

friend class JetKeyDescriptor
friend

Definition at line 101 of file JetKeyDescriptor.h.

◆ JetKeyDescriptorCnv_p1

friend class JetKeyDescriptorCnv_p1
friend

Definition at line 103 of file JetKeyDescriptor.h.

Member Data Documentation

◆ m_ConstStores

const JetKeyDescriptor* JetKeyDescriptorInstance::m_ConstStores
mutableprotected

Definition at line 156 of file JetKeyDescriptor.h.

◆ m_invalid

const size_t JetKeyDescriptorInstance::m_invalid = size_t(-1)
staticprivate

Definition at line 163 of file JetKeyDescriptor.h.

◆ m_invalidKeys

const std::vector< JetKeyDescriptorInstance::key_t > JetKeyDescriptorInstance::m_invalidKeys
staticprivate

Definition at line 165 of file JetKeyDescriptor.h.

◆ m_notFound

const std::string JetKeyDescriptorInstance::m_notFound = "unknown"
staticprivate

Definition at line 164 of file JetKeyDescriptor.h.

◆ m_persistified

const bool JetKeyDescriptorInstance::m_persistified = false
staticprivate

Definition at line 167 of file JetKeyDescriptor.h.

◆ m_Stores

JetKeyDescriptor* JetKeyDescriptorInstance::m_Stores
mutableprotected

Definition at line 155 of file JetKeyDescriptor.h.


The documentation for this class was generated from the following files:
JetKeyDescriptorInstance::m_Stores
JetKeyDescriptor * m_Stores
Definition: JetKeyDescriptor.h:155
JetKeyDescriptor::m_catStore
catlist_t m_catStore
Definition: JetKeyDescriptor.h:77
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
index
Definition: index.py:1
JetKeyDescriptor::m_keyStore
storelist_t m_keyStore
Definition: JetKeyDescriptor.h:75
JetKeyDescriptorInstance::m_invalid
static const size_t m_invalid
Definition: JetKeyDescriptor.h:163
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
JetKeyDescriptorInstance::instance
static JetKeyDescriptorInstance * instance()
Definition: JetKeyDescriptor.h:123
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
JetKeyDescriptorInstance::m_invalidKeys
static const std::vector< key_t > m_invalidKeys
Definition: JetKeyDescriptor.h:165
JetKeyDescriptorInstance::createKeyStore
void createKeyStore() const
Definition: JetKeyDescriptor.cxx:34
JetKeyDescriptorInstance::keystore_t
std::vector< key_t > keystore_t
Definition: JetKeyDescriptor.h:116
JetKeyDescriptorInstance::JetKeyDescriptor
friend class JetKeyDescriptor
Definition: JetKeyDescriptor.h:101
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
JetKeyDescriptorInstance::m_notFound
static const std::string m_notFound
Definition: JetKeyDescriptor.h:164
python.PyAthena.v
v
Definition: PyAthena.py:154
JetKeyDescriptorInstance
Definition: JetKeyDescriptor.h:100
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
JetKeyDescriptorInstance::m_ConstStores
const JetKeyDescriptor * m_ConstStores
Definition: JetKeyDescriptor.h:156