| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- File List
- File Members

GaudiHistos_2DProfVariableBinning.icpp
Go to the documentation of this file.
1 // ============================================================================
2 // book the 2D profile histogram (book on demand)
3 // ============================================================================
4 template <class PBASE>
5 AIDA::IProfile2D* GaudiHistos<PBASE>::bookProfile2D
6 ( const std::string& title ,
7 const HistoBinEdges& edgesX,
8 const HistoBinEdges& edgesY ) const
9 {
10 //
11 if ( !produceHistos() ) { return 0 ; } // RETURN
12 //
13 // exist?
14 auto hist = profile2D ( title ) ;
15 // histogram is already booked
16 if( hist ) { return hist ; } // RETURN !!
17
18 // propose the histogram ID
19 HistoID ID;
20 newHistoID( title, ID );
21
22 // book histogram and return
23 return this -> bookProfile2D ( ID, title, edgesX, edgesY );
24 }
25 // ============================================================================
26 // book the 2D profile histogram with forced ID (book on demand)
27 // ============================================================================
28 template <class PBASE>
29 AIDA::IProfile2D* GaudiHistos<PBASE>::bookProfile2D
30 ( const HistoID& ID ,
31 const std::string& title ,
32 const HistoBinEdges& edgesX ,
33 const HistoBinEdges& edgesY ) const
34 {
35 //
36 if ( !produceHistos() ) { return 0 ; } // RETURN
37 //
38 // Check ID
39 if (ID.undefined())
40 {
41 this->Error("Undefined Histogram ID : Title='"+title+"'");
42 return nullptr;
43 }
44 // exist?
45 auto hist = profile2D ( ID ) ;
46 // histogram is already booked
47 if( hist ) { return hist ; } // RETURN !!
48
49 // Histogram title
50 const std::string & htitle =
51 ( title.empty() ?
52 "Unnamed 2D Profile Histogram ID="+ID.idAsString() : title ) ;
53
54 // book the histogram
55 if ( ID.numeric() )
56 {
57 hist = this->histoSvc() -> bookProf ( histoPath() ,
58 ID.numericID() ,
59 htitle ,
60 edgesX ,
61 edgesY ) ;
62 }
63 else if ( ID.literal() )
64 {
65 hist = this->histoSvc() -> bookProf ( histoPath()+"/"+
66 ID.literalID() ,
67 htitle ,
68 edgesX ,
69 edgesY ) ;
70 }
71
72 // test OK
73 if( !hist )
74 { this->Error( "IProfile2D* points to NULL! ID='" + ID.idAsString() +
75 "' title='"+htitle+"'" ) ; return nullptr; } // RETURN !!
76
77 // add histogram into histogram storages
78 m_profile2DMapID [ ID ] = hist ;
79 m_profile2DMapTitle [ title ] = hist ;
80
81 // Declare to monitoring service
82 monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
83
84 // printout and return
85 if ( this->msgLevel(MSG::DEBUG) )
86 { this->debug() << "Booked 2D Profile Histogram : ID='" << ID
87 << "' Path=" << histoPath()
88 << " Title='"
89 << Gaudi::Utils::Histos::htitle ( hist )
90 << "'" << endmsg; }
91 return hist ;
92 }
93 // ============================================================================
94 // fill the 2D profile histogram (book on demand)
95 // ============================================================================
96 template <class PBASE>
97 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D
98 ( const double valueX ,
99 const double valueY ,
100 const double valueZ ,
101 const std::string& title ,
102 const HistoBinEdges& edgesX ,
103 const HistoBinEdges& edgesY ,
104 const double weight ) const
105 {
106 AIDA::IProfile2D * h(nullptr);
107 if ( produceHistos() )
108 {
109 // retrieve or book the histogram
110 h = profile2D ( title ) ;
111 if ( !h ) { h = bookProfile2D ( title, edgesX, edgesY ) ; }
112 // fill the histogram
113 h = fill ( h , valueX , valueY , valueZ , weight , title ) ;
114 }
115 return h;
116 }
117 // ============================================================================
118 // fill the 2D profile histogram with forced ID assignment (book on demand)
119 // ============================================================================
120 template <class PBASE>
121 AIDA::IProfile2D* GaudiHistos<PBASE>::profile2D
122 ( const double valueX ,
123 const double valueY ,
124 const double valueZ ,
125 const HistoID& ID ,
126 const std::string& title ,
127 const HistoBinEdges& edgesX ,
128 const HistoBinEdges& edgesY ,
129 const double weight ) const
130 {
131 AIDA::IProfile2D * h(nullptr);
132 if ( produceHistos() )
133 {
134 // retrieve or book the histogram
135 h = profile2D ( ID ) ;
136 if ( !h ) { h = bookProfile2D ( ID , title , edgesX , edgesY ) ; }
137
138 // fill the histogram
139 h = fill ( h , valueX , valueY , valueZ , weight , title ) ;
140 }
141 return h;
142 }
143 // ============================================================================
144 // The END
145 // ============================================================================
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)
GaudiHistos::bookProfile2D
AIDA::IProfile2D * bookProfile2D(const std::string &title, const double lowX=0, const double highX=100, const unsigned long binsX=50, const double lowY=0, const double highY=100, const unsigned long binsY=50) const
book the 2D profile histogram
Definition: GaudiHistos_2DProfFixedBinning.icpp:6
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 >
GaudiPython.HistoUtils.bookProf
def bookProf(args, kwargs)
The trivial function to book 1D&2D profile histograms:
Definition: HistoUtils.py:232
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
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
GaudiHistos::profile2D
AIDA::IProfile2D * profile2D(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 unsigned long binsX=50, const unsigned long binsY=50, const double weight=1.0) const
fill the 2D profile histogram (book on demand)
Definition: GaudiHistos_2DProfFixedBinning.icpp:149
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