CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMdcConstruction Class Reference

#include <BesMdcConstruction.hh>

+ Inheritance diagram for BesMdcConstruction:

Public Member Functions

 BesMdcConstruction ()
 
 ~BesMdcConstruction ()
 
void Construct (G4LogicalVolume *)
 
- Public Member Functions inherited from BesSubdetector
 BesSubdetector ()
 
virtual ~BesSubdetector ()
 
G4LogicalVolume * FindLogicalVolume (const G4String &vn)
 

Additional Inherited Members

- Protected Attributes inherited from BesSubdetector
SAXProcessor m_sxp
 
ProcessingConfigurator m_config
 

Detailed Description

Definition at line 23 of file BesMdcConstruction.hh.

Constructor & Destructor Documentation

◆ BesMdcConstruction()

BesMdcConstruction::BesMdcConstruction ( )

Definition at line 34 of file BesMdcConstruction.cc.

35 : mdc_log(0),mdc_phys(0){
37}
static BesMdcGeoParameter * GetGeo(void)

◆ ~BesMdcConstruction()

BesMdcConstruction::~BesMdcConstruction ( )

Definition at line 39 of file BesMdcConstruction.cc.

39 {
40}

Member Function Documentation

◆ Construct()

void BesMdcConstruction::Construct ( G4LogicalVolume * logicBes)
virtual

Implements BesSubdetector.

Definition at line 44 of file BesMdcConstruction.cc.

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

Referenced by BesDetectorConstruction::Construct().


The documentation for this class was generated from the following files: