/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Mdc/MdcAlignAlg/MdcAlignAlg-00-01-04/src/MdcAlignPar.cxx

Go to the documentation of this file.
00001 #include "MdcAlignAlg/MdcAlignPar.h"
00002 
00003 #include "GaudiKernel/MsgStream.h"
00004 #include "GaudiKernel/IMessageSvc.h"
00005 #include "GaudiKernel/StatusCode.h"
00006 #include "GaudiKernel/ISvcLocator.h"
00007 #include "GaudiKernel/Bootstrap.h"
00008 #include "GaudiKernel/SmartDataPtr.h"
00009 #include "GaudiKernel/IDataProviderSvc.h"
00010 #include "GaudiKernel/PropertyMgr.h"
00011 
00012 #include <iostream>
00013 #include <fstream>
00014 #include <string>
00015 #include <cstring>
00016 
00017 using namespace std;
00018 using namespace Alignment;
00019 
00020 MdcAlignPar::MdcAlignPar(){
00021      for(int iEP=0; iEP<NEP; iEP++){
00022           m_delDx[iEP] = 0.0;
00023           m_delDy[iEP] = 0.0;
00024           m_delDz[iEP] = 0.0;
00025           m_delRx[iEP] = 0.0;
00026           m_delRy[iEP] = 0.0;
00027           m_delRz[iEP] = 0.0;
00028      }
00029 }
00030 
00031 MdcAlignPar::~MdcAlignPar(){
00032 }
00033 void MdcAlignPar::initAlignPar(){
00034      for(int iEP=0; iEP<NEP; iEP++){
00035           m_dx[iEP] = 0.0;
00036           m_dy[iEP] = 0.0;
00037           m_dz[iEP] = 0.0;
00038           m_rx[iEP] = 0.0;
00039           m_ry[iEP] = 0.0;
00040           m_rz[iEP] = 0.0;
00041 
00042           m_errDx[iEP] = 0.0;
00043           m_errDy[iEP] = 0.0;
00044           m_errDz[iEP] = 0.0;
00045           m_errRx[iEP] = 0.0;
00046           m_errRy[iEP] = 0.0;
00047           m_errRz[iEP] = 0.0;
00048      }
00049 }
00050 
00051 bool MdcAlignPar::rdAlignPar(std::string alignFile){
00052      IMessageSvc* msgSvc;
00053      Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
00054      MsgStream log(msgSvc, "MdcAlignPar");
00055      log << MSG::WARNING << "read MdcAlignPar data directly from run directory"
00056          << endreq;
00057 
00058      ifstream fpar(alignFile.c_str());
00059      log << MSG::INFO << "open file" << endreq;
00060      if( ! fpar.is_open() ){
00061           log << MSG::FATAL << "can not open alignment file " << alignFile.c_str() << endreq;
00062           return false;
00063      }
00064 
00065      int i;
00066      string strtmp;
00067      for(i=0; i<7; i++) fpar >> strtmp;
00068      for(int iEP=0; iEP<NEP; iEP++){
00069           fpar >> strtmp >> m_dx[iEP] >> m_dy[iEP] >> m_dz[iEP]
00070                >> m_rx[iEP] >> m_ry[iEP] >> m_rz[iEP];
00071      }
00072      fpar.close();
00073      return true;
00074 }
00075 
00076 void MdcAlignPar::wrtAlignPar(){
00077      IMessageSvc* msgSvc;
00078      Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
00079      MsgStream log(msgSvc, "MdcAlignPar");
00080      log << MSG::INFO << "MdcAlignPar::wrtAlignPar()" << endreq;
00081 
00082      int i;
00083      int iEnd;
00084      string str[] = {"Inner_east", "Step0_east", "Step1_east",
00085                      "Step2_east", "Step3_east", "Step4_east",
00086                      "Step5_east", "Outer_east", "Inner_west",
00087                      "Step0_west", "Step1_west", "Step2_west",
00088                      "Step3_west", "Step4_west", "Step5_west",
00089                      "Outer_west"};
00090 
00091      string name[] = {"Elements", "DeltaX(mm)", "DeltaY(mm)",
00092                       "DeltaZ(mm)", "RX(rad)", "RY(rad)", "RZ(rad)"};
00093 
00094      ofstream fout("alignPar_new.txt");
00095      fout << setw(14) << name[0];
00096      for(i=1; i<7; i++) fout << setw(13) << name[i];
00097      fout << endl;
00098      for (iEnd=0; iEnd<NEP; iEnd++){
00099           fout << setw(14) << str[iEnd]
00100                << setw(13) << m_dx[iEnd] + m_delDx[iEnd]
00101                << setw(13) << m_dy[iEnd] + m_delDy[iEnd]
00102                << setw(13) << m_dz[iEnd] + m_delDz[iEnd]
00103                << setw(13) << m_rx[iEnd] + m_delRx[iEnd]
00104                << setw(13) << m_ry[iEnd] + m_delRy[iEnd]
00105                << setw(13) << m_rz[iEnd] + m_delRz[iEnd] << endl;
00106           if(7 == iEnd) fout << endl;
00107      }
00108      fout.close();
00109 
00110      ofstream fdel("delAlign_new.txt");
00111      fdel << setw(14) << name[0];
00112      for(i=1; i<7; i++) fdel << setw(13) << name[i];
00113      fdel << endl;
00114      for (iEnd=0; iEnd<NEP; iEnd++){
00115           fdel << setw(14) << str[iEnd] << setw(13) << m_delDx[iEnd]
00116                << setw(13) << m_delDy[iEnd] << setw(13) << m_delDz[iEnd]
00117                << setw(13) << m_delRx[iEnd] << setw(13) << m_delRy[iEnd]
00118                << setw(13) << m_delRz[iEnd] << endl;
00119           if(7 == iEnd) fdel << endl;
00120      }
00121 
00122      fdel << endl << "Fit error:" << endl;
00123      for (iEnd=0; iEnd<NEP; iEnd++){
00124           fdel << setw(14) << str[iEnd] << setw(13) << m_errDx[iEnd]
00125                << setw(13) << m_errDy[iEnd] << setw(13) << m_errDz[iEnd]
00126                << setw(13) << m_errRx[iEnd] << setw(13) << m_errRy[iEnd]
00127                << setw(13) << m_errRz[iEnd] << endl;
00128           if(7 == iEnd) fdel << endl;
00129      }
00130      fdel.close();
00131 }

Generated on Tue Nov 29 23:12:48 2016 for BOSS_7.0.2 by  doxygen 1.4.7