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>
135 template <
class DaughterContainer>
142 for( ; rhsit != rhs.
end(); ++rhsit, ++ rhschanit) {
143 DaughterContainer* lhscontainer = findContainer( *rhschanit ) ;
144 *lhscontainer = **rhsit ;
150 template <
class DaughterContainer>
156 m_defaultschannelid ;
160 template <
class DaughterContainer>
164 return channelid!=m_defaultschannelid ? (channelid-1)/4 : 99 ;
168 template <
class DaughterContainer>
172 return channelid!=m_defaultschannelid ? (channelid-1)%4 : 99 ;
176 template <
class DaughterContainer>
182 log << MSG::WARNING <<
"Sorry: cannot store containers at BARREL_EC granularity" <<
endmsg ;
184 return findContainer(
channelId(
id ) ) ;
188 template <
class DaughterContainer>
192 if(this->
size()==0) {
193 this->push_back(
new DaughterContainer() ) ;
194 this->
add(m_defaultschannelid);
197 std::find( this->chan_begin(), this->chan_end(), chanid ) ;
199 if(chanit==this->chan_end()) {
201 this->push_back(
new DaughterContainer() ) ;
203 chanindex = this->
size()-1 ;
205 m_channelmap.clear() ;
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>
219 return chanid < m_channelmap.size() ? m_channelmap[chanid] : nullptr ;
222 template <
class DaughterContainer>
227 findContainer(
id)->set(
t ) ;
230 log << MSG::WARNING <<
"Sorry: cannot store containers at BARREL_EC granularity" <<
endmsg;
232 findContainer(
id)->set(
id,
t ) ;
236 template <
class DaughterContainer>
237 inline const typename DaughterContainer::value_type&
241 const DaughterContainer* container = getContainer(
channelId(
id) ) ;
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&
264 const DaughterContainer* container = getContainer(
channelId(
id) ) ;
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>
288 const DaughterContainer* container = getContainer(
channelId(
id) ) ;
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() ) {
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>
379 if( this->
size()>0 && *(this->chan_begin()) != m_defaultschannelid ) {
381 log << MSG::ERROR <<
" first channel id is not defaults channel id!" <<
endmsg ;
385 auto maxchan=std::max_element(this->chan_begin(),this->chan_end());
386 const size_t maxchanid= maxchan==this->chan_end() ? 0 : *maxchan;
389 m_channelmap.clear() ;
390 m_channelmap.resize( maxchanid + 1,
nullptr ) ;
392 auto dauit = this->
begin() ;
393 for(
auto chanit = this->chan_begin();chanit != this->chan_end(); ++chanit, ++dauit ) {
394 m_channelmap[*chanit] = *dauit ;
396 return StatusCode::SUCCESS;