forked from JeffersonLab/EVe_HallC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScintillatorPaddle.cxx
163 lines (128 loc) · 4.46 KB
/
ScintillatorPaddle.cxx
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
///////////////////////////////////////
/* ScintillatorPaddle.cxx 6/16/14
Ben Davis-Purcell
This class creates the planar view of a single scintillation paddle
including PMTs
*/
///////////////////////////////////////
#include "ScintillatorPaddle.h"
#include "TMath.h"
#include <cstring>
#include <cstdio>
#include <iostream>
#include <sstream>
using namespace std;
void rotranspaddle (double angle, double* xL, double* yL, double* xR, double* yR, double* xscint, double* yscint,double sx0,double sy0);
void rotransline(double ang, double* x, double* y, double sx0, double sy0,int size);
ScintillatorPaddle::ScintillatorPaddle(int index, double x, double y, double a, double b, double cx0,double cy0, int PMTn, double PMTlength, double ang)
{
// In parameter of ScintillatorPaddle:
// index is the index of the single Paddle in a ScintPlane
// x and y are the coords of the center of the ScintPlane in the canvas
// a is the horizontal size of the PMT
// b is the vertical size of the PMT
// cx0,cy0 is the coordinate of lower left corner of the paddle with this index
// PMTn is the number of PMTs on the scintillator paddle (1 or 2)
// ang is the angle of the scintplane, ang = 0 got horizontal plane while ang = 90 vertical plane
sx0 = x;
sy0 = y;
sa = a;
sb = b;
// paddle_length = length;
n = PMTn;
angle=ang;
cx0=cx0-PMTlength;
cy0=cy0;
pl=PMTlength;
//consider sypaddle length is different from sxpaddle length
// xL ,yL are the coordinates of endpoints of Left PMT
double xL[7] = {pl*0.0 + cx0 ,pl*0.42857 + cx0 ,pl + cx0 , pl +cx0 , pl*0.42857 + cx0 , pl*0.0 + cx0 , pl*0.0 + cx0 };
double yL[7] = {b*0.7 + cy0, b*0.7 + cy0, b + cy0, b*0.0 + cy0, b*0.3 + cy0, b*0.3 + cy0, b*0.7 + cy0};
// xR ,yR are the coordinates of endpoints of Right PMT
double xR[7] = {a+pl + cx0 ,a+pl*(2-0.42857) + cx0 ,a+2*pl + cx0 ,a+2*pl + cx0 ,a+pl*(2-0.42857) + cx0 , a+pl + cx0 , a+pl + cx0 };
double yR[7] = {b + cy0 , b*0.7 + cy0, b*0.7 + cy0, b*0.3 + cy0, b*0.3 + cy0, b*0.0 + cy0, b + cy0};
// xscint, yscint are the coordinates of endpoints of scintillator paddle
double xscint[5] = {pl + cx0, a+pl + cx0, a+pl + cx0, pl + cx0, pl + cx0};
double yscint[5] = {b*0.0 + cy0, b*0.0 + cy0, b + cy0,b + cy0, b*0.0 + cy0};
double* xl=xL;
double* yl=yL;
double* xr=xR;
double* yr=yR;
double* xs=xscint;
double* ys=yscint;
double xT=a*1.0+2*pl+cx0;
double yT=b*0.125+cy0;
double* tx=& xT;
double* ty=& yT;
// rotate angle (in unit degree) to setup horizontal or vertical scintplane
rotranspaddle (angle, xl, yl, xr, yr, xs, ys, sx0,sy0);
rotransline(angle, tx, ty,sx0,sy0,1);
plineL = new TPolyLine(7,xL,yL);
plineL->SetFillColor(38);
plineL->SetLineColor(1);
plineL->SetLineWidth(1);
plineL->Draw("f");
plineL->Draw();
plineR = new TPolyLine(7,xR,yR);
plineR->SetFillColor(38);
plineR->SetLineColor(1);
plineR->SetLineWidth(1);
plineR->Draw("f");
plineR->Draw();
scint = new TPolyLine(5,xscint,yscint);
scint->SetFillColor(38);
scint->SetLineColor(1);
scint->SetLineWidth(1);
scint->Draw("f");
scint->Draw();
TString Buff;
Buff="";
Buff+=(index+1);
const char *name = Buff.Data();
index_text = new TLatex((Double_t)xT,(Double_t)yT, name);
index_text->SetTextSize(0.02);
index_text->Draw();
}
void rotranspaddle(double angle, double * xL, double * yL, double * xR, double * yR, double * xscint, double * yscint,double sx0,double sy0)
{
rotransline(angle, xL, yL,sx0,sy0,7);
rotransline(angle, xR, yR,sx0,sy0,7);
rotransline(angle, xscint, yscint,sx0,sy0,5);
}
void rotransline(double ang, double * x, double * y,double sx0, double sy0, int size)
{
ang*=(3.1415926/180);
for (int i=0; i< size; i++)
{
double tempx=x[i]*cos(ang)-y[i]*sin(ang);
double tempy=x[i]*sin(ang)+y[i]*cos(ang);
x[i]=tempx;
y[i]=tempy;
}
for (int i=0; i<size; i++) {
x[i]=x[i]+sx0;
y[i]=y[i]+sy0;
}
}
ScintillatorPaddle::~ScintillatorPaddle()
{
//Destructor
}
void ScintillatorPaddle::HitLeft()
{
plineL->SetFillColor(kGreen);
}
void ScintillatorPaddle::HitRight()
{
plineR->SetFillColor(kGreen);
}
void ScintillatorPaddle::HitPaddle()
{
scint->SetFillColor(kGreen);
}
void ScintillatorPaddle::clear()
{
plineR->SetFillColor(38);
plineL->SetFillColor(38);
scint->SetFillColor(38);
}