These objects are filled with some random numbers and saved on a file. If get=1 the macro returns a pointer to the TFile of "hsimple.root" if this file exists, otherwise it is created. The file "hsimple.root" is created in $ROOTSYS/tutorials if the caller has write access to this directory, otherwise the file is created in $PWD
{
if (getFile) {
TString fullPath = dir+
"hsimple.root";
if (hfile) return hfile;
}
if (hfile) return hfile;
}
}
printf("you must run the script in a directory with write access\n");
return nullptr;
}
hfile =
new TFile(
filename,
"RECREATE",
"Demo ROOT file with histograms");
TH1F *hpx =
new TH1F(
"hpx",
"This is the px distribution",100,-4,4);
TH2F *hpxpy =
new TH2F(
"hpxpy",
"py vs px",40,-4,4,40,-4,4);
TProfile *hprof =
new TProfile(
"hprof",
"Profile of pz versus px",100,-4,4,0,20);
TNtuple *ntuple =
new TNtuple(
"ntuple",
"Demo ntuple",
"px:py:pz:random:i");
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(6);
c1->GetFrame()->SetBorderMode(-1);
for (
Int_t i = 0; i < 25000; i++) {
pz = px*px + py*py;
ntuple->
Fill(px,py,pz,rnd,i);
break;
}
}
return hfile;
}
R__EXTERN TBenchmark * gBenchmark
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
R__EXTERN TSystem * gSystem
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void Start(const char *name)
Starts Benchmark with the specified name.
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
TObject * FindObject(const char *name) const override
Find object by name in the list of memory objects.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
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.
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) override
Write memory objects to this file.
void Close(Option_t *option="") override
Close a file.
1-D histogram with a float per channel (see TH1 documentation)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void Draw(Option_t *option="") override
Draw this histogram with options.
2-D histogram with a float per channel (see TH1 documentation)
Int_t Fill(Double_t) override
Invalid Fill method.
A simple TTree restricted to a list of float variables only.
Int_t Fill() override
Fill a Ntuple with current values in fArgs.
Int_t Fill(const Double_t *v)
Random number generator class based on M.
Double_t Rndm() override
Machine independent random number generator.
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).