| The Gaudi Framework v30r0 (c919700c)

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

- File List
- File Members

GaudiHistos_3DVariableBinning.icpp
Go to the documentation of this file.
1 // ==================================== 3D ====================================
2 // ============================= Variable Binning =============================
3 // ============================================================================
4 // book the 3D histogram (book on demand)
5 // ============================================================================
6 template <class PBASE>
7 AIDA::IHistogram3D* GaudiHistos<PBASE>::book3D( const std::string& title, const HistoBinEdges& edgesX,
8 const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ ) const
9 {
10 //
11 if ( !produceHistos() ) {
12 return nullptr;
13 } // RETURN
14 //
15 // exist?
16 auto hist = histo3D( title );
17 // histogram is already booked
18 if ( hist ) {
19 return hist;
20 } // RETURN !!
21
22 // propose the histogram ID
23 HistoID ID;
24 newHistoID( title, ID );
25
26 // Create a new histogram and return
27 return this->book3D( ID, title, edgesX, edgesY, edgesZ );
28 }
29 // ============================================================================
30 // book the 2D histogram with forced ID (book on demand)
31 // ============================================================================
32 template <class PBASE>
33 AIDA::IHistogram3D* GaudiHistos<PBASE>::book3D( const HistoID& ID, const std::string& title,
34 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
35 const HistoBinEdges& edgesZ ) const
36 {
37 //
38 if ( !produceHistos() ) {
39 return nullptr;
40 } // RETURN
41 //
42 // Check ID
43 if ( ID.undefined() ) {
44 this->Error( "Undefined Histogram ID : Title='" + title + "'" ).ignore();
45 return nullptr;
46 }
47
48 // exist?
49 auto hist = histo3D( ID );
50 // histogram is already booked
51 if ( hist ) {
52 return hist;
53 } // RETURN !!
54
55 // Histogram title
56 const std::string& htitle = ( title.empty() ? "Unnamed 3D Histogram ID=" + ID.idAsString() : title );
57
58 // book the histogram
59 if ( ID.numeric() ) {
60 hist = this->histoSvc()->book( histoPath(), ID.numericID(), htitle, edgesX, edgesY, edgesZ );
61 } else if ( ID.literal() ) {
62 hist = this->histoSvc()->book( histoPath() + "/" + ID.literalID(), htitle, edgesX, edgesY, edgesZ );
63 }
64
65 // check OK
66 if ( !hist ) {
67 this->Error( "IHistogram3D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" ).ignore();
68 return nullptr;
69 } // RETURN !!
70
71 // add histogram into histogram storages
72 m_histo3DMapID[ID] = hist;
73 m_histo3DMapTitle[title] = hist;
74
75 // Declare to monitoring service
76 monitorHisto( Gaudi::Utils::Histos::toBase( hist ), ID );
77
78 // Printout and return
79 if ( this->msgLevel( MSG::DEBUG ) ) {
80 this->debug() << "Booked 3D Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
81 << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
82 }
83 return hist;
84 }
85 // ============================================================================
86 // fill the 3D histogram (book on demand)
87 // ============================================================================
88 template <class PBASE>
89 AIDA::IHistogram3D* GaudiHistos<PBASE>::plot3D( const double valueX, const double valueY, const double valueZ,
90 const std::string& title, const HistoBinEdges& edgesX,
91 const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ,
92 const double weight ) const
93 {
94 AIDA::IHistogram3D* h( nullptr );
95 if ( produceHistos() ) {
96 // retrieve or book the histogram
97 h = histo3D( title );
98 if ( !h ) {
99 h = book3D( title, edgesX, edgesY, edgesZ );
100 }
101 // fill the histogram
102 h = fill( h, valueX, valueY, valueZ, weight, title );
103 }
104 return h;
105 }
106 // ============================================================================
107 // fill the 3D variable histogram with forced ID assignment (book on demand)
108 // ============================================================================
109 template <class PBASE>
110 AIDA::IHistogram3D* GaudiHistos<PBASE>::plot3D( const double valueX, const double valueY, const double valueZ,
111 const HistoID& ID, const std::string& title,
112 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY,
113 const HistoBinEdges& edgesZ, const double weight ) const
114 {
115 AIDA::IHistogram3D* h( nullptr );
116 if ( produceHistos() ) {
117 // retrieve or book the histogram
118 h = histo3D( ID );
119 if ( !h ) {
120 h = book3D( ID, title, edgesX, edgesY, edgesZ );
121 }
122 // fill
123 h = fill( h, valueX, valueY, valueZ, weight, title );
124 }
125 return h;
126 }
127 // ============================================================================
128 // The END
129 // ============================================================================
Gaudi::Utils::Histos::htitle
GAUDI_API std::string htitle(const AIDA::IBaseHistogram *histo, const std::string &title="")
get the title
Definition: Fill.cpp:126
std::string::empty
T empty(T...args)
GaudiAlg::ID::numericID
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:74
MSG::DEBUG
Definition: IMessageSvc.h:16
Gaudi::Utils::Histos::fill
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
Definition: Fill.cpp:35
std::string
STL class.
GaudiAlg::ID::literal
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:68
std::vector< double >
GaudiHistos::plot3D
AIDA::IHistogram3D * plot3D(const double valueX, const double valueY, const double valueZ, const std::string &title, const double lowX, const double highX, const double lowY, const double highY, const double lowZ, const double highZ, const unsigned long binsX=10, const unsigned long binsY=10, const unsigned long binsZ=10, const double weight=1.0) const
fill the 3D histogram (book on demand)
Definition: GaudiHistos_3DFixedBinning.icpp:123
GaudiAlg::ID::literalID
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:72
GaudiAlg::ID::idAsString
GAUDI_API LiteralID idAsString() const
Return ID as string, for both numeric and literal IDs.
Definition: GaudiHistoID.cpp:20
GaudiAlg::ID::numeric
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:66
GaudiHistos::book3D
AIDA::IHistogram3D * book3D(const std::string &title, const double lowX=0, const double highX=100, const unsigned long binsX=10, const double lowY=0, const double highY=100, const unsigned long binsY=10, const double lowZ=0, const double highZ=100, const unsigned long binsZ=10) const
book the 3D histogram
Definition: GaudiHistos_3DFixedBinning.icpp:7
Gaudi::Utils::Histos::toBase
GAUDI_API AIDA::IBaseHistogram * toBase(AIDA::IHistogram1D *histo)
Definition: Fill.cpp:180
GaudiAlg::ID::undefined
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:70
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