| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Print.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <ctype.h>
7 #include <functional>
8 #include <string>
9 #include <vector>
10 // ============================================================================
11 // AIDA
12 // ============================================================================
13 #include "AIDA/IHistogram1D.h"
14 #include "AIDA/IHistogram2D.h"
15 #include "AIDA/IHistogram3D.h"
16 #include "AIDA/IProfile1D.h"
17 #include "AIDA/IProfile2D.h"
18 // ============================================================================
19 // GaudiKernel
20 // ============================================================================
21 #include "GaudiKernel/DataObject.h"
22 #include "GaudiKernel/INTuple.h"
23 #include "GaudiKernel/IRegistry.h"
24 #include "GaudiKernel/StatEntity.h"
25 // ============================================================================
26 // GaudiAlg
27 // ============================================================================
28 #include "GaudiAlg/HistoID.h"
29 #include "GaudiAlg/Print.h"
30 // ============================================================================
31 // Boost
32 // ============================================================================
33 #include "boost/format.hpp"
34 // ============================================================================
40 // ============================================================================
41 namespace
42 {
47 static const std::string s_invalidLocation = "<UNKNOWN LOCATION>";
48 }
49 // ============================================================================
50 const std::string& GaudiAlg::Print::location( const AIDA::IHistogram* aida )
51 {
52 if ( !aida ) {
53 return s_invalidLocation;
54 }
55 const DataObject* object = dynamic_cast<const DataObject*>( aida );
56 if ( !object ) {
57 return s_invalidLocation;
58 }
59 IRegistry* registry = object->registry();
60 if ( !registry ) {
61 return s_invalidLocation;
62 }
63 return registry->identifier();
64 }
65 // ============================================================================
66 void GaudiAlg::Print1D::print( MsgStream& stream, const AIDA::IHistogram1D* aida, const GaudiAlg::HistoID& ID )
67 {
68 stream << toString( aida, ID ) << endmsg;
69 }
70 // ============================================================================
71 std::string GaudiAlg::Print1D::toString( const AIDA::IHistogram1D* aida, const GaudiAlg::HistoID& ID )
72 {
73 boost::format fmt( " ID=%|-25|%|30t| \"%|.45s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|" );
74 fmt % ID.idAsString() % aida->title();
75 fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
76 fmt % aida->mean() % aida->rms();
77 //
78 return fmt.str();
79 }
80 // ============================================================================
81 void GaudiAlg::Print2D::print( MsgStream& stream, const AIDA::IHistogram2D* aida, const GaudiAlg::HistoID& ID )
82 {
83 stream << toString( aida, ID ) << endmsg;
84 }
85 // ============================================================================
86 std::string GaudiAlg::Print2D::toString( const AIDA::IHistogram2D* aida, const GaudiAlg::HistoID& ID )
87 {
88 boost::format fmt( " ID=%|-25|%|30t| \"%|.45s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|,<Y>/sY=%|.5|/%|-.5|" );
89 fmt % ID.idAsString() % aida->title();
90 fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
91 fmt % aida->meanX() % aida->rmsX();
92 fmt % aida->meanY() % aida->rmsY();
93 //
94 return fmt.str();
95 }
96 // ============================================================================
97 void GaudiAlg::Print3D::print( MsgStream& stream, const AIDA::IHistogram3D* aida, const GaudiAlg::HistoID& ID )
98 {
99 stream << toString( aida, ID ) << endmsg;
100 }
101 // ============================================================================
102 std::string GaudiAlg::Print3D::toString( const AIDA::IHistogram3D* aida, const GaudiAlg::HistoID& ID )
103 {
104 boost::format fmt( " ID=%|-25|%|30t| \"%|.45s|\" %|79t| "
105 "Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|,<Y>/sY=%|.5|/%|-.5|,<Z>/sZ=%|.5|/%|-.5|" );
106 fmt % ID.idAsString() % aida->title();
107 fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
108 fmt % aida->meanX() % aida->rmsX();
109 fmt % aida->meanY() % aida->rmsY();
110 fmt % aida->meanZ() % aida->rmsZ();
111 //
112 return fmt.str();
113 }
114 // ============================================================================
115 void GaudiAlg::Print1DProf::print( MsgStream& stream, const AIDA::IProfile1D* aida, const GaudiAlg::HistoID& ID )
116 {
117 stream << toString( aida, ID ) << endmsg;
118 }
119 // ============================================================================
120 std::string GaudiAlg::Print1DProf::toString( const AIDA::IProfile1D* aida, const GaudiAlg::HistoID& ID )
121 {
122 boost::format fmt( " ID=%|-25|%|30t| \"%|.55s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|" );
123 fmt % ID.idAsString() % aida->title();
124 fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
125 fmt % aida->mean() % aida->rms();
126 //
127 return fmt.str();
128 }
129 // ============================================================================
130 void GaudiAlg::Print2DProf::print( MsgStream& stream, const AIDA::IProfile2D* aida, const GaudiAlg::HistoID& ID )
131 {
132 stream << toString( aida, ID ) << endmsg;
133 }
134 // ============================================================================
135 std::string GaudiAlg::Print2DProf::toString( const AIDA::IProfile2D* aida, const GaudiAlg::HistoID& ID )
136 {
137 boost::format fmt( " ID=%|-25|%|30t| \"%|.55s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|,<Y>/sY=%|.5|/%|-.5|" );
138 fmt % ID.idAsString() % aida->title();
139 fmt % ( aida->allEntries() - aida->extraEntries() ) % aida->allEntries();
140 fmt % aida->meanX() % aida->rmsX();
141 fmt % aida->meanY() % aida->rmsY();
142 //
143 return fmt.str();
144 }
145 // ============================================================================
146 std::string GaudiAlg::PrintStat::print( const StatEntity& stat, const std::string& tag )
147 {
148 return Gaudi::Utils::formatAsTableRow( tag, stat );
149 }
150 // ============================================================================
151 std::string GaudiAlg::PrintTuple::print( const INTuple* tuple, const GaudiAlg::TupleID& ID )
152 {
153 boost::format fmt( " ID=%|-12|%|18t|%|-s|" );
154 fmt % ID.idAsString() % print( tuple );
155 return fmt.str();
156 }
157 // ============================================================================
158 namespace
159 {
160 std::string _print( const INTuple::ItemContainer& items )
161 {
162 std::string str;
163 for ( const auto& item : items ) {
164 if ( !item ) {
165 continue;
166 }
167 if ( !str.empty() ) {
168 str += ",";
169 }
170 str += item->name();
171 if ( 0 != item->ndim() ) {
172 str += '[' + std::to_string( item->ndim() ) + ']';
173 }
174 if ( item->hasIndex() ) {
175 str += "/V";
176 }
177 }
178 return str;
179 }
180 }
181 // ============================================================================
182 std::string GaudiAlg::PrintTuple::print( const INTuple* tuple )
183 {
184 boost::format fmt( "Title=\"%|.39s|\" %|48t|#items=%|-3|%|50t|{%|.81s|}" );
185 fmt % tuple->title();
186 fmt % tuple->items().size();
187 fmt % _print( tuple->items() );
188 return fmt.str();
189 }
190 // ============================================================================
191
192 // ============================================================================
193 // The END
194 // ============================================================================
GaudiAlg::PrintTuple::print
static std::string print(const INTuple *tuple, const GaudiAlg::TupleID &ID)
Definition: Print.cpp:151
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::string::empty
T empty(T...args)
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
GaudiAlg::PrintStat::print
static std::string print(const StatEntity &stat, const std::string &tag)
Definition: Print.cpp:146
GaudiAlg::Print3D::print
static void print(MsgStream &stream, const AIDA::IHistogram3D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:97
std::to_string
T to_string(T...args)
GaudiAlg::Print1D::toString
static std::string toString(const AIDA::IHistogram1D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:71
GaudiAlg::Print1DProf::print
static void print(MsgStream &stream, const AIDA::IProfile1D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:115
Gaudi::Utils::formatAsTableRow
GAUDI_API std::string formatAsTableRow(const StatEntity &counter, const bool flag, const std::string &format1=" |%|7d| |%|11.7g| |%|#11.5g| |%|#10.5g| |%|#10.5g| |%|#10.5g| |", const std::string &format2="*|%|7d| |%|11.5g| |(%|#9.7g| +- %|-#8.6g|)%%| ----- | ----- |")
print the counter in a form of the table row
Definition: StatEntity.cpp:305
std::string
STL class.
INTuple
NTuple interface class definition.
Definition: INTuple.h:82
HistoID.h
IRegistry::identifier
virtual const id_type & identifier() const =0
Full identifier (or key)
INTuple.h
GaudiAlg::Print::location
static const std::string & location(const AIDA::IHistogram *aida)
Definition: Print.cpp:50
IRegistry.h
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
Print.h
collection of useful utilities to print certain objects (currently used for implementation in class G...
GaudiAlg::Print3D::toString
static std::string toString(const AIDA::IHistogram3D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:102
GaudiPluginService.cpluginsvc.registry
def registry()
Definition: cpluginsvc.py:70
GaudiAlg::Print1D::print
static void print(MsgStream &stream, const AIDA::IHistogram1D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:66
std::vector::size
T size(T...args)
std::vector
STL class.
print
void print(string text)
Definition: mergesort.cpp:30
GaudiAlg::Print2DProf::print
static void print(MsgStream &stream, const AIDA::IProfile2D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:130
StatEntity.h
GaudiAlg::ID::idAsString
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
Definition: GaudiHistoID.cpp:20
GaudiAlg::Print2D::print
static void print(MsgStream &stream, const AIDA::IHistogram2D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:81
GaudiAlg::Print2D::toString
static std::string toString(const AIDA::IHistogram2D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:86
INTuple::items
virtual ItemContainer & items()=0
Access item container.
GaudiAlg::Print1DProf::toString
static std::string toString(const AIDA::IProfile1D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:120
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
INTuple::title
virtual const std::string & title() const =0
Object title.
GaudiAlg::Print2DProf::toString
static std::string toString(const AIDA::IProfile2D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:135
GaudiAlg::ID
ID class for Histogram and Ntuples.
Definition: GaudiHistoID.h:44
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
GaudiMath::Interpolation::toString
std::string toString(const Type &)
Definition: Interpolation.cpp:42
DataObject.h