SND@LHC Software
Loading...
Searching...
No Matches
UpstreamTaggerHit.cxx
Go to the documentation of this file.
1#include "UpstreamTaggerHit.h"
2#include "UpstreamTagger.h"
3#include "TVector3.h"
4#include "TMath.h"
5#include "TRandom1.h"
6#include "TRandom3.h"
7#include "TGeoManager.h"
8#include "TGeoBBox.h"
9#include "TGeoNode.h"
10#include "TRandom3.h"
11
12#include <iostream>
13#include <cmath>
14#include <stdlib.h> /* srand, rand */
15#include <cstdlib>
16#include <ctime>
17#include <time.h> /* time */
18
19using std::cout;
20using std::endl;
21
22Double_t speedOfLight = TMath::C() *100./1000000000.0 ; // from m/sec to cm/ns
23
24// ----- Default constructor --------------
30
31
32// ----- constructor from TimeDetPoint from TimeDetHit-------------------------------
34 : ShipHit()
35{
36
37 fDetectorID = p->GetDetectorID();
38 c0 = c;
39
40 Double_t a1, b1, c1;
41 a1 = p->GetX(); b1 = p->GetY(); c1 = p->GetZ();
42 const Double_t * point1[3];
43 point1[0] = &a1; point1[1] = &b1; point1[2] = &c1;
44 point_final[0] = *point1[0];point_final[1] = *point1[1];point_final[2] = *point1[2];
45
46 Double_t a2, b2, c2;
47 a2 = p->GetPx(); b2 = p->GetPy(); c2 = p->GetPz();
48 mom[0] = &a2; mom[1] = &b2; mom[2] = &c2;
49
50 Float_t lpos, lneg;
51 Dist(p->GetX(), lpos, lneg);
52 Double_t sigma = T_resol; // in ns
53 t_1 = gRandom->Gaus( 0, sigma ) + lneg/v_drift + t0 + p->GetTime();
54 t_2 = gRandom->Gaus( 0, sigma ) + lpos/v_drift + t0 + p->GetTime();
55
56}
57
58
59// ----- Destructor -------------------------
61
62// ---- return time information for a given track extrapolation
63std::vector<double> UpstreamTaggerHit::GetTime(Double_t x){
64 // calculate distance to left and right end
65 Float_t lpos, lneg;
66 Dist(x, lpos, lneg);
67 Double_t dt = T_resol;
68 Double_t t = ( (t_1-lneg/v_drift) + (t_2-lpos/v_drift) )/2;
69 std::vector<double> m;
70 m.push_back(t);
71 m.push_back(dt);
72 return m;
73}
74// ---- return mean time information
75std::vector<double> UpstreamTaggerHit::GetTime(){
76 TGeoBBox* shape = (TGeoBBox*)gGeoManager->GetVolume("UpstreamTagger")->GetShape();
77 Double_t t0;
78 if(RpcModule < 6)
79 t0 = (t_1+t_2)/2. - 114.5/v_drift;// strip length = 229 cm in x
80 else
81 t0 = (t_1+t_2)/2. - 55.5/v_drift;// strip length = 111 cm in y
82 Double_t dt = T_resol;
83 std::vector<double> m;
84 m.push_back(t0);
85 m.push_back(dt);
86 return m;
87}
88
90 std::vector<double> m;
91 m.push_back( t_1);
92 m.push_back( t_2);
93 return m;
94}
95
96// distance to edges
97void UpstreamTaggerHit::Dist(Float_t x, Float_t& lpos, Float_t& lneg){
98
99 Double_t hit_final;
100 Int_t mod;
101 TGeoNode* node = GetNode(hit_final, mod);
102 auto shape = dynamic_cast<TGeoBBox*>(node->GetVolume()->GetShape());
103 TVector3 pos = GetXYZ();
104 if(mod > 0 && mod < 6){
105 lpos = TMath::Abs( pos.X() + 114.5 - hit_final ); // strip length = 229 cm in x
106 lneg = TMath::Abs( pos.X() - 114.5 - hit_final );
107 }
108 else if (mod >= 6){
109 lpos = TMath::Abs( pos.Y() + 55.5 - hit_final ); // strip length = 111 cm in y
110 lneg = TMath::Abs( pos.Y() - 55.5 - hit_final );
111 }
112}
113// ----------------------------------------------
115{
116 Double_t hit_final;
117 Int_t mod;
118 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
119 TGeoNode* node = GetNode(hit_final, mod);
120 auto shape = dynamic_cast<TGeoBBox*>(node->GetVolume()->GetShape());
121 Double_t origin[3] = {shape->GetOrigin()[0],shape->GetOrigin()[1],shape->GetOrigin()[2]};
122 Double_t master[3] = {0,0,0};
123 nav->LocalToMaster(origin,master);
124 TVector3 pos = TVector3(master[0],master[1],master[2]);
125 return pos;
126}
127
128
130{ TVector3 pos = GetXYZ();
131 return pos.X();
132}
133
134
136{ TVector3 pos = GetXYZ();
137 return pos.Y();
138}
139
140
142{ TVector3 pos = GetXYZ();
143 return pos.Z();
144}
145
146
147TGeoNode* UpstreamTaggerHit::GetNode(Double_t &hit_final, Int_t &mod)
148{
149 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
150 mod = 0;
151
152 Double_t XHit1 = point_final[0];
153 Double_t YHit1 = point_final[1];
154 Double_t ZHit1 = point_final[2];
155
156 const Double_t PxHit1 = *mom[0];
157 const Double_t PyHit1 = *mom[1];
158 const Double_t PzHit1 = *mom[2];
159
160 Double_t Ymodule1 = -1000;
161 Double_t Zmodule1 = 0;
162 Double_t Xmodule11 = -1000;
163 Double_t Zmodule11 = 0;
164 Double_t dist1 = 1000;
165
166 Int_t flag0 = 1;
167
168 c0->ybox_fulldet = 499; //resize box to define the modules position from active area of the detectors (discounting the aluminium box + acrilic)
169
170 //First Layer of full Rpc detector covering 2.23 x 4.99 meters with 32 strips
171 c0->module[1][0] = 0; c0->module[1][1] = ((c0->ybox_fulldet/2.0) - ((c0->det_yGlassPos)/2.0)); c0->module[1][2] = (-(c0->zbox_fulldet/2.0) + (c0->det_zAlPos/2.0) + c0->det_dzAlPos);
172 c0->module[2][0] = 0; c0->module[2][1] = 0; c0->module[2][2] = (-(c0->zbox_fulldet/2.0) + (c0->det_zAlPos/2.0) + c0->det_dzAlPos);
173 c0->module[3][0] = 0; c0->module[3][1] = -((c0->ybox_fulldet/2.0) - ((c0->det_yGlassPos)/2.0)); c0->module[3][2] = (-(c0->zbox_fulldet/2.0) + (c0->det_zAlPos/2.0) + c0->det_dzAlPos);
174
175 //Second Layer of full Rpc detector covering 2.23 x 4.99 meters with 32 strips
176 c0->module[4][0] = 0; c0->module[4][1] = ((c0->ybox_fulldet/2.0) - ((c0->det_yGlassPos)) - ((c0->det_yGlassPos)/2.0) + c0->extra_y); c0->module[4][2] = (-(c0->zbox_fulldet/2.0) + c0->det_zAlPos + c0->det_dzAlPos*3.0 + c0->z_space_layers + (c0->det_zAlPos/2.0));
177 c0->module[5][0] = 0; c0->module[5][1] = -((c0->ybox_fulldet/2.0) - ((c0->det_yGlassPos)) - ((c0->det_yGlassPos)/2.0) + c0->extra_y); c0->module[5][2] = (-(c0->zbox_fulldet/2.0) + c0->det_zAlPos + c0->det_dzAlPos*3.0 + c0->z_space_layers + (c0->det_zAlPos/2.0));
178
179 //Third Layer of full Rpc detector covering 2.23 x 4.99 meters with 64 strips
180 c0->module[6][0] = 0; c0->module[6][1] = ((c0->ybox_fulldet/2.0) - ((c0->det_yGlassPos)/2.0)); c0->module[6][2] = (-(c0->zbox_fulldet/2.0) + (c0->det_zAlPos*2.0) + c0->det_dzAlPos*5.0 + (c0->z_space_layers*2.0) + (c0->det_zAlPos/2.0));
181 c0->module[7][0] = 0; c0->module[7][1] = 0; c0->module[7][2] = (-(c0->zbox_fulldet/2.0) + (c0->det_zAlPos*2.0) + c0->det_dzAlPos*5.0 + (c0->z_space_layers*3.0) + (c0->det_zAlPos/2.0));
182 c0->module[8][0] = 0; c0->module[8][1] = -((c0->ybox_fulldet/2.0) - ((c0->det_yGlassPos)/2.0)); c0->module[8][2] = (-(c0->zbox_fulldet/2.0) + (c0->det_zAlPos*2.0) + c0->det_dzAlPos*5.0 + (c0->z_space_layers*2.0) + (c0->det_zAlPos/2.0));
183
184 //Fourth Layer of full Rpc detector covering 2.23 x 4.99 meters with 64 strips
185 c0->module[9][0] = 0; c0->module[9][1] = ((c0->ybox_fulldet/2.0) - ((c0->det_yGlassPos)) - ((c0->det_yGlassPos)/2.0) + c0->extra_y); c0->module[9][2] = (-(c0->zbox_fulldet/2.0) + (c0->det_zAlPos*3.0) + c0->det_dzAlPos*7.0 + (c0->z_space_layers*3.0) + (c0->det_zAlPos/2.0));
186 c0->module[10][0] = 0; c0->module[10][1] = -((c0->ybox_fulldet/2.0) - ((c0->det_yGlassPos)) - ((c0->det_yGlassPos)/2.0) + c0->extra_y); c0->module[10][2] = (-(c0->zbox_fulldet/2.0) + (c0->det_zAlPos*3.0) + c0->det_dzAlPos*7.0 + (c0->z_space_layers*3.0) + (c0->det_zAlPos/2.0));
187
188
189 for(int i = 1; i<= 10; i++){
190
191 if(XHit1 >= c0->module[i][0] - (c0->det_xGlassPos)/2.0 && XHit1 <= c0->module[i][0] + (c0->det_xGlassPos)/2.0 && YHit1 >= c0->module[i][1] - (c0->det_yGlassPos)/2.0 && YHit1 <= c0->module[i][1] + (c0->det_yGlassPos)/2.0 && ZHit1 >= c0->det_zPos + (c0->module[i][2] - (c0->det_zAlPos+2*c0->det_dzAlPos)/2.0) && ZHit1 <= c0->det_zPos + (c0->module[i][2] + (c0->det_zAlPos+2*c0->det_dzAlPos)/2.0)){
192
193
194 if(fabs(c0->det_zPos + c0->module[i][2] - ZHit1) < dist1){
195
196 if (flag0){
197 RpcDetector = 1;
198 mod = i;
199 }
200 else{
201 RpcDetector = 2;
202 mod = i+10;
203 }
204
205 if(i < 6){
206 Zmodule1 = c0->det_zPos + c0->module[i][2] + c0->det_zAlPos - c0->det_zStripPos;
207 Ymodule1 = c0->module[i][1] - (c0->det_yGlassPos + 2*c0->det_yGlassBorderPos)/2.0 + 1.5;
208 }
209 else{
210 Zmodule11 = c0->det_zPos + c0->module[i][2] + c0->det_zAlPos - c0->det_zStripPos;
211 Xmodule11 = c0->module[i][0] - (c0->det_xGlassPos + 2*c0->det_xGlassBorderPos)/2.0 + 2.175;
212 }
213 dist1 = fabs(c0->det_zPos + c0->module[i][2] - ZHit1);
214 }
215 }
216 if(i == 10 && flag0){
217 Double_t tmp = -c0->module[6][2];
218 Double_t tmp1 = -c0->module[4][2];
219 Double_t tmp2 = -c0->module[1][2];
220
221 c0->module[1][2] = -c0->module[9][2];
222 c0->module[2][2] = -c0->module[9][2];
223 c0->module[3][2] = -c0->module[9][2];
224 c0->module[4][2] = tmp;
225 c0->module[5][2] = tmp;
226
227 c0->module[6][2] = tmp1;
228 c0->module[7][2] = tmp1;
229 c0->module[8][2] = tmp1;
230 c0->module[9][2] = tmp2;
231 c0->module[10][2] = tmp2;
232
233 i = 0;
234 flag0 = 0;
235 }
236 }
237
238 Double_t glass = -1;
239 if(fDetectorID == 169)
240 glass = 1;
241 else if(fDetectorID == 170)
242 glass = 2;
243 else if(fDetectorID == 171)
244 glass = 3;
245 if(fDetectorID == 238)
246 glass = 4;
247 else if(fDetectorID == 239)
248 glass = 5;
249 else if(fDetectorID == 240)
250 glass = 6;
251
252 Int_t Strip = -1;
253 Int_t str = -1;
254 Double_t X = -1;
255 Double_t Y = -1;
256
257 if(Zmodule1 != 0){
258
259 Double_t Z = Zmodule1 - ZHit1;
260 X = XHit1 + (Z*(PxHit1/TMath::Sqrt(PxHit1*PxHit1 + PyHit1*PyHit1 + PzHit1*PzHit1)));
261 Y = YHit1 + (Z*(PyHit1/TMath::Sqrt(PxHit1*PxHit1 + PyHit1*PyHit1 + PzHit1*PzHit1)));
262
263 Double_t count_strips = -1;
264 Int_t counter = 0;
265
266 for(int i = 1; i <= 32; i++){
267
268 count_strips = Ymodule1 + i*(c0->det_yStripPos+0.15);
269 counter++;
270
271 if(Y >= (count_strips - 3.25) && Y < count_strips){
272
273 if(Y > count_strips - 0.075)
274 Strip = counter + 1;
275 else
276 Strip = counter;
277
278 if(Y > count_strips - (3.25/2.0))
279 str = 2;
280 else
281 str = 1;
282
283 break;
284 }
285 }
286 }
287
288 if(Zmodule11 != 0){
289
290 Double_t Z = Zmodule11 - ZHit1;
291 X = XHit1 + (Z*(PxHit1/TMath::Sqrt(PxHit1*PxHit1 + PyHit1*PyHit1 + PzHit1*PzHit1)));
292 Y = YHit1 + (Z*(PyHit1/TMath::Sqrt(PxHit1*PxHit1 + PyHit1*PyHit1 + PzHit1*PzHit1)));
293
294 Double_t count_strips = -1;
295 Int_t counter = 0;
296
297 for(int i = 1; i <= 64; i++){
298
299 count_strips = Xmodule11 + i*(c0->det_xStripPos64+0.15);
300 counter++;
301
302 if(X >= (count_strips - 3.45) && X < count_strips){
303
304 if(X > count_strips - 0.075)
305 Strip = counter + 1;
306 else
307 Strip = counter;
308
309 if(X > count_strips - (3.45/2.0))
310 str = 2;
311 else
312 str = 1;
313
314 break;
315 }
316 }
317 }
318
319 RpcModule = mod;
320 RpcGlass = glass;
321 RpcStrip = Strip;
322 Rpc_NeighbourStrip = str;
323
324 if(Zmodule1 != 0)
325 hit_final = X;
326 if(Zmodule11 != 0)
327 hit_final = Y;
328
329 TString path, path1;
330
331 if(mod >=6 && mod <= 10 || mod >= 16){
332 path = "/cave_1/Upstream_Tagger_1/UpstreamTagger1_";path+=mod;path+="/glass_upstreamtagger_";path+=fDetectorID;
333 Bool_t rc = nav->cd(path);
334 }
335 else{
336 path1 = "/cave_1/Upstream_Tagger_1/UpstreamTagger_";path1+=mod;path1+="/glass_upstreamtagger_";path1+=fDetectorID;
337 Bool_t rc = nav->cd(path1);
338 }
339
340 return nav->GetCurrentNode();
341}
342
343// ----- Public method Print -----------------------
345{
346 cout << "-I- UpstreamTaggerHit: UpstreamTagger hit " << " in detector " << fDetectorID << endl;
347 cout << " TDC left " << t_1 << " ns TDC right " << t_2 << " ns" << endl;
348}
349
350
351// -----------------------------------------------------
353
Int_t counter
Double_t m
Double_t speedOfLight
Int_t fDetectorID
Detector unique identifier.
Definition ShipHit.h:58
TGeoNode * GetNode(Double_t &hit_final, Int_t &mod)
std::vector< double > GetTime()
virtual void Print() const
const Double_t * mom[3]
Float_t t_2
TDC on both sides.
std::vector< double > GetMeasurements()
UpstreamTagger * c0
void Dist(Float_t x, Float_t &lpos, Float_t &lneg)
Double_t det_xGlassBorderPos
z-size of Active Glass plates
Double_t det_zStripPos
y-size of Strip for modules with 32 strips
Double_t z_space_layers
Double_t det_yGlassBorderPos
x-size of Inactive Glass plates
Double_t module[11][3]
Double_t det_zAlPos
y-size of Aluminium box
Double_t det_dzAlPos
y-thickness of Aluminium box
Double_t ybox_fulldet
Double_t det_xGlassPos
z-position of veto station
Double_t det_xStripPos64
z-size of Aluminium box
Double_t det_yStripPos
x-size of Strip for modules with 32 strips
Double_t det_zPos
energy loss
Double_t det_yGlassPos
x-size of Active Glass plates
Double_t zbox_fulldet
ClassImp(ecalContFact) ecalContFact