ATLAS Offline Software
Classes | Public Types | Public Member Functions | Protected Attributes | Private Attributes | List of all members
LArConditionsContainerDB< T > Class Template Reference

LArConditionsContainerDB template class Author: Walter Lampl Initial Version: April, 22nd 2005. More...

#include <LArConditionsContainerDB.h>

Collaboration diagram for LArConditionsContainerDB< T >:

Classes

class  iteratorT
 Declaration of const iterator. More...
 

Public Types

typedef LArConditionsSubsetTraits< T > Traits
 
typedef Traits::FebId FebId
 
typedef Traits::ChannelVector ChannelVector
 
typedef Traits::ConstChannelVector ConstChannelVector
 
typedef Traits::ChannelVectorPointer ChannelVectorPointer
 
typedef std::map< FebId, ChannelVectorPointerConditionsMap
 
typedef std::unordered_map< FebId, ChannelVectorPointerConditionsHashMap
 
typedef ChannelVector::const_iterator ConstChannelIt
 
typedef ChannelVector::iterator ChannelIt
 
typedef ConditionsMap::const_iterator ConstConditionsMapIterator
 
typedef ConditionsMap::iterator ConditionsMapIterator
 
typedef ConditionsMap::size_type size_type
 
typedef std::vector< FebIdFebIdVec
 
typedef Traits::Reference Reference
 
typedef Traits::ConstReference ConstReference
 
typedef Traits::Pointer Pointer
 
typedef Traits::ConstPointer ConstPointer
 
typedef iteratorT< ConditionsMapIterator, ChannelIt, Pointer, Referenceiterator
 
typedef iteratorT< ConstConditionsMapIterator, ConstChannelIt, ConstPointer, ConstReferenceconst_iterator
 

Public Member Functions

 LArConditionsContainerDB (unsigned int gain=0)
 Constructor with gain. More...
 
void set (const FebId id, const int channel, const T &payload)
 Setter. More...
 
ConstReference get (const FebId id, const int channel) const
 Getter. More...
 
Reference getNonConst (const FebId id, const int channel)
 non-const get function (might extend FEB map) More...
 
bool exist (FebId id) const
 Do conditions for FebId? Used by writers to check whether add is needed. More...
 
const_iterator begin (const LArOnlineID_Base *onlineHelper) const
 Iterator over all channels. More...
 
const_iterator end (const LArOnlineID_Base *onlineHelper) const
 
iterator begin (const LArOnlineID_Base *onlineHelper)
 
iterator end (const LArOnlineID_Base *onlineHelper)
 
const_iterator begin (const LArOnlineID_Base *onlineHelper, const FebIdVec &febIds) const
 Iterator over all channels of selected FEBs. More...
 
iterator begin (const LArOnlineID_Base *onlineHelper, const FebIdVec &febIds)
 
size_type size () const
 Size of map. More...
 
int getGain () const
 access to gain More...
 
void setGain (int g)
 set gain More...
 
void add (const LArConditionsContainerDB< T > *p)
 const ConditionsMap& getConditionsMap()const { return m_febMap ;} ; More...
 
void add (FebId id, ChannelVectorPointer channelVec)
 add pointer to vector of (febid/channel vector) More...
 
void erase (FebId id)
 erase element for this FebId More...
 

Protected Attributes

ConditionsMap m_febMap
 
ConditionsHashMap m_febHashMap
 
unsigned int m_gain
 

Private Attributes

const iterator m_dummyIt
 
const const_iterator m_dummyConstIt
 

Detailed Description

template<class T>
class LArConditionsContainerDB< T >

LArConditionsContainerDB template class Author: Walter Lampl Initial Version: April, 22nd 2005.

Container class to store any kind of data object that is organized by FEB and FEB-channel number.

The data object stored in this container has to have a sensible default constructor. A default instance is returned by Get-function if the requested channel is not known. Furthermore, the data object must have a operator= because this operator is used by the set function.

