60 {
61
63
64
65
66
67
68
69 G4VisAttributes* red = new G4VisAttributes(G4Colour(1, 0, 0));
70 red->SetForceAuxEdgeVisible(true);
71
72
73
74 G4VisAttributes* green = new G4VisAttributes(G4Colour(0, 1, 0));
75 green->SetForceAuxEdgeVisible(true);
76
77
78
79
80 G4VisAttributes* gray = new G4VisAttributes(G4Colour(.5, .5, .5));
81 gray->SetForceAuxEdgeVisible(true);
82 G4VisAttributes* yellow = new G4VisAttributes(G4Colour(1, 1, 0));
83 yellow->SetForceAuxEdgeVisible(true);
84
85
86
87
88
89
90
91
92
93
94
95
96 double stepSize = content.getLength("stepSize", 5 * CLHEP::um);
97
98
99
100
101
102
103
104
105
106
107
108 for (const GearDir& activeParams : content.getNodes("Active")) {
109
110 int phase = activeParams.getInt("phase");
111 G4double dx_pins = activeParams.getLength("dx_pins") / 2.*CLHEP::cm;
112 G4double dy_pins = activeParams.getLength("dy_pins") / 2.*CLHEP::cm;
113 G4double dz_pins = activeParams.getLength("dz_pins") / 2.*CLHEP::cm;
114
115 double x_pos[100];
116 double y_pos[100];
117 double z_pos[100];
118 double thetaX[100];
119 double thetaZ[100];
120 double thetaY[100];
121 double ch_wAu[100];
122 double ch_woAu[100];
123 double phi[100];
124 double r[100];
125
126 if (phase == 1) {
127 int dimwAu = 0;
128 for (int wAu : activeParams.getArray("Ch_wAu", {0})) {
129 ch_wAu[dimwAu] = wAu;
130 dimwAu++;
131 }
132 int dimwoAu = 0;
133 for (int woAu : activeParams.getArray("Ch_woAu", {0})) {
134 ch_woAu[dimwoAu] = woAu;
135 dimwoAu++;
136 }
137 int dimx = 0;
138 for (double x : activeParams.getArray("x", {0})) {
139 x *= CLHEP::cm;
140 x_pos[dimx] = x;
141 dimx++;
142 }
143 int dimy = 0;
144 for (double y : activeParams.getArray("y", {0})) {
145 y *= CLHEP::cm;
146 y_pos[dimy] = y;
147 r[dimy] =
sqrt(x_pos[dimy] * x_pos[dimy] + y_pos[dimy] * y_pos[dimy]);
148 double Phi = 0;
149 if (x_pos[dimy] >= 0) Phi = TMath::ASin(y_pos[dimy] / r[dimy]) * TMath::RadToDeg();
150 else Phi = -TMath::ASin(y_pos[dimy] / r[dimy]) * TMath::RadToDeg() + 180.;
151
152 phi[dimy] = Phi * CLHEP::deg - 90. * CLHEP::deg;
153 dimy++;
154 }
155 int dimThetaX = 0;
156 for (double ThetaX : activeParams.getArray("ThetaX", {0})) {
157 thetaX[dimThetaX] = ThetaX;
158 dimThetaX++;
159 }
160 int dimThetaY = 0;
161 for (double ThetaY : activeParams.getArray("ThetaY", {0})) {
162 thetaY[dimThetaY] = ThetaY;
163 dimThetaY++;
164 }
165 }
166 int dimPhi = 0;
167 if (phase == 2) {
168 for (int i = 0; i < 100; i++) {
169 x_pos[i] = 0;
170 y_pos[i] = 0;
171 z_pos[i] = 0;
172 }
173 for (double Phi : activeParams.getArray("Phi", {0})) {
174 phi[dimPhi] = Phi - 90. * CLHEP::deg;
175 dimPhi++;
176 }
177 int dimr_pin = 0;
178 for (double r_pin : activeParams.getArray("r_pin", {0})) {
179 r_pin *= CLHEP::cm;
180 r[dimr_pin] = r_pin;
181 dimr_pin++;
182 }
183 }
184 int dimz = 0;
185 for (double z : activeParams.getArray("z", {0})) {
186 z *= CLHEP::cm;
187 z_pos[dimz] = z;
188 dimz++;
189 }
190 int dimThetaZ = 0;
191 for (double ThetaZ : activeParams.getArray("ThetaZ", {0})) {
192 thetaZ[dimThetaZ] = ThetaZ;
193 dimThetaZ++;
194 }
195
196
197 G4double InchtoCm = 2.54 * CLHEP::cm;
198
199
200 G4double dz_airbox = 0.563 / 2. * InchtoCm;
201 G4double dx_airbox = 1. / 2. * InchtoCm;
202 G4double dy_airbox = 0.315 / 2. * InchtoCm;
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224 G4double dz_base = 0.5 / 2. * InchtoCm;
225 G4double dx_base = dx_airbox;
226 G4double dy_base = 0.25 / 2. * InchtoCm;
227 G4VSolid* s_base = new G4Box("s_base", dx_base, dy_base, dz_base);
228
229 G4double ir_hole = 0.;
230 G4double or_hole = 5. / 2.*CLHEP::mm;
231 G4double h_hole = 0.382 / 2. * InchtoCm;
232 G4double sA_hole = 0.*CLHEP::deg;
233 G4double spA_hole = 360.*CLHEP::deg;
234 G4VSolid* s_hole = new G4Tubs("s_hole", ir_hole, or_hole, h_hole, sA_hole, spA_hole);
235 G4double x_pos_hole = dx_base - 0.315 * InchtoCm;
236 G4double y_pos_hole = (0.187 - 0.250 / 2.) * InchtoCm;
237 G4double z_pos_hole = -(0.5 - 0.382) * InchtoCm;
238 s_base = new G4SubtractionSolid("s_base_hole1", s_base, s_hole, 0, G4ThreeVector(x_pos_hole, y_pos_hole, z_pos_hole));
239 s_base = new G4SubtractionSolid("s_base_hole2", s_base, s_hole, 0, G4ThreeVector(-x_pos_hole, y_pos_hole, z_pos_hole));
240
241
242
243
244 const double iTheta[4] = {0, 90, 180, 270};
245 G4LogicalVolume* l_base = new G4LogicalVolume(s_base, G4Material::GetMaterial("Al6061"), "l_base");
246 l_base->SetVisAttributes(yellow);
247 G4Transform3D transform;
248 for (int i = 0; i < dimz; i++) {
249 if (phase == 1) {
250 transform = G4Translate3D(x_pos[i], y_pos[i],
251 z_pos[i]) * G4RotateX3D(thetaX[i]) * G4RotateY3D(thetaY[i]) * G4RotateZ3D(thetaZ[i]);
252
253 new G4PVPlacement(transform, l_base, TString::Format("p_pin_base_%d", i).Data(), &topVolume, false, 0);
254 B2INFO("PIN base-" << (int)i / 4 << "-" << iTheta[i - ((int)i / 4) * 4] << " placed at: " << transform.getTranslation() << " mm ");
255 }
256 }
257
258
259
260
261
262
263
264 G4double dz_cover1 = dz_airbox;
265 G4double dx_cover1 = dx_airbox;
266 G4double dy_cover1 = dy_airbox - dy_base;
267 G4VSolid* s_cover1 = new G4Box("s_cover1", dx_cover1, dy_cover1, dz_cover1);
268
269 G4double dx_shole = (0.563 - 0.406) / 2. * InchtoCm;
270 G4VSolid* s_shole = new G4Box("s_shole", dx_shole, dy_cover1, dx_shole);
271 G4double x_pos_cover_hole = dx_base - 0.392 * InchtoCm + dx_shole;
272
273 G4double z_pos_cover_hole = dz_airbox - 0.406 * InchtoCm + dx_shole;
274 s_cover1 = new G4SubtractionSolid("s_cover1_hole1", s_cover1, s_shole, 0, G4ThreeVector(x_pos_cover_hole, 0, z_pos_cover_hole));
275 s_cover1 = new G4SubtractionSolid("s_cover1_hole2", s_cover1, s_shole, 0, G4ThreeVector(-x_pos_cover_hole, 0, z_pos_cover_hole));
276
277
278
279
280
281
282 G4LogicalVolume* l_cover1 = new G4LogicalVolume(s_cover1, G4Material::GetMaterial("Al6061"), "l_cover1");
283 l_cover1->SetVisAttributes(yellow);
284 for (int i = 0; i < dimz; i++) {
285 if (phase == 1) {
286 transform = G4Translate3D(x_pos[i], y_pos[i],
287 z_pos[i]) * G4RotateX3D(thetaX[i]) * G4RotateY3D(thetaY[i]) * G4RotateZ3D(thetaZ[i]) *
288 G4Translate3D(0., dy_base + dy_cover1, (dz_cover1 - dz_base) - dy_cover1 * 2.);
289
290
291 new G4PVPlacement(transform, l_cover1, TString::Format("p_pin_cover1_%d", i).Data(), &topVolume, false, 0);
292 }
293 }
294
295
296
297
298
299
300
301 G4double dz_cover2 = dz_airbox - dz_base;
302 G4double dx_cover2 = dx_airbox;
303 G4double dy_cover2 = dy_base;
304 G4VSolid* s_cover2 = new G4Box("s_cover2", dx_cover2, dy_cover2, dz_cover2);
305 G4LogicalVolume* l_cover2 = new G4LogicalVolume(s_cover2, G4Material::GetMaterial("Al6061"), "l_cover2");
306 l_cover2->SetVisAttributes(yellow);
307 for (int i = 0; i < dimz; i++) {
308 if (phase == 1) {
309 transform = G4Translate3D(x_pos[i], y_pos[i],
310 z_pos[i]) * G4RotateX3D(thetaX[i]) * G4RotateY3D(thetaY[i]) * G4RotateZ3D(thetaZ[i]) *
311 G4Translate3D(0., -2.*dy_cover1, - dz_base - dz_cover2);
312
313
314 new G4PVPlacement(transform, l_cover2, TString::Format("p_pin_cover2_%d", i).Data(), &topVolume, false, 0);
315 }
316 }
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340 G4double dx_pin = dx_pins;
341 G4double dz_pin = dz_pins;
342 G4double dy_pin = dy_pins;
343
344 G4VSolid* s_pin = new G4Box("s_pin", dx_pin, dy_pin, dz_pin);
346 l_pin->SetVisAttributes(yellow);
347 l_pin->SetUserLimits(new G4UserLimits(stepSize));
348 int detID = 0;
349 for (int i = 0; i < dimz; i++) {
350 int detID1 = 2 * i;
351 int detID2 = 2 * i + 1;
352
353
354
355
356 if (phase == 1) {
357
358 detID1 = ch_wAu[i];
359 detID2 = ch_woAu[i];
360
361 transform = G4Translate3D(x_pos[i], y_pos[i],
362 z_pos[i]) * G4RotateX3D(thetaX[i]) * G4RotateY3D(thetaY[i]) * G4RotateZ3D(thetaZ[i]) *
363 G4Translate3D((0.5 - 0.392) * InchtoCm + dx_shole, (0.187 - 0.250 / 2.) * InchtoCm + dy_pin,
364 (0.563 / 2. - 0.406) * InchtoCm + dx_shole * 2 - 0. - dz_pin);
365
366
367
368
369
370 new G4PVPlacement(transform, l_pin, TString::Format("p_pin_1_%d", i).Data(), &topVolume, false, detID1);
371 B2INFO("With Au PIN-" << detID1 << " placed at: " << transform.getTranslation() << " mm");
372
373 transform = G4Translate3D(x_pos[i], y_pos[i],
374 z_pos[i]) * G4RotateX3D(thetaX[i]) * G4RotateY3D(thetaY[i]) * G4RotateZ3D(thetaZ[i]) *
375 G4Translate3D(-(0.5 - 0.392) * InchtoCm - dx_shole, (0.187 - 0.250 / 2.) * InchtoCm + dy_pin,
376 (0.563 / 2. - 0.406) * InchtoCm + dx_shole * 2 - dz_pin);
377 new G4PVPlacement(transform, l_pin, TString::Format("p_pin_2_%d", i).Data(), &topVolume, false, detID2);
378 B2INFO(" PIN-" << detID2 << " placed at: " << transform.getTranslation() << " mm");
379 }
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394 if (phase == 2) {
395 for (int j = 0; j < dimPhi; j++) {
396 transform = G4RotateZ3D(phi[j]) * G4Translate3D(0, r[i], z_pos[i]) * G4RotateX3D(-M_PI / 2 - thetaZ[j]);
397 new G4PVPlacement(transform, l_pin, TString::Format("p_pin_%d", i).Data(), &topVolume, false, detID);
398 B2INFO("PIN-" << detID << " placed at: " << transform.getTranslation() << " mm");
399 detID ++;
400 }
401 }
402 }
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432 G4double dx_layer = 2.65 / 2.*CLHEP::mm;
433 G4double dz_layer = 2.65 / 2.*CLHEP::mm;
434 G4double dy_layer1 = 0.01 / 2.*CLHEP::mm;
435 G4VSolid* s_layer1 = new G4Box("s_layer1", dx_layer, dy_layer1, dz_layer);
437 l_layer1->SetVisAttributes(red);
438 for (int i = 0; i < dimz; i++) {
439 if (phase == 1) {
440 transform = G4Translate3D(x_pos[i], y_pos[i],
441 z_pos[i]) * G4RotateX3D(thetaX[i]) * G4RotateY3D(thetaY[i]) * G4RotateZ3D(thetaZ[i]) *
442 G4Translate3D((0.5 - 0.392) * InchtoCm + dx_shole, (0.187 - 0.250 / 2.) * InchtoCm + dy_layer1 + 2.* dy_pin,
443 (0.563 / 2. - 0.406) * InchtoCm + dx_shole * 2 - dz_pin);
444
445
446
447 new G4PVPlacement(transform, l_layer1, TString::Format("p_pin_layer1_%d", i).Data(), &topVolume, false, 0);
448 }
449 }
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464 G4double dy_layer2 = 0.001 / 2.*InchtoCm;
465 G4VSolid* s_layer2 = new G4Box("s_layer1", dx_layer, dy_layer2, dz_layer);
467 l_layer2->SetVisAttributes(green);
468 for (int i = 0; i < dimz; i++) {
469 if (phase == 1) {
470 transform = G4Translate3D(x_pos[i], y_pos[i],
471 z_pos[i]) * G4RotateX3D(thetaX[i]) * G4RotateY3D(thetaY[i]) * G4RotateZ3D(thetaZ[i]) *
472 G4Translate3D(-(0.5 - 0.392) * InchtoCm - dx_shole, (0.187 - 0.250 / 2.) * InchtoCm + dy_layer2 + 2. * dy_pin,
473 (0.563 / 2. - 0.406) * InchtoCm + dx_shole * 2 - dz_pin);
474
475
476
477 new G4PVPlacement(transform, l_layer2, TString::Format("p_pin_layer2_%d", i).Data(), &topVolume, false, 0);
478 }
479 }
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494 }
495 }
static G4Material * get(const std::string &name)
Find given material.
double sqrt(double a)
sqrt for double
VXD::SensitiveDetector< PXDSimHit, PXDTrueHit > SensitiveDetector
The PXD Sensitive Detector class.