/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Mdc/MdcAlignAlg/MdcAlignAlg-00-01-04/share/distAlign/src/mergeAlign.cpp File Reference

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
#include "TFile.h"
#include "TTree.h"
#include "TFolder.h"
#include "TProfile.h"
#include "TObjArray.h"
#include "TSpline.h"
#include "TPostScript.h"
#include "TLatex.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "include/MdcAlignPar.h"
#include "include/MdcCosGeom.h"
#include "include/fun.h"
#include "include/ResiAlign.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 26 of file mergeAlign.cpp.

References AlignBase::align(), EvtCyclic3::c_str(), getHistList(), AlignBase::init(), MdcAlignPar::initAlignPar(), AlignBase::mergeHist(), RealDBUtil::npos, MdcAlignPar::rdAlignPar(), deljobs::string, and MdcAlignPar::wrtAlignPar().

00026                                 {
00027      char* jobname;
00028      if(argc>1){
00029           jobname = argv[1];
00030      }else{
00031           cout << "bad argument" << endl;
00032           return -1;
00033      }
00034 
00035      string path = "";
00036      string strJob = jobname;
00037      cout << "strJob: " << strJob << endl;
00038      string::size_type ilast = strJob.find_last_of("/");
00039      if(string::npos != ilast){
00040           path = strJob.substr(0, ilast);
00041      }
00042 
00043      int alignMeth;
00044      string alignFile;
00045      string confname;
00046      string str;
00047      string strtmp;
00048      ifstream fjob(jobname);
00049      if( ! fjob.is_open() ){
00050           cout << "ERROR: can not read jobOption: " << jobname << endl;
00051           return 0;
00052      } else{
00053           cout << "Open jobOption: " << jobname << endl;
00054           while( getline(fjob, str) ){
00055                if(str.find("//", 0) != string::npos){
00056                     continue;
00057                } else if( str.find("MdcGeomSvc.alignFilePath", 0) != string::npos ){
00058                     string::size_type i1 = str.find_first_of("\"");
00059                     string::size_type i2 = str.find_last_of("\"");
00060                     alignFile = str.substr(i1+1, i2-i1-1);
00061                } else if(str.find("MdcAlignAlg.ConfigFile", 0) != string::npos){
00062                     string::size_type i1 = str.find_first_of("\"");
00063                     string::size_type i2 = str.find_last_of("\"");
00064                     confname = str.substr(i1+1, i2-i1-1);
00065                } else if(str.find("MdcAlignAlg.MdcAlignMeth", 0) != string::npos){
00066                     string::size_type i1 = str.find_first_of("=");
00067                     string::size_type i2 = str.find_last_of(";");
00068                     strtmp = str.substr(i1+1, i2-i1-1);
00069                     sscanf(strtmp.c_str(), "%d", &alignMeth);
00070                }
00071           }
00072      }
00073 
00074      MdcCosGeom* pGeom = 0;
00075      pGeom = new MdcCosGeom("/home/bes/wulh/document/wireconf.txt", "/home/bes/wulh/calibConst/MdcAlignPar_ini.txt" );
00076      pGeom -> initialize(0.0);
00077 
00078      TObjArray* hlist = new TObjArray(0);
00079      AlignBase* pAlign;
00080      if(0 == alignMeth) pAlign = new ResiAlign();
00081      else {cout << "Error AlignType" << endl; return 0;}
00082      pAlign->init(hlist, pGeom);
00083 
00084      vector<string> fhistname = getHistList();
00085      if(0==fhistname.size()){
00086           cout << "hist file path: " << path << endl;
00087           fhistname = getHistList(path);
00088      }
00089      for(unsigned nf=0; nf<fhistname.size(); nf++){
00090           TFile* fin = new TFile(fhistname[nf].c_str());
00091           if(!fin->IsOpen()){
00092                continue;
00093           } else{
00094                cout << "merge hist file " << nf << ": " << fhistname[nf] << endl;
00095                pAlign->mergeHist(fin);
00096                fin->Close();
00097           }
00098      }
00099 
00100      // read align par.
00101      MdcAlignPar* alignPar = new MdcAlignPar();
00102      alignPar->initAlignPar();
00103      alignPar->rdAlignPar(alignFile);
00104 
00105      // fit for alignment
00106      pAlign->align(alignPar);
00107 
00108      TFile fhist("histall.root", "recreate");
00109      fhist.cd();
00110      hlist->Write();
00111      fhist.Close();
00112 
00113      // output new alignment file
00114      alignPar->wrtAlignPar();
00115 
00116      return 0;
00117 }


Generated on Tue Nov 29 23:16:45 2016 for BOSS_7.0.2 by  doxygen 1.4.7