forked from JeffersonLab/EVe_HallC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScintPlane.cxx
170 lines (128 loc) · 4.3 KB
/
ScintPlane.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
164
165
166
167
168
169
170
///////////////////////////////////////
/* ScintPlane.cxx 6/17/14
Ben Davis-Purcell
Class that creates an array of ScintillationPaddles to create a plane
*/
///////////////////////////////////////
#include "ScintPlane.h"
#include "TMath.h"
#include <cstring>
#include <cstdio>
#include <iostream>
using namespace std;
ScintPlane::ScintPlane(char *name, int n, double plength, double pheight, double PMTlength, CStransform *trans, double ang)
{
// Converting plenth & pheight [m] into pixels
cst = trans;
N = n;
paddle_length = plength;
paddle_height = pheight;
PMTl=cst->transLtoCL(PMTlength);
//horiz = horizontal;
angle=ang;
std::string geometry = "HMS.txt";
GetVariables *pmt = new GetVariables(geometry);
//// FIXME:: convert to HMS units
double fpaddleH = 0.25; /// 0.25 ????
//double fpaddleL = 0.5625; /// 0.5625 before -- why these values??
int numPMT = pmt->GetInt("Number of paddle PMTs =");
// cout << horiz << " horiiz" << endl;
/*if (horiz == 1) {
rot = 1;
}
else {
rot =0;
}*/
/// FIXME:: Conversion between canvas units and actual units goes back and forth. Rotation hard-coded into ScintillatorPaddle class but does not match up with this class - scaling factors need to be fixed
sx0 = cst->transXtoCX(0.0); ;
sy0 = cst->transYtoCY(0.0); ;
double cx0= - cst->transLtoCL(paddle_length/2.0);
double cy0= cst->transLtoCL(paddle_height*(N)/2.0 - paddle_height);
double CL = cst->transLtoCL(paddle_length);
double CH = cst->transLtoCL(paddle_height);
//sa = CL/fpaddleL;
//Consider sxpaddle length is different from sypaddle length
sa=CL;
sb = CH/fpaddleH;
/// sa and sb should be removed and left as CL and CH to be read into
/// ScintillatorPaddle -- scaling needs to be fixed in both classes
for (int i=0; i<n ;i++){
paddle[i]=new ScintillatorPaddle(i, sx0, sy0, sa ,sb ,cx0,cy0-i*CH, numPMT, PMTl,angle);}
title = new TLatex(sx0-0.2*sa, sy0-2.40*sb, name);
title->SetTextSize(0.03);
title->Draw();
/*if (horiz == 1) {
for(int i=0;i<n;i++) {
paddle[i] = new ScintillatorPaddle(i, sx0, sy0-i*CH, sa, sb, paddle_length, numPMT, rot);}
title = new TLatex(sx0+sa*0.35-sa*0.3,sy0+sb*0.35, name);
title->SetTextSize(0.03);
title->Draw();
}
else {
for(int i=0;i<n;i++) {
paddle[i] = new ScintillatorPaddle(i, sx0, sy0+i*CH, sa, sb, paddle_length, numPMT, rot);
}
title = new TLatex(sy0, sx0-1.5*sb, name);
title->SetTextSize(0.03);
title->Draw();
}*/
for(int i = 0; i<MAX_TRACK_NUM; i++)track_circ[i] = new TEllipse(0,0,0);
cout<<"Scintillation Plane is created!"<<endl;
}
ScintPlane::~ScintPlane()
{
// Destructor
}
/* paddleHit() will turn on PMTs for paddle <num> if the TDC data in <left> and <right> correspond to a good hit.
*/ // -- OLD hit method
void ScintPlane::paddleHit(int num, double left, double right, double y)
{
if (num<N)
{
paddle[num]->hit(left,right,y);
}
}
/// NEW hit method used for tdchits. Needs to be implemented in ScintPlane3D
void ScintPlane::paddleLeftHit(int padn)
{
if(padn<0) cerr << "Negative paddle index" << padn <<" \n";
else
paddle[padn]->HitLeft();
}
void ScintPlane::paddleRightHit(int pad)
{ if(pad<0) cerr << "Negative paddle index" << pad <<" \n";
else
paddle[pad]->HitRight();
}
void ScintPlane::paddleBothHit(int padnum)
{if(padnum<0) cerr << "Negative paddle index" << padnum <<" \n";
else
paddle[padnum]->HitBoth();
}
void ScintPlane::clear()
{
for(int i = 0; i<N; i++) {
paddle[i]->clear();
}
for(int i=0;i<MAX_TRACK_NUM;i++) {
track_circ[i]->SetX1(0.0);
track_circ[i]->SetY1(0.0);
track_circ[i]->SetR1(0.0);
track_circ[i]->SetR2(0.0);
track_circ[i]->SetFillColor(kWhite);
track_circ[i]->Draw();
delete track_index[i];
}
}
void ScintPlane::Track(double x, double y, int i)
{
double CX = cst->transXtoCX(x);
double CY = cst->transYtoCY(y);
track_circ[i]->SetX1(CX);
track_circ[i]->SetY1(CY);
track_circ[i]->SetR1(0.008);
track_circ[i]->SetR2(0.008);
track_circ[i]->SetLineColor(1+i);
track_circ[i]->SetLineWidth(2);
track_circ[i]->Draw();
}