About the iterator: The iterator-class holds internally a iterator over the FEB map and a iterator over the channels inside this FEB as well as an interator pointing to the last feb (NOT the end()!). begin() points to the first channel of the first FEB, end() to the 129th channel of the last FEB. The operator++ jumps form a last channel of FEB n to the first channel of FEB n+1 except we are already at the last FEB. The operator-- jumps from the first channel of FEB n to the last one of FEB n-1. It will try to do this even if FEB n is the first one and thus cause a segfault.

Definition at line 47 of file LArConditionsContainerDB.h.

Member Typedef Documentation

◆ ChannelIt

template<class T >
typedef ChannelVector::iterator LArConditionsContainerDB< T >::ChannelIt

Definition at line 59 of file LArConditionsContainerDB.h.

◆ ChannelVector

Definition at line 53 of file LArConditionsContainerDB.h.

◆ ChannelVectorPointer

Definition at line 55 of file LArConditionsContainerDB.h.

◆ ConditionsHashMap

template<class T >
typedef std::unordered_map<FebId, ChannelVectorPointer > LArConditionsContainerDB< T >::ConditionsHashMap

Definition at line 57 of file LArConditionsContainerDB.h.

◆ ConditionsMap

template<class T >
typedef std::map<FebId, ChannelVectorPointer > LArConditionsContainerDB< T >::ConditionsMap

Definition at line 56 of file LArConditionsContainerDB.h.

◆ ConditionsMapIterator

template<class T >
typedef ConditionsMap::iterator LArConditionsContainerDB< T >::ConditionsMapIterator

Definition at line 61 of file LArConditionsContainerDB.h.

◆ const_iterator

Definition at line 116 of file LArConditionsContainerDB.h.

◆ ConstChannelIt

template<class T >
typedef ChannelVector::const_iterator LArConditionsContainerDB< T >::ConstChannelIt

Definition at line 58 of file LArConditionsContainerDB.h.

◆ ConstChannelVector

Definition at line 54 of file LArConditionsContainerDB.h.

◆ ConstConditionsMapIterator

template<class T >
typedef ConditionsMap::const_iterator LArConditionsContainerDB< T >::ConstConditionsMapIterator

Definition at line 60 of file LArConditionsContainerDB.h.

◆ ConstPointer

Definition at line 67 of file LArConditionsContainerDB.h.

◆ ConstReference

Definition at line 65 of file LArConditionsContainerDB.h.

◆ FebId

template<class T >
typedef Traits::FebId LArConditionsContainerDB< T >::FebId

Definition at line 52 of file LArConditionsContainerDB.h.

◆ FebIdVec

template<class T >
typedef std::vector<FebId> LArConditionsContainerDB< T >::FebIdVec

Definition at line 63 of file LArConditionsContainerDB.h.

◆ iterator

Definition at line 111 of file LArConditionsContainerDB.h.

◆ Pointer

template<class T >
typedef Traits::Pointer LArConditionsContainerDB< T >::Pointer

Definition at line 66 of file LArConditionsContainerDB.h.

◆ Reference

template<class T >
typedef Traits::Reference LArConditionsContainerDB< T >::Reference

Definition at line 64 of file LArConditionsContainerDB.h.

◆ size_type

template<class T >
typedef ConditionsMap::size_type LArConditionsContainerDB< T >::size_type

Definition at line 62 of file LArConditionsContainerDB.h.

◆ Traits

template<class T >
typedef LArConditionsSubsetTraits<T> LArConditionsContainerDB< T >::Traits

Definition at line 51 of file LArConditionsContainerDB.h.

Constructor & Destructor Documentation

◆ LArConditionsContainerDB()

template<class T >
LArConditionsContainerDB< T >::LArConditionsContainerDB ( unsigned int  gain = 0)
inline

Constructor with gain.

Definition at line 186 of file LArConditionsContainerDB.h.

187  :
188  m_gain(gain)
189 {}

Member Function Documentation

◆ add() [1/2]

template<class T >
void LArConditionsContainerDB< T >::add ( const LArConditionsContainerDB< T > *  p)
inline

const ConditionsMap& getConditionsMap()const { return m_febMap ;} ;

