Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:21

0001 /* Copyright 2008-2010, Technische Universitaet Muenchen,
0002    Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 /** @addtogroup genfit
0020  * @{
0021  */
0022 
0023 #ifndef genfit_Exception_h
0024 #define genfit_Exception_h
0025 
0026 #include <exception>
0027 #include <string>
0028 #include <vector>
0029 #include <iostream>
0030 #include <sstream>
0031 
0032 #include <TMatrixD.h>
0033 
0034 
0035 namespace genfit {
0036 
0037 /** @brief Exception class for error handling in GENFIT (provides storage for diagnostic information)
0038  *
0039  *  @author Christian H&ouml;ppner (Technische Universit&auml;t M&uuml;nchen, original author)
0040  *  @author Sebastian Neubert  (Technische Universit&auml;t M&uuml;nchen, original author)
0041  *
0042  * This is the class that is used for all error handling in GENFIT.
0043  * It is a utility class that allows to store numbers and matrices together
0044  * with an error string. The exception class can then be thrown when an error
0045  * is detected and the C++ exception handling facilities can be used to
0046  * catch and process the exception.
0047  */
0048 class Exception : public std::exception {
0049 
0050  public:
0051   /** @brief Initializing constructor
0052    *
0053    * @param excString error message.
0054    * @param line line at which the exception is created. Can be set through __LINE__ macro.
0055    * @param file sourcefile in which the exception is created. Can be set through __FILE__ macro.
0056    */
0057   Exception(std::string excString, int line, std::string  file);
0058   virtual ~Exception() noexcept;
0059 
0060   //! Set fatal flag.
0061   void setFatal (bool b=true){fatal_=b;}
0062   //! Get fatal flag.
0063   bool isFatal (){return fatal_;}
0064   //! Set list of numbers with description.
0065   void setNumbers (std::string, const std::vector<double>&);
0066   //! Set list of matrices with description.
0067   void setMatrices(std::string, const std::vector<TMatrixD>&);
0068 
0069   //! Print information in the exception object.
0070   void info();
0071 
0072   //! Standard error message handling for exceptions. use like "std::cerr << e.what();"
0073   virtual const char* what() const noexcept;
0074 
0075   std::string getExcString(){return excString_;}
0076 
0077   //! "std::cerr << e.what();" will not write anything.
0078   static void quiet(bool b=true){quiet_=b;}
0079 
0080  private:
0081 
0082   static bool quiet_;
0083 
0084   std::string excString_;
0085   int line_;
0086   std::string file_;
0087 
0088   std::string errorMessage_;
0089 
0090   std::string numbersLabel_;
0091   std::string matricesLabel_;
0092   std::vector<double> numbers_;
0093   std::vector<TMatrixD> matrices_;
0094 
0095   bool fatal_;
0096 
0097   //ClassDef(Exception,1)
0098 
0099 };
0100 
0101 } /* End of namespace genfit */
0102 /** @} */
0103 
0104 #endif // genfit_Exception_h