Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
macro.C
Go to the documentation of this file.
1 {
2 TFile f("brachytherapy.root");
3 
4 TDirectory* dir = (TDirectory*)f.Get("ntuple");
5 TTree* ntuple = (TTree*)dir->Get("EnergyDeposition");
6 ntuple -> Print();
7 
13 ntuple->GetBranch("xx")->SetAddress(&xx);
14 ntuple->GetBranch("yy")->SetAddress(&yy);
15 ntuple->GetBranch("zz")->SetAddress(&zz);
16 ntuple->GetBranch("edep")->SetAddress(&edep);
17 
18 // Print the content of the ntuple
19 /*Int_t nevent = Int_t(ntuple->GetEntries());
20 
21 for ( Int_t i=0; i<nevent; i++ ) {
22  ntuple->GetEvent(i);
23  cout << "xx, yy, zz, edep: "
24  << xx << ", " << yy << ", " << zz << ", " << edep << endl;
25  }
26 */
27 
28 // The phantom is 30 cm wide along x, y, z
29 // the voxel size is 1 mm. The number of voxels is 300 along x, y, z
30 
31 // Plot the energy deposition in the phantom in 3D
32 TH3F* edepDDistribution3D = new TH3F("h30", "3Dedepxyz",
33  300, -150, 150, // binning, xmin, xmax, along x direction
34  300, -150, 150, // binning, xmin, xmax, along y direction
35  300, -150, 150);// binning, xmin, xmax, along z direction
36 
37 gStyle->SetPalette(1);
38 
39 ntuple.Draw("xx:yy:zz:edep>>h30", "", "colz");
40 }