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