Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
_tfile.pyzdoc
Go to the documentation of this file.
2
3In the same way as for TDirectory, it is possible to get the content of a
6
10
11In order to write objects into a TFile, the `WriteObject` Python method can
13
17
18This class can also be used as a context manager, with the goal of opening a
19file and doing some quick manipulations of the objects inside it. The
20For
22\code{.py}
23from ROOT import TFile
24with TFile("file1.root", "recreate") as outfile:
25 hout = ROOT.TH1F(...)
26 outfile.WriteObject(hout, "myhisto")
28
29or read
30from the file inside the context are not accessible anymore in the application
32like histograms can be detached from a file with the SetDirectory method. This
33the
34context:
35\code{.py}
36import ROOT
37from ROOT import TFile
38with TFile("file1.root", "read") as infile:
39 hin = infile.Get("myhisto")
40 hin.SetDirectory(ROOT.nullptr)
41
43print(hin.GetName())
45
48current directory to some other file that was opened prior to the `with`
50
#define a(i)
Definition RSha256.hxx:99
#define e(i)
Definition RSha256.hxx:103
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
void Close(Option_t *option="")
#define gROOT
Definition TROOT.h:414
A ROOT file is structured in Directories (like a file system).
Describe directory structure in memory.
Definition TDirectory.h:45
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:131
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition TFile.cxx:4131
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:877
constexpr std::array< decltype(std::declval< F >()(std::declval< int >())), N > make(F f)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
TString as(SEXP s)
Definition RExports.h:86