BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcAlignPar.cxx
Go to the documentation of this file.
2
3#include "GaudiKernel/Bootstrap.h"
4#include "GaudiKernel/IDataProviderSvc.h"
5#include "GaudiKernel/IMessageSvc.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/MsgStream.h"
8#include "GaudiKernel/PropertyMgr.h"
9#include "GaudiKernel/SmartDataPtr.h"
10#include "GaudiKernel/StatusCode.h"
11
12#include <cstring>
13#include <fstream>
14#include <iostream>
15#include <string>
16
17using namespace std;
18using namespace Alignment;
19
21 for ( int iEP = 0; iEP < NEP; iEP++ )
22 {
23 m_delDx[iEP] = 0.0;
24 m_delDy[iEP] = 0.0;
25 m_delDz[iEP] = 0.0;
26 m_delRx[iEP] = 0.0;
27 m_delRy[iEP] = 0.0;
28 m_delRz[iEP] = 0.0;
29 }
30}
31
34 for ( int iEP = 0; iEP < NEP; iEP++ )
35 {
36 m_dx[iEP] = 0.0;
37 m_dy[iEP] = 0.0;
38 m_dz[iEP] = 0.0;
39 m_rx[iEP] = 0.0;
40 m_ry[iEP] = 0.0;
41 m_rz[iEP] = 0.0;
42
43 m_errDx[iEP] = 0.0;
44 m_errDy[iEP] = 0.0;
45 m_errDz[iEP] = 0.0;
46 m_errRx[iEP] = 0.0;
47 m_errRy[iEP] = 0.0;
48 m_errRz[iEP] = 0.0;
49 }
50}
51
52bool MdcAlignPar::rdAlignPar( std::string alignFile ) {
53 IMessageSvc* msgSvc;
54 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
55 MsgStream log( msgSvc, "MdcAlignPar" );
56 log << MSG::WARNING << "read MdcAlignPar data directly from run directory" << endmsg;
57
58 ifstream fpar( alignFile.c_str() );
59 log << MSG::INFO << "open file" << endmsg;
60 if ( !fpar.is_open() )
61 {
62 log << MSG::FATAL << "can not open alignment file " << alignFile.c_str() << endmsg;
63 return false;
64 }
65
66 int i;
67 string strtmp;
68 for ( i = 0; i < 7; i++ ) fpar >> strtmp;
69 for ( int iEP = 0; iEP < NEP; iEP++ )
70 {
71 fpar >> strtmp >> m_dx[iEP] >> m_dy[iEP] >> m_dz[iEP] >> m_rx[iEP] >> m_ry[iEP] >>
72 m_rz[iEP];
73 }
74 fpar.close();
75 return true;
76}
77
79 IMessageSvc* msgSvc;
80 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
81 MsgStream log( msgSvc, "MdcAlignPar" );
82 log << MSG::INFO << "MdcAlignPar::wrtAlignPar()" << endmsg;
83
84 int i;
85 int iEnd;
86 string str[] = { "Inner_east", "Step0_east", "Step1_east", "Step2_east",
87 "Step3_east", "Step4_east", "Step5_east", "Outer_east",
88 "Inner_west", "Step0_west", "Step1_west", "Step2_west",
89 "Step3_west", "Step4_west", "Step5_west", "Outer_west" };
90
91 string name[] = { "Elements", "DeltaX(mm)", "DeltaY(mm)", "DeltaZ(mm)",
92 "RX(rad)", "RY(rad)", "RZ(rad)" };
93
94 ofstream fout( "alignPar_new.txt" );
95 fout << setw( 14 ) << name[0];
96 for ( i = 1; i < 7; i++ ) fout << setw( 13 ) << name[i];
97 fout << endl;
98 for ( iEnd = 0; iEnd < NEP; iEnd++ )
99 {
100 fout << setw( 14 ) << str[iEnd] << setw( 13 ) << m_dx[iEnd] + m_delDx[iEnd] << setw( 13 )
101 << m_dy[iEnd] + m_delDy[iEnd] << setw( 13 ) << m_dz[iEnd] + m_delDz[iEnd]
102 << setw( 13 ) << m_rx[iEnd] + m_delRx[iEnd] << setw( 13 )
103 << m_ry[iEnd] + m_delRy[iEnd] << setw( 13 ) << m_rz[iEnd] + m_delRz[iEnd] << endl;
104 if ( 7 == iEnd ) fout << endl;
105 }
106 fout.close();
107
108 ofstream fdel( "delAlign_new.txt" );
109 fdel << setw( 14 ) << name[0];
110 for ( i = 1; i < 7; i++ ) fdel << setw( 13 ) << name[i];
111 fdel << endl;
112 for ( iEnd = 0; iEnd < NEP; iEnd++ )
113 {
114 fdel << setw( 14 ) << str[iEnd] << setw( 13 ) << m_delDx[iEnd] << setw( 13 )
115 << m_delDy[iEnd] << setw( 13 ) << m_delDz[iEnd] << setw( 13 ) << m_delRx[iEnd]
116 << setw( 13 ) << m_delRy[iEnd] << setw( 13 ) << m_delRz[iEnd] << endl;
117 if ( 7 == iEnd ) fdel << endl;
118 }
119
120 fdel << endl << "Fit error:" << endl;
121 for ( iEnd = 0; iEnd < NEP; iEnd++ )
122 {
123 fdel << setw( 14 ) << str[iEnd] << setw( 13 ) << m_errDx[iEnd] << setw( 13 )
124 << m_errDy[iEnd] << setw( 13 ) << m_errDz[iEnd] << setw( 13 ) << m_errRx[iEnd]
125 << setw( 13 ) << m_errRy[iEnd] << setw( 13 ) << m_errRz[iEnd] << endl;
126 if ( 7 == iEnd ) fdel << endl;
127 }
128 fdel.close();
129}
IMessageSvc * msgSvc()
void initAlignPar()
void wrtAlignPar()
bool rdAlignPar(std::string alignFile)
const int NEP
Definition Alignment.h:46