ATLAS Offline Software
FloatArrayStore.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include <iostream>
8 
10  std::multimap<int,Identifier> indexmap;
11 
12  map_citr itr=m_bufmap.begin();
13  for (;itr!=m_bufmap.end();++itr)
14  indexmap.insert(std::pair<int,Identifier>(std::abs(itr->second),itr->first));
15  std::vector< std::vector<float> > tmp(m_buf);
16  dbg();
17  this->clear();
18  int i(-tmp.size());
19  for (;i<(int)tmp.size();i++){
20  bool first(true);
21  Identifier shared_id;
23  for ( pos=indexmap.lower_bound(i); pos!=indexmap.upper_bound(i); ++pos){
24  if (first){
25  first=false;
26  shared_id=pos->second;
27  this->push_back(shared_id,tmp[std::abs(i)]);
28  } else
29  this->share(pos->second,shared_id);
30  }
31  }
32 }
33 
34 void FloatArrayStore::dbg() const {
35  std::cout << "dbg:" << m_bufmap.size() << " " << m_buf.size() << std::endl;
36 }
37 
38 
39 std::ostream& operator<<(std::ostream& os, const FloatArrayStore& store){
40  os << store.tag() << std::endl ;
41  // it is a bit of a heck, but the FloatArrayStore doesn't allow for more.
42  // first make an inverse map
43  std::map<int, std::vector<Identifier> > indextoidentmap ;
44  for(auto it : store)
45  indextoidentmap[it.second].push_back(it.first) ;
46  // store the number of lines
47  os << indextoidentmap.size() << std::endl ;
48  // now store all elements, as follows
49  // each line is: #idents ident1 ident2 ...indentN vectorsize element1 element2 ... elementN
50  for( std::map<int, std::vector<Identifier> >::const_iterator it = indextoidentmap.begin() ;
51  it != indextoidentmap.end(); ++it) {
52  os << it->second.size() << " " ;
53  for(auto vit : it->second)
54  os << vit << " " ;
55  const std::vector<float>& data = store[it->second.front()] ;
56  os << data.size() << " " ;
57  for(float vit : data)
58  os << vit << " " ;
59  os << std::endl ;
60  }
61  return os ;
62 }
63 
64 std::istream& operator>>(std::istream& is, FloatArrayStore& store){
65  store.clear() ;
66  std::string tag ;
67  is >> tag ;
69  std::vector<int> identifiers(0) ;
70  std::vector<float> data(0) ;
71  constexpr int maxLines=2000000;//max 2 million lines
72  constexpr int maxSize=2000000; //max size 2 million
73  int nlines ;
74  is >> nlines ;
75  if ((nlines>=0) and (nlines<maxLines)) {
76  for(int iline = 0; iline <nlines; ++iline) {
77  int size ;
78  is >> size ;
79  if ((size>=0) and (size<maxSize)){
80  identifiers.resize(size) ;
81  for(int i=0; i<size; ++i) is >> (identifiers[i]) ;
82  }
83  else {
84  MsgStream log(Athena::getMessageSvc(), "FloatArrayStore");
85  log << MSG::ERROR << "size of identifier is incorrect" << endmsg;
86  return is;
87  }
88  is >> size ;
89  if ((size>=0) and (size<maxSize)){
90  data.resize(size) ;
91  for(int i=0; i<size; ++i) is >> (data[i]) ;
92  }
93  else {
94  MsgStream log(Athena::getMessageSvc(), "FloatArrayStore");
95  log << MSG::ERROR << "size of data is incorrect" << endmsg;
96  return is;
97  }
99  store.push_back( reference, data ) ;
100  std::vector<int>::const_iterator it = identifiers.begin() ;
101  for( ++it; it!= identifiers.end(); ++it) store.share(Identifier(*it),reference) ;
102  }
103  }
104  return is ;
105 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
FloatArrayStore.h
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
FloatArrayStore::share
void share(const Identifier &ident, const Identifier &referenceIdent)
makes index ident share data with referenceIdent
Definition: FloatArrayStore.h:147
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
skel.it
it
Definition: skel.GENtoEVGEN.py:423
reference
Definition: hcg.cxx:437
FloatArrayStore::m_buf
Buffer m_buf
The std::vector<float> stored in each second element.
Definition: FloatArrayStore.h:100
FloatArrayStore::dbg
void dbg() const
print method
Definition: FloatArrayStore.cxx:34
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
operator>>
std::istream & operator>>(std::istream &is, FloatArrayStore &store)
Definition: FloatArrayStore.cxx:64
operator<<
std::ostream & operator<<(std::ostream &os, const FloatArrayStore &store)
Definition: FloatArrayStore.cxx:39
FloatArrayStore::cleanUp
void cleanUp()
remove data with no index pointing to it
Definition: FloatArrayStore.cxx:9
FloatArrayStore::map_citr
BufferMap::const_iterator map_citr
Definition: FloatArrayStore.h:49
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
FloatArrayStore::m_bufmap
BufferMap m_bufmap
The std::map.
Definition: FloatArrayStore.h:99
InDetSimDataHelpers::identifiers
std::vector< Identifier > identifiers(const InDetSimDataCollection &coll)
Definition: InDetSimDataDict.h:15
DeMoScan.first
bool first
Definition: DeMoScan.py:534
dq_make_web_display.reference
reference
Definition: dq_make_web_display.py:44
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
FloatArrayStore::clear
void clear()
remove all
Definition: FloatArrayStore.h:113
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:24
FloatArrayStore
class FloatArrayStore Access and manipulate an indexed storage of float vectors
Definition: FloatArrayStore.h:34
FloatArrayStore::push_back
void push_back(const Identifier &ident, const std::vector< float > &value)
makes new indices
Definition: FloatArrayStore.h:116