GFException.cxx
Go to the documentation of this file.
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "GFException.h"
21 
22 #include "TMath.h"
23 
24 #include <iostream>
25 
26 bool GFException::fQuiet = false;
27 
28 GFException::GFException(std::string _excString, int _line, std::string _file) : fExcString(_excString), fLine(_line), fFile(_file),fFatal(false) {
29 }
30 
32 }
33 
35  const std::vector<double>& _numbers) {
36  fNumbersLabel = _numbersLabel;
37  fNumbers = _numbers;
38  return *this;
39 }
40 
42  const std::vector< TMatrixT<Double_t> >& _matrices) {
43  fMatricesLabel = _matricesLabel;
44  fMatrices = _matrices;
45  return *this;
46 }
47 
48 const char* GFException::what() const throw(){
49  if(fQuiet) return "";
50  std::ostringstream returnStream;
51  returnStream << "GFException thrown with excString:"
53  << "in line: " << fLine << " in file: " << fFile << std::endl
54  << "with fatal flag " << fFatal << std::endl;
55  return returnStream.str().c_str();
56 }
57 
59  if(fQuiet) return;
60  if(fNumbers.size() == 0 && fMatrices.size() == 0) return;//do nothing
61  std::cout << "GFException Info Output" << std::endl;
62  std::cout << "===========================" << std::endl;
63  if(fNumbersLabel != "") {
64  std::cout << "Numbers Label String:" << std::endl;
65  std::cout << fNumbersLabel << std::endl;
66  }
67  if(fNumbers.size() > 0) {
68  std::cout << "---------------------------" << std::endl;
69  std::cout << "Numbers:" << std::endl;
70  for(unsigned int i=0;i<fNumbers.size(); i++ ) std::cout << fNumbers.at(i) << std::endl;
71  }
72  if(fMatricesLabel != "") {
73  std::cout << "---------------------------" << std::endl;
74  std::cout << "Matrices Label String:" << std::endl;
75  std::cout << fMatricesLabel << std::endl;
76  }
77  if(fMatrices.size() > 0) {
78  std::cout << "---------------------------" << std::endl;
79  std::cout << "Matrices:" << std::endl;
80  for(unsigned int i=0;i<fMatrices.size(); i++ ) fMatrices.at(i).Print();
81  }
82  std::cout << "===========================" << std::endl;
83 }
84 
85 
86 //------------------------------------------------------------------------------
87 template <>
88 void genf::PrintROOTobject(std::ostream& out, const TVector3& v) {
89  out << "(x,y,z)=(" << v.X() << "," << v.Y() << "," << v.Z() << ")"
90  " (rho,theta,phi)=(" << v.Mag() << "," << (v.Theta()*TMath::RadToDeg())
91  << "," << (v.Phi()*TMath::RadToDeg()) << ")";
92 } // genf::PrintROOTobject<TVector3>()
GFException & setNumbers(std::string, const std::vector< double > &)
set list of numbers with description
Definition: GFException.cxx:34
std::string fNumbersLabel
Definition: GFException.h:58
std::string string
Definition: nybbler.cc:12
std::vector< TMatrixT< Double_t > > fMatrices
Definition: GFException.h:61
virtual const char * what() const
standard error message handling for exceptions. use like "std::cerr << e.what();" ...
Definition: GFException.cxx:48
struct vector vector
std::string fMatricesLabel
Definition: GFException.h:59
std::string fFile
Definition: GFException.h:56
GFException & setMatrices(std::string, const std::vector< TMatrixT< Double_t > > &)
set list of matrices with description
Definition: GFException.cxx:41
void info()
print information in the exception object
Definition: GFException.cxx:58
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:48
GFException(std::string, int, std::string)
Initializing constructor.
Definition: GFException.cxx:28
std::vector< double > fNumbers
Definition: GFException.h:60
virtual ~GFException()
Definition: GFException.cxx:31
void PrintROOTobject(std::ostream &, const ROOTOBJ &)
Small utility functions which print some ROOT objects into an output stream.
Definition: GFException.h:127
std::string fExcString
Definition: GFException.h:54
static bool fQuiet
Definition: GFException.h:52
QTextStream & endl(QTextStream &s)