8#ifndef LARRAWCONDITIONS_LARCONDITIONSCONTAINERDB_H
9#define LARRAWCONDITIONS_LARCONDITIONSCONTAINERDB_H
43#include <unordered_map>
62 typedef typename ConditionsMap::size_type
size_type;
70 template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
77 MAP_ITERATOR febendit,
81 MAP_ITERATOR febendit,
122 void set(
const FebId id,
const int channel,
const T& payload);
232 if(febIds.size()==0)
return end(onlineHelper);
235 for (
FebId id : febIds) {
239 if( it2 ==
m_febMap.end())
return end(onlineHelper);
242 it2->second->begin(),
260 if(febIds.size()==0)
return end(onlineHelper);
263 for (
FebId id : febIds) {
267 if( it2 ==
m_febMap.end())
return end(onlineHelper);
270 it2->second->begin(),
292 last_feb_it->second->end(),
312 last_feb_it->second->end(),
320#define ITERATORT iteratorT<MAP_ITERATOR, CHAN_ITERATOR, POINTER, REFERENCE>
323template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
333template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
337 CHAN_ITERATOR chanit,
338 MAP_ITERATOR febendit,
342 m_lastFebIt(febendit),
343 m_onlineHelper(onlineHelper),
348template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
352 CHAN_ITERATOR chanit,
353 MAP_ITERATOR febendit,
355 const FebIdVec& febIds)
359 m_lastFebIt(febendit),
360 m_onlineHelper(onlineHelper),
361 m_febIds(febIds.size()),
365 MAP_ITERATOR lastFeb = m_lastFebIt;
373 if (febIds.size() && m_febIt != lastFeb) {
374 typename FebIdVec::const_iterator it = febIds.begin();
375 typename FebIdVec::const_iterator last = febIds.end();
376 std::set<FebId> febIdsSet;
377 for (; it != last; ++it) febIdsSet.insert(*it);
378 typename std::set<FebId>::const_iterator itSet = febIdsSet.begin();
379 typename std::set<FebId>::const_iterator lastSet = febIdsSet.end();
380 for (unsigned int i = 0; itSet != lastSet; ++itSet, ++i) m_febIds[i] = (*itSet);
383 m_febIdsIndex = std::lower_bound(m_febIds.begin(), m_febIds.end(), m_febIt->first)
389 while (m_febIt != lastFeb && m_febIdsIndex < m_febIds.size() &&
390 m_febIds[m_febIdsIndex] != m_febIt->first) {
393 if (m_febIt->first < m_febIds[m_febIdsIndex]) {
402 if (m_febIt == lastFeb || m_febIdsIndex == m_febIds.size()) {
404 m_channelIt = m_lastFebIt->second->end();
405 m_febIt = m_lastFebIt;
408 if (m_febIds[m_febIdsIndex] != m_febIt->first) {
409 std::cout <<
"LArConditionsContainerDB<T>::iteratorT constructor - ERROR: NO MATCH FOUND"
417template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
421{
return *m_channelIt; }
424template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
429 auto&
ref = *m_channelIt;
434template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
442 if (m_channelIt == m_febIt->second->end() && m_febIt != m_lastFebIt) {
448 if (m_febIds.size()) {
450 MAP_ITERATOR lastFeb = m_lastFebIt;
457 while (m_febIt != lastFeb && m_febIdsIndex < m_febIds.size() &&
458 m_febIds[m_febIdsIndex] != m_febIt->first) {
461 if (m_febIt->first < m_febIds[m_febIdsIndex]) {
469 if (m_febIt == lastFeb || m_febIdsIndex == m_febIds.size()) {
471 m_channelIt = m_lastFebIt->second->end();
472 m_febIt = m_lastFebIt;
477 if (m_febIds[m_febIdsIndex] != m_febIt->first) {
478 std::cout <<
"LArConditionsContainerDB<T>::iteratorT constructor - ERROR: NO MATCH FOUND"
486 m_channelIt = m_febIt->second->begin();
492template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
497 iteratorT
tmp = *
this;
503template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
507 (
const iteratorT&
a)
const
508{
return (m_channelIt==
a.m_channelIt) && (m_febIt==
a.m_febIt); }
511template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
515 (
const iteratorT&
a)
const
516{
return !(*
this ==
a); }
519template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
523 return m_febIt->first;
527template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
531 return (m_channelIt - m_febIt->second->begin());
535template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
544template <
class MAP_ITERATOR,
class CHAN_ITERATOR,
class POINTER,
class REFERENCE>
550 if (m_onlineHelper) {
551 int chan = m_channelIt - m_febIt->second->begin();
552 return (m_onlineHelper->channel_Id(febId(), chan));
567 typename ConditionsHashMap::iterator it =
m_febHashMap.find (febId);
570 std::cout <<
"LArConditionsContainerDB<T>::set ERROR could not find FEB ID "
571 << febId << std::endl;
576 (*(it->second))[channel] = payload;
592 typename ConditionsHashMap::const_iterator it =
m_febHashMap.find (febId);
600 if (channel <
static_cast<int>(
vec.size())) {
613 typename ConditionsHashMap::iterator it =
m_febHashMap.find (febId);
615 throw std::runtime_error (
"Unknown FEB");
662 for (
const auto& pp : p->m_febMap) {
const boost::regex ref(r_ef)
std::vector< size_t > vec
This file defines the template class used for I/O of conditions data.
Declaration of const iterator.
HWIdentifier channelId() const
const LArOnlineID_Base * m_onlineHelper
bool operator==(const iteratorT &a) const
HWIdentifier febId() const
REFERENCE operator*() const
bool operator!=(const iteratorT &a) const
iteratorT(MAP_ITERATOR febit, CHAN_ITERATOR chanit, MAP_ITERATOR febendit, const LArOnlineID_Base *onlineHelper)
POINTER operator->() const
unsigned int m_febIdsIndex
iteratorT operator++(int)
ConditionsMapIterator m_febIt
ConditionsMapIterator m_lastFebIt
iteratorT(MAP_ITERATOR febit, CHAN_ITERATOR chanit, MAP_ITERATOR febendit, const LArOnlineID_Base *onlineHelper, const FebIdVec &febIds)
LArConditionsContainerDB template class Author: Walter Lampl Initial Version: April,...
std::map< FebId, ChannelVectorPointer > ConditionsMap
const_iterator end(const LArOnlineID_Base *onlineHelper) const
void erase(FebId id)
erase element for this FebId
iteratorT< ConditionsMapIterator, ChannelIt, Pointer, Reference > iterator
void set(const FebId id, const int channel, const T &payload)
Setter.
ConditionsMap::iterator ConditionsMapIterator
Traits::ChannelVector ChannelVector
Traits::ConstChannelVector ConstChannelVector
size_type size() const
Size of map.
Traits::ChannelVectorPointer ChannelVectorPointer
Traits::ConstReference ConstReference
LArConditionsSubsetTraits< T > Traits
Reference getNonConst(const FebId id, const int channel)
non-const get function (might extend FEB map)
ChannelVector::const_iterator ConstChannelIt
void add(const LArConditionsContainerDB< T > *p)
const ConditionsMap& getConditionsMap()const { return m_febMap ;} ;
LArConditionsContainerDB(unsigned int gain=0)
Constructor with gain.
std::unordered_map< FebId, ChannelVectorPointer > ConditionsHashMap
ConstReference get(const FebId id, const int channel) const
Getter.
Traits::ConstPointer ConstPointer
std::vector< FebId > FebIdVec
iteratorT< ConstConditionsMapIterator, ConstChannelIt, ConstPointer, ConstReference > const_iterator
void setGain(int g)
set gain
ConditionsHashMap m_febHashMap
bool exist(FebId id) const
Do conditions for FebId?
int getGain() const
access to gain
const_iterator begin(const LArOnlineID_Base *onlineHelper) const
Iterator over all channels.
ConditionsMap::const_iterator ConstConditionsMapIterator
Traits::Reference Reference
ChannelVector::iterator ChannelIt
ConditionsMap::size_type size_type
const const_iterator m_dummyConstIt
Traits class giving the types to use for the objects contained within the subset.
std::vector< T > ChannelVector
const std::vector< T > ConstChannelVector
ChannelVector * ChannelVectorPointer
Helper for the Liquid Argon Calorimeter cell identifiers.
TGCHBChip operator++(TGCHBChip &rs, int)