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