ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | Friends | List of all members
CoWTools::CoWLibrary Class Reference

#include <CoWLibrary.h>

Collaboration diagram for CoWTools::CoWLibrary:

Public Member Functions

 CoWLibrary (bool Summary=true)
 
 CoWLibrary (const std::string &n, bool Summary=true)
 
void parseRecord (std::istream &in)
 
 operator bool () const
 
CoWLibrary operator- () const
 
CoWLibraryoperator+= (const CoWLibrary &rhs)
 
CoWLibraryoperator-= (const CoWLibrary &rhs)
 

Static Public Member Functions

static std::shared_ptr< CoWLibraryfromRecord (std::istream &in, bool summary)
 

Public Attributes

std::unordered_map< std::string, std::shared_ptr< CoWRecord > > m_records
 
std::string m_libName
 
CoWRecordStats m_ms
 

Private Attributes

bool m_summary
 

Friends

std::ostream & operator<< (std::ostream &, const CoWLibrary &l)
 
CoWLibrary operator- (CoWLibrary lhs, const CoWLibrary &rhs)
 
CoWLibrary operator+ (CoWLibrary lhs, const CoWLibrary &rhs)
 

Detailed Description

Definition at line 16 of file CoWLibrary.h.

Constructor & Destructor Documentation

◆ CoWLibrary() [1/2]

CoWTools::CoWLibrary::CoWLibrary ( bool  Summary = true)
inline

Definition at line 18 of file CoWLibrary.h.

18 :m_libName("Summary"),m_summary(Summary){};

◆ CoWLibrary() [2/2]

CoWTools::CoWLibrary::CoWLibrary ( const std::string &  n,
bool  Summary = true 
)
inline

Definition at line 19 of file CoWLibrary.h.

Member Function Documentation

◆ fromRecord()

std::shared_ptr< CoWLibrary > CoWTools::CoWLibrary::fromRecord ( std::istream &  in,
bool  summary 
)
static

Definition at line 23 of file CoWLibrary.cxx.

23  {
24  std::string libLine;
25  if(std::getline(in,libLine).eof()){
26  //std::cerr<<libLine<<std::endl;
27  std::cerr<<"Returning 0"<<std::endl;
28  return 0;
29  }
30  int len=0;
31  int nfields=0;
32  std::string libName="Anonymous";
33  char buff[2048];
34  //std::cerr<<"LibLine="<<libLine<<std::endl;
35  sscanf(libLine.c_str(),"%*s %*s %*s %*s %*s%n",
36  &len
37  );
38  if(libLine.size()>(uint)(len+1)){
39  nfields=sscanf(libLine.substr(len+1).c_str(),"%2047s",buff);
40  if(nfields>0){
41  libName=buff;
42  //std::cout<<"Found lib "<<libName<<std::endl;
43  }
44  }else{
45  libName="Anonymous";
46  }
47  auto lib=std::make_shared<CoWTools::CoWLibrary>(libName,summary);
48  CoWRecordStats r(summary);
49  r.parseRecord(in);
50  lib->m_ms+=r;
51  return lib;
52  }

◆ operator bool()

CoWTools::CoWLibrary::operator bool ( ) const
inlineexplicit

Definition at line 38 of file CoWLibrary.h.

38  {
39  if(m_summary){
40  auto vals=m_ms.getValueArray();
41  for(int i=0;i<11;i++){
42  if(vals[i])return true;
43  }
44  return false;
45  }else{
46  for(auto i : m_records){
47  if(*(i.second))return true;
48  }
49  return false;
50  }
51  }

◆ operator+=()

CoWLibrary& CoWTools::CoWLibrary::operator+= ( const CoWLibrary rhs)
inline

Definition at line 67 of file CoWLibrary.h.

67  {
68  if(m_libName!=rhs.m_libName){
69  std::cerr<<"Warning trying to add different libraries. Ignoring"<<std::endl;
70  return *this;
71  }
72  for(auto i:rhs.m_records){
73  auto l=m_records.find(i.first);
74  if(l!=m_records.end()){
75  *(l->second)+=*(i.second);
76  }else{
77  m_records.insert(std::make_pair(i.first,std::make_shared<CoWRecord>(*(i.second))));
78  }
79  }
80  m_ms+=rhs.m_ms;
81  return *this;
82  }

◆ operator-()

CoWLibrary CoWTools::CoWLibrary::operator- ( ) const
inline

Definition at line 61 of file CoWLibrary.h.

61  {
62  CoWLibrary m(*this);
63  m.m_ms=-m_ms;
64  return m;
65  }

