Changeset 13617 for fact/tools/rootmacros/PulseTemplates
- Timestamp:
- 05/09/12 14:08:42 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/PulseTemplates/rootfilehandler.C
r13611 r13617 27 27 28 28 29 TFile* 29 void 30 30 OpenRootFile( 31 const char * loc_fname, 32 int verbosityLevel 31 TFile* output_rootfile, 32 const char * loc_fname, 33 int verbosityLevel 33 34 ) 34 35 { 35 TFile* tf= new TFile(loc_fname,"UPDATE");36 if ( tf->IsZombie())36 output_rootfile = new TFile(loc_fname,"UPDATE"); 37 if (output_rootfile->IsZombie()) 37 38 { 38 39 cout << "Error opening file" << endl; 39 40 exit(-1); 40 41 } 41 else { 42 if (verbosityLevel > 1) cout << "...opening root-file:" 43 << loc_fname 44 << " successfull" << endl; 42 else 43 { 44 if (verbosityLevel > 1) 45 { 46 cout << "...opening root-file:" 47 << loc_fname 48 << " successfull" << endl; 49 } 45 50 } 46 return tf;51 return; 47 52 } 48 53 //end of OpenRootFile … … 52 57 void 53 58 CloseRootFile( 54 TFile* tf59 TFile* output_rootfile 55 60 ) 56 61 { 57 if ( tf->IsZombie())62 if (output_rootfile->IsZombie()) 58 63 { 59 64 cout << "Error closing file" << endl; 60 65 exit(-1); 61 66 } else { 62 tf->Close(); 67 output_rootfile->Close(); 68 delete output_rootfile; 63 69 } 64 70 } … … 81 87 << subdirectory << endl ; 82 88 83 TFile* tf = OpenRootFile(loc_fname, verbosityLevel); 89 TFile* output_rootfile = NULL; 90 OpenRootFile(output_rootfile, loc_fname, verbosityLevel); 84 91 if ( !( subdirectory.CompareTo("root") ) ) //if subdirectory = root 85 92 { 86 tf->cd();93 output_rootfile->cd(); 87 94 } 88 95 else 89 96 { 90 tf->cd();91 tf->mkdir(subdirectory,subdirectory);92 tf->cd(subdirectory);97 output_rootfile->cd(); 98 output_rootfile->mkdir(subdirectory,subdirectory); 99 output_rootfile->cd(subdirectory); 93 100 } 94 101 histList->Write(); // write the major histograms into the top level directory 95 102 if (verbosityLevel > 3) tf->ls(); 96 CloseRootFile( tf); // close the file103 CloseRootFile( output_rootfile ); // close the file 97 104 if (verbosityLevel > 2) cout << "...done" << endl; 98 105 }
Note:
See TracChangeset
for help on using the changeset viewer.