Definition at line 657 of file LArConditionsContainerDB.h.

658 {
659  // copy the data to this container. FEB by FEB.
660  // if FEB id exist, the old data will be overwritten.
661 
662  for (const auto& pp : p->m_febMap) {
663  m_febMap[pp.first] = pp.second;
664  m_febHashMap[pp.first] = pp.second;
665  }
666 }

◆ add() [2/2]

template<class T >
void LArConditionsContainerDB< T >::add ( FebId  id,
ChannelVectorPointer  channelVec 
)
inline

add pointer to vector of (febid/channel vector)

Definition at line 671 of file LArConditionsContainerDB.h.

672 {
673  m_febMap[id] = channelVec;
674  m_febHashMap[id] = channelVec;
675 }

◆ begin() [1/4]

template<class T >
LArConditionsContainerDB< T >::iterator LArConditionsContainerDB< T >::begin ( const LArOnlineID_Base onlineHelper)
inline

Definition at line 210 of file LArConditionsContainerDB.h.

211 {
212  if (m_febMap.size()==0) { //no elements yet, begin() and end() have to be identical
213  return m_dummyIt;
214  }
215  else {
216  return iterator(m_febMap.begin(),
217  m_febMap.begin()->second->begin(),
218  m_febMap.end(),
219  onlineHelper); }
220 }

◆ begin() [2/4]

template<class T >
LArConditionsContainerDB< T >::const_iterator LArConditionsContainerDB< T >::begin ( const LArOnlineID_Base onlineHelper) const
inline

Iterator over all channels.

Definition at line 195 of file LArConditionsContainerDB.h.

196 {
197  if (m_febMap.size()==0) { //no elements yet, begin() and end() have to be identical
198  return m_dummyConstIt;
199  }
200  else {
201  return const_iterator(m_febMap.begin(),
202  m_febMap.begin()->second->begin(),
203  m_febMap.end(),
204  onlineHelper); }
205 }

◆ begin() [3/4]

template<class T >
LArConditionsContainerDB< T >::iterator LArConditionsContainerDB< T >::begin ( const LArOnlineID_Base onlineHelper,
const FebIdVec febIds 
)
inline

Definition at line 253 of file LArConditionsContainerDB.h.

255 {
256  if (m_febMap.size()==0) { //no elements yet, begin() and end() have to be identical
257  return m_dummyIt;
258  }
259  else {
260  if(febIds.size()==0) return end(onlineHelper);
261 
262  ConditionsMapIterator it2 = m_febMap.end() ;
263  for (FebId id : febIds) {
264  it2 = m_febMap.find(id);
265  if( it2 != m_febMap.end()) break;
266  }
267  if( it2 == m_febMap.end()) return end(onlineHelper);
268 
269  return iterator( it2,
270  it2->second->begin(),
271  m_febMap.end(),
272  onlineHelper,
273  febIds);
274  }
275 }

◆ begin() [4/4]

template<class T >
LArConditionsContainerDB< T >::const_iterator LArConditionsContainerDB< T >::begin ( const LArOnlineID_Base onlineHelper,
const FebIdVec febIds 
) const
inline

Iterator over all channels of selected FEBs.

Definition at line 225 of file LArConditionsContainerDB.h.

227 {
228  if (m_febMap.size()==0) { //no elements yet, begin() and end() have to be identical
229  return m_dummyConstIt;
230  }
231  else {
232  if(febIds.size()==0) return end(onlineHelper);
233 
235  for (FebId id : febIds) {
236  it2 = m_febMap.find(id);
237  if( it2 != m_febMap.end()) break;
238  }
239  if( it2 == m_febMap.end()) return end(onlineHelper);
240 
241  return const_iterator( it2,
242  it2->second->begin(),
243  m_febMap.end(),
244  onlineHelper,
245  febIds);
246  }
247 }

◆ end() [1/2]

template<class T >
LArConditionsContainerDB< T >::iterator LArConditionsContainerDB< T >::end ( const LArOnlineID_Base onlineHelper)
inline

