ATLAS Offline Software
Loading...
Searching...
No Matches
TrigCompositeCnv_p1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8
10 TrigComposite_p1* pers, MsgStream &log )
11{
12
13 log << MSG::DEBUG << "TrigCompositeCnv_p1::transToPers" << endmsg;
14
15 if ( (!trans) || (!pers) ) {
16 log << MSG::ERROR << "TrigCompositeCnv_p1::transToPers with trans or pers == 0" << endmsg;
17 }
18 else{
19
20 // everywhere below the vector::reserve() can be used since we know the sizes in advance,
21 // in fact, however, we expect this arrays to be of small size so it should not matter
22 for (const std::pair<const std::string, TrigFeatureLink>& p :
24 {
25 pers->m_labels.push_back( p.first );
26 pers->m_clids.push_back( (uint32_t)p.second.clid() );
27 pers->m_stypes.push_back( p.second.subTypeIndex() );
28 pers->m_indexes.push_back( p.second.index() );
29 }
30
31 for (const std::pair<const std::string, float>& p :
32 trans->allDetails<float>())
33 {
34 pers->m_floats.push_back(p.second);
35 pers->m_fnames.push_back(p.first);
36 }
37
38 for (const std::pair<const std::string, int>& p :
39 trans->allDetails<int>())
40 {
41 pers->m_ints.push_back(p.second);
42 pers->m_inames.push_back(p.first);
43 }
44
45 for (const std::pair<const std::string, std::string>& p :
46 trans->allDetails<std::string>())
47 {
48 pers->m_strings.push_back(p.second);
49 pers->m_snames.push_back(p.first);
50 }
51
52 for (const std::pair<const std::string, std::vector<float> >& p :
53 trans->allDetails<std::vector<float> >())
54 {
55 pers->m_v_floats.push_back(p.second);
56 pers->m_v_fnames.push_back(p.first);
57 }
58
59 for (const std::pair<const std::string, std::vector<int> >& p :
60 trans->allDetails<std::vector<int> >())
61 {
62 pers->m_v_ints.push_back(p.second);
63 pers->m_v_inames.push_back(p.first);
64 }
65
66 for (const std::pair<const std::string, std::vector<std::string> >& p :
67 trans->allDetails<std::vector<std::string> >())
68 {
69 pers->m_v_strings.push_back(p.second);
70 pers->m_v_snames.push_back(p.first);
71 }
72
73 pers->m_instance=trans->name();
74 }
75}
76
77
78template<class T>
79void copyDetails2Trans(const std::vector<std::string>& keys, const std::vector<T>& values, TrigComposite* trans, MsgStream &log) {
80 if (values.size() != keys.size() ) {
81 log << MSG::ERROR << "TrigCompositeCnv_p1::persToTrans: The number of values and names for do not match, problem with the stored data, while" << __PRETTY_FUNCTION__ << endmsg;
82 // the __PREETY_FUNCTION__ should give actual function name with the template so we know if this is about floats, ints ....
83 }
84 typename std::vector<T>::const_iterator vi = values.begin();
85 std::vector<std::string>::const_iterator ki = keys.begin();
86
87 for ( ; vi != values.end() and ki != keys.end(); ++ki, ++vi )
88 trans->addDetail(*ki, *vi);
89}
90
92 TrigComposite* trans, MsgStream &log )
93{
94
95 log << MSG::DEBUG << "TrigCompositeCnv_p1::persToTrans" << endmsg;
96
97 if ( (!trans) || (!pers) ) {
98 log << MSG::ERROR << "TrigCompositeCnv_p1::persToTrans with trans or pers == 0" << endmsg;
99 }else{
100 *trans = TrigComposite (pers->m_instance);
101
102 // std::vector<bool>::const_iterator it_set;
103 // it_set=(pers->m_v_set).begin();
104
105 copyDetails2Trans(pers->m_fnames, pers->m_floats, trans, log);
106 copyDetails2Trans(pers->m_inames, pers->m_ints, trans, log);
107 copyDetails2Trans(pers->m_snames, pers->m_strings, trans, log);
108
109 copyDetails2Trans(pers->m_v_fnames, pers->m_v_floats, trans, log);
110 copyDetails2Trans(pers->m_v_inames, pers->m_v_ints, trans, log);
111 copyDetails2Trans(pers->m_v_snames, pers->m_v_strings, trans, log);
112
113 if((pers->m_labels.size())==(pers->m_clids.size()) && (pers->m_labels.size())==(pers->m_stypes.size()) && (pers->m_labels.size())==(pers->m_indexes.size())){
114 std::vector<std::string>::const_iterator labelIt = pers->m_labels.begin();
115 std::vector<uint32_t>::const_iterator clidIt = pers->m_clids.begin();
116 std::vector<uint16_t>::const_iterator colIt = pers->m_stypes.begin();
117 std::vector<uint32_t>::const_iterator indexIt = pers->m_indexes.begin();
118
119
120 for ( ; labelIt != pers->m_labels.end(); ++clidIt, ++indexIt, ++colIt, ++labelIt ){
121 trans->addObject(*labelIt, TrigFeatureLink(*clidIt, *colIt, *indexIt));
122 }
123 }else{
124 log << MSG::ERROR << "TrigCompositeCnv_p1::persToTrans: The number of TrigFeatureLink labels, CLIDs, types and indexes does not match, problem with the stored data" << endmsg;
125 }
126
127 // trans->m_locked=pers->m_f_locked;
128 // traans->m_mustset=pers->m_mustset;
129 //trans->m_log.m_label=pers->m_instance;
130 }
131}
#define endmsg
void copyDetails2Trans(const std::vector< std::string > &keys, const std::vector< T > &values, TrigComposite *trans, MsgStream &log)
virtual void persToTrans(const TrigComposite_p1 *persObj, TrigComposite *transObj, MsgStream &log)
virtual void transToPers(const TrigComposite *transObj, TrigComposite_p1 *persObj, MsgStream &log)
std::vector< int > m_ints
std::vector< std::string > m_inames
std::vector< std::string > m_labels
std::vector< std::vector< int > > m_v_ints
std::vector< std::string > m_v_fnames
std::vector< std::vector< float > > m_v_floats
std::string m_instance
std::vector< std::string > m_v_snames
std::vector< std::string > m_snames
std::vector< std::string > m_strings
std::vector< std::vector< std::string > > m_v_strings
std::vector< uint16_t > m_stypes
std::vector< float > m_floats
std::vector< std::string > m_fnames
std::vector< uint32_t > m_clids
std::vector< std::string > m_v_inames
std::vector< uint32_t > m_indexes
The class is meant to store links (of type TrigFeatureLink) to trigger objects and arbitrary details ...
const std::map< std::string, T > & allDetails() const
return the map of all the details Notie that the non-const version is not provided because it would a...
void addDetail(const std::string &key, const T &value=T())
adds the value user the key, if they detail under that key already exists the exception is thrown If ...
void addObject(const std::string &key, TrigFeatureLink link)
adds the link