Skip to content
Snippets Groups Projects

Check and confirm the default compression settings in ROOT 6

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Yuriy Volkotrub

    ROOT script to verify the default compression settings for a newly created file. This script will create a file without specifying any compression settings, then print the compression level and algorithm used by default.

    For root-config --version 6.32.06 (setupATLAS -c el9) provides: Default Compression Level: 1; Default Compression Algorithm: Zlib

    Edited
    check_default_compression.C 812 B
    // ROOT macro to check default compression settings
    void check_default_compression() {
        TFile *file = new TFile("test_default_compression.root", "RECREATE");
    
        int compressionLevel = file->GetCompressionLevel();
        int compressionAlgorithm = file->GetCompressionAlgorithm();
    
        std::cout << "Default Compression Level: " << compressionLevel << std::endl;
        std::cout << "Default Compression Algorithm: ";
        if (compressionAlgorithm == 1) {
            std::cout << "Zlib" << std::endl;
        } else if (compressionAlgorithm == 2) {
            std::cout << "LZMA" << std::endl;
        } else if (compressionAlgorithm == 4) {
            std::cout << "LZ4" << std::endl;
        } else {
            std::cout << "Unknown" << std::endl;
        }
    
        file->Close();
        delete file;
    }
    
    
    // root -l -q check_default_compression.C
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment