Ignore:
Timestamp:
10/01/04 19:02:30 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mfileio
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mfileio/MRead.cc

    r4601 r5160  
    2424
    2525/////////////////////////////////////////////////////////////////////////////
    26 //                                                                         //
    27 // MRead                                                                   //
    28 //                                                                         //
    29 // Base class for all reading tasks                                        //
    30 //                                                                         //
    31 // You can set a selector. Depending on the impelementation in the derived //
    32 // class it can be used to skip events, if the filter return kFALSE.       //
    33 // Make sure that the selector (filter) doesn't need information which     //
    34 // doesn't exist before reading an event!                                  //
    35 //                                                                         //
     26//
     27// MRead
     28//
     29// Base class for all reading tasks
     30//
     31// You can set a selector. Depending on the impelementation in the derived
     32// class it can be used to skip events, if the filter return kFALSE.
     33// Make sure that the selector (filter) doesn't need information which
     34// doesn't exist before reading an event!
     35//
    3636/////////////////////////////////////////////////////////////////////////////
    3737#include "MRead.h"
     38
     39#include <TSystem.h>
    3840
    3941#include "MLog.h"
     
    119121    return i!=0;
    120122}
     123
     124// --------------------------------------------------------------------------
     125//
     126// Check if the file exists and has read permission. Derived classes
     127// should also check whether its file type is correct.
     128//
     129// Returning 0 means: file doesn't exist.
     130// A returned number corresponds to different file types (1 if only
     131// one exists)
     132//
     133Byte_t MRead::IsFileValid(const char *name)
     134{
     135    return !gSystem->AccessPathName(name, kFileExists) ? 1 : 0;
     136}
  • trunk/MagicSoft/Mars/mfileio/MRead.h

    r4694 r5160  
    2121    virtual Bool_t  Rewind();
    2222
     23    static Byte_t IsFileValid(const char *name);
     24
    2325    void SetSelector(MFilter *f) { fSelector = f; }
    2426    MFilter *GetSelector() { return fSelector; }
  • trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc

    r4694 r5160  
    1818!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2003
     20!   Copyright: MAGIC Software Development, 2000-2004
    2121!
    2222!
     
    2424
    2525/////////////////////////////////////////////////////////////////////////////
    26 //                                                                         //
    27 // MReadMarsFile                                                           //
    28 //                                                                         //
    29 // This task works more or less like MReadTree, but in addition PreProcess //
    30 // reads all the information from the 'RunHeader' tree.                    //
    31 //                                                                         //
    32 // Warning: Until now this works only for 'one run header per file'        //
    33 //                                                                         //
     26//
     27// MReadMarsFile
     28//
     29// This task works more or less like MReadTree, but in addition PreProcess
     30// reads all the information from the 'RunHeader' tree.
     31//
     32// Warning: Until now this works only for 'one run header per file'
     33//
    3434/////////////////////////////////////////////////////////////////////////////
    3535#include "MReadMarsFile.h"
     36
     37#include <fstream>
     38
     39#include <TFile.h>
     40#include <TTree.h>
    3641
    3742#include "MLog.h"
     
    9297{
    9398    delete fRun;
     99}
     100
     101Byte_t MReadMarsFile::IsFileValid(const char *name)
     102{
     103    ifstream fin(name);
     104    if (!fin)
     105        return 0;
     106
     107    Char_t c[4];
     108    fin.read(c, 4);
     109    if (!fin)
     110        return 0;
     111
     112    if (!(c[0]=='r'&& c[1]=='o' && c[2]=='o' && c[3]=='t'))
     113        return 0;
     114
     115    TFile f(name, "READ");
     116
     117    TTree *t = (TTree*)f.Get("Events");
     118    if (!t)
     119        return 0;
     120
     121    // FIXME: Replace numbers by enum! Maybe use bits?
     122    if (t->FindBranch("MRawEvtData."))
     123        return t->FindBranch("MMcEvt.") ? 2 : 1;
     124
     125    if (t->FindBranch("MCerPhotEvt."))
     126        return t->FindBranch("MMcEvt.") ? 4 : 3;
     127
     128    return 0;
    94129}
    95130
  • trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h

    r3682 r5160  
    2424    ~MReadMarsFile();
    2525
     26    static Byte_t IsFileValid(const char *name);
     27
    2628    void SortFiles();
    2729
  • trunk/MagicSoft/Mars/mfileio/MReadTree.cc

    r5100 r5160  
    157157}
    158158
     159Byte_t MReadTree::IsFileValid(const char *name)
     160{
     161    ifstream fin(name);
     162    if (!fin)
     163        return 0;
     164
     165    Char_t c[4];
     166    fin.read(c, 4);
     167    if (!fin)
     168        return 0;
     169
     170    return c[0]=='r'&& c[1]=='o' && c[2]=='o' && c[3]=='t' ? 1 : 0;
     171}
     172
    159173// --------------------------------------------------------------------------
    160174//
  • trunk/MagicSoft/Mars/mfileio/MReadTree.h

    r4895 r5160  
    5151    ~MReadTree();
    5252
     53    static Byte_t IsFileValid(const char *name);
     54
    5355    virtual void SortFiles();
    5456
Note: See TracChangeset for help on using the changeset viewer.