48 G4SDManager* SDman = G4SDManager::GetSDMpointer();
49 G4String mdcSDname =
"BesMdcSD";
50 aTrackerSD =
new BesMdcSD( mdcSDname);
51 SDman->AddNewDetector( aTrackerSD );
55 G4LogicalVolume *logicalMdc = 0;
56 G4LogicalVolume *lv = 0;
62 G4cout<<
"BesMdcConstruction::Construct(), logicalMdc not found"<<G4endl;
65 mdc_phys =
new G4PVPlacement(0,G4ThreeVector(0,0,0),
66 logicalMdc,
"physicalMdc",logicBes,
false, 0);
67 logicalMdc->SetVisAttributes(G4VisAttributes::Invisible);
70 G4VisAttributes* visAttStereoLayer =
new G4VisAttributes(G4Colour(0.,1.,0.));
71 G4VisAttributes* visAttAxialLayer =
new G4VisAttributes(G4Colour(1.,0.,0.));
73 G4double colorShift = 0., shift = 1.0 / (segmentNo-1);
75 for (
int i = 1; i < segmentNo; i++) {
76 std::ostringstream osnameSegment;
77 osnameSegment <<
"logical" <<
"Mdc" <<
"Segment" << i;
78 lv = (G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameSegment.str() );
79 G4VisAttributes* visAttSegment =
new G4VisAttributes(G4Colour(1.0-colorShift, 0.0+colorShift, 0.0));
80 if(i<3) visAttSegment->SetForceWireframe(
true);
82 lv->SetVisAttributes(visAttSegment);
85 else G4cout <<
"logical volume " << osnameSegment.str() <<
"not found " << G4endl;
89 for (
int i = 0; i < 8; i++) {
90 std::ostringstream osnameStereoLayer;
91 osnameStereoLayer <<
"logical" <<
"Mdc" <<
"StereoLayer" << i;
92 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameStereoLayer.str() );
94 lv->SetVisAttributes(visAttStereoLayer);
95 lv->SetVisAttributes(G4VisAttributes::Invisible);
97 else G4cout <<
"logical volume " << osnameStereoLayer.str() <<
"not found " << G4endl;
99 std::ostringstream osnameTwistedTubs;
100 osnameTwistedTubs <<
"logical" <<
"Mdc" <<
"StereoLayer" << i <<
"Cell";
101 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameTwistedTubs.str() );
103 lv->SetSensitiveDetector( aTrackerSD );
104 lv->SetVisAttributes(G4VisAttributes::Invisible);
106 else G4cout <<
"logical volume " << osnameTwistedTubs.str() <<
"not found " << G4endl;
109 for (
int i = 20; i < 36; i++) {
110 std::ostringstream osnameStereoLayer;
111 osnameStereoLayer <<
"logical" <<
"Mdc" <<
"StereoLayer" << i;
112 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameStereoLayer.str() );
114 lv->SetVisAttributes(visAttStereoLayer);
115 lv->SetVisAttributes(G4VisAttributes::Invisible);
117 else G4cout <<
"logical volume " << osnameStereoLayer.str() <<
"not found " << G4endl;
119 std::ostringstream osnameTwistedTubs;
120 osnameTwistedTubs <<
"logical" <<
"Mdc" <<
"StereoLayer" << i <<
"Cell";
121 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameTwistedTubs.str() );
123 lv->SetSensitiveDetector( aTrackerSD );
124 lv->SetVisAttributes(G4VisAttributes::Invisible);
126 else G4cout <<
"logical volume " << osnameTwistedTubs.str() <<
"not found " << G4endl;
129 for (
int i = 8; i < 20; i++) {
130 std::ostringstream osnameAxialLayer;
131 osnameAxialLayer <<
"logical" <<
"Mdc" <<
"AxialLayer" << i;
132 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameAxialLayer.str() );
134 lv->SetVisAttributes(visAttAxialLayer);
135 lv->SetVisAttributes(G4VisAttributes::Invisible);
137 else G4cout <<
"logical volume " << osnameAxialLayer.str() <<
"not found " << G4endl;
139 std::ostringstream osnameReplica;
140 osnameReplica <<
"logical" <<
"Mdc" <<
"AxialLayer" << i <<
"Cell";
141 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameReplica.str() );
143 lv->SetSensitiveDetector( aTrackerSD );
144 lv->SetVisAttributes(G4VisAttributes::Invisible);
146 else G4cout <<
"logical volume " << osnameReplica.str() <<
"not found " << G4endl;
149 for (
int i = 36; i < 43; i++) {
150 for (
int n = 0;
n < 2;
n++) {
151 std::ostringstream osnameAxialLayer;
152 osnameAxialLayer <<
"logical" <<
"Mdc" <<
"AxialLayer" << i <<
"_" <<
n;
153 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameAxialLayer.str() );
155 lv->SetVisAttributes(visAttAxialLayer);
156 lv->SetVisAttributes(G4VisAttributes::Invisible);
158 else G4cout <<
"logical volume " << osnameAxialLayer.str() <<
"not found " << G4endl;
160 std::ostringstream osnameReplica;
161 osnameReplica <<
"logical" <<
"Mdc" <<
"AxialLayer" << i <<
"_" <<
n <<
"Cell";
162 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameReplica.str() );
164 lv->SetSensitiveDetector( aTrackerSD );
165 lv->SetVisAttributes(G4VisAttributes::Invisible);
167 else G4cout <<
"logical volume " << osnameReplica.str() <<
"not found " << G4endl;
179 G4Material* MdcGas = G4Material::GetMaterial(
"Mdcgas");
180 G4Material*
Al = G4Material::GetMaterial(
"Aluminium");
181 G4Element *
C =G4Element::GetElement(
"Carbon");
182 G4Element *
H =G4Element::GetElement(
"Hydrogen");
183 G4Element *O =G4Element::GetElement(
"Oxygen");
185 G4double density = 19.3*g/cm3;
186 G4double a = 183.84*g/mole;
187 G4Material* W =
new G4Material(
"Tungsten", 74., a, density);
191 G4Material* Au=
new G4Material(
"Au",79,a,density);
195 G4Material* CarbonFiber=
new G4Material(
"CarbonFiber",density,nElement);
196 CarbonFiber->AddElement(
C,0.697);
197 CarbonFiber->AddElement(
H,0.0061);
198 CarbonFiber->AddElement(O,0.2969);
200 density = 1.42*g/cm3;
201 G4Material* Kapton =
new G4Material(
"Kapton", density, 3);
202 Kapton->AddElement(O,2);
203 Kapton->AddElement(
C,5);
204 Kapton->AddElement(
H,4);
208 G4double outR, innerR, length;
209 G4double startAngle, spanAngle;
210 G4double posX, posY, posZ;
211 G4VisAttributes* visAtt;
220 G4cout << mdc->
Segment(0).
Name() <<
" innerR: " << innerR <<
" , outR: " << outR <<
" , length: "<<setprecision(8)<<
length << endl;
228 G4Tubs* mdc_tube=
new G4Tubs(
"solidMdc",innerR,outR,
length,startAngle,spanAngle);
229 mdc_log=
new G4LogicalVolume(mdc_tube, MdcGas,
"logicalMdc",0,0,0);
230 mdc_log->SetVisAttributes(G4VisAttributes::Invisible);
236 mdc_phys=
new G4PVPlacement(0,
237 G4ThreeVector(posX ,posY ,posZ),
238 mdc_log,
"physicalMdc",logicBes,
false,0);
243 G4double colorShift=0., shift=1./(mdc->
SegmentNo()-1);
244 G4double gap=0.5*micrometer;
256 std::ostringstream osnameSolid;
257 osnameSolid <<
"solid"<<name<<i;
258 G4Tubs* segment_tube=
new G4Tubs(osnameSolid.str(),innerR,outR,
length,startAngle,spanAngle);
259 std::ostringstream osnameLogical;
260 osnameLogical <<
"logical"<<name<<i;
261 G4LogicalVolume* segment_log;
263 segment_log=
new G4LogicalVolume(segment_tube, CarbonFiber,osnameLogical.str(),0,0,0);
265 segment_log=
new G4LogicalVolume(segment_tube,
Al,osnameLogical.str(),0,0,0);
268 visAtt=
new G4VisAttributes(G4Colour(1.0-colorShift,0.0+colorShift,0.0));
269 if(i<3)visAtt->SetForceWireframe(
true);
270 segment_log->SetVisAttributes(visAtt);
274 G4VPhysicalVolume* segment_phys;
275 std::ostringstream osnamePhys1;
276 osnamePhys1 <<
"physical"<<name<<i<<
"p";
277 segment_phys=
new G4PVPlacement(0,
278 G4ThreeVector(posX ,posY ,posZ),
279 segment_log,osnamePhys1.str(),mdc_log,
false,0);
282 std::ostringstream osnamePhys2;
283 osnamePhys2 <<
"physical"<<name<<i<<
"m";
284 segment_phys=
new G4PVPlacement(0,
285 G4ThreeVector(posX ,posY ,-posZ),
286 segment_log,osnamePhys2.str(),mdc_log,
false,0);
302 G4Tubs* segment_tube1=
new G4Tubs(
"SolidMdcInnerFilm0",innerR,outR,
length,startAngle,spanAngle);
303 G4LogicalVolume* segment_log1;
304 segment_log1=
new G4LogicalVolume(segment_tube1,
Al,
"LogicalMdcInnerFilm0",0,0,0);
305 G4VisAttributes* visAtt1=
new G4VisAttributes(G4Colour(0,1.0,0.0));
306 segment_log1->SetVisAttributes(visAtt1);
307 G4VPhysicalVolume* segment_phys1;
308 segment_phys1=
new G4PVPlacement(0,
309 G4ThreeVector(posX ,posY ,posZ),
310 segment_log1,
"PhysicalMdcInnerFilm0",mdc_log,
false,0);
318 G4Tubs* segment_tube2=
new G4Tubs(
"SolidMdcInnerFilm1",innerR,outR,
length,startAngle,spanAngle);
319 G4LogicalVolume* segment_log2;
320 segment_log2=
new G4LogicalVolume(segment_tube2,
Al,
"LogicalMdcInnerFilm1",0,0,0);
321 G4VisAttributes* visAtt2=
new G4VisAttributes(G4Colour(0,0.0,1.0));
322 segment_log2->SetVisAttributes(visAtt2);
323 G4VPhysicalVolume* segment_phys2;
324 segment_phys2=
new G4PVPlacement(0,
325 G4ThreeVector(posX ,posY ,posZ),
326 segment_log2,
"PhysicalMdcInnerFilm1",mdc_log,
false,0);
336 G4Tubs* segment_tube3=
new G4Tubs(
"SolidMdcOutFilm0",innerR,outR,
length,startAngle,spanAngle);
337 G4LogicalVolume* segment_log3;
338 segment_log3=
new G4LogicalVolume(segment_tube3,
Al,
"LogicalMdcOutFilm0",0,0,0);
339 G4VisAttributes* visAtt3=
new G4VisAttributes(G4Colour(0,1.0,0.0));
340 segment_log3->SetVisAttributes(visAtt3);
341 G4VPhysicalVolume* segment_phys3;
342 segment_phys3=
new G4PVPlacement(0,
343 G4ThreeVector(posX ,posY ,posZ),
344 segment_log3,
"PhysicalMdcOutFilm0",mdc_log,
false,0);
352 G4Tubs* segment_tube4=
new G4Tubs(
"SolidMdcOutFilm1",innerR,outR,
length,startAngle,spanAngle);
353 G4LogicalVolume* segment_log4;
354 segment_log4=
new G4LogicalVolume(segment_tube4,
Al,
"LogicalMdcOutFilm1",0,0,0);
355 G4VisAttributes* visAtt4=
new G4VisAttributes(G4Colour(0,0.0,1.0));
356 segment_log4->SetVisAttributes(visAtt4);
357 G4VPhysicalVolume* segment_phys4;
358 segment_phys4=
new G4PVPlacement(0,
359 G4ThreeVector(posX ,posY ,posZ),
360 segment_log4,
"PhysicalMdcOutFilm1",mdc_log,
false,0);
363 innerR=mdc->
Segment(1).
OutR()*mm+100*micrometer+gap;
368 G4Tubs* segment_tube5=
new G4Tubs(
"SolidMdcOutFilm2",innerR,outR,
length,startAngle,spanAngle);
369 G4LogicalVolume* segment_log5;
370 segment_log5=
new G4LogicalVolume(segment_tube5, Kapton,
"LogicalMdcOutFilm2",0,0,0);
371 G4VisAttributes* visAtt5=
new G4VisAttributes(G4Colour(0,0.5,0.5));
372 segment_log5->SetVisAttributes(visAtt5);
373 G4VPhysicalVolume* segment_phys5;
374 segment_phys5=
new G4PVPlacement(0,
375 G4ThreeVector(posX ,posY ,posZ),
376 segment_log5,
"PhysicalMdcOutFilm2",mdc_log,
false,0);
383 G4Tubs*fixTub=
new G4Tubs(
"solidFixTub",elecGeomPointer->
FixRing(0)*mm,elecGeomPointer->
FixRing(1)*mm,elecGeomPointer->
FixRing(2)/2.*mm,0.*deg,360.*deg);
384 G4LogicalVolume*fixTub_log=
new G4LogicalVolume(fixTub,
Al,
"logicalFixTub");
385 G4VPhysicalVolume*fixTub_phys1=
new G4PVPlacement(0,G4ThreeVector(0,0,1134.5*mm),fixTub_log,
"physcalFixTub1",mdc_log,
false,0);
386 G4VPhysicalVolume*fixTub_phys2=
new G4PVPlacement(0,G4ThreeVector(0,0,-1134.5*mm),fixTub_log,
"physicalFixTub2",mdc_log,
false,0);
389 G4Element *Cu=G4Element::GetElement(
"Copper");
390 G4Element *Si=G4Element::GetElement(
"Silicon");
393 G4double boxDensityEndcape=1.9745*g/cm3;
394 G4int boxNcomponenEndcape=6;
395 G4Material *Cuu = G4Material::GetMaterial(
"Copper");
400 G4Element *Cl =
new G4Element(
"Chlorine",
"Cl",17.,35.5*g/mole);
401 G4Material*synEndcape=
new G4Material(
"M_synthesis",boxDensityEndcape,boxNcomponenEndcape);
402 synEndcape->AddElement(Cu,0.50);
403 synEndcape->AddElement(
C,0.134);
404 synEndcape->AddElement(
H,0.033);
405 synEndcape->AddElement(Si,0.11);
406 synEndcape->AddElement(Cl,0.014);
407 synEndcape->AddElement(O,0.209);
409 G4Box*boxEndcape=
new G4Box(
"solidboxEndcape",elecGeomPointer->
BoxEndcape(0)/2.*mm,elecGeomPointer->
BoxEndcape(1)/2.*mm,elecGeomPointer->
BoxEndcape(2)/2.*mm);
410 G4LogicalVolume*boxEndcape_log=
new G4LogicalVolume(boxEndcape,synEndcape,
"logical boxEndcape");
411 visAtt=
new G4VisAttributes(G4Colour(0.0,1.0,0.0));
412 boxEndcape_log->SetVisAttributes(visAtt);
415 double boxCuEndDx=8.5*mm;
416 double boxCuEndDy=12.*mm;
417 double boxCuEndDz=29.*mm;
419 G4Box* boxCuEnd=
new G4Box(
"solidboxCuEnd",boxCuEndDx/2.,boxCuEndDy/2.,boxCuEndDz/2.);
420 G4LogicalVolume*boxCuEnd_log=
new G4LogicalVolume(boxCuEnd,Cuu,
"logical boxCuEnd");
421 visAtt=
new G4VisAttributes(G4Colour(1.0,1.0,0.0));
422 boxCuEnd_log->SetVisAttributes(visAtt);
424 double dxVirtualBox=18.*mm;
425 double dyVirtualBox=106.*mm;
426 double dzVirtualBox=53.*mm;
427 G4Box*virtualBoxForEndcape=
new G4Box(
"solid virtualBoxEndcape",dxVirtualBox/2.,dyVirtualBox/2.*mm,dzVirtualBox/2.*mm);
428 G4LogicalVolume*virtualBoxForEndcape_log=
new G4LogicalVolume(virtualBoxForEndcape,G4Material::GetMaterial(
"Air"),
"logical virtualBoxEndcape");
430 virtualBoxForEndcape_log->SetVisAttributes(visAtt);
431 G4VPhysicalVolume*boxEndcape_phys=
new G4PVPlacement(0,G4ThreeVector(elecGeomPointer->
BoxEndcape(0)/2.,0,0),boxEndcape_log,
"physical boxEndcape",virtualBoxForEndcape_log,
false,0);
432 G4VPhysicalVolume*boxCuEnd_physFront=
new G4PVPlacement(0,G4ThreeVector(-boxCuEndDx*0.5-0.1*mm,elecGeomPointer->
BoxEndcape(1)/2.-boxCuEndDy/2,0),boxCuEnd_log,
"physical boxCuEnd",virtualBoxForEndcape_log,
false,0);
433 G4VPhysicalVolume*boxCuEnd_physBehind=
new G4PVPlacement(0,G4ThreeVector(-boxCuEndDx*0.5-0.1*mm,-(elecGeomPointer->
BoxEndcape(1)/2.-boxCuEndDy/2),0),boxCuEnd_log,
"physical boxCuEnd",virtualBoxForEndcape_log,
false,0);
434 const double pi=3.141593;
438 double startAngleArray;
442 startAngleArray=acos(elecGeomPointer->
X(i)/elecGeomPointer->
R(i));
444 for(
int j=0;j<elecGeomPointer->
ElecNo(i);j++)
446 G4RotationMatrix*boxRotj=
new G4RotationMatrix;
447 boxRotj->rotateZ(-startAngleArray-j*2*
pi/elecGeomPointer->
ElecNo(i));
448 posXArray=elecGeomPointer->
R(i)*
cos((startAngleArray+j*2*
pi/elecGeomPointer->
ElecNo(i)));
449 posYArray=elecGeomPointer->
R(i)*
sin((startAngleArray+j*2*
pi/elecGeomPointer->
ElecNo(i)));
450 posZArray=elecGeomPointer->
Z(i);
451 std::ostringstream osnamephys;
452 osnamephys<<
"physicalLayer"<<i<<
"Ebox"<<j;
453 G4VPhysicalVolume*box_phys=
new G4PVPlacement(boxRotj,G4ThreeVector(posXArray,posYArray,posZArray),virtualBoxForEndcape_log,osnamephys.str(),mdc_log,
false,j);
459 G4double mCableDensity=6.4*g/cm3;
460 G4Material*materialCable=
new G4Material(
"M_materialCable",mCableDensity,3);
461 materialCable->AddElement(Cu,0.4);
462 materialCable->AddElement(
C,0.3);
463 materialCable->AddElement(
H,0.3);
465 double gapR=0.1*micrometer;
468 double innerRCableTub;
469 double outerRCableTub;
470 for(
int i=0;i<11;i++)
472 innerRCableTub=elecGeomPointer->
R(i)*mm-dxVirtualBox/2.+gapR;
473 outerRCableTub=elecGeomPointer->
R(i+1)*mm-dxVirtualBox/2.-gapR;
474 std::ostringstream osnameCableSolid;
475 osnameCableSolid<<
"MdcCableSolidWest"<<i;
476 G4Tubs*cableTub=
new G4Tubs(osnameCableSolid.str(),innerRCableTub,outerRCableTub,elecGeomPointer->
LengthCableTub(i+1)*1.15/2*mm,0*deg,360*deg);
478 std::ostringstream osnameCableLog;
479 osnameCableLog<<
"MdcCableLogWest"<<i;
480 G4LogicalVolume*cableTub_log=
new G4LogicalVolume(cableTub,materialCable,osnameCableLog.str());
481 visAtt=
new G4VisAttributes(G4Colour(1,0.3,0.5));
482 cableTub_log->SetVisAttributes(visAtt);
484 std::ostringstream osnameCablePhys;
485 osnameCablePhys<<
"MdcCablePhysWest"<<i;
486 G4VPhysicalVolume*cableTub_phys=
new G4PVPlacement(0,G4ThreeVector(0,0,elecGeomPointer->
Z(i)*mm-dzVirtualBox/2.*mm-(elecGeomPointer->
LengthCableTub(i+1))*1.15/2.*mm-0.2*mm),cableTub_log,osnameCablePhys.str(),mdc_log,
false,0);
490 for(
int i=0;i<10;i++)
492 innerRCableTub=elecGeomPointer->
R(i+12)-dxVirtualBox/2.+gapR;
493 outerRCableTub=elecGeomPointer->
R(i+12+1)-dxVirtualBox/2.-gapR;
494 std::ostringstream osnameCableSolid;
495 osnameCableSolid<<
"MdcCableSolidEast"<<i;
496 G4Tubs*cableTub=
new G4Tubs(osnameCableSolid.str(),innerRCableTub,outerRCableTub,elecGeomPointer->
LengthCableTub(i+14)*1.15/2*mm,0*deg,360*deg);
498 std::ostringstream osnameCableLog;
499 osnameCableLog<<
"MdcCableLogEast"<<i;
500 G4LogicalVolume*cableTub_log=
new G4LogicalVolume(cableTub,materialCable,osnameCableLog.str());
501 visAtt=
new G4VisAttributes(G4Colour(1,0.3,0.5));
502 cableTub_log->SetVisAttributes(visAtt);
504 std::ostringstream osnameCablePhys;
505 osnameCablePhys<<
"MdcCablePhysEast"<<i;
506 G4VPhysicalVolume*cableTub_phys=
new G4PVPlacement(0,G4ThreeVector(0,0,elecGeomPointer->
Z(i+12)*mm+dzVirtualBox/2.*mm+(elecGeomPointer->
LengthCableTub(i+14))*1.15/2.*mm+0.2*mm),cableTub_log,osnameCablePhys.str(),mdc_log,
false,0);
512 G4Tubs*cableTubBeginnerW=
new G4Tubs(
"solid cableTubBeginnerW",mdc->
Segment(30).
InnerR()*mm+gapR,elecGeomPointer->
R(0)*mm-dxVirtualBox/2.-gapR,elecGeomPointer->
LengthCableTub(0)*1.15/2.*mm,0*deg,360*deg);
513 G4LogicalVolume*cableTubBeginnerW_log=
new G4LogicalVolume(cableTubBeginnerW,materialCable,
"logical cableTubBeginnerW");
514 visAtt=
new G4VisAttributes(G4Colour(0,0.3,0.8));
515 cableTubBeginnerW_log->SetVisAttributes(visAtt);
516 G4VPhysicalVolume*cableTubBeginnerW_phys=
new G4PVPlacement(0,G4ThreeVector(0,0,elecGeomPointer->
Z(0)*mm-dzVirtualBox/2.*mm-(elecGeomPointer->
LengthCableTub(0))*1.15/2.*mm-0.2*mm),cableTubBeginnerW_log,
"physical cableTubBeginnerW",mdc_log,
false,0);
518 G4Tubs*cableTubBeginnerE=
new G4Tubs(
"solid cableBeginnerE",mdc->
Segment(30).
InnerR()*mm+gapR,elecGeomPointer->
R(12)*mm-dxVirtualBox/2.-gapR,elecGeomPointer->
LengthCableTub(13)*1.15/2.*mm,0*deg,360*deg);
519 G4LogicalVolume*cableTubBeginnerE_log=
new G4LogicalVolume(cableTubBeginnerE,materialCable,
"logical cabieTubBeginnerE");
520 visAtt=
new G4VisAttributes(G4Colour(1,0.3,0.5));
521 cableTubBeginnerE_log->SetVisAttributes(visAtt);
523 G4VPhysicalVolume*cableTubBeginnerE_phys=
new G4PVPlacement(0,G4ThreeVector(0,0,elecGeomPointer->
Z(13)*mm+dzVirtualBox/2.*mm+(elecGeomPointer->
LengthCableTub(13))*1.15/2.*mm+0.2*mm),cableTubBeginnerE_log,
"physical cableTubBeginnerE",mdc_log,
false,0);
528 G4Tubs*cableTubToTailW=
new G4Tubs(
"solid cabletubToTailW",elecGeomPointer->
R(11)*mm+gapR,mdc->
Segment(6).
InnerR()*mm-gapR,elecGeomPointer->
LengthCableTub(12)*1.15/2.*mm,0*deg,360*deg);
529 G4LogicalVolume*cableTubToTailW_log=
new G4LogicalVolume(cableTubToTailW,materialCable,
"logical cableTubToTailW");
530 visAtt=
new G4VisAttributes(G4Colour(0,0.3,0.8));
531 cableTubToTailW_log->SetVisAttributes(visAtt);
533 G4VPhysicalVolume*cableTubToTailW_phys=
new G4PVPlacement(0,G4ThreeVector(0,0,elecGeomPointer->
Z(11)*mm-dzVirtualBox/2.*mm-(elecGeomPointer->
LengthCableTub(12))*1.15/2.*mm-0.2*mm),cableTubToTailW_log,
"physical cableTubToTailW",mdc_log,
false,0);
535 G4Tubs*cableTubToTailE=
new G4Tubs(
"solid cabletubToTailE",elecGeomPointer->
R(22)*mm-dxVirtualBox/2.+gapR,mdc->
Segment(6).
InnerR()*mm-gapR,elecGeomPointer->
LengthCableTub(24)*1.15/2.*mm,0*deg,360*deg);
537 G4LogicalVolume*cableTubToTailE_log=
new G4LogicalVolume(cableTubToTailE,materialCable,
"logical cabieTubToTailE");
538 visAtt=
new G4VisAttributes(G4Colour(1.0,0.3,0.5));
539 cableTubToTailE_log->SetVisAttributes(visAtt);
541 G4VPhysicalVolume*cableTubToTailE_phys=
new G4PVPlacement(0,G4ThreeVector(0,0,elecGeomPointer->
Z(22)*mm+dzVirtualBox/2.*mm+(elecGeomPointer->
LengthCableTub(24))*1.15/2.*mm+0.2*mm),cableTubToTailE_log,
"physical cableTubToTailE",mdc_log,
false,0);
545 G4Box* box0=
new G4Box(
"box0",10.,15.,3.);
546 G4LogicalVolume* box0_log=
new G4LogicalVolume(box0,
Al,
"logicalBox0",0,0,0);
547 visAtt=
new G4VisAttributes(G4Colour(1.0,0.8,0.0));
548 box0_log->SetVisAttributes(visAtt);
550 G4Box* box1=
new G4Box(
"box1",3.*
cos(11.28*deg),15.,81./
sin(11.28*deg)/2.);
551 G4LogicalVolume* box1_log=
new G4LogicalVolume(box1,
Al,
"logicalBox1",0,0,0);
552 box1_log->SetVisAttributes(visAtt);
554 G4Box* box2=
new G4Box(
"box2",63.5,15.,3.);
555 G4LogicalVolume* box2_log=
new G4LogicalVolume(box2,
Al,
"logicalBox2",0,0,0);
556 box2_log->SetVisAttributes(visAtt);
560 G4RotationMatrix* boxRot0=
new G4RotationMatrix();
561 boxRot0->rotateZ(-45*i*deg);
562 posX=784.*
cos(45*i*deg);
563 posY=784.*
sin(45*i*deg);
565 std::ostringstream osnameBox0PhysEast;
566 osnameBox0PhysEast<<
"physical"<<
"box0p"<<i;
567 G4VPhysicalVolume* box0p_phys=
new G4PVPlacement(boxRot0,G4ThreeVector(posX ,posY ,posZ),
568 box0_log,osnameBox0PhysEast.str(),mdc_log,
false,i);
570 std::ostringstream osnameBox0PhysWest;
571 osnameBox0PhysWest<<
"physical"<<
"box0m"<<i;
572 G4VPhysicalVolume* box0m_phys=
new G4PVPlacement(boxRot0,G4ThreeVector(posX ,posY ,-posZ),
573 box0_log,osnameBox0PhysWest.str(),mdc_log,
false,i);
576 G4RotationMatrix* boxRot1p=
new G4RotationMatrix();
577 boxRot1p->rotateZ(-45*i*deg);
578 boxRot1p->rotateY(-78.72*deg);
579 posX=570.5*
cos(45*i*deg);
580 posY=570.5*
sin(45*i*deg);
582 std::ostringstream osnameBox1PhysEast;
583 osnameBox1PhysEast<<
"physical"<<
"box1p"<<i;
584 G4VPhysicalVolume* box1p_phys=
new G4PVPlacement(boxRot1p,G4ThreeVector(posX ,posY ,posZ),
585 box1_log,osnameBox1PhysEast.str(),mdc_log,
false,i);
587 G4RotationMatrix* boxRot1m=
new G4RotationMatrix();
588 boxRot1m->rotateZ(-45*i*deg);
589 boxRot1m->rotateY(78.72*deg);
590 std::ostringstream osnameBox1PhysWest;
591 osnameBox1PhysWest<<
"physical"<<
"box1m"<<i;
592 G4VPhysicalVolume* box1m_phys=
new G4PVPlacement(boxRot1m,G4ThreeVector(posX ,posY ,-posZ),
593 box1_log,osnameBox1PhysWest.str(),mdc_log,
false,i);
595 G4RotationMatrix* boxRot2=
new G4RotationMatrix();
596 boxRot2->rotateZ(-45*i*deg);
597 posX=303.5*
cos(45*i*deg);
598 posY=303.5*
sin(45*i*deg);
600 std::ostringstream osnameBox2PhysEast;
601 osnameBox2PhysEast<<
"physical"<<
"box2p"<<i;
602 G4VPhysicalVolume* box2p_phys=
new G4PVPlacement(boxRot2,G4ThreeVector(posX ,posY ,posZ),
603 box2_log,osnameBox2PhysEast.str(),mdc_log,
false,i);
605 std::ostringstream osnameBox2PhysWest;
606 osnameBox2PhysWest<<
"physical"<<
"box2m"<<i;
607 G4VPhysicalVolume* box2m_phys=
new G4PVPlacement(boxRot2,G4ThreeVector(posX ,posY ,-posZ),
608 box2_log,osnameBox2PhysWest.str(),mdc_log,
false,i);
612 G4double rMax2=774.*mm;
613 G4double rMin2=rMax2 - 1.*mm/
sin(11.28*deg);
614 G4double rMin1=rMin2 - 80.*mm/
tan(11.28*deg);
615 G4double rMax1=rMin1 + 1.*mm/
sin(11.28*deg);
616 G4Cons* shieldPlate0p=
new G4Cons(
"shieldPlate0p",rMin1,rMax1,rMin2,rMax2,40.*mm,0.,360.*deg);
617 G4LogicalVolume* shieldPlate0p_log=
new G4LogicalVolume(shieldPlate0p,
Al,
"logicalShieldPlate0p",0,0,0);
618 visAtt=
new G4VisAttributes(G4Colour(0.0,0.0,1.0));
619 shieldPlate0p_log->SetVisAttributes(visAtt);
623 G4VPhysicalVolume* shieldPlate0p_phys=
new G4PVPlacement(0,G4ThreeVector(posX ,posY ,posZ),
624 shieldPlate0p_log,
"physicalShieldPalte0p",mdc_log,
false,0);
626 G4Cons* shieldPlate0m=
new G4Cons(
"shieldPlate0m",rMin2,rMax2,rMin1,rMax1,40.*mm,0.,360.*deg);
627 G4LogicalVolume* shieldPlate0m_log=
new G4LogicalVolume(shieldPlate0m,
Al,
"logicalShieldPlate0m",0,0,0);
628 visAtt=
new G4VisAttributes(G4Colour(0.0,0.0,1.0));
629 shieldPlate0m_log->SetVisAttributes(visAtt);
633 G4VPhysicalVolume* shieldPlate0m_phys=
new G4PVPlacement(0,G4ThreeVector(posX ,posY ,-posZ),
634 shieldPlate0m_log,
"physicalShieldPalte0m",mdc_log,
false,0);
637 G4Tubs* shieldPlate1=
new G4Tubs(
"shieldPlate1",240.*mm,367.*mm,0.5*mm,0.,360.*deg);
638 G4LogicalVolume* shieldPlate1_log=
new G4LogicalVolume(shieldPlate1,
Al,
"logicalShieldPlate1",0,0,0);
639 visAtt=
new G4VisAttributes(G4Colour(1.0,0.0,0.0));
640 shieldPlate1_log->SetVisAttributes(visAtt);
644 G4VPhysicalVolume* shieldPlate1p_phys=
new G4PVPlacement(0,G4ThreeVector(posX ,posY ,posZ),
645 shieldPlate1_log,
"physicalShieldPalte1p",mdc_log,
false,0);
646 G4VPhysicalVolume* shieldPlate1m_phys=
new G4PVPlacement(0,G4ThreeVector(posX ,posY ,-posZ),
647 shieldPlate1_log,
"physicalShieldPalte1m",mdc_log,
false,0);
650 G4int signalLayer,firstWire;
654 G4double signalWireR=mdc->
SignalWireR()*micrometer;
655 G4double fieldWireR=mdc->
FieldWireR()*micrometer;
656 G4double thickOfAu=0.7*micrometer;
658 G4double innerLength,innerTwistAngle,innerTan,midInnerR,innerStereo;
659 G4double outLength,outTwistAngle,outTwistAngleFixed,outTan,midOutR,outStereo,outRFixed,outTanFixed;
662 for(i=42; i>35; i--){
666 innerR=mdc->
Layer(signalLayer-1+
n).
R()*mm-fieldWireR;
667 outR=mdc->
Layer(signalLayer+
n).
R()*mm-fieldWireR;
668 if(i==42&&
n==1)outR=mdc->
Layer(signalLayer+
n).
R()*mm+fieldWireR;
677 std::ostringstream osnameLayerSolid;
678 osnameLayerSolid <<
"solid"<<
"MdcAxialLayer"<<i<<
"_"<<
n;
679 G4Tubs* axialLayer_tube=
new G4Tubs(osnameLayerSolid.str(),innerR,outR,
length,startAngle,spanAngle);
681 std::ostringstream osnameLayerLogical;
682 osnameLayerLogical <<
"logical"<<
"MdcAxialLayer"<<i<<
"_"<<
n;
683 G4LogicalVolume* axialLayer_log=
new G4LogicalVolume(axialLayer_tube, MdcGas,osnameLayerLogical.str(),0,0,0);
685 axialLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
688 spanAngle=360./replicaNo*deg;
690 offset=mdc->
Layer(signalLayer).
Phi()*
rad-firstWire*spanAngle/2.;
691 G4RotationMatrix* layerRot=
new G4RotationMatrix();
692 layerRot->rotateZ(-offset);
694 std::ostringstream osnameLayerPhys;
695 osnameLayerPhys <<
"physical"<<
"MdcAxialLayer"<<i<<
"_"<<
n;
696 G4VPhysicalVolume* axialLayer_phys;
697 axialLayer_phys=
new G4PVPlacement(layerRot,
699 axialLayer_log,osnameLayerPhys.str(),mdc_log,
false,i);
702 std::ostringstream osnameCellSolid;
703 osnameCellSolid<<
"solid"<<
"MdcAxialLayer"<<i<<
"_"<<
n<<
"Cell";
704 G4Tubs* replica_tube=
new G4Tubs(osnameCellSolid.str(),innerR,outR,
length,startAngle,spanAngle);
706 std::ostringstream osnameCellLogical;
707 osnameCellLogical<<
"logical"<<
"MdcAxialLayer"<<i<<
"_"<<
n<<
"Cell";
708 G4LogicalVolume* replica_log=
new G4LogicalVolume(replica_tube,MdcGas,osnameCellLogical.str(),0,0,0);
710 replica_log->SetSensitiveDetector( aTrackerSD );
711 visAtt=
new G4VisAttributes(G4Colour(0.0,0.0,1.0));
712 replica_log->SetVisAttributes(visAtt);
713 replica_log->SetVisAttributes(G4VisAttributes::Invisible);
717 std::ostringstream osnameFieldWireSolid;
718 osnameFieldWireSolid<<
"solid"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWire";
719 G4Tubs* fieldWire_tube=
new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,
length,0.,360*deg);
720 std::ostringstream osnameFieldWireLogical;
721 osnameFieldWireLogical<<
"logical"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWire";
722 G4LogicalVolume* fieldWire_log=
new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
724 std::ostringstream osnameFieldWireSubSolid;
725 osnameFieldWireSubSolid<<
"solid"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWireSub";
726 G4Tubs* fieldWireSub_tube=
new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,
length,0.,360*deg);
727 std::ostringstream osnameFieldWireSubLogical;
728 osnameFieldWireSubLogical<<
"logical"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWireSub";
729 G4LogicalVolume* fieldWireSub_log=
new G4LogicalVolume(fieldWireSub_tube,
Al,osnameFieldWireSubLogical.str(),0,0,0);
730 std::ostringstream osnameFieldWireSubPhys;
731 osnameFieldWireSubPhys<<
"physical"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWireSub";
732 G4VPhysicalVolume* fieldWireSub_phys;
733 fieldWireSub_phys=
new G4PVPlacement(0,0,fieldWireSub_log,
734 osnameFieldWireSubPhys.str(),fieldWire_log,
false,0);
736 std::ostringstream osnameFieldWireHalfSolid;
737 osnameFieldWireHalfSolid<<
"solid"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWireHalf";
738 G4Tubs* fieldWireHalf_tube=
new G4Tubs(osnameFieldWireHalfSolid.str(),0.,fieldWireR,
length,0.,180*deg);
739 std::ostringstream osnameFieldWireHalfLogical;
740 osnameFieldWireHalfLogical<<
"logical"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWireHalf";
741 G4LogicalVolume* fieldWireHalf_log=
new G4LogicalVolume(fieldWireHalf_tube,Au,osnameFieldWireHalfLogical.str(),0,0,0);
743 std::ostringstream osnameFieldWireHalfSubSolid;
744 osnameFieldWireHalfSubSolid<<
"solid"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWireHalfSub";
745 G4Tubs* fieldWireHalfSub_tube=
new G4Tubs(osnameFieldWireHalfSubSolid.str(),0.,fieldWireR-thickOfAu,
length,0.,360*deg);
746 std::ostringstream osnameFieldWireHalfSubLogical;
747 osnameFieldWireHalfSubLogical<<
"logical"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWireHalfSub";
748 G4LogicalVolume* fieldWireHalfSub_log=
new G4LogicalVolume(fieldWireHalfSub_tube,
Al,osnameFieldWireHalfSubLogical.str(),0,0,0);
749 std::ostringstream osnameFieldWireHalfSubPhys;
750 osnameFieldWireHalfSubPhys<<
"physical"<<
"AxialLayer"<<i<<
"_"<<
n<<
"FieldWireHalfSub";
751 G4VPhysicalVolume* fieldWireHalfSub_phys;
752 fieldWireHalfSub_phys=
new G4PVPlacement(0,0,fieldWireHalfSub_log,
753 osnameFieldWireHalfSubPhys.str(),fieldWireHalf_log,
false,0);
764 std::ostringstream osnameFieldWire0Phys;
765 osnameFieldWire0Phys<<
"physicalAxialLayer"<<i<<
"_"<<
n<<
"FieldWire0";
766 posX=mdc->
Layer(signalLayer-1).
R()*mm;
767 G4VPhysicalVolume* fieldWire0_phys;
768 fieldWire0_phys=
new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
769 osnameFieldWire0Phys.str(),replica_log,
false,0);
771 std::ostringstream osnameFieldWire3Phys;
772 osnameFieldWire3Phys<<
"physicalAxialLayer"<<i<<
"_"<<
n<<
"FieldWire3";
773 posX=mdc->
Layer(signalLayer-1).
R()*mm*
cos(spanAngle/2.);
774 posY=mdc->
Layer(signalLayer-1).
R()*mm*
sin(spanAngle/2.);
775 G4VPhysicalVolume* fieldWire3_phys;
776 fieldWire3_phys=
new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
777 osnameFieldWire3Phys.str(),replica_log,
false,3);
778 std::ostringstream osnameFieldWire6Phys;
779 osnameFieldWire6Phys<<
"physicalAxialLayer"<<i<<
"_"<<
n<<
"FieldWire6";
780 posX=mdc->
Layer(signalLayer-1).
R()*mm*
cos(spanAngle);
781 posY=mdc->
Layer(signalLayer-1).
R()*mm*
sin(spanAngle);
782 G4RotationMatrix* wireRot6=
new G4RotationMatrix();
783 wireRot6->rotateZ(180*deg-spanAngle);
784 G4VPhysicalVolume* fieldWire6_phys;
785 fieldWire6_phys=
new G4PVPlacement(wireRot6,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
786 osnameFieldWire6Phys.str(),replica_log,
false,6);
790 std::ostringstream osnameFieldWire1Phys;
791 osnameFieldWire1Phys<<
"physicalAxialLayer"<<i<<
"_"<<
n<<
"FieldWire1";
792 posX=mdc->
Layer(signalLayer).
R()*mm;
793 G4VPhysicalVolume* fieldWire1_phys;
794 fieldWire1_phys=
new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
795 osnameFieldWire1Phys.str(),replica_log,
false,1);
796 std::ostringstream osnameSignalWireSolid;
797 osnameSignalWireSolid<<
"solid"<<
"AxialLayer"<<i<<
"_"<<
n<<
"SignalWire";
798 G4Tubs* signalWire_tube=
new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,
length,0.,360*deg);
799 std::ostringstream osnameSignalWireLogical;
800 osnameSignalWireLogical<<
"logical"<<
"AxialLayer"<<i<<
"_"<<
n<<
"SignalWire";
801 G4LogicalVolume* signalWire_log=
new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
803 std::ostringstream osnameSignalWireSubSolid;
804 osnameSignalWireSubSolid<<
"solid"<<
"AxialLayer"<<i<<
"_"<<
n<<
"SignalWireSub";
805 G4Tubs* signalWireSub_tube=
new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,
length,0.,360*deg);
806 std::ostringstream osnameSignalWireSubLogical;
807 osnameSignalWireSubLogical<<
"logical"<<
"AxialLayer"<<i<<
"_"<<
n<<
"SignalWireSub";
808 G4LogicalVolume* signalWireSub_log=
new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
809 std::ostringstream osnameSignalWireSubPhys;
810 osnameSignalWireSubPhys<<
"physical"<<
"AxialLayer"<<i<<
"_"<<
n<<
"SignalWireSub";
811 G4VPhysicalVolume* signalWireSub_phys;
812 signalWireSub_phys=
new G4PVPlacement(0,0,signalWireSub_log,
813 osnameSignalWireSubPhys.str(),signalWire_log,
false,0);
815 std::ostringstream osnameSignalWirePhys;
816 osnameSignalWirePhys<<
"physicalAxialLayer"<<i<<
"_"<<
n<<
"SignalWire4";
817 posX=mdc->
Layer(signalLayer).
R()*mm*
cos(spanAngle/2.);
818 posY=mdc->
Layer(signalLayer).
R()*mm*
sin(spanAngle/2.);
819 G4VPhysicalVolume* signalWire_phys;
820 signalWire_phys=
new G4PVPlacement(0,G4ThreeVector(posX,posY,0),signalWire_log,
821 osnameSignalWirePhys.str(),replica_log,
false,4);
823 std::ostringstream osnameFieldWire7Phys;
824 osnameFieldWire7Phys<<
"physicalAxialLayer"<<i<<
"_"<<
n<<
"FieldWire7";
825 posX=mdc->
Layer(signalLayer).
R()*mm*
cos(spanAngle);
826 posY=mdc->
Layer(signalLayer).
R()*mm*
sin(spanAngle);
827 G4RotationMatrix* wireRot7=
new G4RotationMatrix();
828 wireRot7->rotateZ(180*deg-spanAngle);
829 G4VPhysicalVolume* fieldWire7_phys;
830 fieldWire7_phys=
new G4PVPlacement(wireRot7,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
831 osnameFieldWire7Phys.str(),replica_log,
false,7);
833 std::ostringstream osnameFieldWire2Phys;
834 osnameFieldWire2Phys<<
"physicalAxialLayer"<<i<<
"_"<<
n<<
"FieldWire2";
835 posX=mdc->
Layer(signalLayer+1).
R()*mm;
836 G4VPhysicalVolume* fieldWire2_phys;
837 fieldWire2_phys=
new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
838 osnameFieldWire2Phys.str(),replica_log,
false,2);
840 std::ostringstream osnameFieldWire5Phys;
841 osnameFieldWire5Phys<<
"physicalAxialLayer"<<i<<
"_"<<
n<<
"FieldWire5";
842 posX=mdc->
Layer(signalLayer+1).
R()*mm*
cos(spanAngle/2.);
843 posY=mdc->
Layer(signalLayer+1).
R()*mm*
sin(spanAngle/2.);
844 G4VPhysicalVolume* fieldWire5_phys;
845 fieldWire5_phys=
new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
846 osnameFieldWire5Phys.str(),replica_log,
false,5);
848 std::ostringstream osnameFieldWire8Phys;
849 osnameFieldWire8Phys<<
"physicalAxialLayer"<<i<<
"_"<<
n<<
"FieldWire8";
850 posX=mdc->
Layer(signalLayer+1).
R()*mm*
cos(spanAngle);
851 posY=mdc->
Layer(signalLayer+1).
R()*mm*
sin(spanAngle);
852 G4RotationMatrix* wireRot8=
new G4RotationMatrix();
853 wireRot8->rotateZ(180*deg-spanAngle);
854 G4VPhysicalVolume* fieldWire8_phys;
855 fieldWire8_phys=
new G4PVPlacement(wireRot8,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
856 osnameFieldWire8Phys.str(),replica_log,
false,8);
861 for(j=replicaNo-1;j>-1;j--){
862 G4RotationMatrix* cellRot=
new G4RotationMatrix();
863 cellRot->rotateZ(-spanAngle*j);
864 std::ostringstream osnameCellPhys;
865 osnameCellPhys<<
"physical"<<
"MdcAxialLayer"<<i<<
"_"<<
n<<
"Cell"<<j;
866 G4VPhysicalVolume* replica_phys;
867 replica_phys=
new G4PVPlacement(cellRot,0,replica_log,
868 osnameCellPhys.str(),axialLayer_log,
false,j);
876 for(i=35; i>19; i--){
879 innerR=mdc->
Layer(signalLayer-1).
R()*mm-fieldWireR;
880 outR=mdc->
Layer(signalLayer+1).
R()*mm-fieldWireR;
881 if(i==35)outR=mdc->
Layer(signalLayer+1).
R()*mm+fieldWireR;
883 innerLength=(mdc->
Layer(signalLayer-1).Length())/2.*mm;
884 outLength=(mdc->
Layer(signalLayer+1).Length())/2.*mm;
889 innerTan=innerR/innerLength*
sin(innerTwistAngle);
891 midInnerR=innerR*
cos(innerTwistAngle);
892 innerStereo=atan(innerTan);
894 outTan=outR/outLength*
sin(outTwistAngle);
895 outTwistAngleFixed=atan(innerLength/outLength*
tan(outTwistAngle));
897 if(
abs(outTwistAngleFixed) >=
abs(innerTwistAngle)){
898 midOutR=outR*
cos(outTwistAngle);
899 outRFixed=midOutR/
cos(innerTwistAngle);
902 outTanFixed=midOutR/innerLength*
tan(innerTwistAngle);
903 outStereo=atan(outTanFixed);
905 outRFixed=sqrt(outR*outR+(innerLength*innerLength-outLength*outLength)*outTan*outTan);
907 midOutR=outR*
cos(innerTwistAngle);
909 outTanFixed=outRFixed/innerLength*
sin(innerTwistAngle);
910 outStereo=atan(outTanFixed);
913 std::ostringstream osnameLayerSolid;
914 osnameLayerSolid <<
"solid"<<
"MdcStereoLayer"<<i;
916 G4Hype* stereoLayer_hype=
new G4Hype(osnameLayerSolid.str(),midInnerR, midOutR,innerStereo,
917 outStereo,innerLength);
919 std::ostringstream osnameLayerLogical;
920 osnameLayerLogical <<
"logical"<<
"MdcStereoLayer"<<i;
921 G4LogicalVolume* stereoLayer_log=
new G4LogicalVolume(stereoLayer_hype,MdcGas,
922 osnameLayerLogical.str(),0,0,0);
923 stereoLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
926 spanAngle=360./replicaNo*deg;
929 G4RotationMatrix* layerRot=
new G4RotationMatrix();
930 layerRot->rotateZ(-(spanAngle*(1-firstWire)/2.+innerTwistAngle));
932 std::ostringstream osnameLayerPhys;
933 osnameLayerPhys<<
"physical"<<
"MdcStereoLayer"<<i;
934 G4VPhysicalVolume* stereoLayer_phys;
935 stereoLayer_phys=
new G4PVPlacement(layerRot,0,stereoLayer_log,osnameLayerPhys.str(),
938 std::ostringstream osnameCellSolid;
939 osnameCellSolid<<
"solid"<<
"MdcStereoLayer"<<i<<
"Cell";
941 G4TwistedTubs* twistTub=
new G4TwistedTubs(osnameCellSolid.str(), -innerTwistAngle*2, innerR,outR-1.0*micrometer,innerLength,spanAngle);
943 std::ostringstream osnameCellLogical;
944 osnameCellLogical<<
"logical"<<
"MdcStereoLayer"<<i<<
"Cell";
945 G4LogicalVolume* twistTub_log=
new G4LogicalVolume(twistTub, MdcGas,osnameCellLogical.str(),0,0,0);
947 twistTub_log->SetVisAttributes(G4VisAttributes::Invisible);
948 twistTub_log->SetSensitiveDetector( aTrackerSD );
953 std::ostringstream osnameFieldWireSolid;
954 osnameFieldWireSolid<<
"solid"<<
"StereoLayer"<<i<<
"FieldWire";
955 G4Tubs* fieldWire_tube=
new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,innerLength,0.,360*deg);
956 std::ostringstream osnameFieldWireLogical;
957 osnameFieldWireLogical<<
"logical"<<
"StereoLayer"<<i<<
"FieldWire";
958 G4LogicalVolume* fieldWire_log=
new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
960 std::ostringstream osnameFieldWireSubSolid;
961 osnameFieldWireSubSolid<<
"solid"<<
"StereoLayer"<<i<<
"FieldWireSub";
962 G4Tubs* fieldWireSub_tube=
new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,innerLength,0.,360*deg);
963 std::ostringstream osnameFieldWireSubLogical;
964 osnameFieldWireSubLogical<<
"logical"<<
"StereoLayer"<<i<<
"FieldWireSub";
965 G4LogicalVolume* fieldWireSub_log=
new G4LogicalVolume(fieldWireSub_tube,
Al,osnameFieldWireSubLogical.str(),0,0,0);
966 std::ostringstream osnameFieldWireSubPhys;
967 osnameFieldWireSubPhys<<
"physical"<<
"StereoLayer"<<i<<
"FieldWireSub";
968 G4VPhysicalVolume* fieldWireSub_phys;
969 fieldWireSub_phys=
new G4PVPlacement(0,0,fieldWireSub_log,
970 osnameFieldWireSubPhys.str(),fieldWire_log,
false,0);
972 std::ostringstream osnameSignalWireSolid;
973 osnameSignalWireSolid<<
"solid"<<
"StereoLayer"<<i<<
"SignalWire";
974 G4Tubs* signalWire_tube=
new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,innerLength,0.,360*deg);
975 std::ostringstream osnameSignalWireLogical;
976 osnameSignalWireLogical<<
"logical"<<
"StereoLayer"<<i<<
"SignalWire";
977 G4LogicalVolume* signalWire_log=
new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
979 std::ostringstream osnameSignalWireSubSolid;
980 osnameSignalWireSubSolid<<
"solid"<<
"StereoLayer"<<i<<
"SignalWireSub";
981 G4Tubs* signalWireSub_tube=
new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,innerLength,0.,360*deg);
982 std::ostringstream osnameSignalWireSubLogical;
983 osnameSignalWireSubLogical<<
"logical"<<
"StereoLayer"<<i<<
"SignalWireSub";
984 G4LogicalVolume* signalWireSub_log=
new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
985 std::ostringstream osnameSignalWireSubPhys;
986 osnameSignalWireSubPhys<<
"physical"<<
"StereoLayer"<<i<<
"SignalWireSub";
987 G4VPhysicalVolume* signalWireSub_phys;
988 signalWireSub_phys=
new G4PVPlacement(0,0,signalWireSub_log,
989 osnameSignalWireSubPhys.str(),signalWire_log,
false,0);
998 G4double shiftR,midR,eastX,eastY,westX,westY;
999 shiftR=fieldWireR+1*micrometer;
1000 midR=mdc->
Layer(signalLayer).
R()*mm;
1002 std::ostringstream osnameFieldWire0Phys;
1003 osnameFieldWire0Phys<<
"physicalStereoLayer"<<i<<
"FieldWire0";
1005 eastX=(innerR+shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle)+shiftR*
cos(90*deg-innerTwistAngle);
1006 eastY=(innerR+shiftR/
cos(innerTwistAngle))*
sin(-innerTwistAngle)+shiftR*
sin(90*deg-innerTwistAngle);
1007 westX=(innerR+shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle)+shiftR*
cos(90*deg+innerTwistAngle);
1008 westY=(innerR+shiftR/
cos(innerTwistAngle))*
sin(innerTwistAngle)+shiftR*
sin(90*deg+innerTwistAngle);
1010 G4ThreeVector east0(eastX,eastY,innerLength);
1011 G4ThreeVector west0(westX,westY,-innerLength);
1012 east0.rotateZ(-spanAngle/2.);
1013 west0.rotateZ(-spanAngle/2.);
1015 posX=(east0.x()+west0.x())/2.;
1016 posY=(east0.y()+west0.y())/2.;
1017 G4ThreeVector line0=east0-west0;
1018 G4RotationMatrix* wireRot0=
new G4RotationMatrix();
1019 wireRot0->rotateZ(-line0.phi());
1020 wireRot0->rotateY(-line0.theta());
1021 G4VPhysicalVolume* fieldWire0_phys;
1022 fieldWire0_phys=
new G4PVPlacement(wireRot0,G4ThreeVector(posX,posY,0),fieldWire_log,
1023 osnameFieldWire0Phys.str(),twistTub_log,
false,0);
1025 std::ostringstream osnameFieldWire1Phys;
1026 osnameFieldWire1Phys<<
"physicalStereoLayer"<<i<<
"FieldWire1";
1027 eastX=midR*
cos(innerTwistAngle)+shiftR*
cos(90*deg-innerTwistAngle);
1028 eastY=midR*
sin(-innerTwistAngle)+shiftR*
sin(90*deg-innerTwistAngle);
1029 westX=midR*
cos(innerTwistAngle)+shiftR*
cos(90*deg+innerTwistAngle);
1030 westY=midR*
sin(innerTwistAngle)+shiftR*
sin(90*deg+innerTwistAngle);
1031 G4ThreeVector east1(eastX,eastY,innerLength);
1032 G4ThreeVector west1(westX,westY,-innerLength);
1033 east1.rotateZ(-spanAngle/2.);
1034 west1.rotateZ(-spanAngle/2.);
1035 posX=(east1.x()+west1.x())/2.;
1036 posY=(east1.y()+west1.y())/2.;
1037 G4ThreeVector line1=east1-west1;
1038 G4RotationMatrix* wireRot1=
new G4RotationMatrix();
1039 wireRot1->rotateZ(-line1.phi());
1040 wireRot1->rotateY(-line1.theta());
1041 G4VPhysicalVolume* fieldWire1_phys;
1042 fieldWire1_phys=
new G4PVPlacement(wireRot1,G4ThreeVector(posX,posY,0),fieldWire_log,
1043 osnameFieldWire1Phys.str(),twistTub_log,
false,1);
1045 std::ostringstream osnameFieldWire3Phys;
1046 osnameFieldWire3Phys<<
"physicalStereoLayer"<<i<<
"FieldWire3";
1048 eastX=(innerR+shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle);
1049 eastY=(innerR+shiftR/
cos(innerTwistAngle))*
sin(-innerTwistAngle);
1050 westX=(innerR+shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle);
1051 westY=(innerR+shiftR/
cos(innerTwistAngle))*
sin(innerTwistAngle);
1053 G4ThreeVector east3(eastX,eastY,innerLength);
1054 G4ThreeVector west3(westX,westY,-innerLength);
1056 posX=(east3.x()+west3.x())/2.;
1057 posY=(east3.y()+west3.y())/2.;
1058 G4ThreeVector line3=east3-west3;
1059 G4RotationMatrix* wireRot3=
new G4RotationMatrix();
1060 wireRot3->rotateZ(-line3.phi());
1061 wireRot3->rotateY(-line3.theta());
1062 G4VPhysicalVolume* fieldWire3_phys;
1063 fieldWire3_phys=
new G4PVPlacement(wireRot3,G4ThreeVector(posX,posY,0),fieldWire_log,
1064 osnameFieldWire3Phys.str(),twistTub_log,
false,3);
1066 std::ostringstream osnameSignalWire4Phys;
1067 osnameSignalWire4Phys<<
"physicalStereoLayer"<<i<<
"SignalWire4";
1069 eastX=midR*
cos(innerTwistAngle);
1070 eastY=midR*
sin(-innerTwistAngle);
1071 westX=midR*
cos(innerTwistAngle);
1072 westY=midR*
sin(innerTwistAngle);
1074 G4ThreeVector east4(eastX,eastY,innerLength);
1075 G4ThreeVector west4(westX,westY,-innerLength);
1077 posX=(east4.x()+west4.x())/2.;
1078 posY=(east4.y()+west4.y())/2.;
1079 G4ThreeVector line4=east4-west4;
1080 G4RotationMatrix* wireRot4=
new G4RotationMatrix();
1081 wireRot4->rotateZ(-line4.phi());
1082 wireRot4->rotateY(-line4.theta());
1083 G4VPhysicalVolume* signalWire4_phys;
1084 signalWire4_phys=
new G4PVPlacement(wireRot4,G4ThreeVector(posX,posY,0),signalWire_log,
1085 osnameSignalWire4Phys.str(),twistTub_log,
false,4);
1088 std::ostringstream osnameFieldWire2Phys;
1089 osnameFieldWire2Phys<<
"physicalStereoLayer"<<i<<
"FieldWire2";
1091 eastX=(outR-shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle)+shiftR*
cos(90*deg-innerTwistAngle);
1092 eastY=(outR-shiftR/
cos(innerTwistAngle))*
sin(-innerTwistAngle)+shiftR*
sin(90*deg-innerTwistAngle);
1093 westX=(outR-shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle)+shiftR*
cos(90*deg+innerTwistAngle);
1094 westY=(outR-shiftR/
cos(innerTwistAngle))*
sin(innerTwistAngle)+shiftR*
sin(90*deg+innerTwistAngle);
1096 G4ThreeVector east2(eastX,eastY,innerLength);
1097 G4ThreeVector west2(westX,westY,-innerLength);
1098 east2.rotateZ(-spanAngle/2.);
1099 west2.rotateZ(-spanAngle/2.);
1101 posX=(east2.x()+west2.x())/2.;
1102 posY=(east2.y()+west2.y())/2.;
1103 G4ThreeVector line2=east2-west2;
1104 G4RotationMatrix* wireRot2=
new G4RotationMatrix();
1105 wireRot2->rotateZ(-line2.phi());
1106 wireRot2->rotateY(-line2.theta());
1107 G4VPhysicalVolume* fieldWire2_phys;
1108 fieldWire2_phys=
new G4PVPlacement(wireRot2,G4ThreeVector(posX,posY,0),fieldWire_log,
1109 osnameFieldWire2Phys.str(),twistTub_log,
false,2);
1111 std::ostringstream osnameFieldWire5Phys;
1112 osnameFieldWire5Phys<<
"physicalStereoLayer"<<i<<
"FieldWire5";
1114 eastX=(outR-shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle);
1115 eastY=(outR-shiftR/
cos(innerTwistAngle))*
sin(-innerTwistAngle);
1116 westX=(outR-shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle);
1117 westY=(outR-shiftR/
cos(innerTwistAngle))*
sin(innerTwistAngle);
1119 G4ThreeVector east5(eastX,eastY,innerLength);
1120 G4ThreeVector west5(westX,westY,-innerLength);
1122 posX=(east5.x()+west5.x())/2.;
1123 posY=(east5.y()+west5.y())/2.;
1124 G4ThreeVector line5=east5-west5;
1125 G4RotationMatrix* wireRot5=
new G4RotationMatrix();
1126 wireRot5->rotateZ(-line5.phi());
1127 wireRot5->rotateY(-line5.theta());
1128 G4VPhysicalVolume* fieldWire5_phys;
1129 fieldWire5_phys=
new G4PVPlacement(wireRot5,G4ThreeVector(posX,posY,0),fieldWire_log,
1130 osnameFieldWire5Phys.str(),twistTub_log,
false,5);
1134 for(j=replicaNo-1;j>-1;j--){
1135 G4RotationMatrix* cellRot=
new G4RotationMatrix();
1136 cellRot->rotateZ(-spanAngle*j);
1138 std::ostringstream osnameCellPhys;
1139 osnameCellPhys<<
"physical"<<
"MdcStereoLayer"<<i<<
"Cell"<<j;
1140 G4VPhysicalVolume* twistTub_phys;
1141 twistTub_phys=
new G4PVPlacement(cellRot,0,twistTub_log,
1142 osnameCellPhys.str(),stereoLayer_log,
false,j);
1147 for(i=19; i>7; i--){
1149 innerR=mdc->
Layer(signalLayer-1).
R()*mm-fieldWireR;
1150 outR=mdc->
Layer(signalLayer+1).
R()*mm-fieldWireR;
1151 if(i==19)outR=mdc->
Layer(signalLayer+1).
R()*mm+fieldWireR;
1161 std::ostringstream osnameLayerSolid;
1162 osnameLayerSolid <<
"solid"<<
"MdcAxialLayer"<<i;
1163 G4Tubs* axialLayer_tube=
new G4Tubs(osnameLayerSolid.str(),innerR,outR,
length,startAngle,spanAngle);
1165 std::ostringstream osnameLayerLogical;
1166 osnameLayerLogical <<
"logical"<<
"MdcAxialLayer"<<i;
1167 G4LogicalVolume* axialLayer_log=
new G4LogicalVolume(axialLayer_tube, MdcGas,osnameLayerLogical.str(),0,0,0);
1168 axialLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
1171 spanAngle=360./replicaNo*deg;
1173 offset=mdc->
Layer(signalLayer).
Phi()*
rad-firstWire*spanAngle/2.;
1174 G4RotationMatrix* layerRot=
new G4RotationMatrix();
1175 layerRot->rotateZ(-offset);
1177 std::ostringstream osnameLayerPhys;
1178 osnameLayerPhys<<
"physical"<<
"MdcAxialLayer"<<i;
1179 G4VPhysicalVolume* axialLayer_phys;
1180 axialLayer_phys=
new G4PVPlacement(layerRot,0,axialLayer_log,
1181 osnameLayerPhys.str(),mdc_log,
false,i);
1184 std::ostringstream osnameCellSolid;
1185 osnameCellSolid<<
"solid"<<
"MdcAxialLayer"<<i<<
"Cell";
1186 G4Tubs* replica_tube=
new G4Tubs(osnameCellSolid.str(),innerR,outR,
length,startAngle,spanAngle);
1188 std::ostringstream osnameCellLogical;
1189 osnameCellLogical<<
"logical"<<
"MdcAxialLayer"<<i<<
"Cell";
1190 G4LogicalVolume* replica_log=
new G4LogicalVolume(replica_tube,MdcGas,osnameCellLogical.str(),0,0,0);
1192 replica_log->SetSensitiveDetector( aTrackerSD );
1193 visAtt=
new G4VisAttributes(G4Colour(0.0,0.0,1.0));
1194 replica_log->SetVisAttributes(visAtt);
1195 replica_log->SetVisAttributes(G4VisAttributes::Invisible);
1199 std::ostringstream osnameFieldWireSolid;
1200 osnameFieldWireSolid<<
"solid"<<
"AxialLayer"<<i<<
"FieldWire";
1201 G4Tubs* fieldWire_tube=
new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,
length,0.,360*deg);
1202 std::ostringstream osnameFieldWireLogical;
1203 osnameFieldWireLogical<<
"logical"<<
"AxialLayer"<<i<<
"FieldWire";
1204 G4LogicalVolume* fieldWire_log=
new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
1206 std::ostringstream osnameFieldWireSubSolid;
1207 osnameFieldWireSubSolid<<
"solid"<<
"AxialLayer"<<i<<
"FieldWireSub";
1208 G4Tubs* fieldWireSub_tube=
new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,
length,0.,360*deg);
1209 std::ostringstream osnameFieldWireSubLogical;
1210 osnameFieldWireSubLogical<<
"logical"<<
"AxialLayer"<<i<<
"FieldWireSub";
1211 G4LogicalVolume* fieldWireSub_log=
new G4LogicalVolume(fieldWireSub_tube,
Al,osnameFieldWireSubLogical.str(),0,0,0);
1212 std::ostringstream osnameFieldWireSubPhys;
1213 osnameFieldWireSubPhys<<
"physical"<<
"AxialLayer"<<i<<
"FieldWireSub";
1214 G4VPhysicalVolume* fieldWireSub_phys;
1215 fieldWireSub_phys=
new G4PVPlacement(0,0,fieldWireSub_log,
1216 osnameFieldWireSubPhys.str(),fieldWire_log,
false,0);
1218 std::ostringstream osnameFieldWireHalfSolid;
1219 osnameFieldWireHalfSolid<<
"solid"<<
"AxialLayer"<<i<<
"FieldWireHalf";
1220 G4Tubs* fieldWireHalf_tube=
new G4Tubs(osnameFieldWireHalfSolid.str(),0.,fieldWireR,
length,0.,180*deg);
1221 std::ostringstream osnameFieldWireHalfLogical;
1222 osnameFieldWireHalfLogical<<
"logical"<<
"AxialLayer"<<i<<
"FieldWireHalf";
1223 G4LogicalVolume* fieldWireHalf_log=
new G4LogicalVolume(fieldWireHalf_tube,Au,osnameFieldWireHalfLogical.str(),0,0,0);
1225 std::ostringstream osnameFieldWireHalfSubSolid;
1226 osnameFieldWireHalfSubSolid<<
"solid"<<
"AxialLayer"<<i<<
"FieldWireHalfSub";
1227 G4Tubs* fieldWireHalfSub_tube=
new G4Tubs(osnameFieldWireHalfSubSolid.str(),0.,fieldWireR-thickOfAu,
length,0.,360*deg);
1228 std::ostringstream osnameFieldWireHalfSubLogical;
1229 osnameFieldWireHalfSubLogical<<
"logical"<<
"AxialLayer"<<i<<
"FieldWireHalfSub";
1230 G4LogicalVolume* fieldWireHalfSub_log=
new G4LogicalVolume(fieldWireHalfSub_tube,
Al,osnameFieldWireHalfSubLogical.str(),0,0,0);
1231 std::ostringstream osnameFieldWireHalfSubPhys;
1232 osnameFieldWireHalfSubPhys<<
"physical"<<
"AxialLayer"<<i<<
"FieldWireHalfSub";
1233 G4VPhysicalVolume* fieldWireHalfSub_phys;
1234 fieldWireHalfSub_phys=
new G4PVPlacement(0,0,fieldWireHalfSub_log,
1235 osnameFieldWireHalfSubPhys.str(),fieldWireHalf_log,
false,0);
1237 std::ostringstream osnameSignalWireSolid;
1238 osnameSignalWireSolid<<
"solid"<<
"AxialLayer"<<i<<
"SignalWire";
1239 G4Tubs* signalWire_tube=
new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,
length,0.,360*deg);
1240 std::ostringstream osnameSignalWireLogical;
1241 osnameSignalWireLogical<<
"logical"<<
"AxialLayer"<<i<<
"SignalWire";
1242 G4LogicalVolume* signalWire_log=
new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
1244 std::ostringstream osnameSignalWireSubSolid;
1245 osnameSignalWireSubSolid<<
"solid"<<
"AxialLayer"<<i<<
"SignalWireSub";
1246 G4Tubs* signalWireSub_tube=
new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,
length,0.,360*deg);
1247 std::ostringstream osnameSignalWireSubLogical;
1248 osnameSignalWireSubLogical<<
"logical"<<
"AxialLayer"<<i<<
"SignalWireSub";
1249 G4LogicalVolume* signalWireSub_log=
new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
1250 std::ostringstream osnameSignalWireSubPhys;
1251 osnameSignalWireSubPhys<<
"physical"<<
"AxialLayer"<<i<<
"SignalWireSub";
1252 G4VPhysicalVolume* signalWireSub_phys;
1253 signalWireSub_phys=
new G4PVPlacement(0,0,signalWireSub_log,
1254 osnameSignalWireSubPhys.str(),signalWire_log,
false,0);
1263 std::ostringstream osnameFieldWire0Phys;
1264 osnameFieldWire0Phys<<
"physicalAxialLayer"<<i<<
"FieldWire0";
1265 posX=mdc->
Layer(signalLayer-1).
R()*mm;
1266 G4VPhysicalVolume* fieldWire0_phys;
1267 fieldWire0_phys=
new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
1268 osnameFieldWire0Phys.str(),replica_log,
false,0);
1270 std::ostringstream osnameFieldWire1Phys;
1271 osnameFieldWire1Phys<<
"physicalAxialLayer"<<i<<
"FieldWire1";
1272 posX=mdc->
Layer(signalLayer).
R()*mm;
1273 G4VPhysicalVolume* fieldWire1_phys;
1274 fieldWire1_phys=
new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
1275 osnameFieldWire1Phys.str(),replica_log,
false,1);
1278 std::ostringstream osnameFieldWire2Phys;
1279 osnameFieldWire2Phys<<
"physicalAxialLayer"<<i<<
"FieldWire2";
1280 posX=mdc->
Layer(signalLayer+1).
R()*mm;
1281 G4VPhysicalVolume* fieldWire2_phys;
1282 fieldWire2_phys=
new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
1283 osnameFieldWire2Phys.str(),replica_log,
false,2);
1286 std::ostringstream osnameFieldWire3Phys;
1287 osnameFieldWire3Phys<<
"physicalAxialLayer"<<i<<
"FieldWire3";
1288 posX=mdc->
Layer(signalLayer-1).
R()*mm*
cos(spanAngle/2.);
1289 posY=mdc->
Layer(signalLayer-1).
R()*mm*
sin(spanAngle/2.);
1290 G4VPhysicalVolume* fieldWire3_phys;
1291 fieldWire3_phys=
new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
1292 osnameFieldWire3Phys.str(),replica_log,
false,3);
1294 std::ostringstream osnameSignalWirePhys;
1295 osnameSignalWirePhys<<
"physicalAxialLayer"<<i<<
"SignalWire4";
1296 posX=mdc->
Layer(signalLayer).
R()*mm*
cos(spanAngle/2.);
1297 posY=mdc->
Layer(signalLayer).
R()*mm*
sin(spanAngle/2.);
1298 G4VPhysicalVolume* signalWire_phys;
1299 signalWire_phys=
new G4PVPlacement(0,G4ThreeVector(posX,posY,0),signalWire_log,
1300 osnameSignalWirePhys.str(),replica_log,
false,4);
1303 std::ostringstream osnameFieldWire5Phys;
1304 osnameFieldWire5Phys<<
"physicalAxialLayer"<<i<<
"FieldWire5";
1305 posX=mdc->
Layer(signalLayer+1).
R()*mm*
cos(spanAngle/2.);
1306 posY=mdc->
Layer(signalLayer+1).
R()*mm*
sin(spanAngle/2.);
1307 G4VPhysicalVolume* fieldWire5_phys;
1308 fieldWire5_phys=
new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
1309 osnameFieldWire5Phys.str(),replica_log,
false,5);
1312 std::ostringstream osnameFieldWire6Phys;
1313 osnameFieldWire6Phys<<
"physicalAxialLayer"<<i<<
"FieldWire6";
1314 posX=mdc->
Layer(signalLayer-1).
R()*mm*
cos(spanAngle);
1315 posY=mdc->
Layer(signalLayer-1).
R()*mm*
sin(spanAngle);
1316 G4RotationMatrix* wireRot6=
new G4RotationMatrix();
1317 wireRot6->rotateZ(180*deg-spanAngle);
1318 G4VPhysicalVolume* fieldWire6_phys;
1319 fieldWire6_phys=
new G4PVPlacement(wireRot6,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
1320 osnameFieldWire6Phys.str(),replica_log,
false,6);
1322 std::ostringstream osnameFieldWire7Phys;
1323 osnameFieldWire7Phys<<
"physicalAxialLayer"<<i<<
"FieldWire7";
1324 posX=mdc->
Layer(signalLayer).
R()*mm*
cos(spanAngle);
1325 posY=mdc->
Layer(signalLayer).
R()*mm*
sin(spanAngle);
1326 G4RotationMatrix* wireRot7=
new G4RotationMatrix();
1327 wireRot7->rotateZ(180*deg-spanAngle);
1328 G4VPhysicalVolume* fieldWire7_phys;
1329 fieldWire7_phys=
new G4PVPlacement(wireRot7,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
1330 osnameFieldWire7Phys.str(),replica_log,
false,7);
1333 std::ostringstream osnameFieldWire8Phys;
1334 osnameFieldWire8Phys<<
"physicalAxialLayer"<<i<<
"FieldWire8";
1335 posX=mdc->
Layer(signalLayer+1).
R()*mm*
cos(spanAngle);
1336 posY=mdc->
Layer(signalLayer+1).
R()*mm*
sin(spanAngle);
1337 G4RotationMatrix* wireRot8=
new G4RotationMatrix();
1338 wireRot8->rotateZ(180*deg-spanAngle);
1339 G4VPhysicalVolume* fieldWire8_phys;
1340 fieldWire8_phys=
new G4PVPlacement(wireRot8,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
1341 osnameFieldWire8Phys.str(),replica_log,
false,8);
1345 for(j=replicaNo-1;j>-1;j--){
1346 G4RotationMatrix* cellRot=
new G4RotationMatrix();
1347 cellRot->rotateZ(-spanAngle*j);
1349 std::ostringstream osnameCellPhys;
1350 osnameCellPhys<<
"physical"<<
"MdcAxialLayer"<<i<<
"Cell"<<j;
1351 G4VPhysicalVolume* replica_phys;
1352 replica_phys=
new G4PVPlacement(cellRot,0,replica_log,
1353 osnameCellPhys.str(),axialLayer_log,
false,j);
1361 for(i=7; i>innestLayer; i--){
1364 innerR=mdc->
Layer(signalLayer-1).
R()*mm-fieldWireR;
1365 outR=mdc->
Layer(signalLayer+1).
R()*mm-fieldWireR;
1366 if(i==7)outR=mdc->
Layer(signalLayer+1).
R()*mm+fieldWireR;
1368 innerLength=(mdc->
Layer(signalLayer-1).Length())/2.*mm;
1369 outLength=(mdc->
Layer(signalLayer+1).Length())/2.*mm;
1374 innerTan=innerR/innerLength*
sin(innerTwistAngle);
1376 midInnerR=innerR*
cos(innerTwistAngle);
1377 innerStereo=atan(innerTan);
1379 outTan=outR/outLength*
sin(outTwistAngle);
1380 outTwistAngleFixed=atan(innerLength/outLength*
tan(outTwistAngle));
1382 if(
abs(outTwistAngleFixed) >=
abs(innerTwistAngle)){
1383 midOutR=outR*
cos(outTwistAngle);
1384 outRFixed=midOutR/
cos(innerTwistAngle);
1387 outTanFixed=midOutR/innerLength*
tan(innerTwistAngle);
1388 outStereo=atan(outTanFixed);
1390 outRFixed=sqrt(outR*outR+(innerLength*innerLength-outLength*outLength)*outTan*outTan);
1392 midOutR=outR*
cos(innerTwistAngle);
1394 outTanFixed=outRFixed/innerLength*
sin(innerTwistAngle);
1395 outStereo=atan(outTanFixed);
1399 std::ostringstream osnameLayerSolid;
1400 osnameLayerSolid <<
"solid"<<
"MdcStereoLayer"<<i;
1402 G4Hype* stereoLayer_hype=
new G4Hype(osnameLayerSolid.str(),midInnerR, midOutR,innerStereo,
1403 outStereo,innerLength);
1404 std::ostringstream osnameLayerLogical;
1405 osnameLayerLogical <<
"logical"<<
"MdcStereoLayer"<<i;
1406 G4LogicalVolume* stereoLayer_log=
new G4LogicalVolume(stereoLayer_hype,MdcGas,
1407 osnameLayerLogical.str(),0,0,0);
1408 stereoLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
1411 spanAngle=360./replicaNo*deg;
1414 G4RotationMatrix* layerRot=
new G4RotationMatrix();
1415 layerRot->rotateZ(-(spanAngle*(1-firstWire)/2.+innerTwistAngle));
1417 std::ostringstream osnameLayerPhys;
1418 osnameLayerPhys<<
"physical"<<
"MdcStereoLayer"<<i;
1420 G4VPhysicalVolume* stereoLayer_phys;
1421 stereoLayer_phys=
new G4PVPlacement(layerRot,0,stereoLayer_log,osnameLayerPhys.str(),
1425 std::ostringstream osnameCellSolid;
1426 osnameCellSolid<<
"solid"<<
"MdcStereoLayer"<<i<<
"Cell";
1428 G4TwistedTubs* twistTub=
new G4TwistedTubs(osnameCellSolid.str(), -innerTwistAngle*2, innerR,outR-1.0*micrometer,innerLength,spanAngle);
1430 std::ostringstream osnameCellLogical;
1431 osnameCellLogical<<
"logical"<<
"MdcStereoLayer"<<i<<
"Cell";
1432 G4LogicalVolume* twistTub_log=
new G4LogicalVolume(twistTub, MdcGas,osnameCellLogical.str(),0,0,0);
1434 twistTub_log->SetVisAttributes(G4VisAttributes::Invisible);
1435 twistTub_log->SetSensitiveDetector( aTrackerSD );
1439 std::ostringstream osnameFieldWireSolid;
1440 osnameFieldWireSolid<<
"solid"<<
"StereoLayer"<<i<<
"FieldWire";
1441 G4Tubs* fieldWire_tube=
new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,innerLength,0.,360*deg);
1442 std::ostringstream osnameFieldWireLogical;
1443 osnameFieldWireLogical<<
"logical"<<
"StereoLayer"<<i<<
"FieldWire";
1444 G4LogicalVolume* fieldWire_log=
new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
1446 std::ostringstream osnameFieldWireSubSolid;
1447 osnameFieldWireSubSolid<<
"solid"<<
"StereoLayer"<<i<<
"FieldWireSub";
1448 G4Tubs* fieldWireSub_tube=
new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,innerLength,0.,360*deg);
1449 std::ostringstream osnameFieldWireSubLogical;
1450 osnameFieldWireSubLogical<<
"logical"<<
"StereoLayer"<<i<<
"FieldWireSub";
1451 G4LogicalVolume* fieldWireSub_log=
new G4LogicalVolume(fieldWireSub_tube,
Al,osnameFieldWireSubLogical.str(),0,0,0);
1452 std::ostringstream osnameFieldWireSubPhys;
1453 osnameFieldWireSubPhys<<
"physical"<<
"StereoLayer"<<i<<
"FieldWireSub";
1454 G4VPhysicalVolume* fieldWireSub_phys;
1455 fieldWireSub_phys=
new G4PVPlacement(0,0,fieldWireSub_log,
1456 osnameFieldWireSubPhys.str(),fieldWire_log,
false,0);
1459 std::ostringstream osnameSignalWireSolid;
1460 osnameSignalWireSolid<<
"solid"<<
"StereoLayer"<<i<<
"SignalWire";
1461 G4Tubs* signalWire_tube=
new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,innerLength,0.,360*deg);
1462 std::ostringstream osnameSignalWireLogical;
1463 osnameSignalWireLogical<<
"logical"<<
"StereoLayer"<<i<<
"SignalWire";
1464 G4LogicalVolume* signalWire_log=
new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
1466 std::ostringstream osnameSignalWireSubSolid;
1467 osnameSignalWireSubSolid<<
"solid"<<
"StereoLayer"<<i<<
"SignalWireSub";
1468 G4Tubs* signalWireSub_tube=
new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,innerLength,0.,360*deg);
1469 std::ostringstream osnameSignalWireSubLogical;
1470 osnameSignalWireSubLogical<<
"logical"<<
"StereoLayer"<<i<<
"SignalWireSub";
1471 G4LogicalVolume* signalWireSub_log=
new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
1472 std::ostringstream osnameSignalWireSubPhys;
1473 osnameSignalWireSubPhys<<
"physical"<<
"StereoLayer"<<i<<
"SignalWireSub";
1474 G4VPhysicalVolume* signalWireSub_phys;
1475 signalWireSub_phys=
new G4PVPlacement(0,0,signalWireSub_log,
1476 osnameSignalWireSubPhys.str(),signalWire_log,
false,0);
1485 G4double shiftR,midR,eastX,eastY,westX,westY;
1486 shiftR=fieldWireR+1*micrometer;
1487 midR=mdc->
Layer(signalLayer).
R()*mm;
1489 std::ostringstream osnameFieldWire0Phys;
1490 osnameFieldWire0Phys<<
"physicalStereoLayer"<<i<<
"FieldWire0";
1492 eastX=(innerR+shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle)+shiftR*
cos(90*deg-innerTwistAngle);
1493 eastY=(innerR+shiftR/
cos(innerTwistAngle))*
sin(-innerTwistAngle)+shiftR*
sin(90*deg-innerTwistAngle);
1494 westX=(innerR+shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle)+shiftR*
cos(90*deg+innerTwistAngle);
1495 westY=(innerR+shiftR/
cos(innerTwistAngle))*
sin(innerTwistAngle)+shiftR*
sin(90*deg+innerTwistAngle);
1497 G4ThreeVector east0(eastX,eastY,innerLength);
1498 G4ThreeVector west0(westX,westY,-innerLength);
1499 east0.rotateZ(-spanAngle/2.);
1500 west0.rotateZ(-spanAngle/2.);
1502 posX=(east0.x()+west0.x())/2.;
1503 posY=(east0.y()+west0.y())/2.;
1504 G4ThreeVector line0=east0-west0;
1505 G4RotationMatrix* wireRot0=
new G4RotationMatrix();
1506 wireRot0->rotateZ(-line0.phi());
1507 wireRot0->rotateY(-line0.theta());
1508 G4VPhysicalVolume* fieldWire0_phys;
1509 fieldWire0_phys=
new G4PVPlacement(wireRot0,G4ThreeVector(posX,posY,0),fieldWire_log,
1510 osnameFieldWire0Phys.str(),twistTub_log,
false,0);
1512 std::ostringstream osnameFieldWire1Phys;
1513 osnameFieldWire1Phys<<
"physicalStereoLayer"<<i<<
"FieldWire1";
1514 eastX=midR*
cos(innerTwistAngle)+shiftR*
cos(90*deg-innerTwistAngle);
1515 eastY=midR*
sin(-innerTwistAngle)+shiftR*
sin(90*deg-innerTwistAngle);
1516 westX=midR*
cos(innerTwistAngle)+shiftR*
cos(90*deg+innerTwistAngle);
1517 westY=midR*
sin(innerTwistAngle)+shiftR*
sin(90*deg+innerTwistAngle);
1518 G4ThreeVector east1(eastX,eastY,innerLength);
1519 G4ThreeVector west1(westX,westY,-innerLength);
1520 east1.rotateZ(-spanAngle/2.);
1521 west1.rotateZ(-spanAngle/2.);
1522 posX=(east1.x()+west1.x())/2.;
1523 posY=(east1.y()+west1.y())/2.;
1524 G4ThreeVector line1=east1-west1;
1525 G4RotationMatrix* wireRot1=
new G4RotationMatrix();
1526 wireRot1->rotateZ(-line1.phi());
1527 wireRot1->rotateY(-line1.theta());
1528 G4VPhysicalVolume* fieldWire1_phys;
1529 fieldWire1_phys=
new G4PVPlacement(wireRot1,G4ThreeVector(posX,posY,0),fieldWire_log,
1530 osnameFieldWire1Phys.str(),twistTub_log,
false,1);
1532 std::ostringstream osnameFieldWire3Phys;
1533 osnameFieldWire3Phys<<
"physicalStereoLayer"<<i<<
"FieldWire3";
1535 eastX=(innerR+shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle);
1536 eastY=(innerR+shiftR/
cos(innerTwistAngle))*
sin(-innerTwistAngle);
1537 westX=(innerR+shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle);
1538 westY=(innerR+shiftR/
cos(innerTwistAngle))*
sin(innerTwistAngle);
1540 G4ThreeVector east3(eastX,eastY,innerLength);
1541 G4ThreeVector west3(westX,westY,-innerLength);
1543 posX=(east3.x()+west3.x())/2.;
1544 posY=(east3.y()+west3.y())/2.;
1545 G4ThreeVector line3=east3-west3;
1546 G4RotationMatrix* wireRot3=
new G4RotationMatrix();
1547 wireRot3->rotateZ(-line3.phi());
1548 wireRot3->rotateY(-line3.theta());
1549 G4VPhysicalVolume* fieldWire3_phys;
1550 fieldWire3_phys=
new G4PVPlacement(wireRot3,G4ThreeVector(posX,posY,0),fieldWire_log,
1551 osnameFieldWire3Phys.str(),twistTub_log,
false,3);
1553 std::ostringstream osnameSignalWire4Phys;
1554 osnameSignalWire4Phys<<
"physicalStereoLayer"<<i<<
"SignalWire4";
1556 eastX=midR*
cos(innerTwistAngle);
1557 eastY=midR*
sin(-innerTwistAngle);
1558 westX=midR*
cos(innerTwistAngle);
1559 westY=midR*
sin(innerTwistAngle);
1561 G4ThreeVector east4(eastX,eastY,innerLength);
1562 G4ThreeVector west4(westX,westY,-innerLength);
1564 posX=(east4.x()+west4.x())/2.;
1565 posY=(east4.y()+west4.y())/2.;
1566 G4ThreeVector line4=east4-west4;
1567 G4RotationMatrix* wireRot4=
new G4RotationMatrix();
1568 wireRot4->rotateZ(-line4.phi());
1569 wireRot4->rotateY(-line4.theta());
1570 G4VPhysicalVolume* signalWire4_phys;
1571 signalWire4_phys=
new G4PVPlacement(wireRot4,G4ThreeVector(posX,posY,0),signalWire_log,
1572 osnameSignalWire4Phys.str(),twistTub_log,
false,4);
1575 std::ostringstream osnameFieldWire2Phys;
1576 osnameFieldWire2Phys<<
"physicalStereoLayer"<<i<<
"FieldWire2";
1578 eastX=(outR-shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle)+shiftR*
cos(90*deg-innerTwistAngle);
1579 eastY=(outR-shiftR/
cos(innerTwistAngle))*
sin(-innerTwistAngle)+shiftR*
sin(90*deg-innerTwistAngle);
1580 westX=(outR-shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle)+shiftR*
cos(90*deg+innerTwistAngle);
1581 westY=(outR-shiftR/
cos(innerTwistAngle))*
sin(innerTwistAngle)+shiftR*
sin(90*deg+innerTwistAngle);
1583 G4ThreeVector east2(eastX,eastY,innerLength);
1584 G4ThreeVector west2(westX,westY,-innerLength);
1585 east2.rotateZ(-spanAngle/2.);
1586 west2.rotateZ(-spanAngle/2.);
1588 posX=(east2.x()+west2.x())/2.;
1589 posY=(east2.y()+west2.y())/2.;
1590 G4ThreeVector line2=east2-west2;
1591 G4RotationMatrix* wireRot2=
new G4RotationMatrix();
1592 wireRot2->rotateZ(-line2.phi());
1593 wireRot2->rotateY(-line2.theta());
1594 G4VPhysicalVolume* fieldWire2_phys;
1595 fieldWire2_phys=
new G4PVPlacement(wireRot2,G4ThreeVector(posX,posY,0),fieldWire_log,
1596 osnameFieldWire2Phys.str(),twistTub_log,
false,2);
1598 std::ostringstream osnameFieldWire5Phys;
1599 osnameFieldWire5Phys<<
"physicalStereoLayer"<<i<<
"FieldWire5";
1601 eastX=(outR-shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle);
1602 eastY=(outR-shiftR/
cos(innerTwistAngle))*
sin(-innerTwistAngle);
1603 westX=(outR-shiftR/
cos(innerTwistAngle))*
cos(innerTwistAngle);
1604 westY=(outR-shiftR/
cos(innerTwistAngle))*
sin(innerTwistAngle);
1606 G4ThreeVector east5(eastX,eastY,innerLength);
1607 G4ThreeVector west5(westX,westY,-innerLength);
1609 posX=(east5.x()+west5.x())/2.;
1610 posY=(east5.y()+west5.y())/2.;
1611 G4ThreeVector line5=east5-west5;
1612 G4RotationMatrix* wireRot5=
new G4RotationMatrix();
1613 wireRot5->rotateZ(-line5.phi());
1614 wireRot5->rotateY(-line5.theta());
1615 G4VPhysicalVolume* fieldWire5_phys;
1616 fieldWire5_phys=
new G4PVPlacement(wireRot5,G4ThreeVector(posX,posY,0),fieldWire_log,
1617 osnameFieldWire5Phys.str(),twistTub_log,
false,5);
1621 for(j=replicaNo-1;j>-1;j--){
1622 G4RotationMatrix* cellRot=
new G4RotationMatrix();
1623 cellRot->rotateZ(-spanAngle*j);
1625 std::ostringstream osnameCellPhys;
1626 osnameCellPhys<<
"physical"<<
"MdcStereoLayer"<<i<<
"Cell"<<j;
1627 G4VPhysicalVolume* twistTub_phys;
1628 twistTub_phys=
new G4PVPlacement(cellRot,0,twistTub_log,
1629 osnameCellPhys.str(),stereoLayer_log,
false,j);
1632 G4cout<<
"MyMessage::The Most Inner Mdc LayerID: "<<i<<G4endl;