Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BesMdcConstruction Class Reference

#include <BesMdcConstruction.hh>

Inheritance diagram for BesMdcConstruction:

BesSubdetector BesSubdetector List of all members.

Public Member Functions

 BesMdcConstruction ()
 BesMdcConstruction ()
void Construct (G4LogicalVolume *)
void Construct (G4LogicalVolume *)
G4LogicalVolume * FindLogicalVolume (const G4String &vn)
G4LogicalVolume * FindLogicalVolume (const G4String &vn)
 ~BesMdcConstruction ()
 ~BesMdcConstruction ()

Protected Attributes

ProcessingConfigurator m_config
SAXProcessor m_sxp

Private Member Functions

void AxialCellConstruct (G4LogicalVolume *, G4int, G4int)
void AxialCellConstruct (G4LogicalVolume *, G4int, G4int)
void AxialLayerConstruct (G4LogicalVolume *, G4int)
void AxialLayerConstruct (G4LogicalVolume *, G4int)
void StereoLayerConstruct (G4LogicalVolume *, G4int)
void StereoLayerConstruct (G4LogicalVolume *, G4int)
void TubeConstruct (G4LogicalVolume *)
void TubeConstruct (G4LogicalVolume *)

Private Attributes

BesMdcSDaTrackerSD
BesMdcSDaTrackerSD
G4double fieldWireR
G4double innerR
G4double length
BesMdcGeoParametermdc
BesMdcGeoParametermdc
G4LogicalVolume * mdc_log
G4LogicalVolume * mdc_log
G4VPhysicalVolume * mdc_phys
G4VPhysicalVolume * mdc_phys
G4double outR
G4double posX
G4double posY
G4double posZ
G4RotationMatrix * Rot
G4RotationMatrix * Rot
G4double signalWireR
G4double spanAngle
G4double startAngle
G4VisAttributes * visAtt
G4VisAttributes * visAtt

Constructor & Destructor Documentation

BesMdcConstruction::BesMdcConstruction  ) 
 

00035  : mdc_log(0),mdc_phys(0){
00036    mdc=BesMdcGeoParameter::GetGeo();
00037 }

BesMdcConstruction::~BesMdcConstruction  ) 
 

00039                                        {
00040 }

BesMdcConstruction::BesMdcConstruction  ) 
 

BesMdcConstruction::~BesMdcConstruction  ) 
 


Member Function Documentation

void BesMdcConstruction::AxialCellConstruct G4LogicalVolume *  ,
G4int  ,
G4int 
[private]
 

void BesMdcConstruction::AxialCellConstruct G4LogicalVolume *  ,
G4int  ,
G4int 
[private]
 

void BesMdcConstruction::AxialLayerConstruct G4LogicalVolume *  ,
G4int 
[private]
 

void BesMdcConstruction::AxialLayerConstruct G4LogicalVolume *  ,
G4int 
[private]
 

void BesMdcConstruction::Construct G4LogicalVolume *   )  [virtual]
 

Implements BesSubdetector.

void BesMdcConstruction::Construct G4LogicalVolume *   )  [virtual]
 

Implements BesSubdetector.

