|
||||
File indexing completed on 2025-01-18 09:57:33
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #ifndef GAUDIALG_GAUDIHISTOS_H 0012 #define GAUDIALG_GAUDIHISTOS_H 1 0013 // ============================================================================ 0014 /* @file GaudiHistos.h 0015 * 0016 * Header file for class : GaudiHistos 0017 * 0018 * @author Chris Jones Christopher.Rob.Jones@cern.ch 0019 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 0020 * @date 2005-08-08 0021 */ 0022 // ============================================================================ 0023 // Include files# 0024 // ============================================================================ 0025 // STD& STL 0026 // ============================================================================ 0027 #include <boost/algorithm/string/replace.hpp> 0028 #include <limits> 0029 #include <type_traits> 0030 #include <vector> 0031 // ============================================================================ 0032 // GaudiUtils 0033 // ============================================================================ 0034 #include "GaudiUtils/HistoTableFormat.h" 0035 // ============================================================================ 0036 // GaudiAlg 0037 // ============================================================================ 0038 #include "GaudiAlg/GaudiAlgorithm.h" 0039 #include "GaudiAlg/GaudiTool.h" 0040 #include "GaudiAlg/Maps.h" 0041 // ============================================================================ 0042 // GaudiKernel 0043 // ============================================================================ 0044 #include "GaudiKernel/HistoProperty.h" 0045 // ============================================================================ 0046 // Forward declarations 0047 namespace AIDA { 0048 class IHistogram1D; 0049 class IHistogram2D; 0050 class IHistogram3D; 0051 class IProfile1D; 0052 class IProfile2D; 0053 } // namespace AIDA 0054 // ============================================================================ 0055 /** @class GaudiHistos GaudiHistos.h GaudiAlg/GaudiHistos.h 0056 * 0057 * Templated base class providing common histogramming methods for 0058 * GaudiAlgorithm and GaudiTool like classes. 0059 * 0060 * @author Chris Jones Christopher.Rob.Jones@cern.ch 0061 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 0062 * @date 2005-08-08 0063 */ 0064 template <class PBASE> 0065 class GAUDI_API GaudiHistos : public PBASE { 0066 public: 0067 // ========================================================================== 0068 /// the actual type for histogram identifier 0069 typedef GaudiAlg::HistoID HistoID; 0070 // ========================================================================== 0071 /// the actual type for (ID)->(1D histogram) mapping 0072 typedef GaudiAlg::Histo1DMapID Histo1DMapID; 0073 /// the actual type for title->(1D histogram) mapping 0074 typedef GaudiAlg::Histo1DMapTitle Histo1DMapTitle; 0075 // ========================================================================== 0076 /// the actual type for (ID)->(2D histogram) mapping 0077 typedef GaudiAlg::Histo2DMapID Histo2DMapID; 0078 /// the actual type for title->(2D histogram) mapping 0079 typedef GaudiAlg::Histo2DMapTitle Histo2DMapTitle; 0080 // ========================================================================== 0081 /// the actual type for (ID)->(3D histogram) mapping 0082 typedef GaudiAlg::Histo3DMapID Histo3DMapID; 0083 /// the actual type for title->(3D histogram) mapping 0084 typedef GaudiAlg::Histo3DMapTitle Histo3DMapTitle; 0085 // ========================================================================== 0086 /// the actual type for (ID)->(1D profile histogram) mapping 0087 typedef GaudiAlg::Profile1DMapID Profile1DMapID; 0088 /// the actual type for title->(1D profile histogram) mapping 0089 typedef GaudiAlg::Profile1DMapTitle Profile1DMapTitle; 0090 // ========================================================================== 0091 /// the actual type for (ID)->(2D profile histogram) mapping 0092 typedef GaudiAlg::Profile2DMapID Profile2DMapID; 0093 /// the actual type for title->(2D profile histogram) mapping 0094 typedef GaudiAlg::Profile2DMapTitle Profile2DMapTitle; 0095 // ========================================================================== 0096 /// Edges for variable binning 0097 typedef GaudiAlg::HistoBinEdges HistoBinEdges; 0098 // ========================================================================== 0099 public: 0100 // ========================================================================== 0101 // ================================= 1D Histograms ========================== 0102 // ================================= Fixed Binning ========================== 0103 // ========================================================================== 0104 /** fill the 1D histogram (book on demand) 0105 * 0106 * @code 0107 * 0108 * const double mass = ... ; 0109 * plot1D( mass , "Invariant Mass" , 2.5 , 3.5 , 100 ) 0110 * 0111 * @endcode 0112 * 0113 * This example illustrates the filling of the histogram 0114 * titled <tt>"InvariantMass"</tt> with value @c mass . 0115 * 0116 * If the histogram with given title does not exist yet 0117 * it will be automatically booked with parameters 0118 * @c low equal to 2.5, parameters @c high equal to 3.5 0119 * and @c bins equal to 100. 0120 * 0121 * @attention 0122 * The histogram will get a unique identifier automatically assigned which by 0123 * default will be equal to the histogram title. An option exists to instead 0124 * use numerical IDs. In this case the first histogram booked will be ID=1 the 0125 * next ID=2 and so on. Note though this scheme is not recommended as it does 0126 * NOT guarantee predictability of the ID a given histogram will be given when 0127 * filled under conditional statements, since in these circumstances the order 0128 * in which the histograms are first filled, and thus booked, will depend on the 0129 * nature of the first few events read. This is particularly problematic when 0130 * users submit many parallel 'sub-jobs' and then attempt to merge the final 0131 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 0132 * in each of the sub-jobs. Consequently it is strongly recommended that users do 0133 * not use numerical automatic IDs unless they are sure they understand what they 0134 * are doing. 0135 * 0136 * @see AIDA::IHistogram1D 0137 * 0138 * @param value value to be filled 0139 * @param title histogram title (must be unique within the algorithm) 0140 * @param low low limit for histogram 0141 * @param high high limit for histogram 0142 * @param bins number of bins 0143 * @param weight weight 0144 * @return pointer to AIDA 1D histogram 0145 */ 0146 AIDA::IHistogram1D* plot1D( const double value, const std::string& title, const double low, const double high, 0147 const unsigned long bins = 100, const double weight = 1.0 ) const; 0148 // ========================================================================== 0149 /** fill the 1D histogram (book on demand) 0150 * 0151 * Wrapper method for the equivalent plot1D method. 0152 * Retained for backwards compatibility, please use plot1D instead. 0153 * 0154 * @param value value to be filled 0155 * @param title histogram title (must be unique within the algorithm) 0156 * @param low low limit for histogram 0157 * @param high high limit for histogram 0158 * @param bins number of bins 0159 * @param weight weight 0160 * @return pointer to AIDA 1D histogram 0161 */ 0162 inline AIDA::IHistogram1D* plot( const double value, const std::string& title, const double low, const double high, 0163 const unsigned long bins = 100, const double weight = 1.0 ) const { 0164 return plot1D( value, title, low, high, bins, weight ); 0165 } 0166 // ========================================================================== 0167 /** fill the 1D histogram (book on demand) 0168 * 0169 * @code 0170 * 0171 * /// get the histogram descriptor: 0172 * const Gaudi::Histo1DDef& hdef = ... ; 0173 * 0174 * const double mass = ... ; 0175 * plot1D ( mass , hdef ) ; 0176 * 0177 * @endcode 0178 * 0179 * The histogram will get a unique identifier automatically assigned which by 0180 * default will be equal to the histogram title. 0181 * 0182 * The histogram descriptor comes e.g. from the component properties. 0183 * 0184 * @see AIDA::IHistogram1D 0185 * 0186 * @param value value to be filled 0187 * @param hdef histogram descriptor 0188 * @param weight weight 0189 * @return pointer to AIDA 1D histogram 0190 */ 0191 AIDA::IHistogram1D* plot1D( const double value, const Gaudi::Histo1DDef& hdef, const double weight = 1.0 ) const; 0192 // ========================================================================== 0193 /** fill the 1D histogram (book on demand) 0194 * 0195 * Wrapper method for the equivalent plot1D method. 0196 * Retained for backwards compatibility, please use plot1D instead. 0197 * 0198 * @param value value to be filled 0199 * @param hdef histogram descriptor 0200 * @param weight weight 0201 * @return pointer to AIDA 1D histogram 0202 */ 0203 inline AIDA::IHistogram1D* plot( const double value, const Gaudi::Histo1DDef& hdef, 0204 const double weight = 1.0 ) const { 0205 return plot1D( value, hdef, weight ); 0206 } 0207 // ========================================================================== 0208 /** fill the 1D histogram with forced ID assignment (book on demand) 0209 * 0210 * @code 0211 * 0212 * const double mass = ... ; 0213 * plot1D( mass , 15 , "Invariant Mass" , 2.5 , 3.5 , 100 ) 0214 * 0215 * @endcode 0216 * 0217 * This example illustrates the filling of the 1D histogram ID=15 0218 * titled <tt>"Invariant Mass"</tt> with value @c mass . 0219 * 0220 * If the histogram with given ID does not exist yet 0221 * it will be automatically booked with parameters 0222 * @c low equal to 2.5, parameters @c high equal to 3.5 0223 * and @c bins equal to 100. 0224 * 0225 * It is also possible to use literal IDs. For example :- 0226 * 0227 * @code 0228 * 0229 * const double mass = ... ; 0230 * plot1D( mass , "mass" , "Invariant Mass" , 2.5 , 3.5 , 100 ) 0231 * 0232 * @endcode 0233 * 0234 * Will book the same histogram, using the id "mass". 0235 * 0236 * It is also possible using literal IDs, to place histograms in 0237 * sub-directories from the main histogram directory, using for 0238 * example :- 0239 * 0240 * @code 0241 * 0242 * const double mass = ... ; 0243 * plot1D( mass , "subdir/mass" , "Invariant Mass" , 2.5 , 3.5 , 100 ) 0244 * 0245 * @endcode 0246 * 0247 * Which will create the histogram "mass" in the sub-directory "subdir". 0248 * Histograms can also be created in sub-directories with numeric IDs if 0249 * IDs such as "subdir/1" are used. 0250 * 0251 * @attention 0252 * If the histogram with given ID is already booked 0253 * through automatic assignment of histogram ID, 0254 * the error will not be detected. 0255 * Therefore it is recommended 0256 * to use non-trivial histogram ID offset (property "HistoOffSet") 0257 * if one need to combine these techniques together. 0258 * It is still desirable to use the unique histogram title 0259 * to avoid a bad interference. 0260 * 0261 * @see AIDA::IHistogram1D 0262 * 0263 * @param value value to be filled 0264 * @param ID histogram identifier 0265 * @param title histogram title (must be unique within the algorithm) 0266 * @param low low limit for histogram 0267 * @param high high limit for histogram 0268 * @param bins number of bins 0269 * @param weight weight 0270 * @return pointer to AIDA 1D histogram 0271 */ 0272 // ========================================================================== 0273 AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const std::string& title, const double low, 0274 const double high, const unsigned long bins = 100, const double weight = 1.0 ) const; 0275 // ========================================================================== 0276 /** fill the 1D histogram with forced ID assignment (book on demand) 0277 * 0278 * Wrapper method for the equivalent plot1D method. 0279 * Retained for backwards compatibility, please use plot1D instead. 0280 * 0281 * @param value value to be filled 0282 * @param ID histogram identifier 0283 * @param title histogram title (must be unique within the algorithm) 0284 * @param low low limit for histogram 0285 * @param high high limit for histogram 0286 * @param bins number of bins 0287 * @param weight weight 0288 * @return pointer to AIDA 1D histogram 0289 */ 0290 inline AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const std::string& title, const double low, 0291 const double high, const unsigned long bins = 100, 0292 const double weight = 1.0 ) const { 0293 return plot1D( value, ID, title, low, high, bins, weight ); 0294 } 0295 // ========================================================================== 0296 /** fill the 1D histogram with forced ID assignment (book on demand) 0297 * 0298 * @code 0299 * 0300 * // get the histogram descriptor 0301 * const Gaudi::Histo1DDef& hdef = ... ; 0302 * 0303 * // get the histogram ID 0304 * const HistoID ID = ... ; 0305 * 0306 * const double mass = ... ; 0307 * plot1D ( mass , ID , hdef ) 0308 * 0309 * @endcode 0310 * 0311 * @see AIDA::IHistogram1D 0312 * 0313 * The histogram descriptor comes e.g. from component properties 0314 * 0315 * @param value value to be filled 0316 * @param ID histogram identifier 0317 * @param hdef histogram descriptor 0318 * @param weight weight 0319 * @return pointer to AIDA 1D histogram 0320 */ 0321 AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const Gaudi::Histo1DDef& hdef, 0322 const double weight = 1.0 ) const; 0323 // ========================================================================== 0324 /** fill the 1D histogram (book on demand) 0325 * 0326 * Wrapper method for the equivalent plot1D method. 0327 * Retained for backwards compatibility, please use plot1D instead. 0328 * 0329 * @param value value to be filled 0330 * @param ID histogram identifier 0331 * @param hdef histogram descriptor 0332 * @param weight weight 0333 * @return pointer to AIDA 1D histogram 0334 */ 0335 inline AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const Gaudi::Histo1DDef& hdef, 0336 const double weight = 1.0 ) const { 0337 return plot1D( value, ID, hdef, weight ); 0338 } 0339 /** fill the 1D histogram with information from 0340 * [first,last) sequence 0341 * 0342 * @code 0343 * 0344 * std::vector<double> v = ... ; 0345 * 0346 * plot( sin , // function 0347 * v.begin() , v.end() , // sequence 0348 * " bla-bla " , // title 0349 * -1. , 1.0 , // low and high limits 0350 * 100 ) // number of bins 0351 * 0352 * @endcode 0353 * 0354 * @attention 0355 * The histogram will get a unique identifier automatically assigned which by 0356 * default will be equal to the histogram title. An option exists to instead 0357 * use numerical IDs. In this case the first histogram booked will be ID=1 the 0358 * next ID=2 and so on. Note though this scheme is not recommended as it does 0359 * NOT guarantee predictability of the ID a given histogram will be given when 0360 * filled under conditional statements, since in these circumstances the order 0361 * in which the histograms are first filled, and thus booked, will depend on the 0362 * nature of the first few events read. This is particularly problematic when 0363 * users submit many parallel 'sub-jobs' and then attempt to merge the final 0364 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 0365 * in each of the sub-jobs. Consequently it is strongly recommended that users do 0366 * not use numerical automatic IDs unless they are sure they understand what they 0367 * are doing. 0368 * 0369 * Sequence, objects and function can be non-trivial: 0370 * @code 0371 * 0372 * Particles* p = ... ; 0373 * 0374 * plot( PT , // function 0375 * p->begin() , p->end() , // sequence 0376 * " bla-bla " , // title 0377 * -1. , 1.0 , // low and high limits 0378 * 100 ) ; // number of bins 0379 * 0380 * @endcode 0381 * where <c>PT</c> can be any function or function object 0382 * for which the expression <c>PT(p)</c> , with <c>p</c> of type 0383 * <c>Particle*</c> have some sense and can be evaluated to 0384 * the values, which is convertible to <c>double</c> 0385 * 0386 * @attention 0387 * These plot methods using iterator ranges are more efficient than 0388 * the simplier "value" only methods, since the associated histogram 0389 * only requires locating from internal storage once per loop, as opposed 0390 * to once per fill for the simplier functions. It is recommended to use 0391 * these whenever possible. 0392 * 0393 * @see AIDA::IHistogram1D 0394 * @param func function to be plotted 0395 * @param first begin of the sequence 0396 * @param last end of the sequence 0397 * @param title histogram title 0398 * @param low low limit for histogram 0399 * @param high high limit for histogram 0400 * @param bins number of bins for histogram 0401 */ 0402 template <class FUNCTION, class OBJECT> 0403 inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, 0404 const double low, const double high, const unsigned long bins = 100 ) const { 0405 AIDA::IHistogram1D* h = nullptr; 0406 if ( produceHistos() ) { 0407 // retrieve or book the histogram 0408 h = histo1D( title ); 0409 if ( !h ) { h = book1D( title, low, high, bins ); } 0410 // fill histogram 0411 while ( first != last && h ) { 0412 h = fill( h, func( *first ), 1.0, title ); 0413 ++first; 0414 } 0415 } 0416 return h; 0417 } 0418 // ========================================================================== 0419 /** fill the 1D histogram with forced ID and information from 0420 * [first,last) sequence 0421 * 0422 * @code 0423 * 0424 * std::vector<double> v = ... ; 0425 * 0426 * // Example with numeric ID 0427 * plot( sin , // function 0428 * v.begin() , v.end() , // sequence 0429 * 100 , " bla-bla " , // ID and title 0430 * -1. , 1.0 , // low and high limits 0431 * 100 ); // number of bins 0432 * 0433 * // Example with literal ID 0434 * plot( sin , // function 0435 * v.begin() , v.end() , // sequence 0436 * "sin" , " bla-bla " , // ID and title 0437 * -1. , 1.0 , // low and high limits 0438 * 100 ); // number of bins 0439 * 0440 * @endcode 0441 * 0442 * Sequence, objects and function can be non-trivial: 0443 * 0444 * @code 0445 * 0446 * Particles* p = ... ; 0447 * 0448 * plot( PT , // function 0449 * p->begin() , p->end() , // sequence 0450 * 100 , " bla-bla " , // ID and title 0451 * -1. , 1.0 , // low and high limits 0452 * 100 ) ; // number of bins 0453 * 0454 * @endcode 0455 * 0456 * @attention 0457 * These plot methods using iterator ranges are more efficient than 0458 * the simplier "value" only methods, since the associated histogram 0459 * only requires locating from internal storage once per loop, as opposed 0460 * to once per fill for the simplier functions. It is recommended to use 0461 * these whenever possible. 0462 * 0463 * @see AIDA::IHistogram1D 0464 * 0465 * @param func function to be plotted 0466 * @param first begin of the sequence 0467 * @param last end of the sequence 0468 * @param ID histogram identifier 0469 * @param title histogram title 0470 * @param low low limit for histogram 0471 * @param high high limit for histogram 0472 * @param bins number of bins for histogram 0473 */ 0474 template <class FUNCTION, class OBJECT> 0475 inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID, 0476 const std::string& title, const double low, const double high, 0477 const unsigned long bins = 100 ) const { 0478 AIDA::IHistogram1D* h( 0 ); 0479 if ( produceHistos() ) { 0480 // retrieve or book the histogram 0481 h = histo1D( ID ); 0482 if ( !h ) { h = book1D( ID, title, low, high, bins ); } 0483 // fill histogram 0484 while ( first != last && h ) { 0485 h = fill( h, func( *first ), 1.0, title ); 0486 ++first; 0487 } 0488 } 0489 return h; 0490 } 0491 // ========================================================================== 0492 /** book and fill the 1D histogram with information from 0493 * [first,last) sequence with given weight 0494 * 0495 * @code 0496 * 0497 * std::vector<double> v = ... ; 0498 * 0499 * plot( sin , // function 0500 * v.begin() , v.end() , // sequence 0501 * " bla-bla " , // title 0502 * -1. , 1.0 , // low and high limits 0503 * 100 , // number of bins 0504 * tanh ); // weight function 0505 * 0506 * @endcode 0507 * 0508 * @attention 0509 * The histogram will get a unique identifier automatically assigned which by 0510 * default will be equal to the histogram title. An option exists to instead 0511 * use numerical IDs. In this case the first histogram booked will be ID=1 the 0512 * next ID=2 and so on. Note though this scheme is not recommended as it does 0513 * NOT guarantee predictability of the ID a given histogram will be given when 0514 * filled under conditional statements, since in these circumstances the order 0515 * in which the histograms are first filled, and thus booked, will depend on the 0516 * nature of the first few events read. This is particularly problematic when 0517 * users submit many parallel 'sub-jobs' and then attempt to merge the final 0518 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 0519 * in each of the sub-jobs. Consequently it is strongly recommended that users do 0520 * not use numerical automatic IDs unless they are sure they understand what they 0521 * are doing. 0522 * 0523 * Sequence, objects and function can be non-trivial: 0524 * @code 0525 * 0526 * Particles* p = ... ; 0527 * 0528 * plot( PT , // function 0529 * p->begin() , p->end() , // sequence 0530 * " bla-bla " , // title 0531 * -1. , 1.0 , // low and high limits 0532 * 100 , // number of bins 0533 * MASS ) ; // weight function 0534 * 0535 * @endcode 0536 * where <c>PT</c> and <c>MASS</c> can be any function 0537 * or function object 0538 * for which the expressions <c>PT(p)</c> and 0539 * <c>MASS</c> with <c>p</c> of type 0540 * <c>Particle*</c> have some sense and can be evaluated to 0541 * the values, which is convertible to <c>double</c> 0542 * 0543 * @attention 0544 * These plot methods using iterator ranges are more efficient than 0545 * the simplier "value" only methods, since the associated histogram 0546 * only requires locating from internal storage once per loop, as opposed 0547 * to once per fill for the simplier functions. It is recommended to use 0548 * these whenever possible. 0549 * 0550 * @see AIDA::IHistogram1D 0551 * @param first begin of the sequence 0552 * @param last end of the sequence 0553 * @param title histogram title 0554 * @param func function to be plotted 0555 * @param low low limit for histogram 0556 * @param high high limit for histogram 0557 * @param bins number of bins for histogram 0558 * @param weight weight function 0559 */ 0560 template <class FUNCTION, class OBJECT, class WEIGHT> 0561 inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, 0562 const double low, const double high, const unsigned long bins, 0563 const WEIGHT& weight ) const { 0564 AIDA::IHistogram1D* h = nullptr; 0565 if ( produceHistos() ) { 0566 // retrieve or book the histogram 0567 h = histo1D( title ); 0568 if ( !h ) { h = book1D( title, low, high, bins ); } 0569 // fill histogram 0570 while ( first != last && h ) { 0571 h = fill( h, func( *first ), weight( *first ), title ); 0572 ++first; 0573 } 0574 } 0575 return h; 0576 } 0577 // ========================================================================== 0578 /** book and fill the 1D histogram with forced ID and information from 0579 * [first,last) sequence with given weight 0580 * 0581 * @code 0582 * 0583 * std::vector<double> v = ... ; 0584 * 0585 * // example with numerical ID 0586 * plot( sin , // function 0587 * v.begin() , v.end() , // sequence 0588 * 100 , " bla-bla " , // ID and title 0589 * -1. , 1.0 , // low and high limits 0590 * 100 , // number of bins 0591 * sinh ); // weight function 0592 * 0593 * // example with literal ID 0594 * plot( sin , // function 0595 * v.begin() , v.end() , // sequence 0596 * "sin" , " bla-bla " , // ID and title 0597 * -1. , 1.0 , // low and high limits 0598 * 100 , // number of bins 0599 * sinh ); // weight function 0600 * 0601 * @endcode 0602 * 0603 * @attention no checks for NaN or Finite are performed! 0604 * 0605 * Sequence, objects and function can be non-trivial: 0606 * 0607 * @code 0608 * 0609 * Particles* p = ... ; 0610 * 0611 * plot( PT , // function 0612 * p->begin() , p->end() , // sequence 0613 * 100 , " bla-bla " , // ID and title 0614 * -1. , 1.0 , // low and high limits 0615 * 100 , // number of bins 0616 * MASS ) ; // weight function 0617 * 0618 * @endcode 0619 * where <c>PT</c> and <c>MASS</c> can be any function 0620 * or function object 0621 * for which the expressions <c>PT(p)</c> and 0622 * <c>MASS</c> with <c>p</c> of type 0623 * <c>Particle*</c> have some sense and can be evaluated to 0624 * the values, which is convertible to <c>double</c> 0625 * 0626 * @attention 0627 * These plot methods using iterator ranges are more efficient than 0628 * the simplier "value" only methods, since the associated histogram 0629 * only requires locating from internal storage once per loop, as opposed 0630 * to once per fill for the simplier functions. It is recommended to use 0631 * these whenever possible. 0632 * 0633 * @see AIDA::IHistogram1D 0634 * @param first begin of the sequence 0635 * @param last end of the sequence 0636 * @param ID histogram identifier 0637 * @param title histogram title 0638 * @param func function to be plotted 0639 * @param low low limit for histogram 0640 * @param high high limit for histogram 0641 * @param bins number of bins for histogram 0642 * @param weight weight function 0643 */ 0644 template <class FUNCTION, class OBJECT, class WEIGHT> 0645 inline AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID, 0646 const std::string& title, const double low, const double high, 0647 const unsigned long bins, const WEIGHT& weight ) const { 0648 AIDA::IHistogram1D* h = nullptr; 0649 if ( produceHistos() ) { 0650 // retrieve or book the histogram 0651 h = histo1D( ID ); 0652 if ( !h ) { h = book1D( ID, title, low, high, bins ); } 0653 // fill histogram 0654 while ( first != last && h ) { 0655 h = fill( h, func( *first ), weight( *first ), title ); 0656 ++first; 0657 } 0658 } 0659 return h; 0660 } 0661 // ========================================================================== 0662 // ================================= 1D Histograms ========================== 0663 // =============================== Variable Binning ========================= 0664 // ========================================================================== 0665 /** Fill the 1D variable binning histogram (book on demand) 0666 * 0667 * @code 0668 * 0669 * const GaudiAlg::HistoBinEdges edges = ...; 0670 * const double mass = ... ; 0671 * plot1D( mass , "Invariant Mass" , edges ) 0672 * 0673 * @endcode 0674 * 0675 * This example illustrates the filling of the histogram 0676 * titled <tt>"InvariantMass"</tt> with value @c mass. 0677 * 0678 * If the histogram with given title does not exist yet 0679 * it will be automatically booked with the given histogram bin edges. 0680 * 0681 * @attention 0682 * The histogram will get a unique identifier automatically assigned which by 0683 * default will be equal to the histogram title. An option exists to instead 0684 * use numerical IDs. In this case the first histogram booked will be ID=1 the 0685 * next ID=2 and so on. Note though this scheme is not recommended as it does 0686 * NOT guarantee predictability of the ID a given histogram will be given when 0687 * filled under conditional statements, since in these circumstances the order 0688 * in which the histograms are first filled, and thus booked, will depend on the 0689 * nature of the first few events read. This is particularly problematic when 0690 * users submit many parallel 'sub-jobs' and then attempt to merge the final 0691 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 0692 * in each of the sub-jobs. Consequently it is strongly recommended that users do 0693 * not use numerical automatic IDs unless they are sure they understand what they 0694 * are doing. 0695 * 0696 * @see AIDA::IHistogram1D 0697 * 0698 * @param value value to be filled 0699 * @param title histogram title (must be unique within the algorithm) 0700 * @param edges The histogram bin edges 0701 * @param weight weight 0702 * @return pointer to AIDA 1D histogram 0703 */ 0704 AIDA::IHistogram1D* plot1D( const double value, const std::string& title, const HistoBinEdges& edges, 0705 const double weight = 1.0 ) const; 0706 // ========================================================================== 0707 /** fill the 1D variable binning histogram with forced ID assignment (book on demand) 0708 * 0709 * @code 0710 * 0711 * const GaudiAlg::HistoBinEdges edges = ...; 0712 * const double mass = ... ; 0713 * plot1D( mass , 15 , "Invariant Mass" , edges ) 0714 * 0715 * @endcode 0716 * 0717 * This example illustrates the filling of the 1D histogram ID=15 0718 * titled <tt>"Invariant Mass"</tt> with value @c mass. 0719 * 0720 * If the histogram with given ID does not exist yet 0721 * it will be automatically booked with the given histogram bin edges. 0722 * 0723 * It is also possible to use literal IDs. For example :- 0724 * 0725 * @code 0726 * 0727 * const GaudiAlg::HistoBinEdges edges = ...; 0728 * const double mass = ... ; 0729 * plot1D( mass , "mass" , "Invariant Mass" , edges ) 0730 * 0731 * @endcode 0732 * 0733 * Will book the same histogram, using the id "mass". 0734 * 0735 * It is also possible using literal IDs, to place histograms in 0736 * sub-directories from the main histogram directory, using for 0737 * example :- 0738 * 0739 * @code 0740 * 0741 * const GaudiAlg::HistoBinEdges edges = ...; 0742 * const double mass = ... ; 0743 * plot1D( mass , "subdir/mass" , "Invariant Mass" , edges ) 0744 * 0745 * @endcode 0746 * 0747 * Which will create the histogram "mass" in the sub-directory "subdir". 0748 * Histograms can also be created in sub-directories with numeric IDs if 0749 * IDs such as "subdir/1" are used. 0750 * 0751 * @attention 0752 * If the histogram with given ID is already booked 0753 * through automatic assignment of histogram ID, 0754 * the error will not be detected. 0755 * Therefore it is recommended 0756 * to use non-trivial histogram ID offset (property "HistoOffSet") 0757 * if one need to combine these techniques together. 0758 * It is still desirable to use the unique histogram title 0759 * to avoid a bad interference. 0760 * 0761 * @see AIDA::IHistogram1D 0762 * 0763 * @param value value to be filled 0764 * @param ID histogram identifier 0765 * @param title histogram title (must be unique within the algorithm) 0766 * @param edges The histogram bin edges 0767 * @param weight weight 0768 * @return pointer to AIDA 1D histogram 0769 */ 0770 // ========================================================================== 0771 AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const std::string& title, 0772 const HistoBinEdges& edges, const double weight = 1.0 ) const; 0773 // ========================================================================== 0774 // ================================= 2D Histograms ========================== 0775 // ========================================================================== 0776 /** fill the 2D histogram (book on demand) 0777 * 0778 * @code 0779 * 0780 * const double mass1 = ... ; 0781 * const double mass2 = ... ; 0782 * plot2D( mass1, mass2, 0783 * "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 4.5, 5.5, 100, 200 ); 0784 * 0785 * @endcode 0786 * 0787 * This example illustrates the filling of the 2D histogram 0788 * titled <tt>"Invariant Mass2 versus Mass1"</tt> with 0789 * values @c mass1 and @c mass2 . 0790 * 0791 * If the histogram with given title does not exist yet 0792 * it will be automatically booked with parameters 0793 * @c lowX equal to 2.5, @c highX equal to 3.5, 0794 * @c lowY equal to 4.5, @c highY equal to 5.5, 0795 * @c binsX equal to 100 and @c binsY equal to 200. 0796 * 0797 * @attention 0798 * The histogram will get a unique identifier automatically assigned which by 0799 * default will be equal to the histogram title. An option exists to instead 0800 * use numerical IDs. In this case the first histogram booked will be ID=1 the 0801 * next ID=2 and so on. Note though this scheme is not recommended as it does 0802 * NOT guarantee predictability of the ID a given histogram will be given when 0803 * filled under conditional statements, since in these circumstances the order 0804 * in which the histograms are first filled, and thus booked, will depend on the 0805 * nature of the first few events read. This is particularly problematic when 0806 * users submit many parallel 'sub-jobs' and then attempt to merge the final 0807 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 0808 * in each of the sub-jobs. Consequently it is strongly recommended that users do 0809 * not use numerical automatic IDs unless they are sure they understand what they 0810 * are doing. 0811 * 0812 * @see AIDA::IHistogram2D 0813 * 0814 * @param valueX x value to be filled 0815 * @param valueY y value to be filled 0816 * @param title histogram title (must be unique within the algorithm) 0817 * @param lowX low x limit for histogram 0818 * @param highX high x limit for histogram 0819 * @param lowY low y limit for histogram 0820 * @param highY high y limit for histogram 0821 * @param binsX number of bins in x 0822 * @param binsY number of bins in y 0823 * @param weight weight 0824 * @return pointer to AIDA 2D histogram 0825 */ 0826 AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const std::string& title, const double lowX, 0827 const double highX, const double lowY, const double highY, const unsigned long binsX = 50, 0828 const unsigned long binsY = 50, const double weight = 1.0 ) const; 0829 // ========================================================================== 0830 /** fill the 2D histogram with forced ID assignment (book on demand) 0831 * 0832 * @code 0833 * 0834 * const double mass1 = ... ; 0835 * const double mass2 = ... ; 0836 * plot2D( mass1, mass2, 15, 0837 * "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 4.5, 5.5, 100, 200 ); 0838 * 0839 * @endcode 0840 * 0841 * This example illustrates the filling of the 2D histogram ID=15 0842 * titled <tt>"Invariant Mass2 versus Mass1"</tt> 0843 * with values @c mass1 and @c mass2 . 0844 * 0845 * If the histogram with given title does not exist yet 0846 * it will be automatically booked with parameters 0847 * @c lowX equal to 2.5, @c highX equal to 3.5, 0848 * @c lowY equal to 4.5, @c highY equal to 5.5, 0849 * @c binsX equal to 100 and @c binsY equal to 200. 0850 * 0851 * It is also possible to use literal IDs. For example :- 0852 * 0853 * @code 0854 * 0855 * const double mass1 = ... ; 0856 * const double mass2 = ... ; 0857 * plot2D( mass1, mass2, "mass", 0858 * "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 4.5, 5.5, 100, 200 ); 0859 * 0860 * @endcode 0861 * 0862 * Will book the same histogram, using the id "mass". 0863 * 0864 * It is also possible using literal IDs, to place histograms in 0865 * sub-directories from the main histogram directory, using for 0866 * example :- 0867 * 0868 * @code 0869 * 0870 * const double mass1 = ... ; 0871 * const double mass2 = ... ; 0872 * plot2D( mass1, mass2, "subdir/mass", 0873 * "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 4.5, 5.5, 100, 200 ); 0874 * 0875 * @endcode 0876 * 0877 * Which will create the histogram "mass" in the sub-directory "subdir". 0878 * Histograms can also be created in sub-directories with numeric IDs if 0879 * IDs such as "subdir/1" are used. 0880 * 0881 * @attention 0882 * If the histogram with given ID is already booked 0883 * through automatic assignment of histogram ID, 0884 * the error will not be detected. 0885 * Therefore it is recommended 0886 * to use non-trivial histogram ID offset (property "HistoOffSet") 0887 * if one need to combine these techniques together 0888 * It is still desirable to use the unique histogram title 0889 * to avoid a bad interference 0890 * 0891 * @see AIDA::IHistogram2D 0892 * 0893 * @param valueX x value to be filled 0894 * @param valueY y value to be filled 0895 * @param ID Histogram ID to use 0896 * @param title histogram title (must be unique within the algorithm) 0897 * @param lowX low x limit for histogram 0898 * @param highX high x limit for histogram 0899 * @param lowY low y limit for histogram 0900 * @param highY high y limit for histogram 0901 * @param binsX number of bins in x 0902 * @param binsY number of bins in y 0903 * @param weight weight 0904 * @return pointer to AIDA 2D histogram 0905 */ 0906 AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const HistoID& ID, const std::string& title, 0907 const double lowX, const double highX, const double lowY, const double highY, 0908 const unsigned long binsX = 50, const unsigned long binsY = 50, 0909 const double weight = 1.0 ) const; 0910 // ========================================================================== 0911 // ================================= 2D Histograms ========================== 0912 // =============================== Variable Binning ========================= 0913 // ========================================================================== 0914 /** Fill the 2D variable binning histogram (book on demand) 0915 * 0916 * @code 0917 * 0918 * const GaudiAlg::HistoBinEdges edgesX = ...; 0919 * const GaudiAlg::HistoBinEdges edgesY = ...; 0920 * const double mass1 = ... ; 0921 * const double mass2 = ... ; 0922 * plot2D( mass1, mass2, 0923 * "Invariant Mass2 versus Mass1" , edgesX, edgesY ); 0924 * 0925 * @endcode 0926 * 0927 * This example illustrates the filling of the 2D histogram 0928 * titled <tt>"Invariant Mass2 versus Mass1"</tt> 0929 * with values @c mass1 and @c mass2 . 0930 * 0931 * If the histogram with given title does not exist yet 0932 * it will be automatically booked with the given histogram bin edges. 0933 * 0934 * @attention 0935 * The histogram will get a unique identifier automatically assigned which by 0936 * default will be equal to the histogram title. An option exists to instead 0937 * use numerical IDs. In this case the first histogram booked will be ID=1 the 0938 * next ID=2 and so on. Note though this scheme is not recommended as it does 0939 * NOT guarantee predictability of the ID a given histogram will be given when 0940 * filled under conditional statements, since in these circumstances the order 0941 * in which the histograms are first filled, and thus booked, will depend on the 0942 * nature of the first few events read. This is particularly problematic when 0943 * users submit many parallel 'sub-jobs' and then attempt to merge the final 0944 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 0945 * in each of the sub-jobs. Consequently it is strongly recommended that users do 0946 * not use numerical automatic IDs unless they are sure they understand what they 0947 * are doing. 0948 * 0949 * @see AIDA::IHistogram2D 0950 * 0951 * @param valueX x value to be filled 0952 * @param valueY y value to be filled 0953 * @param title histogram title (must be unique within the algorithm) 0954 * @param edgesX The histogram x bin edges 0955 * @param edgesY The histogram y bin edges 0956 * @param weight weight 0957 * @return pointer to AIDA 2D histogram 0958 */ 0959 AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const std::string& title, 0960 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY, 0961 const double weight = 1.0 ) const; 0962 // ========================================================================== 0963 /** fill the 2D variable histogram with forced ID assignment (book on demand) 0964 * 0965 * @code 0966 * 0967 * const GaudiAlg::HistoBinEdges edgesX = ...; 0968 * const GaudiAlg::HistoBinEdges edgesY = ...; 0969 * const double mass1 = ... ; 0970 * const double mass2 = ... ; 0971 * plot2D( mass1, mass2, 15, 0972 * "Invariant Mass2 versus Mass1", edgesX, edgesY ); 0973 * 0974 * @endcode 0975 * 0976 * This example illustrates the filling of the 2D histogram ID=15 0977 * titled <tt>"Invariant Mass2 versus Mass1"</tt> 0978 * with values @c mass1 and @c mass2 . 0979 * 0980 * If the histogram with given title does not exist yet 0981 * it will be automatically booked with the given histogram bin edges. 0982 * 0983 * It is also possible to use literal IDs. For example :- 0984 * 0985 * @code 0986 * 0987 * const GaudiAlg::HistoBinEdges edgesX = ...; 0988 * const GaudiAlg::HistoBinEdges edgesY = ...; 0989 * const double mass1 = ... ; 0990 * const double mass2 = ... ; 0991 * plot2D( mass1, mass2, "mass", 0992 * "Invariant Mass2 versus Mass1", edgesX, edgesY ); 0993 * 0994 * @endcode 0995 * 0996 * Will book the same histogram, using the id "mass". 0997 * 0998 * It is also possible using literal IDs, to place histograms in 0999 * sub-directories from the main histogram directory, using for 1000 * example :- 1001 * 1002 * @code 1003 * 1004 * const GaudiAlg::HistoBinEdges edgesX = ...; 1005 * const GaudiAlg::HistoBinEdges edgesY = ...; 1006 * const double mass1 = ... ; 1007 * const double mass2 = ... ; 1008 * plot2D( mass1, mass2, "subdir/mass", 1009 * "Invariant Mass2 versus Mass1", edgesX, edgesY ); 1010 * 1011 * @endcode 1012 * 1013 * Which will create the histogram "mass" in the sub-directory "subdir". 1014 * Histograms can also be created in sub-directories with numeric IDs if 1015 * IDs such as "subdir/1" are used. 1016 * 1017 * @attention 1018 * If the histogram with given ID is already booked 1019 * through automatic assignment of histogram ID, 1020 * the error will not be detected. 1021 * Therefore it is recommended 1022 * to use non-trivial histogram ID offset (property "HistoOffSet") 1023 * if one need to combine these techniques together 1024 * It is still desirable to use the unique histogram title 1025 * to avoid a bad interference 1026 * 1027 * @see AIDA::IHistogram2D 1028 * 1029 * @param valueX x value to be filled 1030 * @param valueY y value to be filled 1031 * @param ID Histogram ID to use 1032 * @param title histogram title (must be unique within the algorithm) 1033 * @param edgesX The histogram x bin edges 1034 * @param edgesY The histogram y bin edges 1035 * @param weight weight 1036 * @return pointer to AIDA 2D histogram 1037 */ 1038 AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const HistoID& ID, const std::string& title, 1039 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY, 1040 const double weight = 1.0 ) const; 1041 // ========================================================================== 1042 // ================================= 3D Histograms ========================== 1043 // ========================================================================== 1044 /** fill the 3D histogram (book on demand) 1045 * 1046 * @code 1047 * 1048 * const double X = ... ; 1049 * const double Y = ... ; 1050 * const double Z = ... ; 1051 * plot3D( X, Y, Z, "Space Points" , 1052 * 2.5 , 3.5 , 1053 * 4.5 , 5.5 , 1054 * 6.5 , 7.5 , 1055 * 10, 20, 30 ); 1056 * 1057 * @endcode 1058 * 1059 * This example illustrates the filling of the 3D histogram 1060 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 1061 * 1062 * If the histogram with given title does not exist yet 1063 * it will be automatically booked with parameters 1064 * @c lowX equal to 2.5, @c highX equal to 3.5, 1065 * @c lowY equal to 4.5, @c highY equal to 5.5, 1066 * @c lowZ equal to 6.5, @c highZ equal to 7.5, 1067 * @c binsX equal to 10, @c binsY equal to 20 and @c binsZ equal to 30. 1068 * 1069 * @attention 1070 * The histogram will get a unique identifier automatically assigned which by 1071 * default will be equal to the histogram title. An option exists to instead 1072 * use numerical IDs. In this case the first histogram booked will be ID=1 the 1073 * next ID=2 and so on. Note though this scheme is not recommended as it does 1074 * NOT guarantee predictability of the ID a given histogram will be given when 1075 * filled under conditional statements, since in these circumstances the order 1076 * in which the histograms are first filled, and thus booked, will depend on the 1077 * nature of the first few events read. This is particularly problematic when 1078 * users submit many parallel 'sub-jobs' and then attempt to merge the final 1079 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 1080 * in each of the sub-jobs. Consequently it is strongly recommended that users do 1081 * not use numerical automatic IDs unless they are sure they understand what they 1082 * are doing. 1083 * 1084 * @see AIDA::IHistogram3D 1085 * 1086 * @param valueX x value to be filled 1087 * @param valueY y value to be filled 1088 * @param valueZ z value to be filled 1089 * @param title histogram title (must be unique within the algorithm) 1090 * @param lowX low x limit for histogram 1091 * @param highX high x limit for histogram 1092 * @param lowY low y limit for histogram 1093 * @param highY high y limit for histogram 1094 * @param lowZ low z limit for histogram 1095 * @param highZ high z limit for histogram 1096 * @param binsX number of bins in x 1097 * @param binsY number of bins in y 1098 * @param binsZ number of bins in z 1099 * @param weight weight 1100 * @return pointer to AIDA 3D histogram 1101 */ 1102 AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const std::string& title, 1103 const double lowX, const double highX, const double lowY, const double highY, 1104 const double lowZ, const double highZ, const unsigned long binsX = 10, 1105 const unsigned long binsY = 10, const unsigned long binsZ = 10, 1106 const double weight = 1.0 ) const; 1107 // ========================================================================== 1108 /** fill the 3D histogram with forced ID assignment (book on demand) 1109 * 1110 * @code 1111 * 1112 * const double X = ... ; 1113 * const double Y = ... ; 1114 * const double Z = ... ; 1115 * plot3D( X, Y, Z, 1116 * 15 , "Space Points" , 1117 * 2.5 ,3.5, 4.5, 5.5, 6.5, 7.5, 10, 20, 30 ); 1118 * 1119 * @endcode 1120 * 1121 * This example illustrates the filling of the 3D histogram ID=15 1122 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 1123 * 1124 * If the histogram with given title does not exist yet 1125 * it will be automatically booked with parameters 1126 * @c lowX equal to 2.5, @c highX equal to 3.5, 1127 * @c lowY equal to 4.5, @c highY equal to 5.5, 1128 * @c lowZ equal to 6.5, @c highZ equal to 7.5, 1129 * @c binsX equal to 10, @c binsY equal to 20 and @c binsZ equal to 30. 1130 * 1131 * It is also possible to use literal IDs. For example :- 1132 * 1133 * @code 1134 * 1135 * const double X = ... ; 1136 * const double Y = ... ; 1137 * const double Z = ... ; 1138 * plot3D( X, Y, Z, 1139 * "space", "Space Points" , 1140 * 2.5 ,3.5, 4.5, 5.5, 6.5, 7.5, 10, 20, 30 ); 1141 * 1142 * @endcode 1143 * 1144 * Will book the same histogram, using the id "space". 1145 * 1146 * It is also possible using literal IDs, to place histograms in 1147 * sub-directories from the main histogram directory, using for 1148 * example :- 1149 * 1150 * @code 1151 * 1152 * const double X = ... ; 1153 * const double Y = ... ; 1154 * const double Z = ... ; 1155 * plot3D( X, Y, Z, 1156 * "subdir/space", "Space Points" , 1157 * 2.5 ,3.5, 4.5, 5.5, 6.5, 7.5, 10, 20, 30 ); 1158 * 1159 * @endcode 1160 * 1161 * Which will create the histogram "space" in the sub-directory "subdir". 1162 * Histograms can also be created in sub-directories with numeric IDs if 1163 * IDs such as "subdir/1" are used. 1164 * 1165 * @attention 1166 * If the histogram with given ID is already booked 1167 * through automatic assignment of histogram ID, 1168 * the error will not be detected. 1169 * Therefore it is recommended 1170 * to use non-trivial histogram ID offset (property "HistoOffSet") 1171 * if one need to combine these techniques together 1172 * It is still desirable to use the unique histogram title 1173 * to avoid a bad interference 1174 * 1175 * @see AIDA::IHistogram3D 1176 * 1177 * @param valueX x value to be filled 1178 * @param valueY y value to be filled 1179 * @param valueZ z value to be filled 1180 * @param ID Histogram ID to use 1181 * @param title histogram title (must be unique within the algorithm) 1182 * @param lowX low x limit for histogram 1183 * @param highX high x limit for histogram 1184 * @param lowY low y limit for histogram 1185 * @param highY high y limit for histogram 1186 * @param lowZ low z limit for histogram 1187 * @param highZ high z limit for histogram 1188 * @param binsX number of bins in x 1189 * @param binsY number of bins in y 1190 * @param binsZ number of bins in z 1191 * @param weight weight 1192 * @return pointer to AIDA 3D histogram 1193 */ 1194 AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const HistoID& ID, 1195 const std::string& title, const double lowX, const double highX, const double lowY, 1196 const double highY, const double lowZ, const double highZ, const unsigned long binsX = 10, 1197 const unsigned long binsY = 10, const unsigned long binsZ = 10, 1198 const double weight = 1.0 ) const; 1199 // ========================================================================== 1200 // ================================= 3D Histograms ========================== 1201 // =============================== Variable Binning ========================= 1202 // ========================================================================== 1203 /** Fill the 3D variable binning histogram (book on demand) 1204 * 1205 * @code 1206 * 1207 * const GaudiAlg::HistoBinEdges edgesX = ...; 1208 * const GaudiAlg::HistoBinEdges edgesY = ...; 1209 * const GaudiAlg::HistoBinEdges edgesZ = ...; 1210 * const double X = ... ; 1211 * const double Y = ... ; 1212 * const double Z = ... ; 1213 * plot3D( X, Y, Z, "Space Points", edgesX, edgesY, edgesZ ); 1214 * 1215 * @endcode 1216 * 1217 * This example illustrates the filling of the 3D histogram 1218 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 1219 * 1220 * If the histogram with given title does not exist yet 1221 * it will be automatically booked with the given histogram bin edges. 1222 * 1223 * @attention 1224 * The histogram will get a unique identifier automatically assigned which by 1225 * default will be equal to the histogram title. An option exists to instead 1226 * use numerical IDs. In this case the first histogram booked will be ID=1 the 1227 * next ID=2 and so on. Note though this scheme is not recommended as it does 1228 * NOT guarantee predictability of the ID a given histogram will be given when 1229 * filled under conditional statements, since in these circumstances the order 1230 * in which the histograms are first filled, and thus booked, will depend on the 1231 * nature of the first few events read. This is particularly problematic when 1232 * users submit many parallel 'sub-jobs' and then attempt to merge the final 1233 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 1234 * in each of the sub-jobs. Consequently it is strongly recommended that users do 1235 * not use numerical automatic IDs unless they are sure they understand what they 1236 * are doing. 1237 * 1238 * @see AIDA::IHistogram3D 1239 * 1240 * @param valueX x value to be filled 1241 * @param valueY y value to be filled 1242 * @param valueZ z value to be filled 1243 * @param title histogram title (must be unique within the algorithm) 1244 * @param edgesX The histogram x bin edges 1245 * @param edgesY The histogram y bin edges 1246 * @param edgesZ The histogram z bin edges 1247 * @param weight weight 1248 * @return pointer to AIDA 3D histogram 1249 */ 1250 AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const std::string& title, 1251 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ, 1252 const double weight = 1.0 ) const; 1253 // ========================================================================== 1254 // ========================================================================== 1255 /** fill the 3D histogram with forced ID assignment (book on demand) 1256 * 1257 * @code 1258 * 1259 * const GaudiAlg::HistoBinEdges edgesX = ...; 1260 * const GaudiAlg::HistoBinEdges edgesY = ...; 1261 * const GaudiAlg::HistoBinEdges edgesZ = ...; 1262 * const double X = ... ; 1263 * const double Y = ... ; 1264 * const double Z = ... ; 1265 * plot3D( X, Y, Z, "Space Points", edgesX, edgesY, edgesZ ); 1266 * 1267 * @endcode 1268 * 1269 * This example illustrates the filling of the 3D histogram ID=15 1270 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 1271 * 1272 * If the histogram with given title does not exist yet 1273 * it will be automatically booked with the given histogram bin edges and 1274 * histogram ID. 1275 * 1276 * It is also possible to use literal IDs. For example :- 1277 * 1278 * @code 1279 * 1280 * const GaudiAlg::HistoBinEdges edgesX = ...; 1281 * const GaudiAlg::HistoBinEdges edgesY = ...; 1282 * const GaudiAlg::HistoBinEdges edgesZ = ...; 1283 * const double X = ... ; 1284 * const double Y = ... ; 1285 * const double Z = ... ; 1286 * plot3D( X, Y, Z, 1287 * "space", "Space Points" , 1288 * edgesX, edgesY, edgesZ ); 1289 * 1290 * @endcode 1291 * 1292 * Will book the same histogram, using the id "space". 1293 * 1294 * It is also possible using literal IDs, to place histograms in 1295 * sub-directories from the main histogram directory, using for 1296 * example :- 1297 * 1298 * @code 1299 * 1300 * const GaudiAlg::HistoBinEdges edgesX = ...; 1301 * const GaudiAlg::HistoBinEdges edgesY = ...; 1302 * const GaudiAlg::HistoBinEdges edgesZ = ...; 1303 * const double X = ... ; 1304 * const double Y = ... ; 1305 * const double Z = ... ; 1306 * plot3D( X, Y, Z, 1307 * "subdir/space", "Space Points" , 1308 * edgesX, edgesY, edgesZ ); 1309 * 1310 * @endcode 1311 * 1312 * Which will create the histogram "space" in the sub-directory "subdir". 1313 * Histograms can also be created in sub-directories with numeric IDs if 1314 * IDs such as "subdir/1" are used. 1315 * 1316 * @attention 1317 * If the histogram with given ID is already booked 1318 * through automatic assignment of histogram ID, 1319 * the error will not be detected. 1320 * Therefore it is recommended 1321 * to use non-trivial histogram ID offset (property "HistoOffSet") 1322 * if one need to combine these techniques together 1323 * It is still desirable to use the unique histogram title 1324 * to avoid a bad interference 1325 * 1326 * @see AIDA::IHistogram3D 1327 * 1328 * @param valueX x value to be filled 1329 * @param valueY y value to be filled 1330 * @param valueZ z value to be filled 1331 * @param ID Histogram ID to use 1332 * @param title histogram title (must be unique within the algorithm) 1333 * @param edgesX The histogram x bin edges 1334 * @param edgesY The histogram y bin edges 1335 * @param edgesZ The histogram z bin edges 1336 * @param weight weight 1337 * @return pointer to AIDA 3D histogram 1338 */ 1339 AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const HistoID& ID, 1340 const std::string& title, const HistoBinEdges& edgesX, const HistoBinEdges& edgesY, 1341 const HistoBinEdges& edgesZ, const double weight = 1.0 ) const; 1342 // ========================================================================== 1343 // ================================= 1D Profile ============================= 1344 // ================================= Fixed binning ========================== 1345 // ========================================================================== 1346 /** fill the 1D profile histogram (book on demand) 1347 * 1348 * @code 1349 * 1350 * const double mass1 = ... ; 1351 * const double mass2 = ... ; 1352 * profile1D( mass1, mass2, "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 100 ); 1353 * 1354 * @endcode 1355 * 1356 * This example illustrates the filling of the 1D profile histogram 1357 * titled <tt>"Invariant Mass2 versus Mass1"</tt> 1358 * with values @c mass1 and @c mass2 . 1359 * 1360 * If the histogram with given title does not exist yet 1361 * it will be automatically booked with parameters 1362 * @c lowX equal to 2.5, @c highX equal to 3.5, 1363 * @c binsX equal to 100 1364 * 1365 * @attention 1366 * The histogram will get a unique identifier automatically assigned which by 1367 * default will be equal to the histogram title. An option exists to instead 1368 * use numerical IDs. In this case the first histogram booked will be ID=1 the 1369 * next ID=2 and so on. Note though this scheme is not recommended as it does 1370 * NOT guarantee predictability of the ID a given histogram will be given when 1371 * filled under conditional statements, since in these circumstances the order 1372 * in which the histograms are first filled, and thus booked, will depend on the 1373 * nature of the first few events read. This is particularly problematic when 1374 * users submit many parallel 'sub-jobs' and then attempt to merge the final 1375 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 1376 * in each of the sub-jobs. Consequently it is strongly recommended that users do 1377 * not use numerical automatic IDs unless they are sure they understand what they 1378 * are doing. 1379 * 1380 * @see AIDA::IProfile1D 1381 * 1382 * @param valueX x value to be filled 1383 * @param valueY y value to be filled 1384 * @param title histogram title (must be unique within the algorithm) 1385 * @param lowX low x limit for histogram 1386 * @param highX high x limit for histogram 1387 * @param binsX number of bins in x 1388 * @param opt the options, used for evaluation of errors 1389 * @param lowY the min cut-off for y-values 1390 * @param highY the max cut-off for y-values 1391 * @param weight weight 1392 * @return pointer to AIDA 1D profile histogram 1393 */ 1394 AIDA::IProfile1D* profile1D( const double valueX, const double valueY, const std::string& title, const double lowX, 1395 const double highX, const unsigned long binsX = 100, const std::string& opt = "", 1396 const double lowY = -std::numeric_limits<double>::max(), 1397 const double highY = std::numeric_limits<double>::max(), 1398 const double weight = 1.0 ) const; 1399 // ========================================================================== 1400 /** fill the 1D profile histogram with forced ID assignment (book on demand) 1401 * 1402 * @code 1403 * 1404 * const double mass1 = ... ; 1405 * const double mass2 = ... ; 1406 * profile1D( mass1, mass2, 1407 * 15, "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 100 ); 1408 * 1409 * @endcode 1410 * 1411 * This example illustrates the filling of the 1D profile histogram with ID=15 1412 * titled <tt>"Invariant Mass2 versus Mass1"</tt> with 1413 * values @c mass1 and @c mass2 . 1414 * 1415 * If the histogram with given title does not exist yet 1416 * it will be automatically booked with parameters 1417 * @c lowX equal to 2.5, @c highX equal to 3.5, 1418 * @c binsX equal to 100 1419 * 1420 * It is also possible to use literal IDs. For example :- 1421 * 1422 * @code 1423 * 1424 * const double mass1 = ... ; 1425 * const double mass2 = ... ; 1426 * profile1D( mass1, mass2, 1427 * "mass", "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 100 ); 1428 * 1429 * @endcode 1430 * 1431 * Will book the same histogram, using the id "mass". 1432 * 1433 * It is also possible using literal IDs, to place histograms in 1434 * sub-directories from the main histogram directory, using for 1435 * example :- 1436 * 1437 * @code 1438 * 1439 * const double mass1 = ... ; 1440 * const double mass2 = ... ; 1441 * profile1D( mass1, mass2, 1442 * "subdir/mass", "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 100 ); 1443 * 1444 * @endcode 1445 * 1446 * Which will create the histogram "mass" in the sub-directory "subdir". 1447 * Histograms can also be created in sub-directories with numeric IDs if 1448 * IDs such as "subdir/1" are used. 1449 * 1450 * @see AIDA::IProfile1D 1451 * 1452 * @param valueX x value to be filled 1453 * @param valueY y value to be filled 1454 * @param ID histogram identifier 1455 * @param title histogram title (must be unique within the algorithm) 1456 * @param lowX low x limit for histogram 1457 * @param highX high x limit for histogram 1458 * @param binsX number of bins in x 1459 * @param opt the options, used for evaluation of errors 1460 * @param lowY the min cut-off for y-values 1461 * @param highY the max cut-off for y-values 1462 * @param weight weight 1463 * @return pointer to AIDA 1D profile histogram 1464 */ 1465 AIDA::IProfile1D* profile1D( const double valueX, const double valueY, const HistoID& ID, const std::string& title, 1466 const double lowX, const double highX, const unsigned long binsX = 100, 1467 const std::string& opt = "", const double lowY = -std::numeric_limits<double>::max(), 1468 const double highY = std::numeric_limits<double>::max(), 1469 const double weight = 1.0 ) const; 1470 // ========================================================================== 1471 // ================================= 1D Profile ============================= 1472 // ============================== Variable binning ========================== 1473 // ========================================================================== 1474 /** fill the 1D variable binning profile histogram (book on demand) 1475 * 1476 * @code 1477 * 1478 * const GaudiAlg::HistoBinEdges edges = ...; 1479 * const double mass1 = ... ; 1480 * const double mass2 = ... ; 1481 * profile1D( mass1, mass2, "Invariant Mass2 versus Mass1", edges ); 1482 * 1483 * @endcode 1484 * 1485 * This example illustrates the filling of the 1D profile histogram 1486 * titled <tt>"Invariant Mass2 versus Mass1"</tt> 1487 * with values @c mass1 and @c mass2 . 1488 * 1489 * If the histogram with given title does not exist yet 1490 * it will be automatically booked with the given histogram bin edges. 1491 * 1492 * @attention 1493 * The histogram will get a unique identifier automatically assigned which by 1494 * default will be equal to the histogram title. An option exists to instead 1495 * use numerical IDs. In this case the first histogram booked will be ID=1 the 1496 * next ID=2 and so on. Note though this scheme is not recommended as it does 1497 * NOT guarantee predictability of the ID a given histogram will be given when 1498 * filled under conditional statements, since in these circumstances the order 1499 * in which the histograms are first filled, and thus booked, will depend on the 1500 * nature of the first few events read. This is particularly problematic when 1501 * users submit many parallel 'sub-jobs' and then attempt to merge the final 1502 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 1503 * in each of the sub-jobs. Consequently it is strongly recommended that users do 1504 * not use numerical automatic IDs unless they are sure they understand what they 1505 * are doing. 1506 * 1507 * @see AIDA::IProfile1D 1508 * 1509 * @param valueX x value to be filled 1510 * @param valueY y value to be filled 1511 * @param title histogram title (must be unique within the algorithm) 1512 * @param edges The histogram bin edges 1513 * @param weight weight 1514 * @return pointer to AIDA 1D profile histogram 1515 */ 1516 AIDA::IProfile1D* profile1D( const double valueX, const double valueY, const std::string& title, 1517 const HistoBinEdges& edges, const double weight = 1.0 ) const; 1518 // ========================================================================== 1519 /** fill the 1D variable binning profile histogram with forced ID assignment (book on demand) 1520 * 1521 * @code 1522 * 1523 * const GaudiAlg::HistoBinEdges edges = ...; 1524 * const double mass1 = ... ; 1525 * const double mass2 = ... ; 1526 * profile1D( mass1, mass2, 1527 * 15, "Invariant Mass2 versus Mass1", edges ); 1528 * 1529 * @endcode 1530 * 1531 * This example illustrates the filling of the 1D profile histogram with ID=15 1532 * titled <tt>"Invariant Mass2 versus Mass1"</tt> with 1533 * values @c mass1 and @c mass2 . 1534 * 1535 * If the histogram with given ID does not exist yet 1536 * it will be automatically booked with the given histogram bin edges. 1537 * 1538 * It is also possible to use literal IDs. For example :- 1539 * 1540 * @code 1541 * 1542 * const GaudiAlg::HistoBinEdges edges = ...; 1543 * const double mass1 = ... ; 1544 * const double mass2 = ... ; 1545 * profile1D( mass1, mass2, 1546 * "mass", "Invariant Mass2 versus Mass1", edges ); 1547 * 1548 * @endcode 1549 * 1550 * Will book the same histogram, using the id "mass". 1551 * 1552 * It is also possible using literal IDs, to place histograms in 1553 * sub-directories from the main histogram directory, using for 1554 * example :- 1555 * 1556 * @code 1557 * 1558 * const GaudiAlg::HistoBinEdges edges = ...; 1559 * const double mass1 = ... ; 1560 * const double mass2 = ... ; 1561 * profile1D( mass1, mass2, 1562 * "subdir/mass", "Invariant Mass2 versus Mass1", edges ); 1563 * 1564 * @endcode 1565 * 1566 * Which will create the histogram "mass" in the sub-directory "subdir". 1567 * Histograms can also be created in sub-directories with numeric IDs if 1568 * IDs such as "subdir/1" are used. 1569 * 1570 * @see AIDA::IProfile1D 1571 * 1572 * @param valueX x value to be filled 1573 * @param valueY y value to be filled 1574 * @param ID histogram identifier 1575 * @param title histogram title (must be unique within the algorithm) 1576 * @param edges The histogram bin edges 1577 * @param weight weight 1578 * @return pointer to AIDA 1D profile histogram 1579 */ 1580 AIDA::IProfile1D* profile1D( const double valueX, const double valueY, const HistoID& ID, const std::string& title, 1581 const HistoBinEdges& edges, const double weight = 1.0 ) const; 1582 // ========================================================================== 1583 // ================================= 2D Profile ============================= 1584 // ========================================================================== 1585 /** fill the 2D profile histogram (book on demand) 1586 * 1587 * @code 1588 * 1589 * const double X = ... ; 1590 * const double Y = ... ; 1591 * const double Z = ... ; 1592 * profile2( X, Y, Z, "Space Points" ,2.5 ,3.5, 4.5, 5.5, 10, 20 ); 1593 * 1594 * @endcode 1595 * 1596 * This example illustrates the filling of the 2D profile histogram 1597 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 1598 * 1599 * If the histogram with given title does not exist yet 1600 * it will be automatically booked with parameters 1601 * @c lowX equal to 2.5, @c highX equal to 3.5, 1602 * @c lowY equal to 4.5, @c highY equal to 5.5, 1603 * @c binsX equal to 10, @c binsY equal to 20. 1604 * 1605 * @attention 1606 * The histogram will get a unique identifier automatically assigned which by 1607 * default will be equal to the histogram title. An option exists to instead 1608 * use numerical IDs. In this case the first histogram booked will be ID=1 the 1609 * next ID=2 and so on. Note though this scheme is not recommended as it does 1610 * NOT guarantee predictability of the ID a given histogram will be given when 1611 * filled under conditional statements, since in these circumstances the order 1612 * in which the histograms are first filled, and thus booked, will depend on the 1613 * nature of the first few events read. This is particularly problematic when 1614 * users submit many parallel 'sub-jobs' and then attempt to merge the final 1615 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 1616 * in each of the sub-jobs. Consequently it is strongly recommended that users do 1617 * not use numerical automatic IDs unless they are sure they understand what they 1618 * are doing. 1619 * 1620 * @see AIDA::IProfile2D 1621 * 1622 * @param valueX x value to be filled 1623 * @param valueY y value to be filled 1624 * @param valueZ z value to be filled 1625 * @param title histogram title (must be unique within the algorithm) 1626 * @param lowX low x limit for histogram 1627 * @param highX high x limit for histogram 1628 * @param lowY low y limit for histogram 1629 * @param highY high y limit for histogram 1630 * @param binsX number of bins in x 1631 * @param binsY number of bins in y 1632 * @param weight weight 1633 * @return pointer to AIDA 2D profile histogram 1634 */ 1635 AIDA::IProfile2D* profile2D( const double valueX, const double valueY, const double valueZ, const std::string& title, 1636 const double lowX, const double highX, const double lowY, const double highY, 1637 const unsigned long binsX = 50, const unsigned long binsY = 50, 1638 const double weight = 1.0 ) const; 1639 // ========================================================================== 1640 /** fill the 2D profile histogram with forced ID assignment (book on demand) 1641 * 1642 * @code 1643 * 1644 * const double X = ... ; 1645 * const double Y = ... ; 1646 * const double Z = ... ; 1647 * profile2D( X, Y, Z, 15, "Space Points" ,2.5 ,3.5, 4.5, 5.5, 10, 20 ); 1648 * 1649 * @endcode 1650 * 1651 * This example illustrates the filling of the 2D profile histogram with ID=15 1652 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 1653 * 1654 * If the histogram with given title does not exist yet 1655 * it will be automatically booked with parameters 1656 * @c lowX equal to 2.5, @c highX equal to 3.5, 1657 * @c lowY equal to 4.5, @c highY equal to 5.5, 1658 * @c binsX equal to 10, @c binsY equal to 20. 1659 * 1660 * It is also possible to use literal IDs. For example :- 1661 * 1662 * @code 1663 * 1664 * const double X = ... ; 1665 * const double Y = ... ; 1666 * const double Z = ... ; 1667 * profile2D( X, Y, Z, "space", "Space Points" ,2.5 ,3.5, 4.5, 5.5, 10, 20 ); 1668 * 1669 * @endcode 1670 * 1671 * Will book the same histogram, using the id "space". 1672 * 1673 * It is also possible using literal IDs, to place histograms in 1674 * sub-directories from the main histogram directory, using for 1675 * example :- 1676 * 1677 * @code 1678 * 1679 * const double X = ... ; 1680 * const double Y = ... ; 1681 * const double Z = ... ; 1682 * profile2D( X, Y, Z, 1683 * "subdir/space", "Space Points" ,2.5 ,3.5, 4.5, 5.5, 10, 20 ); 1684 * 1685 * @endcode 1686 * 1687 * Which will create the histogram "space" in the sub-directory "subdir". 1688 * Histograms can also be created in sub-directories with numeric IDs if 1689 * IDs such as "subdir/1" are used. 1690 * 1691 * @see AIDA::IProfile2D 1692 * 1693 * @param valueX x value to be filled 1694 * @param valueY y value to be filled 1695 * @param valueZ z value to be filled 1696 * @param ID histogram identifier 1697 * @param title histogram title (must be unique within the algorithm) 1698 * @param lowX low x limit for histogram 1699 * @param highX high x limit for histogram 1700 * @param lowY low y limit for histogram 1701 * @param highY high y limit for histogram 1702 * @param binsX number of bins in x 1703 * @param binsY number of bins in y 1704 * @param weight weight 1705 * @return pointer to AIDA 2D profile histogram 1706 */ 1707 AIDA::IProfile2D* profile2D( const double valueX, const double valueY, const double valueZ, const HistoID& ID, 1708 const std::string& title, const double lowX, const double highX, const double lowY, 1709 const double highY, const unsigned long binsX = 50, const unsigned long binsY = 50, 1710 const double weight = 1.0 ) const; 1711 // ========================================================================== 1712 // ================================= 2D Profile ============================= 1713 // ============================== Variable binning ========================== 1714 // ========================================================================== 1715 /** fill the 2D variable binning profile histogram (book on demand) 1716 * 1717 * @code 1718 * 1719 * const GaudiAlg::HistoBinEdges edgesX = ...; 1720 * const GaudiAlg::HistoBinEdges edgesY = ...; 1721 * const double X = ... ; 1722 * const double Y = ... ; 1723 * const double Z = ... ; 1724 * profile2D( X, Y, Z, "Space Points", edgesX, edgesY ); 1725 * 1726 * @endcode 1727 * 1728 * This example illustrates the filling of the 2D profile histogram 1729 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 1730 * 1731 * If the histogram with given title does not exist yet 1732 * it will be automatically booked with the given histogram bin edges. 1733 * 1734 * @attention 1735 * The histogram will get a unique identifier automatically assigned which by 1736 * default will be equal to the histogram title. An option exists to instead 1737 * use numerical IDs. In this case the first histogram booked will be ID=1 the 1738 * next ID=2 and so on. Note though this scheme is not recommended as it does 1739 * NOT guarantee predictability of the ID a given histogram will be given when 1740 * filled under conditional statements, since in these circumstances the order 1741 * in which the histograms are first filled, and thus booked, will depend on the 1742 * nature of the first few events read. This is particularly problematic when 1743 * users submit many parallel 'sub-jobs' and then attempt to merge the final 1744 * output ROOT (or HBOOK) files, since a given histogram could have different IDs 1745 * in each of the sub-jobs. Consequently it is strongly recommended that users do 1746 * not use numerical automatic IDs unless they are sure they understand what they 1747 * are doing. 1748 * 1749 * @see AIDA::IProfile2D 1750 * 1751 * @param valueX x value to be filled 1752 * @param valueY y value to be filled 1753 * @param valueZ z value to be filled 1754 * @param title histogram title (must be unique within the algorithm) 1755 * @param edgesX The histogram x bin edges 1756 * @param edgesY The histogram x bin edges 1757 * @param weight weight 1758 * @return pointer to AIDA 1D profile histogram 1759 */ 1760 AIDA::IProfile2D* profile2D( const double valueX, const double valueY, const double valueZ, const std::string& title, 1761 const HistoBinEdges& edgesX, const HistoBinEdges& edgesY, 1762 const double weight = 1.0 ) const; 1763 // ========================================================================== 1764 /** fill the 2D variable binning profile histogram with forced ID assignment (book on demand) 1765 * 1766 * @code 1767 * 1768 * const GaudiAlg::HistoBinEdges edgesX = ...; 1769 * const GaudiAlg::HistoBinEdges edgesY = ...; 1770 * const double X = ... ; 1771 * const double Y = ... ; 1772 * const double Z = ... ; 1773 * profile2( X, Y, Z, "Space Points", edgesX, edgesY ); 1774 * 1775 * @endcode 1776 * 1777 * This example illustrates the filling of the 2D profile histogram 1778 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 1779 * 1780 * If the histogram with given ID does not exist yet 1781 * it will be automatically booked with the given histogram bin edges. 1782 * 1783 * It is also possible to use literal IDs. For example :- 1784 * 1785 * @code 1786 * 1787 * const double X = ... ; 1788 * const double Y = ... ; 1789 * const double Z = ... ; 1790 * profile2D( X, Y, Z, "space", "Space Points", edgesX, edgesY ); 1791 * 1792 * @endcode 1793 * 1794 * Will book the same histogram, using the id "mass". 1795 * 1796 * It is also possible using literal IDs, to place histograms in 1797 * sub-directories from the main histogram directory, using for 1798 * example :- 1799 * 1800 * @code 1801 * 1802 * const double X = ... ; 1803 * const double Y = ... ; 1804 * const double Z = ... ; 1805 * profile2D( X, Y, Z, 1806 * "subdir/space", "Space Points", edgesX, edgesY ); 1807 * 1808 * @endcode 1809 * 1810 * Which will create the histogram "mass" in the sub-directory "subdir". 1811 * Histograms can also be created in sub-directories with numeric IDs if 1812 * IDs such as "subdir/1" are used. 1813 * 1814 * @see AIDA::IProfile2D 1815 * 1816 * @param valueX x value to be filled 1817 * @param valueY y value to be filled 1818 * @param valueZ z value to be filled 1819 * @param ID histogram identifier 1820 * @param title histogram title (must be unique within the algorithm) 1821 * @param edgesX The histogram x bin edges 1822 * @param edgesY The histogram y bin edges 1823 * @param weight weight 1824 * @return pointer to AIDA 1D profile histogram 1825 */ 1826 AIDA::IProfile2D* profile2D( const double valueX, const double valueY, const double valueZ, const HistoID& ID, 1827 const std::string& title, const HistoBinEdges& edgesX, const HistoBinEdges& edgesY, 1828 const double weight = 1.0 ) const; 1829 // ========================================================================== 1830 1831 public: // 1D Fixed 1832 // ========================================================================== 1833 /** book the 1D histogram 1834 * 1835 * The histogram will be assigned a unique identifier 1836 * 1837 * @see AIDA::IHistogram1D 1838 * @param title histogram title (must be unique within the algorithm) 1839 * @param low low limit for histogram 1840 * @param high high limit for histogram 1841 * @param bins number of bins 1842 * @return pointer to AIDA 1D histogram 1843 */ 1844 AIDA::IHistogram1D* book1D( const std::string& title, const double low = 0, const double high = 100, 1845 const unsigned long bins = 100 ) const; 1846 // ========================================================================== 1847 /** book the 1D histogram 1848 * 1849 * Wrapper method for the equivalent book1D method. 1850 * Retained for backwards compatibility, please use book1D instead. 1851 * 1852 * @see IHistogram1D 1853 * @param title histogram title (must be unique within the algorithm) 1854 * @param low low limit for histogram 1855 * @param high high limit for histogram 1856 * @param bins number of bins 1857 * @return pointer to AIDA 1D histogram 1858 */ 1859 inline AIDA::IHistogram1D* book( const std::string& title, const double low = 0, const double high = 100, 1860 const unsigned long bins = 100 ) const { 1861 return book1D( title, low, high, bins ); 1862 } 1863 // ========================================================================== 1864 /** book the 1D histogram 1865 * 1866 * The histogram will be assigned a unique identifier 1867 * 1868 * @see AIDA::IHistogram1D 1869 * @param hdef histogram description/definition 1870 * @return pointer to AIDA 1D histogram 1871 */ 1872 AIDA::IHistogram1D* book( const Gaudi::Histo1DDef& hdef ) const; 1873 // ========================================================================== 1874 /** book the 1D histogram with forced ID 1875 * 1876 * @see IHistogram1D 1877 * @param ID unique histogram ID 1878 * @param title histogram title (must be unique within the algorithm) 1879 * @param low low limit for histogram 1880 * @param high high limit for histogram 1881 * @param bins number of bins 1882 * @return pointer to AIDA histogram 1883 */ 1884 AIDA::IHistogram1D* book1D( const HistoID& ID, const std::string& title, const double low = 0, 1885 const double high = 100, const unsigned long bins = 100 ) const; 1886 // ========================================================================== 1887 /** book the 1D histogram with forced ID 1888 * 1889 * Wrapper method for the equivalent book1D method. 1890 * Retained for backwards compatibility, please use book1D instead. 1891 * 1892 * @see IHistogram1D 1893 * @param ID unique histogram ID 1894 * @param title histogram title (must be unique within the algorithm) 1895 * @param low low limit for histogram 1896 * @param high high limit for histogram 1897 * @param bins number of bins 1898 * @return pointer to AIDA histogram 1899 */ 1900 inline AIDA::IHistogram1D* book( const HistoID& ID, const std::string& title, const double low = 0, 1901 const double high = 100, const unsigned long bins = 100 ) const { 1902 return book1D( ID, title, low, high, bins ); 1903 } 1904 // ========================================================================== 1905 /** book the 1D histogram with forced ID 1906 * 1907 * @see IHistogram1D 1908 * @param ID unique histogram ID 1909 * @param hdef histogram descriptor 1910 * @return pointer to AIDA histogram 1911 */ 1912 inline AIDA::IHistogram1D* book( const HistoID& ID, const Gaudi::Histo1DDef& hdef ) const; 1913 // ========================================================================== 1914 1915 public: // 1D Variable 1916 // ========================================================================== 1917 /** book the 1D variable binning histogram 1918 * 1919 * The histogram will be assigned a unique identifier 1920 * 1921 * @see AIDA::IHistogram1D 1922 * 1923 * @param title histogram title (must be unique within the algorithm) 1924 * @param edges The histogram bin edges 1925 * @return pointer to AIDA 1D histogram 1926 */ 1927 AIDA::IHistogram1D* book1D( const std::string& title, const HistoBinEdges& edges ) const; 1928 // ========================================================================== 1929 /** book the 1D variable binning histogram with given ID 1930 * 1931 * @see AIDA::IHistogram1D 1932 * 1933 * @param ID unique histogram ID 1934 * @param title histogram title (must be unique within the algorithm) 1935 * @param edges The histogram bin edges 1936 * @return pointer to AIDA 1D histogram 1937 */ 1938 AIDA::IHistogram1D* book1D( const HistoID& ID, const std::string& title, const HistoBinEdges& edges ) const; 1939 // ========================================================================== 1940 1941 public: // 2D Fixed 1942 // ========================================================================== 1943 /** book the 2D histogram 1944 * 1945 * The histogram will be assigned a unique identifier 1946 * 1947 * @see IHistogram2D 1948 * @param title histogram title (must be unique within the algorithm) 1949 * @param lowX low x limit for histogram 1950 * @param highX high x limit for histogram 1951 * @param binsX number of bins in x 1952 * @param lowY low y limit for histogram 1953 * @param highY high y limit for histogram 1954 * @param binsY number of bins in y 1955 * @return pointer to AIDA 2D histogram 1956 */ 1957 AIDA::IHistogram2D* book2D( const std::string& title, const double lowX = 0, const double highX = 100, 1958 const unsigned long binsX = 50, const double lowY = 0, const double highY = 100, 1959 const unsigned long binsY = 50 ) const; 1960 // ========================================================================== 1961 /** book the 2D histogram with forced ID 1962 * 1963 * @see IHistogram2D 1964 * @param ID unique histogram ID 1965 * @param title histogram title (must be unique within the algorithm) 1966 * @param low low limit for histogram 1967 * @param high high limit for histogram 1968 * @param bins number of bins 1969 * @return pointer to AIDA histogram 1970 */ 1971 AIDA::IHistogram2D* book2D( const HistoID& ID, const std::string& title, const double lowX = 0, 1972 const double highX = 100, const unsigned long binsX = 50, const double lowY = 0, 1973 const double highY = 100, const unsigned long binsY = 50 ) const; 1974 // ========================================================================== 1975 1976 public: // 2D Variable 1977 // ========================================================================== 1978 /** book the 2D variable binning histogram 1979 * 1980 * The histogram will be assigned a unique identifier 1981 * 1982 * @see AIDA::IHistogram2D 1983 * 1984 * @param title histogram title (must be unique within the algorithm) 1985 * @param edgesX The histogram x bin edges 1986 * @param edgesY The histogram y bin edges 1987 * @return pointer to AIDA 2D histogram 1988 */ 1989 AIDA::IHistogram2D* book2D( const std::string& title, const HistoBinEdges& edgesX, 1990 const HistoBinEdges& edgesY ) const; 1991 // ========================================================================== 1992 /** book the 2D variable binning histogram with given ID 1993 * 1994 * @see AIDA::IHistogram2D 1995 * 1996 * @param ID unique histogram ID 1997 * @param title histogram title (must be unique within the algorithm) 1998 * @param edgesX The histogram x bin edges 1999 * @param edgesY The histogram y bin edges 2000 * @return pointer to AIDA 2D histogram 2001 */ 2002 AIDA::IHistogram2D* book2D( const HistoID& ID, const std::string& title, const HistoBinEdges& edgesX, 2003 const HistoBinEdges& edgesY ) const; 2004 // ========================================================================== 2005 2006 public: // 3D Fixed 2007 // ========================================================================== 2008 /** book the 3D histogram 2009 * 2010 * The histogram will be assigned a unique identifier 2011 * 2012 * @see IHistogram3D 2013 * @param title histogram title (must be unique within the algorithm) 2014 * @param lowX low x limit for histogram 2015 * @param highX high x limit for histogram 2016 * @param binsX number of bins in x 2017 * @param lowY low y limit for histogram 2018 * @param highY high y limit for histogram 2019 * @param binsY number of bins in y 2020 * @param lowZ low y limit for histogram 2021 * @param highZ high y limit for histogram 2022 * @param binsZ number of bins in y 2023 * @return pointer to AIDA 3D histogram 2024 */ 2025 AIDA::IHistogram3D* book3D( const std::string& title, const double lowX = 0, const double highX = 100, 2026 const unsigned long binsX = 10, const double lowY = 0, const double highY = 100, 2027 const unsigned long binsY = 10, const double lowZ = 0, const double highZ = 100, 2028 const unsigned long binsZ = 10 ) const; 2029 // ========================================================================== 2030 /** book the 3D histogram with forced ID 2031 * 2032 * @see IHistogram3D 2033 * @param ID unique histogram ID 2034 * @param title histogram title (must be unique within the algorithm) 2035 * @param lowX low x limit for histogram 2036 * @param highX high x limit for histogram 2037 * @param binsX number of bins in x 2038 * @param lowY low y limit for histogram 2039 * @param highY high y limit for histogram 2040 * @param binsY number of bins in y 2041 * @param lowZ low y limit for histogram 2042 * @param highZ high y limit for histogram 2043 * @param binsZ number of bins in y 2044 * @return pointer to AIDA 3D histogram 2045 */ 2046 AIDA::IHistogram3D* book3D( const HistoID& ID, const std::string& title, const double lowX = 0, 2047 const double highX = 100, const unsigned long binsX = 10, const double lowY = 0, 2048 const double highY = 100, const unsigned long binsY = 10, const double lowZ = 0, 2049 const double highZ = 100, const unsigned long binsZ = 10 ) const; 2050 // ========================================================================== 2051 2052 public: // 3D Variable 2053 // ========================================================================== 2054 /** book the 3D variable binning histogram 2055 * 2056 * The histogram will be assigned a unique identifier 2057 * 2058 * @see AIDA::IHistogram3D 2059 * 2060 * @param title histogram title (must be unique within the algorithm) 2061 * @param edgesX The histogram x bin edges 2062 * @param edgesY The histogram y bin edges 2063 * @param edgesZ The histogram z bin edges 2064 * @return pointer to AIDA 3D histogram 2065 */ 2066 AIDA::IHistogram3D* book3D( const std::string& title, const HistoBinEdges& edgesX, const HistoBinEdges& edgesY, 2067 const HistoBinEdges& edgesZ ) const; 2068 // ========================================================================== 2069 /** book the 3D variable binning histogram with given ID 2070 * 2071 * @see AIDA::IHistogram3D 2072 * 2073 * @param ID unique histogram ID 2074 * @param title histogram title (must be unique within the algorithm) 2075 * @param edgesX The histogram x bin edges 2076 * @param edgesY The histogram y bin edges 2077 * @param edgesZ The histogram z bin edges 2078 * @return pointer to AIDA 3D histogram 2079 */ 2080 AIDA::IHistogram3D* book3D( const HistoID& ID, const std::string& title, const HistoBinEdges& edgesX, 2081 const HistoBinEdges& edgesY, const HistoBinEdges& edgesZ ) const; 2082 // ========================================================================== 2083 2084 public: // 1D Fixed Profiles 2085 // ========================================================================== 2086 /** book the 1D profile histogram 2087 * 2088 * The histogram will be assigned a unique identifier 2089 * 2090 * @see IHistogram1D 2091 * @param title histogram title (must be unique within the algorithm) 2092 * @param low low limit for histogram 2093 * @param high high limit for histogram 2094 * @param bins number of bins 2095 * @param opt the options, used for evaluation of errors 2096 * @param lowY the min cut-off for y-values 2097 * @param highY the max cut-off for y-values 2098 * @return pointer to AIDA 1D profile histogram 2099 */ 2100 AIDA::IProfile1D* bookProfile1D( const std::string& title, const double low = 0, const double high = 100, 2101 const unsigned long bins = 100, const std::string& opt = "", 2102 const double lowY = -std::numeric_limits<double>::max(), 2103 const double highY = std::numeric_limits<double>::max() ) const; 2104 // ========================================================================== 2105 /** book the 1D profile histogram 2106 * 2107 * The histogram will be assigned a unique identifier 2108 * 2109 * @see IHistogram1D 2110 * @param title histogram title (must be unique within the algorithm) 2111 * @param edges The histogram bin edges 2112 * @param low low limit for histogram 2113 * @param high high limit for histogram 2114 * @param bins number of bins 2115 * @param opt the options, used for evaluation of errors 2116 * @param lowY the min cut-off for y-values 2117 * @param highY the max cut-off for y-values 2118 * @return pointer to AIDA 1D profile histogram 2119 */ 2120 AIDA::IProfile1D* bookProfile1D( const HistoID& ID, const std::string& title, const double low = 0, 2121 const double high = 100, const unsigned long bins = 100, const std::string& opt = "", 2122 const double lowY = -std::numeric_limits<double>::max(), 2123 const double highY = std::numeric_limits<double>::max() ) const; 2124 // ========================================================================== 2125 2126 public: // 1D Variable Profiles 2127 // ========================================================================== 2128 /** book the 1D profile histogram 2129 * 2130 * The histogram will be assigned a unique identifier 2131 * 2132 * @see IHistogram1D 2133 * @param title histogram title (must be unique within the algorithm) 2134 * @param edges The histogram bin edges 2135 * @return pointer to AIDA 1D profile histogram 2136 */ 2137 AIDA::IProfile1D* bookProfile1D( const std::string& title, const HistoBinEdges& edges ) const; 2138 // ========================================================================== 2139 /** book the 1D profile histogram 2140 * 2141 * The histogram will be assigned a unique identifier 2142 * 2143 * @see IHistogram1D 2144 * @param title histogram title (must be unique within the algorithm) 2145 * @param edges The histogram bin edges 2146 * @return pointer to AIDA 1D profile histogram 2147 */ 2148 AIDA::IProfile1D* bookProfile1D( const HistoID& ID, const std::string& title, const HistoBinEdges& edges ) const; 2149 // ========================================================================== 2150 2151 public: // 2D Profiles 2152 // ========================================================================== 2153 /** book the 2D profile histogram 2154 * 2155 * The histogram will be assigned a unique identifier 2156 * 2157 * @see AIDA::IProfile2D 2158 * @param title histogram title (must be unique within the algorithm) 2159 * @param lowX low x limit for histogram 2160 * @param highX high x limit for histogram 2161 * @param binsX number of bins in x 2162 * @param lowY low y limit for histogram 2163 * @param highY high y limit for histogram 2164 * @param binsY number of bins in y 2165 * @return pointer to AIDA 2D histogram 2166 */ 2167 AIDA::IProfile2D* bookProfile2D( const std::string& title, const double lowX = 0, const double highX = 100, 2168 const unsigned long binsX = 50, const double lowY = 0, const double highY = 100, 2169 const unsigned long binsY = 50 ) const; 2170 // ========================================================================== 2171 /** book the 2D profile histogram with forced ID 2172 * 2173 * @see AIDA::IProfile2D 2174 * @param ID unique histogram ID 2175 * @param title histogram title (must be unique within the algorithm) 2176 * @param lowX low x limit for histogram 2177 * @param highX high x limit for histogram 2178 * @param binsX number of bins in x 2179 * @param lowY low y limit for histogram 2180 * @param highY high y limit for histogram 2181 * @param binsY number of bins in y 2182 * @return pointer to AIDA histogram 2183 */ 2184 AIDA::IProfile2D* bookProfile2D( const HistoID& ID, const std::string& title, const double lowX = 0, 2185 const double highX = 100, const unsigned long binsX = 50, const double lowY = 0, 2186 const double highY = 100, const unsigned long binsY = 50 ) const; 2187 // ========================================================================== 2188 2189 public: // 2D Profiles 2190 // ========================================================================== 2191 /** book the 2D profile histogram 2192 * 2193 * The histogram will be assigned a unique identifier 2194 * 2195 * @see AIDA::IProfile2D 2196 * @param title histogram title (must be unique within the algorithm) 2197 * @param edgesX x bin edges 2198 * @param edgesY y bin edges 2199 * @return pointer to AIDA 2D histogram 2200 */ 2201 AIDA::IProfile2D* bookProfile2D( const std::string& title, const HistoBinEdges& edgesX, 2202 const HistoBinEdges& edgesY ) const; 2203 // ========================================================================== 2204 /** book the 2D profile histogram with forced ID 2205 * 2206 * @see AIDA::IProfile2D 2207 * @param ID unique histogram ID 2208 * @param title histogram title (must be unique within the algorithm) 2209 * @param edgesX x bin edges 2210 * @param edgesY y bin edges 2211 * @return pointer to AIDA histogram 2212 */ 2213 AIDA::IProfile2D* bookProfile2D( const HistoID& ID, const std::string& title, const HistoBinEdges& edgesX, 2214 const HistoBinEdges& edgesY ) const; 2215 // ========================================================================== 2216 2217 public: 2218 // ========================================================================== 2219 /** fill the 1D histogram with the value and weight 2220 * @param histo 1D histogram to be filled 2221 * @param value value to be put into the histogram 2222 * @param weight weight to be used 2223 * @param title histogram title (to be used for error report) 2224 * @return pointer to AIDA 1D histogram 2225 */ 2226 AIDA::IHistogram1D* fill( AIDA::IHistogram1D* histo, const double value, const double weight, 2227 const std::string& title = "" ) const; 2228 // ========================================================================== 2229 /** fill the 2D histogram with the value and weight 2230 * @param histo 2D histogram to be filled 2231 * @param valueX x value to be put into the histogram 2232 * @param valueY y value to be put into the histogram 2233 * @param weight weight to be used 2234 * @param title histogram title (to be used for error report) 2235 * @return pointer to AIDA 2D histogram 2236 */ 2237 AIDA::IHistogram2D* fill( AIDA::IHistogram2D* histo, const double valueX, const double valueY, const double weight, 2238 const std::string& title = "" ) const; 2239 // ========================================================================== 2240 /** fill the 3D histogram with the value and weight 2241 * @param histo 3D histogram to be filled 2242 * @param valueX x value to be put into the histogram 2243 * @param valueY y value to be put into the histogram 2244 * @param valueZ z value to be put into the histogram 2245 * @param weight weight to be used 2246 * @param title histogram title (to be used for error report) 2247 * @return pointer to AIDA 3D histogram 2248 */ 2249 AIDA::IHistogram3D* fill( AIDA::IHistogram3D* histo, const double valueX, const double valueY, const double valueZ, 2250 const double weight, const std::string& title = "" ) const; 2251 // ========================================================================== 2252 /** fill the 1D profile histogram with the values and weight 2253 * @param histo 1D profile histogram to be filled 2254 * @param valueX x value to be put into the histogram 2255 * @param valueY y value to be put into the histogram 2256 * @param weight weight to be used 2257 * @param title histogram title (to be used for error report) 2258 * @return pointer to AIDA 1D histogram 2259 */ 2260 AIDA::IProfile1D* fill( AIDA::IProfile1D* histo, const double valueX, const double valueY, const double weight, 2261 const std::string& title = "" ) const; 2262 // ========================================================================== 2263 /** fill the 2D profile histogram with the values and weight 2264 * @param histo 2D profile histogram to be filled 2265 * @param valueX x value to be put into the histogram 2266 * @param valueY y value to be put into the histogram 2267 * @param valueZ z value to be put into the histogram 2268 * @param weight weight to be used 2269 * @param title histogram title (to be used for error report) 2270 * @return pointer to AIDA 1D histogram 2271 */ 2272 AIDA::IProfile2D* fill( AIDA::IProfile2D* histo, const double valueX, const double valueY, const double valueZ, 2273 const double weight, const std::string& title = "" ) const; 2274 // ========================================================================== 2275 public: 2276 // ========================================================================== 2277 /** access the EXISTING 1D histogram by title 2278 * return the pointer to existing 1D histogram or NULL 2279 */ 2280 inline AIDA::IHistogram1D* histo1D( const std::string& title ) const { 2281 auto found = histo1DMapTitle().find( title ); 2282 return found != histo1DMapTitle().end() ? found->second : nullptr; 2283 } 2284 // ========================================================================== 2285 /** access the EXISTING 1D histogram by title 2286 * 2287 * Wrapper method for the equivalent histo1D method. 2288 * Retained for backwards compatibility, please use histo1D instead. 2289 * 2290 * return the pointer to existing 1D histogram or NULL 2291 */ 2292 inline AIDA::IHistogram1D* histo( const std::string& title ) const { return histo1D( title ); } 2293 // ========================================================================== 2294 /** access the EXISTING 2D histogram by title 2295 * return the pointer to existing 2D histogram or NULL 2296 */ 2297 inline AIDA::IHistogram2D* histo2D( const std::string& title ) const { 2298 auto found = histo2DMapTitle().find( title ); 2299 return histo2DMapTitle().end() != found ? found->second : nullptr; 2300 } 2301 // ========================================================================== 2302 /** access the EXISTING 3D histogram by title 2303 * return the pointer to existing 3D histogram or NULL 2304 */ 2305 inline AIDA::IHistogram3D* histo3D( const std::string& title ) const { 2306 auto found = histo3DMapTitle().find( title ); 2307 return histo3DMapTitle().end() != found ? found->second : nullptr; 2308 } 2309 // ========================================================================== 2310 /** access the EXISTING 1D profile histogram by title 2311 * return the pointer to existing 1D profile histogram or NULL 2312 */ 2313 inline AIDA::IProfile1D* profile1D( const std::string& title ) const { 2314 auto found = profile1DMapTitle().find( title ); 2315 return profile1DMapTitle().end() != found ? found->second : nullptr; 2316 } 2317 // ========================================================================== 2318 /** access the EXISTING 2D profile histogram by title 2319 * return the pointer to existing 2D profile histogram or NULL 2320 */ 2321 inline AIDA::IProfile2D* profile2D( const std::string& title ) const { 2322 auto found = profile2DMapTitle().find( title ); 2323 return profile2DMapTitle().end() != found ? found->second : nullptr; 2324 } 2325 // ========================================================================== 2326 public: 2327 // ========================================================================== 2328 /** access the EXISTING 1D histogram by ID 2329 * return the pointer to existing 1D histogram or NULL 2330 */ 2331 AIDA::IHistogram1D* histo1D( const HistoID& ID ) const; 2332 // ========================================================================== 2333 /** access the EXISTING 1D histogram by ID 2334 * 2335 * Wrapper method for the equivalent histo1D method. 2336 * Retained for backwards compatibility, please use histo1D instead. 2337 * 2338 * return the pointer to existing 1D histogram or NULL 2339 */ 2340 inline AIDA::IHistogram1D* histo( const HistoID& ID ) const { return histo1D( ID ); } 2341 // ========================================================================== 2342 /** access the EXISTING 2D histogram by ID 2343 * return the pointer to existing 2D histogram or NULL 2344 */ 2345 AIDA::IHistogram2D* histo2D( const HistoID& ID ) const; 2346 // ========================================================================== 2347 /** access the EXISTING 3D histogram by ID 2348 * return the pointer to existing 3D histogram or NULL 2349 */ 2350 AIDA::IHistogram3D* histo3D( const HistoID& ID ) const; 2351 // ========================================================================== 2352 /** access the EXISTING 1D profile histogram by ID 2353 * return the pointer to existing 1D profile histogram or NULL 2354 */ 2355 AIDA::IProfile1D* profile1D( const HistoID& ID ) const; 2356 // ========================================================================== 2357 /** access the EXISTING 2D profile histogram by ID 2358 * return the pointer to existing 2D profile histogram or NULL 2359 */ 2360 AIDA::IProfile2D* profile2D( const HistoID& ID ) const; 2361 // ========================================================================== 2362 public: 2363 // ========================================================================== 2364 /// check the existence AND validity of the histogram with given title 2365 inline bool histoExists( const std::string& title ) const { 2366 return ( 0 != histo( title ) || 0 != histo2D( title ) || 0 != histo3D( title ) || 0 != profile1D( title ) || 2367 0 != profile2D( title ) ); 2368 } 2369 // ========================================================================== 2370 /// check the existence AND validity of the histogram with given title 2371 inline bool histoExists( const HistoID& ID ) const { 2372 return ( 0 != histo( ID ) || 0 != histo2D( ID ) || 0 != histo3D( ID ) || 0 != profile1D( ID ) || 2373 0 != profile2D( ID ) ); 2374 } 2375 /// Returns the total number of histograms (of all types) currently booked 2376 unsigned int totalNumberOfHistos() const; 2377 // ========================================================================== 2378 public: // trivial & non-trivial accessors 2379 // ========================================================================== 2380 /// get the flag for histogram production (property "HistoProduce") 2381 inline bool produceHistos() const { return m_produceHistos; } 2382 /// get flag to control output level of histograms 2383 inline bool fullDetail() const { return m_fullDetail; } 2384 /// get the flag for NaN checks (property "HistoCheckForNan") 2385 inline bool checkForNaN() const { return m_checkForNaN; } 2386 /// get the flag for histogram path split (property "HistoSplitDir") 2387 inline bool splitHistoDir() const { return m_splitHistoDir; } 2388 /// get the value for histogram offset (property "HistoOffSet") 2389 inline HistoID::NumericID histoOffSet() const { return m_histoOffSet; } 2390 /// get top-level histogram directory (property "HistoTopDir") 2391 inline const std::string& histoTopDir() const { return m_histoTopDir; } 2392 /// get histogram directory (property "HistoDir") 2393 inline const std::string& histoDir() const { return m_histoDir; } 2394 /// get the constructed histogram path 2395 std::string histoPath() const; 2396 /// print histograms at finalization ? 2397 inline bool histosPrint() const { return m_histosPrint; } 2398 /// print histogram counters at finalization ? 2399 inline bool histoCountersPrint() const { return m_histoCountersPrint; } 2400 /// Use old style sequencial numerical automatically assigned IDs ? 2401 inline bool useNumericAutoIDs() const { return m_useNumericAutoIDs; } 2402 // ========================================================================== 2403 /** perform the actual printout of histograms 2404 * @param level The message level to print at 2405 * @return number of active histograms 2406 */ 2407 int printHistos( const MSG::Level level = MSG::ALWAYS ) const; 2408 // ========================================================================== 2409 /** get access to the map of all 1D histograms indexed via their title 2410 * 2411 * Using this method one can inspect e.g. a list of active histograms 2412 * 2413 * @code 2414 * 2415 * // iterate over the map! 2416 * for ( const auto& entry :histo1DMapTitle() ) 2417 * { 2418 * // histogram title 2419 * const std::string& title = entry.first ; 2420 * // histogram itself 2421 * AIDA::IHistogram1D* hist = entry.second ; 2422 * if( !hist ) { continue ; } // ATTENTION! 2423 * 2424 * std::cout << " Histogram title " << title << std::endl ; 2425 * 2426 * } 2427 * 2428 * @endcode 2429 * 2430 * @attention The map *COULD* contains NULL pointers, 2431 * the check before use is mandatory! 2432 * 2433 */ 2434 const Histo1DMapTitle& histo1DMapTitle() const { return m_histo1DMapTitle; } 2435 // ========================================================================== 2436 /** get access to the map of all 1D histograms index via ID 2437 * 2438 * @code 2439 * 2440 * // iterate over the map! 2441 * for ( const auto& entry : histo1DMapID() ) 2442 * { 2443 * // histogram ID 2444 * const HistoID ID = entry.first ; 2445 * // histogram itself 2446 * AIDA::IHistogram1D* h = entry.second ; 2447 * if ( 0 == h ) { continue ;} 2448 * 2449 * std::cout << " Histogram ID " << ID 2450 * << " Histogram title " << h->title() << std::endl ; 2451 * 2452 * } 2453 * 2454 * @endcode 2455 * 2456 * 2457 */ 2458 const Histo1DMapID& histo1DMapID() const { return m_histo1DMapID; } 2459 // ========================================================================== 2460 /** get access to the map of all 2D histograms indexed via their title 2461 * 2462 * Using this method one can inspect e.g. a list of active histograms 2463 * 2464 * @code 2465 * 2466 * // iterate over the map! 2467 * for ( const auto& entry : histo2DMapTitle() ) 2468 * { 2469 * // histogram title 2470 * const std::string& title = entry.first ; 2471 * // histogram itself 2472 * AIDA::IHistogram2D* hist = entry.second ; 2473 * if( 0 == hist ) { continue ; } // ATTENTION! 2474 * 2475 * std::cout << " Histogram title " << title << std::endl ; 2476 * 2477 * } 2478 * 2479 * @endcode 2480 * 2481 * @attention The map *COULD* contains NULL pointers, 2482 * the check before use is mandatory! 2483 * 2484 */ 2485 const Histo2DMapTitle& histo2DMapTitle() const { return m_histo2DMapTitle; } 2486 // ========================================================================== 2487 /** get access to the map of 2D histograms index via ID 2488 * 2489 * @code 2490 * 2491 * // iterate over the map! 2492 * for ( const auto& entry : histo2DMapID() ) 2493 * { 2494 * // histogram ID 2495 * const HistoID ID = entry.first ; 2496 * // histogram itself 2497 * AIDA::IHistogram2D* h = entry.second ; 2498 * if ( 0 == h ) { continue ;} 2499 * 2500 * std::cout << " Histogram ID " << ID 2501 * << " Histogram title " << h->title() << std::endl ; 2502 * 2503 * } 2504 * 2505 * @endcode 2506 * 2507 */ 2508 const Histo2DMapID& histo2DMapID() const { return m_histo2DMapID; } 2509 // ========================================================================== 2510 /** get access to the map of all 3D histograms indexed via their title 2511 * 2512 * Using this method one can inspect e.g. a list of active histograms 2513 * 2514 * @code 2515 * 2516 * // iterate over the map! 2517 * for ( const auto& entry : histo3DMapTitle() ) 2518 * { 2519 * // histogram title 2520 * const std::string& title = entry.first ; 2521 * // histogram itself 2522 * AIDA::IHistogram3D* hist = entry.second ; 2523 * if( 0 == hist ) { continue ; } // ATTENTION! 2524 * 2525 * std::cout << " Histogram title " << title << std::endl ; 2526 * 2527 * } 2528 * 2529 * @endcode 2530 * 2531 * @attention The map *COULD* contains NULL pointers, 2532 * the check before use is mandatory! 2533 * 2534 */ 2535 const Histo3DMapTitle& histo3DMapTitle() const { return m_histo3DMapTitle; } 2536 // ========================================================================== 2537 /** get access to the map of all 3D histograms index via a ID 2538 * 2539 * @code 2540 * 2541 * // iterate over the map! 2542 * for ( const auto& entry : histo3DMapID() ) 2543 * { 2544 * // histogram ID 2545 * const HistoID ID = entry.first ; 2546 * // histogram itself 2547 * AIDA::IHistogram3D* h = entry.second ; 2548 * if ( 0 == h ) { continue ;} 2549 * 2550 * std::cout << " Histogram ID " << ID 2551 * << " Histogram title " << h->title() << std::endl ; 2552 * 2553 * } 2554 * 2555 * @endcode 2556 * 2557 */ 2558 const Histo3DMapID& histo3DMapID() const { return m_histo3DMapID; } 2559 // ========================================================================== 2560 /** get access to the map of all 1D profile histograms indexed via their title 2561 * 2562 * Using this method one can inspect e.g. a list of active histograms 2563 * 2564 * @code 2565 * 2566 * const Profile1DMapTitle& histos = profile1DMapTitle() ; 2567 * // iterate over the map! 2568 * for ( Profile1DMapTitle::const_iterator entry = histos.begin() ; 2569 * histos.end() != entry ; ++entry ) 2570 * { 2571 * // histogram title 2572 * const std::string& title = entry->first ; 2573 * // histogram itself 2574 * AIDA::IProfile1D* hist = entry->second ; 2575 * if( 0 == hist ) { continue ; } // ATTENTION! 2576 * 2577 * std::cout << " Histogram title " << title << std::endl ; 2578 * 2579 * } 2580 * 2581 * @endcode 2582 * 2583 * @attention The map *COULD* contains NULL pointers, 2584 * the check before use is mandatory! 2585 * 2586 */ 2587 const Profile1DMapTitle& profile1DMapTitle() const { return m_profile1DMapTitle; } 2588 // ========================================================================== 2589 /** get access to the map of 1D profile histograms index via a ID 2590 * 2591 * @code 2592 * 2593 * // iterate over the map! 2594 * for ( const auto& entry : profile1DMapID() ) 2595 * { 2596 * // histogram ID 2597 * const HistoID ID = entry.first ; 2598 * // histogram itself 2599 * AIDA::IProfile1D* h = entry.second ; 2600 * if ( 0 == h ) { continue ;} 2601 * 2602 * std::cout << " Histogram ID " << ID 2603 * << " Histogram title " << h->title() << std::endl ; 2604 * 2605 * } 2606 * 2607 * @endcode 2608 * 2609 */ 2610 const Profile1DMapID& profile1DMapID() const { return m_profile1DMapID; } 2611 // ========================================================================== 2612 /** get access to the map of all 2D profile histograms indexed via their title 2613 * 2614 * Using this method one can inspect e.g. a list of active histograms 2615 * 2616 * @code 2617 * 2618 * // iterate over the map! 2619 * for ( const auto& entry : profile2DMapTitle() ) 2620 * { 2621 * // histogram title 2622 * const std::string& title = entry.first ; 2623 * // histogram itself 2624 * AIDA::IProfile2D* hist = entry.second ; 2625 * if( 0 == hist ) { continue ; } // ATTENTION! 2626 * 2627 * std::cout << " Histogram title " << title << std::endl ; 2628 * 2629 * } 2630 * 2631 * @endcode 2632 * 2633 * @attention The map *COULD* contains NULL pointers, 2634 * the check before use is mandatory! 2635 * 2636 */ 2637 const Profile2DMapTitle& profile2DMapTitle() const { return m_profile2DMapTitle; } 2638 // ========================================================================== 2639 /** get access to the map of 2D profile histograms index via a ID 2640 * 2641 * @code 2642 * 2643 * // iterate over the map! 2644 * for ( const auto& entry : profile2DMapID() ) 2645 * { 2646 * // histogram ID 2647 * const HistoID ID = entry.first ; 2648 * // histogram itself 2649 * AIDA::IProfile2D* h = entry.second ; 2650 * if ( 0 == h ) { continue ;} 2651 * 2652 * std::cout << " Histogram ID " << ID 2653 * << " Histogram title " << h->title() << std::endl ; 2654 * 2655 * } 2656 * 2657 * @endcode 2658 * 2659 */ 2660 const Profile2DMapID& profile2DMapID() const { return m_profile2DMapID; } 2661 // ========================================================================== 2662 public: // trivial setters 2663 // ========================================================================== 2664 /// set the flag for histogram production (property "HistoProduce") 2665 inline void setProduceHistos( const bool val ) { m_produceHistos = val; } 2666 /// set flag to control output level of histograms 2667 inline void setFullDetail( const bool val ) { m_fullDetail = val; } 2668 /// set the flag for NaN checks (property "HistoCheckForNan") 2669 inline void setCheckForNaN( const bool val ) { m_checkForNaN = val; } 2670 /// set the flag for histogram path split (property "HistoSplitDir") 2671 inline void setSplitHistoDir( const bool val ) { m_splitHistoDir = val; } 2672 /// set a value for histogram offset (property "HistoOffSet" 2673 inline void setHistoOffSet( const HistoID::NumericID val ) { m_histoOffSet = val; } 2674 // ========================================================================== 2675 /// set top-level histogram directory (property "HistoTopDir") 2676 inline void setHistoTopDir( const std::string& val ) { m_histoTopDir = val; } 2677 // ========================================================================== 2678 /// set histogram directory (property "HistoDir") 2679 inline void setHistoDir( const std::string& val ) { m_histoDir = val; } 2680 // ========================================================================== 2681 public: 2682 // FIXME: due to a bug in gcc7, the following two cannot be replaced with 2683 // using PBASE::PBASE... 2684 // ========================================================================== 2685 /// Algorithm constructor - the SFINAE constraint below ensures that this is 2686 /// constructor is only defined if PBASE derives from GaudiAlgorithm 2687 template <typename U = PBASE, typename = std::enable_if_t<std::is_base_of_v<Gaudi::Algorithm, PBASE>, U>> 2688 GaudiHistos( const std::string& name, ISvcLocator* pSvcLocator ) : PBASE( name, pSvcLocator ) {} 2689 // ========================================================================== 2690 /// Tool constructor - SFINAE-ed to insure this constructor is only defined 2691 /// if PBASE derives from GaudiTool. 2692 template <typename U = PBASE, typename = std::enable_if_t<std::is_base_of_v<GaudiTool, PBASE>, U>> 2693 GaudiHistos( const std::string& type, const std::string& name, const IInterface* parent ) 2694 : PBASE( type, name, parent ) {} 2695 // ========================================================================== 2696 protected: 2697 // ========================================================================== 2698 /** standard initialization method 2699 * @return status code 2700 */ 2701 StatusCode initialize() override 2702 #ifdef __ICC 2703 { 2704 return i_ghInitialize(); 2705 } 2706 StatusCode i_ghInitialize() 2707 #endif 2708 ; 2709 // ========================================================================== 2710 /** standard finalization method 2711 * @return status code 2712 */ 2713 StatusCode finalize() override 2714 #ifdef __ICC 2715 { 2716 return i_ghFinalize(); 2717 } 2718 StatusCode i_ghFinalize() 2719 #endif 2720 ; 2721 // ========================================================================== 2722 private: 2723 // ========================================================================== 2724 /// Check if all histogram maps are empty 2725 bool noHistos() const; 2726 // ===========================================unsigned=============================== 2727 /** @brief Declare a histogram to the monitor service 2728 * 2729 * Uses the histogram ID as the 'name' sent to the monitor service and 2730 * the histogram title as the long description 2731 */ 2732 void monitorHisto( const AIDA::IBaseHistogram* hist, const HistoID& ID ) const; 2733 // ========================================================================== 2734 /** Create a new histogram ID using the given title 2735 * @param[in] title Histogram title 2736 * @param[out] ID The ID to use for the new histogram 2737 */ 2738 void newHistoID( const std::string& title, HistoID& ID ) const; 2739 // ========================================================================== 2740 protected: 2741 // ========================================================================== 2742 /// Create an ID string from a title string 2743 std::string convertTitleToID( std::string title ) const; 2744 // ========================================================================== 2745 private: 2746 Gaudi::Property<bool> m_produceHistos{ this, "HistoProduce", true, "Switch on/off the production of histograms" }; 2747 Gaudi::Property<bool> m_histosPrint{ this, "HistoPrint", false, 2748 [this]( const auto& ) { 2749 // no action if not yet initialized 2750 if ( this->FSMState() >= Gaudi::StateMachine::INITIALIZED && 2751 this->histosPrint() ) 2752 this->printHistos( MSG::ALWAYS ); 2753 }, 2754 "Switch on/off the printout of histograms at finalization" }; 2755 Gaudi::Property<bool> m_histoCountersPrint{ this, "HistoCountersPrint", true, 2756 "Switch on/off the printout of histogram counters at finalization" }; 2757 Gaudi::Property<bool> m_checkForNaN{ this, "HistoCheckForNaN", true, 2758 "Switch on/off the checks for NaN and Infinity for histogram fill" }; 2759 Gaudi::Property<bool> m_splitHistoDir{ this, "HistoSplitDir", false, 2760 "Split long directory names into short pieces (suitable for HBOOK)" }; 2761 Gaudi::Property<HistoID::NumericID> m_histoOffSet{ 2762 this, "HistoOffSet", 0, "OffSet for automatically assigned histogram numerical identifiers " }; 2763 Gaudi::Property<std::string> m_histoTopDir{ this, "HistoTopDir", "", 2764 "Top level histogram directory (take care that it ends with '/')" }; 2765 Gaudi::Property<std::string> m_histoDir{ 2766 this, "HistoDir", boost::algorithm::replace_all_copy( this->name(), ":", "_" ), "Histogram Directory" }; 2767 Gaudi::Property<bool> m_fullDetail{ this, "FullDetail", false }; 2768 Gaudi::Property<bool> m_declareMoniHists{ this, "MonitorHistograms", true }; 2769 Gaudi::Property<std::string> m_histo1DTableFormat{ this, "FormatFor1DHistoTable", 2770 Gaudi::Utils::Histos::Formats::format(), 2771 "Format string for printout of 1D histograms" }; 2772 Gaudi::Property<std::string> m_histo1DTableFormatShort{ this, "ShortFormatFor1DHistoTable", " | %1$-25.25s %2%", 2773 "Format string for printout of 1D histograms" }; 2774 Gaudi::Property<std::string> m_histo1DTableHeader{ this, "HeaderFor1DHistoTable", 2775 Gaudi::Utils::Histos::Formats::header(), 2776 "The table header for printout of 1D histograms " }; 2777 Gaudi::Property<bool> m_useNumericAutoIDs{ 2778 this, "UseSequencialNumericAutoIDs", false, 2779 "Flag to allow users to switch back to the old style of creating numerical automatic IDs" }; 2780 Gaudi::Property<std::map<std::string, std::string>> m_idReplaceInfo{ 2781 this, 2782 "AutoStringIDPurgeMap", 2783 { { "/", "=SLASH=" } }, 2784 "Map of strings to search and replace when using the title " 2785 "as the basis of automatically generated literal IDs" }; 2786 // ========================================================================== 2787 /// the actual storage/access of 1D histograms by unique title 2788 mutable Histo1DMapTitle m_histo1DMapTitle; 2789 /// the actual storage/access of 1D histograms by unique ID 2790 mutable Histo1DMapID m_histo1DMapID; 2791 // ========================================================================== 2792 /// the actual storage/access of 2D histograms by unique title 2793 mutable Histo2DMapTitle m_histo2DMapTitle; 2794 /// the actual storage/access of 2D histograms by unique ID 2795 mutable Histo2DMapID m_histo2DMapID; 2796 // ========================================================================== 2797 /// the actual storage/access of 3D histograms by unique title 2798 mutable Histo3DMapTitle m_histo3DMapTitle; 2799 /// the actual storage/access of 3D histograms by unique ID 2800 mutable Histo3DMapID m_histo3DMapID; 2801 // ========================================================================== 2802 /// the actual storage/access of 1D profile histograms by unique title 2803 mutable Profile1DMapTitle m_profile1DMapTitle; 2804 /// the actual storage/access of 1D profile histograms by unique ID 2805 mutable Profile1DMapID m_profile1DMapID; 2806 // ========================================================================== 2807 /// the actual storage/access of 2D profile histograms by unique title 2808 mutable Profile2DMapTitle m_profile2DMapTitle; 2809 /// the actual storage/access of 2D profile histograms by unique ID 2810 mutable Profile2DMapID m_profile2DMapID; 2811 // ========================================================================== 2812 }; 2813 // ============================================================================ 2814 // The END 2815 // ============================================================================ 2816 #endif // GAUDIALG_GAUDIHISTOS_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |