BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMdcConstruction.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------
2// BOOST --- BESIII Object_Oriented Simulation Tool
3//---------------------------------------------------------------------------/
4//Description: Main part for construct MDC geometry
5//Author: Yuan Ye([email protected])
6//Created: 4 Dec, 2003
7//Modified:
8//Comment:
9//---------------------------------------------------------------------------/
10
11#include "BesMdcConstruction.hh"
12#include "ReadBoostRoot.hh"
13
14#include "G4Material.hh"
15#include "G4Box.hh"
16#include "G4Tubs.hh"
17#include "G4Hype.hh"
18#include "G4LogicalVolume.hh"
19#include "G4PVPlacement.hh"
20#include "G4PVReplica.hh"
21#include "G4TwistedTubs.hh"
22#include "G4SDManager.hh"
23
24#include "G4UserLimits.hh"
25
26#include "G4VisAttributes.hh"
27#include "G4Colour.hh"
28#include "G4ios.hh"
29#include "G4Geo/MdcG4Geo.h"
30
31#include "MyMdcGeomSvc.hh"
32#include "G4Cons.hh"
33
35 : mdc_log(0),mdc_phys(0){
37}
38
40}
41
42//**************************************************************************
43
44void BesMdcConstruction::Construct(G4LogicalVolume* logicBes){
45 //------------------------------------------------
46 // Sensitive detectors
47 //------------------------------------------------
48 G4SDManager* SDman = G4SDManager::GetSDMpointer();
49 G4String mdcSDname = "BesMdcSD";
50 aTrackerSD = new BesMdcSD( mdcSDname);
51 SDman->AddNewDetector( aTrackerSD );
52
53 if(ReadBoostRoot::GetTuning())return; //No construct when tuning
54 //Construct
55 G4LogicalVolume *logicalMdc = 0;
56 G4LogicalVolume *lv = 0;
57
58 if(ReadBoostRoot::GetMdc()==2){
59 MdcG4Geo* aMdcG4Geo = new MdcG4Geo();
60 logicalMdc = aMdcG4Geo->GetTopVolume();
61 if(!logicalMdc){
62 G4cout<<"BesMdcConstruction::Construct(), logicalMdc not found"<<G4endl;
63 }else{
64 //construct Mdc
65 mdc_phys = new G4PVPlacement(0,G4ThreeVector(0,0,0),
66 logicalMdc, "physicalMdc",logicBes, false, 0);
67 logicalMdc->SetVisAttributes(G4VisAttributes::Invisible);
68
69 //visual attributes and sensitive detector
70 G4VisAttributes* visAttStereoLayer = new G4VisAttributes(G4Colour(0.,1.,0.));
71 G4VisAttributes* visAttAxialLayer = new G4VisAttributes(G4Colour(1.,0.,0.));
72 G4int segmentNo=mdc->SegmentNo();
73 G4double colorShift = 0., shift = 1.0 / (segmentNo-1);
74
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);
81 if(lv) {
82 lv->SetVisAttributes(visAttSegment);
83 //lv->SetVisAttributes(G4VisAttributes::Invisible);
84 }
85 else G4cout << "logical volume " << osnameSegment.str() << "not found " << G4endl;
86 colorShift +=shift;
87 }
88
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() );
93 if(lv) {
94 lv->SetVisAttributes(visAttStereoLayer);
95 lv->SetVisAttributes(G4VisAttributes::Invisible);
96 }
97 else G4cout << "logical volume " << osnameStereoLayer.str() << "not found " << G4endl;
98
99 std::ostringstream osnameTwistedTubs;
100 osnameTwistedTubs << "logical" << "Mdc" << "StereoLayer" << i << "Cell";
101 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameTwistedTubs.str() );
102 if(lv) {
103 lv->SetSensitiveDetector( aTrackerSD );
104 lv->SetVisAttributes(G4VisAttributes::Invisible);
105 }
106 else G4cout << "logical volume " << osnameTwistedTubs.str() << "not found " << G4endl;
107 }
108
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() );
113 if(lv) {
114 lv->SetVisAttributes(visAttStereoLayer);
115 lv->SetVisAttributes(G4VisAttributes::Invisible);
116 }
117 else G4cout << "logical volume " << osnameStereoLayer.str() << "not found " << G4endl;
118
119 std::ostringstream osnameTwistedTubs;
120 osnameTwistedTubs << "logical" << "Mdc" << "StereoLayer" << i << "Cell";
121 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameTwistedTubs.str() );
122 if(lv) {
123 lv->SetSensitiveDetector( aTrackerSD );
124 lv->SetVisAttributes(G4VisAttributes::Invisible);
125 }
126 else G4cout << "logical volume " << osnameTwistedTubs.str() << "not found " << G4endl;
127 }
128
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() );
133 if(lv) {
134 lv->SetVisAttributes(visAttAxialLayer);
135 lv->SetVisAttributes(G4VisAttributes::Invisible);
136 }
137 else G4cout << "logical volume " << osnameAxialLayer.str() << "not found " << G4endl;
138
139 std::ostringstream osnameReplica;
140 osnameReplica << "logical" << "Mdc" << "AxialLayer" << i << "Cell";
141 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameReplica.str() );
142 if(lv) {
143 lv->SetSensitiveDetector( aTrackerSD );
144 lv->SetVisAttributes(G4VisAttributes::Invisible);
145 }
146 else G4cout << "logical volume " << osnameReplica.str() << "not found " << G4endl;
147 }
148
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() );
154 if(lv) {
155 lv->SetVisAttributes(visAttAxialLayer);
156 lv->SetVisAttributes(G4VisAttributes::Invisible);
157 }
158 else G4cout << "logical volume " << osnameAxialLayer.str() << "not found " << G4endl;
159
160 std::ostringstream osnameReplica;
161 osnameReplica << "logical" << "Mdc" << "AxialLayer" << i << "_" << n << "Cell";
162 lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameReplica.str() );
163 if(lv) {
164 lv->SetSensitiveDetector( aTrackerSD );
165 lv->SetVisAttributes(G4VisAttributes::Invisible);
166 }
167 else G4cout << "logical volume " << osnameReplica.str() << "not found " << G4endl;
168 }
169 }
170 }
171 delete aMdcG4Geo;
172 }else {
173 //construct with previous code.
174 if(ReadBoostRoot::GetMdc()==3)G4cout<<"Nowire in Mdc Construct"<<G4endl;
175
176 //--------- Materials ---------
177
178 // Mdcgas He/C3H8 (60:40)
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");
184
185 G4double density = 19.3*g/cm3;
186 G4double a = 183.84*g/mole;
187 G4Material* W = new G4Material("Tungsten", 74., a, density);
188
189 density=19.32*g/cm3;
190 a = 196.967*g/mole;
191 G4Material* Au= new G4Material("Au",79,a,density);
192
193 density=1.57*g/cm3;
194 G4int nElement=3;
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);
199
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);
205
206 //Begin construct
207 G4int i,j,k,n;
208 G4double outR, innerR, length;
209 G4double startAngle, spanAngle;
210 G4double posX, posY, posZ;
211 G4VisAttributes* visAtt;
212 string name;
213 //=======Mdc container
214
215 outR=mdc->Segment(0).OutR()*mm;
216 innerR=mdc->Segment(0).InnerR()*mm;
217 length=mdc->Segment(0).Length()/2.*mm; //In Geant4, soild has central-symmetry
218
219 startAngle=0.*deg;
220 spanAngle=360.*deg;
221 posX = 0.*m;
222 posY = 0.*m;
223 posZ = 0.*m;
224
225 G4Tubs* mdc_tube=new G4Tubs("solidMdc",innerR,outR,length,startAngle,spanAngle);
226 mdc_log=new G4LogicalVolume(mdc_tube, MdcGas,"logicalMdc",0,0,0);
227 mdc_log->SetVisAttributes(G4VisAttributes::Invisible);
228
229 //limits of step length
230 // G4double maxStep = 20.*mm;
231
232
233 mdc_phys= new G4PVPlacement(0,
234 G4ThreeVector(posX ,posY ,posZ),
235 mdc_log,"physicalMdc",logicBes,false,0);
236
237
238 //======Tube and Endplane
239
240 G4double colorShift=0., shift=1./(mdc->SegmentNo()-1);
241 G4double gap=0.5*micrometer;
242 for(i=1; i<mdc->SegmentNo(); i++){
243 outR=mdc->Segment(i).OutR()*mm-gap;
244 innerR=mdc->Segment(i).InnerR()*mm+gap;
245 length=mdc->Segment(i).Length()/2.*mm-gap;
246 startAngle=0*deg;
247 spanAngle=360*deg;
248 posZ=mdc->Segment(i).Z()*mm;
249 //name=mdc->Segment(i).Name();
250 name="MdcSegment";
251 std::ostringstream osnameSolid;
252 osnameSolid << "solid"<<name<<i;
253 G4Tubs* segment_tube=new G4Tubs(osnameSolid.str(),innerR,outR,length,startAngle,spanAngle);
254 std::ostringstream osnameLogical;
255 osnameLogical << "logical"<<name<<i;
256 G4LogicalVolume* segment_log;
257 if(i==1||i==2){
258 segment_log=new G4LogicalVolume(segment_tube, CarbonFiber,osnameLogical.str(),0,0,0);
259 }else{
260 segment_log=new G4LogicalVolume(segment_tube, Al,osnameLogical.str(),0,0,0);
261 }
262
263 visAtt= new G4VisAttributes(G4Colour(1.0-colorShift,0.0+colorShift,0.0));
264 if(i<3)visAtt->SetForceWireframe(true);
265 segment_log->SetVisAttributes(visAtt);
266 //segment_log->SetVisAttributes(G4VisAttributes::Invisible);
267 colorShift +=shift;
268
269 G4VPhysicalVolume* segment_phys;
270 std::ostringstream osnamePhys1;
271 osnamePhys1 << "physical"<<name<<i<<"p";
272 segment_phys=new G4PVPlacement(0,
273 G4ThreeVector(posX ,posY ,posZ),
274 segment_log,osnamePhys1.str(),mdc_log,false,0);
275 //Endplane have two parts at +-Z
276 if(i>2){
277 std::ostringstream osnamePhys2;
278 osnamePhys2 << "physical"<<name<<i<<"m";
279 segment_phys=new G4PVPlacement(0,
280 G4ThreeVector(posX ,posY ,-posZ),
281 segment_log,osnamePhys2.str(),mdc_log,false,0);
282 }
283
284 }
285 //shielding film of inner & outer tube
286
287 outR=mdc->Segment(2).InnerR()*mm-gap;
288 innerR=mdc->Segment(2).InnerR()*mm-100*micrometer;
289 length=mdc->Segment(2).Length()/2.*mm-gap-10*mm;
290 startAngle=0*deg;
291 spanAngle=360*deg;
292 posZ=mdc->Segment(2).Z()*mm;
293 G4Tubs* segment_tube1=new G4Tubs("SolidMdcInnerFilm0",innerR,outR,length,startAngle,spanAngle);
294 G4LogicalVolume* segment_log1;
295 segment_log1=new G4LogicalVolume(segment_tube1, Al,"LogicalMdcInnerFilm0",0,0,0);
296 G4VisAttributes* visAtt1= new G4VisAttributes(G4Colour(0,1.0,0.0));
297 segment_log1->SetVisAttributes(visAtt1);
298 G4VPhysicalVolume* segment_phys1;
299 segment_phys1=new G4PVPlacement(0,
300 G4ThreeVector(posX ,posY ,posZ),
301 segment_log1,"PhysicalMdcInnerFilm0",mdc_log,false,0);
302
303 outR=mdc->Segment(2).OutR()*mm+50*micrometer;
304 innerR=mdc->Segment(2).OutR()*mm+gap;
305 length=mdc->Segment(2).Length()/2.*mm-gap;
306 startAngle=0*deg;
307 spanAngle=360*deg;
308 posZ=mdc->Segment(2).Z()*mm;
309 G4Tubs* segment_tube2=new G4Tubs("SolidMdcInnerFilm1",innerR,outR,length,startAngle,spanAngle);
310 G4LogicalVolume* segment_log2;
311 segment_log2=new G4LogicalVolume(segment_tube2, Al,"LogicalMdcInnerFilm1",0,0,0);
312 G4VisAttributes* visAtt2= new G4VisAttributes(G4Colour(0,0.0,1.0));
313 segment_log2->SetVisAttributes(visAtt2);
314 G4VPhysicalVolume* segment_phys2;
315 segment_phys2=new G4PVPlacement(0,
316 G4ThreeVector(posX ,posY ,posZ),
317 segment_log2,"PhysicalMdcInnerFilm1",mdc_log,false,0);
318
319 outR=mdc->Segment(1).InnerR()*mm-gap;
320 innerR=mdc->Segment(1).InnerR()*mm-100*micrometer;
321 length=mdc->Segment(1).Length()/2.*mm-gap;
322 startAngle=0*deg;
323 spanAngle=360*deg;
324 posZ=mdc->Segment(1).Z()*mm;
325 G4Tubs* segment_tube3=new G4Tubs("SolidMdcOutFilm0",innerR,outR,length,startAngle,spanAngle);
326 G4LogicalVolume* segment_log3;
327 segment_log3=new G4LogicalVolume(segment_tube3, Al,"LogicalMdcOutFilm0",0,0,0);
328 G4VisAttributes* visAtt3= new G4VisAttributes(G4Colour(0,1.0,0.0));
329 segment_log3->SetVisAttributes(visAtt3);
330 G4VPhysicalVolume* segment_phys3;
331 segment_phys3=new G4PVPlacement(0,
332 G4ThreeVector(posX ,posY ,posZ),
333 segment_log3,"PhysicalMdcOutFilm0",mdc_log,false,0);
334
335 outR=mdc->Segment(1).OutR()*mm+100*micrometer;
336 innerR=mdc->Segment(1).OutR()*mm+gap;
337 length=mdc->Segment(1).Length()/2.*mm-gap;
338 startAngle=0*deg;
339 spanAngle=360*deg;
340 posZ=mdc->Segment(1).Z()*mm;
341 G4Tubs* segment_tube4=new G4Tubs("SolidMdcOutFilm1",innerR,outR,length,startAngle,spanAngle);
342 G4LogicalVolume* segment_log4;
343 segment_log4=new G4LogicalVolume(segment_tube4, Al,"LogicalMdcOutFilm1",0,0,0);
344 G4VisAttributes* visAtt4= new G4VisAttributes(G4Colour(0,0.0,1.0));
345 segment_log4->SetVisAttributes(visAtt4);
346 G4VPhysicalVolume* segment_phys4;
347 segment_phys4=new G4PVPlacement(0,
348 G4ThreeVector(posX ,posY ,posZ),
349 segment_log4,"PhysicalMdcOutFilm1",mdc_log,false,0);
350
351 outR=mdc->Segment(1).OutR()*mm+150*micrometer;
352 innerR=mdc->Segment(1).OutR()*mm+100*micrometer+gap;
353 length=mdc->Segment(1).Length()/2.*mm-gap;
354 startAngle=0*deg;
355 spanAngle=360*deg;
356 posZ=mdc->Segment(1).Z()*mm;
357 G4Tubs* segment_tube5=new G4Tubs("SolidMdcOutFilm2",innerR,outR,length,startAngle,spanAngle);
358 G4LogicalVolume* segment_log5;
359 segment_log5=new G4LogicalVolume(segment_tube5, Kapton,"LogicalMdcOutFilm2",0,0,0);
360 G4VisAttributes* visAtt5= new G4VisAttributes(G4Colour(0,0.5,0.5));
361 segment_log5->SetVisAttributes(visAtt5);
362 G4VPhysicalVolume* segment_phys5;
363 segment_phys5=new G4PVPlacement(0,
364 G4ThreeVector(posX ,posY ,posZ),
365 segment_log5,"PhysicalMdcOutFilm2",mdc_log,false,0);
366
367
368 MyMdcGeomSvc* elecGeomPointer= new MyMdcGeomSvc();
369
370 // sustain ring which is used to fix electronic box
371
372 G4Tubs*fixTub=new G4Tubs("solidFixTub",elecGeomPointer->FixRing(0)*mm,elecGeomPointer->FixRing(1)*mm,elecGeomPointer->FixRing(2)/2.*mm,0.*deg,360.*deg);
373 G4LogicalVolume*fixTub_log=new G4LogicalVolume(fixTub,Al,"logicalFixTub");
374 G4VPhysicalVolume*fixTub_phys1=new G4PVPlacement(0,G4ThreeVector(0,0,1134.5*mm),fixTub_log,"physcalFixTub1",mdc_log,false,0);
375 G4VPhysicalVolume*fixTub_phys2=new G4PVPlacement(0,G4ThreeVector(0,0,-1134.5*mm),fixTub_log,"physicalFixTub2",mdc_log,false,0);
376
377
378 G4Element *Cu=G4Element::GetElement("Copper");
379 G4Element *Si=G4Element::GetElement("Silicon");
380
381 // construct east and west endcape
382 G4double boxDensityEndcape=1.9745*g/cm3;
383 G4int boxNcomponenEndcape=6;
384 G4Material *Cuu = G4Material::GetMaterial("Copper");
385 // construct material or element using another method!but you must include "G4NistManager.hh"
386 // G4NistManager*man=G4NistManager::Instance();
387 // G4Element*Cl=man->FindOrBuildElement("Cl");
388
389 G4Element *Cl =new G4Element("Chlorine","Cl",17.,35.5*g/mole);
390 G4Material*synEndcape=new G4Material("M_synthesis",boxDensityEndcape,boxNcomponenEndcape);
391 synEndcape->AddElement(Cu,0.50);
392 synEndcape->AddElement(C,0.134);
393 synEndcape->AddElement(H,0.033);
394 synEndcape->AddElement(Si,0.11);
395 synEndcape->AddElement(Cl,0.014);
396 synEndcape->AddElement(O,0.209);
397
398 G4Box*boxEndcape=new G4Box("solidboxEndcape",elecGeomPointer->BoxEndcape(0)/2.*mm,elecGeomPointer->BoxEndcape(1)/2.*mm,elecGeomPointer->BoxEndcape(2)/2.*mm);
399 G4LogicalVolume*boxEndcape_log=new G4LogicalVolume(boxEndcape,synEndcape,"logical boxEndcape");
400 visAtt= new G4VisAttributes(G4Colour(0.0,1.0,0.0));
401 boxEndcape_log->SetVisAttributes(visAtt);
402
403 // Here is my estimated values
404 double boxCuEndDx=8.5*mm;
405 double boxCuEndDy=12.*mm;
406 double boxCuEndDz=29.*mm;
407
408 G4Box* boxCuEnd=new G4Box("solidboxCuEnd",boxCuEndDx/2.,boxCuEndDy/2.,boxCuEndDz/2.);
409 G4LogicalVolume*boxCuEnd_log=new G4LogicalVolume(boxCuEnd,Cuu,"logical boxCuEnd");
410 visAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0));
411 boxCuEnd_log->SetVisAttributes(visAtt);
412 // to construct a virtual box used to contain boxCuEnd and boxEndcape
413 double dxVirtualBox=18.*mm;
414 double dyVirtualBox=106.*mm;
415 double dzVirtualBox=53.*mm;
416 G4Box*virtualBoxForEndcape=new G4Box("solid virtualBoxEndcape",dxVirtualBox/2.,dyVirtualBox/2.*mm,dzVirtualBox/2.*mm);
417 G4LogicalVolume*virtualBoxForEndcape_log=new G4LogicalVolume(virtualBoxForEndcape,G4Material::GetMaterial("Air"),"logical virtualBoxEndcape");
418 // virtualBoxForEndcape_log->SetVisAttributes(G4VisAttributes::Invisible);
419 virtualBoxForEndcape_log->SetVisAttributes(visAtt);
420 G4VPhysicalVolume*boxEndcape_phys=new G4PVPlacement(0,G4ThreeVector(elecGeomPointer->BoxEndcape(0)/2.,0,0),boxEndcape_log,"physical boxEndcape",virtualBoxForEndcape_log,false,0);
421 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);
422 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);
423 const double pi=3.141593;
424 double posXArray;
425 double posYArray;
426 double posZArray;
427 double startAngleArray;
428
429 for (int i=0;i<elecGeomPointer->TotalElecLayerNo();i++)
430 {
431 startAngleArray=acos(elecGeomPointer->X(i)/elecGeomPointer->R(i));
432
433 for(int j=0;j<elecGeomPointer->ElecNo(i);j++)
434 {
435 G4RotationMatrix*boxRotj=new G4RotationMatrix;
436 boxRotj->rotateZ(-startAngleArray-j*2*pi/elecGeomPointer->ElecNo(i));
437 posXArray=elecGeomPointer->R(i)*cos((startAngleArray+j*2*pi/elecGeomPointer->ElecNo(i)));
438 posYArray=elecGeomPointer->R(i)*sin((startAngleArray+j*2*pi/elecGeomPointer->ElecNo(i)));
439 posZArray=elecGeomPointer->Z(i);
440 std::ostringstream osnamephys;
441 osnamephys<<"physicalLayer"<<i<<"Ebox"<<j;
442 G4VPhysicalVolume*box_phys=new G4PVPlacement(boxRotj,G4ThreeVector(posXArray,posYArray,posZArray),virtualBoxForEndcape_log,osnamephys.str(),mdc_log,false,j);
443
444 }
445 }
446
447 // cable on endcape
448 G4double mCableDensity=6.4*g/cm3;
449 G4Material*materialCable=new G4Material("M_materialCable",mCableDensity,3);
450 materialCable->AddElement(Cu,0.4);
451 materialCable->AddElement(C,0.3);
452 materialCable->AddElement(H,0.3);
453
454 double gapR=0.1*micrometer;
455
456 // The west cable tub can be constructed via recursive alogrithm
457 double innerRCableTub;
458 double outerRCableTub;
459 for(int i=0;i<11;i++)
460 {
461 innerRCableTub=elecGeomPointer->R(i)*mm-dxVirtualBox/2.+gapR;
462 outerRCableTub=elecGeomPointer->R(i+1)*mm-dxVirtualBox/2.-gapR;
463 std::ostringstream osnameCableSolid;
464 osnameCableSolid<<"MdcCableSolidWest"<<i;
465 G4Tubs*cableTub=new G4Tubs(osnameCableSolid.str(),innerRCableTub,outerRCableTub,elecGeomPointer->LengthCableTub(i+1)*1.15/2*mm,0*deg,360*deg);
466
467 std::ostringstream osnameCableLog;
468 osnameCableLog<<"MdcCableLogWest"<<i;
469 G4LogicalVolume*cableTub_log=new G4LogicalVolume(cableTub,materialCable,osnameCableLog.str());
470 visAtt= new G4VisAttributes(G4Colour(1,0.3,0.5));
471 cableTub_log->SetVisAttributes(visAtt);
472
473 std::ostringstream osnameCablePhys;
474 osnameCablePhys<<"MdcCablePhysWest"<<i;
475 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);
476 }
477
478 // The east too
479 for(int i=0;i<10;i++)
480 {
481 innerRCableTub=elecGeomPointer->R(i+12)-dxVirtualBox/2.+gapR;
482 outerRCableTub=elecGeomPointer->R(i+12+1)-dxVirtualBox/2.-gapR;
483 std::ostringstream osnameCableSolid;
484 osnameCableSolid<<"MdcCableSolidEast"<<i;
485 G4Tubs*cableTub=new G4Tubs(osnameCableSolid.str(),innerRCableTub,outerRCableTub,elecGeomPointer->LengthCableTub(i+14)*1.15/2*mm,0*deg,360*deg);
486
487 std::ostringstream osnameCableLog;
488 osnameCableLog<<"MdcCableLogEast"<<i;
489 G4LogicalVolume*cableTub_log=new G4LogicalVolume(cableTub,materialCable,osnameCableLog.str());
490 visAtt= new G4VisAttributes(G4Colour(1,0.3,0.5));
491 cableTub_log->SetVisAttributes(visAtt);
492
493 std::ostringstream osnameCablePhys;
494 osnameCablePhys<<"MdcCablePhysEast"<<i;
495 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);
496 }
497
498
499 // There's need to construct the two first cable tub .
500
501 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);
502 G4LogicalVolume*cableTubBeginnerW_log=new G4LogicalVolume(cableTubBeginnerW,materialCable,"logical cableTubBeginnerW");
503 visAtt= new G4VisAttributes(G4Colour(0,0.3,0.8));
504 cableTubBeginnerW_log->SetVisAttributes(visAtt);
505 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);
506 //Mutiplying 1.15 is used to estimate the practicle length according to Dong Ming-yi and Liu Rong-guang.
507 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);
508 G4LogicalVolume*cableTubBeginnerE_log=new G4LogicalVolume(cableTubBeginnerE,materialCable,"logical cabieTubBeginnerE");
509 visAtt= new G4VisAttributes(G4Colour(1,0.3,0.5));
510 cableTubBeginnerE_log->SetVisAttributes(visAtt);
511
512 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);
513
514
515 // There's need to construct the two cable tub(west and east) to tail seperately too.
516
517 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);
518 G4LogicalVolume*cableTubToTailW_log=new G4LogicalVolume(cableTubToTailW,materialCable,"logical cableTubToTailW");
519 visAtt= new G4VisAttributes(G4Colour(0,0.3,0.8));
520 cableTubToTailW_log->SetVisAttributes(visAtt);
521
522 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);
523
524 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);
525
526 G4LogicalVolume*cableTubToTailE_log=new G4LogicalVolume(cableTubToTailE,materialCable,"logical cabieTubToTailE");
527 visAtt= new G4VisAttributes(G4Colour(1.0,0.3,0.5));
528 cableTubToTailE_log->SetVisAttributes(visAtt);
529
530 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);
531
532 // Construct shield plate beyond endcape
533
534 G4Box* box0=new G4Box("box0",10.,15.,3.);
535 G4LogicalVolume* box0_log=new G4LogicalVolume(box0,Al,"logicalBox0",0,0,0);
536 visAtt= new G4VisAttributes(G4Colour(1.0,0.8,0.0));
537 box0_log->SetVisAttributes(visAtt);
538
539 G4Box* box1=new G4Box("box1",3.*cos(11.28*deg),15.,81./sin(11.28*deg)/2.);
540 G4LogicalVolume* box1_log=new G4LogicalVolume(box1,Al,"logicalBox1",0,0,0);
541 box1_log->SetVisAttributes(visAtt);
542
543 G4Box* box2=new G4Box("box2",63.5,15.,3.);
544 G4LogicalVolume* box2_log=new G4LogicalVolume(box2,Al,"logicalBox2",0,0,0);
545 box2_log->SetVisAttributes(visAtt);
546
547
548 for(i=0;i<8;i++){
549 G4RotationMatrix* boxRot0=new G4RotationMatrix();
550 boxRot0->rotateZ(-45*i*deg);
551 posX=784.*cos(45*i*deg);
552 posY=784.*sin(45*i*deg);
553 posZ=1309.*mm;
554 std::ostringstream osnameBox0PhysEast;
555 osnameBox0PhysEast<<"physical"<< "box0p"<<i;
556 G4VPhysicalVolume* box0p_phys=new G4PVPlacement(boxRot0,G4ThreeVector(posX ,posY ,posZ),
557 box0_log,osnameBox0PhysEast.str(),mdc_log,false,i);
558
559 std::ostringstream osnameBox0PhysWest;
560 osnameBox0PhysWest<<"physical"<< "box0m"<<i;
561 G4VPhysicalVolume* box0m_phys=new G4PVPlacement(boxRot0,G4ThreeVector(posX ,posY ,-posZ),
562 box0_log,osnameBox0PhysWest.str(),mdc_log,false,i);
563
564
565 G4RotationMatrix* boxRot1p=new G4RotationMatrix();
566 boxRot1p->rotateZ(-45*i*deg);
567 boxRot1p->rotateY(-78.72*deg);
568 posX=570.5*cos(45*i*deg);
569 posY=570.5*sin(45*i*deg);
570 posZ=1268.5*mm;
571 std::ostringstream osnameBox1PhysEast;
572 osnameBox1PhysEast<<"physical"<< "box1p"<<i;
573 G4VPhysicalVolume* box1p_phys=new G4PVPlacement(boxRot1p,G4ThreeVector(posX ,posY ,posZ),
574 box1_log,osnameBox1PhysEast.str(),mdc_log,false,i);
575
576 G4RotationMatrix* boxRot1m=new G4RotationMatrix();
577 boxRot1m->rotateZ(-45*i*deg);
578 boxRot1m->rotateY(78.72*deg);
579 std::ostringstream osnameBox1PhysWest;
580 osnameBox1PhysWest<<"physical"<< "box1m"<<i;
581 G4VPhysicalVolume* box1m_phys=new G4PVPlacement(boxRot1m,G4ThreeVector(posX ,posY ,-posZ),
582 box1_log,osnameBox1PhysWest.str(),mdc_log,false,i);
583
584 G4RotationMatrix* boxRot2=new G4RotationMatrix();
585 boxRot2->rotateZ(-45*i*deg);
586 posX=303.5*cos(45*i*deg);
587 posY=303.5*sin(45*i*deg);
588 posZ=1228.*mm;
589 std::ostringstream osnameBox2PhysEast;
590 osnameBox2PhysEast<<"physical"<< "box2p"<<i;
591 G4VPhysicalVolume* box2p_phys=new G4PVPlacement(boxRot2,G4ThreeVector(posX ,posY ,posZ),
592 box2_log,osnameBox2PhysEast.str(),mdc_log,false,i);
593
594 std::ostringstream osnameBox2PhysWest;
595 osnameBox2PhysWest<<"physical"<< "box2m"<<i;
596 G4VPhysicalVolume* box2m_phys=new G4PVPlacement(boxRot2,G4ThreeVector(posX ,posY ,-posZ),
597 box2_log,osnameBox2PhysWest.str(),mdc_log,false,i);
598
599 }
600
601 G4double rMax2=774.*mm;
602 G4double rMin2=rMax2 - 1.*mm/sin(11.28*deg);
603 G4double rMin1=rMin2 - 80.*mm/tan(11.28*deg);
604 G4double rMax1=rMin1 + 1.*mm/sin(11.28*deg);
605 G4Cons* shieldPlate0p=new G4Cons("shieldPlate0p",rMin1,rMax1,rMin2,rMax2,40.*mm,0.,360.*deg);
606 G4LogicalVolume* shieldPlate0p_log=new G4LogicalVolume(shieldPlate0p,Al,"logicalShieldPlate0p",0,0,0);
607 visAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0));
608 shieldPlate0p_log->SetVisAttributes(visAtt);
609 posX=0.;
610 posY=0.;
611 posZ=1272.*mm;
612 G4VPhysicalVolume* shieldPlate0p_phys=new G4PVPlacement(0,G4ThreeVector(posX ,posY ,posZ),
613 shieldPlate0p_log,"physicalShieldPalte0p",mdc_log,false,0);
614
615 G4Cons* shieldPlate0m=new G4Cons("shieldPlate0m",rMin2,rMax2,rMin1,rMax1,40.*mm,0.,360.*deg);
616 G4LogicalVolume* shieldPlate0m_log=new G4LogicalVolume(shieldPlate0m,Al,"logicalShieldPlate0m",0,0,0);
617 visAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0));
618 shieldPlate0m_log->SetVisAttributes(visAtt);
619 posX=0.;
620 posY=0.;
621 posZ=1272.*mm;
622 G4VPhysicalVolume* shieldPlate0m_phys=new G4PVPlacement(0,G4ThreeVector(posX ,posY ,-posZ),
623 shieldPlate0m_log,"physicalShieldPalte0m",mdc_log,false,0);
624
625
626 G4Tubs* shieldPlate1=new G4Tubs("shieldPlate1",240.*mm,367.*mm,0.5*mm,0.,360.*deg);
627 G4LogicalVolume* shieldPlate1_log=new G4LogicalVolume(shieldPlate1,Al,"logicalShieldPlate1",0,0,0);
628 visAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0));
629 shieldPlate1_log->SetVisAttributes(visAtt);
630 posX=0.;
631 posY=0.;
632 posZ=1231.5*mm;
633 G4VPhysicalVolume* shieldPlate1p_phys=new G4PVPlacement(0,G4ThreeVector(posX ,posY ,posZ),
634 shieldPlate1_log,"physicalShieldPalte1p",mdc_log,false,0);
635 G4VPhysicalVolume* shieldPlate1m_phys=new G4PVPlacement(0,G4ThreeVector(posX ,posY ,-posZ),
636 shieldPlate1_log,"physicalShieldPalte1m",mdc_log,false,0);
637
638
639 //========Layer
640 G4int signalLayer,firstWire;
641 G4int replicaNo;
642 G4double offset;
643
644 G4double signalWireR=mdc->SignalWireR()*micrometer;
645 G4double fieldWireR=mdc->FieldWireR()*micrometer;
646 G4double thickOfAu=0.7*micrometer; // All wires are goldplated.
647
648 G4double innerLength,innerTwistAngle,innerTan,midInnerR,innerStereo;
649 G4double outLength,outTwistAngle,outTwistAngleFixed,outTan,midOutR,outStereo,outRFixed,outTanFixed;
650
651 //----Axial layers 37-43
652 for(i=42; i>35; i--){
653 G4int signalLayer=mdc->Signal2Global(i);
654 firstWire=mdc->Layer(signalLayer).FirstWire();
655 for(n=1;n>-1;n--){
656 innerR=mdc->Layer(signalLayer-1+n).R()*mm-fieldWireR;
657 outR=mdc->Layer(signalLayer+n).R()*mm-fieldWireR;
658 if(i==42&&n==1)outR=mdc->Layer(signalLayer+n).R()*mm+fieldWireR;
659 length=(mdc->Layer(signalLayer-1+n).Length())/2.*mm;
660 startAngle=0.*deg;
661 spanAngle=360.*deg;
662 posX = 0.*m;
663 posY = 0.*m;
664 posZ = 0.*m;
665
666 //Layer
667 std::ostringstream osnameLayerSolid;
668 osnameLayerSolid <<"solid"<< "MdcAxialLayer"<<i<<"_"<<n;
669 G4Tubs* axialLayer_tube=new G4Tubs(osnameLayerSolid.str(),innerR,outR,length,startAngle,spanAngle);
670
671 std::ostringstream osnameLayerLogical;
672 osnameLayerLogical <<"logical"<< "MdcAxialLayer"<<i<<"_"<<n;
673 G4LogicalVolume* axialLayer_log=new G4LogicalVolume(axialLayer_tube, MdcGas,osnameLayerLogical.str(),0,0,0);
674
675 axialLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
676
677 replicaNo=mdc->Layer(signalLayer).WireNo()/2;
678 spanAngle=360./replicaNo*deg;
679
680 offset=mdc->Layer(signalLayer).Phi()*rad-firstWire*spanAngle/2.;
681 G4RotationMatrix* layerRot=new G4RotationMatrix();
682 layerRot->rotateZ(-offset);
683
684 std::ostringstream osnameLayerPhys;
685 osnameLayerPhys <<"physical"<< "MdcAxialLayer"<<i<<"_"<<n;
686 G4VPhysicalVolume* axialLayer_phys;
687 axialLayer_phys=new G4PVPlacement(layerRot,
688 0,
689 axialLayer_log,osnameLayerPhys.str(),mdc_log,false,i);
690
691 //Cell
692 std::ostringstream osnameCellSolid;
693 osnameCellSolid<<"solid"<< "MdcAxialLayer"<<i<<"_"<<n<<"Cell";
694 G4Tubs* replica_tube=new G4Tubs(osnameCellSolid.str(),innerR,outR,length,startAngle,spanAngle);
695
696 std::ostringstream osnameCellLogical;
697 osnameCellLogical<<"logical"<< "MdcAxialLayer"<<i<<"_"<<n<<"Cell";
698 G4LogicalVolume* replica_log=new G4LogicalVolume(replica_tube,MdcGas,osnameCellLogical.str(),0,0,0);
699
700 replica_log->SetSensitiveDetector( aTrackerSD );
701 visAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0));
702 replica_log->SetVisAttributes(visAtt);
703 replica_log->SetVisAttributes(G4VisAttributes::Invisible);
704 // replica_log->SetUserLimits(new G4UserLimits(maxStep));
705 //Wire
706 if(ReadBoostRoot::GetMdc()==1){
707 std::ostringstream osnameFieldWireSolid;
708 osnameFieldWireSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"FieldWire";
709 G4Tubs* fieldWire_tube=new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,length,0.,360*deg);
710 std::ostringstream osnameFieldWireLogical;
711 osnameFieldWireLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWire";
712 G4LogicalVolume* fieldWire_log=new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
713
714 std::ostringstream osnameFieldWireSubSolid;
715 osnameFieldWireSubSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireSub";
716 G4Tubs* fieldWireSub_tube=new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,length,0.,360*deg);
717 std::ostringstream osnameFieldWireSubLogical;
718 osnameFieldWireSubLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireSub";
719 G4LogicalVolume* fieldWireSub_log=new G4LogicalVolume(fieldWireSub_tube,Al,osnameFieldWireSubLogical.str(),0,0,0);
720 std::ostringstream osnameFieldWireSubPhys;
721 osnameFieldWireSubPhys<<"physical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireSub";
722 G4VPhysicalVolume* fieldWireSub_phys;
723 fieldWireSub_phys=new G4PVPlacement(0,0,fieldWireSub_log,
724 osnameFieldWireSubPhys.str(),fieldWire_log,false,0);
725
726 std::ostringstream osnameFieldWireHalfSolid;
727 osnameFieldWireHalfSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalf";
728 G4Tubs* fieldWireHalf_tube=new G4Tubs(osnameFieldWireHalfSolid.str(),0.,fieldWireR,length,0.,180*deg);
729 std::ostringstream osnameFieldWireHalfLogical;
730 osnameFieldWireHalfLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalf";
731 G4LogicalVolume* fieldWireHalf_log=new G4LogicalVolume(fieldWireHalf_tube,Au,osnameFieldWireHalfLogical.str(),0,0,0);
732
733 std::ostringstream osnameFieldWireHalfSubSolid;
734 osnameFieldWireHalfSubSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalfSub";
735 G4Tubs* fieldWireHalfSub_tube=new G4Tubs(osnameFieldWireHalfSubSolid.str(),0.,fieldWireR-thickOfAu,length,0.,360*deg);
736 std::ostringstream osnameFieldWireHalfSubLogical;
737 osnameFieldWireHalfSubLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalfSub";
738 G4LogicalVolume* fieldWireHalfSub_log=new G4LogicalVolume(fieldWireHalfSub_tube,Al,osnameFieldWireHalfSubLogical.str(),0,0,0);
739 std::ostringstream osnameFieldWireHalfSubPhys;
740 osnameFieldWireHalfSubPhys<<"physical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalfSub";
741 G4VPhysicalVolume* fieldWireHalfSub_phys;
742 fieldWireHalfSub_phys=new G4PVPlacement(0,0,fieldWireHalfSub_log,
743 osnameFieldWireHalfSubPhys.str(),fieldWireHalf_log,false,0);
744
745 //phi <------------------->-phi
746 // |F8 F5 F2| There are 1 signal wire S4,2 half field wire F1,7
747 // sub1 | | in each cell of sub1 except Layer 42,
748 // |F7 S4 F1| 1 more full field wire F5, 2 more half field wire F2,8
749 // |-----------------|
750 // sub0 | | Each cell of sub0 have 1 full field wire F3, 2 half
751 // |F6 F3 F0| field wire F0,6
752 // -------------------
753 if(n==0){
754 std::ostringstream osnameFieldWire0Phys;
755 osnameFieldWire0Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire0";
756 posX=mdc->Layer(signalLayer-1).R()*mm;
757 G4VPhysicalVolume* fieldWire0_phys;
758 fieldWire0_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
759 osnameFieldWire0Phys.str(),replica_log,false,0);
760
761 std::ostringstream osnameFieldWire3Phys;
762 osnameFieldWire3Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire3";
763 posX=mdc->Layer(signalLayer-1).R()*mm*cos(spanAngle/2.);
764 posY=mdc->Layer(signalLayer-1).R()*mm*sin(spanAngle/2.);
765 G4VPhysicalVolume* fieldWire3_phys;
766 fieldWire3_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
767 osnameFieldWire3Phys.str(),replica_log,false,3);
768 std::ostringstream osnameFieldWire6Phys;
769 osnameFieldWire6Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire6";
770 posX=mdc->Layer(signalLayer-1).R()*mm*cos(spanAngle);
771 posY=mdc->Layer(signalLayer-1).R()*mm*sin(spanAngle);
772 G4RotationMatrix* wireRot6=new G4RotationMatrix();
773 wireRot6->rotateZ(180*deg-spanAngle);
774 G4VPhysicalVolume* fieldWire6_phys;
775 fieldWire6_phys=new G4PVPlacement(wireRot6,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
776 osnameFieldWire6Phys.str(),replica_log,false,6);
777 }
778
779 if(n==1){
780 std::ostringstream osnameFieldWire1Phys;
781 osnameFieldWire1Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire1";
782 posX=mdc->Layer(signalLayer).R()*mm;
783 G4VPhysicalVolume* fieldWire1_phys;
784 fieldWire1_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
785 osnameFieldWire1Phys.str(),replica_log,false,1);
786 std::ostringstream osnameSignalWireSolid;
787 osnameSignalWireSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"SignalWire";
788 G4Tubs* signalWire_tube=new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,length,0.,360*deg);
789 std::ostringstream osnameSignalWireLogical;
790 osnameSignalWireLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"SignalWire";
791 G4LogicalVolume* signalWire_log=new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
792
793 std::ostringstream osnameSignalWireSubSolid;
794 osnameSignalWireSubSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"SignalWireSub";
795 G4Tubs* signalWireSub_tube=new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,length,0.,360*deg);
796 std::ostringstream osnameSignalWireSubLogical;
797 osnameSignalWireSubLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"SignalWireSub";
798 G4LogicalVolume* signalWireSub_log=new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
799 std::ostringstream osnameSignalWireSubPhys;
800 osnameSignalWireSubPhys<<"physical"<< "AxialLayer"<<i<<"_"<<n<<"SignalWireSub";
801 G4VPhysicalVolume* signalWireSub_phys;
802 signalWireSub_phys=new G4PVPlacement(0,0,signalWireSub_log,
803 osnameSignalWireSubPhys.str(),signalWire_log,false,0);
804
805 std::ostringstream osnameSignalWirePhys;
806 osnameSignalWirePhys<<"physicalAxialLayer"<<i<<"_"<<n<<"SignalWire4";
807 posX=mdc->Layer(signalLayer).R()*mm*cos(spanAngle/2.);
808 posY=mdc->Layer(signalLayer).R()*mm*sin(spanAngle/2.);
809 G4VPhysicalVolume* signalWire_phys;
810 signalWire_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),signalWire_log,
811 osnameSignalWirePhys.str(),replica_log,false,4);
812
813 std::ostringstream osnameFieldWire7Phys;
814 osnameFieldWire7Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire7";
815 posX=mdc->Layer(signalLayer).R()*mm*cos(spanAngle);
816 posY=mdc->Layer(signalLayer).R()*mm*sin(spanAngle);
817 G4RotationMatrix* wireRot7=new G4RotationMatrix();
818 wireRot7->rotateZ(180*deg-spanAngle);
819 G4VPhysicalVolume* fieldWire7_phys;
820 fieldWire7_phys=new G4PVPlacement(wireRot7,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
821 osnameFieldWire7Phys.str(),replica_log,false,7);
822 if(i==42){
823 std::ostringstream osnameFieldWire2Phys;
824 osnameFieldWire2Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire2";
825 posX=mdc->Layer(signalLayer+1).R()*mm;
826 G4VPhysicalVolume* fieldWire2_phys;
827 fieldWire2_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
828 osnameFieldWire2Phys.str(),replica_log,false,2);
829
830 std::ostringstream osnameFieldWire5Phys;
831 osnameFieldWire5Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire5";
832 posX=mdc->Layer(signalLayer+1).R()*mm*cos(spanAngle/2.);
833 posY=mdc->Layer(signalLayer+1).R()*mm*sin(spanAngle/2.);
834 G4VPhysicalVolume* fieldWire5_phys;
835 fieldWire5_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
836 osnameFieldWire5Phys.str(),replica_log,false,5);
837
838 std::ostringstream osnameFieldWire8Phys;
839 osnameFieldWire8Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire8";
840 posX=mdc->Layer(signalLayer+1).R()*mm*cos(spanAngle);
841 posY=mdc->Layer(signalLayer+1).R()*mm*sin(spanAngle);
842 G4RotationMatrix* wireRot8=new G4RotationMatrix();
843 wireRot8->rotateZ(180*deg-spanAngle);
844 G4VPhysicalVolume* fieldWire8_phys;
845 fieldWire8_phys=new G4PVPlacement(wireRot8,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
846 osnameFieldWire8Phys.str(),replica_log,false,8);
847 }
848 }
849 }
850 //Put cells into layer
851 for(j=replicaNo-1;j>-1;j--){
852 G4RotationMatrix* cellRot=new G4RotationMatrix();
853 cellRot->rotateZ(-spanAngle*j);
854 std::ostringstream osnameCellPhys;
855 osnameCellPhys<<"physical"<< "MdcAxialLayer"<<i<<"_"<<n<<"Cell"<<j;
856 G4VPhysicalVolume* replica_phys;
857 replica_phys=new G4PVPlacement(cellRot,0,replica_log,
858 osnameCellPhys.str(),axialLayer_log,false,j);
859 }
860
861 }
862
863 }
864 //----Stereo layers 21-36
865
866 for(i=35; i>19; i--){
867 signalLayer=mdc->Signal2Global(i);
868
869 innerR=mdc->Layer(signalLayer-1).R()*mm-fieldWireR;
870 outR=mdc->Layer(signalLayer+1).R()*mm-fieldWireR;
871 if(i==35)outR=mdc->Layer(signalLayer+1).R()*mm+fieldWireR;
872
873 innerLength=(mdc->Layer(signalLayer-1).Length())/2.*mm;
874 outLength=(mdc->Layer(signalLayer+1).Length())/2.*mm;
875
876 innerTwistAngle=mdc->Layer(signalLayer-1).RotateAngle()*rad;
877 outTwistAngle=mdc->Layer(signalLayer+1).RotateAngle()*rad;
878
879 innerTan=innerR/innerLength*sin(innerTwistAngle);
880
881 midInnerR=innerR*cos(innerTwistAngle);
882 innerStereo=atan(innerTan);
883
884 outTan=outR/outLength*sin(outTwistAngle);
885 outTwistAngleFixed=atan(innerLength/outLength*tan(outTwistAngle));
886
887 if(abs(outTwistAngleFixed) >= abs(innerTwistAngle)){
888 midOutR=outR*cos(outTwistAngle);
889 outRFixed=midOutR/cos(innerTwistAngle);
890 outR=outRFixed;
891
892 outTanFixed=midOutR/innerLength*tan(innerTwistAngle);
893 outStereo=atan(outTanFixed);
894 }else{
895 outRFixed=sqrt(outR*outR+(innerLength*innerLength-outLength*outLength)*outTan*outTan);
896 outR=outRFixed;
897 midOutR=outR*cos(innerTwistAngle);
898
899 outTanFixed=outRFixed/innerLength*sin(innerTwistAngle);
900 outStereo=atan(outTanFixed);
901 }
902 //Layer
903 std::ostringstream osnameLayerSolid;
904 osnameLayerSolid <<"solid"<< "MdcStereoLayer"<<i;
905
906 G4Hype* stereoLayer_hype=new G4Hype(osnameLayerSolid.str(),midInnerR, midOutR,innerStereo,
907 outStereo,innerLength);
908
909 std::ostringstream osnameLayerLogical;
910 osnameLayerLogical <<"logical"<< "MdcStereoLayer"<<i;
911 G4LogicalVolume* stereoLayer_log=new G4LogicalVolume(stereoLayer_hype,MdcGas,
912 osnameLayerLogical.str(),0,0,0);
913 stereoLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
914
915 replicaNo=mdc->Layer(signalLayer).WireNo()/2;
916 spanAngle=360./replicaNo*deg;
917 firstWire=mdc->Layer(signalLayer).FirstWire();
918
919 G4RotationMatrix* layerRot=new G4RotationMatrix();
920 layerRot->rotateZ(-(spanAngle*(1-firstWire)/2.+innerTwistAngle));
921
922 std::ostringstream osnameLayerPhys;
923 osnameLayerPhys<<"physical"<< "MdcStereoLayer"<<i;
924 G4VPhysicalVolume* stereoLayer_phys;
925 stereoLayer_phys=new G4PVPlacement(layerRot,0,stereoLayer_log,osnameLayerPhys.str(),
926 mdc_log,false,i);
927 //Cell
928 std::ostringstream osnameCellSolid;
929 osnameCellSolid<<"solid"<< "MdcStereoLayer"<<i<<"Cell";
930
931 G4TwistedTubs* twistTub=new G4TwistedTubs(osnameCellSolid.str(), -innerTwistAngle*2, innerR,outR-1.0*micrometer,innerLength,spanAngle);
932
933 std::ostringstream osnameCellLogical;
934 osnameCellLogical<<"logical"<< "MdcStereoLayer"<<i<<"Cell";
935 G4LogicalVolume* twistTub_log=new G4LogicalVolume(twistTub, MdcGas,osnameCellLogical.str(),0,0,0);
936
937 twistTub_log->SetVisAttributes(G4VisAttributes::Invisible);
938 twistTub_log->SetSensitiveDetector( aTrackerSD );
939 // twistTub_log->SetUserLimits(new G4UserLimits(maxStep));
940
941 //Wire
942 if(ReadBoostRoot::GetMdc()==1){
943 std::ostringstream osnameFieldWireSolid;
944 osnameFieldWireSolid<<"solid"<< "StereoLayer"<<i<<"FieldWire";
945 G4Tubs* fieldWire_tube=new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,innerLength,0.,360*deg);
946 std::ostringstream osnameFieldWireLogical;
947 osnameFieldWireLogical<<"logical"<< "StereoLayer"<<i<<"FieldWire";
948 G4LogicalVolume* fieldWire_log=new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
949
950 std::ostringstream osnameFieldWireSubSolid;
951 osnameFieldWireSubSolid<<"solid"<< "StereoLayer"<<i<<"FieldWireSub";
952 G4Tubs* fieldWireSub_tube=new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,innerLength,0.,360*deg);
953 std::ostringstream osnameFieldWireSubLogical;
954 osnameFieldWireSubLogical<<"logical"<< "StereoLayer"<<i<<"FieldWireSub";
955 G4LogicalVolume* fieldWireSub_log=new G4LogicalVolume(fieldWireSub_tube,Al,osnameFieldWireSubLogical.str(),0,0,0);
956 std::ostringstream osnameFieldWireSubPhys;
957 osnameFieldWireSubPhys<<"physical"<< "StereoLayer"<<i<<"FieldWireSub";
958 G4VPhysicalVolume* fieldWireSub_phys;
959 fieldWireSub_phys=new G4PVPlacement(0,0,fieldWireSub_log,
960 osnameFieldWireSubPhys.str(),fieldWire_log,false,0);
961
962 std::ostringstream osnameSignalWireSolid;
963 osnameSignalWireSolid<<"solid"<< "StereoLayer"<<i<<"SignalWire";
964 G4Tubs* signalWire_tube=new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,innerLength,0.,360*deg);
965 std::ostringstream osnameSignalWireLogical;
966 osnameSignalWireLogical<<"logical"<< "StereoLayer"<<i<<"SignalWire";
967 G4LogicalVolume* signalWire_log=new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
968
969 std::ostringstream osnameSignalWireSubSolid;
970 osnameSignalWireSubSolid<<"solid"<< "StereoLayer"<<i<<"SignalWireSub";
971 G4Tubs* signalWireSub_tube=new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,innerLength,0.,360*deg);
972 std::ostringstream osnameSignalWireSubLogical;
973 osnameSignalWireSubLogical<<"logical"<< "StereoLayer"<<i<<"SignalWireSub";
974 G4LogicalVolume* signalWireSub_log=new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
975 std::ostringstream osnameSignalWireSubPhys;
976 osnameSignalWireSubPhys<<"physical"<< "StereoLayer"<<i<<"SignalWireSub";
977 G4VPhysicalVolume* signalWireSub_phys;
978 signalWireSub_phys=new G4PVPlacement(0,0,signalWireSub_log,
979 osnameSignalWireSubPhys.str(),signalWire_log,false,0);
980
981 //phi <------------------->-phi
982 // | F5 F2| There are 1 signal wire S4,3 full field
983 // | | wire F0,1,3 in each cell except Layer 35,
984 // | S4 F1| 2 more full field wire F2,5.
985 // | | In stereo cell we can't put half wire at edge because of
986 // | F3 F0| overlap, so all wires are full wire,Positon of field
987 // ----------------| wire is not at cell edge but move into cell avoid overlap
988 G4double shiftR,midR,eastX,eastY,westX,westY;
989 shiftR=fieldWireR+1*micrometer;
990 midR=mdc->Layer(signalLayer).R()*mm;
991
992 std::ostringstream osnameFieldWire0Phys;
993 osnameFieldWire0Phys<<"physicalStereoLayer"<<i<<"FieldWire0";
994
995 eastX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
996 eastY=(innerR+shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
997 westX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
998 westY=(innerR+shiftR/cos(innerTwistAngle))*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
999
1000 G4ThreeVector east0(eastX,eastY,innerLength);
1001 G4ThreeVector west0(westX,westY,-innerLength);
1002 east0.rotateZ(-spanAngle/2.);
1003 west0.rotateZ(-spanAngle/2.);
1004
1005 posX=(east0.x()+west0.x())/2.;
1006 posY=(east0.y()+west0.y())/2.;
1007 G4ThreeVector line0=east0-west0;
1008 G4RotationMatrix* wireRot0=new G4RotationMatrix();
1009 wireRot0->rotateZ(-line0.phi());
1010 wireRot0->rotateY(-line0.theta());
1011 G4VPhysicalVolume* fieldWire0_phys;
1012 fieldWire0_phys=new G4PVPlacement(wireRot0,G4ThreeVector(posX,posY,0),fieldWire_log,
1013 osnameFieldWire0Phys.str(),twistTub_log,false,0);
1014
1015 std::ostringstream osnameFieldWire1Phys;
1016 osnameFieldWire1Phys<<"physicalStereoLayer"<<i<<"FieldWire1";
1017 eastX=midR*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
1018 eastY=midR*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
1019 westX=midR*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
1020 westY=midR*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
1021 G4ThreeVector east1(eastX,eastY,innerLength);
1022 G4ThreeVector west1(westX,westY,-innerLength);
1023 east1.rotateZ(-spanAngle/2.);
1024 west1.rotateZ(-spanAngle/2.);
1025 posX=(east1.x()+west1.x())/2.;
1026 posY=(east1.y()+west1.y())/2.;
1027 G4ThreeVector line1=east1-west1;
1028 G4RotationMatrix* wireRot1=new G4RotationMatrix();
1029 wireRot1->rotateZ(-line1.phi());
1030 wireRot1->rotateY(-line1.theta());
1031 G4VPhysicalVolume* fieldWire1_phys;
1032 fieldWire1_phys=new G4PVPlacement(wireRot1,G4ThreeVector(posX,posY,0),fieldWire_log,
1033 osnameFieldWire1Phys.str(),twistTub_log,false,1);
1034
1035 std::ostringstream osnameFieldWire3Phys;
1036 osnameFieldWire3Phys<<"physicalStereoLayer"<<i<<"FieldWire3";
1037
1038 eastX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
1039 eastY=(innerR+shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle);
1040 westX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
1041 westY=(innerR+shiftR/cos(innerTwistAngle))*sin(innerTwistAngle);
1042
1043 G4ThreeVector east3(eastX,eastY,innerLength);
1044 G4ThreeVector west3(westX,westY,-innerLength);
1045
1046 posX=(east3.x()+west3.x())/2.;
1047 posY=(east3.y()+west3.y())/2.;
1048 G4ThreeVector line3=east3-west3;
1049 G4RotationMatrix* wireRot3=new G4RotationMatrix();
1050 wireRot3->rotateZ(-line3.phi());
1051 wireRot3->rotateY(-line3.theta());
1052 G4VPhysicalVolume* fieldWire3_phys;
1053 fieldWire3_phys=new G4PVPlacement(wireRot3,G4ThreeVector(posX,posY,0),fieldWire_log,
1054 osnameFieldWire3Phys.str(),twistTub_log,false,3);
1055
1056 std::ostringstream osnameSignalWire4Phys;
1057 osnameSignalWire4Phys<<"physicalStereoLayer"<<i<<"SignalWire4";
1058
1059 eastX=midR*cos(innerTwistAngle);
1060 eastY=midR*sin(-innerTwistAngle);
1061 westX=midR*cos(innerTwistAngle);
1062 westY=midR*sin(innerTwistAngle);
1063
1064 G4ThreeVector east4(eastX,eastY,innerLength);
1065 G4ThreeVector west4(westX,westY,-innerLength);
1066
1067 posX=(east4.x()+west4.x())/2.;
1068 posY=(east4.y()+west4.y())/2.;
1069 G4ThreeVector line4=east4-west4;
1070 G4RotationMatrix* wireRot4=new G4RotationMatrix();
1071 wireRot4->rotateZ(-line4.phi());
1072 wireRot4->rotateY(-line4.theta());
1073 G4VPhysicalVolume* signalWire4_phys;
1074 signalWire4_phys=new G4PVPlacement(wireRot4,G4ThreeVector(posX,posY,0),signalWire_log,
1075 osnameSignalWire4Phys.str(),twistTub_log,false,4);
1076
1077 if(i==35){
1078 std::ostringstream osnameFieldWire2Phys;
1079 osnameFieldWire2Phys<<"physicalStereoLayer"<<i<<"FieldWire2";
1080
1081 eastX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
1082 eastY=(outR-shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
1083 westX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
1084 westY=(outR-shiftR/cos(innerTwistAngle))*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
1085
1086 G4ThreeVector east2(eastX,eastY,innerLength);
1087 G4ThreeVector west2(westX,westY,-innerLength);
1088 east2.rotateZ(-spanAngle/2.);
1089 west2.rotateZ(-spanAngle/2.);
1090
1091 posX=(east2.x()+west2.x())/2.;
1092 posY=(east2.y()+west2.y())/2.;
1093 G4ThreeVector line2=east2-west2;
1094 G4RotationMatrix* wireRot2=new G4RotationMatrix();
1095 wireRot2->rotateZ(-line2.phi());
1096 wireRot2->rotateY(-line2.theta());
1097 G4VPhysicalVolume* fieldWire2_phys;
1098 fieldWire2_phys=new G4PVPlacement(wireRot2,G4ThreeVector(posX,posY,0),fieldWire_log,
1099 osnameFieldWire2Phys.str(),twistTub_log,false,2);
1100
1101 std::ostringstream osnameFieldWire5Phys;
1102 osnameFieldWire5Phys<<"physicalStereoLayer"<<i<<"FieldWire5";
1103
1104 eastX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
1105 eastY=(outR-shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle);
1106 westX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
1107 westY=(outR-shiftR/cos(innerTwistAngle))*sin(innerTwistAngle);
1108
1109 G4ThreeVector east5(eastX,eastY,innerLength);
1110 G4ThreeVector west5(westX,westY,-innerLength);
1111
1112 posX=(east5.x()+west5.x())/2.;
1113 posY=(east5.y()+west5.y())/2.;
1114 G4ThreeVector line5=east5-west5;
1115 G4RotationMatrix* wireRot5=new G4RotationMatrix();
1116 wireRot5->rotateZ(-line5.phi());
1117 wireRot5->rotateY(-line5.theta());
1118 G4VPhysicalVolume* fieldWire5_phys;
1119 fieldWire5_phys=new G4PVPlacement(wireRot5,G4ThreeVector(posX,posY,0),fieldWire_log,
1120 osnameFieldWire5Phys.str(),twistTub_log,false,5);
1121 }
1122 }
1123 //Put cells into layer
1124 for(j=replicaNo-1;j>-1;j--){
1125 G4RotationMatrix* cellRot=new G4RotationMatrix();
1126 cellRot->rotateZ(-spanAngle*j);
1127
1128 std::ostringstream osnameCellPhys;
1129 osnameCellPhys<<"physical"<< "MdcStereoLayer"<<i<<"Cell"<<j;
1130 G4VPhysicalVolume* twistTub_phys;
1131 twistTub_phys=new G4PVPlacement(cellRot,0,twistTub_log,
1132 osnameCellPhys.str(),stereoLayer_log,false,j);
1133 }
1134 }
1135
1136 //----Axial layers 9-20
1137 for(i=19; i>7; i--){
1138 signalLayer=mdc->Signal2Global(i);
1139 innerR=mdc->Layer(signalLayer-1).R()*mm-fieldWireR;
1140 outR=mdc->Layer(signalLayer+1).R()*mm-fieldWireR;
1141 if(i==19)outR=mdc->Layer(signalLayer+1).R()*mm+fieldWireR;
1142 length=(mdc->Layer(signalLayer).Length())/2.*mm;
1143 startAngle=0.*deg;
1144 spanAngle=360.*deg;
1145 firstWire=mdc->Layer(signalLayer).FirstWire();
1146 posX = 0.*m;
1147 posY = 0.*m;
1148 posZ = 0.*m;
1149
1150 //Layer
1151 std::ostringstream osnameLayerSolid;
1152 osnameLayerSolid <<"solid"<< "MdcAxialLayer"<<i;
1153 G4Tubs* axialLayer_tube=new G4Tubs(osnameLayerSolid.str(),innerR,outR,length,startAngle,spanAngle);
1154
1155 std::ostringstream osnameLayerLogical;
1156 osnameLayerLogical <<"logical"<< "MdcAxialLayer"<<i;
1157 G4LogicalVolume* axialLayer_log=new G4LogicalVolume(axialLayer_tube, MdcGas,osnameLayerLogical.str(),0,0,0);
1158 axialLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
1159
1160 replicaNo=mdc->Layer(signalLayer).WireNo()/2;
1161 spanAngle=360./replicaNo*deg;
1162
1163 offset=mdc->Layer(signalLayer).Phi()*rad-firstWire*spanAngle/2.;
1164 G4RotationMatrix* layerRot=new G4RotationMatrix();
1165 layerRot->rotateZ(-offset);
1166
1167 std::ostringstream osnameLayerPhys;
1168 osnameLayerPhys<<"physical"<< "MdcAxialLayer"<<i;
1169 G4VPhysicalVolume* axialLayer_phys;
1170 axialLayer_phys=new G4PVPlacement(layerRot,0,axialLayer_log,
1171 osnameLayerPhys.str(),mdc_log,false,i);
1172
1173 //Cell
1174 std::ostringstream osnameCellSolid;
1175 osnameCellSolid<<"solid"<< "MdcAxialLayer"<<i<<"Cell";
1176 G4Tubs* replica_tube=new G4Tubs(osnameCellSolid.str(),innerR,outR,length,startAngle,spanAngle);
1177
1178 std::ostringstream osnameCellLogical;
1179 osnameCellLogical<<"logical"<< "MdcAxialLayer"<<i<<"Cell";
1180 G4LogicalVolume* replica_log=new G4LogicalVolume(replica_tube,MdcGas,osnameCellLogical.str(),0,0,0);
1181
1182 replica_log->SetSensitiveDetector( aTrackerSD );
1183 visAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0));
1184 replica_log->SetVisAttributes(visAtt);
1185 replica_log->SetVisAttributes(G4VisAttributes::Invisible);
1186 // replica_log->SetUserLimits(new G4UserLimits(maxStep));
1187 //Wire
1188 if(ReadBoostRoot::GetMdc()==1){
1189 std::ostringstream osnameFieldWireSolid;
1190 osnameFieldWireSolid<<"solid"<< "AxialLayer"<<i<<"FieldWire";
1191 G4Tubs* fieldWire_tube=new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,length,0.,360*deg);
1192 std::ostringstream osnameFieldWireLogical;
1193 osnameFieldWireLogical<<"logical"<< "AxialLayer"<<i<<"FieldWire";
1194 G4LogicalVolume* fieldWire_log=new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
1195
1196 std::ostringstream osnameFieldWireSubSolid;
1197 osnameFieldWireSubSolid<<"solid"<< "AxialLayer"<<i<<"FieldWireSub";
1198 G4Tubs* fieldWireSub_tube=new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,length,0.,360*deg);
1199 std::ostringstream osnameFieldWireSubLogical;
1200 osnameFieldWireSubLogical<<"logical"<< "AxialLayer"<<i<<"FieldWireSub";
1201 G4LogicalVolume* fieldWireSub_log=new G4LogicalVolume(fieldWireSub_tube,Al,osnameFieldWireSubLogical.str(),0,0,0);
1202 std::ostringstream osnameFieldWireSubPhys;
1203 osnameFieldWireSubPhys<<"physical"<< "AxialLayer"<<i<<"FieldWireSub";
1204 G4VPhysicalVolume* fieldWireSub_phys;
1205 fieldWireSub_phys=new G4PVPlacement(0,0,fieldWireSub_log,
1206 osnameFieldWireSubPhys.str(),fieldWire_log,false,0);
1207
1208 std::ostringstream osnameFieldWireHalfSolid;
1209 osnameFieldWireHalfSolid<<"solid"<< "AxialLayer"<<i<<"FieldWireHalf";
1210 G4Tubs* fieldWireHalf_tube=new G4Tubs(osnameFieldWireHalfSolid.str(),0.,fieldWireR,length,0.,180*deg);
1211 std::ostringstream osnameFieldWireHalfLogical;
1212 osnameFieldWireHalfLogical<<"logical"<< "AxialLayer"<<i<<"FieldWireHalf";
1213 G4LogicalVolume* fieldWireHalf_log=new G4LogicalVolume(fieldWireHalf_tube,Au,osnameFieldWireHalfLogical.str(),0,0,0);
1214
1215 std::ostringstream osnameFieldWireHalfSubSolid;
1216 osnameFieldWireHalfSubSolid<<"solid"<< "AxialLayer"<<i<<"FieldWireHalfSub";
1217 G4Tubs* fieldWireHalfSub_tube=new G4Tubs(osnameFieldWireHalfSubSolid.str(),0.,fieldWireR-thickOfAu,length,0.,360*deg);
1218 std::ostringstream osnameFieldWireHalfSubLogical;
1219 osnameFieldWireHalfSubLogical<<"logical"<< "AxialLayer"<<i<<"FieldWireHalfSub";
1220 G4LogicalVolume* fieldWireHalfSub_log=new G4LogicalVolume(fieldWireHalfSub_tube,Al,osnameFieldWireHalfSubLogical.str(),0,0,0);
1221 std::ostringstream osnameFieldWireHalfSubPhys;
1222 osnameFieldWireHalfSubPhys<<"physical"<< "AxialLayer"<<i<<"FieldWireHalfSub";
1223 G4VPhysicalVolume* fieldWireHalfSub_phys;
1224 fieldWireHalfSub_phys=new G4PVPlacement(0,0,fieldWireHalfSub_log,
1225 osnameFieldWireHalfSubPhys.str(),fieldWireHalf_log,false,0);
1226
1227 std::ostringstream osnameSignalWireSolid;
1228 osnameSignalWireSolid<<"solid"<< "AxialLayer"<<i<<"SignalWire";
1229 G4Tubs* signalWire_tube=new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,length,0.,360*deg);
1230 std::ostringstream osnameSignalWireLogical;
1231 osnameSignalWireLogical<<"logical"<< "AxialLayer"<<i<<"SignalWire";
1232 G4LogicalVolume* signalWire_log=new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
1233
1234 std::ostringstream osnameSignalWireSubSolid;
1235 osnameSignalWireSubSolid<<"solid"<< "AxialLayer"<<i<<"SignalWireSub";
1236 G4Tubs* signalWireSub_tube=new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,length,0.,360*deg);
1237 std::ostringstream osnameSignalWireSubLogical;
1238 osnameSignalWireSubLogical<<"logical"<< "AxialLayer"<<i<<"SignalWireSub";
1239 G4LogicalVolume* signalWireSub_log=new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
1240 std::ostringstream osnameSignalWireSubPhys;
1241 osnameSignalWireSubPhys<<"physical"<< "AxialLayer"<<i<<"SignalWireSub";
1242 G4VPhysicalVolume* signalWireSub_phys;
1243 signalWireSub_phys=new G4PVPlacement(0,0,signalWireSub_log,
1244 osnameSignalWireSubPhys.str(),signalWire_log,false,0);
1245
1246 //phi <------------------->-phi
1247 // |F8 F5 F2| There are 1 signal wire S4,1 full field wire F3,
1248 // | | 4 half field wire F0,1,6,7 in each cell except
1249 // |F7 S4 F1| layer 19 , each cell have 1 more full
1250 // | | field wire F5, 2 more half field wire F2,8
1251 // |F6 F3 F0|
1252 // -------------------
1253 std::ostringstream osnameFieldWire0Phys;
1254 osnameFieldWire0Phys<<"physicalAxialLayer"<<i<<"FieldWire0";
1255 posX=mdc->Layer(signalLayer-1).R()*mm;
1256 G4VPhysicalVolume* fieldWire0_phys;
1257 fieldWire0_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
1258 osnameFieldWire0Phys.str(),replica_log,false,0);
1259
1260 std::ostringstream osnameFieldWire1Phys;
1261 osnameFieldWire1Phys<<"physicalAxialLayer"<<i<<"FieldWire1";
1262 posX=mdc->Layer(signalLayer).R()*mm;
1263 G4VPhysicalVolume* fieldWire1_phys;
1264 fieldWire1_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
1265 osnameFieldWire1Phys.str(),replica_log,false,1);
1266
1267 if(i==19){
1268 std::ostringstream osnameFieldWire2Phys;
1269 osnameFieldWire2Phys<<"physicalAxialLayer"<<i<<"FieldWire2";
1270 posX=mdc->Layer(signalLayer+1).R()*mm;
1271 G4VPhysicalVolume* fieldWire2_phys;
1272 fieldWire2_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
1273 osnameFieldWire2Phys.str(),replica_log,false,2);
1274 }
1275
1276 std::ostringstream osnameFieldWire3Phys;
1277 osnameFieldWire3Phys<<"physicalAxialLayer"<<i<<"FieldWire3";
1278 posX=mdc->Layer(signalLayer-1).R()*mm*cos(spanAngle/2.);
1279 posY=mdc->Layer(signalLayer-1).R()*mm*sin(spanAngle/2.);
1280 G4VPhysicalVolume* fieldWire3_phys;
1281 fieldWire3_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
1282 osnameFieldWire3Phys.str(),replica_log,false,3);
1283
1284 std::ostringstream osnameSignalWirePhys;
1285 osnameSignalWirePhys<<"physicalAxialLayer"<<i<<"SignalWire4";
1286 posX=mdc->Layer(signalLayer).R()*mm*cos(spanAngle/2.);
1287 posY=mdc->Layer(signalLayer).R()*mm*sin(spanAngle/2.);
1288 G4VPhysicalVolume* signalWire_phys;
1289 signalWire_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),signalWire_log,
1290 osnameSignalWirePhys.str(),replica_log,false,4);
1291
1292 if(i==19){
1293 std::ostringstream osnameFieldWire5Phys;
1294 osnameFieldWire5Phys<<"physicalAxialLayer"<<i<<"FieldWire5";
1295 posX=mdc->Layer(signalLayer+1).R()*mm*cos(spanAngle/2.);
1296 posY=mdc->Layer(signalLayer+1).R()*mm*sin(spanAngle/2.);
1297 G4VPhysicalVolume* fieldWire5_phys;
1298 fieldWire5_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
1299 osnameFieldWire5Phys.str(),replica_log,false,5);
1300 }
1301
1302 std::ostringstream osnameFieldWire6Phys;
1303 osnameFieldWire6Phys<<"physicalAxialLayer"<<i<<"FieldWire6";
1304 posX=mdc->Layer(signalLayer-1).R()*mm*cos(spanAngle);
1305 posY=mdc->Layer(signalLayer-1).R()*mm*sin(spanAngle);
1306 G4RotationMatrix* wireRot6=new G4RotationMatrix();
1307 wireRot6->rotateZ(180*deg-spanAngle);
1308 G4VPhysicalVolume* fieldWire6_phys;
1309 fieldWire6_phys=new G4PVPlacement(wireRot6,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
1310 osnameFieldWire6Phys.str(),replica_log,false,6);
1311
1312 std::ostringstream osnameFieldWire7Phys;
1313 osnameFieldWire7Phys<<"physicalAxialLayer"<<i<<"FieldWire7";
1314 posX=mdc->Layer(signalLayer).R()*mm*cos(spanAngle);
1315 posY=mdc->Layer(signalLayer).R()*mm*sin(spanAngle);
1316 G4RotationMatrix* wireRot7=new G4RotationMatrix();
1317 wireRot7->rotateZ(180*deg-spanAngle);
1318 G4VPhysicalVolume* fieldWire7_phys;
1319 fieldWire7_phys=new G4PVPlacement(wireRot7,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
1320 osnameFieldWire7Phys.str(),replica_log,false,7);
1321
1322 if(i==19){
1323 std::ostringstream osnameFieldWire8Phys;
1324 osnameFieldWire8Phys<<"physicalAxialLayer"<<i<<"FieldWire8";
1325 posX=mdc->Layer(signalLayer+1).R()*mm*cos(spanAngle);
1326 posY=mdc->Layer(signalLayer+1).R()*mm*sin(spanAngle);
1327 G4RotationMatrix* wireRot8=new G4RotationMatrix();
1328 wireRot8->rotateZ(180*deg-spanAngle);
1329 G4VPhysicalVolume* fieldWire8_phys;
1330 fieldWire8_phys=new G4PVPlacement(wireRot8,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
1331 osnameFieldWire8Phys.str(),replica_log,false,8);
1332 }
1333 }
1334 //Put cells into layer
1335 for(j=replicaNo-1;j>-1;j--){
1336 G4RotationMatrix* cellRot=new G4RotationMatrix();
1337 cellRot->rotateZ(-spanAngle*j);
1338
1339 std::ostringstream osnameCellPhys;
1340 osnameCellPhys<<"physical"<< "MdcAxialLayer"<<i<<"Cell"<<j;
1341 G4VPhysicalVolume* replica_phys;
1342 replica_phys=new G4PVPlacement(cellRot,0,replica_log,
1343 osnameCellPhys.str(),axialLayer_log,false,j);
1344 }
1345 }
1346
1347 //----Stereo layers 1-8
1348 for(i=7; i>-1; i--){
1349 signalLayer=mdc->Signal2Global(i);
1350
1351 innerR=mdc->Layer(signalLayer-1).R()*mm-fieldWireR;
1352 outR=mdc->Layer(signalLayer+1).R()*mm-fieldWireR;
1353 if(i==7)outR=mdc->Layer(signalLayer+1).R()*mm+fieldWireR;
1354
1355 innerLength=(mdc->Layer(signalLayer-1).Length())/2.*mm;
1356 outLength=(mdc->Layer(signalLayer+1).Length())/2.*mm;
1357
1358 innerTwistAngle=mdc->Layer(signalLayer-1).RotateAngle()*rad;
1359 outTwistAngle=mdc->Layer(signalLayer+1).RotateAngle()*rad;
1360
1361 innerTan=innerR/innerLength*sin(innerTwistAngle);
1362
1363 midInnerR=innerR*cos(innerTwistAngle);
1364 innerStereo=atan(innerTan);
1365
1366 outTan=outR/outLength*sin(outTwistAngle);
1367 outTwistAngleFixed=atan(innerLength/outLength*tan(outTwistAngle));
1368
1369 if(abs(outTwistAngleFixed) >= abs(innerTwistAngle)){
1370 midOutR=outR*cos(outTwistAngle);
1371 outRFixed=midOutR/cos(innerTwistAngle);
1372 outR=outRFixed;
1373
1374 outTanFixed=midOutR/innerLength*tan(innerTwistAngle);
1375 outStereo=atan(outTanFixed);
1376 }else{
1377 outRFixed=sqrt(outR*outR+(innerLength*innerLength-outLength*outLength)*outTan*outTan);
1378 outR=outRFixed;
1379 midOutR=outR*cos(innerTwistAngle);
1380
1381 outTanFixed=outRFixed/innerLength*sin(innerTwistAngle);
1382 outStereo=atan(outTanFixed);
1383 }
1384
1385 //Layer
1386 std::ostringstream osnameLayerSolid;
1387 osnameLayerSolid <<"solid"<< "MdcStereoLayer"<<i;
1388
1389 G4Hype* stereoLayer_hype=new G4Hype(osnameLayerSolid.str(),midInnerR, midOutR,innerStereo,
1390 outStereo,innerLength);
1391 std::ostringstream osnameLayerLogical;
1392 osnameLayerLogical <<"logical"<< "MdcStereoLayer"<<i;
1393 G4LogicalVolume* stereoLayer_log=new G4LogicalVolume(stereoLayer_hype,MdcGas,
1394 osnameLayerLogical.str(),0,0,0);
1395 stereoLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
1396
1397 replicaNo=mdc->Layer(signalLayer).WireNo()/2;
1398 spanAngle=360./replicaNo*deg;
1399 firstWire=mdc->Layer(signalLayer).FirstWire();
1400
1401 G4RotationMatrix* layerRot=new G4RotationMatrix();
1402 layerRot->rotateZ(-(spanAngle*(1-firstWire)/2.+innerTwistAngle));
1403
1404 std::ostringstream osnameLayerPhys;
1405 osnameLayerPhys<<"physical"<< "MdcStereoLayer"<<i;
1406
1407 G4VPhysicalVolume* stereoLayer_phys;
1408 stereoLayer_phys=new G4PVPlacement(layerRot,0,stereoLayer_log,osnameLayerPhys.str(),
1409 mdc_log,false,i);
1410
1411 //Cell
1412 std::ostringstream osnameCellSolid;
1413 osnameCellSolid<<"solid"<< "MdcStereoLayer"<<i<<"Cell";
1414
1415 G4TwistedTubs* twistTub=new G4TwistedTubs(osnameCellSolid.str(), -innerTwistAngle*2, innerR,outR-1.0*micrometer,innerLength,spanAngle);
1416
1417 std::ostringstream osnameCellLogical;
1418 osnameCellLogical<<"logical"<< "MdcStereoLayer"<<i<<"Cell";
1419 G4LogicalVolume* twistTub_log=new G4LogicalVolume(twistTub, MdcGas,osnameCellLogical.str(),0,0,0);
1420
1421 twistTub_log->SetVisAttributes(G4VisAttributes::Invisible);
1422 twistTub_log->SetSensitiveDetector( aTrackerSD );
1423 // twistTub_log->SetUserLimits(new G4UserLimits(maxStep));
1424 //Wire
1425 if(ReadBoostRoot::GetMdc()==1){
1426 std::ostringstream osnameFieldWireSolid;
1427 osnameFieldWireSolid<<"solid"<< "StereoLayer"<<i<<"FieldWire";
1428 G4Tubs* fieldWire_tube=new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,innerLength,0.,360*deg);
1429 std::ostringstream osnameFieldWireLogical;
1430 osnameFieldWireLogical<<"logical"<< "StereoLayer"<<i<<"FieldWire";
1431 G4LogicalVolume* fieldWire_log=new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
1432
1433 std::ostringstream osnameFieldWireSubSolid;
1434 osnameFieldWireSubSolid<<"solid"<< "StereoLayer"<<i<<"FieldWireSub";
1435 G4Tubs* fieldWireSub_tube=new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,innerLength,0.,360*deg);
1436 std::ostringstream osnameFieldWireSubLogical;
1437 osnameFieldWireSubLogical<<"logical"<< "StereoLayer"<<i<<"FieldWireSub";
1438 G4LogicalVolume* fieldWireSub_log=new G4LogicalVolume(fieldWireSub_tube,Al,osnameFieldWireSubLogical.str(),0,0,0);
1439 std::ostringstream osnameFieldWireSubPhys;
1440 osnameFieldWireSubPhys<<"physical"<< "StereoLayer"<<i<<"FieldWireSub";
1441 G4VPhysicalVolume* fieldWireSub_phys;
1442 fieldWireSub_phys=new G4PVPlacement(0,0,fieldWireSub_log,
1443 osnameFieldWireSubPhys.str(),fieldWire_log,false,0);
1444
1445
1446 std::ostringstream osnameSignalWireSolid;
1447 osnameSignalWireSolid<<"solid"<< "StereoLayer"<<i<<"SignalWire";
1448 G4Tubs* signalWire_tube=new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,innerLength,0.,360*deg);
1449 std::ostringstream osnameSignalWireLogical;
1450 osnameSignalWireLogical<<"logical"<< "StereoLayer"<<i<<"SignalWire";
1451 G4LogicalVolume* signalWire_log=new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
1452
1453 std::ostringstream osnameSignalWireSubSolid;
1454 osnameSignalWireSubSolid<<"solid"<< "StereoLayer"<<i<<"SignalWireSub";
1455 G4Tubs* signalWireSub_tube=new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,innerLength,0.,360*deg);
1456 std::ostringstream osnameSignalWireSubLogical;
1457 osnameSignalWireSubLogical<<"logical"<< "StereoLayer"<<i<<"SignalWireSub";
1458 G4LogicalVolume* signalWireSub_log=new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
1459 std::ostringstream osnameSignalWireSubPhys;
1460 osnameSignalWireSubPhys<<"physical"<< "StereoLayer"<<i<<"SignalWireSub";
1461 G4VPhysicalVolume* signalWireSub_phys;
1462 signalWireSub_phys=new G4PVPlacement(0,0,signalWireSub_log,
1463 osnameSignalWireSubPhys.str(),signalWire_log,false,0);
1464
1465 //phi <------------------->-phi
1466 // | F5 F2| There are 1 signal wire S4,3 full field
1467 // | | wire F0,1,3 in each cell except layer 7 ,
1468 // | S4 F1| 2 more full field wire F2,5.
1469 // | | In stereo cell we can't put half wire at edge because of
1470 // | F3 F0| overlap, so all wires are full wire,Positon of field
1471 // ----------------| wire is not at cell edge but move into cell avoid overlap
1472 G4double shiftR,midR,eastX,eastY,westX,westY;
1473 shiftR=fieldWireR+1*micrometer;
1474 midR=mdc->Layer(signalLayer).R()*mm;
1475
1476 std::ostringstream osnameFieldWire0Phys;
1477 osnameFieldWire0Phys<<"physicalStereoLayer"<<i<<"FieldWire0";
1478
1479 eastX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
1480 eastY=(innerR+shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
1481 westX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
1482 westY=(innerR+shiftR/cos(innerTwistAngle))*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
1483
1484 G4ThreeVector east0(eastX,eastY,innerLength);
1485 G4ThreeVector west0(westX,westY,-innerLength);
1486 east0.rotateZ(-spanAngle/2.);
1487 west0.rotateZ(-spanAngle/2.);
1488
1489 posX=(east0.x()+west0.x())/2.;
1490 posY=(east0.y()+west0.y())/2.;
1491 G4ThreeVector line0=east0-west0;
1492 G4RotationMatrix* wireRot0=new G4RotationMatrix();
1493 wireRot0->rotateZ(-line0.phi());
1494 wireRot0->rotateY(-line0.theta());
1495 G4VPhysicalVolume* fieldWire0_phys;
1496 fieldWire0_phys=new G4PVPlacement(wireRot0,G4ThreeVector(posX,posY,0),fieldWire_log,
1497 osnameFieldWire0Phys.str(),twistTub_log,false,0);
1498
1499 std::ostringstream osnameFieldWire1Phys;
1500 osnameFieldWire1Phys<<"physicalStereoLayer"<<i<<"FieldWire1";
1501 eastX=midR*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
1502 eastY=midR*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
1503 westX=midR*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
1504 westY=midR*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
1505 G4ThreeVector east1(eastX,eastY,innerLength);
1506 G4ThreeVector west1(westX,westY,-innerLength);
1507 east1.rotateZ(-spanAngle/2.);
1508 west1.rotateZ(-spanAngle/2.);
1509 posX=(east1.x()+west1.x())/2.;
1510 posY=(east1.y()+west1.y())/2.;
1511 G4ThreeVector line1=east1-west1;
1512 G4RotationMatrix* wireRot1=new G4RotationMatrix();
1513 wireRot1->rotateZ(-line1.phi());
1514 wireRot1->rotateY(-line1.theta());
1515 G4VPhysicalVolume* fieldWire1_phys;
1516 fieldWire1_phys=new G4PVPlacement(wireRot1,G4ThreeVector(posX,posY,0),fieldWire_log,
1517 osnameFieldWire1Phys.str(),twistTub_log,false,1);
1518
1519 std::ostringstream osnameFieldWire3Phys;
1520 osnameFieldWire3Phys<<"physicalStereoLayer"<<i<<"FieldWire3";
1521
1522 eastX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
1523 eastY=(innerR+shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle);
1524 westX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
1525 westY=(innerR+shiftR/cos(innerTwistAngle))*sin(innerTwistAngle);
1526
1527 G4ThreeVector east3(eastX,eastY,innerLength);
1528 G4ThreeVector west3(westX,westY,-innerLength);
1529
1530 posX=(east3.x()+west3.x())/2.;
1531 posY=(east3.y()+west3.y())/2.;
1532 G4ThreeVector line3=east3-west3;
1533 G4RotationMatrix* wireRot3=new G4RotationMatrix();
1534 wireRot3->rotateZ(-line3.phi());
1535 wireRot3->rotateY(-line3.theta());
1536 G4VPhysicalVolume* fieldWire3_phys;
1537 fieldWire3_phys=new G4PVPlacement(wireRot3,G4ThreeVector(posX,posY,0),fieldWire_log,
1538 osnameFieldWire3Phys.str(),twistTub_log,false,3);
1539
1540 std::ostringstream osnameSignalWire4Phys;
1541 osnameSignalWire4Phys<<"physicalStereoLayer"<<i<<"SignalWire4";
1542
1543 eastX=midR*cos(innerTwistAngle);
1544 eastY=midR*sin(-innerTwistAngle);
1545 westX=midR*cos(innerTwistAngle);
1546 westY=midR*sin(innerTwistAngle);
1547
1548 G4ThreeVector east4(eastX,eastY,innerLength);
1549 G4ThreeVector west4(westX,westY,-innerLength);
1550
1551 posX=(east4.x()+west4.x())/2.;
1552 posY=(east4.y()+west4.y())/2.;
1553 G4ThreeVector line4=east4-west4;
1554 G4RotationMatrix* wireRot4=new G4RotationMatrix();
1555 wireRot4->rotateZ(-line4.phi());
1556 wireRot4->rotateY(-line4.theta());
1557 G4VPhysicalVolume* signalWire4_phys;
1558 signalWire4_phys=new G4PVPlacement(wireRot4,G4ThreeVector(posX,posY,0),signalWire_log,
1559 osnameSignalWire4Phys.str(),twistTub_log,false,4);
1560
1561 if(i==7){
1562 std::ostringstream osnameFieldWire2Phys;
1563 osnameFieldWire2Phys<<"physicalStereoLayer"<<i<<"FieldWire2";
1564
1565 eastX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
1566 eastY=(outR-shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
1567 westX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
1568 westY=(outR-shiftR/cos(innerTwistAngle))*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
1569
1570 G4ThreeVector east2(eastX,eastY,innerLength);
1571 G4ThreeVector west2(westX,westY,-innerLength);
1572 east2.rotateZ(-spanAngle/2.);
1573 west2.rotateZ(-spanAngle/2.);
1574
1575 posX=(east2.x()+west2.x())/2.;
1576 posY=(east2.y()+west2.y())/2.;
1577 G4ThreeVector line2=east2-west2;
1578 G4RotationMatrix* wireRot2=new G4RotationMatrix();
1579 wireRot2->rotateZ(-line2.phi());
1580 wireRot2->rotateY(-line2.theta());
1581 G4VPhysicalVolume* fieldWire2_phys;
1582 fieldWire2_phys=new G4PVPlacement(wireRot2,G4ThreeVector(posX,posY,0),fieldWire_log,
1583 osnameFieldWire2Phys.str(),twistTub_log,false,2);
1584
1585 std::ostringstream osnameFieldWire5Phys;
1586 osnameFieldWire5Phys<<"physicalStereoLayer"<<i<<"FieldWire5";
1587
1588 eastX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
1589 eastY=(outR-shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle);
1590 westX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
1591 westY=(outR-shiftR/cos(innerTwistAngle))*sin(innerTwistAngle);
1592
1593 G4ThreeVector east5(eastX,eastY,innerLength);
1594 G4ThreeVector west5(westX,westY,-innerLength);
1595
1596 posX=(east5.x()+west5.x())/2.;
1597 posY=(east5.y()+west5.y())/2.;
1598 G4ThreeVector line5=east5-west5;
1599 G4RotationMatrix* wireRot5=new G4RotationMatrix();
1600 wireRot5->rotateZ(-line5.phi());
1601 wireRot5->rotateY(-line5.theta());
1602 G4VPhysicalVolume* fieldWire5_phys;
1603 fieldWire5_phys=new G4PVPlacement(wireRot5,G4ThreeVector(posX,posY,0),fieldWire_log,
1604 osnameFieldWire5Phys.str(),twistTub_log,false,5);
1605 }
1606 }
1607 //Put cells into layer
1608 for(j=replicaNo-1;j>-1;j--){
1609 G4RotationMatrix* cellRot=new G4RotationMatrix();
1610 cellRot->rotateZ(-spanAngle*j);
1611
1612 std::ostringstream osnameCellPhys;
1613 osnameCellPhys<<"physical"<< "MdcStereoLayer"<<i<<"Cell"<<j;
1614 G4VPhysicalVolume* twistTub_phys;
1615 twistTub_phys=new G4PVPlacement(cellRot,0,twistTub_log,
1616 osnameCellPhys.str(),stereoLayer_log,false,j);
1617 }
1618 }
1619
1620 }
1621}
double tan(const BesAngle a)
Definition: BesAngle.h:216
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
***************************************************************************************Pseudo Class RRes *****************************************************************************************Parameters and physical constants **Maarten sept ************************************************************************DOUBLE PRECISION xsmu **************************************************************************PARTICLE DATA all others are from PDG *Only resonances with known widths into electron pairs are sept ************************************************************************C Declarations C
Definition: RRes.h:29
void Construct(G4LogicalVolume *)
static BesMdcGeoParameter * GetGeo(void)
const BesMdcLayer & Layer(int) const
BesMdcMember Segment(int x)
int FirstWire(void) const
int WireNo(void) const
double InnerR(void)
double Z(void)
double OutR(void)
double Length(void)
double R(void) const
double Length(void) const
double RotateAngle(void) const
double Phi(void) const
double R(int n)
double BoxEndcape(int n)
int ElecNo(int n)
Definition: MyMdcGeomSvc.cc:95
double FixRing(int n)
double LengthCableTub(int n)
double Z(int n)
int TotalElecLayerNo()
Definition: MyMdcGeomSvc.cc:87
double X(int n)
Definition: MyMdcGeomSvc.cc:99
static G4int GetTuning()
static G4int GetMdc()
G4LogicalVolume * GetTopVolume()
Get the top(world) volume;.
IMPLICIT REAL *A H
Definition: myXsection.h:1
const float rad
Definition: vector3.h:134
const float pi
Definition: vector3.h:133