20 {
21
22 if(argc!=10) {
23 printf("error, wrong argument number!\n");
24 return 0;
25 }
26 char *opt_host_name=argv[1];
27 unsigned int opt_port_num = 3306;
28 char *opt_socket_name = NULL;
29 char *opt_db_name = argv[3];
30 char *opt_user_name = argv[4];
31 char *opt_password = argv[5];
32 TFile *
f=
new TFile(argv[6]);
33 char *opt_table_name = argv[7];
34 char *opt_type = argv[8];
35 char *opt_id = argv[9];
36 unsigned int opt_flags = 0;
37
38 static char query[80240000];
39 char *p;
40 char query_check[1024];
41
42 int status=-1;
43
44 if(
f->IsZombie())
return 0;
45
46
47 gROOT->cd();
48 if(strcmp(opt_type,"MDC")==0){
49 sprintf(query_check,
"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137 bool foundNewXtTree = false;
138 TObjArray newxttrees;
139 TBufferFile newxttree_buf(TBufferFile::kWrite);
140 int nNewXtTree = 0;
141 const int maxNewXtTreeNum = 43*18*2;
142 for(int t_layer=0; t_layer<43; t_layer++){
143 for(int t_bin=0; t_bin<18; t_bin++){
144 for(int t_lr=0; t_lr<2; t_lr++){
145 char newXtTreeName[20];
146 sprintf(newXtTreeName,
"trNewXt%02d_%02d_%d",t_layer,t_bin,t_lr);
147 if(!
f->Get(newXtTreeName))
break;
148 TTree *newXttree = ((TTree*)
f->Get(newXtTreeName))->CloneTree();
149 newxttrees.Add(newXttree);
150 nNewXtTree++;
151 }
152 }
153 }
154 if(nNewXtTree==maxNewXtTreeNum) {
155 foundNewXtTree = true;
156 newxttrees.Streamer(newxttree_buf);
157 }
158
159
160 TObjArray r2ttrees;
161 TBufferFile r2ttree_buf(TBufferFile::kWrite);
162 int nR2tTree = 0;
163 const int maxR2tTreeNum = 43;
164 for(int t_layer=0; t_layer<43; t_layer++){
165 char r2tTreeName[20];
166 sprintf(r2tTreeName,
"r2t%02d",t_layer);
167 if(!
f->Get(r2tTreeName))
break;
168 TTree *r2ttree = ((TTree*)
f->Get(r2tTreeName))->CloneTree();
169 r2ttrees.Add(r2ttree);
170 nR2tTree++;
171 }
172 if(nR2tTree!=maxR2tTreeNum){
173 printf("r2t tree error\n");
174 }else{
175 r2ttrees.Streamer(r2ttree_buf);
176 }
177
178
179
180
181
182 bool foundOldXtTree = false;
183 TTree *xttree = (TTree*)
f-> Get(
"XtTree");
184 if(xttree){ foundOldXtTree = true; }
185 TTree *xttree_copy = xttree->CloneTree();
186 TBufferFile xttree_buf(TBufferFile::kWrite);
187 if(xttree) xttree_copy->Streamer(xttree_buf);
188
189
190
191 if(!foundOldXtTree && !foundNewXtTree) {
192 printf("no Xt Tree\n");
193 return 0;
194 }
195
196
197
198 TTree *t0tree = (TTree*)
f-> Get(
"T0Tree");
199 TTree *t0tree_copy = t0tree->CloneTree();
200 TBufferFile t0tree_buf(TBufferFile::kWrite);
201 t0tree_copy->Streamer(t0tree_buf);
202
203
204 TTree *qttree = (TTree*)
f-> Get(
"QtTree");
205 TTree *qttree_copy = qttree->CloneTree();
206 TBufferFile qttree_buf(TBufferFile::kWrite);
207 qttree_copy->Streamer(qttree_buf);
208
209
210 TTree *sdtree = (TTree*)
f-> Get(
"SdTree");
211 TTree *sdtree_copy = sdtree->CloneTree();
212 TBufferFile sdtree_buf(TBufferFile::kWrite);
213 sdtree_copy->Streamer(sdtree_buf);
214
215
216
217
218
219
220 sprintf(query,
"UPDATE %s SET QtTree='",opt_table_name);
221 p= query + strlen(query);
222 p += mysql_escape_string(p,qttree_buf.Buffer(),qttree_buf.BufferSize());
223
224 if(xttree){
225 strcat(p,"',XtTree='");
226 p= query + strlen(query);
227 p +=mysql_escape_string(p,xttree_buf.Buffer(),xttree_buf.BufferSize());
228 }
229
230 if(nNewXtTree == maxNewXtTreeNum){
231 strcat(p,"',NewXtTrees='");
232 p= query + strlen(query);
233 p +=mysql_escape_string(p,newxttree_buf.Buffer(),newxttree_buf.BufferSize());
234 }
235
236 strcat(p,"',T0Tree='");
237 p= query + strlen(query);
238 p +=mysql_escape_string(p,t0tree_buf.Buffer(),t0tree_buf.BufferSize());
239
240 strcat(p,"',SdTree='");
241 p= query + strlen(query);
242 p +=mysql_escape_string(p,sdtree_buf.Buffer(),sdtree_buf.BufferSize());
243
244 strcat(p,"',R2tTrees='");
245 p= query + strlen(query);
246 p +=mysql_escape_string(p,r2ttree_buf.Buffer(),r2ttree_buf.BufferSize());
247
248 strcat(p,"' WHERE SerNo = ");
249 p= query + strlen(query);
250 strcat(p,opt_id);
251
252
253 } else if(strcmp(opt_type,"EMC")==0){
254 sprintf(query_check,
"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
255
256 TTree *DigiCalibConst = (TTree*)
f-> Get(
"DigiCalibConst");
257 TTree *DigiCalibConst_copy = DigiCalibConst->CloneTree();
258 TBufferFile DigiCalibConst_buf(TBufferFile::kWrite);
259 DigiCalibConst_copy->Streamer(DigiCalibConst_buf);
260
261
262
263
264
265
266
267 sprintf(query,
"UPDATE %s SET DigiCalibConst='",opt_table_name);
268 p= query + strlen(query);
269 p += mysql_escape_string(p,DigiCalibConst_buf.Buffer(),DigiCalibConst_buf.BufferSize());
270 strcat(p,"' WHERE SerNo = ");
271 strcat(p,opt_id);
272
273 } else if(strcmp(opt_type,"TOF")==0){
274 sprintf(query_check,
"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
275
276 TTree *xttree = (TTree*)
f-> Get(
"BarTofPar");
277 TTree *xttree_copy = xttree->CloneTree();
278 TBufferFile rootBuffer(TBufferFile::kWrite);
279 xttree_copy->Streamer(rootBuffer);
280
281 TTree *xttree1 = (TTree*)
f-> Get(
"EndTofPar");
282 TTree *xttree1_copy = xttree1->CloneTree();
283 TBufferFile rootBuffer1(TBufferFile::kWrite);
284 xttree1_copy->Streamer(rootBuffer1);
285
286 TTree *xttree2 = (TTree*)
f-> Get(
"BarTofParCommon");
287 TTree *xttree2_copy = xttree2->CloneTree();
288 TBufferFile rootBuffer2(TBufferFile::kWrite);
289 xttree2_copy->Streamer(rootBuffer2);
290
291 TTree *xttree3 = (TTree*)
f-> Get(
"CalibInfo");
292 TTree *xttree3_copy = xttree3->CloneTree();
293 TBufferFile rootBuffer3(TBufferFile::kWrite);
294 xttree3_copy->Streamer(rootBuffer3);
295
296
297
298 TTree *xttree4 = (TTree*)
f-> Get(
"EtfTofPar");
299 TBufferFile rootBuffer4(TBufferFile::kWrite);
300 if (xttree4) {
301 TTree *xttree4_copy = xttree4->CloneTree();
302 xttree4_copy->Streamer(rootBuffer4);
303 }
304
305 TTree *xttree5 = (TTree*)
f-> Get(
"EtfTofBunch");
306 TBufferFile rootBuffer5(TBufferFile::kWrite);
307 if (xttree5) {
308 TTree *xttree5_copy = xttree5->CloneTree();
309 xttree5_copy->Streamer(rootBuffer5);
310 }
311
312
313 sprintf(query,
"UPDATE %s SET BarTofPar='",opt_table_name);
314 p= query + strlen(query);
315 p += mysql_escape_string(p,rootBuffer.Buffer(),rootBuffer.BufferSize());
316 strcat(p,"',EndTofPar='");
317 p= query + strlen(query);
318 p +=mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
319 strcat(p,"',TofConPar='");
320 p= query + strlen(query);
321 p +=mysql_escape_string(p,rootBuffer2.Buffer(),rootBuffer2.BufferSize());
322 strcat(p,"',BarTof='");
323 p= query + strlen(query);
324
325 p +=mysql_escape_string(p,rootBuffer3.Buffer(),rootBuffer3.BufferSize());
326 if (xttree4) {
327 strcat(p,"',EtfTofPar='");
328 p= query + strlen(query);
329 p +=mysql_escape_string(p,rootBuffer4.Buffer(),rootBuffer4.BufferSize());
330 }
331 if (xttree5) {
332 strcat(p,"',EtfTofBunch='");
333 p= query + strlen(query);
334 p +=mysql_escape_string(p,rootBuffer5.Buffer(),rootBuffer5.BufferSize());
335 }
336
337 strcat(p,"' WHERE SerNo = ");
338 strcat(p,opt_id);
339
340 } else if(strcmp(opt_type,"MUC")==0){
341 sprintf(query_check,
"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
342
343 TTree *xttree = (TTree*)
f-> Get(
"LayConst");
344 TTree *xttree_copy = xttree->CloneTree();
345 TBufferFile rootBuffer(TBufferFile::kWrite);
346 xttree_copy->Streamer(rootBuffer);
347
348 TTree *xttree1 = (TTree*)
f-> Get(
"BoxConst");
349 TTree *xttree1_copy = xttree1->CloneTree();
350 TBufferFile rootBuffer1(TBufferFile::kWrite);
351 xttree1_copy->Streamer(rootBuffer1);
352
353 TTree *xttree2 = (TTree*)
f-> Get(
"StrConst");
354 TTree *xttree2_copy =xttree2->CloneTree();
355 TBufferFile rootBuffer2(TBufferFile::kWrite);
356 xttree2_copy->Streamer(rootBuffer2);
357
358
359 sprintf(query,
"UPDATE %s SET LayTree='",opt_table_name);
360 p= query + strlen(query);
361 p += mysql_escape_string(p,rootBuffer.Buffer(),rootBuffer.BufferSize());
362 strcat(p,"',BoxTree='");
363 p= query + strlen(query);
364 p += mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
365 strcat(p,"',StrTree='");
366 p= query + strlen(query);
367 p += mysql_escape_string(p,rootBuffer2.Buffer(),rootBuffer2.BufferSize());
368 strcat(p,"' WHERE SerNo = ");
369 strcat(p,opt_id);
370 }
371 else if(strcmp(opt_type,"DEDX")==0){
372 sprintf(query_check,
"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
373
374
375
376
377
378 TTree *ddgcalib = (TTree*)
f-> Get(
"ddgcalib");
379 TTree *ddgcalib_copy = ddgcalib->CloneTree();
380 TBufferFile ddgcalib_buf(TBufferFile::kWrite);
381 ddgcalib_copy->Streamer(ddgcalib_buf);
382
383 TTree *entracalib = (TTree*)
f-> Get(
"entracalib");
384 TTree *entracalib_copy = entracalib->CloneTree();
385 TBufferFile entracalib_buf(TBufferFile::kWrite);
386 entracalib_copy->Streamer(entracalib_buf);
387
388 TTree *gaincalib = (TTree*)
f-> Get(
"gaincalib");
389 TTree *gaincalib_copy = gaincalib->CloneTree();
390 TBufferFile gaincalib_buf(TBufferFile::kWrite);
391 gaincalib_copy->Streamer(gaincalib_buf);
392
393 TTree *ggscalib = (TTree*)
f-> Get(
"ggscalib");
394 TTree *ggscalib_copy = ggscalib->CloneTree();
395 TBufferFile ggscalib_buf(TBufferFile::kWrite);
396 ggscalib_copy->Streamer(ggscalib_buf);
397
398 TTree *layergcalib = (TTree*)
f-> Get(
"layergcalib");
399 TTree *layergcalib_copy = layergcalib->CloneTree();
400 TBufferFile layergcalib_buf(TBufferFile::kWrite);
401 layergcalib_copy->Streamer(layergcalib_buf);
402
403 TTree *resolcalib = (TTree*)
f-> Get(
"resolcalib");
404 TTree *resolcalib_copy =resolcalib->CloneTree();
405 TBufferFile resolcalib_buf(TBufferFile::kWrite);
406 resolcalib_copy->Streamer(resolcalib_buf);
407
408 TTree *wiregcalib = (TTree*)
f-> Get(
"wiregcalib");
409 TTree *wiregcalib_copy = wiregcalib->CloneTree();
410
411
412
413
414
415 TBufferFile wiregcalib_buf(TBufferFile::kWrite);
416 wiregcalib_copy->Streamer(wiregcalib_buf);
417
418
419 TTree *zdepcalib = (TTree*)
f-> Get(
"zdepcalib");
420 TTree *zdepcalib_copy = zdepcalib->CloneTree();
421 TBufferFile zdepcalib_buf(TBufferFile::kWrite);
422 zdepcalib_copy->Streamer(zdepcalib_buf);
423
424 TTree *runcalib = (TTree*)
f-> Get(
"runcalib");
425 TTree *runcalib_copy = runcalib->CloneTree();
426 TBufferFile runcalib_buf(TBufferFile::kWrite);
427 runcalib_copy->Streamer(runcalib_buf);
428
429
430
431
432
433
434
435 sprintf(query,
"UPDATE %s SET WireGain='",opt_table_name);
436
437 p= query + strlen(query);
438
439 p += mysql_escape_string(p,wiregcalib_buf.Buffer(),wiregcalib_buf.BufferSize());
440
441 strcat(p,"',Resolution = '");
442 p= query + strlen(query);
443 p += mysql_escape_string(p,resolcalib_buf.Buffer(),resolcalib_buf.BufferSize());
444 strcat(p,"',MeanGain = '");
445 p= query + strlen(query);
446 p += mysql_escape_string(p,gaincalib_buf.Buffer(),gaincalib_buf.BufferSize());
447 strcat(p,"',GasGain = '");
448 p= query + strlen(query);
449 p += mysql_escape_string(p,ggscalib_buf.Buffer(),ggscalib_buf.BufferSize());
450 strcat(p,"',LayerGain = '");
451 p= query + strlen(query);
452 p += mysql_escape_string(p,layergcalib_buf.Buffer(),layergcalib_buf.BufferSize());
453 strcat(p,"',ZDep = '");
454 p= query + strlen(query);
455 p += mysql_escape_string(p,zdepcalib_buf.Buffer(),zdepcalib_buf.BufferSize());
456 strcat(p,"',EntranceAng = '");
457 p= query + strlen(query);
458 p += mysql_escape_string(p,entracalib_buf.Buffer(),entracalib_buf.BufferSize());
459 strcat(p,"',RunGain = '");
460 p= query + strlen(query);
461
462 p += mysql_escape_string(p,runcalib_buf.Buffer(),runcalib_buf.Length());
463
464
465
466
467
468
469
470
471
472 strcat(p,"',DriftDist = '");
473 p= query + strlen(query);
474 p += mysql_escape_string(p,ddgcalib_buf.Buffer(),ddgcalib_buf.BufferSize());
475 strcat(p,"' WHERE SerNo = ");
476 strcat(p,opt_id);
477
478 } else if(strcmp(opt_type,"ESTIME")==0){
479 sprintf(query_check,
"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
480
481 TTree *xttree = (TTree*)
f-> Get(
"h2");
482 TTree *xttree_copy = xttree->CloneTree();
483 TBufferFile rootBuffer(TBufferFile::kWrite);
484 xttree_copy->Streamer(rootBuffer);
485
486 TTree *xttree1 = (TTree*)
f-> Get(
"calibconst");
487 TTree *xttree1_copy = xttree1->CloneTree();
488 TBufferFile rootBuffer1(TBufferFile::kWrite);
489 xttree1_copy->Streamer(rootBuffer1);
490
491 TTree *xttree2 = (TTree*)
f-> Get(
"calibconst");
492 Int_t bunchtime;
493 Double_t t0offset;
494 xttree2->SetBranchAddress("bunchtime",&bunchtime);
495 xttree2->SetBranchAddress("t0offset",&t0offset);
496 for(Int_t i = 0 ; i < (Int_t)xttree2->GetEntries() ; i++){
497 xttree2->GetEntry(i);
498 }
499
500
501 sprintf(query,
"UPDATE %s SET EsTimeH2='",opt_table_name);
502 p= query + strlen(query);
503 p += mysql_escape_string(p,rootBuffer.Buffer(),rootBuffer.BufferSize());
504 strcat(p,"',EsTimeH9='");
505 p= query + strlen(query);
506 p += mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
507 char c[64];
509 strcat(p,"', Bunchtime=");
510 strcat(p,c);
511 strcat(p,", T0offset=");
513 strcat(p,c);
514 strcat(p," WHERE SerNo = ");
515 strcat(p,opt_id);
516 } else if(strcmp(opt_type,"ESTTOF")==0){
517 sprintf(query_check,
"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
518
519 TTree *xttree = (TTree*)
f-> Get(
"BarTofPar");
520 TTree *xttree_copy = xttree->CloneTree();
521 TBufferFile rootBuffer(TBufferFile::kWrite);
522 xttree_copy->Streamer(rootBuffer);
523
524 TTree *xttree1 = (TTree*)
f-> Get(
"EndTofPar");
525 TTree *xttree1_copy = xttree1->CloneTree();
526 TBufferFile rootBuffer1(TBufferFile::kWrite);
527 xttree1_copy->Streamer(rootBuffer1);
528
529 TTree *xttree2 = (TTree*)
f-> Get(
"BarTofParCommon");
530 TTree *xttree2_copy = xttree2->CloneTree();
531 TBufferFile rootBuffer2(TBufferFile::kWrite);
532 xttree2_copy->Streamer(rootBuffer2);
533
534 TTree *xttree3 = (TTree*)
f-> Get(
"CalibInfo");
535 TTree *xttree3_copy = xttree3->CloneTree();
536 TBufferFile rootBuffer3(TBufferFile::kWrite);
537 xttree3_copy->Streamer(rootBuffer3);
538
539
540
541 TTree *xttree4 = (TTree*)
f-> Get(
"EtfTofPar");
542 TBufferFile rootBuffer4(TBufferFile::kWrite);
543 if (xttree4) {
544 TTree *xttree4_copy = xttree4->CloneTree();
545 xttree4_copy->Streamer(rootBuffer4);
546 }
547
548 TTree *xttree5 = (TTree*)
f-> Get(
"EtfTofBunch");
549 TBufferFile rootBuffer5(TBufferFile::kWrite);
550 if (xttree5) {
551 TTree *xttree5_copy = xttree5->CloneTree();
552 xttree5_copy->Streamer(rootBuffer5);
553 }
554
555
556
557
558 sprintf(query,
"UPDATE %s SET BarTofPar='",opt_table_name);
559 p= query + strlen(query);
560 p += mysql_escape_string(p,rootBuffer.Buffer(),rootBuffer.BufferSize());
561 strcat(p,"',EndTofPar='");
562 p= query + strlen(query);
563 p +=mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
564 strcat(p,"',TofConPar='");
565 p= query + strlen(query);
566 p +=mysql_escape_string(p,rootBuffer2.Buffer(),rootBuffer2.BufferSize());
567 strcat(p,"',BarTof='");
568 p= query + strlen(query);
569 p +=mysql_escape_string(p,rootBuffer3.Buffer(),rootBuffer3.BufferSize());
570 if (xttree4) {
571 strcat(p,"',EtfTofPar='");
572 p= query + strlen(query);
573 p +=mysql_escape_string(p,rootBuffer4.Buffer(),rootBuffer4.BufferSize());
574 }
575 if (xttree5) {
576 strcat(p,"',EtfTofBunch='");
577 p= query + strlen(query);
578 p +=mysql_escape_string(p,rootBuffer5.Buffer(),rootBuffer5.BufferSize());
579 }
580 strcat(p,"' WHERE SerNo = ");
581 strcat(p,opt_id);
582 } else if(strcmp(opt_type,"TOFQELEC")==0){
583 sprintf(query_check,
"select RunFrom,RunTo,CalParVer,SftVer from %s where TofQELecSerNo=%s",opt_table_name,opt_id);
584
585 TTree *xttree = (TTree*)
f-> Get(
"BarBoardNum");
586 TTree *xttree_copy = xttree->CloneTree();
587 TBufferFile rootBuffer(TBufferFile::kWrite);
588 xttree_copy->Streamer(rootBuffer);
589
590 TTree *xttree1 = (TTree*)
f-> Get(
"EndBoardNum");
591 TTree *xttree1_copy = xttree1->CloneTree();
592 TBufferFile rootBuffer1(TBufferFile::kWrite);
593 xttree1_copy->Streamer(rootBuffer1);
594
595 TTree *xttree2 = (TTree*)
f-> Get(
"QElecBarParEast");
596 TTree *xttree2_copy = xttree2->CloneTree();
597 TBufferFile rootBuffer2(TBufferFile::kWrite);
598 xttree2_copy->Streamer(rootBuffer2);
599
600 TTree *xttree3 = (TTree*)
f-> Get(
"QElecBarParWest");
601 TTree *xttree3_copy = xttree3->CloneTree();
602 TBufferFile rootBuffer3(TBufferFile::kWrite);
603 xttree3_copy->Streamer(rootBuffer3);
604
605 TTree *xttree4 = (TTree*)
f-> Get(
"QElecEndPar");
606 TTree *xttree4_copy = xttree4->CloneTree();
607 TBufferFile rootBuffer4(TBufferFile::kWrite);
608 xttree4_copy->Streamer(rootBuffer4);
609
610 TTree *xttree5 = (TTree*)
f-> Get(
"SimQElecBarParEast");
611 TTree *xttree5_copy = xttree5->CloneTree();
612 TBufferFile rootBuffer5(TBufferFile::kWrite);
613 xttree5_copy->Streamer(rootBuffer5);
614
615 TTree *xttree6 = (TTree*)
f-> Get(
"SimQElecBarParWest");
616 TTree *xttree6_copy = xttree6->CloneTree();
617 TBufferFile rootBuffer6(TBufferFile::kWrite);
618 xttree6_copy->Streamer(rootBuffer6);
619
620 TTree *xttree7 = (TTree*)
f-> Get(
"SimQElecEndPar");
621 TTree *xttree7_copy = xttree7->CloneTree();
622 TBufferFile rootBuffer7(TBufferFile::kWrite);
623 xttree7_copy->Streamer(rootBuffer7);
624
625 sprintf(query,
"UPDATE %s SET BarBoardNum='",opt_table_name);
626 p= query + strlen(query);
627 p += mysql_escape_string(p,rootBuffer.Buffer(),rootBuffer.BufferSize());
628 strcat(p,"',EndBoardNum='");
629 p= query + strlen(query);
630 p +=mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
631 strcat(p,"',QElecBarParEast='");
632 p= query + strlen(query);
633 p +=mysql_escape_string(p,rootBuffer2.Buffer(),rootBuffer2.BufferSize());
634 strcat(p,"',QElecBarParWest='");
635 p= query + strlen(query);
636 p +=mysql_escape_string(p,rootBuffer3.Buffer(),rootBuffer3.BufferSize());
637 strcat(p,"',QElecEndPar='");
638 p= query + strlen(query);
639 p +=mysql_escape_string(p,rootBuffer4.Buffer(),rootBuffer4.BufferSize());
640 strcat(p,"',SimQElecBarParEast='");
641 p= query + strlen(query);
642 p +=mysql_escape_string(p,rootBuffer5.Buffer(),rootBuffer5.BufferSize());
643 strcat(p,"',SimQElecBarParWest='");
644 p= query + strlen(query);
645 p +=mysql_escape_string(p,rootBuffer6.Buffer(),rootBuffer6.BufferSize());
646 strcat(p,"',SimQElecEndPar='");
647 p= query + strlen(query);
648 p +=mysql_escape_string(p,rootBuffer7.Buffer(),rootBuffer7.BufferSize());
649
650 strcat(p,"' WHERE TofQELecSerNo = ");
651 strcat(p,opt_id);
652 } else if(strcmp(opt_type,"DEDXCURVE")==0){
653 sprintf(query_check,
"select RunFrom,RunTo,DedxCurveParVer,SftVer from %s where DedxCurveParSerNo=%s",opt_table_name,opt_id);
654
655 TTree *xttree = (TTree*)
f-> Get(
"curve");
656 TTree *xttree_copy = xttree->CloneTree();
657 TBufferFile rootBuffer(TBufferFile::kWrite);
658 xttree_copy->Streamer(rootBuffer);
659
660 TTree *xttree1 = (TTree*)
f-> Get(
"sigma");
661 TTree *xttree1_copy = xttree1->CloneTree();
662 TBufferFile rootBuffer1(TBufferFile::kWrite);
663 xttree1_copy->Streamer(rootBuffer1);
664
665 sprintf(query,
"UPDATE %s SET DedxCurvePar='",opt_table_name);
666 p= query + strlen(query);
667 p += mysql_escape_string(p,rootBuffer.Buffer(),rootBuffer.BufferSize());
668 strcat(p,"',DedxSigmaPar='");
669 p= query + strlen(query);
670 p +=mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
671 strcat(p,"' WHERE DedxCurveParSerNo = ");
672 strcat(p,opt_id);
673
674 } else if(strcmp(opt_type,"TOFSIM")==0){
675 sprintf(query_check,
"select RunFrom,RunTo,TofSimParVer,SftVer from %s where TofSimSvcSerNo=%s",opt_table_name,opt_id);
676
677 TTree *xttree = (TTree*)
f-> Get(
"BTofSim");
678 TTree *xttree_copy = xttree->CloneTree();
679 TBufferFile rootBuffer(TBufferFile::kWrite);
680 xttree_copy->Streamer(rootBuffer);
681
682 TTree *xttree1 = (TTree*)
f-> Get(
"ETofSim");
683 TTree *xttree1_copy = xttree1->CloneTree();
684 TBufferFile rootBuffer1(TBufferFile::kWrite);
685 xttree1_copy->Streamer(rootBuffer1);
686
687 TTree *xttree2 = (TTree*)
f-> Get(
"SimConstants");
688 TTree *xttree2_copy = xttree2->CloneTree();
689 TBufferFile rootBuffer2(TBufferFile::kWrite);
690 xttree2_copy->Streamer(rootBuffer2);
691
692 sprintf(query,
"UPDATE %s SET BTofSim='",opt_table_name);
693 p= query + strlen(query);
694 p += mysql_escape_string(p,rootBuffer.Buffer(),rootBuffer.BufferSize());
695
696 strcat(p,"',ETofSim='");
697 p= query + strlen(query);
698 p +=mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
699
700 strcat(p,"',SimConstants='");
701 p= query + strlen(query);
702 p +=mysql_escape_string(p,rootBuffer2.Buffer(),rootBuffer2.BufferSize());
703
704 strcat(p,"' WHERE TofSimSvcSerNo = ");
705 strcat(p,opt_id);
706
707 } else if(strcmp(opt_type,"DEDXSIM")==0){
708 sprintf(query_check,
"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
709
710 TTree *xttree = (TTree*)
f-> Get(
"TH1F_Col");
711 gROOT->cd();
712 TTree *xttree_copy = xttree->CloneTree();
713 TBufferFile rootBuffer(TBufferFile::kWrite);
714
715 xttree_copy->Streamer(rootBuffer);
716 cout<<"rootBuffer.BufferSize()"<<rootBuffer.BufferSize()<<endl;
717
718 TTree *xttree1 = (TTree*)
f-> Get(
"bin");
719 TTree *xttree1_copy = xttree1->CloneTree();
720 TBufferFile rootBuffer1(TBufferFile::kWrite);
721 xttree1_copy->Streamer(rootBuffer1);
722
723 sprintf(query,
"UPDATE %s SET TH1F_Col='",opt_table_name);
724 p= query + strlen(query);
725 p += mysql_escape_string(p,rootBuffer.Buffer(),rootBuffer.BufferSize());
726 strcat(p,"',bin='");
727 p= query + strlen(query);
728 p +=mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
729 strcat(p,"' WHERE SerNo = ");
730 strcat(p,opt_id);
731 }
732 else if(strcmp(opt_type,"INJSIGINTERVAL")==0){
733 printf(query_check,"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
734
735 TTree *Interval = (TTree*)
f-> Get(
"interval");
736 TTree *Interval_copy = Interval->CloneTree();
737 TBufferFile Interval_buf(TBufferFile::kWrite);
738 Interval_copy->Streamer(Interval_buf);
739
740 sprintf(query,
"UPDATE %s SET interval='",opt_table_name);
741 p= query + strlen(query);
742 p += mysql_escape_string(p,Interval_buf.Buffer(),Interval_buf.BufferSize());
743 strcat(p,"' WHERE SerNo = ");
744 strcat(p,opt_id);
745 }
746 else if(strcmp(opt_type,"INJSIGTIME")==0){
747 printf(query_check,"select Runfrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
748
749 TTree *Ist = (TTree*)
f-> Get(
"ist");
750 TTree *Ist_copy = Ist->CloneTree();
751 TBufferFile Ist_buf(TBufferFile::kWrite);
752 Ist_copy->Streamer(Ist_buf);
753
754 sprintf(query,
"UPDATE %s SET ist='",opt_table_name);
755 p= query + strlen(query);
756 p += mysql_escape_string(p,Ist_buf.Buffer(),Ist_buf.BufferSize());
757 strcat(p,"' WHERE SerNo = ");
758 strcat(p,opt_id);
759 }
760 else if(strcmp(opt_type,"OFFEVTFILTER")==0){
761 printf(query_check,"select RunFrom,RunTo,CalParVer,SftVer from %s where SerNo=%s",opt_table_name,opt_id);
762
763 TTree *Data = (TTree*)
f-> Get(
"data");
764 TTree *Data_copy = Data->CloneTree();
765 TBufferFile Data_buf(TBufferFile::kWrite);
766 Data_copy->Streamer(Data_buf);
767
768 TTree *Oef = (TTree*)
f-> Get(
"oef");
769 TTree *Oef_copy = Oef->CloneTree();
770 TBufferFile Oef_buf(TBufferFile::kWrite);
771 Oef_copy->Streamer(Oef_buf);
772
773 sprintf(query,
"UPDATE %s SET data='",opt_table_name);
774 p= query + strlen(query);
775 p += mysql_escape_string(p,Data_buf.Buffer(),Data_buf.BufferSize());
776 strcat(p,"',oef='");
777 p= query + strlen(query);
778 p +=mysql_escape_string(p,Oef_buf.Buffer(),Oef_buf.BufferSize());
779 strcat(p,"' WHERE SerNo = ");
780 strcat(p,opt_id);
781 }
782
783 else {
784 printf("error, wrong type");
785 return 0;
786 }
787
788
790 conn = mysql_init(NULL);
791 mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password,
792 opt_db_name, opt_port_num, opt_socket_name, opt_flags);
793
794
795 status = mysql_query(conn,query_check);
796 MYSQL_RES* result = mysql_store_result(conn);
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825 status = mysql_query(conn,query);
826 printf("status=%d\n",status);
827 int kkkk=mysql_errno(conn);
828 printf("err=%d\n",kkkk);
829
831 return 0;
832}
struct st_mysql_res MYSQL_RES
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")