- Timestamp:
- 05/09/12 17:48:09 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/rootfilehandler.C
r13617 r13626 8 8 void 9 9 CreateRootFile( 10 const char*loc_fname,10 TString loc_fname, 11 11 int verbosityLevel 12 12 ) 13 13 { 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()) 16 17 { 17 18 cout << "Error opening file" << endl; … … 19 20 } 20 21 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(); 23 25 } 24 26 } … … 27 29 28 30 29 void 31 TFile* 30 32 OpenRootFile( 31 TFile* output_rootfile, 32 const char * loc_fname, 33 TString loc_fname, 33 34 int verbosityLevel 34 35 ) 35 36 { 36 output_rootfile = new TFile(loc_fname,"UPDATE");37 TFile* output_rootfile = new TFile(loc_fname,"UPDATE"); 37 38 if (output_rootfile->IsZombie()) 38 39 { … … 49 50 } 50 51 } 51 return ;52 return output_rootfile; 52 53 } 53 54 //end of OpenRootFile … … 57 58 void 58 59 CloseRootFile( 59 TFile* output_rootfile60 TFile* output_rootfile 60 61 ) 61 62 { … … 66 67 } else { 67 68 output_rootfile->Close(); 69 } 68 70 delete output_rootfile; 69 }70 71 } 71 72 //end of CloseRootFile … … 75 76 void 76 77 SaveHistograms( 77 const char*loc_fname,78 TString loc_fname, 78 79 TString subdirectory, 79 80 TObjArray* histList, … … 88 89 89 90 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(); 103 100 CloseRootFile( output_rootfile ); // close the file 104 101 if (verbosityLevel > 2) cout << "...done" << endl; … … 124 121 TString 125 122 CreateSubDirName( 126 const char*title123 TString title 127 124 ) 128 125 { 129 TString path = title; 130 path += "_Pixel"; 126 title += "_Pixel"; 131 127 // cout << "path " << path << endl ; 132 return path;128 return title; 133 129 } 134 130 // end of CreateSubDirName
Note:
See TracChangeset
for help on using the changeset viewer.