ATLAS Offline Software
TRT_RDO_ContainerCnv_p1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Andrei Gaponenko <agaponenko@lbl.gov>, 2006
6 
8 
10 #include "InDetIdentifier/TRT_ID.h"
11 #include "MsgUtil.h"
12 
13 #include <string>
14 #include <iostream>
15 #include <sstream>
16 
17 
18 
19 //================================================================
20 namespace {
21 #if 0
22  std::string shortPrint(const TRT_RDO_Container *main_input_TRT, unsigned maxprint=25) {
23  std::ostringstream os;
24  if(main_input_TRT) {
25  for(unsigned i=0; i<maxprint; i++) {
27  if(p != main_input_TRT->end()) {
28  os<<" "<< (*p)->size();
29  }
30  else {
31  os<<" *";
32  }
33  }
34  }
35  else {
36  os<<" [TRT_RDO_Container==NULL]";
37  }
38  return os.str();
39  }
40 #endif
41 
42  //----------------------------------------------------------------
43  std::string persistentTRT_ToString(const TRT_RDO_colvector& rdoV, unsigned maxprint = 20) {
44  std::ostringstream os;
45  os<<"TRT_RDO_colvector = ["<<rdoV.size()<<"] ";
46  unsigned count = 0;
47  for(TRT_RDO_colvector::const_iterator it = rdoV.begin(); it != rdoV.end(); ++it) {
48  if(++count>maxprint) break;
49  if(*it) {
50  os<<(*it)->size()<<" ";
51  }
52  else {
53  os<<"* ";
54  }
55  }
56  return os.str();
57  }
58 }
59 
60 //================================================================
62  // Copy objects from InDetRawDataContainer collections to simple vector
63 
64  unsigned null_count(0);
65 
66  // First try iterators on container. If no collections, then try
67  // retrieving directly from SG.
68  if(trans->begin() != trans->end()) {
69  MSG_DEBUG(log,"[p1] using container iterators");
70  for(TRT_RDO_Container::const_iterator it=trans->begin(); it != trans->end(); ++it) {
71  if(*it) {
72  pers->push_back( *it );
73  }
74  else {
75  null_count++;
76  }
77  }
78  }
79  else {
80  // Access directly from SG
81 
82  // Retrieve the digits by class, not by name
85 
86  // Failure means no collections
88  if (sc.isFailure()) {
89  MSG_DEBUG(log,"[p1]: No RDO collections found !");
90  }
91  else {
92  MSG_DEBUG(log,"[p1] using collections found in the StoreGate");
93 
94  for (; it != last; ++it) {
95  const TRT_RDO_Collection* RDO_Collection = &*it;
96  pers->push_back(RDO_Collection);
97  }
98  }
99  }
100 
101  if(null_count) {
102  log<<MSG::WARNING<<"[p1] transToPers(): got "<< null_count<<" NULLs in IdentifiableContainer"<<endmsg;
103  }
104 
105  MSG_DEBUG(log,"[p1] transToPers(): PERS = "<<persistentTRT_ToString(*pers));
106 }
107 
108 //================================================================
110 
111  MSG_DEBUG(log,"[p1] persToTrans(): PERS = "<<persistentTRT_ToString(*pers));
112 
115  for (; it != last; ++it) {
116  const TRT_RDO_Container::IDENTIFIABLE *rdoColl = *it;
117  IdentifierHash idHash = rdoColl->identifyHash();
118  StatusCode sc = trans->addCollection( rdoColl, idHash);
119  if (sc.isFailure()) {
120  log << MSG::FATAL << "[p1] persToTrans(): TRT RDOs could not be added to the container!" << endmsg;
121  throw std::runtime_error("TRT_RDO_ContainerCnv_p1::persToTrans(): TRT RDOs could not be added to the container!");
122  }
123  }
124 }
125 
126 //================================================================
128  std::unique_ptr<TRT_RDO_Container> trans(std::make_unique<TRT_RDO_Container>(m_trtId->straw_layer_hash_max()));
129  persToTrans(persObj, trans.get(), log);
130  return(trans.release());
131 }
132 
133 //================================================================
135  std::unique_ptr<TRT_RDO_Container_p1> pers(std::make_unique<TRT_RDO_Container_p1>(SG::VIEW_ELEMENTS));
136  transToPers(transObj, pers.get(), log);
137  return(pers.release());
138 }
139 
140 //================================================================
TRT_RDO_ContainerCnv_p1::m_trtId
const TRT_ID * m_trtId
Definition: TRT_RDO_ContainerCnv_p1.h:20
TRT_RDO_Container.h
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
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
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
ConstDataVector::end
iterator end() noexcept
Return an iterator pointing past the end of the collection.
TRT_ID::straw_layer_hash_max
size_type straw_layer_hash_max(void) const
Definition: TRT_ID.h:920
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
TRT_RDO_ContainerCnv_p1::transToPers
virtual void transToPers(const TRT_RDO_Container *transObj, TRT_RDO_Container_p1 *persObj, MsgStream &log)
Definition: TRT_RDO_ContainerCnv_p1.cxx:61
IdentifiableContainerMT::IDENTIFIABLE
T IDENTIFIABLE
Definition: IdentifiableContainerMT.h:69
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
TRT_RDO_ContainerCnv_p1::persToTrans
virtual void persToTrans(const TRT_RDO_Container_p1 *persObj, TRT_RDO_Container *transObj, MsgStream &log)
Definition: TRT_RDO_ContainerCnv_p1.cxx:109
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
TRT_RDO_ContainerCnv_p1::createTransient
virtual TRT_RDO_Container * createTransient(const TRT_RDO_Container_p1 *persObj, MsgStream &log)
Definition: TRT_RDO_ContainerCnv_p1.cxx:127
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
IdentifiableContainerMT::indexFind
const_iterator indexFind(IdentifierHash hashId) const
Definition: IdentifiableContainerMT.h:163
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
TRT_RDO_ContainerCnv_p1::createPersistent
virtual TRT_RDO_Container_p1 * createPersistent(const TRT_RDO_Container *persObj, MsgStream &log)
Definition: TRT_RDO_ContainerCnv_p1.cxx:134
ConstDataVector::const_iterator
DV::const_iterator const_iterator
Definition: ConstDataVector.h:85
TRT_RDO_ContainerCnv_p1::m_storeGate
StoreGateSvc * m_storeGate
Definition: TRT_RDO_ContainerCnv_p1.h:21
ConstDataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ConstDataVector
DataVector adapter that acts like it holds const pointers.
Definition: ConstDataVector.h:76
TRT_RDO_ContainerCnv_p1.h
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MSG_DEBUG
#define MSG_DEBUG(log, x)
Definition: MsgUtil.h:15
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
SG::ConstIterator
Definition: SGIterator.h:163
ConstDataVector::begin
iterator begin() noexcept
Return an iterator pointing at the beginning of the collection.
MsgUtil.h