7#include <mysql/mysql.h>
14#include "TBufferFile.h"
16#define CALCONSTSQLHELPER
20int main(
int argc,
char** argv) {
23 printf(
"error, wrong argument number!\n");
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;
38 static char query[80240000];
40 char query_check[1024];
44 if(
f->IsZombie())
return 0;
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);
137 bool foundNewXtTree =
false;
138 TObjArray newxttrees;
139 TBufferFile newxttree_buf(TBufferFile::kWrite);
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);
154 if(nNewXtTree==maxNewXtTreeNum) {
155 foundNewXtTree =
true;
156 newxttrees.Streamer(newxttree_buf);
161 TBufferFile r2ttree_buf(TBufferFile::kWrite);
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);
172 if(nR2tTree!=maxR2tTreeNum){
173 printf(
"r2t tree error\n");
175 r2ttrees.Streamer(r2ttree_buf);
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);
191 if(!foundOldXtTree && !foundNewXtTree) {
192 printf(
"no Xt Tree\n");
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);
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);
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);
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());
225 strcat(p,
"',XtTree='");
226 p= query + strlen(query);
227 p +=mysql_escape_string(p,xttree_buf.Buffer(),xttree_buf.BufferSize());
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());
236 strcat(p,
"',T0Tree='");
237 p= query + strlen(query);
238 p +=mysql_escape_string(p,t0tree_buf.Buffer(),t0tree_buf.BufferSize());
240 strcat(p,
"',SdTree='");
241 p= query + strlen(query);
242 p +=mysql_escape_string(p,sdtree_buf.Buffer(),sdtree_buf.BufferSize());
244 strcat(p,
"',R2tTrees='");
245 p= query + strlen(query);
246 p +=mysql_escape_string(p,r2ttree_buf.Buffer(),r2ttree_buf.BufferSize());
248 strcat(p,
"' WHERE SerNo = ");
249 p= query + strlen(query);
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);
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);
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 = ");
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);
276 TTree *xttree = (TTree*)
f-> Get(
"BarTofPar");
277 TTree *xttree_copy = xttree->CloneTree();
278 TBufferFile rootBuffer(TBufferFile::kWrite);
279 xttree_copy->Streamer(rootBuffer);
281 TTree *xttree1 = (TTree*)
f-> Get(
"EndTofPar");
282 TTree *xttree1_copy = xttree1->CloneTree();
283 TBufferFile rootBuffer1(TBufferFile::kWrite);
284 xttree1_copy->Streamer(rootBuffer1);
286 TTree *xttree2 = (TTree*)
f-> Get(
"BarTofParCommon");
287 TTree *xttree2_copy = xttree2->CloneTree();
288 TBufferFile rootBuffer2(TBufferFile::kWrite);
289 xttree2_copy->Streamer(rootBuffer2);
291 TTree *xttree3 = (TTree*)
f-> Get(
"CalibInfo");
292 TTree *xttree3_copy = xttree3->CloneTree();
293 TBufferFile rootBuffer3(TBufferFile::kWrite);
294 xttree3_copy->Streamer(rootBuffer3);
298 TTree *xttree4 = (TTree*)
f-> Get(
"EtfTofPar");
299 TBufferFile rootBuffer4(TBufferFile::kWrite);
301 TTree *xttree4_copy = xttree4->CloneTree();
302 xttree4_copy->Streamer(rootBuffer4);
305 TTree *xttree5 = (TTree*)
f-> Get(
"EtfTofBunch");
306 TBufferFile rootBuffer5(TBufferFile::kWrite);
308 TTree *xttree5_copy = xttree5->CloneTree();
309 xttree5_copy->Streamer(rootBuffer5);
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);
325 p +=mysql_escape_string(p,rootBuffer3.Buffer(),rootBuffer3.BufferSize());
327 strcat(p,
"',EtfTofPar='");
328 p= query + strlen(query);
329 p +=mysql_escape_string(p,rootBuffer4.Buffer(),rootBuffer4.BufferSize());
332 strcat(p,
"',EtfTofBunch='");
333 p= query + strlen(query);
334 p +=mysql_escape_string(p,rootBuffer5.Buffer(),rootBuffer5.BufferSize());
337 strcat(p,
"' WHERE SerNo = ");
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);
343 TTree *xttree = (TTree*)
f-> Get(
"LayConst");
344 TTree *xttree_copy = xttree->CloneTree();
345 TBufferFile rootBuffer(TBufferFile::kWrite);
346 xttree_copy->Streamer(rootBuffer);
348 TTree *xttree1 = (TTree*)
f-> Get(
"BoxConst");
349 TTree *xttree1_copy = xttree1->CloneTree();
350 TBufferFile rootBuffer1(TBufferFile::kWrite);
351 xttree1_copy->Streamer(rootBuffer1);
353 TTree *xttree2 = (TTree*)
f-> Get(
"StrConst");
354 TTree *xttree2_copy =xttree2->CloneTree();
355 TBufferFile rootBuffer2(TBufferFile::kWrite);
356 xttree2_copy->Streamer(rootBuffer2);
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 = ");
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);
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);
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);
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);
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);
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);
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);
408 TTree *wiregcalib = (TTree*)
f-> Get(
"wiregcalib");
409 TTree *wiregcalib_copy = wiregcalib->CloneTree();
415 TBufferFile wiregcalib_buf(TBufferFile::kWrite);
416 wiregcalib_copy->Streamer(wiregcalib_buf);
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);
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);
435 sprintf(query,
"UPDATE %s SET WireGain='",opt_table_name);
437 p= query + strlen(query);
439 p += mysql_escape_string(p,wiregcalib_buf.Buffer(),wiregcalib_buf.BufferSize());
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);
462 p += mysql_escape_string(p,runcalib_buf.Buffer(),runcalib_buf.Length());
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 = ");
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);
481 TTree *xttree = (TTree*)
f-> Get(
"h2");
482 TTree *xttree_copy = xttree->CloneTree();
483 TBufferFile rootBuffer(TBufferFile::kWrite);
484 xttree_copy->Streamer(rootBuffer);
486 TTree *xttree1 = (TTree*)
f-> Get(
"calibconst");
487 TTree *xttree1_copy = xttree1->CloneTree();
488 TBufferFile rootBuffer1(TBufferFile::kWrite);
489 xttree1_copy->Streamer(rootBuffer1);
491 TTree *xttree2 = (TTree*)
f-> Get(
"calibconst");
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);
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());
509 strcat(p,
"', Bunchtime=");
511 strcat(p,
", T0offset=");
514 strcat(p,
" WHERE SerNo = ");
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);
519 TTree *xttree = (TTree*)
f-> Get(
"BarTofPar");
520 TTree *xttree_copy = xttree->CloneTree();
521 TBufferFile rootBuffer(TBufferFile::kWrite);
522 xttree_copy->Streamer(rootBuffer);
524 TTree *xttree1 = (TTree*)
f-> Get(
"EndTofPar");
525 TTree *xttree1_copy = xttree1->CloneTree();
526 TBufferFile rootBuffer1(TBufferFile::kWrite);
527 xttree1_copy->Streamer(rootBuffer1);
529 TTree *xttree2 = (TTree*)
f-> Get(
"BarTofParCommon");
530 TTree *xttree2_copy = xttree2->CloneTree();
531 TBufferFile rootBuffer2(TBufferFile::kWrite);
532 xttree2_copy->Streamer(rootBuffer2);
534 TTree *xttree3 = (TTree*)
f-> Get(
"CalibInfo");
535 TTree *xttree3_copy = xttree3->CloneTree();
536 TBufferFile rootBuffer3(TBufferFile::kWrite);
537 xttree3_copy->Streamer(rootBuffer3);
541 TTree *xttree4 = (TTree*)
f-> Get(
"EtfTofPar");
542 TBufferFile rootBuffer4(TBufferFile::kWrite);
544 TTree *xttree4_copy = xttree4->CloneTree();
545 xttree4_copy->Streamer(rootBuffer4);
548 TTree *xttree5 = (TTree*)
f-> Get(
"EtfTofBunch");
549 TBufferFile rootBuffer5(TBufferFile::kWrite);
551 TTree *xttree5_copy = xttree5->CloneTree();
552 xttree5_copy->Streamer(rootBuffer5);
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());
571 strcat(p,
"',EtfTofPar='");
572 p= query + strlen(query);
573 p +=mysql_escape_string(p,rootBuffer4.Buffer(),rootBuffer4.BufferSize());
576 strcat(p,
"',EtfTofBunch='");
577 p= query + strlen(query);
578 p +=mysql_escape_string(p,rootBuffer5.Buffer(),rootBuffer5.BufferSize());
580 strcat(p,
"' WHERE SerNo = ");
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);
585 TTree *xttree = (TTree*)
f-> Get(
"BarBoardNum");
586 TTree *xttree_copy = xttree->CloneTree();
587 TBufferFile rootBuffer(TBufferFile::kWrite);
588 xttree_copy->Streamer(rootBuffer);
590 TTree *xttree1 = (TTree*)
f-> Get(
"EndBoardNum");
591 TTree *xttree1_copy = xttree1->CloneTree();
592 TBufferFile rootBuffer1(TBufferFile::kWrite);
593 xttree1_copy->Streamer(rootBuffer1);
595 TTree *xttree2 = (TTree*)
f-> Get(
"QElecBarParEast");
596 TTree *xttree2_copy = xttree2->CloneTree();
597 TBufferFile rootBuffer2(TBufferFile::kWrite);
598 xttree2_copy->Streamer(rootBuffer2);
600 TTree *xttree3 = (TTree*)
f-> Get(
"QElecBarParWest");
601 TTree *xttree3_copy = xttree3->CloneTree();
602 TBufferFile rootBuffer3(TBufferFile::kWrite);
603 xttree3_copy->Streamer(rootBuffer3);
605 TTree *xttree4 = (TTree*)
f-> Get(
"QElecEndPar");
606 TTree *xttree4_copy = xttree4->CloneTree();
607 TBufferFile rootBuffer4(TBufferFile::kWrite);
608 xttree4_copy->Streamer(rootBuffer4);
610 TTree *xttree5 = (TTree*)
f-> Get(
"SimQElecBarParEast");
611 TTree *xttree5_copy = xttree5->CloneTree();
612 TBufferFile rootBuffer5(TBufferFile::kWrite);
613 xttree5_copy->Streamer(rootBuffer5);
615 TTree *xttree6 = (TTree*)
f-> Get(
"SimQElecBarParWest");
616 TTree *xttree6_copy = xttree6->CloneTree();
617 TBufferFile rootBuffer6(TBufferFile::kWrite);
618 xttree6_copy->Streamer(rootBuffer6);
620 TTree *xttree7 = (TTree*)
f-> Get(
"SimQElecEndPar");
621 TTree *xttree7_copy = xttree7->CloneTree();
622 TBufferFile rootBuffer7(TBufferFile::kWrite);
623 xttree7_copy->Streamer(rootBuffer7);
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());
650 strcat(p,
"' WHERE TofQELecSerNo = ");
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);
655 TTree *xttree = (TTree*)
f-> Get(
"curve");
656 TTree *xttree_copy = xttree->CloneTree();
657 TBufferFile rootBuffer(TBufferFile::kWrite);
658 xttree_copy->Streamer(rootBuffer);
660 TTree *xttree1 = (TTree*)
f-> Get(
"sigma");
661 TTree *xttree1_copy = xttree1->CloneTree();
662 TBufferFile rootBuffer1(TBufferFile::kWrite);
663 xttree1_copy->Streamer(rootBuffer1);
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 = ");
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);
677 TTree *xttree = (TTree*)
f-> Get(
"BTofSim");
678 TTree *xttree_copy = xttree->CloneTree();
679 TBufferFile rootBuffer(TBufferFile::kWrite);
680 xttree_copy->Streamer(rootBuffer);
682 TTree *xttree1 = (TTree*)
f-> Get(
"ETofSim");
683 TTree *xttree1_copy = xttree1->CloneTree();
684 TBufferFile rootBuffer1(TBufferFile::kWrite);
685 xttree1_copy->Streamer(rootBuffer1);
687 TTree *xttree2 = (TTree*)
f-> Get(
"SimConstants");
688 TTree *xttree2_copy = xttree2->CloneTree();
689 TBufferFile rootBuffer2(TBufferFile::kWrite);
690 xttree2_copy->Streamer(rootBuffer2);
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());
696 strcat(p,
"',ETofSim='");
697 p= query + strlen(query);
698 p +=mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
700 strcat(p,
"',SimConstants='");
701 p= query + strlen(query);
702 p +=mysql_escape_string(p,rootBuffer2.Buffer(),rootBuffer2.BufferSize());
704 strcat(p,
"' WHERE TofSimSvcSerNo = ");
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);
710 TTree *xttree = (TTree*)
f-> Get(
"TH1F_Col");
712 TTree *xttree_copy = xttree->CloneTree();
713 TBufferFile rootBuffer(TBufferFile::kWrite);
715 xttree_copy->Streamer(rootBuffer);
716 cout<<
"rootBuffer.BufferSize()"<<rootBuffer.BufferSize()<<endl;
718 TTree *xttree1 = (TTree*)
f-> Get(
"bin");
719 TTree *xttree1_copy = xttree1->CloneTree();
720 TBufferFile rootBuffer1(TBufferFile::kWrite);
721 xttree1_copy->Streamer(rootBuffer1);
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());
727 p= query + strlen(query);
728 p +=mysql_escape_string(p,rootBuffer1.Buffer(),rootBuffer1.BufferSize());
729 strcat(p,
"' WHERE SerNo = ");
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);
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);
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 = ");
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);
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);
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 = ");
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);
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);
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);
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());
777 p= query + strlen(query);
778 p +=mysql_escape_string(p,Oef_buf.Buffer(),Oef_buf.BufferSize());
779 strcat(p,
"' WHERE SerNo = ");
784 printf(
"error, wrong type");
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);
795 status = mysql_query(conn,query_check);
796 MYSQL_RES* result = mysql_store_result(conn);
825 status = mysql_query(conn,query);
826 printf(
"status=%d\n",status);
827 int kkkk=mysql_errno(conn);
828 printf(
"err=%d\n",kkkk);
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")