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