Gaudi Framework, version v25r2

Home   Generated: Wed Jun 4 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GaudiHistos_2DVariableBinning.icpp
Go to the documentation of this file.
1 // ==================================== 2D ====================================
2 // ============================= Variable Binning =============================
3 // ============================================================================
4 // book the 2D histogram (book on demand)
5 // ============================================================================
6 template <class PBASE>
7 AIDA::IHistogram2D* GaudiHistos<PBASE>::book2D
8 ( const std::string& title ,
9  const HistoBinEdges& edgesX ,
10  const HistoBinEdges& edgesY ) const
11 {
12  //
13  if ( !produceHistos() ) { return 0 ; } // RETURN
14  //
15  // exist?
16  AIDA::IHistogram2D * hist = histo2D ( title ) ;
17  // histogram is already booked
18  if ( NULL != hist ) { return hist ; } // RETURN !!
19 
20  // propose the histogram ID
21  HistoID ID;
22  newHistoID( title, ID );
23 
24  // Create a new histogram and return
25  return this -> book2D ( ID, title, edgesX, edgesY );
26 }
27 // ============================================================================
28 // book the 2D histogram with forced ID (book on demand)
29 // ============================================================================
30 template <class PBASE>
31 AIDA::IHistogram2D* GaudiHistos<PBASE>::book2D
32 ( const HistoID& ID ,
33  const std::string& title ,
34  const HistoBinEdges& edgesX ,
35  const HistoBinEdges& edgesY ) const
36 {
37  //
38  if ( !produceHistos() ) { return 0 ; } // RETURN
39  //
40  // Check ID
41  if (ID.undefined())
42  {
43  this->Error("Undefined Histogram ID : Title='"+title+"'");
44  return NULL;
45  }
46 
47  // exist?
48  AIDA::IHistogram2D * hist = histo2D ( ID ) ;
49  // histogram is already booked
50  if ( NULL != hist ) { return hist ; } // RETURN !!
51 
52  // Histogram title
53  const std::string & htitle =
54  ( title.empty() ? "Unnamed 2D Histogram ID="+ID.idAsString() : title ) ;
55 
56  // book the histogram
57  if ( ID.numeric() )
58  {
59  hist = this->histoSvc() -> book ( histoPath() ,
60  ID.numericID() ,
61  htitle ,
62  edgesX ,
63  edgesY ) ;
64  }
65  else if ( ID.literal() )
66  {
67  hist = this->histoSvc() -> book ( histoPath()+"/"+
68  ID.literalID() ,
69  htitle ,
70  edgesX ,
71  edgesY ) ;
72  }
73 
74  // check OK
75  if( NULL == hist )
76  { this->Error( "IHistogram2D* points to NULL! ID='" + ID.idAsString() +
77  "' title='"+htitle+"'" ) ; return NULL; } // RETURN !!
78 
79  // add histogram into histogram storages
80  m_histo2DMapID [ ID ] = hist ;
81  m_histo2DMapTitle [ title ] = hist ;
82 
83  // Declare to monitoring service
84  monitorHisto( Gaudi::Utils::Histos::toBase ( hist ) , ID );
85 
86  // Printout and return
87  if ( this->msgLevel(MSG::DEBUG) )
88  { this->debug() << "Booked 2D Histogram : ID='" << ID
89  << "' Path=" << histoPath()
90  << " Title='"
92  << "'" << endmsg; }
93  return hist ;
94 }
95 // ============================================================================
96 // fill the 2D histogram (book on demand)
97 // ============================================================================
98 template <class PBASE>
99 AIDA::IHistogram2D*
101 ( const double valueX ,
102  const double valueY ,
103  const std::string& title ,
104  const HistoBinEdges& edgesX ,
105  const HistoBinEdges& edgesY ,
106  const double weight ) const
107 {
108  AIDA::IHistogram2D * h(NULL);
109  if ( produceHistos() )
110  {
111  // retrieve or book the histogram
112  h = histo2D ( title ) ;
113  if ( NULL == h ) { h = book2D ( title , edgesX , edgesY ) ; }
114  // fill the histogram
115  h = fill ( h , valueX , valueY , weight , title );
116  }
117  return h;
118 }
119 // ============================================================================
120 // fill the 2D variable histogram with forced ID assignment (book on demand)
121 // ============================================================================
122 template <class PBASE>
123 AIDA::IHistogram2D*
125 ( const double valueX ,
126  const double valueY ,
127  const HistoID& ID ,
128  const std::string& title ,
129  const HistoBinEdges& edgesX ,
130  const HistoBinEdges& edgesY ,
131  const double weight ) const
132 {
133  AIDA::IHistogram2D * h(NULL);
134  if ( produceHistos() )
135  {
136  // retrieve or book the histogram
137  h = histo2D ( ID ) ;
138  if ( NULL == h ) { h = book2D ( ID , title , edgesX , edgesY ) ; }
139  // fill
140  h = fill ( h , valueX , valueY , weight , title ) ;
141  }
142  return h;
143 }
144 // ============================================================================
145 // The END
146 // ============================================================================
147 

Generated at Wed Jun 4 2014 14:48:55 for Gaudi Framework, version v25r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004