27 #ifndef TRTCONDITIONSDATA_MULTCHANNELCONTAINERDEFAULT_H
28 #define TRTCONDITIONSDATA_MULTCHANNELCONTAINERDEFAULT_H
33 #include "GaudiKernel/MsgStream.h"
42 template <
class DaughterContainer>
79 const typename DaughterContainer::value_type&
get(
const ExpandedIdentifier&
id ,
size_t& resolvelevel )
const ;
82 typedef std::pair< const DaughterContainer*, const typename DaughterContainer::value_type*>
ContainerWithValue ;
111 const typename DaughterContainer::value_type&
dummyVal()
const;
120 template <
class DaughterContainer>
121 inline const typename DaughterContainer::value_type&
124 static typename DaughterContainer::value_type dummyVal;
128 template <
class DaughterContainer>
134 template <
class DaughterContainer>
141 for( ; rhsit != rhs.
end(); ++rhsit, ++ rhschanit) {
142 DaughterContainer* lhscontainer = findContainer( *rhschanit ) ;
143 *lhscontainer = **rhsit ;
149 template <
class DaughterContainer>
155 m_defaultschannelid ;
159 template <
class DaughterContainer>
163 return channelid!=m_defaultschannelid ? (channelid-1)/4 : 99 ;
167 template <
class DaughterContainer>
171 return channelid!=m_defaultschannelid ? (channelid-1)%4 : 99 ;
175 template <
class DaughterContainer>
181 log << MSG::WARNING <<
"Sorry: cannot store containers at BARREL_EC granularity" <<
endmsg ;
183 return findContainer(
channelId(
id ) ) ;
187 template <
class DaughterContainer>
191 if(this->
size()==0) {
192 this->push_back(
new DaughterContainer() ) ;
193 this->
add(m_defaultschannelid);
196 std::find( this->chan_begin(), this->chan_end(), chanid ) ;
197 size_t chanindex =
std::distance(this->chan_begin(),chanit) ;
198 if(chanit==this->chan_end()) {
200 this->push_back(
new DaughterContainer() ) ;
202 chanindex = this->
size()-1 ;
204 m_channelmap.clear() ;
210 template <
class DaughterContainer>
215 return chanid < m_channelmap.size() ? m_channelmap[chanid] : nullptr ;
218 template <
class DaughterContainer>
223 findContainer(
id)->set(
t ) ;
226 log << MSG::WARNING <<
"Sorry: cannot store containers at BARREL_EC granularity" <<
endmsg;
228 findContainer(
id)->set(
id,
t ) ;
232 template <
class DaughterContainer>
233 inline const typename DaughterContainer::value_type&
237 const DaughterContainer* container = getContainer(
channelId(
id) ) ;
239 const typename DaughterContainer::value_type& rc = container->get(
id ) ;
240 if( DaughterContainer::trait_type::isvalid(rc) )
return rc ;
244 if ( this->
size() == 0 ) {
247 char*
tmp = abi::__cxa_demangle(
typeid(
this).
name(),0,&len,&
s);
248 std::string
error = std::string(
tmp) + std::string(
" is empty!!");
249 throw std::runtime_error(
error );
251 return this->front()->get() ;
255 template <
class DaughterContainer>
256 inline const typename DaughterContainer::value_type&
260 const DaughterContainer* container = getContainer(
channelId(
id) ) ;
262 const typename DaughterContainer::value_type& rc = container->get(
id , resolvelevel) ;
263 if( DaughterContainer::trait_type::isvalid(rc) )
return rc ;
267 if ( this->
size() == 0 ) {
270 char*
tmp = abi::__cxa_demangle(
typeid(
this).
name(),0,&len,&
s);
271 std::string
error = std::string(
tmp) + std::string(
" is empty!!");
272 throw std::runtime_error(
error );
275 return this->front()->get(
id,resolvelevel) ;
279 template <
class DaughterContainer>
284 const DaughterContainer* container = getContainer(
channelId(
id) ) ;
286 const typename DaughterContainer::value_type&
value = container->get(
id ) ;
291 if ( this->
size() == 0 ) {
294 char*
tmp = abi::__cxa_demangle(
typeid(
this).
name(),0,&len,&
s);
295 std::string
error = std::string(
tmp) + std::string(
" is empty!!");
296 throw std::runtime_error(
error );
302 template <
class DaughterContainer>
306 it != this->
end(); ++
it) (*it)->clear() ;
310 template <
class DaughterContainer>
314 it != this->
end(); ++
it) total += (*it)->footprint() ;
319 template <
class DaughterContainer>
322 it != this->
end(); ++
it) (*it)->crunch() ;
326 template <
class DaughterContainer>
330 it != this->
end(); ++
it) rc += (*it)->numObjects() ;
335 template <
class DaughterContainer>
339 for( ; dauit != this->
end(); ++dauit, ++chanit) {
341 typename DaughterContainer::FlatContainer newentries ;
342 (*dauit)->getall(newentries) ;
344 if( dauit == this->
begin() ) {
354 entries.insert(
entries.end(), newentries.begin(), newentries.end() ) ;
359 template <
class DaughterContainer>
363 for( ; dauit != this->
end(); ++dauit, ++chanit) {
364 std::cout <<
"Now printing channel " << *chanit <<
" layer/becindex: " << layerwheelindex(*chanit) <<
" " << barrelecindex(*chanit) << std::endl ;
371 template <
class DaughterContainer>
375 if( this->
size()>0 && *(this->chan_begin()) != m_defaultschannelid ) {
377 log << MSG::ERROR <<
" first channel id is not defaults channel id!" <<
endmsg ;
381 auto maxchan=std::max_element(this->chan_begin(),this->chan_end());
382 const size_t maxchanid= maxchan==this->chan_end() ? 0 : *maxchan;
385 m_channelmap.clear() ;
386 m_channelmap.resize( maxchanid + 1,
nullptr ) ;
388 auto dauit = this->
begin() ;
389 for(
auto chanit = this->chan_begin();chanit != this->chan_end(); ++chanit, ++dauit ) {
390 m_channelmap[*chanit] = *dauit ;
392 return StatusCode::SUCCESS;