EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GFException.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GFException.cxx
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 #include"GFException.h"
20 
21 bool GFException::fQuiet = false;
22 
23 GFException::GFException(std::string _excString, int _line, std::string _file) : fExcString(_excString), fLine(_line), fFile(_file),fFatal(false) {
24  std::ostringstream ErrMsgStream;
25  ErrMsgStream << "GFException thrown with excString:"
26  << std::endl << fExcString << std::endl
27  << "in line: " << fLine << " in file: " << fFile << std::endl
28  << "with fatal flag " << fFatal << std::endl;
29  fErrorMessage = ErrMsgStream.str();
30 }
31 
33 }
34 
35 void GFException::setNumbers(std::string _numbersLabel,
36  const std::vector<double>& _numbers) {
37  fNumbersLabel = _numbersLabel;
38  fNumbers = _numbers;
39 }
40 
41 void GFException::setMatrices(std::string _matricesLabel,
42  const std::vector< TMatrixT<double> >& _matrices) {
43  fMatricesLabel = _matricesLabel;
44  fMatrices = _matrices;
45 }
46 
47 const char* GFException::what() const throw(){
48  if(fQuiet) return "";
49  return fErrorMessage.c_str();
50 }
51 
53  if(fQuiet) return;
54  if(fNumbers.size() == 0 && fMatrices.size() == 0) return;//do nothing
55  std::cout << "GFException Info Output" << std::endl;
56  std::cout << "===========================" << std::endl;
57  if(fNumbersLabel != "") {
58  std::cout << "Numbers Label String:" << std::endl;
59  std::cout << fNumbersLabel << std::endl;
60  }
61  if(fNumbers.size() > 0) {
62  std::cout << "---------------------------" << std::endl;
63  std::cout << "Numbers:" << std::endl;
64  for(unsigned int i=0;i<fNumbers.size(); i++ ) std::cout << fNumbers.at(i) << std::endl;
65  }
66  if(fMatricesLabel != "") {
67  std::cout << "---------------------------" << std::endl;
68  std::cout << "Matrices Label String:" << std::endl;
69  std::cout << fMatricesLabel << std::endl;
70  }
71  if(fMatrices.size() > 0) {
72  std::cout << "---------------------------" << std::endl;
73  std::cout << "Matrices:" << std::endl;
74  for(unsigned int i=0;i<fMatrices.size(); i++ ) fMatrices.at(i).Print();
75  }
76  std::cout << "===========================" << std::endl;
77 }