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