- Timestamp:
- 02/11/05 10:36:02 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r6367 r6373 22 22 -*-*- END OF LINE -*-*- 23 23 24 2005/02/11 Thomas Bretz 25 26 * mfileio/MWriteRootFile.[h,cc]: 27 - added the possibility to write to an already existing file. 28 This doesn't affect the old behaviour, but using this new feature 29 might still have problems. 30 31 * mfileio/MReadReports.cc: 32 - fixed column-level in PrintStatistics 33 34 35 24 36 2005/02/10 Abelardo Moralejo 25 37 … … 29 41 * macros/starmc2.C 30 42 - Added comment about value of cleaning levels 43 31 44 32 45 … … 52 65 - make sure that all variables are set correctly independent on 53 66 the order of their initialization by the user 67 54 68 55 69 -
trunk/MagicSoft/Mars/mfileio/MReadReports.cc
r5143 r6373 425 425 { 426 426 MRead::PrintStatistics(lvl, title, time); 427 fTrees->PrintStatistics(lvl , title, GetCpuTime());428 } 427 fTrees->PrintStatistics(lvl+1, title, GetCpuTime()); 428 } -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc
r6348 r6373 97 97 // 98 98 //fTrees.SetOwner(); 99 100 gROOT->GetListOfCleanups()->Add(this); // To remove fDisplay 101 SetBit(kMustCleanup); 99 102 } 100 103 … … 188 191 // Open the rootfile 189 192 // 190 fOut = new TFile(str, opt, ftitle, comp); 193 TObject *find = gROOT->FindObject(str); 194 if (find && find->InheritsFrom(TFile::Class())) 195 { 196 fOut = (TFile*)find; 197 fOut->SetBit(kMustCleanup); 198 SetBit(kIsNotOwner); 199 200 *fLog << inf << "File '" << fname << "' already open... using." << endl; 201 *fLog << "Make sure that you do NOT write to trees which are" << endl; 202 *fLog << "scheduled already by a different MWriteRootFile..." << endl; 203 } 204 else 205 fOut = new TFile(str, opt, ftitle, comp); 191 206 } 192 207 … … 203 218 Print(); 204 219 205 if (fOut )220 if (fOut && !TestBit(kIsNotOwner)) 206 221 { 207 222 // … … 216 231 // 217 232 delete fOut; 218 fOut = 0; 219 }220 221 //222 // Remark:223 // - Trees are automatically deleted by the the file224 // (unless file.SetDirectory(0) was called)225 // - Branches are automatically deleted by the tree destructor226 //227 228 *fLog << inf << "Output File closed and object deleted." << endl;233 234 // 235 // Remark: 236 // - Trees are automatically deleted by the the file 237 // (unless file.SetDirectory(0) was called) 238 // - Branches are automatically deleted by the tree destructor 239 // 240 *fLog << inf << "Output File closed and object deleted." << endl; 241 } 242 243 fOut = 0; 229 244 } 230 245 … … 244 259 void MWriteRootFile::Print(Option_t *) const 245 260 { 261 if (!fOut) 262 return; 263 246 264 *fLog << all << underline << "File: " << GetFileName() << endl; 247 265 … … 267 285 name += branch->GetName(); 268 286 269 *fLog << " " << name.Strip(TString::kTrailing, '.') << ": \t" << (ULong_t)branch->GetEntries() << " entries." << endl;287 *fLog << " + " << name.Strip(TString::kTrailing, '.') << ": \t" << (ULong_t)branch->GetEntries() << " entries." << endl; 270 288 } 271 289 … … 274 292 while ((t=(TTree*)NextTree())) 275 293 if (t->TestBit(kIsNewTree)) 276 *fLog << " " << t->GetName() << ": \t" << (ULong_t)t->GetEntries() << " entries." << endl; 294 *fLog << " + " << t->GetName() << ": \t" << (ULong_t)t->GetEntries() << " entries." << endl; 295 296 TIter NextKey(fOut->GetListOfKeys()); 297 while ((obj=NextKey())) 298 { 299 if (!obj->InheritsFrom(TTree::Class())) 300 continue; 301 302 if (fTrees.FindObject(obj) && obj->TestBit(kIsNewTree)) 303 continue; 304 305 *fLog << " - " << obj->GetName() << ": \t" << (ULong_t)((TTree*)t)->GetEntries() << " entries." << endl; 306 } 277 307 *fLog << endl; 308 278 309 } 279 310 … … 662 693 Bool_t MWriteRootFile::ChangeFile(const char *fname) 663 694 { 695 if (!fOut) 696 { 697 TObject *find = gROOT->FindObject(fname); 698 if (find && find->InheritsFrom(TFile::Class())) 699 { 700 fOut = (TFile*)find; 701 SetBit(kIsNotOwner); 702 return kTRUE; 703 } 704 705 *fLog << err << "MWriteRootFile::ChangeFile: Expecting file '" << fname; 706 *fLog << "' in gROOT->FindObject... not found." << endl; 707 return kFALSE; 708 } 709 664 710 // 665 711 // The following code is more or less a copy of TTree::ChangeFile … … 879 925 } 880 926 927 void MWriteRootFile::RecursiveRemove(TObject *obj) 928 { 929 if (obj==fOut && TestBit(kIsNotOwner)) 930 { 931 ResetBit(kIsNotOwner); 932 fOut=0; 933 } 934 } 935 881 936 // -------------------------------------------------------------------------- 882 937 // … … 925 980 } 926 981 } 982 -
trunk/MagicSoft/Mars/mfileio/MWriteRootFile.h
r4826 r6373 82 82 83 83 enum { 84 kFillTree = BIT(14), 84 kIsNotOwner = BIT(14), // MWriteRootFile is not owner of fOut 85 kFillTree = BIT(14), 85 86 // Be carefull these bits are already in use! 86 87 // TBranch::kAutoDelete = BIT(15) 87 88 // TBranchElement::kDeleteObject = BIT(16) 88 kIsNewTree = BIT(17)89 kIsNewTree = BIT(17) 89 90 }; 90 91 … … 130 131 Bool_t cd(const char *path=0); 131 132 133 void RecursiveRemove(TObject *obj); 134 132 135 ClassDef(MWriteRootFile, 1) // Task to write data into a root file 133 136 };
Note:
See TracChangeset
for help on using the changeset viewer.