Changeset 9292 for trunk/MagicSoft/Mars/mfileio
- Timestamp:
- 02/03/09 13:28:09 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
r9230 r9292 106 106 // -------------------------------------------------------------------------- 107 107 // 108 // Try to get the file from gROOT->GetListOfFiles. 108 // Try to get the file from gROOT->GetListOfFiles. (In case the file name 109 // is /dev/null we look for a file with name /dev/null and the given title) 109 110 // If it is found fOut is set to it and returned. 110 111 // Otherwise a new file is opened and returned. … … 112 113 TFile *MWriteRootFile::OpenFile(const char *name, Option_t *option, const char *title, Int_t comp) 113 114 { 114 TFile *file = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(name)); 115 116 // If the file was not found with its name try its expanded name 115 TFile *file = 0; 116 117 if (TString(name)=="/dev/null") 118 { 119 TIter Next(gROOT->GetListOfFiles()); 120 TObject *obj = 0; 121 while ((obj=Next())) 122 if (TString(obj->GetName())=="/dev/null" && TString(obj->GetTitle())==title) 123 { 124 *fLog << inf3 << "Found file '/dev/null' <Title=" << title << ">" << endl; 125 file = dynamic_cast<TFile*>(obj); 126 break; 127 } 128 } 129 else 130 { 131 file = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(name)); 132 133 // If the file was not found with its name try its expanded name 134 if (!file) 135 { 136 TString fqp(name); 137 gSystem->ExpandPathName(fqp); 138 file = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(fqp)); 139 } 140 } 141 117 142 if (!file) 118 {119 TString fqp(name);120 gSystem->ExpandPathName(fqp);121 file = dynamic_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(fqp));122 }123 124 if (!file || TString(name)=="/dev/null")125 143 { 126 144 file = new TFile(name, option, title, comp); … … 130 148 return NULL; 131 149 } 150 151 *fLog << inf3 << "New file '" << name << "' <Title=" << title << "> created." << endl; 132 152 133 153 file->SetOption(option); // IMPORTANT! … … 143 163 *fLog << inf; 144 164 *fLog << "File '" << name << "' already open... using." << endl; 165 *fLog << inf3; 145 166 *fLog << "Make sure that you do NOT write to trees which are" << endl; 146 167 *fLog << "scheduled already by a different MWriteRootFile..." << endl; … … 170 191 // ftitle: File title stored in the file (see TFile) 171 192 // name, title: Name and title of this object 193 // 194 // Until the first file is opened a dummy file with name /dev/null is 195 // opened to allow creation of trees and branches in the file. 196 // To distinguish between different /dev/null-files the given title is used. 172 197 // 173 198 MWriteRootFile::MWriteRootFile(const Int_t comp,
Note:
See TracChangeset
for help on using the changeset viewer.