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