Changeset 5160 for trunk/MagicSoft/Mars/mfileio
- Timestamp:
- 10/01/04 19:02:30 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mfileio
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfileio/MRead.cc
r4601 r5160 24 24 25 25 ///////////////////////////////////////////////////////////////////////////// 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 // 36 36 ///////////////////////////////////////////////////////////////////////////// 37 37 #include "MRead.h" 38 39 #include <TSystem.h> 38 40 39 41 #include "MLog.h" … … 119 121 return i!=0; 120 122 } 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 // 133 Byte_t MRead::IsFileValid(const char *name) 134 { 135 return !gSystem->AccessPathName(name, kFileExists) ? 1 : 0; 136 } -
trunk/MagicSoft/Mars/mfileio/MRead.h
r4694 r5160 21 21 virtual Bool_t Rewind(); 22 22 23 static Byte_t IsFileValid(const char *name); 24 23 25 void SetSelector(MFilter *f) { fSelector = f; } 24 26 MFilter *GetSelector() { return fSelector; } -
trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc
r4694 r5160 18 18 ! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 320 ! Copyright: MAGIC Software Development, 2000-2004 21 21 ! 22 22 ! … … 24 24 25 25 ///////////////////////////////////////////////////////////////////////////// 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 // 34 34 ///////////////////////////////////////////////////////////////////////////// 35 35 #include "MReadMarsFile.h" 36 37 #include <fstream> 38 39 #include <TFile.h> 40 #include <TTree.h> 36 41 37 42 #include "MLog.h" … … 92 97 { 93 98 delete fRun; 99 } 100 101 Byte_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; 94 129 } 95 130 -
trunk/MagicSoft/Mars/mfileio/MReadMarsFile.h
r3682 r5160 24 24 ~MReadMarsFile(); 25 25 26 static Byte_t IsFileValid(const char *name); 27 26 28 void SortFiles(); 27 29 -
trunk/MagicSoft/Mars/mfileio/MReadTree.cc
r5100 r5160 157 157 } 158 158 159 Byte_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 159 173 // -------------------------------------------------------------------------- 160 174 // -
trunk/MagicSoft/Mars/mfileio/MReadTree.h
r4895 r5160 51 51 ~MReadTree(); 52 52 53 static Byte_t IsFileValid(const char *name); 54 53 55 virtual void SortFiles(); 54 56
Note:
See TracChangeset
for help on using the changeset viewer.