ATLAS Offline Software
Loading...
Searching...
No Matches
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
11#include "MsgUtil.h"
12
13#include <string>
14#include <iostream>
15#include <sstream>
16
17
18
19//================================================================
20namespace {
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
87 StatusCode sc(m_storeGate->retrieve(it, last));
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//================================================================
#define endmsg
static Double_t sc
#define MSG_DEBUG(log, x)
Definition MsgUtil.h:15
This is an Identifier helper class for the TRT subdetector.
InDetRawDataCollection< TRT_RDORawData > TRT_RDO_Collection
TRT_RDO_colvector TRT_RDO_Container_p1
ConstDataVector< DataVector< InDetRawDataCollection< TRT_RDORawData > > > TRT_RDO_colvector
InDetRawDataContainer< InDetRawDataCollection< TRT_RDORawData > > TRT_RDO_Container
value_type push_back(value_type pElem)
Add an element to the end of the collection.
iterator begin() noexcept
Return an iterator pointing at the beginning of the collection.
iterator end() noexcept
Return an iterator pointing past the end of the collection.
DataVector< InDetRawDataCollection< TRT_RDORawData > >::const_iterator const_iterator
size_type size() const noexcept
Returns the number of elements in the collection.
const_iterator end() const
return const_iterator for end of container
const_iterator indexFind(IdentifierHash hashId) const
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,...
const_iterator begin() const
return const_iterator for first entry
This is a "hash" representation of an Identifier.
a const_iterator facade to DataHandle.
Definition SGIterator.h:164
virtual void persToTrans(const TRT_RDO_Container_p1 *persObj, TRT_RDO_Container *transObj, MsgStream &log)
virtual TRT_RDO_Container_p1 * createPersistent(const TRT_RDO_Container *persObj, MsgStream &log)
virtual void transToPers(const TRT_RDO_Container *transObj, TRT_RDO_Container_p1 *persObj, MsgStream &log)
virtual TRT_RDO_Container * createTransient(const TRT_RDO_Container_p1 *persObj, MsgStream &log)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts