plot.C
Go to the documentation of this file.
1 // -------------------------------------------------------------------
2 // $Id: plot.C 70323 2013-05-29 07:57:44Z gcosmo $
3 // -------------------------------------------------------------------
4 //
5 // *********************************************************************
6 // To execute this macro under ROOT after your simulation ended,
7 // 1 - launch ROOT (usually type 'root' at your machine's prompt)
8 // 2 - type '.X plot.C' at the ROOT session prompt
9 // *********************************************************************
10 {
11 gROOT->Reset();
12 gStyle->SetPalette(1);
13 gROOT->SetStyle("Plain");
14 
15 c1 = new TCanvas ("c1","",20,20,1500,500);
16 c1->Divide(3,1);
17 
18 system ("rm -rf dna.root");
19 system ("hadd dna.root dna_*.root");
20 
21 TFile f("dna.root");
22 
23 TNtuple* ntuple;
24 ntuple = (TNtuple*)f.Get("dna");
25 
26 c1->cd(1);
27  gStyle->SetOptStat(000000);
28 
29  // All
30  ntuple->SetFillStyle(1001);
31  ntuple->SetFillColor(2);
32  ntuple->Draw("flagProcess","","B");
33 
34  // Excitation
35  ntuple->SetFillStyle(1001);
36  ntuple->SetFillColor(3);
37  ntuple->Draw("flagProcess","flagProcess==12||flagProcess==15||flagProcess==22||flagProcess==32||flagProcess==42||flagProcess==52||flagProcess==62","Bsame");
38 
39  // Elastic
40  ntuple->SetFillStyle(1001);
41  ntuple->SetFillColor(4);
42  ntuple->Draw("flagProcess","flagProcess==11||flagProcess==21||flagProcess==31||flagProcess==41||flagProcess==51||flagProcess==61||flagProcess==110||flagProcess==210||flagProcess==410||flagProcess==510||flagProcess==710||flagProcess==120||flagProcess==220||flagProcess==420||flagProcess==520||flagProcess==720","Bsame");
43 
44  // Ionisation
45  ntuple->SetFillStyle(1001);
46  ntuple->SetFillColor(5);
47  ntuple->Draw("flagProcess","flagProcess==13||flagProcess==23||flagProcess==33||flagProcess==43||flagProcess==53||flagProcess==63||flagProcess==73||flagProcess==130||flagProcess==230||flagProcess==430||flagProcess==530||flagProcess==730","Bsame");
48 
49  // Charge decrease
50  //ntuple->SetFillStyle(1001);
51  //ntuple->SetFillColor(6);
52  //ntuple->Draw("flagProcess","flagProcess==24||flagProcess==44||flagProcess==54","Bsame");
53 
54  // Charge increase
55  //ntuple->SetFillStyle(1001);
56  //ntuple->SetFillColor(7);
57  //ntuple->Draw("flagProcess","flagProcess==35||flagProcess==55||flagProcess==65","Bsame");
58 
59  gPad->SetLogy();
60 
61 c1->cd(2);
62 
63  ntuple->SetMarkerColor(2);
64 
65  ntuple->Draw("x:y:z","flagParticle==1");
66 
67  //ntuple->SetMarkerColor(4);
68  //ntuple->SetMarkerSize(4);
69  //ntuple->Draw("x:y:z/1000","flagParticle==4 || flagParticle==5 || flagParticle==6","same");
70 
71 c1->cd(3);
72 
73  Double_t flagParticle;
74  Double_t flagProcess;
75  Double_t x;
76  Double_t y;
77  Double_t z;
79  Double_t stepLength;
81  Int_t eventID;
82  Double_t kineticEnergy;
83  Int_t stepID;
84  Int_t trackID;
85  Int_t parentID;
86  Double_t angle;
87 
88  ntuple->SetBranchAddress("flagParticle",&flagParticle);
89  ntuple->SetBranchAddress("flagProcess",&flagProcess);
90  ntuple->SetBranchAddress("x",&x);
91  ntuple->SetBranchAddress("y",&y);
92  ntuple->SetBranchAddress("z",&z);
93  ntuple->SetBranchAddress("totalEnergyDeposit",&totalEnergyDeposit);
94  ntuple->SetBranchAddress("stepLength",&stepLength);
95  ntuple->SetBranchAddress("kineticEnergyDifference",&kineticEnergyDifference);
96  ntuple->SetBranchAddress("kineticEnergy",&kineticEnergy);
97  ntuple->SetBranchAddress("cosTheta",&angle);
98  ntuple->SetBranchAddress("eventID",&eventID);
99  ntuple->SetBranchAddress("trackID",&trackID);
100  ntuple->SetBranchAddress("parentID",&parentID);
101  ntuple->SetBranchAddress("stepID",&stepID);
102 
103  TH1F* hsolvE = new TH1F ("hsolvE","solvE",100,0,2000);
104  TH1F* helastE = new TH1F ("helastE","elastE",100,0,2000);
105  TH1F* hexcitE = new TH1F ("hexcitE","excitE",100,0,2000);
106  TH1F* hioniE = new TH1F ("hiioniE","ioniE",100,0,2000);
107  TH1F* hattE = new TH1F ("hattE","attE",100,0,2000);
108  TH1F* hvibE = new TH1F ("hvibE","vibE",100,0,2000);
109 
110  for (Int_t j=0;j<ntuple->GetEntries(); j++)
111  {
112 
113  ntuple->GetEntry(j);
114  if (flagProcess==10) hsolvE->Fill(x);
115  if (flagProcess==11) helastE->Fill(x);
116  if (flagProcess==12) hexcitE->Fill(x);
117  if (flagProcess==13) hioniE->Fill(x);
118  if (flagProcess==14) hattE->Fill(x);
119  if (flagProcess==15) hvibE->Fill(x);
120 
121  }
122 
123  helastE->GetXaxis()->SetTitle("x (nm)");
124  helastE->SetLineColor(2);
125 
126  hexcitE->SetLineColor(3);
127  hioniE->SetLineColor(4);
128  hattE->SetLineColor(5);
129  hvibE->SetLineColor(6);
130  hsolvE->SetLineColor(7);
131 
132  gPad->SetLogy();
133 
134  helastE->Draw("");
135  hexcitE->Draw("SAME");
136  hioniE->Draw("SAME");
137  hattE->Draw("SAME");
138  hvibE->Draw("SAME");
139  hsolvE->Draw("SAME");
140 
141 
142 end:
143 }
Double_t y
Definition: plot.C:277
Int_t stepID
Definition: plot.C:83
Double_t angle
Definition: plot.C:86
Double_t stepLength
Definition: plot.C:79
system("rm -rf microbeam.root")
Double_t kineticEnergy
Definition: plot.C:82
TFile f("microbeam.root")
Double_t z
Definition: plot.C:277
TH1F * hexcitE
Definition: plot.C:105
Int_t eventID
Definition: plot.C:81
Double_t x
Definition: plot.C:277
TNtuple * ntuple
Definition: plot.C:20
Double_t kineticEnergyDifference
Definition: plot.C:80
const double j
Definition: BetheBloch.cxx:29
TH1F * hsolvE
Definition: plot.C:103
TH1F * hvibE
Definition: plot.C:108
TH1F * hattE
Definition: plot.C:107
Int_t parentID
Definition: plot.C:85
Double_t totalEnergyDeposit
Definition: plot.C:78
TH1F * helastE
Definition: plot.C:104
c1
Definition: plot.C:28
Double_t flagProcess
Definition: plot.C:74
Int_t trackID
Definition: plot.C:84
Double_t flagParticle
Definition: plot.C:73
TH1F * hioniE
Definition: plot.C:106