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 13 of file plot.C.

References c1, edep, f(), gr1, nentries, ntuple, and SetLeafAddress().

14 {
15 gROOT->Reset();
16 gStyle->SetPalette(1);
17 gROOT->SetStyle("Plain");
18 gStyle->SetOptStat(00000);
19 
20 //********************
21 Int_t nbRadius = 101;
22 //********************
23 
24 TCanvas *c1 = new TCanvas ("c1","",60,60,800,800);
25 Int_t mycolor;
26 
27 TFile f("t.root");
28 mycolor=4;
29 
30 TNtuple* ntuple;
31 ntuple = (TNtuple*)f.Get("t");
32 
33 bool rowWise = true;
34 TBranch* eventBranch = ntuple->FindBranch("row_wise_branch");
35 if ( ! eventBranch ) rowWise = false;
36 // std::cout << "rowWise: " << rowWise << std::endl
37 
38 Double_t radius1,nofHits,nbEdep,edep,radius2,Einc;
39 Int_t noRadius;
40 
41 if ( ! rowWise ) {
42  ntuple->SetBranchAddress("radius1",&radius1);
43  ntuple->SetBranchAddress("noRadius",&noRadius);
44  ntuple->SetBranchAddress("nbHits",&nofHits);
45  ntuple->SetBranchAddress("nbScoredHits",&nbEdep);
46  ntuple->SetBranchAddress("edep",&edep);
47  ntuple->SetBranchAddress("radius2",&radius2);
48  ntuple->SetBranchAddress("Einc",&Einc);
49  }
50 else {
51  SetLeafAddress(ntuple, "radius1",&radius1);
52  SetLeafAddress(ntuple, "noRadius",&noRadius);
53  SetLeafAddress(ntuple, "nbHits",&nofHits);
54  SetLeafAddress(ntuple, "nbScoredHits",&nbEdep);
55  SetLeafAddress(ntuple, "edep",&edep);
56  SetLeafAddress(ntuple, "radius2",&radius2);
57  SetLeafAddress(ntuple, "Einc",&Einc);
58 }
59 
60 Int_t nentries = (Int_t)ntuple->GetEntries();
61 
62 //
63 
64 Double_t t[1000]; // 1000 is the max number of radius values
65 Double_t population[1000];
66 Double_t myRad[1000];
67 
68 for (Int_t i=0; i<1000; i++)
69 {
70  t[i]=0;
71  population[i]=0;
72  myRad[i]=0;
73 }
74 
75 Int_t event = 0;
76 
77 for (Int_t i=0; i<nentries; i++)
78 {
79  ntuple->GetEntry(i);
80  t[noRadius] = t[noRadius] + edep;
81  population[noRadius]=population[noRadius]+1;
82  myRad[noRadius] = radius1;
83 }
84 
85 // Mean
86 
87 for (Int_t j=1; j<nbRadius; j++)
88 {
89  t[j] = t[j]/population[j];
90  t[j] = t[j]/(myRad[j+1]-myRad[j]);
91  //cout << j << " " << myRad[j] << " " << myRad[j+1]
92  // << " " << t[j] << " " << population[j] << endl;
93 }
94 
95 //
96 
97  c1->cd(1);
98 
99  TGraph* gr1 =new TGraph(nbRadius,myRad,t);
100  gr1->SetMarkerColor(2);
101  gr1->SetMarkerStyle(20);
102  gr1->SetMarkerSize(1);
103  gr1->SetLineColor(2);
104  gr1->SetTitle("");
105  gr1->GetXaxis()->SetLimits(0.1,100);
106  gr1->GetYaxis()->SetLimits(0.,22);
107  gr1->GetXaxis()->SetLabelSize(0.025);
108  gr1->GetYaxis()->SetLabelSize(0.025);
109  gr1->GetXaxis()->SetTitleSize(0.035);
110  gr1->GetYaxis()->SetTitleSize(0.035);
111  gr1->GetXaxis()->SetTitleOffset(1.4);
112  gr1->GetYaxis()->SetTitleOffset(1.4);
113  gr1->GetXaxis()->SetTitle("r (nm)");
114  gr1->GetYaxis()->SetTitle("t (eV/nm)");
115  gr1->Draw("");
116  gPad->SetLogx();
117 
118 }
TFile f("microbeam.root")
TNtuple * ntuple
Definition: plot.C:20
void SetLeafAddress(TNtuple *ntuple, const char *name, void *address)
Definition: plot.C:170
TGraph * gr1
Definition: compare.C:42
Int_t nentries
Definition: plot.C:280
Double_t edep
Definition: macro.C:13
c1
Definition: plot.C:27
void SetLeafAddress ( TNtuple *  ntuple,
const char *  name,
void *  address 
)

Definition at line 120 of file plot.C.

120  {
121  TLeaf* leaf = ntuple->FindLeaf(name);
122  if ( ! leaf ) {
123  std::cerr << "Error in <SetLeafAddress>: unknown leaf --> " << name << std::endl;
124  return;
125  }
126  leaf->SetAddress(address);
127 }
TNtuple * ntuple
Definition: plot.C:20