00044                                                            {
00045   //------------------------------------------------ 
00046   // Sensitive detectors
00047   //------------------------------------------------ 
00048   G4SDManager* SDman = G4SDManager::GetSDMpointer();
00049   G4String mdcSDname = "BesMdcSD";
00050   aTrackerSD = new BesMdcSD( mdcSDname);
00051   SDman->AddNewDetector( aTrackerSD );
00052 
00053   if(ReadBoostRoot::GetTuning())return; //No construct when tuning
00054   //Construct 
00055   G4LogicalVolume *logicalMdc = 0;
00056   G4LogicalVolume *lv         = 0;
00057   
00058   if(ReadBoostRoot::GetMdc()==2){
00059     MdcG4Geo* aMdcG4Geo = new MdcG4Geo();
00060     logicalMdc = aMdcG4Geo->GetTopVolume(); 
00061     if(!logicalMdc){
00062       G4cout<<"BesMdcConstruction::Construct(), logicalMdc not found"<<G4endl;
00063     }else{
00064       //construct Mdc
00065       mdc_phys = new G4PVPlacement(0,G4ThreeVector(0,0,0),
00066                                    logicalMdc, "physicalMdc",logicBes, false, 0);
00067       logicalMdc->SetVisAttributes(G4VisAttributes::Invisible);
00068       
00069       //visual attributes and sensitive detector
00070       G4VisAttributes* visAttStereoLayer = new G4VisAttributes(G4Colour(0.,1.,0.));
00071       G4VisAttributes* visAttAxialLayer  = new G4VisAttributes(G4Colour(1.,0.,0.));
00072       G4int segmentNo=mdc->SegmentNo();
00073       G4double colorShift = 0., shift = 1.0 / (segmentNo-1);
00074       
00075       for (int i = 1; i < segmentNo; i++) { 
00076         std::ostringstream osnameSegment;
00077         osnameSegment << "logical" << "Mdc" << "Segment" << i;
00078         lv = (G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameSegment.str() );
00079         G4VisAttributes* visAttSegment     = new G4VisAttributes(G4Colour(1.0-colorShift, 0.0+colorShift, 0.0));
00080         if(i<3) visAttSegment->SetForceWireframe(true);
00081         if(lv) {
00082           lv->SetVisAttributes(visAttSegment);
00083           //lv->SetVisAttributes(G4VisAttributes::Invisible);
00084         }
00085         else G4cout << "logical volume " << osnameSegment.str() << "not found " << G4endl;
00086         colorShift +=shift;
00087       }
00088       
00089       for (int i = 0; i < 8; i++) { 
00090         std::ostringstream osnameStereoLayer;
00091         osnameStereoLayer << "logical" << "Mdc" << "StereoLayer" << i;
00092         lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameStereoLayer.str() );
00093         if(lv) {
00094           lv->SetVisAttributes(visAttStereoLayer);
00095           lv->SetVisAttributes(G4VisAttributes::Invisible);
00096         }
00097         else G4cout << "logical volume " << osnameStereoLayer.str() << "not found " << G4endl;
00098         
00099         std::ostringstream osnameTwistedTubs;
00100         osnameTwistedTubs << "logical" << "Mdc" << "StereoLayer" << i << "Cell";
00101         lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameTwistedTubs.str() );
00102         if(lv) {
00103           lv->SetSensitiveDetector( aTrackerSD );
00104           lv->SetVisAttributes(G4VisAttributes::Invisible);
00105         }
00106         else G4cout << "logical volume " << osnameTwistedTubs.str() << "not found " << G4endl;
00107       }
00108       
00109       for (int i = 20; i < 36; i++) { 
00110         std::ostringstream osnameStereoLayer;
00111         osnameStereoLayer << "logical" << "Mdc" << "StereoLayer" << i;
00112         lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameStereoLayer.str() );
00113         if(lv) {
00114           lv->SetVisAttributes(visAttStereoLayer);
00115           lv->SetVisAttributes(G4VisAttributes::Invisible);
00116         }
00117         else G4cout << "logical volume " << osnameStereoLayer.str() << "not found " << G4endl;
00118         
00119         std::ostringstream osnameTwistedTubs;
00120         osnameTwistedTubs << "logical" << "Mdc" << "StereoLayer" << i << "Cell";
00121         lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameTwistedTubs.str() );
00122         if(lv) {
00123           lv->SetSensitiveDetector( aTrackerSD );
00124           lv->SetVisAttributes(G4VisAttributes::Invisible);
00125         }
00126         else G4cout << "logical volume " << osnameTwistedTubs.str() << "not found " << G4endl;
00127       }
00128       
00129       for (int i = 8; i < 20; i++) { 
00130         std::ostringstream osnameAxialLayer;
00131         osnameAxialLayer << "logical" << "Mdc" << "AxialLayer" << i;
00132         lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameAxialLayer.str() );
00133         if(lv) {
00134           lv->SetVisAttributes(visAttAxialLayer);
00135           lv->SetVisAttributes(G4VisAttributes::Invisible);
00136         }
00137         else G4cout << "logical volume " << osnameAxialLayer.str() << "not found " << G4endl;
00138         
00139         std::ostringstream osnameReplica;
00140         osnameReplica << "logical" << "Mdc" << "AxialLayer" << i << "Cell";
00141         lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameReplica.str() );
00142         if(lv) {
00143           lv->SetSensitiveDetector( aTrackerSD );
00144           lv->SetVisAttributes(G4VisAttributes::Invisible);
00145         }
00146         else G4cout << "logical volume " << osnameReplica.str() << "not found " << G4endl;
00147       }
00148       
00149       for (int i = 36; i < 43; i++) { 
00150         for (int n = 0; n < 2; n++) {
00151           std::ostringstream osnameAxialLayer;
00152           osnameAxialLayer << "logical" << "Mdc" << "AxialLayer" << i << "_" << n;
00153           lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameAxialLayer.str() );
00154           if(lv) {
00155             lv->SetVisAttributes(visAttAxialLayer);
00156             lv->SetVisAttributes(G4VisAttributes::Invisible);
00157           }
00158           else G4cout << "logical volume " << osnameAxialLayer.str() << "not found " << G4endl;
00159           
00160           std::ostringstream osnameReplica;
00161           osnameReplica << "logical" << "Mdc" << "AxialLayer" << i << "_" << n << "Cell";
00162           lv=(G4LogicalVolume*)GDMLProcessor::GetInstance()->GetLogicalVolume( osnameReplica.str() );
00163           if(lv) {
00164             lv->SetSensitiveDetector( aTrackerSD );
00165             lv->SetVisAttributes(G4VisAttributes::Invisible);
00166           }
00167           else G4cout << "logical volume " << osnameReplica.str() << "not found " << G4endl;
00168         }
00169       }
00170     }
00171     delete aMdcG4Geo;
00172   }else {
00173     //construct with previous code. 
00174     if(ReadBoostRoot::GetMdc()==3)G4cout<<"Nowire in Mdc Construct"<<G4endl;   
00175 
00176     //--------- Materials  ---------
00177     
00178     // Mdcgas He/C3H8 (60:40)
00179     G4Material* MdcGas = G4Material::GetMaterial("Mdcgas");
00180     G4Material* Al = G4Material::GetMaterial("Aluminium");
00181     G4Element *C  =G4Element::GetElement("Carbon");
00182     G4Element *H  =G4Element::GetElement("Hydrogen");
00183     G4Element *O  =G4Element::GetElement("Oxygen");
00184 
00185     G4double density = 19.3*g/cm3;
00186     G4double a = 183.84*g/mole;
00187     G4Material* W = new G4Material("Tungsten", 74., a, density);
00188 
00189     density=19.32*g/cm3;
00190     a = 196.967*g/mole;
00191     G4Material* Au= new G4Material("Au",79,a,density);
00192 
00193     density=1.57*g/cm3;
00194     G4int nElement=3;
00195     G4Material* CarbonFiber=new G4Material("CarbonFiber",density,nElement);
00196     CarbonFiber->AddElement(C,0.697);
00197     CarbonFiber->AddElement(H,0.0061);
00198     CarbonFiber->AddElement(O,0.2969);
00199 
00200     //Begin construct
00201     G4int i,j,k,n;
00202     G4double outR, innerR, length;
00203     G4double startAngle, spanAngle;
00204     G4double posX, posY, posZ;
00205     G4VisAttributes* visAtt;
00206     string name; 
00207     //=======Mdc container
00208     
00209     outR=mdc->Segment(0).OutR()*mm;
00210     innerR=mdc->Segment(0).InnerR()*mm;
00211     length=mdc->Segment(0).Length()/2.*mm; //In Geant4, soild has central-symmetry 
00212     
00213     startAngle=0.*deg;
00214     spanAngle=360.*deg;
00215     posX  = 0.*m;
00216     posY  = 0.*m;
00217     posZ  = 0.*m;
00218     
00219     G4Tubs* mdc_tube=new G4Tubs("solidMdc",innerR,outR,length,startAngle,spanAngle);
00220     mdc_log=new G4LogicalVolume(mdc_tube, MdcGas,"logicalMdc",0,0,0);
00221     mdc_log->SetVisAttributes(G4VisAttributes::Invisible);
00222 
00223     //limits of step length
00224     //    G4double maxStep = 20.*mm;
00225  
00226   
00227     mdc_phys= new G4PVPlacement(0,
00228              G4ThreeVector(posX ,posY ,posZ),
00229              mdc_log,"physicalMdc",logicBes,false,0);
00230 
00231          
00232     //======Tube and Endplane
00233         
00234     G4double colorShift=0., shift=1./(mdc->SegmentNo()-1);
00235     G4double gap=0.5*micrometer;
00236     for(i=1; i<mdc->SegmentNo(); i++){
00237       outR=mdc->Segment(i).OutR()*mm-gap;
00238       innerR=mdc->Segment(i).InnerR()*mm+gap;
00239       length=mdc->Segment(i).Length()/2.*mm-gap; 
00240       startAngle=0*deg;
00241       spanAngle=360*deg; 
00242       posZ=mdc->Segment(i).Z()*mm;
00243       //name=mdc->Segment(i).Name();
00244       name="MdcSegment";
00245       std::ostringstream osnameSolid;
00246       osnameSolid << "solid"<<name<<i;      
00247       G4Tubs* segment_tube=new G4Tubs(osnameSolid.str(),innerR,outR,length,startAngle,spanAngle);
00248       std::ostringstream osnameLogical;
00249       osnameLogical << "logical"<<name<<i;  
00250       G4LogicalVolume* segment_log;
00251       if(i==1||i==2){
00252       segment_log=new G4LogicalVolume(segment_tube, CarbonFiber,osnameLogical.str(),0,0,0);
00253       }else{
00254       segment_log=new G4LogicalVolume(segment_tube, Al,osnameLogical.str(),0,0,0);
00255       }
00256             
00257       visAtt= new G4VisAttributes(G4Colour(1.0-colorShift,0.0+colorShift,0.0));
00258       if(i<3)visAtt->SetForceWireframe(true);
00259       segment_log->SetVisAttributes(visAtt);
00260       //segment_log->SetVisAttributes(G4VisAttributes::Invisible);
00261       colorShift +=shift;
00262       
00263       G4VPhysicalVolume* segment_phys;
00264       std::ostringstream osnamePhys1;
00265       osnamePhys1 << "physical"<<name<<i<<"p";
00266       segment_phys=new G4PVPlacement(0,
00267                                      G4ThreeVector(posX ,posY ,posZ),
00268                                      segment_log,osnamePhys1.str(),mdc_log,false,0);
00269       //Endplane have two parts at +-Z
00270       if(i>2){
00271       std::ostringstream osnamePhys2;
00272       osnamePhys2  << "physical"<<name<<i<<"m";
00273         segment_phys=new G4PVPlacement(0,
00274                                        G4ThreeVector(posX ,posY ,-posZ),
00275                                        segment_log,osnamePhys2.str(),mdc_log,false,0);
00276       }
00277       
00278     }
00279     
00280       MyMdcGeomSvc* elecGeomPointer= new MyMdcGeomSvc(); 
00281     
00282     //  sustain ring which is used to fix electronic box
00283 
00284       G4Tubs*fixTub=new G4Tubs("solidFixTub",elecGeomPointer->FixRing(0)*mm,elecGeomPointer->FixRing(1)*mm,elecGeomPointer->FixRing(2)/2.*mm,0.*deg,360.*deg);
00285       G4LogicalVolume*fixTub_log=new G4LogicalVolume(fixTub,Al,"logicalFixTub");
00286       G4VPhysicalVolume*fixTub_phys1=new G4PVPlacement(0,G4ThreeVector(0,0,1134.5*mm),fixTub_log,"physcalFixTub1",mdc_log,false,0);
00287       G4VPhysicalVolume*fixTub_phys2=new G4PVPlacement(0,G4ThreeVector(0,0,-1134.5*mm),fixTub_log,"physicalFixTub2",mdc_log,false,0);
00288 
00289 
00290       G4Element *Cu=G4Element::GetElement("Copper");
00291       G4Element *Si=G4Element::GetElement("Silicon");
00292 
00293    //  construct east and west endcape
00294       G4double boxDensityEndcape=1.9745*g/cm3;
00295       G4int boxNcomponenEndcape=6;
00296       G4Material *Cuu = G4Material::GetMaterial("Copper");
00297     // construct material or element using another method!but you must include "G4NistManager.hh"
00298     // G4NistManager*man=G4NistManager::Instance();
00299     // G4Element*Cl=man->FindOrBuildElement("Cl");
00300 
00301       G4Element *Cl =new G4Element("Chlorine","Cl",17.,35.5*g/mole);
00302       G4Material*synEndcape=new G4Material("M_synthesis",boxDensityEndcape,boxNcomponenEndcape);
00303       synEndcape->AddElement(Cu,0.50);
00304       synEndcape->AddElement(C,0.134);
00305       synEndcape->AddElement(H,0.033);
00306       synEndcape->AddElement(Si,0.11);
00307       synEndcape->AddElement(Cl,0.014);
00308       synEndcape->AddElement(O,0.209);
00309 
00310       G4Box*boxEndcape=new G4Box("solidboxEndcape",elecGeomPointer->BoxEndcape(0)/2.*mm,elecGeomPointer->BoxEndcape(1)/2.*mm,elecGeomPointer->BoxEndcape(2)/2.*mm);
00311       G4LogicalVolume*boxEndcape_log=new G4LogicalVolume(boxEndcape,synEndcape,"logical boxEndcape"); 
00312       visAtt= new G4VisAttributes(G4Colour(0.0,1.0,0.0));
00313       boxEndcape_log->SetVisAttributes(visAtt);
00314 
00315     // Here is my estimated values 
00316       double boxCuEndDx=8.5*mm;
00317       double boxCuEndDy=12.*mm;
00318       double boxCuEndDz=29.*mm;
00319 
00320       G4Box* boxCuEnd=new G4Box("solidboxCuEnd",boxCuEndDx/2.,boxCuEndDy/2.,boxCuEndDz/2.);
00321       G4LogicalVolume*boxCuEnd_log=new G4LogicalVolume(boxCuEnd,Cuu,"logical boxCuEnd");
00322       visAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0));
00323       boxCuEnd_log->SetVisAttributes(visAtt);
00324     // to construct a virtual box used to contain boxCuEnd and boxEndcape
00325       double dxVirtualBox=18.*mm;
00326       double dyVirtualBox=106.*mm;
00327       double dzVirtualBox=53.*mm;
00328       G4Box*virtualBoxForEndcape=new G4Box("solid virtualBoxEndcape",dxVirtualBox/2.,dyVirtualBox/2.*mm,dzVirtualBox/2.*mm);
00329       G4LogicalVolume*virtualBoxForEndcape_log=new G4LogicalVolume(virtualBoxForEndcape,G4Material::GetMaterial("Air"),"logical virtualBoxEndcape");
00330     // virtualBoxForEndcape_log->SetVisAttributes(G4VisAttributes::Invisible);
00331       virtualBoxForEndcape_log->SetVisAttributes(visAtt);
00332       G4VPhysicalVolume*boxEndcape_phys=new G4PVPlacement(0,G4ThreeVector(elecGeomPointer->BoxEndcape(0)/2.,0,0),boxEndcape_log,"physical boxEndcape",virtualBoxForEndcape_log,false,0);
00333       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);
00334       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);
00335       const double pi=3.141593;
00336       double posXArray;
00337       double posYArray;
00338       double posZArray;
00339       double startAngleArray;
00340 
00341       for (int i=0;i<elecGeomPointer->TotalElecLayerNo();i++)
00342       {
00343          startAngleArray=acos(elecGeomPointer->X(i)/elecGeomPointer->R(i));
00344 
00345          for(int j=0;j<elecGeomPointer->ElecNo(i);j++)
00346          {
00347             G4RotationMatrix*boxRotj=new G4RotationMatrix;
00348             boxRotj->rotateZ(-startAngleArray-j*2*pi/elecGeomPointer->ElecNo(i));
00349             posXArray=elecGeomPointer->R(i)*cos((startAngleArray+j*2*pi/elecGeomPointer->ElecNo(i)));
00350             posYArray=elecGeomPointer->R(i)*sin((startAngleArray+j*2*pi/elecGeomPointer->ElecNo(i)));
00351             posZArray=elecGeomPointer->Z(i);
00352             std::ostringstream osnamephys;
00353             osnamephys<<"physicalLayer"<<i<<"Ebox"<<j;
00354             G4VPhysicalVolume*box_phys=new G4PVPlacement(boxRotj,G4ThreeVector(posXArray,posYArray,posZArray),virtualBoxForEndcape_log,osnamephys.str(),mdc_log,false,j);
00355 
00356          }
00357       }
00358 
00359    //  cable on endcape
00360       G4double mCableDensity=6.4*g/cm3;
00361       G4Material*materialCable=new G4Material("M_materialCable",mCableDensity,3);
00362       materialCable->AddElement(Cu,0.4);
00363       materialCable->AddElement(C,0.3);
00364       materialCable->AddElement(H,0.3);
00365 
00366       double gapR=0.1*micrometer;
00367 
00368       //  The west cable tub can be constructed via recursive alogrithm
00369       double innerRCableTub;
00370       double outerRCableTub;
00371       for(int i=0;i<11;i++)
00372       { 
00373          innerRCableTub=elecGeomPointer->R(i)*mm-dxVirtualBox/2.+gapR;
00374          outerRCableTub=elecGeomPointer->R(i+1)*mm-dxVirtualBox/2.-gapR;
00375          std::ostringstream osnameCableSolid;
00376          osnameCableSolid<<"MdcCableSolidWest"<<i;
00377          G4Tubs*cableTub=new G4Tubs(osnameCableSolid.str(),innerRCableTub,outerRCableTub,elecGeomPointer->LengthCableTub(i+1)*1.15/2*mm,0*deg,360*deg);
00378 
00379          std::ostringstream osnameCableLog;
00380          osnameCableLog<<"MdcCableLogWest"<<i;
00381          G4LogicalVolume*cableTub_log=new G4LogicalVolume(cableTub,materialCable,osnameCableLog.str());
00382          visAtt= new G4VisAttributes(G4Colour(1,0.3,0.5));
00383          cableTub_log->SetVisAttributes(visAtt);
00384 
00385          std::ostringstream osnameCablePhys;
00386          osnameCablePhys<<"MdcCablePhysWest"<<i;
00387          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);
00388       }
00389 
00390       // The east too
00391       for(int i=0;i<10;i++)
00392       {
00393          innerRCableTub=elecGeomPointer->R(i+12)-dxVirtualBox/2.+gapR;
00394          outerRCableTub=elecGeomPointer->R(i+12+1)-dxVirtualBox/2.-gapR;
00395          std::ostringstream osnameCableSolid;
00396          osnameCableSolid<<"MdcCableSolidEast"<<i;
00397          G4Tubs*cableTub=new G4Tubs(osnameCableSolid.str(),innerRCableTub,outerRCableTub,elecGeomPointer->LengthCableTub(i+14)*1.15/2*mm,0*deg,360*deg);
00398 
00399          std::ostringstream osnameCableLog;
00400          osnameCableLog<<"MdcCableLogEast"<<i;
00401          G4LogicalVolume*cableTub_log=new G4LogicalVolume(cableTub,materialCable,osnameCableLog.str());
00402          visAtt= new G4VisAttributes(G4Colour(1,0.3,0.5));
00403          cableTub_log->SetVisAttributes(visAtt);
00404 
00405          std::ostringstream osnameCablePhys;
00406          osnameCablePhys<<"MdcCablePhysEast"<<i;
00407          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);
00408       }
00409 
00410 
00411      // There's need to construct the two first cable tub .
00412 
00413       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);
00414       G4LogicalVolume*cableTubBeginnerW_log=new G4LogicalVolume(cableTubBeginnerW,materialCable,"logical cableTubBeginnerW");
00415       visAtt= new G4VisAttributes(G4Colour(0,0.3,0.8));
00416       cableTubBeginnerW_log->SetVisAttributes(visAtt);
00417       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);
00418      //Mutiplying 1.15 is used to estimate the practicle length according to Dong Ming-yi and Liu Rong-guang.  
00419       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);
00420       G4LogicalVolume*cableTubBeginnerE_log=new G4LogicalVolume(cableTubBeginnerE,materialCable,"logical cabieTubBeginnerE");
00421       visAtt= new G4VisAttributes(G4Colour(1,0.3,0.5));
00422       cableTubBeginnerE_log->SetVisAttributes(visAtt);
00423 
00424       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);
00425 
00426 
00427      // There's need to construct the two cable tub(west and east) to tail seperately too.
00428       
00429       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);
00430       G4LogicalVolume*cableTubToTailW_log=new G4LogicalVolume(cableTubToTailW,materialCable,"logical cableTubToTailW");
00431       visAtt= new G4VisAttributes(G4Colour(0,0.3,0.8));
00432       cableTubToTailW_log->SetVisAttributes(visAtt);
00433 
00434       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);
00435 
00436       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);
00437     
00438       G4LogicalVolume*cableTubToTailE_log=new G4LogicalVolume(cableTubToTailE,materialCable,"logical cabieTubToTailE");
00439       visAtt= new G4VisAttributes(G4Colour(1.0,0.3,0.5));
00440       cableTubToTailE_log->SetVisAttributes(visAtt);
00441 
00442       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);
00443    
00444      // Construct shield plate beyond endcape
00445 
00446       G4Box* box0=new G4Box("box0",10.,15.,3.);
00447       G4LogicalVolume* box0_log=new G4LogicalVolume(box0,Al,"logicalBox0",0,0,0);
00448       visAtt= new G4VisAttributes(G4Colour(1.0,0.8,0.0));
00449       box0_log->SetVisAttributes(visAtt);
00450 
00451       G4Box* box1=new G4Box("box1",3.*cos(11.28*deg),15.,81./sin(11.28*deg)/2.);
00452       G4LogicalVolume* box1_log=new G4LogicalVolume(box1,Al,"logicalBox1",0,0,0);
00453       box1_log->SetVisAttributes(visAtt);
00454 
00455       G4Box* box2=new G4Box("box2",63.5,15.,3.);
00456       G4LogicalVolume* box2_log=new G4LogicalVolume(box2,Al,"logicalBox2",0,0,0);
00457       box2_log->SetVisAttributes(visAtt);
00458 
00459 
00460       for(i=0;i<8;i++){
00461          G4RotationMatrix* boxRot0=new G4RotationMatrix();
00462          boxRot0->rotateZ(-45*i*deg);
00463          posX=784.*cos(45*i*deg);
00464          posY=784.*sin(45*i*deg);
00465          posZ=1309.*mm;
00466          std::ostringstream osnameBox0PhysEast;
00467          osnameBox0PhysEast<<"physical"<< "box0p"<<i;
00468          G4VPhysicalVolume* box0p_phys=new G4PVPlacement(boxRot0,G4ThreeVector(posX ,posY ,posZ),
00469                box0_log,osnameBox0PhysEast.str(),mdc_log,false,i);
00470 
00471          std::ostringstream osnameBox0PhysWest;
00472          osnameBox0PhysWest<<"physical"<< "box0m"<<i;
00473          G4VPhysicalVolume* box0m_phys=new G4PVPlacement(boxRot0,G4ThreeVector(posX ,posY ,-posZ),
00474                box0_log,osnameBox0PhysWest.str(),mdc_log,false,i);
00475 
00476 
00477          G4RotationMatrix* boxRot1p=new G4RotationMatrix();
00478          boxRot1p->rotateZ(-45*i*deg);
00479          boxRot1p->rotateY(-78.72*deg);
00480          posX=570.5*cos(45*i*deg);
00481          posY=570.5*sin(45*i*deg);
00482          posZ=1268.5*mm;
00483          std::ostringstream osnameBox1PhysEast;
00484          osnameBox1PhysEast<<"physical"<< "box1p"<<i;
00485          G4VPhysicalVolume* box1p_phys=new G4PVPlacement(boxRot1p,G4ThreeVector(posX ,posY ,posZ),
00486                box1_log,osnameBox1PhysEast.str(),mdc_log,false,i);
00487 
00488          G4RotationMatrix* boxRot1m=new G4RotationMatrix();
00489          boxRot1m->rotateZ(-45*i*deg);
00490          boxRot1m->rotateY(78.72*deg);
00491          std::ostringstream osnameBox1PhysWest;
00492          osnameBox1PhysWest<<"physical"<< "box1m"<<i;
00493          G4VPhysicalVolume* box1m_phys=new G4PVPlacement(boxRot1m,G4ThreeVector(posX ,posY ,-posZ),
00494                box1_log,osnameBox1PhysWest.str(),mdc_log,false,i);
00495 
00496          G4RotationMatrix* boxRot2=new G4RotationMatrix();
00497          boxRot2->rotateZ(-45*i*deg);
00498          posX=303.5*cos(45*i*deg);
00499          posY=303.5*sin(45*i*deg);
00500          posZ=1228.*mm;
00501          std::ostringstream osnameBox2PhysEast;
00502          osnameBox2PhysEast<<"physical"<< "box2p"<<i;
00503          G4VPhysicalVolume* box2p_phys=new G4PVPlacement(boxRot2,G4ThreeVector(posX ,posY ,posZ),
00504                box2_log,osnameBox2PhysEast.str(),mdc_log,false,i);
00505 
00506          std::ostringstream osnameBox2PhysWest;
00507          osnameBox2PhysWest<<"physical"<< "box2m"<<i;
00508          G4VPhysicalVolume* box2m_phys=new G4PVPlacement(boxRot2,G4ThreeVector(posX ,posY ,-posZ),
00509                box2_log,osnameBox2PhysWest.str(),mdc_log,false,i);
00510 
00511       }
00512 
00513       G4double rMax2=774.*mm;
00514       G4double rMin2=rMax2 - 1.*mm/sin(11.28*deg);
00515       G4double rMin1=rMin2 - 80.*mm/tan(11.28*deg);
00516       G4double rMax1=rMin1 + 1.*mm/sin(11.28*deg);
00517       G4Cons* shieldPlate0p=new G4Cons("shieldPlate0p",rMin1,rMax1,rMin2,rMax2,40.*mm,0.,360.*deg);
00518       G4LogicalVolume* shieldPlate0p_log=new G4LogicalVolume(shieldPlate0p,Al,"logicalShieldPlate0p",0,0,0);
00519       visAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0));
00520       shieldPlate0p_log->SetVisAttributes(visAtt);
00521       posX=0.;
00522       posY=0.;
00523       posZ=1272.*mm;
00524       G4VPhysicalVolume* shieldPlate0p_phys=new G4PVPlacement(0,G4ThreeVector(posX ,posY ,posZ),
00525             shieldPlate0p_log,"physicalShieldPalte0p",mdc_log,false,0);
00526 
00527       G4Cons* shieldPlate0m=new G4Cons("shieldPlate0m",rMin2,rMax2,rMin1,rMax1,40.*mm,0.,360.*deg);
00528       G4LogicalVolume* shieldPlate0m_log=new G4LogicalVolume(shieldPlate0m,Al,"logicalShieldPlate0m",0,0,0);
00529       visAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0));
00530       shieldPlate0m_log->SetVisAttributes(visAtt);
00531       posX=0.;
00532       posY=0.;
00533       posZ=1272.*mm;
00534       G4VPhysicalVolume* shieldPlate0m_phys=new G4PVPlacement(0,G4ThreeVector(posX ,posY ,-posZ),
00535             shieldPlate0m_log,"physicalShieldPalte0m",mdc_log,false,0);
00536 
00537 
00538       G4Tubs* shieldPlate1=new G4Tubs("shieldPlate1",240.*mm,367.*mm,0.5*mm,0.,360.*deg);
00539       G4LogicalVolume* shieldPlate1_log=new G4LogicalVolume(shieldPlate1,Al,"logicalShieldPlate1",0,0,0);
00540       visAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0));
00541       shieldPlate1_log->SetVisAttributes(visAtt);
00542       posX=0.;
00543       posY=0.;
00544       posZ=1231.5*mm;
00545       G4VPhysicalVolume* shieldPlate1p_phys=new G4PVPlacement(0,G4ThreeVector(posX ,posY ,posZ),
00546             shieldPlate1_log,"physicalShieldPalte1p",mdc_log,false,0);
00547       G4VPhysicalVolume* shieldPlate1m_phys=new G4PVPlacement(0,G4ThreeVector(posX ,posY ,-posZ),
00548             shieldPlate1_log,"physicalShieldPalte1m",mdc_log,false,0);
00549 
00550                  
00551     //========Layer  
00552     G4int signalLayer,firstWire;
00553     G4int replicaNo;
00554     G4double offset;
00555     
00556     G4double signalWireR=mdc->SignalWireR()*micrometer;
00557     G4double fieldWireR=mdc->FieldWireR()*micrometer;
00558     G4double thickOfAu=0.7*micrometer; // All wires are goldplated.
00559     
00560     G4double innerLength,innerTwistAngle,innerTan,midInnerR,innerStereo;
00561     G4double outLength,outTwistAngle,outTwistAngleFixed,outTan,midOutR,outStereo,outRFixed,outTanFixed; 
00562     
00563     //----Axial layers 37-43 
00564     for(i=42; i>35; i--){
00565       G4int signalLayer=mdc->Signal2Global(i);
00566       firstWire=mdc->Layer(signalLayer).FirstWire();
00567       for(n=1;n>-1;n--){
00568         innerR=mdc->Layer(signalLayer-1+n).R()*mm-fieldWireR;
00569         outR=mdc->Layer(signalLayer+n).R()*mm-fieldWireR;
00570         if(i==42&&n==1)outR=mdc->Layer(signalLayer+n).R()*mm+fieldWireR;
00571         length=(mdc->Layer(signalLayer-1+n).Length())/2.*mm;
00572         startAngle=0.*deg;
00573         spanAngle=360.*deg;
00574         posX  = 0.*m;
00575         posY  = 0.*m;
00576         posZ  = 0.*m;
00577         
00578         //Layer 
00579         std::ostringstream osnameLayerSolid;
00580         osnameLayerSolid <<"solid"<< "MdcAxialLayer"<<i<<"_"<<n;  
00581         G4Tubs* axialLayer_tube=new G4Tubs(osnameLayerSolid.str(),innerR,outR,length,startAngle,spanAngle);
00582         
00583         std::ostringstream osnameLayerLogical;
00584         osnameLayerLogical <<"logical"<< "MdcAxialLayer"<<i<<"_"<<n;
00585         G4LogicalVolume* axialLayer_log=new G4LogicalVolume(axialLayer_tube, MdcGas,osnameLayerLogical.str(),0,0,0);
00586 
00587         axialLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
00588 
00589         replicaNo=mdc->Layer(signalLayer).WireNo()/2;
00590         spanAngle=360./replicaNo*deg;
00591         
00592         offset=mdc->Layer(signalLayer).Phi()*rad-firstWire*spanAngle/2.;      
00593         G4RotationMatrix* layerRot=new G4RotationMatrix();
00594         layerRot->rotateZ(-offset);
00595 
00596         std::ostringstream osnameLayerPhys;
00597         osnameLayerPhys <<"physical"<< "MdcAxialLayer"<<i<<"_"<<n;
00598         G4VPhysicalVolume* axialLayer_phys;
00599         axialLayer_phys=new G4PVPlacement(layerRot,
00600                                              0,
00601                                           axialLayer_log,osnameLayerPhys.str(),mdc_log,false,i);
00602         
00603         //Cell
00604         std::ostringstream osnameCellSolid;
00605         osnameCellSolid<<"solid"<< "MdcAxialLayer"<<i<<"_"<<n<<"Cell"; 
00606         G4Tubs* replica_tube=new G4Tubs(osnameCellSolid.str(),innerR,outR,length,startAngle,spanAngle);
00607 
00608         std::ostringstream osnameCellLogical;
00609         osnameCellLogical<<"logical"<< "MdcAxialLayer"<<i<<"_"<<n<<"Cell"; 
00610         G4LogicalVolume* replica_log=new G4LogicalVolume(replica_tube,MdcGas,osnameCellLogical.str(),0,0,0);
00611         
00612         replica_log->SetSensitiveDetector( aTrackerSD );
00613         visAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0));
00614         replica_log->SetVisAttributes(visAtt);
00615         replica_log->SetVisAttributes(G4VisAttributes::Invisible);
00616         //       replica_log->SetUserLimits(new G4UserLimits(maxStep));
00617         //Wire
00618         if(ReadBoostRoot::GetMdc()==1){
00619           std::ostringstream osnameFieldWireSolid;
00620           osnameFieldWireSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"FieldWire";
00621           G4Tubs* fieldWire_tube=new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,length,0.,360*deg);
00622           std::ostringstream osnameFieldWireLogical;
00623           osnameFieldWireLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWire";
00624           G4LogicalVolume* fieldWire_log=new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
00625           
00626           std::ostringstream osnameFieldWireSubSolid;
00627           osnameFieldWireSubSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireSub";
00628           G4Tubs* fieldWireSub_tube=new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,length,0.,360*deg);
00629           std::ostringstream osnameFieldWireSubLogical;
00630           osnameFieldWireSubLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireSub";
00631           G4LogicalVolume* fieldWireSub_log=new G4LogicalVolume(fieldWireSub_tube,Al,osnameFieldWireSubLogical.str(),0,0,0);
00632           std::ostringstream osnameFieldWireSubPhys;
00633           osnameFieldWireSubPhys<<"physical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireSub";
00634           G4VPhysicalVolume* fieldWireSub_phys;
00635           fieldWireSub_phys=new G4PVPlacement(0,0,fieldWireSub_log,
00636                                               osnameFieldWireSubPhys.str(),fieldWire_log,false,0);
00637           
00638           std::ostringstream osnameFieldWireHalfSolid;
00639           osnameFieldWireHalfSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalf";
00640           G4Tubs* fieldWireHalf_tube=new G4Tubs(osnameFieldWireHalfSolid.str(),0.,fieldWireR,length,0.,180*deg);
00641           std::ostringstream osnameFieldWireHalfLogical;
00642           osnameFieldWireHalfLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalf";
00643           G4LogicalVolume* fieldWireHalf_log=new G4LogicalVolume(fieldWireHalf_tube,Au,osnameFieldWireHalfLogical.str(),0,0,0);
00644           
00645           std::ostringstream osnameFieldWireHalfSubSolid;
00646           osnameFieldWireHalfSubSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalfSub";
00647           G4Tubs* fieldWireHalfSub_tube=new G4Tubs(osnameFieldWireHalfSubSolid.str(),0.,fieldWireR-thickOfAu,length,0.,360*deg);
00648           std::ostringstream osnameFieldWireHalfSubLogical;
00649           osnameFieldWireHalfSubLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalfSub";
00650           G4LogicalVolume* fieldWireHalfSub_log=new G4LogicalVolume(fieldWireHalfSub_tube,Al,osnameFieldWireHalfSubLogical.str(),0,0,0);
00651           std::ostringstream osnameFieldWireHalfSubPhys;
00652           osnameFieldWireHalfSubPhys<<"physical"<< "AxialLayer"<<i<<"_"<<n<<"FieldWireHalfSub";
00653           G4VPhysicalVolume* fieldWireHalfSub_phys;
00654           fieldWireHalfSub_phys=new G4PVPlacement(0,0,fieldWireHalfSub_log,
00655                                                   osnameFieldWireHalfSubPhys.str(),fieldWireHalf_log,false,0);
00656           
00657           //phi  <------------------->-phi 
00658           //      |F8      F5     F2|  There are 1 signal wire S4,2 half field wire F1,7 
00659           // sub1 |                 |  in each cell of sub1 except Layer 42,  
00660           //      |F7      S4     F1|  1 more full field wire F5, 2 more half field wire F2,8
00661           //      |-----------------|
00662           // sub0 |                 |  Each cell of sub0 have 1 full field wire F3, 2 half 
00663           //      |F6      F3     F0|  field wire F0,6
00664           //      -------------------
00665           if(n==0){
00666             std::ostringstream osnameFieldWire0Phys;
00667             osnameFieldWire0Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire0";
00668             posX=mdc->Layer(signalLayer-1).R()*mm;
00669             G4VPhysicalVolume* fieldWire0_phys;
00670             fieldWire0_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
00671                                               osnameFieldWire0Phys.str(),replica_log,false,0);
00672             
00673             std::ostringstream osnameFieldWire3Phys;
00674             osnameFieldWire3Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire3";
00675             posX=mdc->Layer(signalLayer-1).R()*mm*cos(spanAngle/2.);
00676             posY=mdc->Layer(signalLayer-1).R()*mm*sin(spanAngle/2.);
00677             G4VPhysicalVolume* fieldWire3_phys;
00678             fieldWire3_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
00679                                               osnameFieldWire3Phys.str(),replica_log,false,3);      
00680             std::ostringstream osnameFieldWire6Phys;
00681             osnameFieldWire6Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire6";
00682             posX=mdc->Layer(signalLayer-1).R()*mm*cos(spanAngle);
00683             posY=mdc->Layer(signalLayer-1).R()*mm*sin(spanAngle);
00684             G4RotationMatrix* wireRot6=new G4RotationMatrix();
00685             wireRot6->rotateZ(180*deg-spanAngle);
00686             G4VPhysicalVolume* fieldWire6_phys;
00687             fieldWire6_phys=new G4PVPlacement(wireRot6,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
00688                                               osnameFieldWire6Phys.str(),replica_log,false,6);
00689           }
00690           
00691           if(n==1){
00692             std::ostringstream osnameFieldWire1Phys;
00693             osnameFieldWire1Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire1";
00694             posX=mdc->Layer(signalLayer).R()*mm;
00695             G4VPhysicalVolume* fieldWire1_phys;
00696             fieldWire1_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
00697                                               osnameFieldWire1Phys.str(),replica_log,false,1);      
00698             std::ostringstream osnameSignalWireSolid;
00699             osnameSignalWireSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"SignalWire";
00700             G4Tubs* signalWire_tube=new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,length,0.,360*deg);
00701             std::ostringstream osnameSignalWireLogical;
00702             osnameSignalWireLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"SignalWire";
00703             G4LogicalVolume* signalWire_log=new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
00704             
00705             std::ostringstream osnameSignalWireSubSolid;
00706             osnameSignalWireSubSolid<<"solid"<< "AxialLayer"<<i<<"_"<<n<<"SignalWireSub";
00707             G4Tubs* signalWireSub_tube=new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,length,0.,360*deg);
00708             std::ostringstream osnameSignalWireSubLogical;
00709             osnameSignalWireSubLogical<<"logical"<< "AxialLayer"<<i<<"_"<<n<<"SignalWireSub";
00710             G4LogicalVolume* signalWireSub_log=new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
00711             std::ostringstream osnameSignalWireSubPhys;
00712             osnameSignalWireSubPhys<<"physical"<< "AxialLayer"<<i<<"_"<<n<<"SignalWireSub";
00713             G4VPhysicalVolume* signalWireSub_phys;
00714             signalWireSub_phys=new G4PVPlacement(0,0,signalWireSub_log,
00715                                                  osnameSignalWireSubPhys.str(),signalWire_log,false,0);
00716 
00717             std::ostringstream osnameSignalWirePhys;
00718             osnameSignalWirePhys<<"physicalAxialLayer"<<i<<"_"<<n<<"SignalWire4";
00719             posX=mdc->Layer(signalLayer).R()*mm*cos(spanAngle/2.);
00720             posY=mdc->Layer(signalLayer).R()*mm*sin(spanAngle/2.);
00721             G4VPhysicalVolume* signalWire_phys;
00722             signalWire_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),signalWire_log,
00723                                               osnameSignalWirePhys.str(),replica_log,false,4);
00724             
00725             std::ostringstream osnameFieldWire7Phys;
00726             osnameFieldWire7Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire7";
00727             posX=mdc->Layer(signalLayer).R()*mm*cos(spanAngle);
00728             posY=mdc->Layer(signalLayer).R()*mm*sin(spanAngle);
00729             G4RotationMatrix* wireRot7=new G4RotationMatrix();
00730             wireRot7->rotateZ(180*deg-spanAngle);
00731             G4VPhysicalVolume* fieldWire7_phys;
00732             fieldWire7_phys=new G4PVPlacement(wireRot7,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
00733                                               osnameFieldWire7Phys.str(),replica_log,false,7);
00734             if(i==42){
00735               std::ostringstream osnameFieldWire2Phys;
00736               osnameFieldWire2Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire2";
00737               posX=mdc->Layer(signalLayer+1).R()*mm;
00738               G4VPhysicalVolume* fieldWire2_phys;
00739               fieldWire2_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
00740                                                 osnameFieldWire2Phys.str(),replica_log,false,2);
00741               
00742               std::ostringstream osnameFieldWire5Phys;
00743               osnameFieldWire5Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire5";
00744               posX=mdc->Layer(signalLayer+1).R()*mm*cos(spanAngle/2.);
00745               posY=mdc->Layer(signalLayer+1).R()*mm*sin(spanAngle/2.);
00746               G4VPhysicalVolume* fieldWire5_phys;
00747               fieldWire5_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
00748                                                 osnameFieldWire5Phys.str(),replica_log,false,5);
00749               
00750               std::ostringstream osnameFieldWire8Phys;
00751               osnameFieldWire8Phys<<"physicalAxialLayer"<<i<<"_"<<n<<"FieldWire8";
00752               posX=mdc->Layer(signalLayer+1).R()*mm*cos(spanAngle);
00753               posY=mdc->Layer(signalLayer+1).R()*mm*sin(spanAngle);
00754               G4RotationMatrix* wireRot8=new G4RotationMatrix();
00755               wireRot8->rotateZ(180*deg-spanAngle);
00756               G4VPhysicalVolume* fieldWire8_phys;
00757               fieldWire8_phys=new G4PVPlacement(wireRot8,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
00758                                                 osnameFieldWire8Phys.str(),replica_log,false,8);
00759             }
00760           }
00761         }
00762         //Put cells into layer
00763         for(j=replicaNo-1;j>-1;j--){
00764           G4RotationMatrix* cellRot=new G4RotationMatrix();
00765           cellRot->rotateZ(-spanAngle*j);
00766           std::ostringstream osnameCellPhys;
00767           osnameCellPhys<<"physical"<< "MdcAxialLayer"<<i<<"_"<<n<<"Cell"<<j; 
00768           G4VPhysicalVolume* replica_phys;
00769           replica_phys=new G4PVPlacement(cellRot,0,replica_log,
00770                                          osnameCellPhys.str(),axialLayer_log,false,j);
00771         }             
00772         
00773       }
00774       
00775     }
00776     //----Stereo layers 21-36
00777             
00778     for(i=35; i>19; i--){
00779       signalLayer=mdc->Signal2Global(i);
00780 
00781       innerR=mdc->Layer(signalLayer-1).R()*mm-fieldWireR;
00782       outR=mdc->Layer(signalLayer+1).R()*mm-fieldWireR;
00783       if(i==35)outR=mdc->Layer(signalLayer+1).R()*mm+fieldWireR;
00784 
00785       innerLength=(mdc->Layer(signalLayer-1).Length())/2.*mm;
00786       outLength=(mdc->Layer(signalLayer+1).Length())/2.*mm;
00787 
00788       innerTwistAngle=mdc->Layer(signalLayer-1).RotateAngle()*rad;
00789       outTwistAngle=mdc->Layer(signalLayer+1).RotateAngle()*rad;
00790 
00791       innerTan=innerR/innerLength*sin(innerTwistAngle);
00792                 
00793       midInnerR=innerR*cos(innerTwistAngle);
00794       innerStereo=atan(innerTan);
00795 
00796       outTan=outR/outLength*sin(outTwistAngle);
00797       outTwistAngleFixed=atan(innerLength/outLength*tan(outTwistAngle));
00798 
00799       if(abs(outTwistAngleFixed) >= abs(innerTwistAngle)){
00800         midOutR=outR*cos(outTwistAngle);
00801         outRFixed=midOutR/cos(innerTwistAngle);
00802         outR=outRFixed;
00803 
00804         outTanFixed=midOutR/innerLength*tan(innerTwistAngle);
00805         outStereo=atan(outTanFixed);
00806       }else{    
00807         outRFixed=sqrt(outR*outR+(innerLength*innerLength-outLength*outLength)*outTan*outTan);
00808         outR=outRFixed;
00809         midOutR=outR*cos(innerTwistAngle);
00810 
00811         outTanFixed=outRFixed/innerLength*sin(innerTwistAngle);
00812         outStereo=atan(outTanFixed);
00813       }
00814       //Layer
00815       std::ostringstream osnameLayerSolid;
00816       osnameLayerSolid <<"solid"<< "MdcStereoLayer"<<i;  
00817 
00818       G4Hype* stereoLayer_hype=new G4Hype(osnameLayerSolid.str(),midInnerR, midOutR,innerStereo,
00819                                           outStereo,innerLength);
00820 
00821       std::ostringstream osnameLayerLogical;
00822       osnameLayerLogical <<"logical"<< "MdcStereoLayer"<<i;
00823       G4LogicalVolume* stereoLayer_log=new G4LogicalVolume(stereoLayer_hype,MdcGas,
00824                                                            osnameLayerLogical.str(),0,0,0);
00825       stereoLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
00826 
00827       replicaNo=mdc->Layer(signalLayer).WireNo()/2;
00828       spanAngle=360./replicaNo*deg;
00829       firstWire=mdc->Layer(signalLayer).FirstWire();
00830 
00831       G4RotationMatrix* layerRot=new G4RotationMatrix();
00832       layerRot->rotateZ(-(spanAngle*(1-firstWire)/2.+innerTwistAngle));
00833 
00834       std::ostringstream osnameLayerPhys;
00835       osnameLayerPhys<<"physical"<< "MdcStereoLayer"<<i;
00836       G4VPhysicalVolume* stereoLayer_phys;
00837       stereoLayer_phys=new G4PVPlacement(layerRot,0,stereoLayer_log,osnameLayerPhys.str(),
00838                                          mdc_log,false,i);
00839       //Cell
00840       std::ostringstream osnameCellSolid;
00841       osnameCellSolid<<"solid"<< "MdcStereoLayer"<<i<<"Cell";
00842       
00843       G4TwistedTubs* twistTub=new G4TwistedTubs(osnameCellSolid.str(), -innerTwistAngle*2, innerR,outR-1.0*micrometer,innerLength,spanAngle);
00844       
00845       std::ostringstream osnameCellLogical;
00846       osnameCellLogical<<"logical"<< "MdcStereoLayer"<<i<<"Cell";
00847       G4LogicalVolume* twistTub_log=new G4LogicalVolume(twistTub, MdcGas,osnameCellLogical.str(),0,0,0);
00848 
00849       twistTub_log->SetVisAttributes(G4VisAttributes::Invisible);
00850       twistTub_log->SetSensitiveDetector( aTrackerSD );
00851       //       twistTub_log->SetUserLimits(new G4UserLimits(maxStep));       
00852 
00853       //Wire
00854       if(ReadBoostRoot::GetMdc()==1){
00855         std::ostringstream osnameFieldWireSolid;
00856         osnameFieldWireSolid<<"solid"<< "StereoLayer"<<i<<"FieldWire";
00857         G4Tubs* fieldWire_tube=new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,innerLength,0.,360*deg);
00858         std::ostringstream osnameFieldWireLogical;
00859         osnameFieldWireLogical<<"logical"<< "StereoLayer"<<i<<"FieldWire";
00860         G4LogicalVolume* fieldWire_log=new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
00861         
00862         std::ostringstream osnameFieldWireSubSolid;
00863         osnameFieldWireSubSolid<<"solid"<< "StereoLayer"<<i<<"FieldWireSub";
00864         G4Tubs* fieldWireSub_tube=new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,innerLength,0.,360*deg);
00865         std::ostringstream osnameFieldWireSubLogical;
00866         osnameFieldWireSubLogical<<"logical"<< "StereoLayer"<<i<<"FieldWireSub";
00867         G4LogicalVolume* fieldWireSub_log=new G4LogicalVolume(fieldWireSub_tube,Al,osnameFieldWireSubLogical.str(),0,0,0);
00868         std::ostringstream osnameFieldWireSubPhys;
00869         osnameFieldWireSubPhys<<"physical"<< "StereoLayer"<<i<<"FieldWireSub";
00870         G4VPhysicalVolume* fieldWireSub_phys;
00871         fieldWireSub_phys=new G4PVPlacement(0,0,fieldWireSub_log,
00872                                             osnameFieldWireSubPhys.str(),fieldWire_log,false,0);
00873         
00874         std::ostringstream osnameSignalWireSolid;
00875         osnameSignalWireSolid<<"solid"<< "StereoLayer"<<i<<"SignalWire";
00876         G4Tubs* signalWire_tube=new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,innerLength,0.,360*deg);
00877         std::ostringstream osnameSignalWireLogical;
00878         osnameSignalWireLogical<<"logical"<< "StereoLayer"<<i<<"SignalWire";
00879         G4LogicalVolume* signalWire_log=new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
00880         
00881         std::ostringstream osnameSignalWireSubSolid;
00882         osnameSignalWireSubSolid<<"solid"<< "StereoLayer"<<i<<"SignalWireSub";
00883         G4Tubs* signalWireSub_tube=new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,innerLength,0.,360*deg);
00884         std::ostringstream osnameSignalWireSubLogical;
00885         osnameSignalWireSubLogical<<"logical"<< "StereoLayer"<<i<<"SignalWireSub";
00886         G4LogicalVolume* signalWireSub_log=new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
00887         std::ostringstream osnameSignalWireSubPhys;
00888         osnameSignalWireSubPhys<<"physical"<< "StereoLayer"<<i<<"SignalWireSub";
00889         G4VPhysicalVolume* signalWireSub_phys;
00890         signalWireSub_phys=new G4PVPlacement(0,0,signalWireSub_log,
00891                                              osnameSignalWireSubPhys.str(),signalWire_log,false,0);
00892         
00893         //phi  <------------------->-phi 
00894         //      |      F5     F2|  There are 1 signal wire S4,3 full field  
00895         //      |               |  wire F0,1,3 in each cell except Layer 35, 
00896         //      |      S4     F1|  2 more full field wire F2,5.
00897         //      |               |  In stereo cell we can't put half wire at edge because of
00898         //      |      F3     F0|  overlap, so all wires are full wire,Positon of field   
00899         //      ----------------|  wire is not at cell edge but move into cell avoid overlap
00900         G4double shiftR,midR,eastX,eastY,westX,westY;
00901         shiftR=fieldWireR+1*micrometer;
00902         midR=mdc->Layer(signalLayer).R()*mm;
00903         
00904         std::ostringstream osnameFieldWire0Phys;
00905         osnameFieldWire0Phys<<"physicalStereoLayer"<<i<<"FieldWire0";
00906         
00907         eastX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
00908         eastY=(innerR+shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
00909         westX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
00910         westY=(innerR+shiftR/cos(innerTwistAngle))*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
00911         
00912         G4ThreeVector east0(eastX,eastY,innerLength);
00913         G4ThreeVector west0(westX,westY,-innerLength);
00914         east0.rotateZ(-spanAngle/2.);
00915         west0.rotateZ(-spanAngle/2.);
00916         
00917         posX=(east0.x()+west0.x())/2.;
00918         posY=(east0.y()+west0.y())/2.;
00919         G4ThreeVector line0=east0-west0;
00920         G4RotationMatrix* wireRot0=new G4RotationMatrix();
00921         wireRot0->rotateZ(-line0.phi());
00922         wireRot0->rotateY(-line0.theta());      
00923         G4VPhysicalVolume* fieldWire0_phys;
00924         fieldWire0_phys=new G4PVPlacement(wireRot0,G4ThreeVector(posX,posY,0),fieldWire_log,
00925                                           osnameFieldWire0Phys.str(),twistTub_log,false,0);
00926         
00927         std::ostringstream osnameFieldWire1Phys;
00928         osnameFieldWire1Phys<<"physicalStereoLayer"<<i<<"FieldWire1";
00929         eastX=midR*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
00930         eastY=midR*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
00931         westX=midR*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
00932         westY=midR*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
00933         G4ThreeVector east1(eastX,eastY,innerLength);
00934         G4ThreeVector west1(westX,westY,-innerLength);
00935         east1.rotateZ(-spanAngle/2.);
00936         west1.rotateZ(-spanAngle/2.);
00937         posX=(east1.x()+west1.x())/2.;
00938         posY=(east1.y()+west1.y())/2.;
00939         G4ThreeVector line1=east1-west1;
00940         G4RotationMatrix* wireRot1=new G4RotationMatrix();
00941         wireRot1->rotateZ(-line1.phi());
00942         wireRot1->rotateY(-line1.theta());      
00943         G4VPhysicalVolume* fieldWire1_phys;
00944         fieldWire1_phys=new G4PVPlacement(wireRot1,G4ThreeVector(posX,posY,0),fieldWire_log,
00945                                           osnameFieldWire1Phys.str(),twistTub_log,false,1);
00946         
00947         std::ostringstream osnameFieldWire3Phys;
00948         osnameFieldWire3Phys<<"physicalStereoLayer"<<i<<"FieldWire3";
00949         
00950         eastX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
00951         eastY=(innerR+shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle);
00952         westX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
00953         westY=(innerR+shiftR/cos(innerTwistAngle))*sin(innerTwistAngle);
00954         
00955         G4ThreeVector east3(eastX,eastY,innerLength);
00956         G4ThreeVector west3(westX,westY,-innerLength);
00957         
00958         posX=(east3.x()+west3.x())/2.;
00959         posY=(east3.y()+west3.y())/2.;
00960         G4ThreeVector line3=east3-west3;
00961         G4RotationMatrix* wireRot3=new G4RotationMatrix();
00962         wireRot3->rotateZ(-line3.phi());
00963         wireRot3->rotateY(-line3.theta());      
00964         G4VPhysicalVolume* fieldWire3_phys;
00965         fieldWire3_phys=new G4PVPlacement(wireRot3,G4ThreeVector(posX,posY,0),fieldWire_log,
00966                                           osnameFieldWire3Phys.str(),twistTub_log,false,3);
00967         
00968         std::ostringstream osnameSignalWire4Phys;
00969         osnameSignalWire4Phys<<"physicalStereoLayer"<<i<<"SignalWire4";
00970         
00971         eastX=midR*cos(innerTwistAngle);
00972         eastY=midR*sin(-innerTwistAngle);
00973         westX=midR*cos(innerTwistAngle);
00974         westY=midR*sin(innerTwistAngle);
00975         
00976         G4ThreeVector east4(eastX,eastY,innerLength);
00977         G4ThreeVector west4(westX,westY,-innerLength);
00978         
00979         posX=(east4.x()+west4.x())/2.;
00980         posY=(east4.y()+west4.y())/2.;
00981         G4ThreeVector line4=east4-west4;
00982         G4RotationMatrix* wireRot4=new G4RotationMatrix();
00983         wireRot4->rotateZ(-line4.phi());
00984         wireRot4->rotateY(-line4.theta());      
00985         G4VPhysicalVolume* signalWire4_phys;
00986         signalWire4_phys=new G4PVPlacement(wireRot4,G4ThreeVector(posX,posY,0),signalWire_log,
00987                                            osnameSignalWire4Phys.str(),twistTub_log,false,4);
00988         
00989         if(i==35){
00990           std::ostringstream osnameFieldWire2Phys;
00991           osnameFieldWire2Phys<<"physicalStereoLayer"<<i<<"FieldWire2";
00992           
00993           eastX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
00994           eastY=(outR-shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
00995           westX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
00996           westY=(outR-shiftR/cos(innerTwistAngle))*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
00997           
00998           G4ThreeVector east2(eastX,eastY,innerLength);
00999           G4ThreeVector west2(westX,westY,-innerLength);
01000           east2.rotateZ(-spanAngle/2.);
01001           west2.rotateZ(-spanAngle/2.);
01002           
01003           posX=(east2.x()+west2.x())/2.;
01004           posY=(east2.y()+west2.y())/2.;
01005           G4ThreeVector line2=east2-west2;
01006           G4RotationMatrix* wireRot2=new G4RotationMatrix();
01007           wireRot2->rotateZ(-line2.phi());
01008           wireRot2->rotateY(-line2.theta());    
01009           G4VPhysicalVolume* fieldWire2_phys;
01010           fieldWire2_phys=new G4PVPlacement(wireRot2,G4ThreeVector(posX,posY,0),fieldWire_log,
01011                                             osnameFieldWire2Phys.str(),twistTub_log,false,2);
01012           
01013           std::ostringstream osnameFieldWire5Phys;
01014           osnameFieldWire5Phys<<"physicalStereoLayer"<<i<<"FieldWire5";
01015           
01016           eastX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
01017           eastY=(outR-shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle);
01018           westX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
01019           westY=(outR-shiftR/cos(innerTwistAngle))*sin(innerTwistAngle);
01020           
01021           G4ThreeVector east5(eastX,eastY,innerLength);
01022           G4ThreeVector west5(westX,westY,-innerLength);
01023           
01024           posX=(east5.x()+west5.x())/2.;
01025           posY=(east5.y()+west5.y())/2.;
01026           G4ThreeVector line5=east5-west5;
01027           G4RotationMatrix* wireRot5=new G4RotationMatrix();
01028           wireRot5->rotateZ(-line5.phi());
01029           wireRot5->rotateY(-line5.theta());    
01030           G4VPhysicalVolume* fieldWire5_phys;
01031           fieldWire5_phys=new G4PVPlacement(wireRot5,G4ThreeVector(posX,posY,0),fieldWire_log,
01032                                             osnameFieldWire5Phys.str(),twistTub_log,false,5);
01033         }
01034       }
01035       //Put cells into layer
01036       for(j=replicaNo-1;j>-1;j--){
01037         G4RotationMatrix* cellRot=new G4RotationMatrix();
01038         cellRot->rotateZ(-spanAngle*j);
01039 
01040         std::ostringstream osnameCellPhys;
01041         osnameCellPhys<<"physical"<< "MdcStereoLayer"<<i<<"Cell"<<j;
01042         G4VPhysicalVolume* twistTub_phys;
01043         twistTub_phys=new G4PVPlacement(cellRot,0,twistTub_log,
01044                                         osnameCellPhys.str(),stereoLayer_log,false,j);
01045       }
01046     }
01047 
01048     //----Axial layers 9-20    
01049     for(i=19; i>7; i--){
01050       signalLayer=mdc->Signal2Global(i);
01051       innerR=mdc->Layer(signalLayer-1).R()*mm-fieldWireR;
01052       outR=mdc->Layer(signalLayer+1).R()*mm-fieldWireR;
01053       if(i==19)outR=mdc->Layer(signalLayer+1).R()*mm+fieldWireR;
01054       length=(mdc->Layer(signalLayer).Length())/2.*mm;
01055       startAngle=0.*deg;
01056       spanAngle=360.*deg;
01057       firstWire=mdc->Layer(signalLayer).FirstWire();
01058       posX  = 0.*m;
01059       posY  = 0.*m;
01060       posZ  = 0.*m;
01061       
01062       //Layer
01063       std::ostringstream osnameLayerSolid;
01064       osnameLayerSolid <<"solid"<< "MdcAxialLayer"<<i;  
01065       G4Tubs* axialLayer_tube=new G4Tubs(osnameLayerSolid.str(),innerR,outR,length,startAngle,spanAngle);
01066 
01067       std::ostringstream osnameLayerLogical;
01068       osnameLayerLogical <<"logical"<< "MdcAxialLayer"<<i;
01069       G4LogicalVolume* axialLayer_log=new G4LogicalVolume(axialLayer_tube, MdcGas,osnameLayerLogical.str(),0,0,0);
01070       axialLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
01071 
01072       replicaNo=mdc->Layer(signalLayer).WireNo()/2;
01073       spanAngle=360./replicaNo*deg;
01074       
01075       offset=mdc->Layer(signalLayer).Phi()*rad-firstWire*spanAngle/2.;
01076       G4RotationMatrix* layerRot=new G4RotationMatrix();
01077       layerRot->rotateZ(-offset);
01078 
01079       std::ostringstream osnameLayerPhys;
01080       osnameLayerPhys<<"physical"<< "MdcAxialLayer"<<i;
01081       G4VPhysicalVolume* axialLayer_phys;
01082       axialLayer_phys=new G4PVPlacement(layerRot,0,axialLayer_log,
01083                                         osnameLayerPhys.str(),mdc_log,false,i);
01084 
01085       //Cell      
01086       std::ostringstream osnameCellSolid;
01087       osnameCellSolid<<"solid"<< "MdcAxialLayer"<<i<<"Cell"; 
01088       G4Tubs* replica_tube=new G4Tubs(osnameCellSolid.str(),innerR,outR,length,startAngle,spanAngle);
01089 
01090       std::ostringstream osnameCellLogical;
01091       osnameCellLogical<<"logical"<< "MdcAxialLayer"<<i<<"Cell";
01092       G4LogicalVolume* replica_log=new G4LogicalVolume(replica_tube,MdcGas,osnameCellLogical.str(),0,0,0);
01093       
01094       replica_log->SetSensitiveDetector( aTrackerSD );
01095       visAtt= new G4VisAttributes(G4Colour(0.0,0.0,1.0));
01096       replica_log->SetVisAttributes(visAtt);
01097       replica_log->SetVisAttributes(G4VisAttributes::Invisible);
01098       //       replica_log->SetUserLimits(new G4UserLimits(maxStep));
01099       //Wire
01100       if(ReadBoostRoot::GetMdc()==1){
01101         std::ostringstream osnameFieldWireSolid;
01102         osnameFieldWireSolid<<"solid"<< "AxialLayer"<<i<<"FieldWire";
01103         G4Tubs* fieldWire_tube=new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,length,0.,360*deg);
01104         std::ostringstream osnameFieldWireLogical;
01105         osnameFieldWireLogical<<"logical"<< "AxialLayer"<<i<<"FieldWire";
01106         G4LogicalVolume* fieldWire_log=new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
01107         
01108         std::ostringstream osnameFieldWireSubSolid;
01109         osnameFieldWireSubSolid<<"solid"<< "AxialLayer"<<i<<"FieldWireSub";
01110         G4Tubs* fieldWireSub_tube=new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,length,0.,360*deg);
01111         std::ostringstream osnameFieldWireSubLogical;
01112         osnameFieldWireSubLogical<<"logical"<< "AxialLayer"<<i<<"FieldWireSub";
01113         G4LogicalVolume* fieldWireSub_log=new G4LogicalVolume(fieldWireSub_tube,Al,osnameFieldWireSubLogical.str(),0,0,0);
01114         std::ostringstream osnameFieldWireSubPhys;
01115         osnameFieldWireSubPhys<<"physical"<< "AxialLayer"<<i<<"FieldWireSub";
01116         G4VPhysicalVolume* fieldWireSub_phys;
01117         fieldWireSub_phys=new G4PVPlacement(0,0,fieldWireSub_log,
01118                                             osnameFieldWireSubPhys.str(),fieldWire_log,false,0);
01119         
01120         std::ostringstream osnameFieldWireHalfSolid;
01121         osnameFieldWireHalfSolid<<"solid"<< "AxialLayer"<<i<<"FieldWireHalf";
01122         G4Tubs* fieldWireHalf_tube=new G4Tubs(osnameFieldWireHalfSolid.str(),0.,fieldWireR,length,0.,180*deg);
01123         std::ostringstream osnameFieldWireHalfLogical;
01124         osnameFieldWireHalfLogical<<"logical"<< "AxialLayer"<<i<<"FieldWireHalf";
01125         G4LogicalVolume* fieldWireHalf_log=new G4LogicalVolume(fieldWireHalf_tube,Au,osnameFieldWireHalfLogical.str(),0,0,0);
01126         
01127         std::ostringstream osnameFieldWireHalfSubSolid;
01128         osnameFieldWireHalfSubSolid<<"solid"<< "AxialLayer"<<i<<"FieldWireHalfSub";
01129         G4Tubs* fieldWireHalfSub_tube=new G4Tubs(osnameFieldWireHalfSubSolid.str(),0.,fieldWireR-thickOfAu,length,0.,360*deg);
01130         std::ostringstream osnameFieldWireHalfSubLogical;
01131         osnameFieldWireHalfSubLogical<<"logical"<< "AxialLayer"<<i<<"FieldWireHalfSub";
01132         G4LogicalVolume* fieldWireHalfSub_log=new G4LogicalVolume(fieldWireHalfSub_tube,Al,osnameFieldWireHalfSubLogical.str(),0,0,0);
01133         std::ostringstream osnameFieldWireHalfSubPhys;
01134         osnameFieldWireHalfSubPhys<<"physical"<< "AxialLayer"<<i<<"FieldWireHalfSub";
01135         G4VPhysicalVolume* fieldWireHalfSub_phys;
01136         fieldWireHalfSub_phys=new G4PVPlacement(0,0,fieldWireHalfSub_log,
01137                                                 osnameFieldWireHalfSubPhys.str(),fieldWireHalf_log,false,0);
01138         
01139         std::ostringstream osnameSignalWireSolid;
01140         osnameSignalWireSolid<<"solid"<< "AxialLayer"<<i<<"SignalWire";
01141         G4Tubs* signalWire_tube=new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,length,0.,360*deg);
01142         std::ostringstream osnameSignalWireLogical;
01143         osnameSignalWireLogical<<"logical"<< "AxialLayer"<<i<<"SignalWire";
01144         G4LogicalVolume* signalWire_log=new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
01145         
01146         std::ostringstream osnameSignalWireSubSolid;
01147         osnameSignalWireSubSolid<<"solid"<< "AxialLayer"<<i<<"SignalWireSub";
01148         G4Tubs* signalWireSub_tube=new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,length,0.,360*deg);
01149         std::ostringstream osnameSignalWireSubLogical;
01150         osnameSignalWireSubLogical<<"logical"<< "AxialLayer"<<i<<"SignalWireSub";
01151         G4LogicalVolume* signalWireSub_log=new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
01152         std::ostringstream osnameSignalWireSubPhys;
01153         osnameSignalWireSubPhys<<"physical"<< "AxialLayer"<<i<<"SignalWireSub";
01154         G4VPhysicalVolume* signalWireSub_phys;
01155         signalWireSub_phys=new G4PVPlacement(0,0,signalWireSub_log,
01156                                              osnameSignalWireSubPhys.str(),signalWire_log,false,0);
01157         
01158         //phi  <------------------->-phi 
01159         //      |F8      F5     F2|  There are 1 signal wire S4,1 full field wire F3,
01160         //      |                 |   4 half field wire F0,1,6,7 in each cell except
01161         //      |F7      S4     F1|  layer 19 , each cell have 1 more full
01162         //      |                 |  field wire F5, 2 more half field wire F2,8
01163         //      |F6      F3     F0|   
01164         //      -------------------
01165         std::ostringstream osnameFieldWire0Phys;
01166         osnameFieldWire0Phys<<"physicalAxialLayer"<<i<<"FieldWire0";
01167         posX=mdc->Layer(signalLayer-1).R()*mm;
01168         G4VPhysicalVolume* fieldWire0_phys;
01169         fieldWire0_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
01170                                           osnameFieldWire0Phys.str(),replica_log,false,0);
01171         
01172         std::ostringstream osnameFieldWire1Phys;
01173         osnameFieldWire1Phys<<"physicalAxialLayer"<<i<<"FieldWire1";
01174         posX=mdc->Layer(signalLayer).R()*mm;
01175         G4VPhysicalVolume* fieldWire1_phys;
01176         fieldWire1_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
01177                                           osnameFieldWire1Phys.str(),replica_log,false,1);
01178         
01179         if(i==19){
01180           std::ostringstream osnameFieldWire2Phys;
01181           osnameFieldWire2Phys<<"physicalAxialLayer"<<i<<"FieldWire2";
01182           posX=mdc->Layer(signalLayer+1).R()*mm;
01183           G4VPhysicalVolume* fieldWire2_phys;
01184           fieldWire2_phys=new G4PVPlacement(0,G4ThreeVector(posX,0,0),fieldWireHalf_log,
01185                                             osnameFieldWire2Phys.str(),replica_log,false,2);
01186         }
01187         
01188         std::ostringstream osnameFieldWire3Phys;
01189         osnameFieldWire3Phys<<"physicalAxialLayer"<<i<<"FieldWire3";
01190         posX=mdc->Layer(signalLayer-1).R()*mm*cos(spanAngle/2.);
01191         posY=mdc->Layer(signalLayer-1).R()*mm*sin(spanAngle/2.);
01192         G4VPhysicalVolume* fieldWire3_phys;
01193         fieldWire3_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
01194                                           osnameFieldWire3Phys.str(),replica_log,false,3);
01195         
01196         std::ostringstream osnameSignalWirePhys;
01197         osnameSignalWirePhys<<"physicalAxialLayer"<<i<<"SignalWire4";
01198         posX=mdc->Layer(signalLayer).R()*mm*cos(spanAngle/2.);
01199         posY=mdc->Layer(signalLayer).R()*mm*sin(spanAngle/2.);
01200         G4VPhysicalVolume* signalWire_phys;
01201         signalWire_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),signalWire_log,
01202                                           osnameSignalWirePhys.str(),replica_log,false,4);
01203         
01204         if(i==19){
01205           std::ostringstream osnameFieldWire5Phys;
01206           osnameFieldWire5Phys<<"physicalAxialLayer"<<i<<"FieldWire5";
01207           posX=mdc->Layer(signalLayer+1).R()*mm*cos(spanAngle/2.);
01208           posY=mdc->Layer(signalLayer+1).R()*mm*sin(spanAngle/2.);
01209           G4VPhysicalVolume* fieldWire5_phys;
01210           fieldWire5_phys=new G4PVPlacement(0,G4ThreeVector(posX,posY,0),fieldWire_log,
01211                                             osnameFieldWire5Phys.str(),replica_log,false,5);
01212         }
01213         
01214         std::ostringstream osnameFieldWire6Phys;
01215         osnameFieldWire6Phys<<"physicalAxialLayer"<<i<<"FieldWire6";
01216         posX=mdc->Layer(signalLayer-1).R()*mm*cos(spanAngle);
01217         posY=mdc->Layer(signalLayer-1).R()*mm*sin(spanAngle);
01218         G4RotationMatrix* wireRot6=new G4RotationMatrix();
01219         wireRot6->rotateZ(180*deg-spanAngle);
01220         G4VPhysicalVolume* fieldWire6_phys;
01221         fieldWire6_phys=new G4PVPlacement(wireRot6,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
01222                                           osnameFieldWire6Phys.str(),replica_log,false,6);
01223         
01224         std::ostringstream osnameFieldWire7Phys;
01225         osnameFieldWire7Phys<<"physicalAxialLayer"<<i<<"FieldWire7";
01226         posX=mdc->Layer(signalLayer).R()*mm*cos(spanAngle);
01227         posY=mdc->Layer(signalLayer).R()*mm*sin(spanAngle);
01228         G4RotationMatrix* wireRot7=new G4RotationMatrix();
01229         wireRot7->rotateZ(180*deg-spanAngle);
01230         G4VPhysicalVolume* fieldWire7_phys;
01231         fieldWire7_phys=new G4PVPlacement(wireRot7,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
01232                                           osnameFieldWire7Phys.str(),replica_log,false,7);
01233         
01234         if(i==19){
01235           std::ostringstream osnameFieldWire8Phys;
01236           osnameFieldWire8Phys<<"physicalAxialLayer"<<i<<"FieldWire8";
01237           posX=mdc->Layer(signalLayer+1).R()*mm*cos(spanAngle);
01238           posY=mdc->Layer(signalLayer+1).R()*mm*sin(spanAngle);
01239           G4RotationMatrix* wireRot8=new G4RotationMatrix();
01240           wireRot8->rotateZ(180*deg-spanAngle);
01241           G4VPhysicalVolume* fieldWire8_phys;
01242           fieldWire8_phys=new G4PVPlacement(wireRot8,G4ThreeVector(posX,posY,0),fieldWireHalf_log,
01243                                             osnameFieldWire8Phys.str(),replica_log,false,8);
01244         }
01245       } 
01246       //Put cells into layer
01247       for(j=replicaNo-1;j>-1;j--){
01248         G4RotationMatrix* cellRot=new G4RotationMatrix();
01249         cellRot->rotateZ(-spanAngle*j);
01250         
01251         std::ostringstream osnameCellPhys;
01252         osnameCellPhys<<"physical"<< "MdcAxialLayer"<<i<<"Cell"<<j;
01253         G4VPhysicalVolume* replica_phys;
01254         replica_phys=new G4PVPlacement(cellRot,0,replica_log,
01255                                        osnameCellPhys.str(),axialLayer_log,false,j);
01256       }  
01257     }  
01258 
01259     //----Stereo layers 1-8
01260     for(i=7; i>-1; i--){
01261       signalLayer=mdc->Signal2Global(i);
01262 
01263       innerR=mdc->Layer(signalLayer-1).R()*mm-fieldWireR;
01264       outR=mdc->Layer(signalLayer+1).R()*mm-fieldWireR;
01265       if(i==7)outR=mdc->Layer(signalLayer+1).R()*mm+fieldWireR;
01266 
01267       innerLength=(mdc->Layer(signalLayer-1).Length())/2.*mm;
01268       outLength=(mdc->Layer(signalLayer+1).Length())/2.*mm;
01269 
01270       innerTwistAngle=mdc->Layer(signalLayer-1).RotateAngle()*rad;
01271       outTwistAngle=mdc->Layer(signalLayer+1).RotateAngle()*rad;
01272 
01273       innerTan=innerR/innerLength*sin(innerTwistAngle);
01274                 
01275       midInnerR=innerR*cos(innerTwistAngle);
01276       innerStereo=atan(innerTan);
01277 
01278       outTan=outR/outLength*sin(outTwistAngle);
01279       outTwistAngleFixed=atan(innerLength/outLength*tan(outTwistAngle));
01280  
01281       if(abs(outTwistAngleFixed) >= abs(innerTwistAngle)){
01282         midOutR=outR*cos(outTwistAngle);
01283         outRFixed=midOutR/cos(innerTwistAngle);
01284         outR=outRFixed;
01285 
01286         outTanFixed=midOutR/innerLength*tan(innerTwistAngle);
01287         outStereo=atan(outTanFixed);
01288       }else{
01289         outRFixed=sqrt(outR*outR+(innerLength*innerLength-outLength*outLength)*outTan*outTan);
01290         outR=outRFixed;
01291         midOutR=outR*cos(innerTwistAngle);
01292 
01293         outTanFixed=outRFixed/innerLength*sin(innerTwistAngle);
01294         outStereo=atan(outTanFixed);
01295       }
01296 
01297       //Layer
01298       std::ostringstream osnameLayerSolid;
01299       osnameLayerSolid <<"solid"<< "MdcStereoLayer"<<i;  
01300 
01301       G4Hype* stereoLayer_hype=new G4Hype(osnameLayerSolid.str(),midInnerR, midOutR,innerStereo,
01302                                           outStereo,innerLength);
01303       std::ostringstream osnameLayerLogical;
01304       osnameLayerLogical <<"logical"<< "MdcStereoLayer"<<i;
01305       G4LogicalVolume* stereoLayer_log=new G4LogicalVolume(stereoLayer_hype,MdcGas,
01306                                                            osnameLayerLogical.str(),0,0,0);
01307       stereoLayer_log->SetVisAttributes(G4VisAttributes::Invisible);
01308 
01309       replicaNo=mdc->Layer(signalLayer).WireNo()/2;
01310       spanAngle=360./replicaNo*deg;
01311       firstWire=mdc->Layer(signalLayer).FirstWire();
01312 
01313       G4RotationMatrix* layerRot=new G4RotationMatrix();
01314       layerRot->rotateZ(-(spanAngle*(1-firstWire)/2.+innerTwistAngle));
01315 
01316       std::ostringstream osnameLayerPhys;
01317       osnameLayerPhys<<"physical"<< "MdcStereoLayer"<<i;
01318 
01319       G4VPhysicalVolume* stereoLayer_phys;
01320       stereoLayer_phys=new G4PVPlacement(layerRot,0,stereoLayer_log,osnameLayerPhys.str(),
01321                                          mdc_log,false,i);
01322 
01323       //Cell
01324       std::ostringstream osnameCellSolid;
01325       osnameCellSolid<<"solid"<< "MdcStereoLayer"<<i<<"Cell";
01326 
01327       G4TwistedTubs* twistTub=new G4TwistedTubs(osnameCellSolid.str(), -innerTwistAngle*2, innerR,outR-1.0*micrometer,innerLength,spanAngle);
01328       
01329      std::ostringstream osnameCellLogical;
01330      osnameCellLogical<<"logical"<< "MdcStereoLayer"<<i<<"Cell";
01331       G4LogicalVolume* twistTub_log=new G4LogicalVolume(twistTub, MdcGas,osnameCellLogical.str(),0,0,0);
01332       
01333       twistTub_log->SetVisAttributes(G4VisAttributes::Invisible);
01334       twistTub_log->SetSensitiveDetector( aTrackerSD );
01335       //       twistTub_log->SetUserLimits(new G4UserLimits(maxStep));       
01336       //Wire
01337       if(ReadBoostRoot::GetMdc()==1){
01338         std::ostringstream osnameFieldWireSolid;
01339         osnameFieldWireSolid<<"solid"<< "StereoLayer"<<i<<"FieldWire";
01340         G4Tubs* fieldWire_tube=new G4Tubs(osnameFieldWireSolid.str(),0.,fieldWireR,innerLength,0.,360*deg);
01341         std::ostringstream osnameFieldWireLogical;
01342         osnameFieldWireLogical<<"logical"<< "StereoLayer"<<i<<"FieldWire";
01343         G4LogicalVolume* fieldWire_log=new G4LogicalVolume(fieldWire_tube,Au,osnameFieldWireLogical.str(),0,0,0);
01344         
01345         std::ostringstream osnameFieldWireSubSolid;
01346         osnameFieldWireSubSolid<<"solid"<< "StereoLayer"<<i<<"FieldWireSub";
01347         G4Tubs* fieldWireSub_tube=new G4Tubs(osnameFieldWireSubSolid.str(),0.,fieldWireR-thickOfAu,innerLength,0.,360*deg);
01348         std::ostringstream osnameFieldWireSubLogical;
01349         osnameFieldWireSubLogical<<"logical"<< "StereoLayer"<<i<<"FieldWireSub";
01350         G4LogicalVolume* fieldWireSub_log=new G4LogicalVolume(fieldWireSub_tube,Al,osnameFieldWireSubLogical.str(),0,0,0);
01351         std::ostringstream osnameFieldWireSubPhys;
01352         osnameFieldWireSubPhys<<"physical"<< "StereoLayer"<<i<<"FieldWireSub";
01353         G4VPhysicalVolume* fieldWireSub_phys;
01354         fieldWireSub_phys=new G4PVPlacement(0,0,fieldWireSub_log,
01355                                             osnameFieldWireSubPhys.str(),fieldWire_log,false,0);
01356         
01357         
01358         std::ostringstream osnameSignalWireSolid;
01359         osnameSignalWireSolid<<"solid"<< "StereoLayer"<<i<<"SignalWire";
01360         G4Tubs* signalWire_tube=new G4Tubs(osnameSignalWireSolid.str(),0.,signalWireR,innerLength,0.,360*deg);
01361         std::ostringstream osnameSignalWireLogical;
01362         osnameSignalWireLogical<<"logical"<< "StereoLayer"<<i<<"SignalWire";
01363         G4LogicalVolume* signalWire_log=new G4LogicalVolume(signalWire_tube,Au,osnameSignalWireLogical.str(),0,0,0);
01364         
01365         std::ostringstream osnameSignalWireSubSolid;
01366         osnameSignalWireSubSolid<<"solid"<< "StereoLayer"<<i<<"SignalWireSub";
01367         G4Tubs* signalWireSub_tube=new G4Tubs(osnameSignalWireSubSolid.str(),0.,signalWireR-thickOfAu,innerLength,0.,360*deg);
01368         std::ostringstream osnameSignalWireSubLogical;
01369         osnameSignalWireSubLogical<<"logical"<< "StereoLayer"<<i<<"SignalWireSub";
01370         G4LogicalVolume* signalWireSub_log=new G4LogicalVolume(signalWireSub_tube,W,osnameSignalWireSubLogical.str(),0,0,0);
01371         std::ostringstream osnameSignalWireSubPhys;
01372         osnameSignalWireSubPhys<<"physical"<< "StereoLayer"<<i<<"SignalWireSub";
01373         G4VPhysicalVolume* signalWireSub_phys;
01374         signalWireSub_phys=new G4PVPlacement(0,0,signalWireSub_log,
01375                                              osnameSignalWireSubPhys.str(),signalWire_log,false,0);
01376         
01377         //phi  <------------------->-phi 
01378         //      |      F5     F2|  There are 1 signal wire S4,3 full field  
01379         //      |               |  wire F0,1,3 in each cell except layer 7 , 
01380         //      |      S4     F1|  2 more full field wire F2,5.
01381         //      |               |  In stereo cell we can't put half wire at edge because of
01382         //      |      F3     F0|  overlap, so all wires are full wire,Positon of field   
01383         //      ----------------|  wire is not at cell edge but move into cell avoid overlap
01384         G4double shiftR,midR,eastX,eastY,westX,westY;
01385         shiftR=fieldWireR+1*micrometer;
01386         midR=mdc->Layer(signalLayer).R()*mm;
01387         
01388         std::ostringstream osnameFieldWire0Phys;
01389         osnameFieldWire0Phys<<"physicalStereoLayer"<<i<<"FieldWire0";
01390         
01391         eastX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
01392         eastY=(innerR+shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
01393         westX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
01394         westY=(innerR+shiftR/cos(innerTwistAngle))*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
01395         
01396         G4ThreeVector east0(eastX,eastY,innerLength);
01397         G4ThreeVector west0(westX,westY,-innerLength);
01398         east0.rotateZ(-spanAngle/2.);
01399         west0.rotateZ(-spanAngle/2.);
01400         
01401         posX=(east0.x()+west0.x())/2.;
01402         posY=(east0.y()+west0.y())/2.;
01403         G4ThreeVector line0=east0-west0;
01404         G4RotationMatrix* wireRot0=new G4RotationMatrix();
01405         wireRot0->rotateZ(-line0.phi());
01406         wireRot0->rotateY(-line0.theta());      
01407         G4VPhysicalVolume* fieldWire0_phys;
01408         fieldWire0_phys=new G4PVPlacement(wireRot0,G4ThreeVector(posX,posY,0),fieldWire_log,
01409                                           osnameFieldWire0Phys.str(),twistTub_log,false,0);
01410         
01411         std::ostringstream osnameFieldWire1Phys;
01412         osnameFieldWire1Phys<<"physicalStereoLayer"<<i<<"FieldWire1";
01413         eastX=midR*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
01414         eastY=midR*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
01415         westX=midR*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
01416         westY=midR*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
01417         G4ThreeVector east1(eastX,eastY,innerLength);
01418         G4ThreeVector west1(westX,westY,-innerLength);
01419         east1.rotateZ(-spanAngle/2.);
01420         west1.rotateZ(-spanAngle/2.);
01421         posX=(east1.x()+west1.x())/2.;
01422         posY=(east1.y()+west1.y())/2.;
01423         G4ThreeVector line1=east1-west1;
01424         G4RotationMatrix* wireRot1=new G4RotationMatrix();
01425         wireRot1->rotateZ(-line1.phi());
01426         wireRot1->rotateY(-line1.theta());      
01427         G4VPhysicalVolume* fieldWire1_phys;
01428         fieldWire1_phys=new G4PVPlacement(wireRot1,G4ThreeVector(posX,posY,0),fieldWire_log,
01429                                           osnameFieldWire1Phys.str(),twistTub_log,false,1);
01430         
01431         std::ostringstream osnameFieldWire3Phys;
01432         osnameFieldWire3Phys<<"physicalStereoLayer"<<i<<"FieldWire3";
01433         
01434         eastX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
01435         eastY=(innerR+shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle);
01436         westX=(innerR+shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
01437         westY=(innerR+shiftR/cos(innerTwistAngle))*sin(innerTwistAngle);
01438         
01439         G4ThreeVector east3(eastX,eastY,innerLength);
01440         G4ThreeVector west3(westX,westY,-innerLength);
01441         
01442         posX=(east3.x()+west3.x())/2.;
01443         posY=(east3.y()+west3.y())/2.;
01444         G4ThreeVector line3=east3-west3;
01445         G4RotationMatrix* wireRot3=new G4RotationMatrix();
01446         wireRot3->rotateZ(-line3.phi());
01447         wireRot3->rotateY(-line3.theta());      
01448         G4VPhysicalVolume* fieldWire3_phys;
01449         fieldWire3_phys=new G4PVPlacement(wireRot3,G4ThreeVector(posX,posY,0),fieldWire_log,
01450                                           osnameFieldWire3Phys.str(),twistTub_log,false,3);
01451         
01452         std::ostringstream osnameSignalWire4Phys;
01453         osnameSignalWire4Phys<<"physicalStereoLayer"<<i<<"SignalWire4";
01454         
01455         eastX=midR*cos(innerTwistAngle);
01456         eastY=midR*sin(-innerTwistAngle);
01457         westX=midR*cos(innerTwistAngle);
01458         westY=midR*sin(innerTwistAngle);
01459         
01460         G4ThreeVector east4(eastX,eastY,innerLength);
01461         G4ThreeVector west4(westX,westY,-innerLength);
01462         
01463         posX=(east4.x()+west4.x())/2.;
01464         posY=(east4.y()+west4.y())/2.;
01465         G4ThreeVector line4=east4-west4;
01466         G4RotationMatrix* wireRot4=new G4RotationMatrix();
01467         wireRot4->rotateZ(-line4.phi());
01468         wireRot4->rotateY(-line4.theta());      
01469         G4VPhysicalVolume* signalWire4_phys;
01470         signalWire4_phys=new G4PVPlacement(wireRot4,G4ThreeVector(posX,posY,0),signalWire_log,
01471                                            osnameSignalWire4Phys.str(),twistTub_log,false,4);
01472         
01473         if(i==7){
01474           std::ostringstream osnameFieldWire2Phys;
01475           osnameFieldWire2Phys<<"physicalStereoLayer"<<i<<"FieldWire2";
01476           
01477           eastX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg-innerTwistAngle);
01478           eastY=(outR-shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle)+shiftR*sin(90*deg-innerTwistAngle);
01479           westX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle)+shiftR*cos(90*deg+innerTwistAngle);
01480           westY=(outR-shiftR/cos(innerTwistAngle))*sin(innerTwistAngle)+shiftR*sin(90*deg+innerTwistAngle);
01481           
01482           G4ThreeVector east2(eastX,eastY,innerLength);
01483           G4ThreeVector west2(westX,westY,-innerLength);
01484           east2.rotateZ(-spanAngle/2.);
01485           west2.rotateZ(-spanAngle/2.);
01486           
01487           posX=(east2.x()+west2.x())/2.;
01488           posY=(east2.y()+west2.y())/2.;
01489           G4ThreeVector line2=east2-west2;
01490           G4RotationMatrix* wireRot2=new G4RotationMatrix();
01491           wireRot2->rotateZ(-line2.phi());
01492           wireRot2->rotateY(-line2.theta());    
01493           G4VPhysicalVolume* fieldWire2_phys;
01494           fieldWire2_phys=new G4PVPlacement(wireRot2,G4ThreeVector(posX,posY,0),fieldWire_log,
01495                                             osnameFieldWire2Phys.str(),twistTub_log,false,2);
01496           
01497           std::ostringstream osnameFieldWire5Phys;
01498           osnameFieldWire5Phys<<"physicalStereoLayer"<<i<<"FieldWire5";
01499           
01500           eastX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
01501           eastY=(outR-shiftR/cos(innerTwistAngle))*sin(-innerTwistAngle);
01502           westX=(outR-shiftR/cos(innerTwistAngle))*cos(innerTwistAngle);
01503           westY=(outR-shiftR/cos(innerTwistAngle))*sin(innerTwistAngle);
01504           
01505           G4ThreeVector east5(eastX,eastY,innerLength);
01506           G4ThreeVector west5(westX,westY,-innerLength);
01507           
01508           posX=(east5.x()+west5.x())/2.;
01509           posY=(east5.y()+west5.y())/2.;
01510           G4ThreeVector line5=east5-west5;
01511           G4RotationMatrix* wireRot5=new G4RotationMatrix();
01512           wireRot5->rotateZ(-line5.phi());
01513           wireRot5->rotateY(-line5.theta());    
01514           G4VPhysicalVolume* fieldWire5_phys;
01515           fieldWire5_phys=new G4PVPlacement(wireRot5,G4ThreeVector(posX,posY,0),fieldWire_log,
01516                                             osnameFieldWire5Phys.str(),twistTub_log,false,5);
01517         }
01518       }
01519       //Put cells into layer
01520       for(j=replicaNo-1;j>-1;j--){
01521         G4RotationMatrix* cellRot=new G4RotationMatrix();
01522         cellRot->rotateZ(-spanAngle*j);
01523         
01524         std::ostringstream osnameCellPhys;
01525         osnameCellPhys<<"physical"<< "MdcStereoLayer"<<i<<"Cell"<<j;
01526         G4VPhysicalVolume* twistTub_phys;
01527         twistTub_phys=new G4PVPlacement(cellRot,0,twistTub_log,
01528                                         osnameCellPhys.str(),stereoLayer_log,false,j);
01529       }
01530     }
01531       
01532   } 
01533 }

