-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignal.C
211 lines (158 loc) · 4.45 KB
/
signal.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
#include "TH1F.h"
#include "TVirtualFFT.h"
#include "TRandom.h"
#include "TF1.h"
#include "TTree.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TMath.h"
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <TSpectrum.h>
#include <TSpectrumTransform.h>
void signal()
{
gStyle->SetPadTickX(1);
gStyle->SetPadTickY(1);
gStyle->SetPadGridX(1);
gStyle->SetPadGridY(1);
gStyle->SetStatY(0.9);
gStyle->SetStatX(0.95);
gStyle->SetStatW(0.3);
gStyle->SetStatH(0.2);
gStyle->SetStatBorderSize(3);
Double_t initial = 15;
std::vector<TString> fileNames;
fileNames.push_back("OutPut_t0.root");
fileNames.push_back("OutPut_t1.root");
fileNames.push_back("OutPut_t2.root");
fileNames.push_back("OutPut_t3.root");
fileNames.push_back("OutPut_t4.root");
fileNames.push_back("OutPut_t5.root");
fileNames.push_back("OutPut_t6.root");
std::vector<double> dataX;
std::vector<double> dataY;
std::vector<double> dataZ;
std::vector<double> dataT;
std::vector<double> dataE;
int size = 0;
int nentries = 0;
Double_t x;
Double_t y;
Double_t z;
Double_t t;
Double_t e;
TFile *f;
TTree *T;
for (int i = 0; i < fileNames.size(); ++i)
{
f = new TFile(fileNames[i],"READ");
if ( f->IsOpen() )
{
printf("File opened successfully\n");
}
else
{
printf("Error! Invalid File Name\n");
return;
}
T = (TTree*)f -> Get("ntuple");
T->SetBranchAddress("x",&x);
T->SetBranchAddress("y",&y);
T->SetBranchAddress("z",&z);
T->SetBranchAddress("t",&t);
T->SetBranchAddress("energy",&e);
nentries = (int)T->GetEntries();
for (int i = 0; i < nentries; ++i)
{
T->GetEntry(i);
dataX.push_back(x);
dataY.push_back(y);
dataZ.push_back(z);
dataT.push_back(t);
dataE.push_back(e);
}
}
size = dataE.size();
printf("There were %d events.\n", size);
std::vector<double> wasVisited;
std::vector<double> howMany;
TH1D *simpleX = new TH1D("simpleX", "simpleX", 100, -60, 60);
TH1D *simpleY = new TH1D("simpleY", "simpleY", 100, -60, 60);
TH1D *simpleZ = new TH1D("simpleZ", "simpleZ", 100, -60, 60);
TH1D *simpleT = new TH1D("simpleT", "simpleT", 200, 200, 400);
for (Int_t i=0; i<size; i++)
{
simpleX->Fill(dataX[i]);
simpleY->Fill(dataY[i]);
simpleZ->Fill(dataZ[i]);
simpleT->Fill(dataT[i]);
if (dataZ[i] == 0)
{
break;
size = i;
}
// printf("%3.3lf %3.3lf %3.3lf %3.3lf %3.3lf\n",x[i],y[i],z[i],t[i], e[i]);
}
simpleX->SetTitle("Eixo X");
simpleX->GetXaxis()->SetTitle("Distancia (cm)");
simpleX->GetYaxis()->SetTitle("#");
simpleX->SetLineWidth(1);
simpleY->SetTitle("Eixo Y");
simpleY->GetXaxis()->SetTitle("Distancia (cm)");
simpleY->GetYaxis()->SetTitle("#");
simpleY->SetLineWidth(1);
simpleZ->SetTitle("Eixo Z");
simpleZ->GetXaxis()->SetTitle("Distancia (cm)");
simpleZ->GetYaxis()->SetTitle("#");
simpleZ->SetLineWidth(1);
simpleT->SetTitle("Tempo de voo");
simpleT->GetXaxis()->SetTitle("Tempo (ns)");
simpleT->GetYaxis()->SetTitle("Contagem de eventos");
simpleT->SetLineWidth(1);
TCanvas *Simple = new TCanvas("Simple", "Simple plots", 1600, 900);
Simple->Divide(2,2);
Simple->cd(1);
simpleX->Draw();
Simple->cd(2);
simpleY->Draw();
Simple->cd(3);
simpleZ->Draw();
Simple->cd(4);
gPad-> SetLogy();
simpleT->Draw();
//*********************************************************************************
TCanvas *C_Frente = new TCanvas("C_Frente", "Parede frontal",0,0,1800,900);
C_Frente->cd();
gPad->SetRightMargin(.45);
TH2D* Frente = new TH2D("Distribuicao na base da pir#hat{a}mide", "Distribuicao na base da pir#hat{a}mide", 60, -60, 60, 60, -60, 60);
Int_t bin = 0;
for (int i = 0; i < size; ++i)
{
Frente->Fill(dataX[i],dataY[i]);
}
for (int i = 0; i < size; ++i)
{
bin = Frente->FindBin(dataX[i],dataY[i]);
howMany.push_back(Frente->GetBinContent(bin));
}
Frente->Reset("ICES");
for (int i = 0; i < size; ++i)
{
bin = Frente->FindBin(dataX[i],dataY[i]);
Frente->SetBinContent(bin, dataE[i]/(howMany[i]) + Frente->GetBinContent(bin));
}
// Frente->Smooth(10,"k3a");
Frente->SetTitle("Mean energy of the muons at the pyramid base");
Frente->GetXaxis()->SetTitle("Distance (m)");
Frente->GetYaxis()->SetTitle("Distance (m)");
Frente->GetZaxis()->SetTitle("Mean energy (GeV)");
Frente->GetZaxis()->SetTitleOffset(1);
Frente->SetLineWidth(1);
Frente->Draw("colz");
// Frente->SetMaximum(max);
return;
}