◆ operator-=()

CoWLibrary& CoWTools::CoWLibrary::operator-= ( const CoWLibrary rhs)
inline

Definition at line 84 of file CoWLibrary.h.

84  {
85  if(m_libName!=rhs.m_libName){
86  std::cerr<<"Warning trying to subtract different libraries. Ignoring"<<std::endl;
87  return *this;
88  }
89  for(auto i:rhs.m_records){
90  auto l=m_records.find(i.first);
91  if(l!=m_records.end()){
92  *(l->second)-=*(i.second);
93  }else{
94  m_records.insert(std::make_pair(i.first,std::make_shared<CoWRecord>(-*(i.second))));
95  }
96  }
97  m_ms-=rhs.m_ms;
98  return *this;
99  }

◆ parseRecord()

void CoWTools::CoWLibrary::parseRecord ( std::istream &  in)

Definition at line 9 of file CoWLibrary.cxx.

9  {
10  //std::cout<<"Got record line "<<line<<std::endl;
11  auto mr=std::make_shared<CoWRecord>(m_summary);
12  mr->parseRecord(in);
13  m_ms+=mr->m_ms;
14  }

Friends And Related Function Documentation

◆ operator+

CoWLibrary operator+ ( CoWLibrary  lhs,
const CoWLibrary rhs 
)
friend

Definition at line 53 of file CoWLibrary.h.

53  {
54  if(lhs.m_libName!=rhs.m_libName){
55  std::cerr<<"Warning trying to add different libraries. Ignoring"<<std::endl;
56  return lhs;
57  }
58  return lhs+=rhs;
59  }

◆ operator-

CoWLibrary operator- ( CoWLibrary  lhs,
const CoWLibrary rhs 
)
friend

Definition at line 30 of file CoWLibrary.h.

30  {
31  if(lhs.m_libName!=rhs.m_libName){
32  std::cerr<<"Warning trying to subtract different libraries. Ignoring"<<std::endl;
33  return lhs;
34  }
35  return lhs-=rhs;
36  }

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const CoWLibrary l 
)
friend

Definition at line 54 of file CoWLibrary.cxx.

54  {
55  // char buff[1024];
56  // snprintf(buff,1024,"Library= %s"
57  // );
58  // out<<buff;
59 
60  os<<" Lib= "<<l.m_libName<<" "<<l.m_ms;
61  return os;
62  }

Member Data Documentation

◆ m_libName

std::string CoWTools::CoWLibrary::m_libName

Definition at line 22 of file CoWLibrary.h.

◆ m_ms

CoWRecordStats CoWTools::CoWLibrary::m_ms

Definition at line 23 of file CoWLibrary.h.

◆ m_records

std::unordered_map<std::string,std::shared_ptr<CoWRecord> > CoWTools::CoWLibrary::m_records

Definition at line 20 of file CoWLibrary.h.

◆ m_summary

bool CoWTools::CoWLibrary::m_summary
private

Definition at line 26 of file CoWLibrary.h.


The documentation for this class was generated from the following files:
get_hdefs.buff
buff
Definition: get_hdefs.py:61
beamspotman.r
def r
Definition: beamspotman.py:676
CoWTools::CoWRecordStats::getValueArray
long long * getValueArray()
Definition: CoWRecordStats.h:94
checkPlugins.libName
libName
Definition: checkPlugins.py:143
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
CoWTools::CoWLibrary::m_ms
CoWRecordStats m_ms
Definition: CoWLibrary.h:23
CoWTools::CoWLibrary::m_summary
bool m_summary
Definition: CoWLibrary.h:26
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
MuonValidation_CreateSlides_config.Summary
list Summary
Definition: MuonValidation_CreateSlides_config.py:34
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
CoWTools::CoWLibrary::m_records
std::unordered_map< std::string, std::shared_ptr< CoWRecord > > m_records
Definition: CoWLibrary.h:19
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
ReadOfcFromCool.nfields
nfields
Definition: ReadOfcFromCool.py:114
CoWTools::CoWLibrary::CoWLibrary
CoWLibrary(bool Summary=true)
Definition: CoWLibrary.h:18
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
python.update_ci_reference_files.mr
mr
Definition: update_ci_reference_files.py:415
CoWTools::CoWLibrary::m_libName
std::string m_libName
Definition: CoWLibrary.h:22
PlotCalibFromCool.vals
vals
Definition: PlotCalibFromCool.py:474
SCT_Monitoring::summary
@ summary
Definition: SCT_MonitoringNumbers.h:65