35 {
36 char* jobname;
37 char* strcal;
38 int fgCal = 1;
39 if(argc>2){
40 jobname = argv[1];
41 strcal = argv[2];
42 sscanf(strcal, "%d", &fgCal);
43 } else if(argc>1){
44 jobname = argv[1];
45 }else{
46 cout << "bad argument" << endl;
47 return -1;
48 }
49 if(fgCal <= 0) cout << "do not calibrate " << endl;
50
51 string path = "";
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);
57 }
58
59 int calType;
60 string constname;
61 string confname;
62 string str;
63 string strtmp;
65 if( ! fjob.is_open() ){
66 cout << "ERROR: can not read jobOption: " << jobname << endl;
67 return 0;
68 } else{
69 cout << "Open jobOption: " << jobname << endl;
70 while( getline(fjob, str) ){
71 if(str.find("//", 0) != string::npos){
72 continue;
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);
86 }
87 }
88 }
89
91 pGeom =
new MdcCosGeom(
"/home/bes/wulh/document/wireconf.txt",
"/home/bes/wulh/calibConst/MdcAlignPar_ini.txt" );
92 pGeom -> initialize(0.0);
93
94 int lay;
95 for(lay=0; lay<15; lay++)
gNEntr[lay] = 1;
96 for(lay=15; lay<43; lay++)
gNEntr[lay] = 2;
97
98
99 string strconfig;
100 string strcomment;
102 if( ! fconfig.is_open() ){
103 cout << "ERROR: can not read config file" << endl;
104 return 0;
105 } else{
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++){
136 fconfig >> strtmp
143 >> strtmp
146 }
147 }
148 }
149 }
150 fconfig.close();
151
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);
164
166 if(0==fhistname.size()){
167 cout << "hist file path: " << path << endl;
169 }
170 for(unsigned nf=0; nf<fhistname.size(); nf++){
171 TFile* fin =
new TFile(fhistname[nf].
c_str());
172 if(!fin->IsOpen()){
173 continue;
174 } else{
175 cout << "merge hist file " << nf << ": " << fhistname[nf] << endl;
177 fin->Close();
178 }
179 }
180
181
183
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;
188 return 0;
189 }
190 cout << "Open calib const file " << constname << endl;
192 double xtpar;
193 int entry;
194 TTree* xttree = (TTree*)fconst.Get("XtTree");
197 entry = (int)xttree -> GetEntries();
198 for(int i=0; i<entry; i++){
201 }
202
203 double t0;
204 double delt0;
205 TTree* t0tree = (TTree*)fconst.Get("T0Tree");
208 entry = (int)t0tree -> GetEntries();
209 for(int i=0; i<entry; i++){
213 }
214
215 double qtpar0;
216 double qtpar1;
217 TTree* qttree = (TTree*)fconst.Get("QtTree");
220 entry = (int)qttree -> GetEntries();
221 for(int i=0; i<entry; i++){
225 }
226
227 double sdpar;
228 TTree* sdtree = (TTree*)fconst.Get("SdTree");
231 entry = sdtree -> GetEntries();
232 for(int i=0; i<entry; i++){
235 }
236
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;
241 if(listSize > 4){
242 gROOT->cd();
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("");
248 newXtList->Add(t2);
249 }
250 }
251 }
252 fconst.Close();
253
254 gStyle -> SetCanvasBorderMode(0);
255 gStyle -> SetCanvasColor(10);
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);
265
266 TObjArray* r2tList = new TObjArray(0);
267
268
269 pcal->
calib(calconst, newXtList, r2tList);
270
271 TFile fhist("histall.root", "recreate");
272 fhist.cd();
273 hlist->Write();
274 fhist.Close();
275
276
277 if(fgCal > 0)
writeConst(calconst, newXtList, r2tList);
278
279 return 0;
280}
data SetBranchAddress("time",&time)
vector< string > getHistList()
double gTminFitRange[NLAYER][2]
double gTmaxFitRange[NLAYER][2]
void writeConst(MdcCalibConst *calconst, TObjArray *newXtList, TObjArray *r2tList)
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
virtual void init(TObjArray *hlist, MdcCosGeom *pGeom)=0
virtual void mergeHist(TFile *fhist)=0
virtual void calib(MdcCalibConst *calconst, TObjArray *newXtList, TObjArray *r2tList)=0
void fillXtpar(int key, double val)
void fillQtpar0(double val)
void fillQtpar1(double val)
void fillDelT0(double val)
void fillSdpar(int key, double val)