ATLAS Offline Software
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 :
23  trans->allDetails<TrigFeatureLink>())
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 
78 template<class T>
79 void 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 }
TrigComposite_p1::m_ints
std::vector< int > m_ints
Definition: TrigComposite_p1.h:57
TrigComposite_p1::m_inames
std::vector< std::string > m_inames
Definition: TrigComposite_p1.h:58
TrigComposite_p1::m_fnames
std::vector< std::string > m_fnames
Definition: TrigComposite_p1.h:56
TrigComposite::addDetail
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 ...
Definition: TrigComposite.cxx:89
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
xAOD::TrigComposite
TrigComposite_v1 TrigComposite
Declare the latest version of the class.
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:16
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TrigComposite_p1::m_v_floats
std::vector< std::vector< float > > m_v_floats
Definition: TrigComposite_p1.h:62
TrigComposite
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:26
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:797
TrigComposite_p1::m_indexes
std::vector< uint32_t > m_indexes
Definition: TrigComposite_p1.h:51
TrigComposite_p1::m_snames
std::vector< std::string > m_snames
Definition: TrigComposite_p1.h:60
TrigCompositeCnv_p1::persToTrans
virtual void persToTrans(const TrigComposite_p1 *persObj, TrigComposite *transObj, MsgStream &log)
Definition: TrigCompositeCnv_p1.cxx:91
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
TrigComposite_p1::m_labels
std::vector< std::string > m_labels
Definition: TrigComposite_p1.h:52
TrigCompositeCnv_p1.h
TrigComposite_p1
Definition: TrigComposite_p1.h:27
TrigComposite_p1::m_v_strings
std::vector< std::vector< std::string > > m_v_strings
Definition: TrigComposite_p1.h:66
TrigComposite_p1::m_floats
std::vector< float > m_floats
Definition: TrigComposite_p1.h:55
TrigComposite_p1::m_v_snames
std::vector< std::string > m_v_snames
Definition: TrigComposite_p1.h:67
TrigComposite_p1::m_strings
std::vector< std::string > m_strings
Definition: TrigComposite_p1.h:59
TrigComposite.h
TrigComposite_p1::m_v_inames
std::vector< std::string > m_v_inames
Definition: TrigComposite_p1.h:65
TrigComposite_p1::m_stypes
std::vector< uint16_t > m_stypes
Definition: TrigComposite_p1.h:50
TrigComposite::name
const std::string & name() const
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:42
TrigComposite_p1::m_clids
std::vector< uint32_t > m_clids
Definition: TrigComposite_p1.h:49
TrigComposite::allDetails
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...
Definition: Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h:149
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TrigCompositeCnv_p1::transToPers
virtual void transToPers(const TrigComposite *transObj, TrigComposite_p1 *persObj, MsgStream &log)
Definition: TrigCompositeCnv_p1.cxx:9
copyDetails2Trans
void copyDetails2Trans(const std::vector< std::string > &keys, const std::vector< T > &values, TrigComposite *trans, MsgStream &log)
Definition: TrigCompositeCnv_p1.cxx:79
TrigComposite::addObject
void addObject(const std::string &key, TrigFeatureLink link)
adds the link
Definition: TrigComposite.cxx:54
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
TrigComposite_p1::m_instance
std::string m_instance
Definition: TrigComposite_p1.h:69
TrigComposite_p1.h
TrigComposite_p1::m_v_fnames
std::vector< std::string > m_v_fnames
Definition: TrigComposite_p1.h:63
TrigComposite_p1::m_v_ints
std::vector< std::vector< int > > m_v_ints
Definition: TrigComposite_p1.h:64