1 //____________________________________________________________________
3 // Script to compare the output of GEANT 3.21 to FLUKA 2.
5 /** @ingroup simple_script
10 TFile* fluka_file = TFile::Open("fluka/FMD.Hits.root", "READ");
11 TFile* geant_file = TFile::Open("geant321/FMD.Hits.root", "READ");
12 if (!fluka_file || !geant_file) {
13 std::cerr << "Failed to open one or more of the input files"
20 gDirectory->cd("Event0");
21 TTree* fluka_tree = static_cast<TTree*>(gDirectory->Get("TreeH"));
24 gDirectory->cd("Event0");
25 TTree* geant_tree = static_cast<TTree*>(gDirectory->Get("TreeH"));
27 if (!fluka_tree || !geant_tree) {
28 std::cerr << "Failed to get one or more of the trees"
33 gStyle->SetOptStat(0);
34 gStyle->SetOptTitle(0);
35 gStyle->SetLabelFont(132, "XY");
36 gStyle->SetTitleFont(132, "XY");
37 gStyle->SetTextFont(132);
38 gStyle->SetNdivisions(10, "XY");
40 TCanvas* c = new TCanvas("c", "c", 600, 600);
45 c->SetRightMargin(.05);
47 TH1* fluka_dist = new TH1F("fluka_dist", "FLUKA Energy deposition",
49 fluka_dist->SetLineColor(2);
50 fluka_dist->SetFillColor(2);
51 fluka_dist->SetFillStyle(3001);
52 fluka_dist->GetXaxis()->SetTitle("Energy deposited");
53 fluka_dist->GetYaxis()->SetTitle("Frequency");
54 fluka_tree->Draw("FMD.fEdep>>fluka_dist");
56 TH1* geant_dist = new TH1F("geant_dist", "GEANT Energy deposition",
58 geant_dist->SetLineColor(3);
59 geant_dist->SetFillColor(3);
60 geant_dist->SetFillStyle(3002);
61 geant_tree->Draw("FMD.fEdep>>geant_dist", "", "SAME");
63 TLegend* l = new TLegend(.3, .8, .95, .95);
67 l->AddEntry(fluka_dist, Form("%s - %d counts",
68 fluka_dist->GetTitle(),
69 Int_t(fluka_dist->Integral())), "LF");
70 l->AddEntry(geant_dist, Form("%s - %d counts",
71 geant_dist->GetTitle(),
72 Int_t(geant_dist->Integral())), "LF");
77 c->Print("fluka_vs_geant321.C");
80 //____________________________________________________________________