BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Ext_err_valid.cxx
Go to the documentation of this file.
1// File: Ext_err_valid.cc
2//
3// Check the validity of the error matrix and set the invalid element to 0.
4//
5// Creation: 13-Nov-1998
6// Version: 04-Mar-1999
7//
8// $Id: Ext_err_valid.cxx,v 1.2 2010/03/25 03:20:12 wangll Exp $
9//
10// Revision history
11//
12// $Log: Ext_err_valid.cxx,v $
13// Revision 1.2 2010/03/25 03:20:12 wangll
14// see the ChangeLog
15//
16// Revision 1.1.1.1 2005/08/10 06:59:26 wangll
17// First import TrkExtAlg.
18//
19// Revision 1.7 2000/04/13 22:13:14 katayama
20// added std:: to cout,cerr,endl,stream etc
21//
22// Revision 1.6 1999/03/05 07:03:27 teramoto
23// More for the treatment for the invalid error matrix.
24//
25// Revision 1.5 1999/03/05 02:13:43 teramoto
26// Reduction of the frequency of the invalid error matrix message.
27//
28// Revision 1.4 1999/02/26 09:30:02 teramoto
29// Suppress the invalid matrix error message and temporary fix the negative
30// diagonal element problem of the error matrix by forcing them to zero.
31//
32// Revision 1.3 1999/02/20 10:18:02 teramoto
33// Added error calculation skip function. Reduced error messages.
34//
35// Revision 1.2 1998/11/18 06:53:58 teramoto
36// Reduce the error messages for the invalid track error matrix.
37//
38// Revision 1.1 1998/11/13 11:20:19 teramoto
39// Modification for four purposes.
40// (1) Put protections for invalid error matrix values with error messages.
41// (2) Change the default media_list parameter from 0 to 1.
42// (3) Fill both the version 0 and 1 format panther banks as default.
43// (4) Put mandatory comment items in the heading comment lines.
44//
45
46#include "CLHEP/Matrix/SymMatrix.h"
47#include <iostream>
48
49using namespace CLHEP;
50
51static const double Large( 1.0e13 ); // large number.
52
53/*
54 valid(). Check the validity of the diagonal elements and if the
55 element is not valid, force the element to 0.0.
56*/
57
58bool Ext_err_valid( bool msg, HepSymMatrix& error, const int dimension ) {
59 bool valid( 1 );
60 double trace( 0 );
61
62 for ( int i = 1; i <= dimension; i++ )
63 {
64 double elem( error( i, i ) );
65 trace += elem;
66 if ( elem < 0.0 )
67 {
68 valid = 0;
69 if ( msg )
70 {
71 std::cout << "%ERROR detected at Ext_err_valid: error(" << i << "," << i
72 << ") = " << elem << " < 0.0. "
73 << "Force to 0.0." << std::endl;
74 }
75 error( i, i ) = 0.0;
76 }
77 else if ( elem > Large )
78 {
79 valid = 0;
80 if ( msg )
81 {
82 std::cout << "%ERROR detected at Ext_err_valid: error(" << i << "," << i
83 << ") = " << elem << " > " << Large << ". Force to " << Large << std::endl;
84 }
85 error( i, i ) = Large;
86 }
87 }
88 if ( !trace ) valid = 0;
89 return ( valid );
90}
91
92/*
93 This only checks but it does not force to set 0.
94*/
95
96bool Ext_err_valid( bool msg, const HepSymMatrix& error, const int dimension ) {
97 bool valid( 1 );
98 double trace( 0 );
99
100 for ( int i = 1; i <= dimension; i++ )
101 {
102 double elem( error( i, i ) );
103 trace += elem;
104 if ( elem < 0.0 )
105 {
106 valid = 0;
107 if ( msg )
108 {
109 std::cout << "%ERROR detected at Ext_err_valid: error matrix: error(" << i << "," << i
110 << ")= " << elem << " < 0.0." << std::endl;
111 }
112 }
113 else if ( elem > Large )
114 {
115 valid = 0;
116 if ( msg )
117 {
118 std::cout << "%ERROR detected at Ext_err_valid: error matrix: error(" << i << "," << i
119 << ")= " << elem << " > " << Large << std::endl;
120 }
121 }
122 }
123 if ( !trace ) valid = 0;
124 return ( valid );
125}
bool Ext_err_valid(bool msg, HepSymMatrix &error, const int dimension)