27#ifndef TRTCONDITIONSDATA_MULTCHANNELCONTAINERDEFAULT_H
28#define TRTCONDITIONSDATA_MULTCHANNELCONTAINERDEFAULT_H
33#include "GaudiKernel/MsgStream.h"
43 template <
class DaughterContainer>
80 const typename DaughterContainer::value_type&
get(
const ExpandedIdentifier&
id ,
size_t& resolvelevel )
const ;
83 typedef std::pair< const DaughterContainer*, const typename DaughterContainer::value_type*>
ContainerWithValue ;
112 const typename DaughterContainer::value_type&
dummyVal()
const;
121 template <
class DaughterContainer>
122 inline const typename DaughterContainer::value_type&
125 static typename DaughterContainer::value_type
dummyVal;
129 template <
class DaughterContainer>
135template <
class DaughterContainer>
142 for( ; rhsit != rhs.
end(); ++rhsit, ++ rhschanit) {
143 DaughterContainer* lhscontainer =
findContainer( *rhschanit ) ;
144 *lhscontainer = **rhsit ;
150 template <
class DaughterContainer>
160 template <
class DaughterContainer>
168 template <
class DaughterContainer>
176 template <
class DaughterContainer>
182 log << MSG::WARNING <<
"Sorry: cannot store containers at BARREL_EC granularity" <<
endmsg ;
188 template <
class DaughterContainer>
192 if(this->
size()==0) {
193 this->
push_back(
new DaughterContainer() ) ;
198 auto chanindex = std::distance(this->
chan_begin(),chanit) ;
201 this->
push_back(
new DaughterContainer() ) ;
203 chanindex = this->
size()-1 ;
207 if (chanindex < 0 or chanindex >= std::ssize(*
this)){
208 throw std::out_of_range(
"MultiChanContainer::findContainer chanindex out of range");
214 template <
class DaughterContainer>
222 template <
class DaughterContainer>
230 log << MSG::WARNING <<
"Sorry: cannot store containers at BARREL_EC granularity" <<
endmsg;
236 template <
class DaughterContainer>
237 inline const typename DaughterContainer::value_type&
243 const typename DaughterContainer::value_type&
rc =
container->get(
id ) ;
244 if( DaughterContainer::trait_type::isvalid(
rc) )
return rc ;
248 if ( this->
size() == 0 ) {
251 char* tmp = abi::__cxa_demangle(
typeid(
this).name(),0,&len,&s);
252 std::string
error = std::string(tmp) + std::string(
" is empty!!");
253 throw std::runtime_error(
error );
255 return this->
front()->get() ;
259 template <
class DaughterContainer>
260 inline const typename DaughterContainer::value_type&
266 const typename DaughterContainer::value_type&
rc =
container->get(
id , resolvelevel) ;
267 if( DaughterContainer::trait_type::isvalid(
rc) )
return rc ;
271 if ( this->
size() == 0 ) {
274 char* tmp = abi::__cxa_demangle(
typeid(
this).name(),0,&len,&s);
275 std::string
error = std::string(tmp) + std::string(
" is empty!!");
276 throw std::runtime_error(
error );
279 return this->
front()->get(
id,resolvelevel) ;
283 template <
class DaughterContainer>
290 const typename DaughterContainer::value_type& value =
container->get(
id ) ;
295 if ( this->
size() == 0 ) {
298 char* tmp = abi::__cxa_demangle(
typeid(
this).name(),0,&len,&s);
299 std::string
error = std::string(tmp) + std::string(
" is empty!!");
300 throw std::runtime_error(
error );
306 template <
class DaughterContainer>
310 it != this->
end(); ++it) (*it)->clear() ;
314 template <
class DaughterContainer>
318 it != this->
end(); ++it) total += (*it)->footprint() ;
323 template <
class DaughterContainer>
326 it != this->
end(); ++it) (*it)->crunch() ;
330 template <
class DaughterContainer>
334 it != this->
end(); ++it)
rc += (*it)->numObjects() ;
339 template <
class DaughterContainer>
343 for( ; dauit != this->
end(); ++dauit, ++chanit) {
345 typename DaughterContainer::FlatContainer newentries ;
346 (*dauit)->getall(newentries) ;
348 if( dauit == this->
begin() ) {
350 for(
typename DaughterContainer::FlatContainer::iterator it = newentries.begin() ; it!= newentries.end(); ++it)
353 for(
typename DaughterContainer::FlatContainer::iterator it = newentries.begin() ; it!= newentries.end(); ++it) {
358 entries.insert(
entries.end(), newentries.begin(), newentries.end() ) ;
363 template <
class DaughterContainer>
367 for( ; dauit != this->
end(); ++dauit, ++chanit) {
368 std::cout <<
"Now printing channel " << *chanit <<
" layer/becindex: " <<
layerwheelindex(*chanit) <<
" " <<
barrelecindex(*chanit) << std::endl ;
375 template <
class DaughterContainer>
381 log << MSG::ERROR <<
" first channel id is not defaults channel id!" <<
endmsg ;
386 const size_t maxchanid= maxchan==this->
chan_end() ? 0 : *maxchan;
392 auto dauit = this->
begin() ;
393 for(
auto chanit = this->
chan_begin();chanit != this->
chan_end(); ++chanit, ++dauit ) {
396 return StatusCode::SUCCESS;
This file defines the template class used to register the tokens of T* in a COOL multchannel folder.
'Nested' template container for storing TRT conditions data.
ChanVec::const_iterator chan_const_iterator
chan_const_iterator chan_end() const
chan_const_iterator chan_begin() const
Access to Channel numbers via iterators.
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
const DaughterContainer * operator[](size_type n) const
value_type push_back(value_type pElem)
DataModel_detail::iterator< DataVector > iterator
Standard iterator.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const DaughterContainer * front() const
size_type size() const noexcept
Identifier for TRT detector elements in the conditions code.
Class for accessing NestedContainers via channels in a CondMultChanCollection.
void set(const ExpandedIdentifier &id, const typename DaughterContainer::value_type &t)
set a value
static const size_t m_defaultschannelid
now need various forwarding calls for CondMultChanCollection functionality
std::vector< const DaughterContainer * > m_channelmap
cached table for fast access from channel to layercontainer
MultChanContainer()
constructor.
MultChanContainer & operator=(const MultChanContainer &rhs)
DaughterContainer * findContainer(const ExpandedIdentifier &id)
find a layercontainer from an identifier.
void print() const
dump to standard output
size_t numObjects() const
total number of valid calibration objects
const DaughterContainer * getContainer(size_t chanid) const
get a layercontainer from a channel id.
size_t channelId(const ExpandedIdentifier &x) const
calculate the channel for a given TRT identifier
size_t barrelecindex(size_t channelid) const
calculate the barrel-ec index from a channel id.
size_t layerwheelindex(size_t channelid) const
calculate layer or wheel index from a channel id
void clear()
clear all layercontainers
const DaughterContainer::value_type & dummyVal() const
dummy value to return when DaughterContainer is empty
const DaughterContainer::value_type & get(const ExpandedIdentifier &id) const
get a value
void getall(typename DaughterContainer::FlatContainer &entries) const
get a flat vector with all values.
std::pair< const DaughterContainer *, const typename DaughterContainer::value_type * > ContainerWithValue
get a value with the corresponding container.
void crunch()
crunch the layercontainers.
size_t footprint() const
return the memory allocated by the layercontainers.
ContainerWithValue getWithContainer(const ExpandedIdentifier &id) const
for retrieving t0 values, we need also the container to 'unpack' the t0
StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
bool add(const std::string &hname, TKey *tobj)
singleton-like access to IMessageSvc via open function and helper
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
IMessageSvc * getMessageSvc(bool quiet=false)