G4LogicalVolume* BesSubdetector::FindLogicalVolume const G4String &  vn  )  [inherited]
 

G4LogicalVolume * BesSubdetector::FindLogicalVolume const G4String &  vn  )  [inline, inherited]
 

00038                                                                        {
00039   return const_cast<G4LogicalVolume*>( GDMLProcessor::GetInstance()->GetLogicalVolume(vn) );
00040 }

void BesMdcConstruction::StereoLayerConstruct G4LogicalVolume *  ,
G4int 
[private]
 

void BesMdcConstruction::StereoLayerConstruct G4LogicalVolume *  ,
G4int 
[private]
 

void BesMdcConstruction::TubeConstruct G4LogicalVolume *   )  [private]
 

void BesMdcConstruction::TubeConstruct G4LogicalVolume *   )  [private]
 


Member Data Documentation

BesMdcSD* BesMdcConstruction::aTrackerSD [private]
 

BesMdcSD* BesMdcConstruction::aTrackerSD [private]
 

G4double BesMdcConstruction::fieldWireR [private]
 

G4double BesMdcConstruction::innerR [private]
 

G4double BesMdcConstruction::length [private]
 

ProcessingConfigurator BesSubdetector::m_config [protected, inherited]
 

SAXProcessor BesSubdetector::m_sxp [protected, inherited]
 

BesMdcGeoParameter* BesMdcConstruction::mdc [private]
 

BesMdcGeoParameter* BesMdcConstruction::mdc [private]
 

G4LogicalVolume* BesMdcConstruction::mdc_log [private]
 

G4LogicalVolume* BesMdcConstruction::mdc_log [private]
 

G4VPhysicalVolume* BesMdcConstruction::mdc_phys [private]
 

G4VPhysicalVolume* BesMdcConstruction::mdc_phys [private]
 

G4double BesMdcConstruction::outR [private]
 

G4double BesMdcConstruction::posX [private]
 

G4double BesMdcConstruction::posY [private]
 

G4double BesMdcConstruction::posZ [private]
 

G4RotationMatrix* BesMdcConstruction::Rot [private]
 

G4RotationMatrix* BesMdcConstruction::Rot [private]
 

G4double BesMdcConstruction::signalWireR [private]
 

G4double BesMdcConstruction::spanAngle [private]
 

G4double BesMdcConstruction::startAngle [private]
 

G4VisAttributes* BesMdcConstruction::visAtt [private]
 

G4VisAttributes* BesMdcConstruction::visAtt [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 15:52:46 2011 for BOSS6.5.5 by  doxygen 1.3.9.1