ATLAS Offline Software
MuonRdoContainerTPCnv.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Gaudi
6 #include "GaudiKernel/MsgStream.h"
7 #include <stdexcept>
8 #include <memory>
9 #include "Identifier/IdentifierHash.h"
10 
11 
12 template <class T, class P, class CONV>
13 MuonRdoContainerTPCnv<T,P, CONV >::MuonRdoContainerTPCnv(ISvcLocator* svcloc)
14  : T_AthenaPoolCustomCnv<T,P >(svcloc)
15 { }
16 
17 
18 
19 
20 template <class T, class P, class CONV>
21 P *
22 MuonRdoContainerTPCnv<T,P, CONV >::createPersistent(T* rdoC)
23 {
24  MsgStream log(this->msgSvc(), "MuonRdoContainerTPCnv" );
25 
26  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " **** Entered MuonRdoContainerTPCnv::createPersistent()" << endmsg;
27 
28  P *persObj = m_TPconverter.createPersistent( rdoC, log );
29 
30  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Write RDO vector, size " << persObj->size()
31  << endmsg;
32 
33  return persObj;
34 }
35 
36 
37 // has to be inlined to prevent gcc3.2 problem/bug? of multiple definitons for specialized templates
38 template <class T, class P, class CONV>
39 inline
40 T*
41 MuonRdoContainerTPCnv<T,P, CONV >
42 ::createTransient()
43 {
44  MsgStream log(this->msgSvc(), "MuonRdoContainerTPCnv" );
45  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << " **** Warning: using default createTransient() - (possibly missing specialized version of this method" << endmsg;
46  //std::cout << " **** Warning: using default createTransient() - (possibly missing specialized version of this method" << std::endl;
47 
48  return createTransientFrom_p0( this->poolReadObject(), log );
49 }
50 
51 template <class T, class P, class CONV>
52 inline
53 StatusCode
54 MuonRdoContainerTPCnv<T,P, CONV >
55 ::initialize(){
56  return T_AthenaPoolCustomCnv<T,P>::initialize();
57 }
58 
59 
60 // invoked from persToTrans_impl to read old data from before TP separation
61 template <class T, class P, class CONV>
62 T*
63 MuonRdoContainerTPCnv<T,P, CONV >
64 ::createTransientFrom_p0(COLL_vector* col_vect, MsgStream &log)
65 {
66  if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "Using old RDO container converter" << endmsg;
67 
68  std::unique_ptr<T> rdoC( new T(col_vect->size()) );
69  //COLL_vector *col_vect = (COLL_vector*) colV;
70  typename COLL_vector::const_iterator it_Coll = col_vect->begin();
71  typename COLL_vector::const_iterator it_CollE = col_vect->end();
72  for(; it_Coll != it_CollE; ++it_Coll) {
73  const COLLECTION_t *col = *it_Coll;
74 
75  // register the rdo collection in IDC
76  //unsigned int id_hash = rdoC->idToHash((unsigned int)col->identify());
77  IdentifierHash id_hash = col->identifyHash();
78  if( rdoC->addCollection(col, id_hash).isFailure() ) {
79  throw std::runtime_error("Transient RDOs could not be created");
80  }
81  }
82  return rdoC.release();
83 }
84 
85 
86 
87 
88 
89 
90 
91