MCPcopy Create free account
hub / github.com/KDE/labplot / ROOTData

Method ROOTData

src/backend/datasources/filters/ROOTFilter.cpp:635–868  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633using namespace ROOTDataHelpers;
634
635ROOTData::ROOTData(const std::string& filename)
636 : filename(filename) {
637 DEBUG(Q_FUNC_INFO << ", filename = " << filename)
638 // The file structure is described in root/io/io/src/TFile.cxx
639 std::ifstream is(filename, std::ifstream::binary);
640 std::string root(4, 0);
641 is.read(const_cast<char*>(root.data()), 4);
642 if (root != "root")
643 return;
644
645 int fileVersion = read<int>(is);
646 long int pos = read<int>(is);
647 histdirs.emplace(pos, Directory{});
648 treedirs.emplace(pos, Directory{});
649 long int endpos = fileVersion < 1000000 ? read<int>(is) : read<long int>(is);
650
651 is.seekg(33);
652 int compression = read<int>(is);
653 compression = compression > 0 ? compression : 0;
654
655 while (is.good() && pos < endpos) {
656 is.seekg(pos);
657 int lcdata = read<int>(is);
658 if (lcdata == 0) {
659 break;
660 }
661 if (lcdata < 0) {
662 pos -= lcdata;
663 continue;
664 }
665 short version = read<short>(is);
666 size_t ldata = read<unsigned int>(is);
667 is.seekg(4, is.cur); // skip the date
668 size_t lkey = read<unsigned short int>(is);
669 short cycle = read<short>(is);
670 long int pseek;
671 if (version > 1000) {
672 is.seekg(8, is.cur);
673 pseek = read<long int>(is);
674 } else {
675 is.seekg(4, is.cur);
676 pseek = read<int>(is);
677 }
678 std::string cname(read<unsigned char>(is), 0);
679 is.read(&cname[0], cname.size());
680 std::string name(read<unsigned char>(is), 0);
681 is.read(&name[0], name.size());
682 std::string title(read<unsigned char>(is), 0);
683 is.read(&title[0], title.size());
684
685 auto type = ContentType::Invalid;
686 if (cname.size() == 4 && cname.substr(0, 3) == "TH1") {
687 type = histType(cname[3]);
688 } else if (cname == "TTree")
689 type = ContentType::Tree;
690 else if (cname.substr(0, 7) == "TNtuple")
691 type = ContentType::NTuple;
692 else if (cname == "TBasket")

Callers

nothing calls this directly

Calls 10

eraseMethod · 0.80
readMethod · 0.45
dataMethod · 0.45
seekgMethod · 0.45
goodMethod · 0.45
sizeMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
emptyMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected