SND@LHC Software
Loading...
Searching...
No Matches
Exception.cc
Go to the documentation of this file.
1/* Copyright 2008-2010, Technische Universitaet Muenchen,
2 Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
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 "Exception.h"
21
22namespace genfit {
23
24bool Exception::quiet_ = true; // TR, to stop this annoying messages, false;
25
26Exception::Exception(std::string excString, int line, std::string file) :
27 excString_(excString), line_(line), file_(file), fatal_(false) {
28 std::ostringstream ErrMsgStream;
29 ErrMsgStream << "genfit::Exception thrown with excString:"
30 << std::endl << excString_ << std::endl
31 << "in line: " << line_ << " in file: " << file_ << std::endl
32 << "with fatal flag " << fatal_ << std::endl;
33 errorMessage_ = ErrMsgStream.str();
34}
35
37}
38
39void Exception::setNumbers(std::string _numbersLabel,
40 const std::vector<double>& _numbers) {
41 numbersLabel_ = _numbersLabel;
42 numbers_ = _numbers;
43}
44
45void Exception::setMatrices(std::string _matricesLabel,
46 const std::vector<TMatrixD>& _matrices) {
47 matricesLabel_ = _matricesLabel;
48 matrices_ = _matrices;
49}
50
51const char* Exception::what() const throw(){
52 //std::cerr << errorMessage_.c_str() << std::endl; // FIXME just for debugging purposes
53 if(quiet_) {
54 return "";
55 }
56 return errorMessage_.c_str();
57}
58
60 if(quiet_) return;
61 if(numbers_.empty() && matrices_.empty()) return; //do nothing
62 std::cout << "genfit::Exception Info Output" << std::endl;
63 std::cout << "===========================" << std::endl;
64 if(numbersLabel_ != "") {
65 std::cout << "Numbers Label String:" << std::endl;
66 std::cout << numbersLabel_ << std::endl;
67 }
68 if(!numbers_.empty()) {
69 std::cout << "---------------------------" << std::endl;
70 std::cout << "Numbers:" << std::endl;
71 for(unsigned int i=0;i<numbers_.size(); ++i ) std::cout << numbers_[i] << std::endl;
72 }
73 if(matricesLabel_ != "") {
74 std::cout << "---------------------------" << std::endl;
75 std::cout << "Matrices Label String:" << std::endl;
76 std::cout << matricesLabel_ << std::endl;
77 }
78 if(!matrices_.empty()) {
79 std::cout << "---------------------------" << std::endl;
80 std::cout << "Matrices:" << std::endl;
81 for(unsigned int i=0;i<matrices_.size(); ++i ) matrices_[i].Print();
82 }
83 std::cout << "===========================" << std::endl;
84}
85
86} /* End of namespace genfit */
87
void setNumbers(std::string, const std::vector< double > &)
Set list of numbers with description.
Definition Exception.cc:39
std::vector< TMatrixD > matrices_
Definition Exception.h:93
std::string matricesLabel_
Definition Exception.h:91
std::string errorMessage_
Definition Exception.h:88
std::string file_
Definition Exception.h:86
std::string excString_
Definition Exception.h:84
virtual const char * what() const
Standard error message handling for exceptions. use like "std::cerr << e.what();".
Definition Exception.cc:51
static bool quiet_
Definition Exception.h:82
void setMatrices(std::string, const std::vector< TMatrixD > &)
Set list of matrices with description.
Definition Exception.cc:45
virtual ~Exception()
Definition Exception.cc:36
Exception(std::string excString, int line, std::string file)
Initializing constructor.
Definition Exception.cc:26
std::vector< double > numbers_
Definition Exception.h:92
std::string numbersLabel_
Definition Exception.h:90
void info()
Print information in the exception object.
Definition Exception.cc:59
Matrix inversion tools.
Definition AbsBField.h:29