User Tools

Site Tools


root:troubleshooting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
root:troubleshooting [2010/11/09 16:02] nchiaproot:troubleshooting [2013/06/14 12:14] (current) nchiap
Line 1: Line 1:
-====== Writing Root-files ====== +====== Root-files ====== 
-<code C> + 
-TFile* inputFile = TFile::Open("myInputFile.root"); +Root-files can be the source of various problems
-TFile* outputFile = new TFile("myOutputFile.root", "RECREATE"); +Usually they are caused by hidden changes in the internal state of ROOT. 
-// your code +ROOT stores the active directory and uses this to create new objects and look for existing ones
-outputFile->Write(); +The active directory is changed when a new file is opened.  
-</code>+This can lead to unexpected behaviours and hard to trace bugs.
  
 ===== Empty Files ===== ===== Empty Files =====
Line 17: Line 17:
 outputFile->Write(); outputFile->Write();
 </code> </code>
 +
 +but instead do:
 +<code C>
 +TFile* inputFile = TFile::Open("myInputFile.root");
 +TFile* outputFile = new TFile("myOutputFile.root", "RECREATE");
 +// your code
 +outputFile->Write();
 +</code>
 +
 +
 +
root/troubleshooting.1289314974.txt.gz · Last modified: 2010/11/09 16:02 by nchiap