8 template <
class T1,
class T2,
typename Comp=std::less<T1> >
struct PairSortBy1st :
public std::binary_function<std::pair<T1,T2>,std::pair<T1,T2>,bool> {
12 bool operator()(
const std::pair<T1,T2>& lhs,
const std::pair<T1,T2>&rhs)
const{
return comp(lhs.first,rhs.first);}
13 bool operator()(
const T1& lhs,
const std::pair<T1,T2>&rhs)
const{
return comp(lhs,rhs.first);}
14 bool operator()(
const std::pair<T1,T2>& lhs,
const T1 &rhs)
const{
return comp(lhs.first,rhs);}
18 template <
class T1,
typename Comp=std::less<T1> >
struct Adjacent :
public std::binary_function<T1,T1,bool> {
27 template <
class T1,
class T2>
struct Pair2nd :
public std::unary_function<std::pair<T1,T2>,bool> {
28 T2
operator()(
const std::pair<T1,T2>& val)
const{
return val.second;}
40 if(readHeaderCode!=
SUCCESS)
return readHeaderCode;
42 std::vector<std::pair<unsigned int,int> >
entries;
46 while(std::getline(stream,line)){
47 line.erase(
std::find( line.begin(), line.end(),
'#' ), line.end() );
48 std::istringstream lineStream(line);
49 std::pair<unsigned int,int> entry;
50 while(lineStream >> entry.first >> entry.second ){
53 entries.push_back(entry);
54 if(entry.first>maxAddress || maxAddress==
addressMask_) maxAddress=entry.first;
67 if(entries.front().first!=0 ||
68 std::adjacent_find(entries.begin(),entries.end(),
88 stream <<
"#<header> V1 "<<nrBitsAddress_<<
" "<<nrBitsData_<<
" </header> "<<std::endl;
89 for(
unsigned int address=0;address<data_.size();address++){
90 stream << (address&addressMask_)<<
" "<<
data(address)<<std::endl;
97 int startPos=stream.tellg();
99 while(std::getline(stream,line)){
100 if(line.find(
"#<header>")==0){
101 std::istringstream lineStream(line);
105 if(lineStream >> headerField >> version >> nrBitsAddress_ >> nrBitsData_){
106 addressMask_ = nrBitsAddress_!=32 ? (0x1<<nrBitsAddress_)-1 : ~0x0;
107 dataMask_ = (0x1<<nrBitsData_)-1;
108 stream.seekg(startPos);
116 addressMask_ = (0x1<<nrBitsAddress_)-1;
117 dataMask_ = (0x1<<nrBitsData_)-1;
119 stream.seekg(startPos);
void write(std::ostream &stream) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool operator()(const T1 &lhs, const T1 &rhs) const
T2 operator()(const std::pair< T1, T2 > &val) const
int read(std::istream &stream)
Adjacent(const Comp &iComp)
bool operator()(const std::pair< T1, T2 > &lhs, const std::pair< T1, T2 > &rhs) const
unsigned int addressMask_
Abs< T >::type abs(const T &t)
bool operator()(const T1 &lhs, const std::pair< T1, T2 > &rhs) const
int readHeader_(std::istream &)
PairSortBy1st(const Comp &iComp)
bool operator()(const T1 &lhs, const T1 &rhs) const
char data[epos_bytes_allocation]
bool operator()(const std::pair< T1, T2 > &lhs, const T1 &rhs) const