109{
110 gErrorIgnoreLevel = kFatal;
114
115 G4SDManager* SDman = G4SDManager::GetSDMpointer();
116 if (!besEMCSD) {
117 besEMCSD =
new BesEmcSD(
"CalorSD",
this,besEMCGeometry);
118 SDman->AddNewDetector( besEMCSD );
119 }
120
121
124 {
126
127 if(logicEMC){
128 physiEMC = new G4PVPlacement(0,
129 G4ThreeVector(0.0 ,0.0 ,0.0),
130 logicEMC,
"physicalEMC",logicBes,
false, 0,
CHECKLV0);
131 G4cout<<"logicEmc: === "<<logicEMC<<" physiEmc "<<physiEMC<<G4endl;
132
135 }
136 }
137 else {
138
139
140
141 DefineMaterials();
142 phiNbCrystals = (*besEMCGeometry).BSCNbPhi;
143 thetaNbCrystals = (*besEMCGeometry).BSCNbTheta*2;
144
145 G4double da=0.001*deg;
146
147
148
149
150 solidBSC = new G4Tubs("solidBSC",
151 (*besEMCGeometry).TaperRingRmin1,
152 (*besEMCGeometry).BSCRmax+(*besEMCGeometry).SPBarThickness+(*besEMCGeometry).SPBarThickness1+2.1*mm,
153 (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3+(*besEMCGeometry).EndRingDz,
154 0.*deg,
155 360.*deg);
156
157 solidESC = new G4Cons("solidESC",(*emcEnd).WorldRmin1,(*emcEnd).WorldRmax1,
158 (*emcEnd).WorldRmin2,(*emcEnd).WorldRmax2,
159 (*emcEnd).WorldDz/2,0.*deg,360.*deg);
160
161 solidEMC = new G4UnionSolid("solidEMC0",
162 solidBSC,
163 solidESC,
164 0,
165 G4ThreeVector(0,0,(*emcEnd).WorldZPosition));
166
167 G4RotationMatrix *rotateESC = new G4RotationMatrix();
168 rotateESC->rotateY(180.*deg);
169
170 solidEMC = new G4UnionSolid("solidEMC",
171 solidEMC,
172 solidESC,
173 rotateESC,
174 G4ThreeVector(0,0,-(*emcEnd).WorldZPosition));
175
176 logicEMC = new G4LogicalVolume(solidEMC,
177 G4Material::GetMaterial("Air"),
178 "logicalEMC");
179
180 physiEMC = new G4PVPlacement(0,
181 G4ThreeVector(),
182 logicEMC,
183 "physicalEMC",
184 logicBes,
185 false,
187
188 solidBSCWorld = new G4SubtractionSolid("solidBSCWorld0",
189 solidBSC,
190 solidESC,
191 0,
192 G4ThreeVector(0,0,(*emcEnd).WorldZPosition));
193
194 solidBSCWorld = new G4SubtractionSolid("solidBSCWorld",
195 solidBSCWorld,
196 solidESC,
197 rotateESC,
198 G4ThreeVector(0,0,-(*emcEnd).WorldZPosition));
199
200 logicBSCWorld = new G4LogicalVolume(solidBSCWorld,
201 G4Material::GetMaterial("Air"),
202 "logicalBSCWorld");
203
204 G4RotationMatrix *rotBSC = new G4RotationMatrix();
205 rotBSC->rotateY(180.*deg);
206 physiBSCWorld = new G4PVPlacement(rotBSC,
207 G4ThreeVector(),
208 logicBSCWorld,
209 "physicalBSCWorld",
210 logicEMC,
211 false,
213
214 G4RotationMatrix *rotateMatrix[200];
215 G4double oOp,ox,oy,oz;
216 G4double
delta = 0*deg;
217 G4ThreeVector axis = G4ThreeVector(0,0,0);
218 oOp=(*besEMCGeometry).BSCRmin/
sin(0.5*(*besEMCGeometry).BSCPhiDphi+90*deg)
219 *
sin((*besEMCGeometry).BSCAngleRotat);
220 G4double ll=(*besEMCGeometry).BSCCryLength;
221 G4double rr=(*besEMCGeometry).BSCRmin;
222 G4double oj=sqrt(ll*ll+rr*rr-2*ll*rr*
cos(180.*deg-(*besEMCGeometry).BSCAngleRotat));
223 G4double oij=90.*deg-(*besEMCGeometry).BSCPhiDphi/2.-(*besEMCGeometry).BSCAngleRotat;
224 G4double doj=asin(
sin(180.*deg-(*besEMCGeometry).BSCAngleRotat)/oj*ll);
225 G4double ioj=(*besEMCGeometry).BSCPhiDphi/2.+doj;
226 G4double ij=oj/
sin(oij)*
sin(ioj);
227 G4double dOp=rr/
sin(90.*deg-(*besEMCGeometry).BSCPhiDphi/2.)
228 *
sin(90.*deg+(*besEMCGeometry).BSCPhiDphi/2.-(*besEMCGeometry).BSCAngleRotat);
229 G4double cOp=rr/
sin(90.*deg+(*besEMCGeometry).BSCPhiDphi/2.)
230 *
sin(90.*deg-(*besEMCGeometry).BSCPhiDphi/2.-(*besEMCGeometry).BSCAngleRotat);
231 G4double ch=(dOp+ll)/
cos((*besEMCGeometry).BSCPhiDphi)-cOp;
232 G4double hi=(dOp+ll)*
tan((*besEMCGeometry).BSCPhiDphi)-ij;
233 G4double oh=sqrt(ch*ch+rr*rr-2*ch*rr*
cos(180*deg-(*besEMCGeometry).BSCAngleRotat));
234 G4double hoi=asin(
sin(180*deg-oij)/oh*hi);
235 G4double dok=asin(
sin(180*deg-(*besEMCGeometry).BSCAngleRotat)/oh*ch);
236 if(verboseLevel>3)
237 G4cout << "oj=" <<oj/cm<<G4endl
238 << "oij="<<oij/deg<<G4endl
239 << "doj="<<doj/deg<<G4endl
240 << "ioj="<<ioj/deg<<G4endl
241 << "ij="<<ij/cm<<G4endl
242 << "dOp="<<dOp/cm<<G4endl
243 << "cOp="<<cOp/cm<<G4endl
244 << "ch="<<ch/cm<<G4endl
245 << "hi="<<hi/cm<<G4endl
246 << "oh="<<oh/cm<<G4endl
247 << "hoi="<<hoi/deg<<G4endl
248 << "dok="<<dok/deg<<G4endl;
249
250
251 G4double cmo = asin(
sin(180*degree-(*besEMCGeometry).BSCAngleRotat)/(*besEMCGeometry).BSCRmax2*dOp);
252 G4double cm = (*besEMCGeometry).BSCRmax2/
sin(180*degree-(*besEMCGeometry).BSCAngleRotat)*
sin((*besEMCGeometry).BSCAngleRotat-cmo);
253 G4ThreeVector Pout(dOp+cm*
cos((*besEMCGeometry).BSCAngleRotat),-cm*
sin((*besEMCGeometry).BSCAngleRotat),(*besEMCGeometry).BSCDz);
254
255 G4double rTaperRingOuter1 = (*besEMCGeometry).TaperRingRmin1+(*besEMCGeometry).TaperRingThickness1;
256 G4double rTaperRingOuter2 = (*besEMCGeometry).TaperRingRmin2+(*besEMCGeometry).TaperRingDr;
257 G4double zTaperRing1 = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3-(*besEMCGeometry).TaperRingDz;
258 G4double zTaperRing2 = (*besEMCGeometry).BSCDz+(*besEMCGeometry).TaperRingThickness3;
259
260 G4RotationMatrix* rotIntersection = new G4RotationMatrix();
261 rotIntersection->rotateZ(-(*besEMCGeometry).BSCAngleRotat-(*besEMCGeometry).BSCPhiDphi/2.-hoi);
262 G4ThreeVector
P(oOp*
cos(-90.*deg+(*besEMCGeometry).BSCAngleRotat+hoi), oOp*
sin(-90.*deg+(*besEMCGeometry).BSCAngleRotat+hoi), 0);
263 G4AffineTransform Td(rotIntersection,
P);
264 G4ThreeVector md = Td.Inverse().TransformPoint(G4ThreeVector(0,0,0));
265 G4ThreeVector vd = Td.Inverse().TransformPoint(Pout);
266
267 G4double zPlane0[4]={-(*besEMCGeometry).BSCDz,-zTaperRing1,zTaperRing1,(*besEMCGeometry).BSCDz};
268 G4double rInner0[4]={vd.perp(),cOp,cOp,vd.perp()};
269 G4double rOuter0[4]={(*besEMCGeometry).BSCPhiRmax,(*besEMCGeometry).BSCPhiRmax,(*besEMCGeometry).BSCPhiRmax,(*besEMCGeometry).BSCPhiRmax};
270
271 G4double zPlane1[4]={-zTaperRing2,-zTaperRing1,zTaperRing1,zTaperRing2};
272 G4double rInner1[4]={rTaperRingOuter2,rTaperRingOuter1,rTaperRingOuter1,rTaperRingOuter2};
273 G4double rOuter1[4]={(*besEMCGeometry).BSCRmax,(*besEMCGeometry).BSCRmax,(*besEMCGeometry).BSCRmax,(*besEMCGeometry).BSCRmax};
274
275 G4VSolid* solidBSCPhi1 = new G4Polycone("solidBSCPhi1",0,360*deg,4,zPlane1,rInner1,rOuter1);
276 G4VSolid* solidBSCPhi0 = new G4Polyhedra("solidBSCPhi0",360.*deg-(*besEMCGeometry).BSCPhiDphi,(*besEMCGeometry).BSCPhiDphi,(*besEMCGeometry).BSCNbPhi/2,4,zPlane0,rInner0,rOuter0);
277 G4IntersectionSolid* solidBSCPhi = new G4IntersectionSolid("solidBSCPhi", solidBSCPhi0, solidBSCPhi1, 0, md);
278
279 logicBSCPhi = new G4LogicalVolume(solidBSCPhi,
280 G4Material::GetMaterial("Air"),
281 "logicalBSCPhi");
282
283 G4int i;
284 for(G4int j=0;j<(*besEMCGeometry).BSCNbPhi;j++)
285 {
286 if(j<(*besEMCGeometry).BSCNbPhi/2) {
287 i=(*besEMCGeometry).BSCNbPhi/2-j-1;
288 } else {
289 i=(*besEMCGeometry).BSCNbPhi*3/2-j-1;
290 }
291 rotateMatrix[i] = new G4RotationMatrix();
292 rotateMatrix[i]->rotateZ(-i*(*besEMCGeometry).BSCPhiDphi
293 -(*besEMCGeometry).BSCAngleRotat
294 -(*besEMCGeometry).BSCPhiDphi/2.
295 -hoi);
296 rotateMatrix[i]->getAngleAxis(
delta, axis);
297
298
299
300 ox=oOp*
cos(-90.*deg+(*besEMCGeometry).BSCAngleRotat+hoi
301 +i*(*besEMCGeometry).BSCPhiDphi);
302 oy=oOp*
sin(-90.*deg+(*besEMCGeometry).BSCAngleRotat+hoi
303 +i*(*besEMCGeometry).BSCPhiDphi);
304 oz=0*cm;
305
306 ostringstream strPhi;
307 strPhi << "physicalBSCPhi" << j;
308
309 physiBSCPhi = new G4PVPlacement(rotateMatrix[i],
310 G4ThreeVector(ox,oy,oz),
311 logicBSCPhi,
312 strPhi.str(),
313 logicBSCWorld,
314 false,
316
317
318 }
319
320
321
322
323 G4double zHalfLength[50];
324 G4double thetaAxis[50];
325 G4double phiAxis[50];
326 G4double yHalfLength1[50];
327 G4double xHalfLength2[50];
328 G4double xHalfLength1[50];
329 G4double tanAlpha1[50];
330 G4double yHalfLength2[50];
331 G4double xHalfLength4[50];
332 G4double xHalfLength3[50];
333 G4double tanAlpha2[50];
334 G4double xPosition[50];
335 G4double yPosition[50];
336 G4double zPosition[50];
337 G4double thetaPosition[50];
338 for(i=0;i<(*besEMCGeometry).BSCNbTheta;i++)
339 {
340 zHalfLength[i] = (*besEMCGeometry).zHalfLength[i];
341 thetaAxis[i] = (*besEMCGeometry).thetaAxis[i];
342 phiAxis[i] = (*besEMCGeometry).phiAxis[i];
343 yHalfLength1[i] = (*besEMCGeometry).yHalfLength1[i];
344 xHalfLength2[i] = (*besEMCGeometry).xHalfLength2[i];
345 xHalfLength1[i] = (*besEMCGeometry).xHalfLength1[i];
346 tanAlpha1[i] = (*besEMCGeometry).tanAlpha1[i];
347 yHalfLength2[i] = (*besEMCGeometry).yHalfLength2[i];
348 xHalfLength4[i] = (*besEMCGeometry).xHalfLength4[i];
349 xHalfLength3[i] = (*besEMCGeometry).xHalfLength3[i];
350 tanAlpha2[i] = (*besEMCGeometry).tanAlpha2[i];
351 xPosition[i] = (*besEMCGeometry).xPosition[i];
352 yPosition[i] = (*besEMCGeometry).yPosition[i];
353 zPosition[i] = (*besEMCGeometry).zPosition[i];
354 thetaPosition[i]= (*besEMCGeometry).thetaPosition[i];
355 if(verboseLevel>4)
356 G4cout << "The sizes of the "<<i+1<<" crystal are:" << G4endl
357 <<"zHalfLength ="<<zHalfLength[i]/cm<< "(cm)," << G4endl
358 << "thetaAxis ="<<thetaAxis[i]/deg << "(deg),"<< G4endl
359 << "phiAxis ="<< phiAxis[i]/deg << "(deg),"<< G4endl
360 << "yHalfLength1="<<yHalfLength1[i]/cm<<"(cm),"<< G4endl
361 << "xHalfLength1="<<xHalfLength1[i]/cm<<"(cm),"<< G4endl
362 << "xHalfLength2="<<xHalfLength2[i]/cm<<"(cm),"<< G4endl
363 << "tanAlpha1 ="<< tanAlpha1[i] << G4endl
364 << "yHalfLength2="<<yHalfLength2[i]/cm<<"(cm),"<< G4endl
365 << "xHalfLength3="<<xHalfLength3[i]/cm<<"(cm),"<< G4endl
366 << "xHalfLength4="<<xHalfLength4[i]/cm<<"(cm),"<< G4endl
367 << "tanAlpha2 =" << tanAlpha2[i] << "." << G4endl;
368 }
370
371 solidBSCCrystal = new G4Trap("solidCrystal",
372 100*cm, 100*deg, 100*deg,
373 100*cm, 100*cm, 100*cm, 100*deg,
374 100*cm, 100*cm, 100*cm, 100*deg);
375
376 logicBSCCrystal = new G4LogicalVolume(solidBSCCrystal,
377 fCrystalMaterial,
378 "logicalCrystal");
379
381 (startID,
382 thetaNbCrystals,
383 (*besEMCGeometry).BSCNbTheta*2,
384 besEMCGeometry,
385 verboseLevel);
386
387
388
389 solidRear = new G4Box("solidRearBox",
390 (*besEMCGeometry).rearBoxLength/2,
391 (*besEMCGeometry).rearBoxLength/2,
392 (*besEMCGeometry).rearBoxDz/2);
393
394 logicRear = new G4LogicalVolume(solidRear,
395 G4Material::GetMaterial("Air"),
396 "logicalRearBox");
397
398
399 solidOrgGlass = new G4Box("solidOrganicGlass",
400 (*besEMCGeometry).orgGlassLengthX/2,
401 (*besEMCGeometry).orgGlassLengthY/2,
402 (*besEMCGeometry).orgGlassLengthZ/2);
403
404 logicOrgGlass = new G4LogicalVolume(solidOrgGlass,
405 organicGlass,
406 "logicalOrganicGlass");
407
408 physiOrgGlass = new G4PVPlacement(0,
409 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz-(*besEMCGeometry).orgGlassLengthZ)/2),
410 logicOrgGlass,
411 "physicalOrganicGlass",
412 logicRear,
413 false,
415
416
417 solidCasingBox = new G4Box("solidCasingBox",
418 (*besEMCGeometry).rearBoxLength/2,
419 (*besEMCGeometry).rearBoxLength/2,
420 (*besEMCGeometry).rearCasingThickness/2);
421
422 solidAirHole = new G4Box("solidAirHole",
423 (*besEMCGeometry).orgGlassLengthX/2,
424 (*besEMCGeometry).orgGlassLengthY/2,
425 (*besEMCGeometry).rearBoxDz/2);
426
427 solidRearCasing = new G4SubtractionSolid("solidRearCasing",
428 solidCasingBox,
429 solidAirHole,
430 0,
431 G4ThreeVector());
432
433 logicRearCasing = new G4LogicalVolume(solidRearCasing,
434 rearCasingMaterial,
435 "logicalRearCasing");
436
437 physiRearCasing = new G4PVPlacement(0,
438 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz-(*besEMCGeometry).rearCasingThickness)/2),
439 logicRearCasing,
440 "physicalRearCasing",
441 logicRear,
442 false,
444
445
446 solidAlBox = new G4Box("solidAlBox",
447 (*besEMCGeometry).rearBoxLength/2,
448 (*besEMCGeometry).rearBoxLength/2,
449 (*besEMCGeometry).AlPlateDz/2);
450
451 solidAlPlate = new G4SubtractionSolid("solidAlPlate",
452 solidAlBox,
453 solidAirHole,
454 0,
455 G4ThreeVector());
456
457 logicAlPlate = new G4LogicalVolume(solidAlPlate,
458 G4Material::GetMaterial("Aluminium"),
459 "logicalAlPlate");
460
461 physiAlPlate = new G4PVPlacement(0,
462 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
463 -(*besEMCGeometry).rearCasingThickness
464 -(*besEMCGeometry).AlPlateDz/2)),
465 logicAlPlate,
466 "physicalAlPlate",
467 logicRear,
468 false,
470
471
472 solidPD = new G4Box("solidPD",
473 (*besEMCGeometry).PDLengthX,
474 (*besEMCGeometry).PDLengthY/2,
475 (*besEMCGeometry).PDLengthZ/2);
476
477 logicPD = new G4LogicalVolume(solidPD,
478 G4Material::GetMaterial("M_Silicon"),
479 "logicalPD");
480
481 physiPD = new G4PVPlacement(0,
482 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
483 -(*besEMCGeometry).orgGlassLengthZ
484 -(*besEMCGeometry).PDLengthZ/2)),
485 logicPD,
486 "physicalPD",
487 logicRear,
488 false,
490
491
492 solidPreAmpBox = new G4Box("solidPreAmpBox",
493 (*besEMCGeometry).rearBoxLength/2,
494 (*besEMCGeometry).rearBoxLength/2,
495 (*besEMCGeometry).PABoxDz/2);
496
497 logicPreAmpBox = new G4LogicalVolume(solidPreAmpBox,
498 G4Material::GetMaterial("Aluminium"),
499 "logicalPreAmpBox");
500
501 physiPreAmpBox = new G4PVPlacement(0,
502 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
503 -(*besEMCGeometry).rearCasingThickness
504 -(*besEMCGeometry).AlPlateDz
505 -(*besEMCGeometry).PABoxDz/2)),
506 logicPreAmpBox,
507 "physicalPreAmpBox",
508 logicRear,
509 false,
511
512
513 solidAirInPABox = new G4Box("solidAirInPABox",
514 (*besEMCGeometry).rearBoxLength/2-(*besEMCGeometry).PABoxThickness,
515 (*besEMCGeometry).rearBoxLength/2-(*besEMCGeometry).PABoxThickness,
516 (*besEMCGeometry).PABoxDz/2-(*besEMCGeometry).PABoxThickness);
517
518 logicAirInPABox = new G4LogicalVolume(solidAirInPABox,
519 G4Material::GetMaterial("Air"),
520 "logicalAirInPABox");
521
522 physiAirInPABox = new G4PVPlacement(0,
523 G4ThreeVector(),
524 logicAirInPABox,
525 "physicalAirInPABox",
526 logicPreAmpBox,
527 false,
529
530
531 solidHangingPlate = new G4Box("solidHangingPlate",
532 (*besEMCGeometry).rearBoxLength/2,
533 (*besEMCGeometry).rearBoxLength/2,
534 (*besEMCGeometry).HangingPlateDz/2);
535
536 logicHangingPlate = new G4LogicalVolume(solidHangingPlate,stainlessSteel,"logicalHangingPlate");
537
538 physiHangingPlate = new G4PVPlacement(0,
539 G4ThreeVector(0,0,-((*besEMCGeometry).rearBoxDz/2
540 -(*besEMCGeometry).rearCasingThickness
541 -(*besEMCGeometry).AlPlateDz
542 -(*besEMCGeometry).PABoxDz
543 -(*besEMCGeometry).HangingPlateDz/2)),
544 logicHangingPlate,
545 "physicalHangingPlate",
546 logicRear,
547 false,
549
550
551 solidWaterPipe = new G4Tubs("solidWaterPipe",
552 0,
553 (*besEMCGeometry).waterPipeDr,
554 (*besEMCGeometry).BSCDz,
555 0.*deg,
556 360.*deg);
557
558 logicWaterPipe = new G4LogicalVolume(solidWaterPipe,waterPipe,"logicalWaterPipe");
559
560 physiWaterPipe = new G4PVPlacement(0,
561 G4ThreeVector((*besEMCGeometry).cablePosX[0]-2*(*besEMCGeometry).cableDr,
562 (*besEMCGeometry).cablePosY[0]-(*besEMCGeometry).cableDr-(*besEMCGeometry).waterPipeDr,
563 0),
564 logicWaterPipe,
565 "physicalWaterPipe",
566 logicBSCPhi,
567 false,
569
570
571
572
573
574
575 G4String nameCrystalAndCasing="CrystalAndCasing";
576
577 G4int id=0;
578 for(i=startID;i<=thetaNbCrystals;i++)
579 {
580 ostringstream strSolidCasing;
581 strSolidCasing << "solidBSCCasing" << i-1;
582 ostringstream strVolumeCasing;
583 strVolumeCasing << "logicalBSCCasing" << i-1;
584 ostringstream strPhysiCasing;
585 strPhysiCasing << "physicalBSCCasing" << i-1;
586
587 if(i>(*besEMCGeometry).BSCNbTheta)
588 {
589 id=i-(*besEMCGeometry).BSCNbTheta-1;
590 solidBSCTheta = new G4Trap(strSolidCasing.str(),
591 zHalfLength[id],
592 thetaAxis[id],
593 -phiAxis[id],
594 yHalfLength1[id],
595 xHalfLength2[id],
596 xHalfLength1[id],
597 -tanAlpha1[id],
598 yHalfLength2[id],
599 xHalfLength4[id],
600 xHalfLength3[id],
601 -tanAlpha2[id]);
602
603
604
605
606 logicBSCTheta = new G4LogicalVolume(solidBSCTheta,
607 fCasingMaterial,
608 strVolumeCasing.str());
609
610 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1] = new G4RotationMatrix();
611 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]->rotateZ(-90*deg);
612 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]
613 ->rotateX(-thetaPosition[id]);
614
615
616 physiBSCTheta =
617 new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
618 G4ThreeVector(xPosition[id],
619 yPosition[id],
620 zPosition[id]),
621 strPhysiCasing.str(),
622 logicBSCTheta,
623 physiBSCPhi,
624 false,
626
627 if(logicBSCTheta)
628 {
629 G4VisAttributes* rightVisAtt= new G4VisAttributes(G4Colour(1.0,0.,0.));
630 rightVisAtt->SetVisibility(true);
631 logicBSCTheta->SetVisAttributes(rightVisAtt);
632 logicBSCTheta->SetVisAttributes(G4VisAttributes::Invisible);
633 }
634
635 ostringstream strRear;
636 strRear << "physicalRearBox_1_" << i-1;
637
638 physiRear = new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
639 G4ThreeVector((*besEMCGeometry).rearBoxPosX[id],
640 (*besEMCGeometry).rearBoxPosY[id],
641 (*besEMCGeometry).rearBoxPosZ[id]),
642 strRear.str(),
643 logicRear,
644 physiBSCPhi,
645 false,
647
648 ostringstream strGirder;
649 strGirder << "solidOpenningCutGirder_1_" << i-1;
650 solidOCGirder = new G4Cons(strGirder.str(),
651 (*besEMCGeometry).OCGirderRmin1[id],
652 (*besEMCGeometry).BSCPhiRmax,
653 (*besEMCGeometry).OCGirderRmin2[id],
654 (*besEMCGeometry).BSCPhiRmax,
655 (*besEMCGeometry).OCGirderDz[id]/2,
656 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
657 (*besEMCGeometry).OCGirderAngle/2-da);
658
659 ostringstream strVGirder;
660 strVGirder << "logicalOpenningCutGirder_1_" << i-1;
661 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,strVGirder.str());
662 logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
663
664 ostringstream strPGirder;
665 strPGirder << "physicalOpenningCutGirder_1_" << i-1;
666 physiOCGirder = new G4PVPlacement(0,
667 G4ThreeVector(0,0,(*besEMCGeometry).OCGirderPosZ[id]),
668 logicOCGirder,
669 strPGirder.str(),
670 logicBSCPhi,
671 false,
673
674 if(id<(*besEMCGeometry).BSCNbTheta-1)
675 {
676 G4double zLength = (*besEMCGeometry).OCGirderPosZ[id+1]
677 -(*besEMCGeometry).OCGirderPosZ[id]
678 -(*besEMCGeometry).OCGirderDz[id+1]/2-(*besEMCGeometry).OCGirderDz[id]/2;
679 G4double zPositionOCGirder = (*besEMCGeometry).OCGirderPosZ[id+1]
680 -(*besEMCGeometry).OCGirderDz[id+1]/2-zLength/2;
681
682 ostringstream strGirder2;
683 strGirder2 << "solidOpenningCutGirder_2_" << i-1;
684 solidOCGirder = new G4Cons(strGirder2.str(),
685 (*besEMCGeometry).OCGirderRmin2[id],
686 (*besEMCGeometry).BSCPhiRmax,
687 (*besEMCGeometry).OCGirderRmin1[id+1],
688 (*besEMCGeometry).BSCPhiRmax,
689 zLength/2,
690 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
691 (*besEMCGeometry).OCGirderAngle/2-da);
692
693 ostringstream strVGirder2;
694 strVGirder2 << "logicalOpenningCutGirder_2_" << i-1;
695 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,strVGirder2.str());
696 logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
697
698 ostringstream strPGirder2;
699 strPGirder2 << "physicalOpenningCutGirder_2_" << i-1;
700 physiOCGirder = new G4PVPlacement(0,
701 G4ThreeVector(0,0,zPositionOCGirder),
702 logicOCGirder,
703 strPGirder2.str(),
704 logicBSCPhi,
705 false,
707 }
708
709 ostringstream strBSCCable;
710 strBSCCable << "solidBSCCable_1_" << i-1;
711 solidCable = new G4Tubs(strBSCCable.str(),
712 0,
713 (*besEMCGeometry).cableDr,
714 (*besEMCGeometry).cableLength[id]/2,
715 0.*deg,
716 360.*deg);
717
718 ostringstream strVBSCCable;
719 strVBSCCable << "logicalBSCCable_1_" << i-1;
720 logicCable = new G4LogicalVolume(solidCable,cable,strVBSCCable.str());
721
722 ostringstream strPBSCCable;
723 strPBSCCable << "physicalBSCCable_1_" << i-1;
724 physiCable = new G4PVPlacement(0,
725 G4ThreeVector((*besEMCGeometry).cablePosX[id],
726 (*besEMCGeometry).cablePosY[id],
727 (*besEMCGeometry).cablePosZ[id]),
728 logicCable,
729 strPBSCCable.str(),
730 logicBSCPhi,
731 false,
733 logicCable->SetVisAttributes(G4VisAttributes::Invisible);
734 }
735 else
736 {
737 id=(*besEMCGeometry).BSCNbTheta-i;
738 solidBSCTheta = new G4Trap(strSolidCasing.str(),
739 zHalfLength[id],
740 thetaAxis[id],
741 phiAxis[id],
742 yHalfLength1[id],
743 xHalfLength1[id],
744 xHalfLength2[id],
745 tanAlpha1[id],
746 yHalfLength2[id],
747 xHalfLength3[id],
748 xHalfLength4[id],
749 tanAlpha2[id]);
750
751
752
753
754 logicBSCTheta = new G4LogicalVolume(solidBSCTheta,
755 fCasingMaterial,
756 strVolumeCasing.str());
757
758 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1] = new G4RotationMatrix();
759 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]->rotateZ(-90*deg);
760 rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1]
761 ->rotateX(-180*deg+thetaPosition[id]);
762 physiBSCTheta =
763 new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
764 G4ThreeVector(xPosition[id],
765 yPosition[id],
766 -zPosition[id]),
767 strPhysiCasing.str(),
768 logicBSCTheta,
769 physiBSCPhi,
770 false,
772 if(logicBSCTheta)
773 {
774 G4VisAttributes* rightVisAtt= new G4VisAttributes(G4Colour(1.0,0.,0.));
775 rightVisAtt->SetVisibility(true);
776 logicBSCTheta->SetVisAttributes(rightVisAtt);
777 logicBSCTheta->SetVisAttributes(G4VisAttributes::Invisible);
778 }
779
780 ostringstream strRear;
781 strRear << "physicalRearBox_2_" << i-1;
782
783 physiRear = new G4PVPlacement(rotateMatrix[(*besEMCGeometry).BSCNbPhi+i-1],
784 G4ThreeVector((*besEMCGeometry).rearBoxPosX[id],
785 (*besEMCGeometry).rearBoxPosY[id],
786 -(*besEMCGeometry).rearBoxPosZ[id]),
787 strRear.str(),
788 logicRear,
789 physiBSCPhi,
790 false,
792
793 ostringstream strGirder;
794 strGirder << "solidOpenningCutGirder_3_" << i-1;
795 solidOCGirder = new G4Cons(strGirder.str(),
796 (*besEMCGeometry).OCGirderRmin2[id],
797 (*besEMCGeometry).BSCPhiRmax,
798 (*besEMCGeometry).OCGirderRmin1[id],
799 (*besEMCGeometry).BSCPhiRmax,
800 (*besEMCGeometry).OCGirderDz[id]/2,
801 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
802 (*besEMCGeometry).OCGirderAngle/2-da);
803
804 ostringstream strVGirder;
805 strVGirder << "logicalOpenningCutGirder_3_" << i-1;
806 logicOCGirder = new G4LogicalVolume(solidOCGirder,stainlessSteel,strVGirder.str());
807 logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
808
809 ostringstream strPGirder;
810 strPGirder << "physicalOpenningCutGirder_3_" << i-1;
811 physiOCGirder = new G4PVPlacement(0,
812 G4ThreeVector(0,0,-(*besEMCGeometry).OCGirderPosZ[id]),
813 logicOCGirder,
814 strPGirder.str(),
815 logicBSCPhi,
816 false,
818
819 if(id<(*besEMCGeometry).BSCNbTheta-1)
820 {
821 G4double zLength = (*besEMCGeometry).OCGirderPosZ[id+1]-(*besEMCGeometry).OCGirderPosZ[id]
822 -(*besEMCGeometry).OCGirderDz[id+1]/2-(*besEMCGeometry).OCGirderDz[id]/2;
823 G4double zPositionOCGirder = (*besEMCGeometry).OCGirderPosZ[id+1]-(*besEMCGeometry).OCGirderDz[id+1]/2-zLength/2;
824
825 ostringstream strGirder2;
826 strGirder2 << "solidOpenningCutGirder_4_" << i-1;
827 solidOCGirder = new G4Cons(strGirder2.str(),
828 (*besEMCGeometry).OCGirderRmin1[id+1],
829 (*besEMCGeometry).BSCPhiRmax,
830 (*besEMCGeometry).OCGirderRmin2[id],
831 (*besEMCGeometry).BSCPhiRmax,
832 zLength/2,
833 360.*deg-(*besEMCGeometry).OCGirderAngle/2,
834 (*besEMCGeometry).OCGirderAngle/2-da);
835
836 ostringstream strVGirder2;
837 strVGirder2 << "logicalOpenningCutGirder_4_" << i-1;
838 logicOCGirder
839 = new G4LogicalVolume(solidOCGirder,stainlessSteel,strVGirder2.str());
840 logicOCGirder->SetVisAttributes(G4VisAttributes::Invisible);
841
842 ostringstream strPGirder2;
843 strPGirder2 << "physicalOpenningCutGirder_4_" << i-1;
844 physiOCGirder = new G4PVPlacement(0,
845 G4ThreeVector(0,0,-zPositionOCGirder),
846 logicOCGirder,
847 strPGirder2.str(),
848 logicBSCPhi,
849 false,
851 }
852
853 ostringstream strBSCCable;
854 strBSCCable << "solidBSCCable_2_" << i-1;
855 solidCable = new G4Tubs(strBSCCable.str(),
856 0,
857 (*besEMCGeometry).cableDr,
858 (*besEMCGeometry).cableLength[id]/2,
859 0.*deg,
860 360.*deg);
861
862 ostringstream strVBSCCable;
863 strVBSCCable << "logicalBSCCable_2_" << i-1;
864 logicCable = new G4LogicalVolume(solidCable,cable,strVBSCCable.str());
865
866 ostringstream strPBSCCable;
867 strPBSCCable << "physicalBSCCable_2_" << i-1;
868 physiCable = new G4PVPlacement(0,
869 G4ThreeVector((*besEMCGeometry).cablePosX[id],
870 (*besEMCGeometry).cablePosY[id],
871 -(*besEMCGeometry).cablePosZ[id]),
872 logicCable,
873 strPBSCCable.str(),
874 logicBSCPhi,
875 false,
877 logicCable->SetVisAttributes(G4VisAttributes::Invisible);
878
879 }
880
881 ostringstream strCrystal;
882 strCrystal << "physicalCrystal" << i-1;
883 physiBSCCrystal = new G4PVParameterised(
884 strCrystal.str(),
885 logicBSCCrystal,
886 physiBSCTheta,
887 kZAxis,
888 1,
889 crystalParam);
890 (*besEMCGeometry).physiBSCCrystal[i]=physiBSCCrystal;
891
892 physiBSCCrystal->SetCopyNo(i);
893 if(
CHECKLV4) physiBSCCrystal->CheckOverlaps();
894
895 if(verboseLevel>4)
896 G4cout << "BesEmcConstruction*****************************"<< G4endl
897 << "point of crystal =" <<physiBSCCrystal << G4endl
898
899 << "point of excepted=" <<physiBSCTheta << G4endl;
900
901 }
902
903
904
906
907
910 }
911
912
914
915
916 if(logicEMC&&physiEMC&&verboseLevel>4){
917 G4cout<<"logicEmc "<<logicEMC<<" physiEmc "<<physiEMC<<G4endl;
918 G4cout<<"list geo tree"<<G4endl;
919
920 int NdaughterofEMC = logicEMC->GetNoDaughters();
921
922 for(int i = 0; i < NdaughterofEMC; i++)
923 {
924 G4LogicalVolume *daughterofEmc = logicEMC->GetDaughter(i)->GetLogicalVolume();
925 G4cout<<i<<"/"<<NdaughterofEMC<<" name: "<<daughterofEmc->GetName()<<" "<<daughterofEmc<<" shape: "<<daughterofEmc->GetSolid()->GetName()<<G4endl;
926 int NdaughterofEmc_2 = daughterofEmc->GetNoDaughters();
927 for(int j = 0; j < NdaughterofEmc_2; j++)
928 {
929 G4LogicalVolume *daughterofEmc_2 = daughterofEmc->GetDaughter(j)->GetLogicalVolume();
930 G4cout<<" --> "<<j<<"/"<<NdaughterofEmc_2<<" name: "<<daughterofEmc_2->GetName()<<" "<<daughterofEmc_2<<" shape: "<<daughterofEmc_2->GetSolid()->GetName()<<G4endl;
931 int NdaughterofEmc_3 = daughterofEmc_2->GetNoDaughters();
932 for(int k = 0; k < NdaughterofEmc_3; k++)
933 {
934 G4LogicalVolume *daughterofEmc_3 = daughterofEmc_2->GetDaughter(k)->GetLogicalVolume();
935 G4cout<<" --> "<<k<<"/"<<NdaughterofEmc_3<<" name: "<<daughterofEmc_3->GetName()<<" "<<daughterofEmc_3<<" shape: "<<daughterofEmc_3->GetSolid()->GetName()<<G4endl;
936 int NdaughterofEmc_4 = daughterofEmc_3->GetNoDaughters();
937 for(int m = 0; m < NdaughterofEmc_4; m++)
938 {
939 G4LogicalVolume *daughterofEmc_4 = daughterofEmc_3->GetDaughter(m)->GetLogicalVolume();
940 G4cout<<" --> "<<m<<"/"<<NdaughterofEmc_4<<" name: "<<daughterofEmc_4->GetName()<<" "<<daughterofEmc_4<<" shape: "<<daughterofEmc_4->GetSolid()->GetName()<<G4endl;
941 if(daughterofEmc_3->GetSolid()->GetName().contains("solidBSCCasing"))
942 {
943 G4Trap *Crystal = (G4Trap *)daughterofEmc_3->GetSolid();
944 double hz = Crystal->GetZHalfLength();
945 double hx1 = Crystal->GetXHalfLength1();
946 double hx2 = Crystal->GetXHalfLength2();
947 double hx3 = Crystal->GetXHalfLength3();
948 double hx4 = Crystal->GetXHalfLength4();
949 double hy1 = Crystal->GetYHalfLength1();
950 double hy2 = Crystal->GetYHalfLength2();
951 double tanalpha1 = Crystal->GetTanAlpha1();
952 double tanalpha2 = Crystal->GetTanAlpha2();
953 G4cout<<" --> "<<hx1<<" "<<hx2<<" "<<hx3<<" "<<hx4<<" "<<hy1<<" "<<hy2<<" "<<hz<<" "<<tanalpha1<<" "<<tanalpha2<<G4endl;
954
955 }
956 }
957 }
958 }
959 }
960 }
961
962}
double tan(const BesAngle a)
double sin(const BesAngle a)
double cos(const BesAngle a)
double P(RecMdcKalTrack *trk)
void ConstructSPFrame(G4LogicalVolume *, BesEmcGeometry *)
void ConstructEndGeometry(G4LogicalVolume *)
void PrintEMCParameters()
void ComputeEMCParameters()
static EmcG4Geo * Instance()
Get a pointer to the single instance of EmcG4Geo.
G4LogicalVolume * GetTopVolume()
Get the top(world) volume;.