CbmRoot
CbmFormatTsPrintout.cxx
Go to the documentation of this file.
1 
4 #include <ios>
5 
6 std::string FormatTsHeaderPrintout(const fles::Timeslice& ts) {
7  std::stringstream ss;
8 
9  uint64_t min_num_microslices = UINT64_MAX;
10  uint64_t max_num_microslices = 0;
11  uint64_t total_num_microslices = 0;
12  uint64_t min_microslice_size = UINT64_MAX;
13  uint64_t max_microslice_size = 0;
14  uint64_t total_microslice_size = 0;
15 
16  size_t nbComps = ts.num_components();
17  size_t nbMicroslicesCore = ts.num_core_microslices();
18  for (uint64_t compIdx = 0; compIdx < nbComps; ++compIdx) {
19  uint64_t num_microslices = ts.num_microslices(compIdx);
20  min_num_microslices = std::min(min_num_microslices, num_microslices);
21  max_num_microslices = std::max(max_num_microslices, num_microslices);
22  total_num_microslices += num_microslices;
23  for (uint64_t msIdx = 0; msIdx < num_microslices; ++msIdx) {
24  uint64_t size = ts.descriptor(compIdx, msIdx).size;
25  total_microslice_size += size;
26  min_microslice_size = std::min(min_microslice_size, size);
27  max_microslice_size = std::max(max_microslice_size, size);
28  } // for( uint64_t msIdx = 0; msIdx < num_microslices; ++msIdx )
29  } // for( uint64_t compIdx = 0; compIdx < nbComps; ++compIdx )
30 
31  uint64_t min_overlap = min_num_microslices - nbMicroslicesCore;
32  uint64_t max_overlap = max_num_microslices - nbMicroslicesCore;
33 
34  ss << "Timeslice " << std::setw(6) << ts.index() << " with " << std::setw(3)
35  << nbComps << " components "
36  << " x " << std::setw(6) << nbMicroslicesCore << " core microslices";
37  if (0 != nbComps) {
38  ss << " (+";
39  if (min_overlap != max_overlap) {
40  ss << std::setw(3) << min_overlap << std::setw(3) << ".." << max_overlap;
41  } // if( min_overlap != max_overlap )
42  else {
43  ss << std::setw(3) << min_overlap;
44  } // else of if( min_overlap != max_overlap )
45  ss << " overlap) = " << std::setw(9) << total_num_microslices << std::endl;
46  ss
47  << "\tmicroslice size min/avg/max: " << std::setw(6)
48  << min_microslice_size << " / " << std::fixed << std::setprecision(0)
49  << std::setw(6)
50  << (static_cast<double>(total_microslice_size) / total_num_microslices)
51  // << std::defaultfloat // commented out as not included in GCC 4.9.2 => restore defaults, probably not needed
52  << std::setprecision(6) // restore defaults, probably not needed
53  << " / " << std::setw(6) << max_microslice_size << " bytes" << std::endl;
54  } // if( 0 != nbComps )
55 
56  return ss.str();
57 }
58 
59 std::string FormatTsPrintout(const fles::Timeslice& ts) {
60  std::stringstream ss;
61  ss << FormatTsHeaderPrintout(ts);
62 
63  size_t nbComps = ts.num_components();
64  if (0 != nbComps) {
65  size_t nbMicroslicesCore = ts.num_core_microslices();
66  size_t nbMicroslicesOverlap =
67  ts.num_microslices(0) - ts.num_core_microslices();
68 
69  for (size_t compIdx = 0; compIdx < nbComps; ++compIdx) {
70  ss << "Core Microslices for component " << std::setw(3) << compIdx
71  << std::endl;
72  for (size_t msIdx = 0; msIdx < nbMicroslicesCore; ++msIdx) {
73  ss << ts.descriptor(compIdx, msIdx);
74  ss << FormatMsBufferPrintout(ts, compIdx, msIdx);
75  ss << "----------------------------------------------" << std::endl;
76  } // for( size_t msIdx = 0; msIdx < nbMicroslicesCore; ++msIdx )
77  ss << "Overlap Microslices for component " << std::setw(3) << compIdx
78  << std::endl;
79  for (size_t msIdx = 0; msIdx < nbMicroslicesOverlap; ++msIdx) {
80  ss << ts.descriptor(compIdx, msIdx + nbMicroslicesCore);
81  ss << FormatMsBufferPrintout(ts, compIdx, msIdx + nbMicroslicesCore);
82  ss << "----------------------------------------------" << std::endl;
83  } // for( size_t msIdx = 0; msIdx < nbMicroslicesOverlap; ++msIdx )
84  } // for( size_t comp = 0; comp < nbComps; ++comp )
85  } // if( 0 != nbComps )
86  ss << "**********************************************" << std::endl;
87 
88  return ss.str();
89 }
90 
91 std::ostream& operator<<(std::ostream& os, const fles::Timeslice& ts) {
92  os << FormatTsHeaderPrintout(ts);
93 
94  size_t nbComps = ts.num_components();
95  size_t nbMicroslicesCore = ts.num_core_microslices();
96  size_t nbMicroslicesOverlap =
97  ts.num_microslices(0) - ts.num_core_microslices();
98 
99  for (size_t compIdx = 0; compIdx < nbComps; ++compIdx) {
100  os << "Core Microslices for component " << std::setw(3) << compIdx
101  << std::endl;
102  for (size_t msIdx = 0; msIdx < nbMicroslicesCore; ++msIdx) {
103  os << ts.descriptor(compIdx, msIdx);
104  os << FormatMsBufferPrintout(ts, compIdx, msIdx);
105  os << "----------------------------------------------" << std::endl;
106  } // for( size_t msIdx = 0; msIdx < nbMicroslicesCore; ++msIdx )
107  os << "Overlap Microslices for component " << std::setw(3) << compIdx
108  << std::endl;
109  for (size_t msIdx = 0; msIdx < nbMicroslicesOverlap; ++msIdx) {
110  os << ts.descriptor(compIdx, msIdx + nbMicroslicesCore);
111  os << FormatMsBufferPrintout(ts, compIdx, msIdx + nbMicroslicesCore);
112  os << "----------------------------------------------" << std::endl;
113  } // for( size_t msIdx = 0; msIdx < nbMicroslicesOverlap; ++msIdx )
114  } // for( size_t comp = 0; comp < nbComps; ++comp )
115  os << "**********************************************" << std::endl;
116 
117  return os;
118 }
FormatTsHeaderPrintout
std::string FormatTsHeaderPrintout(const fles::Timeslice &ts)
Definition: CbmFormatTsPrintout.cxx:6
min
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: L1/vectors/P4_F32vec4.h:33
FormatMsBufferPrintout
std::string FormatMsBufferPrintout(const fles::Timeslice &ts, const size_t uMsCompIdx, const size_t uMsIdx, const uint32_t uBlocksPerLine)
Definition: CbmFormatMsBufferPrintout.cxx:4
operator<<
std::ostream & operator<<(std::ostream &os, const fles::Timeslice &ts)
Definition: CbmFormatTsPrintout.cxx:91
CbmFormatMsBufferPrintout.h
FormatTsPrintout
std::string FormatTsPrintout(const fles::Timeslice &ts)
Definition: CbmFormatTsPrintout.cxx:59
max
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: L1/vectors/P4_F32vec4.h:36
CbmFormatMsHeaderPrintout.h