CGEM BOSS 6.6.5.g
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 <iostream>
47#include "CLHEP/Matrix/SymMatrix.h"
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{
60 bool valid( 1 );
61 double trace( 0 );
62
63 for( int i = 1; i<=dimension; i++ ){
64 double elem( error( i, i ) );
65 trace += elem;
66 if( elem < 0.0 ){
67 valid = 0;
68 if( msg ){
69 std::cout << "%ERROR detected at Ext_err_valid: error("
70 << i << "," << i << ") = " << elem << " < 0.0. "
71 << "Force to 0.0." << std::endl;
72 }
73 error( i, i ) = 0.0;
74 } else if( elem > Large ){
75 valid = 0;
76 if( msg ){
77 std::cout << "%ERROR detected at Ext_err_valid: error("
78 << i << "," << i << ") = " << elem << " > " << Large
79 << ". Force to " << Large << std::endl;
80 }
81 error( i, i ) = Large;
82 }
83 }
84 if( !trace ) valid = 0;
85 return( valid );
86}
87
88/*
89 This only checks but it does not force to set 0.
90*/
91
92bool Ext_err_valid( bool msg, const HepSymMatrix &error, const int dimension )
93{
94 bool valid( 1 );
95 double trace( 0 );
96
97 for( int i = 1; i<=dimension; i++ ){
98 double elem( error( i, i ) );
99 trace += elem;
100 if( elem < 0.0 ){
101 valid = 0;
102 if( msg ){
103 std::cout << "%ERROR detected at Ext_err_valid: error matrix: error("
104 << i << "," << i << ")= " << elem << " < 0.0." << std::endl;
105 }
106 } else if( elem > Large ){
107 valid = 0;
108 if( msg ){
109 std::cout << "%ERROR detected at Ext_err_valid: error matrix: error("
110 << i << "," << i << ")= " << elem << " > " << Large << std::endl;
111 }
112 }
113 }
114 if( !trace ) valid = 0;
115 return( valid );
116}
bool Ext_err_valid(bool msg, HepSymMatrix &error, const int dimension)