LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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 bool GFException::fQuiet = false;
25 
26 GFException::GFException(std::string _excString, int _line, std::string _file) : fExcString(_excString), fLine(_line), fFile(_file),fFatal(false) {
27 }
28 
30 }
31 
32 GFException& GFException::setNumbers(std::string _numbersLabel,
33  const std::vector<double>& _numbers) {
34  fNumbersLabel = _numbersLabel;
35  fNumbers = _numbers;
36  return *this;
37 }
38 
39 GFException& GFException::setMatrices(std::string _matricesLabel,
40  const std::vector< TMatrixT<Double_t> >& _matrices) {
41  fMatricesLabel = _matricesLabel;
42  fMatrices = _matrices;
43  return *this;
44 }
45 
46 const char* GFException::what() const throw(){
47  if(fQuiet) return "";
48  std::ostringstream returnStream;
49  returnStream << "GFException thrown with excString:"
50  << std::endl << fExcString << std::endl
51  << "in line: " << fLine << " in file: " << fFile << std::endl
52  << "with fatal flag " << fFatal << std::endl;
53  return returnStream.str().c_str();
54 }
55 
57  if(fQuiet) return;
58  if(fNumbers.size() == 0 && fMatrices.size() == 0) return;//do nothing
59  std::cout << "GFException Info Output" << std::endl;
60  std::cout << "===========================" << std::endl;
61  if(fNumbersLabel != "") {
62  std::cout << "Numbers Label String:" << std::endl;
63  std::cout << fNumbersLabel << std::endl;
64  }
65  if(fNumbers.size() > 0) {
66  std::cout << "---------------------------" << std::endl;
67  std::cout << "Numbers:" << std::endl;
68  for(unsigned int i=0;i<fNumbers.size(); i++ ) std::cout << fNumbers.at(i) << std::endl;
69  }
70  if(fMatricesLabel != "") {
71  std::cout << "---------------------------" << std::endl;
72  std::cout << "Matrices Label String:" << std::endl;
73  std::cout << fMatricesLabel << std::endl;
74  }
75  if(fMatrices.size() > 0) {
76  std::cout << "---------------------------" << std::endl;
77  std::cout << "Matrices:" << std::endl;
78  for(unsigned int i=0;i<fMatrices.size(); i++ ) fMatrices.at(i).Print();
79  }
80  std::cout << "===========================" << std::endl;
81 }
82 
83 
84 //------------------------------------------------------------------------------
85 template <>
86 void genf::PrintROOTobject(std::ostream& out, const TVector3& v) {
87  out << "(x,y,z)=(" << v.X() << "," << v.Y() << "," << v.Z() << ")"
88  " (rho,theta,phi)=(" << v.Mag() << "," << (v.Theta()*TMath::RadToDeg())
89  << "," << (v.Phi()*TMath::RadToDeg()) << ")";
90 } // genf::PrintROOTobject<TVector3>()
91 
GFException & setNumbers(std::string, const std::vector< double > &)
set list of numbers with description
Definition: GFException.cxx:32
std::string fNumbersLabel
Definition: GFException.h:60
std::vector< TMatrixT< Double_t > > fMatrices
Definition: GFException.h:63
virtual const char * what() const
standard error message handling for exceptions. use like "std::cerr << e.what();" ...
Definition: GFException.cxx:46
std::string fMatricesLabel
Definition: GFException.h:61
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
std::string fFile
Definition: GFException.h:58
GFException & setMatrices(std::string, const std::vector< TMatrixT< Double_t > > &)
set list of matrices with description
Definition: GFException.cxx:39
void info()
print information in the exception object
Definition: GFException.cxx:56
Exception class for error handling in GENFIT (provides storage for diagnostic information) ...
Definition: GFException.h:50
GFException(std::string, int, std::string)
Initializing constructor.
Definition: GFException.cxx:26
std::vector< double > fNumbers
Definition: GFException.h:62
virtual ~GFException()
Definition: GFException.cxx:29
void PrintROOTobject(std::ostream &, const ROOTOBJ &)
Small utility functions which print some ROOT objects into an output stream.
Definition: GFException.h:129
std::string fExcString
Definition: GFException.h:56
static bool fQuiet
Definition: GFException.h:54