| The Gaudi Framework v29r0 (ff2e7097)

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

- File List
- File Members

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 //
8 if ( !produceHistos() ) {
9 return nullptr;
10 } // RETURN
11 //
12 // exist?
13 auto hist = profile1D( title );
14 // histogram is already booked
15 if ( hist ) {
16 return hist;
17 } // RETURN !!
18
19 // propose the histogram ID
20 HistoID ID;
21 newHistoID( title, ID );
22
23 // Book the histo and return
24 return this->bookProfile1D( ID, title, edges );
25 }
26 // ============================================================================
27 // book the 1D profile histogram with forced ID (book on demand)
28 // ============================================================================
29 template <class PBASE>
30 AIDA::IProfile1D* GaudiHistos<PBASE>::bookProfile1D( const HistoID& ID, const std::string& title,
31 const HistoBinEdges& edges ) const
32 {
33 //
34 if ( !produceHistos() ) {
35 return nullptr;
36 } // RETURN
37 //
38 // Check ID
39 if ( ID.undefined() ) {
40 this->Error( "Undefined Histogram ID : Title='" + title + "'" );
41 return nullptr;
42 }
43
44 // exist?
45 auto hist = profile1D( ID );
46 // histogram is already booked
47 if ( hist ) {
48 return hist;
49 } // RETURN !!
50
51 // Histogram title
52 const std::string& htitle = ( title.empty() ? "Unnamed 1D Profile Histogram ID=" + ID.idAsString() : title );
53
54 // book the histogram
55 if ( ID.numeric() ) {
56 hist = this->histoSvc()->bookProf( histoPath(), ID.numericID(), htitle, edges );
57 } else if ( ID.literal() ) {
58 hist = this->histoSvc()->bookProf( histoPath() + "/" + ID.literalID(), htitle, edges );
59 }
60
61 // test ok
62 if ( !hist ) {
63 this->Error( "IProfile1D* points to NULL! ID='" + ID.idAsString() + "' title='" + htitle + "'" );
64 return nullptr;
65 } // RETURN !!
66
67 // add histogram into histogram storages
68 m_profile1DMapID[ID] = hist;
69 m_profile1DMapTitle[title] = hist;
70
71 // Declare to monitoring service
72 monitorHisto( Gaudi::Utils::Histos::toBase( hist ), ID );
73
74 // printout and return
75 if ( this->msgLevel( MSG::DEBUG ) ) {
76 this->debug() << "Booked 1D Profile Histogram : ID='" << ID << "' Path=" << histoPath() << " Title='"
77 << Gaudi::Utils::Histos::htitle( hist ) << "'" << endmsg;
78 }
79 return hist;
80 }
81 // ============================================================================
82 // fill the 1D profile histogram (book on demand)
83 // ============================================================================
84 template <class PBASE>
85 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const std::string& title,
86 const HistoBinEdges& edges, const double weight ) const
87 {
88 AIDA::IProfile1D* h( nullptr );
89 if ( produceHistos() ) {
90 // retrieve or book the histogram
91 h = profile1D( title );
92 if ( !h ) {
93 h = bookProfile1D( title, edges );
94 }
95 // fill the histogram
96 h = fill( h, valueX, valueY, weight, title );
97 }
98 return h;
99 }
100 // ============================================================================
101 // fill the 1D profile histogram with forced ID assignment (book on demand)
102 // ============================================================================
103 template <class PBASE>
104 AIDA::IProfile1D* GaudiHistos<PBASE>::profile1D( const double valueX, const double valueY, const HistoID& ID,
105 const std::string& title, const HistoBinEdges& edges,
106 const double weight ) const
107 {
108 AIDA::IProfile1D* h( nullptr );
109 if ( produceHistos() ) {
110 // retrieve or book the histogram
111 h = profile1D( ID );
112 if ( !h ) {
113 h = bookProfile1D( ID, title, edges );
114 }
115 // fill the histogram
116 h = fill( h, valueX, valueY, weight, title );
117 }
118 return h;
119 }
120 // ============================================================================
121 // The END
122 // ============================================================================
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)
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:115
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.
HiveAlgSequencer.h
h
Definition: HiveAlgSequencer.py:24
GaudiAlg::ID::literal
bool literal() const noexcept
Is this ID numeric.
Definition: GaudiHistoID.h:68
std::vector< double >
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
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
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