| The Gaudi Framework v32r1 (f65d50dc)

GaudiHistos_1DProfVariableBinning.icpp
Go to the documentation of this file.
1 // ============================================================================
2 // book the 1D profile histogram (book on demand)
3 // ============================================================================
4 template <class PBASE>
5 AIDA::IProfile1D* GaudiHistos<PBASE>::bookProfile1D( const std::string& title, const HistoBinEdges& edges ) const {
6 //
7 if ( !produceHistos() ) { return nullptr; } // RETURN
8 //
9 // exist?
10 auto hist = profile1D( title );
11 // histogram is already booked
12 if ( hist ) { return hist; } // RETURN !!
13
14 // propose the histogram ID
15 HistoID ID;
16 newHistoID( title, ID );
17
18 // Book the histo and return
19 return this->bookProfile1D( ID, title, edges );
20 }
21 // ============================================================================
22 // book the 1D profile histogram with forced ID (book on demand)
23 // ============================================================================
24 template <class PBASE>
25 AIDA::IProfile1D* GaudiHistos<PBASE>::bookProfile1D( const HistoID& ID, const std::string& title,
26 const HistoBinEdges& edges ) const {
27 //
28 if ( !produceHistos() ) { return nullptr; } // RETURN
29 //
30 // Check ID
31 if ( ID.undefined() ) {
32 this->Error( "Undefined Histogram ID : Title='" + title + "'" ).ignore();
33 return nullptr;
34 }
35
36 // exist?
37 auto hist = profile1D( ID );
38 // histogram is already booked
39 if ( hist ) { return hist; } // RETURN !!
40
41 // Histogram title
42 const std::string& htitle = ( title.empty() ? "Unnamed 1D Profile Histogram ID=" + ID.idAsString() : title );
43
44 // book the histogram
45 if ( ID.numeric() ) {
46 hist = this->histoSvc()->bookProf( histoPath(), ID.numericID(), htitle, edges );
47 } else if ( ID.literal() ) {
48 hist = this->histoSvc()->bookProf( histoPath() + "/" + ID.literalID(), htitle, edges );
49 }
50
51 // test ok
52 if ( !hist ) {
53 this->Error( "IProfile1D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" ).ignore();
54 return nullptr;
55 } // RETURN !!
56
57 // add histogram into histogram storages
58 m_profile1DMapID[ID] = hist;
59 m_profile1DMapTitle[title] = hist;
60
61 // Declare to monitoring service
62 monitorHisto( Gaudi::Utils::Histos::toBase( hist ), ID );
63
64 // printout and return
65 if ( this->msgLevel( MSG::DEBUG ) ) {
66 this->debug() << "Booked 1D Profile Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
67 << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
68 }
69 return hist;
70 }
71 // ============================================================================
72 // fill the 1D profile histogram (book on demand)
73 // ============================================================================
74 template <class PBASE>
75 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const std::string& title,
76 const HistoBinEdges& edges, const double weight ) const {
77 AIDA::IProfile1D* h( nullptr );
78 if ( produceHistos() ) {
79 // retrieve or book the histogram
80 h = profile1D( title );
81 if ( !h ) { h = bookProfile1D( title, edges ); }
82 // fill the histogram
83 h = fill( h, valueX, valueY, weight, title );
84 }
85 return h;
86 }
87 // ============================================================================
88 // fill the 1D profile histogram with forced ID assignment (book on demand)
89 // ============================================================================
90 template <class PBASE>
91 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const HistoID& ID,
92 const std::string& title, const HistoBinEdges& edges,
93 const double weight ) const {
94 AIDA::IProfile1D* h( nullptr );
95 if ( produceHistos() ) {
96 // retrieve or book the histogram
97 h = profile1D( ID );
98 if ( !h ) { h = bookProfile1D( ID, title, edges ); }
99 // fill the histogram
100 h = fill( h, valueX, valueY, weight, title );
101 }
102 return h;
103 }
104 // ============================================================================
105 // The END
106 // ============================================================================
GaudiAlg::ID::literalID
const LiteralID & literalID() const noexcept
Returns the ID as a LiteralID.
Definition: GaudiHistoID.h:70
Gaudi::Utils::Histos::htitle
GAUDI_API std::string htitle(const AIDA::IBaseHistogram *histo, const std::string &title="")
get the title
Definition: Fill.cpp:109
std::string::empty
T empty(T... args)
MSG::DEBUG
Definition: IMessageSvc.h:15
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::numericID
NumericID numericID() const noexcept
Returns the numerical ID.
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::undefined
bool undefined() const noexcept
Is this ID undefined.
Definition: GaudiHistoID.h:68
GaudiAlg::ID::literal
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:66
GaudiHistos::profile1D
AIDA::IProfile1D * profile1D(const double valueX, const double valueY, const std::string &title, const double lowX, const double highX, const unsigned long binsX=100, const std::string &opt="", const double lowY=-std::numeric_limits< double >::max(), const double highY=std::numeric_limits< double >::max(), const double weight=1.0) const
fill the 1D profile histogram (book on demand)
Definition: GaudiHistos_1DProfFixedBinning.icpp:104
GaudiHistos::bookProfile1D
AIDA::IProfile1D * bookProfile1D(const std::string &title, const double low=0, const double high=100, const unsigned long bins=100, const std::string &opt="", const double lowY=-std::numeric_limits< double >::max(), const double highY=std::numeric_limits< double >::max()) const
book the 1D profile histogram
Definition: GaudiHistos_1DProfFixedBinning.icpp:5
std::vector< double >
GaudiAlg::ID::numeric
bool numeric() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:64
Gaudi::Utils::Histos::toBase
GAUDI_API AIDA::IBaseHistogram * toBase(AIDA::IHistogram1D *histo)
Definition: Fill.cpp:155
GaudiAlg::ID
ID class for Histogram and Ntuples.
Definition: GaudiHistoID.h:43
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192