CDM tool to check root files

//
// Program requires BOOST library to compile and link
//
// Author: Anar Manafov;
// email: A.Manafov@gsi.de
//

// ROOT block
#include "TFile.h"

// BOOST
#include "boost/filesystem/operations.hpp"

// STD block
#include <string>
#include <vector>
#include <iostream>
#include <fstream>

const char * const g_pszStep3cLinksDir = "/d/ceres04/step3c_links/";

using namespace std;
using namespace boost::filesystem;

typedef vector<string> string_vector_t;

// Global counter
size_t g_nAllScanedFiles(0);


// Validating ROOT File
bool IsBrokenRootFile( const string &_strFileName )
{
        TFile root_tree(_strFileName.c_str(), "READ");
        if ( root_tree.IsZombie() )
        {
                cerr << "Error opening file:\n>>>>>>>>>>>>>>>>> " << _strFileName  << "<<<<<<<<<<<<<<<<<<<" << endl;
                return true;
        }
        return false;
}

// Enumerating files in the given directory and storing result in the _Container
bool EnumFiles( const path & _dir_path, string_vector_t *_Container )
{
        if ( !exists( _dir_path ) ) 
        return false;
        
        cout << "Enumirating: " << _dir_path.string() << endl;
        directory_iterator end_itr; // default construction yields past-the-end
        for ( directory_iterator itr( _dir_path ); 
        itr != end_itr; 
        ++itr )
        {
                if ( is_directory( *itr ) )
                {
                        if ( EnumFiles( *itr, _Container ) ) 
                        return true;
                }
                else {
                        ++g_nAllScanedFiles;
                        string file_name(itr->string());
                        if( IsBrokenRootFile( file_name ) )
                        {
                                _Container->push_back( file_name );     
                        }
                } 
        }
        return false;
}

int main()
{
        string_vector_t file_list;
        path rootlinkspath( g_pszStep3cLinksDir );
        
        g_nAllScanedFiles = 0;
        
        EnumFiles( rootlinkspath, &file_list );
        
        string_vector_t::iterator iter_end = file_list.end();
        string_vector_t::iterator iter = file_list.begin();
        ofstream f("broken_root_files.list");
        while( iter != iter_end )
        {
                f << *iter << endl;
                ++iter;
        }
        f.close();
        
        cout << "Scanned: " << g_nAllScanedFiles << " files;" << endl;
        cout << "Appeared to be broken: " << file_list.size() << " files;" << endl;
        
        return 0;
}

Broken Files

Scanned files: 86966
Broken files: 11:
/d/ceres04/step3c_links/prod013N/unit225/run1436-burst0144.root
/d/ceres04/step3c_links/prod013N/unit225/run1436-burst0148.root
/d/ceres04/step3c_links/prod012/unit134/run1359-burst0254.root
/d/ceres04/step3c_links/prod012/unit355/run1518-burst0708.root
/d/ceres04/step3c_links/prod012/unit268/run1454-burst0200.root
/d/ceres04/step3c_links/prod012/unit127/run1348-burst0201.root
/d/ceres04/step3c_links/prod012/unit127/run1348-burst0203.root
/d/ceres04/step3c_links/prod012/unit127/run1348-burst0205.root
/d/ceres04/step3c_links/prod012/unit127/run1348-burst0224.root
/d/ceres04/step3c_links/prod012/unit127/run1348-burst0233.root
/d/ceres04/step3c_links/prod012/unit127/run1348-burst0235.root

Broken files reported by Oliver Busch.
corrupted trees:
/d/ceres06/step3c/prod012_13/unit190/run1400-burst1036.root
/d/ceres06/step3c/prod012_13/unit337/run1514-burst2092.root
/d/ceres04/step3c_links/prod012/unit342/run1515-burst0885.root (broken tree)
/d/ceres04/step3c_links/prod012/unit337/run1514-burst2092.root (broken tree)
/d/ceres05/step4c/step4c_links/prod013N/unit225/run1436-burst0077.root (no keys)

-- AnarManafov - 02 Apr 2006
Topic revision: r3 - 2006-04-02, AnarManafov
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding GSI Wiki? Send feedback
Imprint (in German)
Privacy Policy (in German)