Changeset 13626 for fact


Ignore:
Timestamp:
05/09/12 17:48:09 (13 years ago)
Author:
Jens Buss
Message:
bugfixes Seg faults solved in Save Histogram
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/rootmacros/PulseTemplates/rootfilehandler.C

    r13617 r13626  
    88void
    99CreateRootFile(
    10         const char*     loc_fname,
     10        TString         loc_fname,
    1111        int             verbosityLevel
    1212        )
    1313{
    14     TFile* tf = new TFile(loc_fname,"UPDATE");
    15     if (tf->IsZombie())
     14    TFile output_rootfile(loc_fname,"UPDATE");
     15
     16    if (output_rootfile.IsZombie())
    1617    {
    1718        cout << "Error opening file" << endl;
     
    1920    }
    2021    else {
    21         if (verbosityLevel > 1) cout << "creating root-file successfull" << endl;
    22         tf->Close();
     22        if (verbosityLevel > 1) cout << "creating root-file...successfull" << endl;
     23        output_rootfile.pwd();
     24        output_rootfile.Close();
    2325    }
    2426}
     
    2729
    2830
    29 void
     31TFile*
    3032OpenRootFile(
    31         TFile*          output_rootfile,
    32         const char *    loc_fname,
     33        TString    loc_fname,
    3334        int             verbosityLevel
    3435        )
    3536{
    36     output_rootfile = new TFile(loc_fname,"UPDATE");
     37    TFile* output_rootfile = new TFile(loc_fname,"UPDATE");
    3738    if (output_rootfile->IsZombie())
    3839    {
     
    4950        }
    5051    }
    51     return;
     52    return output_rootfile;
    5253}
    5354//end of OpenRootFile
     
    5758void
    5859CloseRootFile(
    59         TFile* output_rootfile
     60        TFile*          output_rootfile
    6061        )
    6162{
     
    6667    } else {
    6768    output_rootfile->Close();
     69    }
    6870    delete output_rootfile;
    69     }
    7071}
    7172//end of CloseRootFile
     
    7576void
    7677SaveHistograms(
    77         const char*     loc_fname,
     78        TString         loc_fname,
    7879        TString         subdirectory,
    7980        TObjArray*      histList,
     
    8889
    8990    TFile* output_rootfile = NULL;
    90     OpenRootFile(output_rootfile, loc_fname, verbosityLevel);
    91     if ( !( subdirectory.CompareTo("root") ) ) //if subdirectory = root
    92     {
    93         output_rootfile->cd();
    94     }
    95     else
    96     {
    97         output_rootfile->cd();
    98         output_rootfile->mkdir(subdirectory,subdirectory);
    99         output_rootfile->cd(subdirectory);
    100     }
    101     histList->Write(); // write the major histograms into the top level directory
    102     if (verbosityLevel > 3) tf->ls();
     91    output_rootfile = OpenRootFile( loc_fname, verbosityLevel);
     92
     93    if (verbosityLevel > 2) cout << endl
     94                                 << "...writing histogram list to root file "
     95                                 << endl ;
     96    gFile->WriteTObject(histList, subdirectory); // write the histograms into one Key in the top level directory
     97
     98
     99    if (verbosityLevel > 3) output_rootfile->ls();
    103100    CloseRootFile( output_rootfile ); // close the file
    104101    if (verbosityLevel > 2) cout << "...done" << endl;
     
    124121TString
    125122CreateSubDirName(
    126         const char* title
     123        TString title
    127124        )
    128125{
    129     TString path = title;
    130     path += "_Pixel";
     126    title += "_Pixel";
    131127//    cout << "path " << path << endl ;
    132     return path;
     128    return title;
    133129}
    134130// end of CreateSubDirName
Note: See TracChangeset for help on using the changeset viewer.