ATLAS Offline Software
Loading...
Searching...
No Matches
ForwardDetectors
FPTracker
FPTracker
DataDumperHelpers.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef FPTRACKER_DATADUMPERHELPERS_H
6
#define FPTRACKER_DATADUMPERHELPERS_H
7
#include <sstream>
8
#include <cstddef>
9
#include <algorithm>
10
11
namespace
FPTracker
{
12
class
LineFormater
{
13
public
:
14
LineFormater
(
int
numPerLine):
m_numPerLine
(0),
m_maxPerLine
(numPerLine) {}
15
template
<
class
T>
16
void
operator()
(T t){
17
if
(
m_numPerLine
==
m_maxPerLine
){
18
m_numPerLine
= 0;
19
m_ost
<<
'\n'
;
20
}
21
m_ost
<<t<<
" "
;
22
++
m_numPerLine
;
23
}
24
std::string
toString
()
const
{
return
m_ost
.str();}
25
private
:
26
int
m_numPerLine
;
27
int
m_maxPerLine
;
28
std::ostringstream
m_ost
;
29
};
30
31
template
<
class
Array1D>
32
std::string
array1DToString
(
const
Array1D& arr){
33
34
std::ostringstream
dump
;
35
LineFormater
lf = std::for_each(arr.begin(), arr.end(),
LineFormater
(10));
36
dump
<<lf.toString()+
'\n'
;
37
return
dump
.str();
38
}
39
40
41
42
template
<
class
Array2D>
43
std::string
array2DToString
(
const
Array2D& arr){
44
45
std::ostringstream
dump
;
46
for
(std::size_t is=0; is<arr.size(); ++is){
47
dump
<<
"side "
<<is<<
'\n'
;
48
49
LineFormater
lf = std::for_each(arr[is].begin(), arr[is].end(),
LineFormater
(10));
50
dump
<<lf.toString()+
'\n'
;
51
}
52
return
dump
.str();
53
}
54
55
template
<
class
Array3D>
56
std::string
array3DToString
(
const
Array3D& arr){
57
58
std::ostringstream
dump
;
59
for
(std::size_t is=0; is<arr.size(); ++is){
60
dump
<<
"side "
<<is<<
'\n'
;
61
for
(std::size_t ig=0; ig<arr[is].size(); ++ig){
62
63
dump
<<
"geom "
<<ig<<
'\n'
;
64
LineFormater
lf = std::for_each(arr[is][ig].begin(), arr[is][ig].end(),
LineFormater
(10));
65
dump
<<lf.toString()+
'\n'
;
66
67
}
68
}
69
return
dump
.str();
70
}
71
}
72
73
#endif
FPTracker::LineFormater
Definition
DataDumperHelpers.h:12
FPTracker::LineFormater::LineFormater
LineFormater(int numPerLine)
Definition
DataDumperHelpers.h:14
FPTracker::LineFormater::m_ost
std::ostringstream m_ost
Definition
DataDumperHelpers.h:28
FPTracker::LineFormater::operator()
void operator()(T t)
Definition
DataDumperHelpers.h:16
FPTracker::LineFormater::toString
std::string toString() const
Definition
DataDumperHelpers.h:24
FPTracker::LineFormater::m_maxPerLine
int m_maxPerLine
Definition
DataDumperHelpers.h:27
FPTracker::LineFormater::m_numPerLine
int m_numPerLine
Definition
DataDumperHelpers.h:26
FPTracker
Definition
FPTracker/FPTracker/Beamline.h:12
FPTracker::array2DToString
std::string array2DToString(const Array2D &arr)
Definition
DataDumperHelpers.h:43
FPTracker::array3DToString
std::string array3DToString(const Array3D &arr)
Definition
DataDumperHelpers.h:56
FPTracker::array1DToString
std::string array1DToString(const Array1D &arr)
Definition
DataDumperHelpers.h:32
dump
-event-from-file
Generated on
for ATLAS Offline Software by
1.14.0