|
||||
File indexing completed on 2025-01-18 09:57:34
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_IHISTOTOOL_H 0012 #define GAUDIALG_IHISTOTOOL_H 1 0013 // ============================================================================ 0014 // Include files 0015 // ============================================================================ 0016 // from STL 0017 // ============================================================================ 0018 #include <string> 0019 // ============================================================================ 0020 // from Gaudi 0021 // ============================================================================ 0022 #include "GaudiAlg/HistoID.h" 0023 #include "GaudiKernel/IAlgTool.h" 0024 // ============================================================================ 0025 0026 namespace AIDA { 0027 class IHistogram1D; 0028 class IHistogram2D; 0029 class IHistogram3D; 0030 } // namespace AIDA 0031 0032 /** @class IHistoTool IHistoTool.h GaudiTools/IHistoTool.h 0033 * 0034 * An abstract interface for "histogramming tool" 0035 * 0036 * @author Vanya BELYAEV Ivan.Belyaev@itep.ru 0037 * @date 2004-06-28 0038 */ 0039 0040 class GAUDI_API IHistoTool : virtual public IAlgTool { 0041 public: 0042 /// InterfaceID 0043 DeclareInterfaceID( IHistoTool, 2, 0 ); 0044 0045 /// the actual type for histogram identifier (HBOOK style) 0046 typedef Histos::HistoID HistoID; 0047 0048 public: 0049 // ================================= 1D Histograms ======================================== 0050 0051 /** fill the 1D histogram (book on demand) 0052 * 0053 * @code 0054 * 0055 * const double mass = ... ; 0056 * plot1D( mass , "Invariant Mass" , 2.5 , 3.5 , 100 ) 0057 * 0058 * @endcode 0059 * 0060 * - This example illustrates the filling of the histogram 0061 * titled <tt>"InvariantMass"</tt> with value @c mass . 0062 * - If the histogram with given title does not exist yet 0063 * it will be automatically booked with parameters 0064 * @c low equal to 2.5, parameters @c high equal to 3.5 0065 * and @c bins equal to 100. 0066 * 0067 * The histogram will get a unique integer identifier automatically assigned. 0068 * 0069 * @see AIDA::IHistogram1D 0070 * 0071 * @param value value to be filled 0072 * @param title histogram title (must be unique within the algorithm) 0073 * @param low low limit for histogram 0074 * @param high high limit for histogram 0075 * @param bins number of bins 0076 * @param weight weight 0077 * @return pointer to AIDA 1D histogram 0078 */ 0079 virtual AIDA::IHistogram1D* plot1D( const double value, const std::string& title, const double low, const double high, 0080 const unsigned long bins = 100, const double weight = 1.0 ) const = 0; 0081 0082 /** fill the 1D histogram (book on demand) 0083 * 0084 * Wrapper method for the equivalent plot1D method. 0085 * Retained for backwards compatibility, please use plot1D instead. 0086 * 0087 * @param value value to be filled 0088 * @param title histogram title (must be unique within the algorithm) 0089 * @param low low limit for histogram 0090 * @param high high limit for histogram 0091 * @param bins number of bins 0092 * @param weight weight 0093 * @return pointer to AIDA 1D histogram 0094 */ 0095 AIDA::IHistogram1D* plot( const double value, const std::string& title, const double low, const double high, 0096 const unsigned long bins = 100, const double weight = 1.0 ) const { 0097 return plot1D( value, title, low, high, bins, weight ); 0098 } 0099 0100 /** fill the 1D histogram with forced ID assignement (book on demand) 0101 * 0102 * @code 0103 * 0104 * const double mass = ... ; 0105 * plot1D( mass , 15 , "Invariant Mass" , 2.5 , 3.5 , 100 ) 0106 * 0107 * @endcode 0108 * 0109 * - This example illustrates the filling of the 1D histogram ID=15 0110 * titled <tt>"Invariant Mass"</tt> with value @c mass . 0111 * - If the histogram with given ID does not exist yet 0112 * it will be automatically booked with parameters 0113 * @c low equal to 2.5, parameters @c high equal to 3.5 0114 * and @c bins equal to 100. 0115 * 0116 * @attention 0117 * If the histogram with given ID is already booked 0118 * through automatic assignement of histogram ID, 0119 * the error will not be detected. 0120 * Therefore it is recommended 0121 * to use non-trivial histogram ID offset (property "HistoOffSet") 0122 * if one need to combine these techniques together 0123 * It is still desirable to use the unique histogram title 0124 * to avoid a bad interference. 0125 * 0126 * Note : This method is more efficient that the similar method without 0127 * forced ID, since the histogram lookup is faster using a numerical ID. 0128 * 0129 * @see AIDA::IHistogram1D 0130 * 0131 * @param value value to be filled 0132 * @param ID histogram identifier 0133 * @param title histogram title (must be unique within the algorithm) 0134 * @param low low limit for histogram 0135 * @param high high limit for histogram 0136 * @param bins number of bins 0137 * @param weight weight 0138 * @return pointer to AIDA histogram 0139 */ 0140 virtual AIDA::IHistogram1D* plot1D( const double value, const HistoID& ID, const std::string& title, const double low, 0141 const double high, const unsigned long bins = 100, 0142 const double weight = 1.0 ) const = 0; 0143 0144 /** fill the 1D histogram with forced ID assignment (book on demand) 0145 * 0146 * Wrapper method for the equivalent plot1D method. 0147 * Retained for backwards compatibility, please use plot1D instead. 0148 * 0149 * @param value value to be filled 0150 * @param ID histogram identifier 0151 * @param title histogram title (must be unique within the algorithm) 0152 * @param low low limit for histogram 0153 * @param high high limit for histogram 0154 * @param bins number of bins 0155 * @param weight weight 0156 * @return pointer to AIDA histogram 0157 */ 0158 AIDA::IHistogram1D* plot( const double value, const HistoID& ID, const std::string& title, const double low, 0159 const double high, const unsigned long bins = 100, const double weight = 1.0 ) const { 0160 return plot1D( value, ID, title, low, high, bins, weight ); 0161 }; 0162 0163 // ================================= 2D Histograms ======================================== 0164 0165 /** fill the 2D histogram (book on demand) 0166 * 0167 * @code 0168 * 0169 * const double mass1 = ... ; 0170 * const double mass2 = ... ; 0171 * plot2D( mass1, mass2, "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 4.5, 5.5, 100, 200 ); 0172 * 0173 * @endcode 0174 * 0175 * - This example illustrates the filling of the 2D histogram 0176 * titled <tt>"Invariant Mass2 versus Mass1"</tt> with values @c mass1 and @c mass2 . 0177 * - If the histogram with given title does not exist yet 0178 * it will be automatically booked with parameters 0179 * @c lowX equal to 2.5, @c highX equal to 3.5, 0180 * @c lowY equal to 4.5, @c highY equal to 5.5, 0181 * @c binsX equal to 100 and @c binsY equal to 200. 0182 * 0183 * The histogram will get a unique integer identifier automatically assigned 0184 * 0185 * @see AIDA::IHistogram2D 0186 * 0187 * @param valueX x value to be filled 0188 * @param valueY y value to be filled 0189 * @param title histogram title (must be unique within the algorithm) 0190 * @param lowX low x limit for histogram 0191 * @param highX high x limit for histogram 0192 * @param lowY low y limit for histogram 0193 * @param highY high y limit for histogram 0194 * @param binsX number of bins in x 0195 * @param binsY number of bins in y 0196 * @param weight weight 0197 * @return pointer to AIDA 2D histogram 0198 */ 0199 virtual AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const std::string& title, 0200 const double lowX, const double highX, const double lowY, const double highY, 0201 const unsigned long binsX = 50, const unsigned long binsY = 50, 0202 const double weight = 1.0 ) const = 0; 0203 0204 /** fill the 2D histogram with forced ID assignment (book on demand) 0205 * 0206 * @code 0207 * 0208 * const double mass1 = ... ; 0209 * const double mass2 = ... ; 0210 * plot2D( mass1, mass2, 15, "Invariant Mass2 versus Mass1" ,2.5 ,3.5, 4.5, 5.5, 100, 200 ); 0211 * 0212 * @endcode 0213 * 0214 * - This example illustrates the filling of the 2D histogram ID=15 0215 * titled <tt>"Invariant Mass2 versus Mass1"</tt> with values @c mass1 and @c mass2 . 0216 * - If the histogram with given title does not exist yet 0217 * it will be automatically booked with parameters 0218 * @c lowX equal to 2.5, @c highX equal to 3.5, 0219 * @c lowY equal to 4.5, @c highY equal to 5.5, 0220 * @c binsX equal to 100 and @c binsY equal to 200. 0221 * 0222 * @attention 0223 * If the histogram with given ID is already booked 0224 * through automatic assignment of histogram ID, 0225 * the error will not be detected. 0226 * Therefore it is recommended 0227 * to use non-trivial histogram ID offset (property "HistoOffSet") 0228 * if one need to combine these techniques together 0229 * It is still desirable to use the unique histogram title 0230 * to avoid a bad interference 0231 * 0232 * Note : This method is more efficient that the similar method without 0233 * forced ID, since the histogram lookup is faster using a numerical ID. 0234 * 0235 * @see AIDA::IHistogram2D 0236 * 0237 * @param valueX x value to be filled 0238 * @param valueY y value to be filled 0239 * @param ID Histogram ID to use 0240 * @param title histogram title (must be unique within the algorithm) 0241 * @param lowX low x limit for histogram 0242 * @param highX high x limit for histogram 0243 * @param lowY low y limit for histogram 0244 * @param highY high y limit for histogram 0245 * @param binsX number of bins in x 0246 * @param binsY number of bins in y 0247 * @param weight weight 0248 * @return pointer to AIDA 2D histogram 0249 */ 0250 virtual AIDA::IHistogram2D* plot2D( const double valueX, const double valueY, const HistoID& ID, 0251 const std::string& title, const double lowX, const double highX, 0252 const double lowY, const double highY, const unsigned long binsX = 50, 0253 const unsigned long binsY = 50, const double weight = 1.0 ) const = 0; 0254 0255 // ================================= 3D Histograms ======================================== 0256 0257 /** fill the 3D histogram (book on demand) 0258 * 0259 * @code 0260 * 0261 * const double mass1 = ... ; 0262 * const double mass2 = ... ; 0263 * const double mass3 = ... ; 0264 * plot3D( X, Y, Z, "Space Points" ,2.5 ,3.5, 4.5, 5.5, 6.5, 7.5, 10, 20, 30 ); 0265 * 0266 * @endcode 0267 * 0268 * - This example illustrates the filling of the 3D histogram 0269 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 0270 * - If the histogram with given title does not exist yet 0271 * it will be automatically booked with parameters 0272 * @c lowX equal to 2.5, @c highX equal to 3.5, 0273 * @c lowY equal to 4.5, @c highY equal to 5.5, 0274 * @c lowZ equal to 6.5, @c highZ equal to 7.5, 0275 * @c binsX equal to 10, @c binsY equal to 20 and @c binsZ equal to 30. 0276 * 0277 * The histogram will get a unique integer identifier automatically assigned 0278 * 0279 * @see AIDA::IHistogram3D 0280 * 0281 * @param valueX x value to be filled 0282 * @param valueY y value to be filled 0283 * @param valueZ z value to be filled 0284 * @param title histogram title (must be unique within the algorithm) 0285 * @param lowX low x limit for histogram 0286 * @param highX high x limit for histogram 0287 * @param lowY low y limit for histogram 0288 * @param highY high y limit for histogram 0289 * @param lowZ low z limit for histogram 0290 * @param highZ high z limit for histogram 0291 * @param binsX number of bins in x 0292 * @param binsY number of bins in y 0293 * @param binsZ number of bins in z 0294 * @param weight weight 0295 * @return pointer to AIDA 3D histogram 0296 */ 0297 virtual AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, 0298 const std::string& title, const double lowX, const double highX, 0299 const double lowY, const double highY, const double lowZ, const double highZ, 0300 const unsigned long binsX = 10, const unsigned long binsY = 10, 0301 const unsigned long binsZ = 10, const double weight = 1.0 ) const = 0; 0302 0303 /** fill the 3D histogram with forced ID assignment (book on demand) 0304 * 0305 * @code 0306 * 0307 * const double mass1 = ... ; 0308 * const double mass2 = ... ; 0309 * const double mass3 = ... ; 0310 * plot3D( X, Y, Z, "Space Points" ,2.5 ,3.5, 4.5, 5.5, 6.5, 7.5, 10, 20, 30 ); 0311 * 0312 * @endcode 0313 * 0314 * - This example illustrates the filling of the 3D histogram 0315 * titled <tt>"Space Points"</tt> with values @c X, @c Y and @c Z. 0316 * - If the histogram with given title does not exist yet 0317 * it will be automatically booked with parameters 0318 * @c lowX equal to 2.5, @c highX equal to 3.5, 0319 * @c lowY equal to 4.5, @c highY equal to 5.5, 0320 * @c lowZ equal to 6.5, @c highZ equal to 7.5, 0321 * @c binsX equal to 10, @c binsY equal to 20 and @c binsZ equal to 30. 0322 * 0323 * @attention 0324 * If the histogram with given ID is already booked 0325 * through automatic assignment of histogram ID, 0326 * the error will not be detected. 0327 * Therefore it is recommended 0328 * to use non-trivial histogram ID offset (property "HistoOffSet") 0329 * if one need to combine these techniques together 0330 * It is still desirable to use the unique histogram title 0331 * to avoid a bad interference 0332 * 0333 * Note : This method is more efficient that the similar method without 0334 * forced ID, since the histogram lookup is faster using a numerical ID. 0335 * 0336 * @see AIDA::IHistogram3D 0337 * 0338 * @param valueX x value to be filled 0339 * @param valueY y value to be filled 0340 * @param valueZ z value to be filled 0341 * @param ID Histogram ID to use 0342 * @param title histogram title (must be unique within the algorithm) 0343 * @param lowX low x limit for histogram 0344 * @param highX high x limit for histogram 0345 * @param lowY low y limit for histogram 0346 * @param highY high y limit for histogram 0347 * @param lowZ low z limit for histogram 0348 * @param highZ high z limit for histogram 0349 * @param binsX number of bins in x 0350 * @param binsY number of bins in y 0351 * @param binsZ number of bins in z 0352 * @param weight weight 0353 * @return pointer to AIDA 3D histogram 0354 */ 0355 virtual AIDA::IHistogram3D* plot3D( const double valueX, const double valueY, const double valueZ, const HistoID& ID, 0356 const std::string& title, const double lowX, const double highX, 0357 const double lowY, const double highY, const double lowZ, const double highZ, 0358 const unsigned long binsX = 10, const unsigned long binsY = 10, 0359 const unsigned long binsZ = 10, const double weight = 1.0 ) const = 0; 0360 0361 public: 0362 /** book the 1D histogram 0363 * 0364 * The histogram will be assigned a unique identifier 0365 * 0366 * @see IHistogram1D 0367 * @param title histogram title (must be unique within the algorithm) 0368 * @param low low limit for histogram 0369 * @param high high limit for histogram 0370 * @param bins number of bins 0371 * @return pointer to AIDA 1D histogram 0372 */ 0373 virtual AIDA::IHistogram1D* book1D( const std::string& title, const double low = 0, const double high = 100, 0374 const unsigned long bins = 100 ) const = 0; 0375 0376 /** book the 1D histogram 0377 * 0378 * Wrapper method for the equivalent book1D method. 0379 * Retained for backwards compatibility, please use book1D instead. 0380 * 0381 * @see IHistogram1D 0382 * @param title histogram title (must be unique within the algorithm) 0383 * @param low low limit for histogram 0384 * @param high high limit for histogram 0385 * @param bins number of bins 0386 * @return pointer to AIDA 1D histogram 0387 */ 0388 AIDA::IHistogram1D* book( const std::string& title, const double low = 0, const double high = 100, 0389 const unsigned long bins = 100 ) const { 0390 return book1D( title, low, high, bins ); 0391 } 0392 0393 /** book the 2D histogram 0394 * 0395 * The histogram will be assigned a unique identifier 0396 * 0397 * @see IHistogram2D 0398 * @param title histogram title (must be unique within the algorithm) 0399 * @param lowX low x limit for histogram 0400 * @param highX high x limit for histogram 0401 * @param binsX number of bins in x 0402 * @param lowY low y limit for histogram 0403 * @param highY high y limit for histogram 0404 * @param binsY number of bins in y 0405 * @return pointer to AIDA 2D histogram 0406 */ 0407 virtual AIDA::IHistogram2D* book2D( const std::string& title, const double lowX = 0, const double highX = 100, 0408 const unsigned long binsX = 50, const double lowY = 0, const double highY = 100, 0409 const unsigned long binsY = 50 ) const = 0; 0410 0411 /** book the 3D histogram 0412 * 0413 * The histogram will be assigned a unique identifier 0414 * 0415 * @see IHistogram3D 0416 * @param title histogram title (must be unique within the algorithm) 0417 * @param lowX low x limit for histogram 0418 * @param highX high x limit for histogram 0419 * @param binsX number of bins in x 0420 * @param lowY low y limit for histogram 0421 * @param highY high y limit for histogram 0422 * @param binsY number of bins in y 0423 * @param lowZ low y limit for histogram 0424 * @param highZ high y limit for histogram 0425 * @param binsZ number of bins in y 0426 * @return pointer to AIDA 3D histogram 0427 */ 0428 virtual AIDA::IHistogram3D* book3D( const std::string& title, const double lowX = 0, const double highX = 100, 0429 const unsigned long binsX = 10, const double lowY = 0, const double highY = 100, 0430 const unsigned long binsY = 10, const double lowZ = 0, const double highZ = 100, 0431 const unsigned long binsZ = 10 ) const = 0; 0432 0433 /** book the 1D histogram with forced ID 0434 * 0435 * @see IHistogram1D 0436 * @param ID unique histogram ID 0437 * @param title histogram title (must be unique within the algorithm) 0438 * @param low low limit for histogram 0439 * @param high high limit for histogram 0440 * @param bins number of bins 0441 * @return pointer to AIDA histogram 0442 */ 0443 virtual AIDA::IHistogram1D* book1D( const HistoID& ID, const std::string& title = "", const double low = 0, 0444 const double high = 100, const unsigned long bins = 100 ) const = 0; 0445 0446 /** book the 1D histogram with forced ID 0447 * 0448 * Wrapper method for the equivalent book1D method. 0449 * Retained for backwards compatibility, please use book1D instead. 0450 * 0451 * @see IHistogram1D 0452 * @param ID unique histogram ID 0453 * @param title histogram title (must be unique within the algorithm) 0454 * @param low low limit for histogram 0455 * @param high high limit for histogram 0456 * @param bins number of bins 0457 * @return pointer to AIDA histogram 0458 */ 0459 AIDA::IHistogram1D* book( const HistoID& ID, const std::string& title = "", const double low = 0, 0460 const double high = 100, const unsigned long bins = 100 ) const { 0461 return book1D( ID, title, low, high, bins ); 0462 } 0463 0464 /** book the 2D histogram with forced ID 0465 * 0466 * @see IHistogram2D 0467 * @param ID unique histogram ID 0468 * @param title histogram title (must be unique within the algorithm) 0469 * @param low low limit for histogram 0470 * @param high high limit for histogram 0471 * @param bins number of bins 0472 * @return pointer to AIDA histogram 0473 */ 0474 virtual AIDA::IHistogram2D* book2D( const HistoID& ID, const std::string& title, const double lowX = 0, 0475 const double highX = 100, const unsigned long binsX = 100, const double lowY = 0, 0476 const double highY = 100, const unsigned long binsY = 100 ) const = 0; 0477 0478 /** book the 3D histogram with forced ID 0479 * 0480 * @see IHistogram3D 0481 * @param ID unique histogram ID 0482 * @param title histogram title (must be unique within the algorithm) 0483 * @param lowX low x limit for histogram 0484 * @param highX high x limit for histogram 0485 * @param binsX number of bins in x 0486 * @param lowY low y limit for histogram 0487 * @param highY high y limit for histogram 0488 * @param binsY number of bins in y 0489 * @param lowZ low y limit for histogram 0490 * @param highZ high y limit for histogram 0491 * @param binsZ number of bins in y 0492 * @return pointer to AIDA 3D histogram 0493 */ 0494 virtual AIDA::IHistogram3D* book3D( const HistoID& ID, const std::string& title, const double lowX = 0, 0495 const double highX = 100, const unsigned long binsX = 10, const double lowY = 0, 0496 const double highY = 100, const unsigned long binsY = 10, const double lowZ = 0, 0497 const double highZ = 100, const unsigned long binsZ = 10 ) const = 0; 0498 0499 /** fill the 1D histo with the value and weight 0500 * @param histo 1D histogram to be filled 0501 * @param value value to be put into the histogram 0502 * @param weight weight to be used 0503 * @param title histogram title (to be used for error report) 0504 * @return pointer to AIDA 1D histogram 0505 */ 0506 virtual AIDA::IHistogram1D* fill( AIDA::IHistogram1D* histo, const double value, const double weight, 0507 const std::string& title = "" ) const = 0; 0508 0509 /** fill the 2D histo with the value and weight 0510 * @param histo 2D histogram to be filled 0511 * @param valueX x value to be put into the histogram 0512 * @param valueY y value to be put into the histogram 0513 * @param weight weight to be used 0514 * @param title histogram title (to be used for error report) 0515 * @return pointer to AIDA 2D histogram 0516 */ 0517 virtual AIDA::IHistogram2D* fill( AIDA::IHistogram2D* histo, const double valueX, const double valueY, 0518 const double weight, const std::string& title = "" ) const = 0; 0519 0520 /** fill the 3D histo with the value and weight 0521 * @param histo 3D histogram to be filled 0522 * @param valueX x value to be put into the histogram 0523 * @param valueY y value to be put into the histogram 0524 * @param valueZ z value to be put into the histogram 0525 * @param weight weight to be used 0526 * @param title histogram title (to be used for error report) 0527 * @return pointer to AIDA 3D histogram 0528 */ 0529 virtual AIDA::IHistogram3D* fill( AIDA::IHistogram3D* histo, const double valueX, const double valueY, 0530 const double valueZ, const double weight, const std::string& title = "" ) const = 0; 0531 0532 /** access the EXISTING 1D histogram by title 0533 * return the pointer to existing 1D histogram or NULL 0534 */ 0535 virtual AIDA::IHistogram1D* histo1D( const std::string& title ) const = 0; 0536 0537 /** access the EXISTING 1D histogram by title 0538 * 0539 * Wrapper method for the equivalent histo1D method. 0540 * Retained for backwards compatibility, please use histo1D instead. 0541 * 0542 * return the pointer to existing 1D histogram or NULL 0543 */ 0544 AIDA::IHistogram1D* histo( const std::string& title ) const { return histo1D( title ); }; 0545 0546 /** access the EXISTING 2D histogram by title 0547 * return the pointer to existing 2D histogram or NULL 0548 */ 0549 virtual AIDA::IHistogram2D* histo2D( const std::string& title ) const = 0; 0550 0551 /** access the EXISTING 3D histogram by title 0552 * return the pointer to existing 3D histogram or NULL 0553 */ 0554 virtual AIDA::IHistogram3D* histo3D( const std::string& title ) const = 0; 0555 0556 /** access the EXISTING 1D histogram by ID 0557 * return the pointer to existing 1D histogram or NULL 0558 */ 0559 virtual AIDA::IHistogram1D* histo1D( const HistoID& ID ) const = 0; 0560 0561 /** access the EXISTING 1D histogram by ID 0562 * 0563 * Wrapper method for the equivalent histo1D method. 0564 * Retained for backwards compatibility, please use histo1D instead. 0565 * 0566 * return the pointer to existing 1D histogram or NULL 0567 */ 0568 AIDA::IHistogram1D* histo( const HistoID& ID ) const { return histo1D( ID ); }; 0569 0570 /** access the EXISTING 2D histogram by ID 0571 * return the pointer to existing 2D histogram or NULL 0572 */ 0573 virtual AIDA::IHistogram2D* histo2D( const HistoID& ID ) const = 0; 0574 0575 /** access the EXISTING 3D histogram by ID 0576 * return the pointer to existing 3D histogram or NULL 0577 */ 0578 virtual AIDA::IHistogram3D* histo3D( const HistoID& ID ) const = 0; 0579 0580 /// check the existence AND validity of the histogram with given title 0581 virtual bool histoExists( const std::string& title ) const = 0; 0582 0583 /// check the existence AND validity of the histogram with given title 0584 virtual bool histoExists( const HistoID& ID ) const = 0; 0585 0586 public: 0587 /** fill the 1D histogram with information from 0588 * [first,last) sequence 0589 * 0590 * @code 0591 * 0592 * std::vector<double> v = ... ; 0593 * 0594 * plot( sin , // function 0595 * v.begin() , v.end() , // sequence 0596 * " bla-bla " , // title 0597 * -1. , 1.0 , // low and high limits 0598 * 100 ) // number of bins 0599 * 0600 * @endcode 0601 * 0602 * The histogram will get a unique integer identifier automatically assigned 0603 * 0604 * Sequence, objects and function can be non-trivial: 0605 * @code 0606 * 0607 * Particles* p = ... ; 0608 * 0609 * plot( PT , // function 0610 * p->begin() , p->end() , // sequence 0611 * " bla-bla " , // title 0612 * -1. , 1.0 , // low and high limits 0613 * 100 ) ; // number of bins 0614 * 0615 * @endcode 0616 * where <c>PT</c> can be any function or function object 0617 * for which the expression <c>PT(p)</c> , with <c>p</c> of type 0618 * <c>Particle*</c> have some sense and can be evaluated to 0619 * the values, which is convertible to <c>double</c> 0620 * 0621 * Note : These plot methods using iterator ranges are more efficient than 0622 * the simplier "value" only methods, since the associated histogram 0623 * only requires locating from internal storage once per loop, as opposed 0624 * to once per fill for the simplier functions. It is recommended to use 0625 * these whenever possible. 0626 * 0627 * @see AIDA::IHistogram1D 0628 * @param func function to be plotted 0629 * @param first begin of the sequence 0630 * @param last end of the sequence 0631 * @param title histogram title 0632 * @param low low limit for histogram 0633 * @param high high limit for histogram 0634 * @param bins number of bins for histogram 0635 */ 0636 template <class FUNCTION, class OBJECT> 0637 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, const double low, 0638 const double high, const unsigned long bins = 100 ) const { 0639 // retrieve or book the histogram 0640 AIDA::IHistogram1D* h = histo1D( title ); 0641 if ( !h ) { h = book1D( title, low, high, bins ); } 0642 while ( first != last && h ) { 0643 h = fill( h, func( *first ), 1.0, title ); 0644 ++first; 0645 } 0646 return h; 0647 } 0648 0649 /** fill the 1D histogram with forced ID and information from 0650 * [first,last) sequence 0651 * 0652 * @code 0653 * 0654 * std::vector<double> v = ... ; 0655 * 0656 * plot( sin , // function 0657 * v.begin() , v.end() , // sequence 0658 * 100 , " bla-bla " , // ID and title 0659 * -1. , 1.0 , // low and high limits 0660 * 100 ); // number of bins 0661 * 0662 * @endcode 0663 * 0664 * Sequence, objects and function can be non-trivial: 0665 * 0666 * @code 0667 * 0668 * Particles* p = ... ; 0669 * 0670 * plot( PT , // function 0671 * p->begin() , p->end() , // sequence 0672 * 100 , " bla-bla " , // ID and title 0673 * -1. , 1.0 , // low and high limits 0674 * 100 ) ; // number of bins 0675 * 0676 * @endcode 0677 * 0678 * Note : These plot methods using iterator ranges are more efficient than 0679 * the simplier "value" only methods, since the associated histogram 0680 * only requires locating from internal storage once per loop, as opposed 0681 * to once per fill for the simplier functions. It is recommended to use 0682 * these whenever possible. 0683 * 0684 * Note : This method is more efficient that the similar method without 0685 * forced ID, since the histogram lookup is faster using a numerical ID. 0686 * 0687 * @see AIDA::IHistogram1D 0688 * 0689 * @param func function to be plotted 0690 * @param first begin of the sequence 0691 * @param last end of the sequence 0692 * @param ID histogram identifier 0693 * @param title histogram title 0694 * @param low low limit for histogram 0695 * @param high high limit for histogram 0696 * @param bins number of bins for histogram 0697 */ 0698 template <class FUNCTION, class OBJECT> 0699 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID, 0700 const std::string& title, const double low, const double high, 0701 const unsigned long bins = 100 ) const { 0702 // retrieve or book the histogram 0703 AIDA::IHistogram1D* h = histo1D( ID ); 0704 if ( !h ) { h = book1D( ID, title, low, high, bins ); } 0705 while ( first != last && h ) { 0706 h = fill( h, func( *first ), 1.0, title ); 0707 ++first; 0708 } 0709 return h; 0710 } 0711 0712 /** book and fill the 1D histogram with information from 0713 * [first,last) sequence with given weight 0714 * 0715 * @code 0716 * 0717 * std::vector<double> v = ... ; 0718 * 0719 * plot( sin , // function 0720 * v.begin() , v.end() , // sequence 0721 * " bla-bla " , // title 0722 * -1. , 1.0 , // low and high limits 0723 * 100 , // number of bins 0724 * tanh ); // weight function 0725 * 0726 * @endcode 0727 * 0728 * The histogram will get a unique integer identifier automatically assigned 0729 * 0730 * Sequence, objects and function can be non-trivial: 0731 * @code 0732 * 0733 * Particles* p = ... ; 0734 * 0735 * plot( PT , // function 0736 * p->begin() , p->end() , // sequence 0737 * " bla-bla " , // title 0738 * -1. , 1.0 , // low and high limits 0739 * 100 , // number of bins 0740 * MASS ) ; // weight function 0741 * 0742 * @endcode 0743 * where <c>PT</c> and <c>MASS</c> can be any function 0744 * or function object 0745 * for which the expressions <c>PT(p)</c> and 0746 * <c>MASS</c> with <c>p</c> of type 0747 * <c>Particle*</c> have some sense and can be evaluated to 0748 * the values, which is convertible to <c>double</c> 0749 * 0750 * Note : These plot methods using iterator ranges are more efficient than 0751 * the simplier "value" only methods, since the associated histogram 0752 * only requires locating from internal storage once per loop, as opposed 0753 * to once per fill for the simplier functions. It is recommended to use 0754 * these whenever possible. 0755 * 0756 * @see AIDA::IHistogram1D 0757 * @param first begin of the sequence 0758 * @param last end of the sequence 0759 * @param title histogram title 0760 * @param func function to be plotted 0761 * @param low low limit for histogram 0762 * @param high high limit for histogram 0763 * @param bins number of bins for histogram 0764 * @param weight weight function 0765 */ 0766 template <class FUNCTION, class OBJECT, class WEIGHT> 0767 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const std::string& title, const double low, 0768 const double high, const unsigned long bins, const WEIGHT& weight ) const { 0769 // retrieve or book the histogram 0770 AIDA::IHistogram1D* h = histo1D( title ); 0771 if ( !h ) { h = book1D( title, low, high, bins ); } 0772 while ( first != last && h ) { 0773 h = fill( h, func( *first ), weight( *first ), title ); 0774 ++first; 0775 } 0776 return h; 0777 } 0778 0779 /** book and fill the 1D histogram with forced ID and information from 0780 * [first,last) sequence with given weight 0781 * 0782 * @code 0783 * 0784 * std::vector<double> v = ... ; 0785 * 0786 * plot( sin , // function 0787 * v.begin() , v.end() , // sequence 0788 * 100 , " bla-bla " , // ID and title 0789 * -1. , 1.0 , // low and high limits 0790 * 100 , // number of bins 0791 * sinh ); // weight function 0792 * 0793 * @endcode 0794 * 0795 * @attention no checks for NaN and Finite is performed! 0796 * 0797 * Sequence, objects and function can be non-trivial: 0798 * 0799 * @code 0800 * 0801 * Particles* p = ... ; 0802 * 0803 * plot( PT , // function 0804 * p->begin() , p->end() , // sequence 0805 * 100 , " bla-bla " , // ID and title 0806 * -1. , 1.0 , // low and high limits 0807 * 100 , // number of bins 0808 * MASS ) ; // weight function 0809 * 0810 * @endcode 0811 * where <c>PT</c> and <c>MASS</c> can be any function 0812 * or function object 0813 * for which the expressions <c>PT(p)</c> and 0814 * <c>MASS</c> with <c>p</c> of type 0815 * <c>Particle*</c> have some sense and can be evaluated to 0816 * the values, which is convertible to <c>double</c> 0817 * 0818 * Note : These plot methods using iterator ranges are more efficient than 0819 * the simplier "value" only methods, since the associated histogram 0820 * only requires locating from internal storage once per loop, as opposed 0821 * to once per fill for the simplier functions. It is recommended to use 0822 * these whenever possible. 0823 * 0824 * Note : This method is more efficient that the similar method without 0825 * forced ID, since the histogram lookup is faster using a numerical ID. 0826 * 0827 * @see AIDA::IHistogram1D 0828 * @param first begin of the sequence 0829 * @param last end of the sequence 0830 * @param ID histogram identifier 0831 * @param title histogram title 0832 * @param func function to be plotted 0833 * @param low low limit for histogram 0834 * @param high high limit for histogram 0835 * @param bins number of bins for histogram 0836 * @param weight weight function 0837 */ 0838 template <class FUNCTION, class OBJECT, class WEIGHT> 0839 AIDA::IHistogram1D* plot( const FUNCTION& func, OBJECT first, OBJECT last, const HistoID& ID, 0840 const std::string& title, const double low, const double high, const unsigned long bins, 0841 const WEIGHT& weight ) const { 0842 // retrieve or book the histogram 0843 AIDA::IHistogram1D* h = histo1D( ID ); 0844 if ( !h ) { h = book1D( ID, title, low, high, bins ); } 0845 while ( first != last && h ) { 0846 h = fill( h, func( *first ), weight( *first ), title ); 0847 ++first; 0848 } 0849 return h; 0850 } 0851 }; 0852 0853 #endif // GAUDIALG_IHISTOTOOL_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |