BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
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

◆ main()

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

Definition at line 26 of file mergeAlign.cpp.

26 {
27 char* jobname;
28 if(argc>1){
29 jobname = argv[1];
30 }else{
31 cout << "bad argument" << endl;
32 return -1;
33 }
34
35 string path = "";
36 string strJob = jobname;
37 cout << "strJob: " << strJob << endl;
38 string::size_type ilast = strJob.find_last_of("/");
39 if(string::npos != ilast){
40 path = strJob.substr(0, ilast);
41 }
42
43 int alignMeth;
44 string alignFile;
45 string confname;
46 string str;
47 string strtmp;
48 ifstream fjob(jobname);
49 if( ! fjob.is_open() ){
50 cout << "ERROR: can not read jobOption: " << jobname << endl;
51 return 0;
52 } else{
53 cout << "Open jobOption: " << jobname << endl;
54 while( getline(fjob, str) ){
55 if(str.find("//", 0) != string::npos){
56 continue;
57 } else if( str.find("MdcGeomSvc.alignFilePath", 0) != string::npos ){
58 string::size_type i1 = str.find_first_of("\"");
59 string::size_type i2 = str.find_last_of("\"");
60 alignFile = str.substr(i1+1, i2-i1-1);
61 } else if(str.find("MdcAlignAlg.ConfigFile", 0) != string::npos){
62 string::size_type i1 = str.find_first_of("\"");
63 string::size_type i2 = str.find_last_of("\"");
64 confname = str.substr(i1+1, i2-i1-1);
65 } else if(str.find("MdcAlignAlg.MdcAlignMeth", 0) != string::npos){
66 string::size_type i1 = str.find_first_of("=");
67 string::size_type i2 = str.find_last_of(";");
68 strtmp = str.substr(i1+1, i2-i1-1);
69 sscanf(strtmp.c_str(), "%d", &alignMeth);
70 }
71 }
72 }
73
74 MdcCosGeom* pGeom = 0;
75 pGeom = new MdcCosGeom("/home/bes/wulh/document/wireconf.txt", "/home/bes/wulh/calibConst/MdcAlignPar_ini.txt" );
76 pGeom -> initialize(0.0);
77
78 TObjArray* hlist = new TObjArray(0);
79 AlignBase* pAlign;
80 if(0 == alignMeth) pAlign = new ResiAlign();
81 else {cout << "Error AlignType" << endl; return 0;}
82 pAlign->init(hlist, pGeom);
83
84 vector<string> fhistname = getHistList();
85 if(0==fhistname.size()){
86 cout << "hist file path: " << path << endl;
87 fhistname = getHistList(path);
88 }
89 for(unsigned nf=0; nf<fhistname.size(); nf++){
90 TFile* fin = new TFile(fhistname[nf].c_str());
91 if(!fin->IsOpen()){
92 continue;
93 } else{
94 cout << "merge hist file " << nf << ": " << fhistname[nf] << endl;
95 pAlign->mergeHist(fin);
96 fin->Close();
97 }
98 }
99
100 // read align par.
101 MdcAlignPar* alignPar = new MdcAlignPar();
102 alignPar->initAlignPar();
103 alignPar->rdAlignPar(alignFile);
104
105 // fit for alignment
106 pAlign->align(alignPar);
107
108 TFile fhist("histall.root", "recreate");
109 fhist.cd();
110 hlist->Write();
111 fhist.Close();
112
113 // output new alignment file
114 alignPar->wrtAlignPar();
115
116 return 0;
117}
virtual void align(MdcAlignPar *alignPar)=0
Definition: AlignBase.cpp:18
virtual void mergeHist(TFile *fhist)=0
Definition: AlignBase.cpp:15
virtual void init(TObjArray *hlist, MdcCosGeom *pGeom)=0
Definition: AlignBase.cpp:12
void initAlignPar()
Definition: MdcAlignPar.cpp:24
void wrtAlignPar()
Definition: MdcAlignPar.cpp:61
bool rdAlignPar(std::string alignFile)
Definition: MdcAlignPar.cpp:42
char * c_str(Index i)
Definition: EvtCyclic3.cc:252
std::ifstream ifstream
Definition: bpkt_streams.h:44