ATLAS Offline Software
Loading...
Searching...
No Matches
FloatArrayStore.cxx File Reference
#include "TRT_ConditionsData/FloatArrayStore.h"
#include "GaudiKernel/MsgStream.h"
#include "AthenaKernel/getMessageSvc.h"
#include <iostream>
Include dependency graph for FloatArrayStore.cxx:

Go to the source code of this file.

Functions

std::ostream & operator<< (std::ostream &os, const FloatArrayStore &store)
std::istream & operator>> (std::istream &is, FloatArrayStore &store)

Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream & os,
const FloatArrayStore & store )

Definition at line 40 of file FloatArrayStore.cxx.

40 {
41 os << store.tag() << std::endl ;
42 // it is a bit of a heck, but the FloatArrayStore doesn't allow for more.
43 // first make an inverse map
44 std::map<int, std::vector<Identifier> > indextoidentmap ;
45 for(auto it : store)
46 indextoidentmap[it.second].push_back(it.first) ;
47 // store the number of lines
48 os << indextoidentmap.size() << std::endl ;
49 // now store all elements, as follows
50 // each line is: #idents ident1 ident2 ...indentN vectorsize element1 element2 ... elementN
51 for( std::map<int, std::vector<Identifier> >::const_iterator it = indextoidentmap.begin() ;
52 it != indextoidentmap.end(); ++it) {
53 os << it->second.size() << " " ;
54 for(auto vit : it->second)
55 os << vit << " " ;
56 const std::vector<float>& data = store[it->second.front()] ;
57 os << data.size() << " " ;
58 for(float vit : data)
59 os << vit << " " ;
60 os << std::endl ;
61 }
62 return os ;
63}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
TestStore store
Definition TestStore.cxx:23

◆ operator>>()

std::istream & operator>> ( std::istream & is,
FloatArrayStore & store )

Definition at line 65 of file FloatArrayStore.cxx.

65 {
66 store.clear() ;
67 std::string tag ;
68 is >> tag ;
69 store = FloatArrayStore(tag) ;
70 std::vector<int> identifiers(0) ;
71 std::vector<float> data(0) ;
72 constexpr int maxLines=2000000;//max 2 million lines
73 constexpr int maxSize=2000000; //max size 2 million
74 int nlines ;
75 is >> nlines ;
76 if ((nlines>=0) and (nlines<maxLines)) {
77 for(int iline = 0; iline <nlines; ++iline) {
78 int size ;
79 is >> size ;
80 if ((size>=0) and (size<maxSize)){
81 identifiers.resize(size) ;
82 for(int i=0; i<size; ++i) is >> (identifiers[i]) ;
83 }
84 else {
85 MsgStream log(Athena::getMessageSvc(), "FloatArrayStore");
86 log << MSG::ERROR << "size of identifier is incorrect" << endmsg;
87 return is;
88 }
89 is >> size ;
90 if ((size>=0) and (size<maxSize)){
91 data.resize(size) ;
92 for(int i=0; i<size; ++i) is >> (data[i]) ;
93 }
94 else {
95 MsgStream log(Athena::getMessageSvc(), "FloatArrayStore");
96 log << MSG::ERROR << "size of data is incorrect" << endmsg;
97 return is;
98 }
100 store.push_back( reference, data ) ;
101 std::vector<int>::const_iterator it = identifiers.begin() ;
102 for( ++it; it!= identifiers.end(); ++it) store.share(Identifier(*it),reference) ;
103 }
104 }
105 return is ;
106}
#define endmsg
class FloatArrayStore Access and manipulate an indexed storage of float vectors
IMessageSvc * getMessageSvc(bool quiet=false)
std::vector< Identifier > identifiers(const InDetSimDataCollection &coll)