LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
plot.C File Reference

Go to the source code of this file.

Functions

void SetLeafAddress (TNtuple *ntuple, const char *name, void *address)
 
void plot ()
 

Function Documentation

void plot ( )

Definition at line 12 of file plot.C.

References c1, f(), kineticEnergyDifference, ntuple, SetLeafAddress(), x, y, and z.

13 {
14  gROOT->Reset();
15  gStyle->SetPalette(1);
16  gROOT->SetStyle("Plain");
17 
18  TCanvas* c1 = new TCanvas ("c1","",20,20,1500,500);
19  c1->Divide(3,1);
20 
21  // Uncomment if merging should be done
22  //system ("rm -rf dna.root");
23  //system ("hadd dna.root dna_*.root");
24 
25  TFile* f = new TFile("dna.root");
26 
27  TNtuple* ntuple;
28  ntuple = (TNtuple*)f->Get("dna");
29  bool rowWise = true;
30  TBranch* eventBranch = ntuple->FindBranch("row_wise_branch");
31  if ( ! eventBranch ) rowWise = false;
32  // std::cout << "rowWise: " << rowWise << std::endl;
33 
34  // canvas tab 1
35  c1->cd(1);
36  gStyle->SetOptStat(000000);
37 
38  // All
39  ntuple->SetFillStyle(1001);
40  ntuple->SetFillColor(2);
41  ntuple->Draw("flagProcess","","B");
42 
43  // Excitation
44  ntuple->SetFillStyle(1001);
45  ntuple->SetFillColor(3);
46  ntuple->Draw("flagProcess","flagProcess==12||flagProcess==15||flagProcess==22||flagProcess==32||flagProcess==42||flagProcess==52||flagProcess==62","Bsame");
47 
48  // Elastic
49  ntuple->SetFillStyle(1001);
50  ntuple->SetFillColor(4);
51  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");
52 
53  // Ionisation
54  ntuple->SetFillStyle(1001);
55  ntuple->SetFillColor(5);
56  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");
57 
58  // Charge decrease
59  //ntuple->SetFillStyle(1001);
60  //ntuple->SetFillColor(6);
61  //ntuple->Draw("flagProcess","flagProcess==24||flagProcess==44||flagProcess==54","Bsame");
62 
63  // Charge increase
64  //ntuple->SetFillStyle(1001);
65  //ntuple->SetFillColor(7);
66  //ntuple->Draw("flagProcess","flagProcess==35||flagProcess==55||flagProcess==65","Bsame");
67 
68  gPad->SetLogy();
69 
70  // canvas tab 2
71  c1->cd(2);
72 
73  ntuple->SetMarkerColor(2);
74 
75  ntuple->Draw("x:y:z","flagParticle==1");
76 
77  //ntuple->SetMarkerColor(4);
78  //ntuple->SetMarkerSize(4);
79  //ntuple->Draw("x:y:z/1000","flagParticle==4 || flagParticle==5 || flagParticle==6","same");
80 
81  // canvas tab 3
82  c1->cd(3);
83 
84  Double_t flagParticle;
85  Double_t flagProcess;
86  Double_t x;
87  Double_t y;
88  Double_t z;
89  Double_t totalEnergyDeposit;
90  Double_t stepLength;
91  Double_t kineticEnergyDifference;
92  Int_t eventID;
93  Double_t kineticEnergy;
94  Int_t stepID;
95  Int_t trackID;
96  Int_t parentID;
97  Double_t angle;
98 
99  if ( ! rowWise ) {
100  ntuple->SetBranchAddress("flagParticle",&flagParticle);
101  ntuple->SetBranchAddress("flagProcess",&flagProcess);
102  ntuple->SetBranchAddress("x",&x);
103  ntuple->SetBranchAddress("y",&y);
104  ntuple->SetBranchAddress("z",&z);
105  ntuple->SetBranchAddress("totalEnergyDeposit",&totalEnergyDeposit);
106  ntuple->SetBranchAddress("stepLength",&stepLength);
107  ntuple->SetBranchAddress("kineticEnergyDifference",&kineticEnergyDifference);
108  ntuple->SetBranchAddress("kineticEnergy",&kineticEnergy);
109  ntuple->SetBranchAddress("cosTheta",&angle);
110  ntuple->SetBranchAddress("eventID",&eventID);
111  ntuple->SetBranchAddress("trackID",&trackID);
112  ntuple->SetBranchAddress("parentID",&parentID);
113  ntuple->SetBranchAddress("stepID",&stepID);
114  }
115  else {
116  SetLeafAddress(ntuple, "flagParticle",&flagParticle);
117  SetLeafAddress(ntuple, "flagProcess",&flagProcess);
118  SetLeafAddress(ntuple, "x",&x);
119  SetLeafAddress(ntuple, "y",&y);
120  SetLeafAddress(ntuple, "z",&z);
121  SetLeafAddress(ntuple, "totalEnergyDeposit",&totalEnergyDeposit);
122  SetLeafAddress(ntuple, "stepLength",&stepLength);
123  SetLeafAddress(ntuple, "kineticEnergyDifference",&kineticEnergyDifference);
124  SetLeafAddress(ntuple, "kineticEnergy",&kineticEnergy);
125  SetLeafAddress(ntuple, "cosTheta",&angle);
126  SetLeafAddress(ntuple, "eventID",&eventID);
127  SetLeafAddress(ntuple, "trackID",&trackID);
128  SetLeafAddress(ntuple, "parentID",&parentID);
129  SetLeafAddress(ntuple, "stepID",&stepID);
130  }
131 
132  TH1F* hsolvE = new TH1F ("hsolvE","solvE",100,0,2000);
133  TH1F* helastE = new TH1F ("helastE","elastE",100,0,2000);
134  TH1F* hexcitE = new TH1F ("hexcitE","excitE",100,0,2000);
135  TH1F* hioniE = new TH1F ("hiioniE","ioniE",100,0,2000);
136  TH1F* hattE = new TH1F ("hattE","attE",100,0,2000);
137  TH1F* hvibE = new TH1F ("hvibE","vibE",100,0,2000);
138 
139  for (Int_t j=0;j<ntuple->GetEntries(); j++)
140  {
141  ntuple->GetEntry(j);
142  if (flagProcess==10) hsolvE->Fill(x);
143  if (flagProcess==11) helastE->Fill(x);
144  if (flagProcess==12) hexcitE->Fill(x);
145  if (flagProcess==13) hioniE->Fill(x);
146  if (flagProcess==14) hattE->Fill(x);
147  if (flagProcess==15) hvibE->Fill(x);
148 
149  }
150 
151  helastE->GetXaxis()->SetTitle("x (nm)");
152  helastE->SetLineColor(2);
153 
154  hexcitE->SetLineColor(3);
155  hioniE->SetLineColor(4);
156  hattE->SetLineColor(5);
157  hvibE->SetLineColor(6);
158  hsolvE->SetLineColor(7);
159 
160  gPad->SetLogy();
161 
162  helastE->Draw("");
163  hexcitE->Draw("SAME");
164  hioniE->Draw("SAME");
165  hattE->Draw("SAME");
166  hvibE->Draw("SAME");
167  hsolvE->Draw("SAME");
168 }
double kineticEnergyDifference
Definition: plot.C:43
Double_t y
Definition: plot.C:276
TFile f("microbeam.root")
Double_t z
Definition: plot.C:276
Double_t x
Definition: plot.C:276
TNtuple * ntuple
Definition: plot.C:20
void SetLeafAddress(TNtuple *ntuple, const char *name, void *address)
Definition: plot.C:170
c1
Definition: plot.C:27
void SetLeafAddress ( TNtuple *  ntuple,
const char *  name,
void *  address 
)

Definition at line 170 of file plot.C.

Referenced by plot().

170  {
171  TLeaf* leaf = ntuple->FindLeaf(name);
172  if ( ! leaf ) {
173  std::cerr << "Error in <SetLeafAddress>: unknown leaf --> " << name << std::endl;
174  return;
175  }
176  leaf->SetAddress(address);
177 }
TNtuple * ntuple
Definition: plot.C:20