| The Gaudi Framework v27r1

- 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 <string>
8 #include <vector>
9 #include <functional>
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/IRegistry.h"
23 #include "GaudiKernel/StatEntity.h"
24 #include "GaudiKernel/INTuple.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
51 ( const AIDA::IHistogram* aida )
52 {
53 if ( !aida ) { return s_invalidLocation ; }
54 const DataObject* object = dynamic_cast<const DataObject*>( aida ) ;
55 if ( !object ) { return s_invalidLocation ; }
56 IRegistry* registry = object->registry() ;
57 if ( !registry ) { return s_invalidLocation ; }
58 return registry->identifier() ;
59 }
60 // ============================================================================
61 void GaudiAlg::Print1D::print
62 ( MsgStream & stream,
63 const AIDA::IHistogram1D* aida ,
64 const GaudiAlg::HistoID& ID )
65 { stream << toString ( aida , ID ) << endmsg ; }
66 // ============================================================================
67 std::string GaudiAlg::Print1D::toString
68 ( const AIDA::IHistogram1D* aida ,
69 const GaudiAlg::HistoID& ID )
70 {
71 boost::format fmt
72 ( " ID=%|-25|%|30t| \"%|.45s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|" ) ;
73 fmt % ID.idAsString() % aida->title();
74 fmt % (aida->allEntries()-aida->extraEntries()) % aida->allEntries() ;
75 fmt % aida->mean() % aida->rms() ;
76 //
77 return fmt.str() ;
78 }
79 // ============================================================================
80 void GaudiAlg::Print2D::print
81 ( MsgStream & stream,
82 const AIDA::IHistogram2D* aida ,
83 const GaudiAlg::HistoID& ID )
84 { stream << toString ( aida , ID ) << endmsg ; }
85 // ============================================================================
86 std::string GaudiAlg::Print2D::toString
87 ( const AIDA::IHistogram2D* aida ,
88 const GaudiAlg::HistoID& ID )
89 {
90 boost::format fmt
91 ( " ID=%|-25|%|30t| \"%|.45s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|,<Y>/sY=%|.5|/%|-.5|" ) ;
92 fmt % ID.idAsString() % aida->title();
93 fmt % (aida->allEntries()-aida->extraEntries()) % aida->allEntries() ;
94 fmt % aida->meanX() % aida->rmsX() ;
95 fmt % aida->meanY() % aida->rmsY() ;
96 //
97 return fmt.str() ;
98 }
99 // ============================================================================
100 void GaudiAlg::Print3D::print
101 ( MsgStream & stream,
102 const AIDA::IHistogram3D* aida ,
103 const GaudiAlg::HistoID& ID )
104 { stream << toString ( aida , ID ) << endmsg ; }
105 // ============================================================================
106 std::string GaudiAlg::Print3D::toString
107 ( const AIDA::IHistogram3D* aida ,
108 const GaudiAlg::HistoID& ID )
109 {
110 boost::format fmt
111 ( " ID=%|-25|%|30t| \"%|.45s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|,<Y>/sY=%|.5|/%|-.5|,<Z>/sZ=%|.5|/%|-.5|" ) ;
112 fmt % ID.idAsString() % aida->title();
113 fmt % (aida->allEntries()-aida->extraEntries()) % aida->allEntries() ;
114 fmt % aida->meanX() % aida->rmsX() ;
115 fmt % aida->meanY() % aida->rmsY() ;
116 fmt % aida->meanZ() % aida->rmsZ() ;
117 //
118 return fmt.str() ;
119 }
120 // ============================================================================
121 void GaudiAlg::Print1DProf::print
122 ( MsgStream & stream,
123 const AIDA::IProfile1D* aida ,
124 const GaudiAlg::HistoID& ID )
125 { stream << toString ( aida , ID ) << endmsg ; }
126 // ============================================================================
127 std::string GaudiAlg::Print1DProf::toString
128 ( const AIDA::IProfile1D* aida ,
129 const GaudiAlg::HistoID& ID )
130 {
131 boost::format fmt
132 ( " ID=%|-25|%|30t| \"%|.55s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|" ) ;
133 fmt % ID.idAsString() % aida->title();
134 fmt % (aida->allEntries()-aida->extraEntries()) % aida->allEntries() ;
135 fmt % aida->mean() % aida->rms() ;
136 //
137 return fmt.str() ;
138 }
139 // ============================================================================
140 void GaudiAlg::Print2DProf::print
141 ( MsgStream & stream,
142 const AIDA::IProfile2D* aida ,
143 const GaudiAlg::HistoID& ID )
144 { stream << toString ( aida , ID ) << endmsg ; }
145 // ============================================================================
146 std::string GaudiAlg::Print2DProf::toString
147 ( const AIDA::IProfile2D* aida ,
148 const GaudiAlg::HistoID& ID )
149 {
150 boost::format fmt
151 ( " ID=%|-25|%|30t| \"%|.55s|\" %|79t| Ents/All=%|5|/%|-5|<X>/sX=%|.5|/%|-.5|,<Y>/sY=%|.5|/%|-.5|" );
152 fmt % ID.idAsString() % aida->title();
153 fmt % (aida->allEntries()-aida->extraEntries()) % aida->allEntries() ;
154 fmt % aida->meanX() % aida->rmsX() ;
155 fmt % aida->meanY() % aida->rmsY() ;
156 //
157 return fmt.str() ;
158 }
159 // ============================================================================
160 std::string GaudiAlg::PrintStat::print
161 ( const StatEntity& stat ,
162 const std::string& tag )
163 {
164 return Gaudi::Utils::formatAsTableRow ( tag , stat ) ;
165 }
166 // ============================================================================
167 std::string GaudiAlg::PrintTuple::print
168 ( const INTuple* tuple ,
169 const GaudiAlg::TupleID& ID )
170 {
171 boost::format fmt ( " ID=%|-12|%|18t|%|-s|") ;
172 fmt % ID.idAsString() % print ( tuple ) ;
173 return fmt.str() ;
174 }
175 // ============================================================================
176 namespace
177 {
178 std::string _print ( const INTuple::ItemContainer& items )
179 {
180 std::string str ;
181 for ( const auto& item : items )
182 {
183 if ( !item ) { continue ; }
184 if ( !str.empty() ) { str +="," ; }
185 str += item->name() ;
186 if ( 0 != item->ndim() )
187 { str += '[' + std::to_string( item->ndim() ) + ']'; }
188 if ( item->hasIndex() ) { str += "/V" ; }
189 }
190 return str ;
191 }
192 }
193 // ============================================================================
194 std::string GaudiAlg::PrintTuple::print
195 ( const INTuple* tuple )
196 {
197 boost::format fmt
198 ( "Title=\"%|.39s|\" %|48t|#items=%|-3|%|50t|{%|.81s|}" ) ;
199 fmt % tuple->title() ;
200 fmt % tuple->items().size() ;
201 fmt % _print( tuple->items() ) ;
202 return fmt.str() ;
203 }
204 // ============================================================================
205
206 // ============================================================================
207 // The END
208 // ============================================================================
GaudiAlg::PrintTuple::print
static std::string print(const INTuple *tuple, const GaudiAlg::TupleID &ID)
Definition: Print.cpp:168
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:119
GaudiAlg::PrintStat::print
static std::string print(const StatEntity &stat, const std::string &tag)
Definition: Print.cpp:161
GaudiAlg::Print3D::print
static void print(MsgStream &stream, const AIDA::IHistogram3D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:101
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:371
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:68
INTuple::title
virtual const std::string & title() const =0
Object title.
GaudiAlg::Print1DProf::print
static void print(MsgStream &stream, const AIDA::IProfile1D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:122
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:299
std::string
STL class.
INTuple
NTuple interface class definition.
Definition: INTuple.h:79
HistoID.h
INTuple.h
GaudiAlg::Print::location
static const std::string & location(const AIDA::IHistogram *aida)
Definition: Print.cpp:51
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:107
GaudiPluginService.cpluginsvc.registry
def registry()
Definition: cpluginsvc.py:63
GaudiAlg::Print1D::print
static void print(MsgStream &stream, const AIDA::IHistogram1D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:62
std::vector::size
T size(T...args)
std::vector
STL class.
print
void print(string text)
Definition: mergesort.cpp:33
GaudiAlg::Print2DProf::print
static void print(MsgStream &stream, const AIDA::IProfile2D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:141
StatEntity.h
GaudiAlg::ID::idAsString
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
Definition: GaudiHistoID.cpp:47
ana.item
tuple item
print s1,s2
Definition: ana.py:146
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:87
IRegistry::identifier
virtual const id_type & identifier() const =0
Full identifier (or key)
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:128
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:64
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
GaudiAlg::Print2DProf::toString
static std::string toString(const AIDA::IProfile2D *aida, const GaudiAlg::HistoID &ID)
Definition: Print.cpp:147
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:244
DataObject.h