Definition at line 302 of file LArConditionsContainerDB.h.

303 {
304  if (m_febMap.size()==0) {
305  return m_dummyIt;
306  }
307  else {
308  ConditionsMapIterator feb_end_it=m_febMap.end();
309  ConditionsMapIterator last_feb_it=feb_end_it;
310  last_feb_it--;
311  return iterator(last_feb_it,
312  last_feb_it->second->end(),
313  feb_end_it,
314  onlineHelper);
315  }
316 }

◆ end() [2/2]

template<class T >
LArConditionsContainerDB< T >::const_iterator LArConditionsContainerDB< T >::end ( const LArOnlineID_Base onlineHelper) const
inline

Definition at line 282 of file LArConditionsContainerDB.h.

283 {
284  if (m_febMap.size()==0) {
285  return m_dummyConstIt;
286  }
287  else {
288  ConstConditionsMapIterator feb_end_it=m_febMap.end();
289  ConstConditionsMapIterator last_feb_it=feb_end_it;
290  last_feb_it--;
291  return const_iterator(last_feb_it,
292  last_feb_it->second->end(),
293  feb_end_it,
294  onlineHelper);
295  }
296 }

◆ erase()

template<class T >
void LArConditionsContainerDB< T >::erase ( FebId  id)
inline

erase element for this FebId

Definition at line 680 of file LArConditionsContainerDB.h.

681 {
682  m_febMap.erase(id);
683  m_febHashMap.erase(id);
684 }

◆ exist()

template<class T >
bool LArConditionsContainerDB< T >::exist ( FebId  id) const
inline

Do conditions for FebId? Used by writers to check whether add is needed.


Definition at line 626 of file LArConditionsContainerDB.h.

627 {
628  return m_febHashMap.find (id) != m_febHashMap.end();
629 }

◆ get()

template<class T >
LArConditionsContainerDB< T >::ConstReference LArConditionsContainerDB< T >::get ( const FebId  id,
const int  channel 
) const
inline

Getter.

Definition at line 583 of file LArConditionsContainerDB.h.

584 {
585  // The get/set methods used to cache the iterator in m_febMap where the
586  // last access was found. That, however, is not at all thread-safe
587  // (and was in fact observed to lead to incorrect results in MT jobs).
588  // We need to get rid of the caching, but we'll also introduce
589  // m_febHashMap to try to reduce the lookup overhead.
590  // If this turns out to be a hot spot, then the iterator could
591  // be returned to the caller via a cookie.
592  typename ConditionsHashMap::const_iterator it = m_febHashMap.find (febId);
593  if (it == m_febHashMap.end()) {
594  // Unknown FEB
595  return Traits::empty();
596  }
597 
598  const ConstChannelVector& vec = *it->second;
599  // First check the size - channel vec may be empty
600  if (channel < static_cast<int>(vec.size())) {
601  return vec[channel];
602  }
603  else {
604  return Traits::empty();
605  }
606 }

◆ getGain()

template<class T >
int LArConditionsContainerDB< T >::getGain
inline

access to gain

Definition at line 649 of file LArConditionsContainerDB.h.

650 {
651  return m_gain;
652 }

◆ getNonConst()

template<class T >
LArConditionsContainerDB< T >::Reference LArConditionsContainerDB< T >::getNonConst ( const FebId  id,
const int  channel 
)
inline

non-const get function (might extend FEB map)

Definition at line 611 of file LArConditionsContainerDB.h.

612 {
613  typename ConditionsHashMap::iterator it = m_febHashMap.find (febId);
614  if (it == m_febHashMap.end()) {
615  throw std::runtime_error ("Unknown FEB");
616  }
617 
618  ChannelVector& vec = *it->second;
619  // Note: channel vec should always be full for non-const access
620  return vec[channel];
621 }

◆ set()

template<class T >
void LArConditionsContainerDB< T >::set ( const FebId  id,
const int  channel,
const T &  payload 
)
inline

Setter.

Definition at line 565 of file LArConditionsContainerDB.h.

