ATLAS Offline Software
MM_RawDataContainerCnv_p2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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<<"MM_RawDataContainerCnv_p2::transToPers with MM_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  MM_RawDataCollection_p2& 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 MM_RawData* transObj = (*collection)[j] ;
26  MM_RawData_p2* 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  }
33 }
34 
36 {
37 
38  size_t numColl = persCont->size();
39 
40  if (DEBUG) log<<MSG::VERBOSE<<"MM_RawDataContainerCnv_p2::persToTrans with MM_RawDataContainer_p2 with this many collections "<<numColl<<std::endl;
41 
42  MM_RawDataCollection* coll = nullptr;
43  for ( const MM_RawDataCollection_p2& collection : *persCont){
44 
45  coll = new MM_RawDataCollection(collection.m_idHash);
46  if ( transCont->addCollection(coll,collection.m_idHash).isFailure() ) {
47  log << MSG::WARNING << "Could not add the MM RDO collection during persistent -> transient conversion" << std::endl;
48  return;
49  }
50 
51  if (DEBUG) log<<MSG::VERBOSE<<"Have created empty transient collection, now looping over persistent coll with this many entries: "<<collection.size() <<std::endl;
52 
53  for ( unsigned int j=0 ; j < collection.size() ; ++j ){
54  const MM_RawData_p2* persObj = &( collection[j] );
55  MM_RawData* transObj = m_chanCnv.createTransient( persObj, log );
56  coll->push_back(transObj);
57  if (DEBUG) log<<MSG::VERBOSE<<*transObj<<std::endl;
58  }
59  }
60  if (DEBUG) log<<MSG::VERBOSE<<"MM_RawDataContainerCnv_p2::persToTrans with MM_RawDataCollection with this many collections "<<transCont->numberOfCollections()<<std::endl;
61 }
62 
63 
64 
65 //================================================================
67 {
68  std::unique_ptr<MM_RawDataContainer> trans(new Muon::MM_RawDataContainer(m_idHelper->module_hash_max()));
69  if (DEBUG) log<<MSG::VERBOSE<<"MM_RawDataContainerCnv_p2::createTransient() Created new MM_RawDataContainer with this many collections "<<trans->numberOfCollections()<<std::endl;
70 
71  persToTrans(persObj, trans.get(), log);
72  if (DEBUG) log<<MSG::VERBOSE<<"MM_RawDataContainerCnv_p2::createTransient() After persToTrans this many collections "<<trans->numberOfCollections()<<std::endl;
73 
74  return(trans.release());
75 }
76 
78 {
79  m_idHelper = idHelper;
80 }
Muon::MM_RawDataCollection_p2::m_idHash
unsigned int m_idHash
Definition: MM_RawDataCollection_p2.h:18
Muon::MM_RawDataContainerCnv_p2::initialize
void initialize(const MmIdHelper *idHelper)
Definition: MM_RawDataContainerCnv_p2.cxx:77
Muon::MM_RawDataContainerCnv_p2::createTransient
virtual Muon::MM_RawDataContainer * createTransient(const Muon::MM_RawDataContainer_p2 *persObj, MsgStream &log) override final
Definition: MM_RawDataContainerCnv_p2.cxx:66
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:297
Muon::MM_RawDataCollection::m_idHash
IdentifierHash m_idHash
Offline IdentifierHash for this collection.
Definition: MM_RawDataCollection.h:28
Muon::MM_RawData_p2
Definition: MM_RawData_p2.h:12
MM_RawDataContainerCnv_p2.h
MM_RawDataContainer_p2.h
Muon::MM_RawDataCollection
Definition: MM_RawDataCollection.h:15
Muon::MM_RawDataCnv_p2::transToPers
void transToPers(const MM_RawData *transObj, MM_RawData_p2 *persObj, MsgStream &log) override final
Definition: MM_RawDataCnv_p2.cxx:11
Muon::MM_RawDataContainer_p2
Definition: MM_RawDataContainer_p2.h:14
Muon::MM_RawDataContainer
Definition: MM_RawDataContainer.h:18
Muon::MM_RawDataCollection_p2
Definition: MM_RawDataCollection_p2.h:14
IdentifiableContainerMT::numberOfCollections
virtual size_t numberOfCollections() const override final
return number of collections
Definition: IdentifiableContainerMT.h:213
lumiFormat.i
int i
Definition: lumiFormat.py:85
Muon::MM_RawData
Temporary class to hold the MM RDO.
Definition: MM_RawData.h:20
Muon::MM_RawDataContainerCnv_p2::persToTrans
virtual void persToTrans(const Muon::MM_RawDataContainer_p2 *persCont, Muon::MM_RawDataContainer *transCont, MsgStream &log) override
Definition: MM_RawDataContainerCnv_p2.cxx:35
MmIdHelper.h
Muon::MM_RawData_p2::m_id
unsigned int m_id
FIXME! Remove this eventually.
Definition: MM_RawData_p2.h:16
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
MM_RawDataContainer.h
MmIdHelper
Definition: MmIdHelper.h:54
Muon::MM_RawDataContainerCnv_p2::transToPers
virtual void transToPers(const Muon::MM_RawDataContainer *transCont, Muon::MM_RawDataContainer_p2 *persCont, MsgStream &log) override
Definition: MM_RawDataContainerCnv_p2.cxx:12
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
DEBUG
#define DEBUG
Definition: MM_RawDataContainerCnv_p2.cxx:10
Muon::MM_RawDataContainerCnv_p2::m_chanCnv
MM_RawDataCnv_p2 m_chanCnv
Definition: MM_RawDataContainerCnv_p2.h:36
python.Constants.VERBOSE
int VERBOSE
Definition: Control/AthenaCommon/python/Constants.py:14