ATLAS Offline Software
STGC_RawDataContainerCnv_p3.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 
10 #define DEBUG 0
11 
13 {
14  // Not using T_AthenaPoolTPPtrVectorCnv because someday we should do something a bit more sophisticated here.
15  size_t numColl = transCont->numberOfCollections();
16  if (DEBUG) log<<MSG::VERBOSE<<"STGC_RawDataContainerCnv_p3::transToPers with STGC_RawDataContainer with this many collections: "<<numColl<<std::endl;
17 
18  persCont->resize(numColl);
19  unsigned int i=0;
20  for ( const auto *collection : *transCont){
21  STGC_RawDataCollection_p3& persColl = (*persCont)[i++];
22  persColl.resize(collection->size());
23  persColl.m_idHash = collection->m_idHash;
24  for ( unsigned int j=0 ; j < collection->size() ; ++j ){
25  const STGC_RawData* transObj = (*collection)[j] ;
26  STGC_RawData_p3* persObj = &( persColl[j] );
27  m_chanCnv.transToPers( transObj, persObj, log );
28  if (DEBUG) {
29  log<<MSG::VERBOSE<<"Trans:"<<*transObj<<" Pers: "<<std::hex<<persObj->m_id<<std::dec<<std::endl;
30  }
31  }
32  log<<MSG::VERBOSE<<"trancoll "<<collection->size()<<" perscoll "<<persColl.size()<<std::endl;
33  }
34 }
35 
37 {
38  size_t numColl = persCont->size();
39  if (DEBUG) log<<MSG::VERBOSE<<"STGC_RawDataContainerCnv_p3::persToTrans with STGC_RawDataContainer_p3 with this many collections "<<numColl<<std::endl;
40 
41  STGC_RawDataCollection* coll = nullptr;
42  for ( const STGC_RawDataCollection_p3& collection : *persCont){
43  coll = new STGC_RawDataCollection(collection.m_idHash);
44  if ( transCont->addCollection(coll,collection.m_idHash).isFailure() ) {
45  log << MSG::WARNING << "Could not add the sTGC collection during persistent->transient conversion" << std::endl;
46  return;
47  }
48  if (DEBUG) log<<MSG::VERBOSE<<"Have created empty transient collection, now looping over persistent coll with this many entries: "<<collection.size() <<std::endl;
49 
50  for ( unsigned int j=0 ; j < collection.size() ; ++j ){
51  const STGC_RawData_p3* persObj = &( collection[j] );
52  STGC_RawData* transObj = m_chanCnv.createTransient( persObj, log );
53  coll->push_back(transObj);
54  if (DEBUG) log<<MSG::VERBOSE<<*transObj<<std::endl;
55  }
56  }
57  if (DEBUG) log<<MSG::VERBOSE<<"STGC_RawDataContainerCnv_p3::persToTrans with STGC_RawDataCollection with this many collections "<<transCont->numberOfCollections()<<std::endl;
58 }
59 
60 
61 
62 //================================================================
64 {
65  std::unique_ptr<STGC_RawDataContainer> trans(new Muon::STGC_RawDataContainer(m_idHelper->module_hash_max()));
66  if (DEBUG) log<<MSG::VERBOSE<<"STGC_RawDataContainerCnv_p3::createTransient() Created new STGC_RawDataContainer with this many collections "<<trans->numberOfCollections()<<std::endl;
67 
68  persToTrans(persObj, trans.get(), log);
69  if (DEBUG) log<<MSG::VERBOSE<<"STGC_RawDataContainerCnv_p3::createTransient() After persToTrans this many collections "<<trans->numberOfCollections()<<std::endl;
70 
71  return(trans.release());
72 }
73 
75 {
76  m_idHelper = idHelper;
77 }
Muon::STGC_RawDataContainer_p3
Definition: STGC_RawDataContainer_p3.h:14
sTgcIdHelper.h
IdentifiableContainerMT::addCollection
virtual StatusCode addCollection(const T *coll, IdentifierHash hashId) override final
insert collection into container with id hash if IDC should not take ownership of collection,...
Definition: IdentifiableContainerMT.h:300
Muon::STGC_RawDataContainer
Definition: STGC_RawDataContainer.h:18
Muon::STGC_RawDataContainerCnv_p3::persToTrans
virtual void persToTrans(const Muon::STGC_RawDataContainer_p3 *persCont, Muon::STGC_RawDataContainer *transCont, MsgStream &log) override
Definition: STGC_RawDataContainerCnv_p3.cxx:36
STGC_RawDataContainer.h
IdentifiableContainerMT::numberOfCollections
virtual size_t numberOfCollections() const override final
return number of collections
Definition: IdentifiableContainerMT.h:216
Muon::STGC_RawData
Definition: STGC_RawData.h:14
lumiFormat.i
int i
Definition: lumiFormat.py:92
Muon::STGC_RawDataCnv_p3::transToPers
void transToPers(const STGC_RawData *transObj, STGC_RawData_p3 *persObj, MsgStream &log) override final
Definition: STGC_RawDataCnv_p3.cxx:11
Muon::STGC_RawDataContainerCnv_p3::createTransient
virtual Muon::STGC_RawDataContainer * createTransient(const Muon::STGC_RawDataContainer_p3 *persObj, MsgStream &log) override final
Definition: STGC_RawDataContainerCnv_p3.cxx:63
Muon::STGC_RawData_p3::m_id
unsigned int m_id
FIXME! Remove this eventually.
Definition: STGC_RawData_p3.h:16
DEBUG
#define DEBUG
Definition: STGC_RawDataContainerCnv_p3.cxx:10
Muon::STGC_RawDataCollection_p3::m_idHash
unsigned int m_idHash
Definition: STGC_RawDataCollection_p3.h:18
Muon::STGC_RawData_p3
Definition: STGC_RawData_p3.h:12
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
sTgcIdHelper
Definition: sTgcIdHelper.h:55
Muon::STGC_RawDataContainerCnv_p3::m_chanCnv
STGC_RawDataCnv_p3 m_chanCnv
Definition: STGC_RawDataContainerCnv_p3.h:36
Muon::STGC_RawDataContainerCnv_p3::transToPers
virtual void transToPers(const Muon::STGC_RawDataContainer *transCont, Muon::STGC_RawDataContainer_p3 *persCont, MsgStream &log) override
Definition: STGC_RawDataContainerCnv_p3.cxx:12
STGC_RawDataContainerCnv_p3.h
STGC_RawDataContainer_p3.h
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Muon::STGC_RawDataCollection::m_idHash
IdentifierHash m_idHash
Offline IdentifierHash for this collection.
Definition: STGC_RawDataCollection.h:30
Muon::STGC_RawDataCollection
Definition: STGC_RawDataCollection.h:18
Muon::STGC_RawDataContainerCnv_p3::initialize
void initialize(const sTgcIdHelper *idHelper)
Definition: STGC_RawDataContainerCnv_p3.cxx:74
Muon::STGC_RawDataCollection_p3
Definition: STGC_RawDataCollection_p3.h:14
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14