-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDraw.C
211 lines (180 loc) · 7.52 KB
/
Draw.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
211
// C++ headers
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <sstream>
#include <algorithm>
// C headers
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <math.h>
#include <cstring>
#include <unistd.h>
// ROOT headers
#include "TROOT.h"
#include "TObject.h"
#include "TApplication.h"
#include "TAttLine.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TH2.h"
#include "TH3.h"
#include "TF1.h"
#include "TProfile.h"
#include "TPolyLine3D.h"
#include "TStyle.h"
#include "TFrame.h"
#include "TFile.h"
#include "TVirtualPad.h"
#include "TView.h"
#include "TView3D.h"
#include "TTree.h"
void Draw()
{
const float kDetector[] = {2.5604,2.325,10.368}; // Size of the detectors in m (used from docdb 1821)
const int kResolution[] = {25,25,100};
// Remove gifs
std::remove("RecoX.gif"); std::remove("RecoY.gif"); std::remove("RecoZ.gif");
std::remove("ResidualX.gif"); std::remove("ResidualY.gif"); std::remove("ResidualZ.gif");
TFile* FieldFile = new TFile("RecoDispl.root","READ");
if (FieldFile->IsZombie())
{
std::cout << "Error opening field file" << std::endl;
exit(-1);
}
std::vector<TH3F*> DistortMap;
DistortMap.push_back((TH3F*) FieldFile->Get("Distortion_Field_X"));
DistortMap.push_back((TH3F*) FieldFile->Get("Distortion_Field_Y"));
DistortMap.push_back((TH3F*) FieldFile->Get("Distortion_Field_Z"));
// FieldFile->Close();
TFile* RecoFile = new TFile("RecoDispl.root","READ");
if (RecoFile->IsZombie())
{
std::cout << "Error opening reco file" << std::endl;
exit(-1);
}
std::vector<TH3F*> ReconstructionMap;
ReconstructionMap.push_back((TH3F*) RecoFile->Get("Reco_Displacement_X"));
ReconstructionMap.push_back((TH3F*) RecoFile->Get("Reco_Displacement_Y"));
ReconstructionMap.push_back((TH3F*) RecoFile->Get("Reco_Displacement_Z"));
// ReconstructionMap.push_back((TH3F*) RecoFile->Get("Reco_Field_X"));
// RecoFile->Close();
int Nxbins = ReconstructionMap[0]->GetNbinsX();
int Nybins = ReconstructionMap[0]->GetNbinsY();
int Nzbins = ReconstructionMap[0]->GetNbinsZ();
// unsigned int MaximumBin[3];
// unsigned int MinimumBin[3];
// double Maximum[3];
// double Minimum[3];
// for(unsigned coord = 0; coord < 3; coord++)
// {
// MaximumBin[coord] = ReconstructionMap[coord]->GetMaximumBin();
// MinimumBin[coord] = ReconstructionMap[coord]->GetMinimumBin();
// Maximum[coord] = ReconstructionMap[coord]->GetMaximum();
// Minimum[coord] = ReconstructionMap[coord]->GetMinimum();
// Maximum[coord] = ReconstructionMap[coord]->GetBinContent(MaximumBin);
// Minimum[coord] = ReconstructionMap[coord]->GetBinContent(MinimumBin);
// }
int Smoothing = 3; // order of smoothing
int SRange = (int)(Smoothing/2.);
int Nelements; // # pixels used for smoothing
// for(int coord = 0; coord < 3; coord++)
// {
// ReconstructionMap[3] = ReconstructionMap[coord];
// for(int xbin = 1; xbin <= Nxbins; xbin++) for(int ybin = 1; ybin <= Nybins; ybin++) for(int zbin = 1; zbin <= Nzbins; zbin++)
// {
// Nelements = 0;
// double SmoothEntry = 0.;
// for(int dx = -SRange; dx <= SRange; dx++) for(int dy = -SRange; dy <= SRange; dy++) for(int dz = -SRange; dz <= SRange; dz++)
// {
// if(xbin+dx > 1 && xbin+dx <= Nxbins && ybin+dy > 1 && ybin+dy <= Nybins && zbin+dz > 1 && zbin+dz <= Nzbins)
// {
// Nelements++;
// SmoothEntry += ReconstructionMap[coord]->GetBinContent(xbin+dx,ybin+dy,zbin+dz);
// }
// }
// SmoothEntry /= (double)Nelements;
// ReconstructionMap[3]->SetBinContent(xbin,ybin,zbin,SmoothEntry);
// }
// ReconstructionMap[coord] = ReconstructionMap[3];
// }
// delete ReconstructionMap[3];
// ReconstructionMap.pop_back();
std::vector<TH2F*> ProjectionXZ;
ProjectionXZ.push_back(new TH2F("Reco Map X","Reco Map X",kResolution[2],0,kDetector[2],kResolution[0],0,kDetector[0]));
ProjectionXZ.push_back(new TH2F("Reco Map Y","Reco Map Y",kResolution[2],0,kDetector[2],kResolution[0],0,kDetector[0]));
ProjectionXZ.push_back(new TH2F("Reco Map Z","Reco Map Z",kResolution[2],0,kDetector[2],kResolution[0],0,kDetector[0]));
int MinBin = 1+SRange;
for (int ybin = MinBin; ybin <= kResolution[1]-SRange; ybin++)
{
for (int xbin = MinBin; xbin <= kResolution[0]-SRange; xbin++) for (int zbin = MinBin; zbin <= kResolution[2]-SRange; zbin++)
{
// One Laser
for (int coord = 0; coord < 3; coord++) ProjectionXZ[coord] -> SetBinContent(zbin,xbin,ReconstructionMap[coord]->GetBinContent(xbin,ybin,zbin));
// Two laser approach in symmetric distributions
// for (int coord = 0; coord < 3; coord++)
// ProjectionXZ[coord] -> SetBinContent(zbin,xbin,(-ReconstructionMap[coord]->GetBinContent(xbin,ybin,zbin)-ReconstructionMap[coord]->GetBinContent(xbin,ybin,kResolution[3]-zbin+1))/2.0);
}
for (int coord = 0; coord < 3; coord++) ProjectionXZ[coord] -> SetStats(0);
float Limit = 20.;
ProjectionXZ[0] -> SetMaximum(Limit);
ProjectionXZ[0] -> SetMinimum(-Limit);
ProjectionXZ[1] -> SetMaximum(Limit);
ProjectionXZ[1] -> SetMinimum(-Limit);
ProjectionXZ[2] -> SetMaximum(Limit);
ProjectionXZ[2] -> SetMinimum(-Limit);
TCanvas * C1 = new TCanvas("Reco Map X","Reco Map X",1000,500);
ProjectionXZ[0] -> Draw("colz");
C1 -> Print("DisplacementX.gif+5","gif+5");
TCanvas * C2 = new TCanvas("Reco Map Y","Reco Map Y",1000,500);
ProjectionXZ[1] -> Draw("colz");
C2 -> Print("DisplacementY.gif+5","gif+5");
TCanvas * C3 = new TCanvas("Reco Map Z","Reco Map Z",1000,500);
ProjectionXZ[2] -> Draw("colz");
C3 -> Print("DisplacementZ.gif+5","gif+5");
delete C1;
delete C2;
delete C3;
}
for (int ybin = MinBin; ybin <= kResolution[1]-SRange; ybin++)
{
for (int xbin = MinBin; xbin <= kResolution[0]-SRange; xbin++) for (int zbin = MinBin; zbin <= kResolution[2]-SRange; zbin++)
{
// One laser
for (int coord = 0; coord < 3; coord++) ProjectionXZ[coord] -> SetBinContent(zbin,xbin,(ReconstructionMap[coord]->GetBinContent(xbin,ybin,zbin)-DistortMap[coord]->GetBinContent(xbin,ybin,zbin)));
// Two lasers
// for (int coord = 0; coord < 3; coord++)
// ProjectionXZ[coord] -> SetBinContent(zbin,xbin,(ReconstructionMap[coord]->GetBinContent(xbin,ybin,zbin)+ReconstructionMap[coord]->GetBinContent(xbin,ybin,kResolution[3]-zbin+1))/2.0+DistortMap[coord]->GetBinContent(xbin,ybin,zbin));
}
for (int coord = 0; coord < 3; coord++) ProjectionXZ[coord] -> SetStats(0);
ProjectionXZ[0] -> SetMaximum(0.01);
ProjectionXZ[0] -> SetMinimum(-0.01);
ProjectionXZ[1] -> SetMaximum(0.015);
ProjectionXZ[1] -> SetMinimum(-0.015);
ProjectionXZ[2] -> SetMaximum(0.05);
ProjectionXZ[2] -> SetMinimum(-0.05);
TCanvas * C1 = new TCanvas("Residual Map X","Residual Map X",1000,500);
ProjectionXZ[0] -> Draw("colz");
C1 -> Print("ResidualX.gif+5","gif+50");
TCanvas * C2 = new TCanvas("Residual Map Y","Residual Map Y",1000,500);
ProjectionXZ[1] -> Draw("colz");
C2 -> Print("ResidualY.gif+5","gif+50");
TCanvas * C3 = new TCanvas("Residual Map Z","Residual Map Z",1000,500);
ProjectionXZ[2] -> Draw("colz");
C3 -> Print("ResidualZ.gif+5","gif+50");
delete C1;
delete C2;
delete C3;
}
// for(int coord = 0; coord < 3; coord++)
// {
// delete DistortMap[coord];
// delete ReconstructionMap[coord];
// delete ProjectionXZ[coord];
// }
// FieldFile->Close();
// RecoFile->Close();
};