Changeset 18838
- Timestamp:
- 04/18/17 20:41:25 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/fitsdump.cc
r18837 r18838 406 406 407 407 408 #ifdef HAVE_ROOT 409 template<typename T> 410 void SetBranch(TTree *ttree, const string &bname, const MyColumn &col) 411 { 412 TBranch *b = ttree->GetBranch(bname.c_str()); 413 414 T *address = reinterpret_cast<T*>(col.ptr)+col.first; 415 if (b) 416 b->SetAddress(address); 417 else 418 ttree->Branch(bname.c_str(), address); 419 } 420 #endif 421 408 422 // -------------------------------------------------------------------------- 409 423 // … … 455 469 456 470 // FIXME: Add header values 457 TTree *ttree = tfile ? new TTree(fKeyMap.find("EXTNAME")->second.value.c_str(), Tools::Form("From N=%d [cnt=%d] {filter=%s}", first, limit, filter.c_str()).c_str()) : 0; 471 TTree *ttree = 0; 472 if (tfile) 473 { 474 const string tname = fKeyMap.find("EXTNAME")->second.value; 475 tfile->GetObject(tname.c_str(), ttree); 476 if (!ttree) 477 ttree = new TTree(tname.c_str(), Tools::Form("From N=%d [cnt=%d] {filter=%s}", first, limit, filter.c_str()).c_str()); 478 } 458 479 #endif 459 480 … … 501 522 { 502 523 case 'B': 503 ttree->Branch(branch.c_str(), reinterpret_cast<unsigned char*>(it->ptr)+it->first);524 SetBranch<unsigned char>(ttree, branch, *it); 504 525 break; 505 526 case 'L': 506 ttree->Branch(branch.c_str(), reinterpret_cast<bool*>(it->ptr)+it->first);527 SetBranch<bool>(ttree, branch, *it); 507 528 break; 508 529 case 'I': 509 ttree->Branch(branch.c_str(), reinterpret_cast<int16_t*>(it->ptr)+it->first);530 SetBranch<int16_t>(ttree, branch, *it); 510 531 break; 511 532 case 'J': 512 ttree->Branch(branch.c_str(), reinterpret_cast<int32_t*>(it->ptr)+it->first);533 SetBranch<int32_t>(ttree, branch, *it); 513 534 break; 514 535 case 'K': 515 ttree->Branch(branch.c_str(), reinterpret_cast<int64_t*>(it->ptr)+it->first);536 SetBranch<int64_t>(ttree, branch, *it); 516 537 break; 517 538 case 'E': 518 ttree->Branch(branch.c_str(), reinterpret_cast<float*>(it->ptr)+it->first);539 SetBranch<float>(ttree, branch, *it); 519 540 break; 520 541 case 'D': 521 ttree->Branch(branch.c_str(), reinterpret_cast<double*>(it->ptr)+it->first);542 SetBranch<double>(ttree, branch, *it); 522 543 break; 523 544 default: … … 630 651 fout << endl; 631 652 632 ttree->Write( );653 ttree->Write("", TObject::kWriteDelete); 633 654 delete tfile; 634 655 } … … 1273 1294 ("filter,f", var<string>(""), "Filter to restrict the selection of events (e.g. '[0]>10 && [0]<20'; does not work with stat and minmax yet)") 1274 1295 ("overwrite", po_switch(), "Force overwriting an existing root file ('RECREATE')") 1275 ("update", po_switch(), "Update an existing root file with the new tree ('UPDATE')")1296 ("update", po_switch(), "Update an existing root file ('UPDATE') or an existing tree with more data.") 1276 1297 ("compression", var<uint16_t>(1), "zlib compression level for the root file") 1277 1298 #endif
Note:
See TracChangeset
for help on using the changeset viewer.