| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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
8 ( const std::string& title ,
9 const HistoBinEdges& edgesX ,
10 const HistoBinEdges& edgesY ,
11 const HistoBinEdges& edgesZ ) const
12 {
13 //
14 if ( !produceHistos() ) { return nullptr; } // RETURN
15 //
16 // exist?
17 auto hist = histo3D ( title ) ;
18 // histogram is already booked
19 if( hist ) { return hist ; } // RETURN !!
20
21 // propose the histogram ID
22 HistoID ID;
23 newHistoID( title, ID );
24
25 // Create a new histogram and return
26 return this -> book3D ( ID, title, edgesX, edgesY, edgesZ );
27 }
28 // ============================================================================
29 // book the 2D histogram with forced ID (book on demand)
30 // ============================================================================
31 template <class PBASE>
32 AIDA::IHistogram3D* GaudiHistos<PBASE>::book3D
33 ( const HistoID& ID ,
34 const std::string& title ,
35 const HistoBinEdges& edgesX ,
36 const HistoBinEdges& edgesY ,
37 const HistoBinEdges& edgesZ ) const
38 {
39 //
40 if ( !produceHistos() ) { return nullptr; } // RETURN
41 //
42 // Check ID
43 if (ID.undefined())
44 {
45 this->Error("Undefined Histogram ID : Title='"+title+"'");
46 return nullptr;
47 }
48
49 // exist?
50 auto hist = histo3D ( ID ) ;
51 // histogram is already booked
52 if ( hist ) { return hist ; } // RETURN !!
53
54 // Histogram title
55 const std::string & htitle =
56 ( title.empty() ? "Unnamed 3D Histogram ID="+ID.idAsString() : title ) ;
57
58 // book the histogram
59 if ( ID.numeric() )
60 {
61 hist = this->histoSvc() -> book ( histoPath() ,
62 ID.numericID() ,
63 htitle ,
64 edgesX ,
65 edgesY ,
66 edgesZ ) ;
67 }
68 else if ( ID.literal() )
69 {
70 hist = this->histoSvc() -> book ( histoPath()+"/"+
71 ID.literalID() ,
72 htitle ,
73 edgesX ,
74 edgesY ,
75 edgesZ ) ;
76 }
77
78 // check OK
79 if( !hist )
80 { this->Error( "IHistogram3D* points to NULL! ID='" + ID.idAsString() +
81 "' title='"+htitle+"'" ) ; return nullptr; } // RETURN !!
82
83 // add histogram into histogram storages
84 m_histo3DMapID [ ID ] = hist ;
85 m_histo3DMapTitle [ title ] = hist ;
86
87 // Declare to monitoring service
88 monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
89
90 // Printout and return
91 if ( this->msgLevel(MSG::DEBUG) )
92 { this->debug() << "Booked 3D Histogram : ID='" << ID
93 << "' Path=" << histoPath()
94 << " Title='"
95 << Gaudi::Utils::Histos::htitle ( hist )
96 << "'" << endmsg; }
97 return hist ;
98 }
99 // ============================================================================
100 // fill the 3D histogram (book on demand)
101 // ============================================================================
102 template <class PBASE>
103 AIDA::IHistogram3D*
104 GaudiHistos<PBASE>::plot3D
105 ( const double valueX ,
106 const double valueY ,
107 const double valueZ ,
108 const std::string& title ,
109 const HistoBinEdges& edgesX ,
110 const HistoBinEdges& edgesY ,
111 const HistoBinEdges& edgesZ ,
112 const double weight ) const
113 {
114 AIDA::IHistogram3D * h(nullptr);
115 if ( produceHistos() )
116 {
117 // retrieve or book the histogram
118 h = histo3D ( title ) ;
119 if ( !h ) { h = book3D ( title , edgesX , edgesY , edgesZ ) ; }
120 // fill the histogram
121 h = fill ( h , valueX , valueY , valueZ , weight , title );
122 }
123 return h;
124 }
125 // ============================================================================
126 // fill the 3D variable histogram with forced ID assignment (book on demand)
127 // ============================================================================
128 template <class PBASE>
129 AIDA::IHistogram3D*
130 GaudiHistos<PBASE>::plot3D
131 ( const double valueX ,
132 const double valueY ,
133 const double valueZ ,
134 const HistoID& ID ,
135 const std::string& title ,
136 const HistoBinEdges& edgesX ,
137 const HistoBinEdges& edgesY ,
138 const HistoBinEdges& edgesZ ,
139 const double weight ) const
140 {
141 AIDA::IHistogram3D * h(nullptr);
142 if ( produceHistos() )
143 {
144 // retrieve or book the histogram
145 h = histo3D ( ID ) ;
146 if ( !h ) { h = book3D ( ID , title , edgesX , edgesY , edgesZ ) ; }
147 // fill
148 h = fill ( h , valueX , valueY , valueZ , weight , title ) ;
149 }
150 return h;
151 }
152 // ============================================================================
153 // The END
154 // ============================================================================
155
Gaudi::Utils::Histos::htitle
GAUDI_API std::string htitle(const AIDA::IBaseHistogram *histo, const std::string &title="")
get the title
Definition: Fill.cpp:138
std::string::empty
T empty(T...args)
Gaudi::Histos::book
GAUDI_API AIDA::IHistogram1D * book(IHistogramSvc *svc, const std::string &path, const Gaudi::Histo1DDef &hist)
helper function to book 1D-histogram
Definition: HistoDef.cpp:124
GaudiAlg::ID::numericID
NumericID numericID() const noexcept
Returns the numerical ID.
Definition: GaudiHistoID.h:82
MSG::DEBUG
Definition: IMessageSvc.h:18
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:36
std::string
STL class.
HiveAlgSequencer.h
h
Definition: HiveAlgSequencer.py:24
GaudiAlg::ID::literal
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:76
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:166
GaudiAlg::ID::literalID
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:80
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:74
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:8
Gaudi::Utils::Histos::toBase
GAUDI_API AIDA::IBaseHistogram * toBase(AIDA::IHistogram1D *histo)
Definition: Fill.cpp:193
GaudiAlg::ID::undefined
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:78
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