566 {
567  typename ConditionsHashMap::iterator it = m_febHashMap.find (febId);
568  if (it == m_febHashMap.end()) {
569  // Should never get here
570  std::cout << "LArConditionsContainerDB<T>::set ERROR could not find FEB ID "
571  << febId << std::endl;
572  return;
573  }
574 
575  // Set payload
576  (*(it->second))[channel] = payload;
577 }

◆ setGain()

template<class T >
void LArConditionsContainerDB< T >::setGain ( int  g)
inline

set gain

Definition at line 633 of file LArConditionsContainerDB.h.

634 {
635  m_gain = g;
636  return;
637 }

◆ size()

template<class T >
LArConditionsContainerDB< T >::size_type LArConditionsContainerDB< T >::size
inline

Size of map.

Definition at line 642 of file LArConditionsContainerDB.h.

643 {
644  return (m_febMap.size());
645 }

Member Data Documentation

◆ m_dummyConstIt

template<class T >
const const_iterator LArConditionsContainerDB< T >::m_dummyConstIt
private

Definition at line 179 of file LArConditionsContainerDB.h.

◆ m_dummyIt

template<class T >
const iterator LArConditionsContainerDB< T >::m_dummyIt
private

Definition at line 178 of file LArConditionsContainerDB.h.

◆ m_febHashMap

template<class T >
ConditionsHashMap LArConditionsContainerDB< T >::m_febHashMap
protected

Definition at line 172 of file LArConditionsContainerDB.h.

◆ m_febMap

template<class T >
ConditionsMap LArConditionsContainerDB< T >::m_febMap
protected

Definition at line 171 of file LArConditionsContainerDB.h.

◆ m_gain

template<class T >
unsigned int LArConditionsContainerDB< T >::m_gain
protected

Definition at line 174 of file LArConditionsContainerDB.h.


The documentation for this class was generated from the following file:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
LArConditionsContainerDB::ChannelVector
Traits::ChannelVector ChannelVector
Definition: LArConditionsContainerDB.h:53
LArConditionsContainerDB::ConstConditionsMapIterator
ConditionsMap::const_iterator ConstConditionsMapIterator
Definition: LArConditionsContainerDB.h:60
LArConditionsContainerDB::m_febHashMap
ConditionsHashMap m_febHashMap
Definition: LArConditionsContainerDB.h:172
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
LArConditionsSubsetTraits::empty
static const T & empty()
Definition: LArConditionsSubset.h:80
LArConditionsContainerDB::end
const_iterator end(const LArOnlineID_Base *onlineHelper) const
Definition: LArConditionsContainerDB.h:282
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
skel.it
it
Definition: skel.GENtoEVGEN.py:396
LArConditionsContainerDB::m_dummyIt
const iterator m_dummyIt
Definition: LArConditionsContainerDB.h:178
LArConditionsContainerDB::m_febMap
ConditionsMap m_febMap
Definition: LArConditionsContainerDB.h:171
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
LArConditionsContainerDB::ConditionsMapIterator
ConditionsMap::iterator ConditionsMapIterator
Definition: LArConditionsContainerDB.h:61
LArConditionsContainerDB::FebId
Traits::FebId FebId
Definition: LArConditionsContainerDB.h:52
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
LArConditionsContainerDB::m_gain
unsigned int m_gain
Definition: LArConditionsContainerDB.h:174
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
LArConditionsContainerDB::iterator
iteratorT< ConditionsMapIterator, ChannelIt, Pointer, Reference > iterator
Definition: LArConditionsContainerDB.h:111
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
LArConditionsContainerDB::const_iterator
iteratorT< ConstConditionsMapIterator, ConstChannelIt, ConstPointer, ConstReference > const_iterator
Definition: LArConditionsContainerDB.h:116
LArConditionsContainerDB::ConstChannelVector
Traits::ConstChannelVector ConstChannelVector
Definition: LArConditionsContainerDB.h:54
LArConditionsContainerDB::m_dummyConstIt
const const_iterator m_dummyConstIt
Definition: LArConditionsContainerDB.h:179