35int main(
int argc,
char* argv[]){
42 sscanf(strcal,
"%d", &fgCal);
46 cout <<
"bad argument" << endl;
49 if(fgCal <= 0) cout <<
"do not calibrate " << endl;
52 string strJob = jobname;
53 cout <<
"strJob: " << strJob << endl;
54 string::size_type ilast = strJob.find_last_of(
"/");
55 if(string::npos != ilast){
56 path = strJob.substr(0, ilast);
64 ifstream fjob(jobname);
65 if( ! fjob.is_open() ){
66 cout <<
"ERROR: can not read jobOption: " << jobname << endl;
69 cout <<
"Open jobOption: " << jobname << endl;
70 while( getline(fjob, str) ){
71 if(str.find(
"//", 0) != string::npos){
73 }
else if( str.find(
"CalibRootCnvSvc.Mdcrootfile", 0) != string::npos ){
74 string::size_type i1 = str.find_first_of(
"\"");
75 string::size_type i2 = str.find_last_of(
"\"");
76 constname = str.substr(i1+1, i2-i1-1);
77 }
else if(str.find(
"MdcCalibAlg.ConfigFile", 0) != string::npos){
78 string::size_type i1 = str.find_first_of(
"\"");
79 string::size_type i2 = str.find_last_of(
"\"");
80 confname = str.substr(i1+1, i2-i1-1);
81 }
else if(str.find(
"MdcCalibAlg.MdcCalFlg", 0) != string::npos){
82 string::size_type i1 = str.find_first_of(
"=");
83 string::size_type i2 = str.find_last_of(
";");
84 strtmp = str.substr(i1+1, i2-i1-1);
85 sscanf(strtmp.c_str(),
"%d", &calType);
91 pGeom =
new MdcCosGeom(
"/home/bes/wulh/document/wireconf.txt",
"/home/bes/wulh/calibConst/MdcAlignPar_ini.txt" );
92 pGeom -> initialize(0.0);
95 for(lay=0; lay<15; lay++)
gNEntr[lay] = 1;
96 for(lay=15; lay<43; lay++)
gNEntr[lay] = 2;
101 ifstream fconfig(confname.c_str());
102 if( ! fconfig.is_open() ){
103 cout <<
"ERROR: can not read config file" << endl;
106 cout <<
"Open config file: " << confname << endl;
107 while( fconfig >> strconfig ){
108 if(
'#' == strconfig[0]){
109 getline(fconfig, strcomment);
110 }
else if(
"TimeShift" == strconfig){
112 }
else if(
"TesMin" == strconfig){
114 }
else if(
"TesMax" == strconfig){
116 }
else if(
"FlagIniCalConst" == strconfig){
118 }
else if(
"FlagUpdateTmInPreT0" == strconfig){
120 }
else if(
"InitT0" == strconfig){
122 }
else if(
"T0Shift" == strconfig){
124 }
else if(
"TminFitChindf" == strconfig){
126 }
else if(
"TmaxFitChindf" == strconfig){
128 }
else if(
"ResidualType" == strconfig){
130 }
else if(
"UpdateSigma" == strconfig){
132 }
else if(
"FixXtC0" == strconfig){
134 }
else if(
"RawTimeFitRange" == strconfig){
135 for(lay=0; lay<
NLAYER; lay++){
152 TObjArray* hlist =
new TObjArray(0);
154 if(0 == calType) pcal =
new IniCalib();
155 else if(1 == calType) pcal =
new PreXtCalib();
156 else if(2 == calType) pcal =
new PreT0Calib();
157 else if(3 == calType) pcal =
new XtCalib();
158 else if(4 == calType) pcal =
new GrXtCalib();
160 else if(5 == calType) pcal =
new T0Calib();
161 else if(8 == calType) pcal =
new QtCalib();
162 else {cout <<
"Error CalibType" << endl;
return 0;}
163 pcal->
init(hlist, pGeom);
166 if(0==fhistname.size()){
167 cout <<
"hist file path: " << path << endl;
170 for(
unsigned nf=0; nf<fhistname.size(); nf++){
171 TFile* fin =
new TFile(fhistname[nf].c_str());
175 cout <<
"merge hist file " << nf <<
": " << fhistname[nf] << endl;
184 if(constname==
""){constname =
"/home/bes/wulh/calibConst/MdcCalibConst_11397_psi3770_652b_v1.root";}
185 TFile fconst(constname.c_str());
186 if(!fconst.IsOpen()){
187 cout <<
"ERROR: " << constname <<
" does not exist" << endl;
190 cout <<
"Open calib const file " << constname << endl;
194 TTree* xttree = (TTree*)fconst.Get(
"XtTree");
197 entry = (int)xttree -> GetEntries();
198 for(
int i=0; i<entry; i++){
205 TTree* t0tree = (TTree*)fconst.Get(
"T0Tree");
208 entry = (int)t0tree -> GetEntries();
209 for(
int i=0; i<entry; i++){
217 TTree* qttree = (TTree*)fconst.Get(
"QtTree");
220 entry = (int)qttree -> GetEntries();
221 for(
int i=0; i<entry; i++){
228 TTree* sdtree = (TTree*)fconst.Get(
"SdTree");
231 entry = sdtree -> GetEntries();
232 for(
int i=0; i<entry; i++){
237 TObjArray* newXtList =
new TObjArray(0);
238 TList* list = fconst.GetListOfKeys();
239 int listSize = (int)(list->GetSize());
240 cout <<
"Number of trees in old calib const file: " << listSize << endl;
243 for (
int i = 0; i<listSize; i++) {
244 TTree* tree = (TTree*)fconst.Get(list->At(i)->GetName());
245 string strName(tree->GetName());
246 if(string::npos != strName.find(
"trNewXt")){
247 TTree* t2 = tree->CopyTree(
"");
254 gStyle -> SetCanvasBorderMode(0);
256 gStyle -> SetOptFit(0011);
257 gStyle -> SetStatColor(10);
258 gStyle -> SetStatBorderSize(1);
259 gStyle -> SetStatFont(42);
260 gStyle -> SetStatFontSize(0.04);
261 gStyle -> SetStatX(0.9);
262 gStyle -> SetStatY(0.9);
263 gStyle -> SetPadColor(10);
264 gStyle -> SetFuncColor(2);
266 TObjArray* r2tList =
new TObjArray(0);
269 pcal->
calib(calconst, newXtList, r2tList);
271 TFile fhist(
"histall.root",
"recreate");
277 if(fgCal > 0)
writeConst(calconst, newXtList, r2tList);