35 int createdirc_prism(Int_t fEvType = 3,Int_t fNBars = 3, Int_t fFocusingSystem = 6, Int_t  fMcpRows= 40, Int_t iter=0, 
TString geomPath=
".", 
Double_t par1=-100, 
Double_t par2=-100, 
Double_t par3=-100, 
Double_t par4=-100, 
Double_t par5=-100, 
Double_t par6=-100, 
Double_t par7=-100, 
Double_t par8=-100, 
Double_t par9=-100){ 
 
   38     TString vmcWorkdir = getenv(
"VMCWORKDIR");
 
   41     gSystem->Load(
"libGeoBase");
 
   42     gSystem->Load(
"libParBase");
 
   43     gSystem->Load(
"libBase");
 
   44     gSystem->Load(
"libPndData");
 
   45     gSystem->Load(
"libPassive");
 
   47     TString fGeoFile= vmcWorkdir + Form(
"/geometry/dirc_e%d_b%d_l%d_m%d.root",fEvType, fNBars, fFocusingSystem,fMcpRows);
 
   48     if(iter!=0) fGeoFile= geomPath + Form(
"/dirc_%d.root",iter);
 
   60     Int_t mcpRows = (fMcpRows==40)? 4 : fMcpRows;
 
   66     const Int_t NpixTotal       = Npix*Npix; 
 
   72     Double_t hgap               = 0.5*(MCPsize - MCPactiveArea + MCPgap); 
 
   73     Double_t step               = MCPactiveArea + 2.*hgap; 
 
   81     if(fNBars==5) barwidth      =  3.2;
 
   82     if(fNBars==4) barwidth      =  4;
 
   83     if(fNBars==2) barwidth      =  8;
 
   84     if(fNBars==1) barwidth      =  16;
 
   85     std::cout<<
"barwidth  "<<barwidth <<std::endl;
 
   92     Double_t dphi               = (180.-2.*pipehAngle)/bbnum*2.;
 
   97     Double_t bbox_hlen          =  0.5*(bbox_zdown - bbox_zup);           
 
   98     Double_t bbox_shift         =  bbox_zup + bbox_hlen; 
 
  110     Double_t sob_shift          =  -bbox_hlen + bbox_shift - sob_len; 
 
  112     if(fEvType==2) sob_angleB = 90;
 
  114     if(fEvType<3) EVdrop += boxgap+boxthick;
 
  118     Double_t bbSideGap          =  0.5*( ((barwidth+2.*barhgap)*fNBars) - (2.*radius*
sin((dphi-bbGapAngle)/180.*
pi/2.)+2.*barhgap) );
 
  119     Double_t bbX                =  2.*radius*
sin((dphi-bbGapAngle)/180.*
pi/2.)+2.*barhgap;  
 
  121     Double_t barBoxWidth =  0.5*fNBars*(barwidth+2.*barhgap)+bbSideGap+boxthick;
 
  122     Double_t barBoxHeight = hthick+boxgap+boxthick;
 
  124     Double_t sob_angle          =  atan((5*step + 2*hgap-2*hthick -EVoffset-EVdrop)/sob_len)/
pi*180.;
 
  125     Double_t sob_Rout           =  radius-hthick + 5*step -2*hgap-EVdrop; 
 
  127     Double_t radiusCornerIn     = (radius-hthick-EVdrop)/
cos(dphi/2./180.*
pi);
 
  128     Double_t radiusCornerOut    = sob_Rout/
cos(dphi_rad/2.);
 
  129     Double_t radiusMiddleSmall  = radius-hthick-EVdrop;
 
  132     Double_t mirrorAngle = (par8==-100)? 0 : par8; 
 
  137     cout<<
"sob_Rout = "<<sob_Rout<<endl;
 
  149     Double_t pheight     =  2.*phlength * tan(pangle/180.*
pi);  
 
  150     Double_t sob_Rprism    =  radius + hthick + poffset + pheight + EVoffset + (sob_len-2.*phlength)*tan(60./180.*
pi);  
 
  157     TFile* 
fi = 
new TFile(fGeoFile,
"RECREATE");
 
  158     cout<<
"Output file = "<<fGeoFile<<endl;
 
  163     Int_t nel, numed, nz;
 
  165     FairGeoLoader* 
geoLoad = 
new FairGeoLoader(
"TGeo",
"FairGeoLoader");
 
  166     FairGeoInterface *
geoFace = geoLoad->getGeoInterface();
 
  167     geoFace->setMediaFile(vmcWorkdir +
"/geometry/media_pnd.geo");
 
  168     geoFace->readMedia();
 
  170     FairGeoMedia *
Media =  geoFace->getMedia();
 
  171     FairGeoBuilder *
geobuild=geoLoad->getGeoBuilder();
 
  173     FairGeoMedium *DrcAir               = Media->getMedium(
"air");
 
  174     FairGeoMedium *DrcAirNoSens   = Media->getMedium(
"DIRCairNoSens");
 
  175     FairGeoMedium *DrcEpotek301_2 = Media->getMedium(
"Epotek301_2");
 
  176     FairGeoMedium *DrcOpticalGrease    = Media->getMedium(
"OpticalGrease");
 
  177     FairGeoMedium *DrcCarbonFiber = Media->getMedium(
"DIRCcarbonFiber");
 
  178     FairGeoMedium *DrcFusedSil    = Media->getMedium(
"FusedSil");
 
  179     FairGeoMedium *DrcMirror      = Media->getMedium(
"Mirror");
 
  180     FairGeoMedium *DrcAluminum      = Media->getMedium(
"Aluminum");
 
  181     FairGeoMedium *DrcMarcol82_7  = Media->getMedium(
"Marcol82_7");
 
  182     FairGeoMedium *DrcNLAK33A     = Media->getMedium(
"NLAK33A");
 
  183     FairGeoMedium *DrcBK7G18      = Media->getMedium(
"BK7G18");
 
  184     FairGeoMedium *DrcPBF2        = Media->getMedium(
"PBF2");
 
  185     FairGeoMedium *DrcPhotocathode= Media->getMedium(
"Photocathode");  
 
  187     Int_t 
nmed=geobuild->createMedium(DrcAir);
 
  188     nmed=geobuild->createMedium(DrcAirNoSens);
 
  189     nmed=geobuild->createMedium(DrcEpotek301_2);
 
  190     nmed=geobuild->createMedium(DrcOpticalGrease);
 
  191     nmed=geobuild->createMedium(DrcCarbonFiber);
 
  192     nmed=geobuild->createMedium(DrcFusedSil);
 
  193     nmed=geobuild->createMedium(DrcMirror);
 
  194     nmed=geobuild->createMedium(DrcAluminum);
 
  195     nmed=geobuild->createMedium(DrcMarcol82_7);
 
  196     nmed=geobuild->createMedium(DrcNLAK33A);
 
  197     nmed=geobuild->createMedium(DrcBK7G18);
 
  198     nmed=geobuild->createMedium(DrcPBF2);
 
  199     nmed=geobuild->createMedium(DrcPhotocathode);
 
  203   TGeoVolume *CylLensWide1, *CylLensWide2, *Lens1, *Lens2, *Lens3, *Lens4;
 
  204   Double_t halfshift = 0, halfheight = 0.5*entranceh;
 
  206     if(fFocusingSystem == 0){  
 
  209     if(fFocusingSystem == 1){ 
 
  216       cr1=
sqrt(lenspw*lenspw/4.+cr1*cr1);
 
  218       len=2*min+r1-
sqrt(r1*r1-cr1*cr1);
 
  219       std::cout<<
"thicknes of the lens:  "<< len  <<std::endl;
 
  222       TGeoSphere* lsr1 = 
new TGeoSphere(
"sr1",0 ,r1, 0. ,180.,0.,360.);
 
  223       TGeoEltu*   lcr1 = 
new TGeoEltu(
"cr1", cr1, cr1, 0.5*len);
 
  225       TGeoBBox* lBoxB = 
new TGeoBBox(
"BoxB", 0.5*lenspw-barhgap, 0.5*entranceh, 0.5*len);
 
  226       TGeoBBox* lBoxS = 
new TGeoBBox(
"BoxS", 0.5*lenspw, cr1, 0.5*len);
 
  227       TGeoBBox* lBoxH = 
new TGeoBBox(
"BoxH", 0.5*lenspw-barhgap, 0.5*entranceh+10, 10);
 
  228       TGeoBBox* lBoxW = 
new TGeoBBox(
"BoxW", 0.5*lenspw+10, 0.5*entranceh, 10);
 
  229       TGeoBBox* lBoxA = 
new TGeoBBox(
"BoxA", 0.5*lenspw+10, 0.5*entranceh+10,0.5*len);
 
  231       TGeoTranslation tr1(
"tr1", 0., 0.,r1+0.5*len-(r1-
sqrt(r1*r1-cr1*cr1)+min));
 
  232       TGeoRotation rt1(
"rot",90., 90. ,0. );
 
  233       TGeoHMatrix *tm1 = 
new TGeoHMatrix(tr1*rt1);
 
  235       tm1->RegisterYourself();
 
  237       TGeoCompositeShape *cslens1 = 
new TGeoCompositeShape(
"cslens1",
"cr1*(sr1:tm1)*BoxH*BoxW");
 
  238       TGeoVolume *Lens1 = 
new TGeoVolume(
"DrcLENS1Sensor",cslens1, 
gGeoManager->GetMedium(
"FusedSil"));
 
  239       Lens1->SetLineColor(kBlue);
 
  242       TGeoTranslation tr3(
"tr3", 0., 0.,-min);
 
  243       TGeoHMatrix *tm3 = 
new TGeoHMatrix(tr3);
 
  245       tm3->RegisterYourself();
 
  247       TGeoCompositeShape *cslens3 = 
new TGeoCompositeShape(
"cslens2",
"(BoxA:tm3)*BoxB-(sr1:tm1)");
 
  248       TGeoVolume *Lens2 = 
new TGeoVolume(
"DrcLENS2Sensor",cslens3, 
gGeoManager->GetMedium(
"DIRCairNoSens"));
 
  249       Lens2->SetLineColor(kBlue+2);      
 
  252     if(fFocusingSystem == 2){ 
 
  259       cr1=
sqrt(lenspw*lenspw/4.+cr1*cr1);
 
  261       len=2*min+r1-
sqrt(r1*r1-cr1*cr1);
 
  262       std::cout<<
"thicknes of the lens:  "<< len  <<std::endl;
 
  265       TGeoSphere* lsr1 = 
new TGeoSphere(
"sr1",0 ,r1, 0. ,180.,0.,360.);
 
  266       TGeoEltu*   lcr1 = 
new TGeoEltu(
"cr1", cr1, cr1, 0.5*len);
 
  268       TGeoBBox* lBoxB = 
new TGeoBBox(
"BoxB", 0.5*lenspw-barhgap, 0.5*entranceh, 0.5*len);
 
  269       TGeoBBox* lBoxS = 
new TGeoBBox(
"BoxS", 0.5*lenspw, cr1, 0.5*len);
 
  270       TGeoBBox* lBoxH = 
new TGeoBBox(
"BoxH", 0.5*lenspw-barhgap, 0.5*entranceh+10, 10);
 
  271       TGeoBBox* lBoxW = 
new TGeoBBox(
"BoxW", 0.5*lenspw+10, 0.5*entranceh, 10);
 
  272       TGeoBBox* lBoxA = 
new TGeoBBox(
"BoxA", 0.5*lenspw+10, 0.5*entranceh+10,0.5*len);
 
  274       TGeoTranslation tr1(
"tr1", 0., 0.,r1+0.5*len-(r1-
sqrt(r1*r1-cr1*cr1)+min));
 
  275       TGeoRotation rt1(
"rot",90., 90. ,0. );
 
  276       TGeoHMatrix *tm1 = 
new TGeoHMatrix(tr1*rt1);
 
  278       tm1->RegisterYourself();
 
  280       TGeoCompositeShape *cslens1 = 
new TGeoCompositeShape(
"cslens1",
"cr1*(sr1:tm1)*BoxH*BoxW");
 
  281       TGeoVolume *Lens1 = 
new TGeoVolume(
"DrcLENS1Sensor",cslens1, 
gGeoManager->GetMedium(
"NLAK33A"));
 
  282       Lens1->SetLineColor(kBlue);
 
  285       TGeoTranslation tr3(
"tr3", 0., 0.,-min);
 
  286       TGeoHMatrix *tm3 = 
new TGeoHMatrix(tr3);
 
  288       tm3->RegisterYourself();
 
  290       TGeoCompositeShape *cslens3 = 
new TGeoCompositeShape(
"cslens2",
"(BoxA:tm3)*BoxB-(sr1:tm1)");
 
  291       TGeoVolume *Lens2 = 
new TGeoVolume(
"DrcLENS2Sensor",cslens3, 
gGeoManager->GetMedium(
"FusedSil"));
 
  292       Lens2->SetLineColor(kBlue+2);      
 
  295     if(fFocusingSystem == 3){ 
 
  297       if(fFocusingSystem == 35) {
 
  309       TGeoEltu* lCylinder = 
new TGeoEltu(
"Cyl", rlens, rlens, llens+1);
 
  310       TGeoBBox* lCylBox = 
new TGeoBBox(
"LensBox", llens, halfheight, 0.5*len);
 
  311       TGeoTranslation 
t1(
"trans", 0., halfshift, rlens+hlens2-0.5*len);
 
  312       TGeoRotation 
r1(
"rot",90., 90. ,0. );
 
  313       TGeoHMatrix 
tr = t1*
r1;
 
  314       TGeoHMatrix *transf = 
new TGeoHMatrix(tr);
 
  315       transf->SetName(
"transf");
 
  316       transf->RegisterYourself();
 
  317       TGeoCompositeShape *cslens1 = 
new TGeoCompositeShape(
"cslens1",
"Cyl:transf * LensBox");
 
  318       Lens1 = 
new TGeoVolume(
"DrcLENS1Sensor", cslens1, 
gGeoManager->GetMedium(
"NLAK33A"));
 
  319       Lens1->SetLineColor(kBlue+2);
 
  320       Lens1->SetTransparency(40);
 
  322       fdz_lens1 = -bbox_hlen - barWin_hthick; 
 
  325       TGeoTranslation 
t2(
"trans", 0., halfshift, rlens+hlens2-0.5*len);
 
  326       TGeoHMatrix tr2 = t2*
r1;
 
  327       TGeoHMatrix *transf2 = 
new TGeoHMatrix(tr2);
 
  328       transf2->SetName(
"transf2");
 
  329       transf2->RegisterYourself();
 
  331       TGeoCompositeShape *cslens2 = 
new TGeoCompositeShape(
"cslens2", 
"LensBox - Cyl:transf2");
 
  332       Lens2 = 
new TGeoVolume(
"DrcLENS2Sensor", cslens2, 
gGeoManager->GetMedium(
"FusedSil"));
 
  333       Lens2->SetLineColor(kBlue+2);
 
  334       Lens2->SetTransparency(40);
 
  338     if(fFocusingSystem == 4){ 
 
  349       if(fNBars==3 || fNBars==4){
 
  365       r2 = (par2==-100)? r2: par2;
 
  369       len=2*min+r2-
sqrt(r2*r2-cr1*cr1)+
min;
 
  370       std::cout<<
"thicknes of the lens:  "<< len  <<std::endl;
 
  373       TGeoEltu* lsr1 = 
new TGeoEltu(
"sr1",r1, r1, lenspw);
 
  374       TGeoEltu* lsr2 = 
new TGeoEltu(
"sr2",r2, r2, lenspw);
 
  376       TGeoBBox* lBoxB = 
new TGeoBBox(
"BoxB", 0.5*lenspw-barhgap, 0.5*entranceh, 0.5*len);
 
  377       TGeoBBox* lBoxH = 
new TGeoBBox(
"BoxH", 0.5*lenspw-barhgap, 0.5*entranceh+10, 0.5*len);
 
  378       TGeoBBox* lBoxW = 
new TGeoBBox(
"BoxW", 0.5*lenspw+10, 0.5*entranceh, 10);
 
  380       TGeoBBox* lBoxH1 = 
new TGeoBBox(
"BoxH1", 0.5*lenspw-barhgap-0.01, 0.5*entranceh+10-0.01, 0.5*len);
 
  381       TGeoBBox* lBoxW1 = 
new TGeoBBox(
"BoxW1", 0.5*lenspw+10-0.01, 0.5*entranceh-0.01, 10);
 
  383       TGeoBBox* lBoxA = 
new TGeoBBox(
"BoxA", 0.5*lenspw+10, 0.5*entranceh+10,len);
 
  385       TGeoTranslation tr1(
"tr1", 0., 0.,r1+0.5*len-(r1-
sqrt(r1*r1-cr1*cr1)+min));
 
  386       TGeoRotation rt1(
"rot",90., 90. ,0. );
 
  387       TGeoHMatrix *tm1 = 
new TGeoHMatrix(tr1*rt1);
 
  389       tm1->RegisterYourself();
 
  391       TGeoCompositeShape *cslens1 = 
new TGeoCompositeShape(
"cslens1",
"(sr1:tm1)*BoxH*BoxW");
 
  392       TGeoVolume *Lens1 = 
new TGeoVolume(
"DrcLENS1Sensor",cslens1, 
gGeoManager->GetMedium(
"FusedSil"));
 
  393       Lens1->SetLineColor(kBlue+2);
 
  396       TGeoTranslation tr2(
"tr2", 0., 0.,r2+0.5*len-(r2-
sqrt(r2*r2-cr1*cr1)+2*min));
 
  397       TGeoHMatrix *tm2 = 
new TGeoHMatrix(tr2*rt1);
 
  399       tm2->RegisterYourself();
 
  401       TGeoCompositeShape *cslens2 = 
new TGeoCompositeShape(
"cslens2",
"(sr2:tm2)*BoxH1*BoxW1-(sr1:tm1)*BoxH*BoxW");
 
  402       TGeoVolume* Lens2 = 
new TGeoVolume(
"DrcLENS2Sensor", cslens2, 
gGeoManager->GetMedium(
"PBF2"));
 
  403       Lens2->SetLineColor(kBlue);
 
  406       TGeoTranslation tr3(
"tr3", 0., 0.,-2*min);
 
  407       TGeoHMatrix *tm3 = 
new TGeoHMatrix(tr3);
 
  409       tm3->RegisterYourself();
 
  411       TGeoCompositeShape *cslens3 = 
new TGeoCompositeShape(
"cslens3",
"(BoxA:tm3)*BoxB-(sr2:tm2)");
 
  412       TGeoVolume *Lens3 = 
new TGeoVolume(
"DrcLENS3Sensor",cslens3, 
gGeoManager->GetMedium(
"FusedSil"));
 
  413       Lens3->SetLineColor(kBlue+2);
 
  417     if(fFocusingSystem == 6){ 
 
  428       if(fNBars==3 || fNBars==4){
 
  444       r2 = (par2==-100)? r2: par2;
 
  447       cr1=
sqrt(lenspw*lenspw/4.+cr1*cr1);
 
  449       len=2*min+r2-
sqrt(r2*r2-cr1*cr1)+
min;
 
  450       std::cout<<
"thicknes of the lens:  "<< len  <<std::endl;
 
  453       TGeoSphere* lsr1 = 
new TGeoSphere(
"sr1",0 ,r1, 0. ,180.,0.,360.);
 
  454       TGeoSphere* lsr2 = 
new TGeoSphere(
"sr2",0 ,r2, 0. ,180.,0.,360.);
 
  455       TGeoEltu*   lcr1 = 
new TGeoEltu(
"cr1", cr1, cr1, 0.5*len);
 
  457       TGeoBBox* lBoxB = 
new TGeoBBox(
"BoxB", 0.5*lenspw, 0.5*entranceh, 0.5*len);
 
  458       TGeoBBox* lBoxS = 
new TGeoBBox(
"BoxS", 0.5*lenspw, cr1, 0.5*len);
 
  459       TGeoBBox* lBoxH = 
new TGeoBBox(
"BoxH", 0.5*lenspw-barhgap, 0.5*entranceh+10, 10);
 
  460       TGeoBBox* lBoxW = 
new TGeoBBox(
"BoxW", 0.5*lenspw+10, 0.5*entranceh, 10);
 
  461       TGeoBBox* lBoxA = 
new TGeoBBox(
"BoxA", 0.5*lenspw+10, 0.5*entranceh+10,0.5*len);
 
  463       TGeoTranslation tr1(
"tr1", 0., 0.,r1+0.5*len-(r1-
sqrt(r1*r1-cr1*cr1)+min));
 
  464       TGeoRotation rt1(
"rot",90., 90. ,0. );
 
  465       TGeoHMatrix *tm1 = 
new TGeoHMatrix(tr1*rt1);
 
  467       tm1->RegisterYourself();
 
  469       TGeoCompositeShape *cslens1 = 
new TGeoCompositeShape(
"cslens1",
"cr1*(sr1:tm1)*BoxH*BoxW");
 
  470       TGeoVolume *Lens1 = 
new TGeoVolume(
"DrcLENS1Sensor",cslens1, 
gGeoManager->GetMedium(
"FusedSil"));
 
  471       Lens1->SetLineColor(kBlue+2);
 
  474       TGeoTranslation tr2(
"tr2", 0., 0.,r2+0.5*len-(r2-
sqrt(r2*r2-cr1*cr1)+2*min));
 
  475       TGeoHMatrix *tm2 = 
new TGeoHMatrix(tr2*
rot1);
 
  477       tm2->RegisterYourself();
 
  479       TGeoCompositeShape *cslens2 = 
new TGeoCompositeShape(
"cslens2",
"(((sr2:tm2)*cr1)-(sr1:tm1))*BoxH*BoxW");
 
  480       TGeoVolume* Lens2 = 
new TGeoVolume(
"DrcLENS2Sensor", cslens2, 
gGeoManager->GetMedium(
"PBF2"));
 
  481       Lens2->SetLineColor(kBlue);
 
  484       TGeoTranslation tr3(
"tr3", 0., 0.,-2*min);
 
  485       TGeoHMatrix *tm3 = 
new TGeoHMatrix(tr3);
 
  487       tm3->RegisterYourself();
 
  489       TGeoCompositeShape *cslens3 = 
new TGeoCompositeShape(
"cslens3",
"(BoxA:tm3)*BoxB-(sr2:tm2)");
 
  490       TGeoVolume *Lens3 = 
new TGeoVolume(
"DrcLENS3Sensor",cslens3, 
gGeoManager->GetMedium(
"FusedSil"));
 
  491       Lens3->SetLineColor(kBlue+2);
 
  495     if(fFocusingSystem == 15){ 
 
  503       lenm =  (hlens1+hlens2)/2.;     
 
  506       TGeoSphere* lSphUp = 
new TGeoSphere(
"SphUp",0 ,rlens, 0. ,180.,0.,360.);
 
  507       TGeoBBox* lCylBox = 
new TGeoBBox(
"LensBox", llens, halfheight, lenm);
 
  509       TGeoTranslation t1m(
"transm", 0., halfshift, -rlens-hlens2+lenm);
 
  510       TGeoRotation 
r1(
"rot",90., 90. ,0. );
 
  511       TGeoHMatrix trm = t1m*
r1;
 
  512       TGeoHMatrix *transf = 
new TGeoHMatrix(trm);
 
  513       transf->SetName(
"transfm");
 
  514       transf->RegisterYourself();
 
  516       TGeoCompositeShape *cslens1 = 
new TGeoCompositeShape(
"cslens1",
"SphUp:transfm * LensBox");
 
  517       TGeoVolume *CylLens1 = 
new TGeoVolume(
"DrcMLSensor",cslens1, 
gGeoManager->GetMedium(
"FusedSil"));
 
  518       CylLens1->SetLineColor(kCyan-9);
 
  519       CylLens1->SetTransparency(60);
 
  521       fdz_lens1 = -bbox_hlen + 3*barWin_hthick - lenm/2. + rlens;
 
  524       TGeoTranslation t2m(
"transm", 0., halfshift, -rlens-hlens2+lenm);
 
  525       TGeoHMatrix tr2m = t2m*
r1;
 
  526       TGeoHMatrix *transf2 = 
new TGeoHMatrix(tr2m);
 
  527       transf2->SetName(
"transf2m");
 
  528       transf2->RegisterYourself();
 
  530       TGeoCompositeShape *cslens2 = 
new TGeoCompositeShape(
"cslens2", 
"LensBox - SphUp:transf2m");
 
  531       TGeoVolume* CylLens2 = 
new TGeoVolume(
"DrcML", cslens2,  
gGeoManager->GetMedium(
"Aluminum"));
 
  532       CylLens2->SetLineColor(kYellow+2);
 
  533       CylLens2->SetTransparency(40);
 
  556   TGeoManager* 
gGeoMan = (TGeoManager*)gROOT->FindObject(
"FAIRGeom");
 
  559   TGeoBBox*   lTop = 
new TGeoBBox(500,500,300);
 
  560   TGeoVolume* 
top = 
new TGeoVolumeAssembly(
"BarrelDIRCa");
 
  567   double sum = 0.5*len + barWin_hthick + EVgreaseLayer;
 
  568   double mirrorgap = 0.0;
 
  569   double mirrorblock = mirr_hthick/2.+mirrorgap/2.;
 
  570   double zzev = (sob_angleB>90)? (5*step -2*hgap)*
cos(sob_angleB*
pi/180.):0;
 
  573     shape = 
new TGeoPcon(
"BarrelDIRCShape", 0, 360., 4);
 
  574     shape->DefineSection(0, bbox_zdown+2*mirrorblock +1 , 35., 60.);
 
  575     shape->DefineSection(1, bbox_zup, 35., 60.);
 
  576     shape->DefineSection(2, bbox_zup - sob_len +20., radiusMiddleSmall-2, sob_Rout+poffset+pheight+EVoffset+1.);
 
  577     shape->DefineSection(3, bbox_zup - sob_len - 2*PDbaseLayer - 2*sum+zzev-1 , radiusMiddleSmall-2, sob_Rout+poffset+pheight+EVoffset+1.);
 
  579     shape = 
new TGeoPcon(
"BarrelDIRCShape", 0, 360., 6);
 
  580     shape->DefineSection(0, bbox_zdown+2*mirrorblock +1 , 35., 60.);
 
  581     shape->DefineSection(1, bbox_zup, 35., 60.);
 
  582     shape->DefineSection(2, bbox_zup-2.*sum, 35., 60.);
 
  583     shape->DefineSection(3, bbox_zup - 2.*sum -0.01, radiusMiddleSmall-1, sob_Rout+poffset+pheight+EVoffset+1.);   
 
  584     shape->DefineSection(4, bbox_zup - sob_len, radiusMiddleSmall-1, sob_Rout+poffset+pheight+EVoffset+1.);
 
  585     shape->DefineSection(5, bbox_zup - sob_len - 2*PDbaseLayer - 2*sum +zzev  , radiusMiddleSmall-1, sob_Rout+poffset+pheight+EVoffset+1.);
 
  587   vLocalMother  = 
new TGeoVolumeAssembly(
"BarrelDIRC");
 
  588   vSupport = 
new TGeoVolumeAssembly(
"DrcSupport");
 
  589   vBarBox = 
new TGeoVolumeAssembly(
"DrcBarBox");
 
  591   top->AddNode(vLocalMother, 0,0);
 
  594   Double_t entransewidth =0.5*len+barWin_hthick+EVgreaseLayer;
 
  595   cout<<
"entrance width = "<<entransewidth<<endl;
 
  596   double aw = bbox_hlen+entransewidth;
 
  598   TGeoBBox *lEntrance = 
new TGeoBBox(
"lEntrance", 0.5*prismWidth, 0.5*entranceh+0.01, entransewidth);
 
  599   TGeoVolume *gEntrance = 
new TGeoVolume(
"DrcEntrance", lEntrance, 
gGeoManager->GetMedium(
"DIRCairNoSens"));
 
  600   gEntrance->SetLineColor(19); 
 
  603   TGeoShape *lBarBoxCover, *lBarBoxAir;
 
  605     TGeoBBox *lBarBox1 = 
new TGeoBBox(
"lBarBox1",barBoxWidth, hthick+boxgap+boxthick, bbox_hlen);
 
  606     TGeoBBox *lBarBox2 = 
new TGeoBBox(
"lBarBox2",10, 5, 2);
 
  607     TGeoTranslation t1b(
"transb", 0., 0, bbox_hlen + 2/
cos(mirrorAngle*
pi/180.)-hthick*tan(mirrorAngle*
pi/180.));
 
  608     TGeoRotation r1b(
"rotb",0., mirrorAngle ,0. );
 
  609     TGeoHMatrix trb = t1b*r1b;
 
  610     TGeoHMatrix *transfb = 
new TGeoHMatrix(trb);
 
  611     transfb->SetName(
"transfb1");
 
  612     transfb->RegisterYourself();
 
  613     TGeoCompositeShape *lBarBoxCover = 
new TGeoCompositeShape(
"lBarBoxCover",
"lBarBox1 - lBarBox2:transfb1");
 
  615     TGeoBBox *lBarAirBox1 = 
new TGeoBBox(
"lBarAirBox1", barBoxWidth - 0.1, hthick + 0.1, bbox_hlen);
 
  616     TGeoCompositeShape *lBarBoxAir = 
new TGeoCompositeShape(
"lBarBoxAir",
"lBarAirBox1 - lBarBox2:transfb1");
 
  619     lBarBoxCover =  
new TGeoBBox(
"lBarBoxCover", barBoxWidth, hthick+boxgap+boxthick, bbox_hlen);
 
  620     lBarBoxAir = 
new TGeoBBox(
"lBarBoxAir", barBoxWidth - 0.1, hthick + 0.1, bbox_hlen);
 
  623   TGeoBBox *lSupport1 =  
new TGeoBBox(
"lSupport1", 1.5/2., 1.4/2., bbox_hlen-0.1);
 
  624   TGeoBBox *lSupport2 =  
new TGeoBBox(
"lSupport2", 0.4/2., 3.8/2., bbox_hlen-0.1);
 
  625   TGeoBBox *lSupport3 =  
new TGeoBBox(
"lSupport3", 1.5/2., 0.5/2., bbox_hlen-0.1);
 
  626   TGeoBBox *lSupport4 =  
new TGeoBBox(
"lSupport4", 0.4/2., 2.35/2.,bbox_hlen-0.1);
 
  627   TGeoBBox *lSupport5 =  
new TGeoBBox(
"lSupport5", 1.5/2., 0.5/2., bbox_hlen-0.1);
 
  630   TGeoTubeSeg *lSupportS1 = 
new TGeoTubeSeg(
"lSupportS1",supportradius-0.2,     supportradius-0.01, bbox_hlen,3.4-90,180-3.4-90);
 
  631   TGeoTubeSeg *lSupportS2 = 
new TGeoTubeSeg(
"lSupportS2",supportradius+9.0-0.4, supportradius+9.0 , bbox_hlen,3.4-90,180-3.4-90);
 
  632   TGeoRotation *rSupportS = 
new TGeoRotation(
"rSupportS",0,0,180);
 
  633   rSupportS->RegisterYourself();
 
  634   TGeoCompositeShape *lSupportS = 
new TGeoCompositeShape(
"lSupport",
"lSupportS1 + lSupportS2 + lSupportS1:rSupportS + lSupportS2:rSupportS");
 
  635   TGeoVolume *gSupport0 = 
new TGeoVolume(
"DrcBarSupportS", lSupportS, 
gGeoManager->GetMedium(
"DIRCcarbonFiber")); 
 
  637   TGeoTranslation * tSupport1 = 
new TGeoTranslation(
"tSupport1",0,lSupport1->GetDY(),0); 
 
  638   tSupport1->RegisterYourself();
 
  639   TGeoTranslation * tSupport2 = 
new TGeoTranslation(
"tSupport2",0,2*lSupport1->GetDY()+lSupport2->GetDY(),0); 
 
  640   tSupport2->RegisterYourself();
 
  641   TGeoTranslation * tSupport3 = 
new TGeoTranslation(
"tSupport3",0,2*(lSupport1->GetDY()+lSupport2->GetDY())+lSupport3->GetDY(),0); 
 
  642   tSupport3->RegisterYourself();
 
  643   TGeoTranslation * tSupport4 = 
new TGeoTranslation(
"tSupport4",0,2*(lSupport1->GetDY()+lSupport2->GetDY()+lSupport3->GetDY())+lSupport4->GetDY(),0); 
 
  644   tSupport4->RegisterYourself();
 
  645   TGeoTranslation * tSupport5 = 
new TGeoTranslation(
"tSupport5",0,2*(lSupport1->GetDY()+lSupport2->GetDY()+lSupport3->GetDY()+lSupport4->GetDY())+lSupport5->GetDY(),0); 
 
  646   tSupport5->RegisterYourself();
 
  648   TGeoCompositeShape *lSupport = 
new TGeoCompositeShape(
"lSupport",
"lSupport1:tSupport1 + lSupport2:tSupport2 + lSupport3:tSupport3 + lSupport4:tSupport4 + lSupport5:tSupport5");
 
  649   TGeoVolume *gSupport1 = 
new TGeoVolume(
"DrcBarSupport", lSupport, 
gGeoManager->GetMedium(
"DIRCcarbonFiber")); 
 
  650   gSupport1->SetLineColor(kGray);
 
  652   TGeoVolume *gBarBoxCover = 
new TGeoVolume(
"DrcBarBoxCover", lBarBoxCover,
gGeoManager->GetMedium(
"DIRCcarbonFiber")); 
 
  653   gBarBoxCover->SetLineColor(30);
 
  655   TGeoVolume *gBarBoxAir = 
new TGeoVolume(
"DrcBarBoxAir", lBarBoxAir,
gGeoManager->GetMedium(
"DIRCairNoSens")); 
 
  656   gBarBoxAir->SetLineColor(31); 
 
  657   gBarBoxCover->AddNode(gBarBoxAir, 0,0);
 
  660   TGeoBBox* lEVgrease = 
new  TGeoBBox(
"lEVgrease", 0.5*prismWidth, 0.5*entranceh, EVgreaseLayer);
 
  661   TGeoVolume* evgrease = 
new TGeoVolume(
"DrcEVgrease", lEVgrease, 
gGeoManager->GetMedium(
"OpticalGrease"));
 
  662   evgrease->SetLineColor(kTeal-7);
 
  665   TGeoBBox* lBarWin = 
new  TGeoBBox(
"lBarWin", 0.5*prismWidth, 0.5*entranceh, barWin_hthick);
 
  666   TGeoVolume* barwin = 
new TGeoVolume(
"DrcBarboxWindowSensor", lBarWin, 
gGeoManager->GetMedium(
"FusedSil"));
 
  667   barwin->SetLineColor(kBlue-4);
 
  670   TGeoBBox* lMirror  = 
new TGeoBBox(
"lMirror", barBoxWidth, barBoxHeight, mirr_hthick/2.);
 
  671   TGeoVolume *gMirror  = 
new TGeoVolume(
"DrcMirror", lMirror,  
gGeoManager->GetMedium(
"Mirror"));
 
  672   gMirror->SetLineColor(5);
 
  674   if(mirrorAngle!=0) mirrorCorr =  -0.5*mirr_hthick + 0.5*mirr_hthick/
cos(mirrorAngle*
pi/180.)-hthick*tan(mirrorAngle*
pi/180.);
 
  676   vBarBox->AddNode(gEntrance,   0, 
new TGeoCombiTrans(0, 0, bbox_zup - entransewidth, 
new TGeoRotation(0)));
 
  677   vBarBox->AddNode(gBarBoxCover, 0, 
new TGeoCombiTrans(0, 0, bbox_zdown - bbox_hlen, 
new TGeoRotation(0)));
 
  678   vBarBox->AddNode(gMirror,      0, 
new TGeoCombiTrans(0, 0, bbox_zdown + mirrorblock + mirrorCorr, 
new TGeoRotation(0)));
 
  680   if(fFocusingSystem == 3 || fFocusingSystem == 4){
 
  681     gEntrance->AddNode(Lens1, 0, 
new TGeoCombiTrans(0, 0,  barWin_hthick + EVgreaseLayer, 
new TGeoRotation(0))); 
 
  682     gEntrance->AddNode(Lens2, 0, 
new TGeoCombiTrans(0, 0,  barWin_hthick + EVgreaseLayer, 
new TGeoRotation(0)));
 
  683     if(fFocusingSystem == 4) gEntrance->AddNode(Lens3, 0, 
new TGeoCombiTrans(0, 0,  barWin_hthick + EVgreaseLayer, 
new TGeoRotation(0))); 
 
  686   if( barWin_hthick != 0) gEntrance->AddNode(barwin,       0, 
new TGeoCombiTrans(0, 0, entransewidth - len - barWin_hthick, 
new TGeoRotation(0)));
 
  687   gEntrance->AddNode(evgrease,     0, 
new TGeoCombiTrans(0, 0, entransewidth - len - 2*barWin_hthick - EVgreaseLayer, 
new TGeoRotation(0)));
 
  693   for(Int_t 
m = 0; 
m < bbnum; 
m ++){
 
  694     phi_curr = (90. - 
phi0 - dphi*
m)/180.*
pi;    
 
  695     if(
m > bbnum/2-1){ phi_curr = (90. - 
phi0 - dphi*
m - 2.*pipehAngle)/180.*
pi; }
 
  696     dx = radius * 
cos(phi_curr);
 
  697     dy = radius * 
sin(phi_curr);
 
  701       phi_currs = (90. - 
phi0 + dphi/2.- dphi*
m)/180.*
pi;    
 
  702       if(
m > bbnum/2-1){ phi_currs = (90. - 
phi0 + dphi/2. - dphi*
m - 2.*pipehAngle)/180.*
pi; }
 
  703       dxs = supportradius * 
cos(phi_currs);
 
  704       dys = supportradius * 
sin(phi_currs);
 
  705       TGeoRotation rotbboxs1;    
 
  706       rotbboxs1.RotateZ( -
phi0 + dphi/2. - 
m*dphi  -  (TMath::Floor(2.*
m/bbnum))*(2.*pipehAngle));   
 
  707       vSupport->AddNode(gSupport1,   supportid, 
new TGeoCombiTrans(dxs,dys,bbox_zdown - bbox_hlen, 
new TGeoRotation(rotbboxs1)));
 
  711     phi_currs = (90. - 
phi0 - dphi/2.- dphi*
m)/180.*
pi;    
 
  712     if(
m > bbnum/2-1){ phi_currs = (90. - 
phi0 - dphi/2. - dphi*
m - 2.*pipehAngle)/180.*
pi; }
 
  713     dxs = supportradius * 
cos(phi_currs);
 
  714     dys = supportradius * 
sin(phi_currs);
 
  716     TGeoRotation rotbbox;    
 
  717     rotbbox.RotateZ( -
phi0 - 
m*dphi - (TMath::Floor(2.*
m/bbnum))*(2.*pipehAngle));  
 
  718     TGeoRotation rotbboxs;    
 
  719     rotbboxs.RotateZ( -
phi0 - dphi/2. - 
m*dphi  -  (TMath::Floor(2.*
m/bbnum))*(2.*pipehAngle));   
 
  721     vLocalMother->AddNode(vBarBox, 
m, 
new TGeoCombiTrans(dx, dy, 0, 
new TGeoRotation(rotbbox)));
 
  722     vSupport->AddNode(gSupport1,    supportid, 
new TGeoCombiTrans(dxs,dys,bbox_zdown - bbox_hlen, 
new TGeoRotation(rotbboxs)));
 
  726   vSupport->AddNode(gSupport0, 0, 
new TGeoCombiTrans(0,0,bbox_zdown - bbox_hlen, 
new TGeoRotation(0)));
 
  727   vLocalMother->AddNode(vSupport, 0, 0);
 
  731     TGeoBBox *lBar1 = 
new TGeoBBox(
"lBar1", barwidth/2., hthick, bbox_hlen);
 
  732     TGeoBBox *lBar2 = 
new TGeoBBox(
"lBar2",10, 5, 2);
 
  733     TGeoTranslation t1b(
"transb", 0., 0, bbox_hlen + 2./
cos(mirrorAngle*
pi/180.)-hthick*tan(mirrorAngle*
pi/180.));
 
  734     TGeoRotation r1b(
"rotb",0., mirrorAngle ,0. );
 
  735     TGeoHMatrix trb = t1b*r1b;
 
  736     TGeoHMatrix *transfb = 
new TGeoHMatrix(trb);
 
  737     transfb->SetName(
"transfb");
 
  738     transfb->RegisterYourself();
 
  739     TGeoCompositeShape *lBar = 
new TGeoCompositeShape(
"lBar",
"lBar1 - lBar2:transfb");
 
  741     lBar = 
new TGeoBBox(
"lBar", barwidth/2., hthick, bbox_hlen); 
 
  744   TGeoVolume *bar = 
new TGeoVolume(
"DrcBarSensor",lBar, 
gGeoManager->GetMedium(
"FusedSil"));
 
  745   bar->SetLineColor(kCyan-9);
 
  746   bar->SetTransparency(60);
 
  749   TGeoBBox* lBarGlue  = 
new TGeoBBox(
"lBarGlue", barwidth/2., hthick, gluehthick);
 
  750   TGeoVolume *barglue  = 
new TGeoVolume(
"DrcBarGlueSensor", lBarGlue,  
gGeoManager->GetMedium(
"Epotek301_2"));
 
  751   barglue->SetLineColor(kSpring-5);
 
  752   bar->AddNode(barglue, 0, 
new TGeoCombiTrans(0., 0., 0., 
new TGeoRotation (0)));
 
  754   for(Int_t j=0; j<fNBars; j++){
 
  755     dx = - (bbX/2.) - bbSideGap + (j+0.5) * (barwidth+2.*barhgap);
 
  757     gBarBoxAir->AddNode(bar,  j, 
new TGeoCombiTrans(dx, dy,-lenm, 
new TGeoRotation(0)));
 
  759     if(fFocusingSystem == 1 || fFocusingSystem == 2 || fFocusingSystem == 6){
 
  760       gEntrance->AddNode(Lens1, j, 
new TGeoCombiTrans(dx, dy, barWin_hthick + EVgreaseLayer, 
new TGeoRotation(0)));
 
  761       gEntrance->AddNode(Lens2, j, 
new TGeoCombiTrans(dx, dy, barWin_hthick + EVgreaseLayer, 
new TGeoRotation(0)));
 
  762       if(fFocusingSystem == 6) gEntrance->AddNode(Lens3, j, 
new TGeoCombiTrans(dx, dy, barWin_hthick + EVgreaseLayer, 
new TGeoRotation(0)));
 
  765     if(fFocusingSystem == 5) { 
 
  766       gBarBoxAir->AddNode(CylLens1, j, 
new TGeoCombiTrans(dx, dy, -bbox_hlen, 
new TGeoRotation (0)));
 
  767       gBarBoxAir->AddNode(CylLens2, j, 
new TGeoCombiTrans(dx, dy, -bbox_hlen, 
new TGeoRotation (0)));
 
  773     TGeoPgon* logicEV1, * logicEV2, *logicEV3, * logicEV4; 
 
  774     TGeoPgon* logicEV1c, * logicEV2c, *logicEV3c, * logicEV4c; 
 
  775     TGeoPgon* logicEV1s, * logicEV2s, *logicEV3s, * logicEV4s;
 
  776     TGeoPgon* logicEV1b, * logicEV2b, *logicEV3b, * logicEV4b;
 
  779     Double_t dR = (radius+hthick+boxgap+boxthick)/
cos(dphi/2./180.*
pi) - (radius-hthick);
 
  785       minrad = radiusMiddleSmall,
 
  786       viscorrection =  0.000001, 
 
  787       mcptot = MCPsize + MCPgap,
 
  788       alpharad = TMath::ATan(mcptot/sob_len),
 
  789       steprad=0, stepz=0, currz = 0.;  
 
  790     Int_t totalnumbering = 0;
 
  793     TGeoVolumeAssembly *pdbase = 
new TGeoVolumeAssembly(
"DrcPDbase");
 
  797       TGeoBBox* logicPD = 
new TGeoBBox(
"logicPD", MCPactiveArea/2., MCPactiveArea/2., PDsensitiveThick/2.); 
 
  798       TGeoVolume *pixelholder  = 
new TGeoVolume(
"DrcPD", logicPD,  
gGeoManager->GetMedium(
"FusedSil"));
 
  799       pixelholder->SetLineColor(kGreen+1);
 
  802       TGeoBBox* logicCathode = 
new TGeoBBox(
"logicCathode", MCPactiveArea/2., MCPactiveArea/2., CathodeThick/2.); 
 
  803       TGeoVolume *phcathode  = 
new TGeoVolume(
"DrcCathodeSensor", logicCathode,  
gGeoManager->GetMedium(
"Photocathode"));
 
  804       phcathode->SetLineColor(kYellow+2);
 
  807       TGeoBBox* logicWindow = 
new TGeoBBox(
"logicWindow", MCPsize/2., MCPsize/2., PDwindowThick/2.); 
 
  808       TGeoVolume *window  = 
new TGeoVolume(
"DrcPDwindow", logicWindow,  
gGeoManager->GetMedium(
"FusedSil"));
 
  809       window->SetLineColor(kGreen-3);
 
  812       TGeoBBox* logicMCPgrease = 
new TGeoBBox(
"logicMCPgrease", MCPsize/2., MCPsize/2., PDgreaseLayer/2.); 
 
  813       TGeoVolume *mcpgrease  = 
new TGeoVolume(
"DrcMcpGrease", logicMCPgrease, 
gGeoManager->GetMedium(
"OpticalGrease"));
 
  814       mcpgrease->SetLineColor(kGreen);
 
  817       TGeoBBox *logicMCP = 
new TGeoBBox(
"logicMCP", MCPsize/2.+MCPgap/2., MCPsize/2.+MCPgap/2., (PDsensitiveThick+CathodeThick+PDwindowThick+PDgreaseLayer)/2.);
 
  818       TGeoVolume *oneMCP = 
new TGeoVolume(
"DrcMCP", logicMCP, 
gGeoManager->GetMedium(
"DIRCcarbonFiber"));
 
  819       oneMCP->SetLineColor(kBlue);
 
  821       oneMCP->AddNode(mcpgrease, 0, 
new TGeoCombiTrans(0, 0, (PDwindowThick+CathodeThick+PDsensitiveThick)/2., 
new TGeoRotation(0)));
 
  822       oneMCP->AddNode(window, 0, 
new TGeoCombiTrans(0, 0, (CathodeThick+PDsensitiveThick-PDgreaseLayer)/2., 
new TGeoRotation(0)));
 
  823       oneMCP->AddNode(phcathode, 0, 
new TGeoCombiTrans(0, 0, (PDsensitiveThick-PDgreaseLayer-PDwindowThick)/2., 
new TGeoRotation(0))); 
 
  824       oneMCP->AddNode(pixelholder, 0, 
new TGeoCombiTrans(0, 0, (-PDgreaseLayer-PDwindowThick-CathodeThick)/2., 
new TGeoRotation(0)));
 
  827     double btilt=(par5==-100)? 0 : par5*
pi/180.;
 
  828     double fixvisual = 0.000001;
 
  829     double coverthickness = 0.05;
 
  831       if(sob_angleB == 90.){
 
  832         logicEV1 = 
new TGeoPgon(
"logicEV1",  90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 2);
 
  833         logicEV1->DefineSection(0, 0.,      radiusMiddleSmall+sob_len*tan(btilt),  sob_Rout+sob_len*tan(btilt));
 
  834         logicEV1->DefineSection(1, sob_len, radiusMiddleSmall,  (radius+hthick+boxgap+boxthick+EVoffset));
 
  835         logicEV2 = 
new TGeoPgon(
"logicEV2", -90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 2);
 
  836         logicEV2->DefineSection(0, 0.,      radiusMiddleSmall+sob_len*tan(btilt),  sob_Rout+sob_len*tan(btilt));
 
  837         logicEV2->DefineSection(1, sob_len, radiusMiddleSmall,  (radius+hthick+boxgap+boxthick+EVoffset));
 
  838         logicEV3 = 
new TGeoPgon(
"logicEV3",  90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 2);
 
  839         logicEV3->DefineSection(0, 0.,      (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1,  (sob_Rout+sob_len*tan(btilt))*cosFactor1);
 
  840         logicEV3->DefineSection(1, sob_len, (radiusMiddleSmall)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset)*cosFactor1);     
 
  841         logicEV4 = 
new TGeoPgon(
"logicEV4", -90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 2);
 
  842         logicEV4->DefineSection(0, 0.,      (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1,  (sob_Rout+sob_len*tan(btilt))*cosFactor1);
 
  843         logicEV4->DefineSection(1, sob_len, (radiusMiddleSmall)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset)*cosFactor1);
 
  845         logicEV1c = 
new TGeoPgon(
"logicEV1c",  90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 2);
 
  846         logicEV1c->DefineSection(0, 0.,      radiusMiddleSmall+sob_len*tan(btilt)-coverthickness,  sob_Rout+sob_len*tan(btilt)+coverthickness);
 
  847         logicEV1c->DefineSection(1, sob_len, radiusMiddleSmall-coverthickness,  (radius+hthick+boxgap+boxthick+EVoffset));
 
  848         logicEV2c = 
new TGeoPgon(
"logicEV2c", -90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 2);
 
  849         logicEV2c->DefineSection(0, 0.,      radiusMiddleSmall+sob_len*tan(btilt)-coverthickness,  sob_Rout+sob_len*tan(btilt)+coverthickness);
 
  850         logicEV2c->DefineSection(1, sob_len, radiusMiddleSmall-coverthickness,  (radius+hthick+boxgap+boxthick+EVoffset)+coverthickness);
 
  851         logicEV3c = 
new TGeoPgon(
"logicEV3c",  90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 2);
 
  852         logicEV3c->DefineSection(0, 0.,      (radiusMiddleSmall+sob_len*tan(btilt)-coverthickness)*cosFactor1,  (sob_Rout+sob_len*tan(btilt)+coverthickness)*cosFactor1);
 
  853         logicEV3c->DefineSection(1, sob_len, (radiusMiddleSmall-coverthickness)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset+coverthickness)*cosFactor1);     
 
  854         logicEV4c = 
new TGeoPgon(
"logicEV4c", -90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 2);
 
  855         logicEV4c->DefineSection(0, 0.,      (radiusMiddleSmall+sob_len*tan(btilt)-coverthickness)*cosFactor1,  (sob_Rout+sob_len*tan(btilt)+coverthickness)*cosFactor1);
 
  856         logicEV4c->DefineSection(1, sob_len, (radiusMiddleSmall-coverthickness)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset+coverthickness)*cosFactor1);
 
  858       }
else if(sob_angleB < 90.){
 
  859         logicEV1 = 
new TGeoPgon(
"logicEV1",  90.+(
phi0-dphi/2.),  180.-2.*(
phi0-dphi/2.), bbnum/2, 3);
 
  860         logicEV1->DefineSection(0, 0.,      radiusMiddleSmall+sob_len*tan(btilt),  radiusMiddleSmall+sob_len*tan(btilt)+fixvisual);
 
  861         logicEV1->DefineSection(1, zEV,     radiusMiddleSmall+(sob_len-zEV)*tan(btilt),  radiusMiddleSmall+hEV+sob_len*tan(btilt));
 
  862         logicEV1->DefineSection(2, sob_len, radiusMiddleSmall,  (radius+hthick+boxgap+boxthick+EVoffset));
 
  863         logicEV2 = 
new TGeoPgon(
"logicEV2", -90.+(
phi0-dphi/2.), 180.-2.*(
phi0-dphi/2.), bbnum/2, 3);
 
  864         logicEV2->DefineSection(0, 0.,      radiusMiddleSmall+sob_len*tan(btilt),  radiusMiddleSmall+sob_len*tan(btilt)+fixvisual);
 
  865         logicEV2->DefineSection(1, zEV,     radiusMiddleSmall+(sob_len-zEV)*tan(btilt),  radiusMiddleSmall+hEV+sob_len*tan(btilt));
 
  866         logicEV2->DefineSection(2, sob_len, radiusMiddleSmall,  (radius+hthick+boxgap+boxthick+EVoffset));     
 
  867         logicEV3 = 
new TGeoPgon(
"logicEV3",  90.-(
phi0-dphi/2.),2.*(
phi0-dphi/2.), 1, 3);
 
  868         logicEV3->DefineSection(0, 0.,      (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1,  (radiusMiddleSmall+sob_len*tan(btilt)+fixvisual)*cosFactor1);
 
  869         logicEV3->DefineSection(1, zEV,     (radiusMiddleSmall+(sob_len-zEV)*tan(btilt))*cosFactor1,  (radiusMiddleSmall+hEV+sob_len*tan(btilt))*cosFactor1);
 
  870         logicEV3->DefineSection(2, sob_len, (radiusMiddleSmall)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset)*cosFactor1);     
 
  871         logicEV4 = 
new TGeoPgon(
"logicEV4", -90.-(
phi0-dphi/2.), 2.*(
phi0-dphi/2.), 1, 3);
 
  872         logicEV4->DefineSection(0, 0.,      (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1,  (radiusMiddleSmall+sob_len*tan(btilt)+fixvisual)*cosFactor1);
 
  873         logicEV4->DefineSection(1, zEV,     (radiusMiddleSmall+(sob_len-zEV)*tan(btilt))*cosFactor1,  (radiusMiddleSmall+sob_len*tan(btilt)+hEV)*cosFactor1);
 
  874         logicEV4->DefineSection(2, sob_len, (radiusMiddleSmall)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset)*cosFactor1);
 
  876         double xl = radius+hthick+boxgap+boxthick+EVoffset;
 
  877         double xh = radiusMiddleSmall+(sob_len-
fabs(zEV))*tan(btilt) + xl-radiusMiddleSmall+sob_len*((hEV-(xl-radiusMiddleSmall))/(
fabs(zEV)+sob_len));
 
  878         logicEV1 = 
new TGeoPgon(
"logicEV1",  90.+(
phi0-dphi/2.),  180.-2.*(
phi0-dphi/2.), bbnum/2, 3);
 
  879         logicEV1->DefineSection(0, zEV,     radiusMiddleSmall+hEV+sob_len*tan(btilt),  radiusMiddleSmall+hEV+sob_len*tan(btilt)+fixvisual);
 
  880         logicEV1->DefineSection(1, 0.,      radiusMiddleSmall+(sob_len)*tan(btilt),  xh);
 
  881         logicEV1->DefineSection(2, sob_len, radiusMiddleSmall,  xl);
 
  882         logicEV2 = 
new TGeoPgon(
"logicEV2", -90.+(
phi0-dphi/2.), 180.-2.*(
phi0-dphi/2.), bbnum/2, 3);
 
  883         logicEV2->DefineSection(0, zEV,     radiusMiddleSmall+hEV+sob_len*tan(btilt), radiusMiddleSmall+hEV+sob_len*tan(btilt)+fixvisual);
 
  884         logicEV2->DefineSection(1, 0.,      radiusMiddleSmall+(sob_len)*tan(btilt),xh);
 
  885         logicEV2->DefineSection(2, sob_len, radiusMiddleSmall,  xl);     
 
  886         logicEV3 = 
new TGeoPgon(
"logicEV3",  90.-(
phi0-dphi/2.),2.*(
phi0-dphi/2.), 1, 3);
 
  887         logicEV3->DefineSection(0, zEV,     (radiusMiddleSmall+hEV+sob_len*tan(btilt))*cosFactor1,  ( radiusMiddleSmall+hEV+sob_len*tan(btilt)+fixvisual)*cosFactor1);
 
  888         logicEV3->DefineSection(1, 0,       (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1,  xh*cosFactor1);
 
  889         logicEV3->DefineSection(2, sob_len, (radiusMiddleSmall)*cosFactor1,  xl*cosFactor1);     
 
  890         logicEV4 = 
new TGeoPgon(
"logicEV4", -90.-(
phi0-dphi/2.), 2.*(
phi0-dphi/2.), 1, 3);
 
  891         logicEV4->DefineSection(0, zEV,     (radiusMiddleSmall+hEV+sob_len*tan(btilt))*cosFactor1,  (radiusMiddleSmall+hEV+sob_len*tan(btilt)+fixvisual)*cosFactor1);
 
  892         logicEV4->DefineSection(1, 0,       (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1,  xh*cosFactor1);
 
  893         logicEV4->DefineSection(2, sob_len, (radiusMiddleSmall)*cosFactor1,  xl*cosFactor1);
 
  896       TGeoCompositeShape *logicEV = 
new TGeoCompositeShape(
"logicEV",
"logicEV1  + logicEV3 + logicEV2 + logicEV4 ");
 
  897       TGeoVolume* baseEV = 
new TGeoVolume(
"DrcEVSensor", logicEV, 
gGeoManager->GetMedium(
"Marcol82_7"));
 
  899       TGeoPgon *logicPDbase1, *logicPDbase2, *logicPDbase3, *logicPDbase4;
 
  901       if(sob_angleB == 90.){
 
  902         logicPDbase1 = 
new TGeoPgon(
"logicPDbase1",  90.+(
phi0-dphi/2.), 180.-2.*(
phi0-dphi/2.), bbnum/2, 2);
 
  903         logicPDbase2 = 
new TGeoPgon(
"logicPDbase2", -90.+(
phi0-dphi/2.), 180.-2.*(
phi0-dphi/2.), bbnum/2, 2);
 
  904         logicPDbase3 = 
new TGeoPgon(
"logicPDbase3",  90.-(
phi0-dphi/2.), 2.*(
phi0-dphi/2.)     ,       1, 2);
 
  905         logicPDbase4 = 
new TGeoPgon(
"logicPDbase4", -90.-(
phi0-dphi/2.), 2.*(
phi0-dphi/2.)     ,       1, 2);  
 
  906         logicPDbase1->DefineSection(0, 0.,  radiusMiddleSmall+sob_len*tan(btilt)-hgap, sob_Rout+sob_len*tan(btilt)+hgap);
 
  907         logicPDbase1->DefineSection(1, PDbaseLayer,  radiusMiddleSmall+sob_len*tan(btilt)-hgap, sob_Rout+sob_len*tan(btilt)+hgap);           
 
  908         logicPDbase2->DefineSection(0, 0.,  radiusMiddleSmall+sob_len*tan(btilt)-hgap, sob_Rout+sob_len*tan(btilt)+hgap);
 
  909         logicPDbase2->DefineSection(1, PDbaseLayer,  radiusMiddleSmall+sob_len*tan(btilt)-hgap, sob_Rout+sob_len*tan(btilt)+hgap);      
 
  910         logicPDbase3->DefineSection(0, 0., (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1-hgap, (sob_Rout+hgap+sob_len*tan(btilt))*cosFactor1);
 
  911         logicPDbase3->DefineSection(1, PDbaseLayer, (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1-hgap, (sob_Rout+hgap+sob_len*tan(btilt))*cosFactor1);
 
  912         logicPDbase4->DefineSection(0, 0., (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1-hgap, (sob_Rout+hgap+sob_len*tan(btilt))*cosFactor1);
 
  913         logicPDbase4->DefineSection(1, PDbaseLayer, (radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1-hgap, (sob_Rout+hgap+sob_len*tan(btilt))*cosFactor1);
 
  914       }
else if(sob_angleB < 90.){
 
  915         logicPDbase1 = 
new TGeoPgon(
"logicPDbase1",  90.+(
phi0-dphi/2.), 180.-2.*(
phi0-dphi/2.), bbnum/2, 4);
 
  916         logicPDbase2 = 
new TGeoPgon(
"logicPDbase2", -90.+(
phi0-dphi/2.), 180.-2.*(
phi0-dphi/2.), bbnum/2, 4);
 
  917         logicPDbase3 = 
new TGeoPgon(
"logicPDbase3",  90.-(
phi0-dphi/2.), 2.*(
phi0-dphi/2.)     ,       1, 4);
 
  918         logicPDbase4 = 
new TGeoPgon(
"logicPDbase4", -90.-(
phi0-dphi/2.), 2.*(
phi0-dphi/2.)     ,       1, 4);
 
  919         double cba = 
cos(sob_angleB*
pi/180.);
 
  920         double sba = 
sin(sob_angleB*
pi/180.);
 
  921         double addt = radiusMiddleSmall+sob_len*tan(btilt);
 
  922         logicPDbase1->DefineSection(0, PDbaseLayer-PDbaseLayer*sba -hgap/tan(sob_angleB*
pi/180.),  
 
  923                                     addt-hgap+PDbaseLayer*cba,
 
  924                                     addt-hgap+PDbaseLayer*cba+fixvisual);
 
  925         logicPDbase1->DefineSection(1, PDbaseLayer-hgap/tan(sob_angleB*
pi/180.),  
 
  927                                     addt-hgap+PDbaseLayer/cba);
 
  929         logicPDbase1->DefineSection(2, PDbaseLayer-PDbaseLayer*sba -hgap/tan(sob_angleB*
pi/180.) + zEV,
 
  930                                     addt + hEV-hgap + PDbaseLayer*cba - PDbaseLayer/cba, 
 
  931                                     addt + hEV+hgap + PDbaseLayer*
cos((90-sob_angleB*
pi/180.)));
 
  932         logicPDbase1->DefineSection(3,  PDbaseLayer+hgap/tan(sob_angleB*
pi/180.) + zEV , addt+ hEV+hgap, addt+ hEV+hgap+fixvisual);
 
  935         logicPDbase2->DefineSection(0, PDbaseLayer-PDbaseLayer*sba -hgap/tan(sob_angleB*
pi/180.),  
 
  936                                     addt-hgap+PDbaseLayer*cba,
 
  937                                     addt-hgap+PDbaseLayer*cba+fixvisual);
 
  938         logicPDbase2->DefineSection(1, PDbaseLayer-hgap/tan(sob_angleB*
pi/180.),  
 
  940                                     addt-hgap+PDbaseLayer/cba);
 
  942         logicPDbase2->DefineSection(2, PDbaseLayer-PDbaseLayer*sba -hgap/tan(sob_angleB*
pi/180.) + zEV,
 
  943                                     addt + hEV-hgap + PDbaseLayer*cba - PDbaseLayer/cba, 
 
  944                                     addt + hEV+hgap + PDbaseLayer*
cos((90-sob_angleB*
pi/180.)) );
 
  945         logicPDbase2->DefineSection(3,  PDbaseLayer+hgap/tan(sob_angleB*
pi/180.) + zEV , addt+ hEV+hgap, addt+ hEV+hgap+fixvisual);
 
  948         logicPDbase3->DefineSection(0, PDbaseLayer-PDbaseLayer*sba -hgap/tan(sob_angleB*
pi/180.),  
 
  949                                     (addt-hgap+PDbaseLayer*cba)*cosFactor1,
 
  950                                     (addt-hgap+PDbaseLayer*cba)*cosFactor1+fixvisual);
 
  951         logicPDbase3->DefineSection(1, PDbaseLayer-hgap/tan(sob_angleB*
pi/180.),  
 
  952                                     (addt-hgap)*cosFactor1, 
 
  953                                     (addt-hgap+PDbaseLayer/cba)*cosFactor1);
 
  955         logicPDbase3->DefineSection(2, PDbaseLayer-PDbaseLayer*sba -hgap/tan(sob_angleB*
pi/180.) + zEV,
 
  956                                     (addt + hEV-hgap + PDbaseLayer*cba - PDbaseLayer/cba)*cosFactor1, 
 
  957                                     (addt + hEV+hgap + PDbaseLayer*
cos((90-sob_angleB*
pi/180.)))*cosFactor1);
 
  958         logicPDbase3->DefineSection(3,  PDbaseLayer+hgap/tan(sob_angleB*
pi/180.) + zEV , 
 
  959                                     (addt+ hEV+hgap)*cosFactor1, 
 
  960                                     (addt+ hEV+hgap)*cosFactor1+fixvisual);
 
  962         logicPDbase4->DefineSection(0, PDbaseLayer-PDbaseLayer*sba -hgap/tan(sob_angleB*
pi/180.),  
 
  963                                     (addt-hgap+PDbaseLayer*cba)*cosFactor1,
 
  964                                     (addt-hgap+PDbaseLayer*cba)*cosFactor1+fixvisual);
 
  965         logicPDbase4->DefineSection(1, PDbaseLayer-hgap/tan(sob_angleB*
pi/180.),  
 
  966                                     (addt-hgap)*cosFactor1, 
 
  967                                     (addt-hgap+PDbaseLayer/cba)*cosFactor1);
 
  969         logicPDbase4->DefineSection(2, PDbaseLayer-PDbaseLayer*sba -hgap/tan(sob_angleB*
pi/180.) + zEV,
 
  970                                     (addt + hEV-hgap + PDbaseLayer*cba - PDbaseLayer/cba)*cosFactor1, 
 
  971                                     (addt + hEV+hgap + PDbaseLayer*
cos((90-sob_angleB*
pi/180.)))*cosFactor1);
 
  972         logicPDbase4->DefineSection(3,  PDbaseLayer+hgap/tan(sob_angleB*
pi/180.) + zEV , 
 
  973                                     (addt+ hEV+hgap)*cosFactor1, 
 
  974                                     (addt+ hEV+hgap)*cosFactor1+fixvisual);
 
  977       if(sob_angleB <= 90.){
 
  978         TGeoCompositeShape *logicPDbase = 
new TGeoCompositeShape(
"logicPDbase",
" logicPDbase1 + logicPDbase2+ logicPDbase3  + logicPDbase4 ");
 
  981         vLocalMother->AddNode(pdbase, 0, 
new TGeoCombiTrans(0., 0., sob_shift-2*sum-PDbaseLayer, 
new TGeoRotation(0)));
 
  984       TGeoCompositeShape *logicEVc = 
new TGeoCompositeShape(
"logicEVc",
"logicEV1c  + logicEV3c + logicEV2c + logicEV4c ");
 
  985       TGeoVolume* baseEVc = 
new TGeoVolume(
"DrcEVCoverSensor", logicEVc, 
gGeoManager->GetMedium(
"DIRCairNoSens"));
 
  987       baseEVc->AddNode(baseEV, 0, 
new TGeoCombiTrans(0.,0.,0., 
new TGeoRotation(0)));
 
  988       vLocalMother->AddNode(baseEVc, 0, 
new TGeoCombiTrans(0.,0.,sob_shift - 2*sum, 
new TGeoRotation(0)));
 
  994         Double_t pdthickness = (PDsensitiveThick+CathodeThick+PDwindowThick+PDgreaseLayer)/2.;
 
  995         for(Int_t 
m = 0; 
m < bbnum; 
m ++){       
 
  996           phi_curr1 = (90. - 
phi0 - dphi*
m)/180.*
pi;    
 
  997           if(
m > bbnum/2-1){ phi_curr1 = (90. - 
phi0 - dphi*
m - 2.*pipehAngle)/180.*
pi; } 
 
  998           if(sob_angleB != 90.){
 
  999             stepz   =  MCPactiveArea*
cos(sob_angleB*
pi/180.)/2. - pdthickness*
sin(sob_angleB*
pi/180.);
 
 1000             steprad = -MCPactiveArea*(1-
sin(sob_angleB*
pi/180.))/2. + pdthickness*
cos(sob_angleB*
pi/180.);
 
 1002             stepz = -pdthickness;
 
 1004           TGeoRotation rot_sector;  
 
 1005           rot_sector.RotateX(90-sob_angleB);        
 
 1006           rot_sector.RotateZ( -
phi0 - 
m*dphi - (TMath::Floor(2.*
m/bbnum))*(2.*pipehAngle));       
 
 1008           for(Int_t nrow=0; nrow < Int_t((sob_Rout+2*hgap-radiusMiddleSmall)/step); nrow++){
 
 1009             sectorWidth = 2.* (radiusMiddleSmall + step*nrow) * tan(dphi_rad/2.);
 
 1010             nmcp = Int_t(sectorWidth/step);
 
 1011             xpos = (radiusMiddleSmall + 0.5*MCPactiveArea + step*(nrow))+sob_len*tan(btilt);      
 
 1012             for(Int_t ny=0; ny<nmcp; ny++){
 
 1013               ypos = ((-Int_t(nmcp/2.) - 0.5*(nmcp%2))*step + (0.5+ny)*step);
 
 1014               location.SetXYZ(xpos+steprad,ypos,stepz);
 
 1015               location.RotateZ(phi_curr1);
 
 1016               if(pdbase) pdbase->AddNode(oneMCP, totalnumbering, 
new TGeoCombiTrans(location.X(), location.Y(), PDbaseLayer + location.Z(), 
new TGeoRotation(rot_sector)));
 
 1017               else vLocalMother->AddNode(oneMCP, totalnumbering, 
new TGeoCombiTrans(location.X(), location.Y(), PDbaseLayer + location.Z()+sob_shift-2*sum-PDbaseLayer, 
new TGeoRotation(rot_sector)));
 
 1018               totalnumbering = totalnumbering + 1;   
 
 1020             if(sob_angleB != 90.){
 
 1021               stepz += mcptot*
cos(sob_angleB*
pi/180.);
 
 1022               steprad += -mcptot*(1-
sin(sob_angleB*
pi/180.));
 
 1026         if(sob_angleB == 90.){
 
 1027           if(sob_angleB != 90.){
 
 1028             stepz   =  MCPactiveArea*
cos(sob_angleB*
pi/180.)/2. - pdthickness*
sin(sob_angleB*
pi/180.);
 
 1029             steprad = -MCPactiveArea*(1-
sin(sob_angleB*
pi/180.))/2. + pdthickness*
cos(sob_angleB*
pi/180.);
 
 1031           for(Int_t nrow=0; nrow < Int_t((sob_Rout+2*hgap-radiusMiddleSmall)/step); nrow++){
 
 1032             for(Int_t nadd = 0; nadd<2; nadd++){
 
 1033               TGeoRotation rot_sector;  
 
 1034               if(nadd==1) rot_sector.RotateX(270+sob_angleB);
 
 1035               else rot_sector.RotateX(90-sob_angleB);
 
 1036               xpos = ((radiusMiddleSmall+sob_len*tan(btilt))*cosFactor1 + 0.5*MCPactiveArea + step*(nrow));
 
 1037               location.SetXYZ(xpos+steprad,0.,stepz);
 
 1038               location.RotateZ(
pi/2.+
pi*nadd);
 
 1039               pdbase->AddNode(oneMCP, totalnumbering, 
new TGeoCombiTrans(location.X(), location.Y(), PDbaseLayer + location.Z(), 
new TGeoRotation(rot_sector)));
 
 1040               totalnumbering = totalnumbering + 1;
 
 1042             if(sob_angleB != 90.){
 
 1043               stepz += mcptot*
cos(sob_angleB*
pi/180.);
 
 1044               steprad += -mcptot*(1-
sin(sob_angleB*
pi/180.));
 
 1052         logicEV1 = 
new TGeoPgon(
"logicEV1",  90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 7);
 
 1053         logicEV2 = 
new TGeoPgon(
"logicEV2", -90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 7);
 
 1054         logicEV3 = 
new TGeoPgon(
"logicEV3",  90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 7); 
 
 1055         logicEV4 = 
new TGeoPgon(
"logicEV4", -90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 7);
 
 1057         for(
int i=0; 
i<6; 
i++){
 
 1060           if(
i!=0) viscorrection = 0;
 
 1061           logicEV1->DefineSection(
i, currz ,radiusMiddleSmall, minrad+viscorrection);
 
 1062           logicEV2->DefineSection(
i, currz ,radiusMiddleSmall, minrad+viscorrection);
 
 1063           logicEV3->DefineSection(
i, currz ,radiusMiddleSmall*cosFactor1, (minrad+viscorrection)*cosFactor1);
 
 1064           logicEV4->DefineSection(
i, currz ,radiusMiddleSmall*cosFactor1, (minrad+viscorrection)*cosFactor1);
 
 1067           if(
i==4) maxrz = currz;
 
 1070         logicEV1->DefineSection(6, sob_len, radiusMiddleSmall,  (radius+hthick+boxgap+boxthick+EVoffset));
 
 1071         logicEV2->DefineSection(6, sob_len, radiusMiddleSmall,  (radius+hthick+boxgap+boxthick+EVoffset));    
 
 1072         logicEV3->DefineSection(6, sob_len, radiusMiddleSmall*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset)*cosFactor1);   
 
 1073         logicEV4->DefineSection(6, sob_len, radiusMiddleSmall*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset)*cosFactor1);
 
 1077         minrad = radiusMiddleSmall;
 
 1080         logicEV1s = 
new TGeoPgon(
"logicEV1s",  90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 7);
 
 1081         logicEV2s = 
new TGeoPgon(
"logicEV2s", -90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 7);
 
 1082         logicEV3s = 
new TGeoPgon(
"logicEV3s",  90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 7); 
 
 1083         logicEV4s = 
new TGeoPgon(
"logicEV4s", -90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 7);
 
 1085         Double_t airgap = 0.05, airdz=airgap/tan(
pi/2.-alpharad);
 
 1086         for(
int i=0; 
i<6; 
i++){
 
 1089           if(
i!=0) {viscorrection = 0; airgap = 0; airdz=0;}
 
 1090           logicEV1s->DefineSection(
i, currz-airdz ,radiusMiddleSmall-airgap, minrad+viscorrection-airgap);
 
 1091           logicEV2s->DefineSection(
i, currz-airdz ,radiusMiddleSmall-airgap, minrad+viscorrection-airgap);
 
 1092           logicEV3s->DefineSection(
i, currz-airdz ,(radiusMiddleSmall-airgap)*cosFactor1, (minrad+viscorrection-airgap)*cosFactor1);
 
 1093           logicEV4s->DefineSection(
i, currz-airdz ,(radiusMiddleSmall-airgap)*cosFactor1, (minrad+viscorrection-airgap)*cosFactor1);
 
 1096           if(
i==4) maxrz = currz;
 
 1100         logicEV1s->DefineSection(6, sob_len, radiusMiddleSmall-airgap,  (radius+hthick+boxgap+boxthick+EVoffset+airgap));
 
 1101         logicEV2s->DefineSection(6, sob_len, radiusMiddleSmall-airgap,  (radius+hthick+boxgap+boxthick+EVoffset+airgap));    
 
 1102         logicEV3s->DefineSection(6, sob_len, (radiusMiddleSmall-airgap)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset+airgap)*cosFactor1);   
 
 1103         logicEV4s->DefineSection(6, sob_len, (radiusMiddleSmall-airgap)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset+airgap)*cosFactor1);
 
 1106         minrad = radiusMiddleSmall; 
 
 1107         mcptot = MCPsize + MCPgap;
 
 1108         alpharad = TMath::ATan(mcptot/sob_len);
 
 1111         logicEV1b = 
new TGeoPgon(
"logicEV1b",  90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 8);
 
 1112         logicEV2b = 
new TGeoPgon(
"logicEV2b", -90 + pipehAngle, 180 - 2.*pipehAngle, bbnum/2, 8);
 
 1113         logicEV3b = 
new TGeoPgon(
"logicEV3b",  90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 8);
 
 1114         logicEV4b = 
new TGeoPgon(
"logicEV4b", -90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 8);
 
 1118         for(
int i=0; 
i<6; 
i++){
 
 1122           logicEV1b->DefineSection(
i, currz-mcpcoverthick ,radiusMiddleSmall-coverthick, minrad+mcpcoverthick);
 
 1123           logicEV2b->DefineSection(
i, currz-mcpcoverthick ,radiusMiddleSmall-coverthick, minrad+mcpcoverthick);
 
 1124           logicEV3b->DefineSection(
i, currz-mcpcoverthick ,(radiusMiddleSmall-coverthick)*cosFactor1, (minrad+mcpcoverthick)*cosFactor1);
 
 1125           logicEV4b->DefineSection(
i, currz-mcpcoverthick ,(radiusMiddleSmall-coverthick)*cosFactor1, (minrad+mcpcoverthick)*cosFactor1);
 
 1127             tga = (sob_len - currz)/(minrad - (radius+hthick+boxgap+boxthick+EVoffset));
 
 1128             double tshift = mcpcoverthick*tga - coverthick;
 
 1129             logicEV1b->DefineSection(6, currz-tshift ,radiusMiddleSmall-coverthick, minrad+mcpcoverthick);
 
 1130             logicEV2b->DefineSection(6, currz-tshift ,radiusMiddleSmall-coverthick, minrad+mcpcoverthick);
 
 1131             logicEV3b->DefineSection(6, currz-tshift ,(radiusMiddleSmall-coverthick)*cosFactor1, (minrad+mcpcoverthick)*cosFactor1);
 
 1132             logicEV4b->DefineSection(6, currz-tshift ,(radiusMiddleSmall-coverthick)*cosFactor1, (minrad+mcpcoverthick)*cosFactor1);
 
 1136           if(
i==4) maxrz = currz;
 
 1140         logicEV1b->DefineSection(7, sob_len-0.01, radiusMiddleSmall-coverthick,  (radius+hthick+boxgap+boxthick+EVoffset)+coverthick/tga);
 
 1141         logicEV2b->DefineSection(7, sob_len-0.01, radiusMiddleSmall-coverthick,  (radius+hthick+boxgap+boxthick+EVoffset)+coverthick/tga);    
 
 1142         logicEV3b->DefineSection(7, sob_len-0.01, (radiusMiddleSmall-coverthick)*cosFactor1, ((radius+hthick+boxgap+boxthick+EVoffset)+coverthick/tga)*cosFactor1);
 
 1143         logicEV4b->DefineSection(7, sob_len-0.01, (radiusMiddleSmall-coverthick)*cosFactor1, ((radius+hthick+boxgap+boxthick+EVoffset)+coverthick/tga)*cosFactor1);
 
 1145         TGeoCompositeShape *logicEV = 
new TGeoCompositeShape(
"logicEV",
"logicEV1 + logicEV3 + logicEV2 + logicEV4");
 
 1146         TGeoVolume* baseEV = 
new TGeoVolume(
"DrcEVSensor", logicEV, 
gGeoManager->GetMedium(
"Marcol82_7"));
 
 1148         TGeoCompositeShape *logicEVs = 
new TGeoCompositeShape(
"logicEVs",
"logicEV1s + logicEV3s + logicEV2s + logicEV4s"); 
 
 1149         TGeoCompositeShape *logicEVb = 
new TGeoCompositeShape(
"logicEVb",
"logicEV1b + logicEV3b + logicEV2b + logicEV4b"); 
 
 1151         TGeoCompositeShape *logicEVcover = 
new TGeoCompositeShape(
"logicEVcover",
"logicEVb - logicEVs");
 
 1154         vLocalMother->AddNode(pdbase, 0, 
new TGeoCombiTrans(0., 0., sob_shift-2*sum, 
new TGeoRotation(0)));
 
 1157       vLocalMother->AddNode(baseEV, 0, 
new TGeoCombiTrans(0.,0.,sob_shift - 2*sum, 
new TGeoRotation(0)));
 
 1164         for(Int_t 
m = 0; 
m < bbnum; 
m ++){
 
 1165           phi_curr1 = (90. - 
phi0 - dphi*
m)/180.*
pi;    
 
 1166           if(
m > bbnum/2-1){ phi_curr1 = (90. - 
phi0 - dphi*
m - 2.*pipehAngle)/180.*
pi; }
 
 1169           steprad =  mcptot*(1-
TMath::Cos(alpharad))/2.;
 
 1172           for(Int_t nrow=0; nrow < Int_t((sob_Rout+2*hgap-radiusMiddleSmall)/step); nrow++){
 
 1174             TGeoRotation rot_sector;    
 
 1175             rot_sector.RotateX((nrow+1)*alpharad*180./
pi);
 
 1176             rot_sector.RotateZ( -
phi0 - 
m*dphi - (TMath::Floor(2.*
m/bbnum))*(2.*pipehAngle));
 
 1178             sectorWidth = 2.* (radiusMiddleSmall + step*nrow) * tan(dphi_rad/2.);
 
 1179             nmcp = Int_t(sectorWidth/step);
 
 1180             xpos = (radiusMiddleSmall + 0.5*mcptot + step*(nrow));
 
 1181             for(Int_t ny=0; ny<nmcp; ny++){
 
 1182               ypos = ((-Int_t(nmcp/2.) - 0.5*(nmcp%2))*step + (0.5+ny)*step);
 
 1183               location.SetXYZ(xpos-steprad + (logicMCP->GetDZ())*(
TMath::Cos(
pi/2. - (nrow+1)*alpharad)) ,ypos,0.);
 
 1184               location.RotateZ(phi_curr1);
 
 1186               pdbase->AddNode(oneMCP, totalnumbering, 
new TGeoCombiTrans(location.X(), location.Y(),stepz - (logicMCP->GetDZ())*(
TMath::Sin(
pi/2. - (nrow+1)*alpharad))
 
 1187                                                                          , 
new TGeoRotation(rot_sector)));
 
 1188               totalnumbering = totalnumbering + 1;      
 
 1192             steprad += mcptot*(1-
TMath::Cos((nrow+1)*alpharad))/2. + mcptot*(1-
TMath::Cos((nrow+2)*alpharad))/2.;
 
 1201         double sp = 2*(0.5*prismheight1+EVdrop/2.+EVoffset/2.);
 
 1202         double evh = mcpRows*step - 2*hgap;
 
 1205           evh = 3*step - 2*hgap;
 
 1206           omang=atan(MCPactiveArea/sob_len)*180./
pi;
 
 1209         double evb = evh*
sin(sob_angleB*
pi/180.);
 
 1210         double dz1 = (sob_len - evh*
cos(sob_angleB*
pi/180.))/2.;
 
 1211         double dz2 =  evh*
cos(sob_angleB*
pi/180.)/2.;
 
 1212         double evwidth = prismWidth/2.;
 
 1214         std::cout<<
"h0 "<<prismheight1  <<
" h1 "<<evh <<
"  w "<< prismWidth <<std::endl;
 
 1216         TGeoTrap *Trd0 = 
new TGeoTrap(
"Trd0",sob_len/2., atan((evh-sp)/(2.*sob_len))*180./
pi+omang, 270, evh/2., evwidth, evwidth, 0, sp/2., evwidth, evwidth, 0);  
 
 1217         TGeoTrap *Trd1 = 
new TGeoTrap(
"Trd1",dz1, atan((evb-sp)/(4.*dz1))*180./
pi+omang, 270., evb/2., evwidth, evwidth, 0, sp/2., evwidth, evwidth, 0);         
 
 1218         TGeoTrap *Trd2 = 
new TGeoTrap(
"Trd2",dz2, -atan((evb)/(4.*dz2))*180./
pi+omang, 270., 0.000001, evwidth, evwidth, 0, evb/2., evwidth, evwidth, 0);       
 
 1220         evLocShift =  (Trd1->GetH1()+Trd1->GetH2())/2. - 0.5*prismheight1;
 
 1221         if(fEvType==4)  evLocShift =  (Trd1->GetH1()+Trd1->GetH2())/2. - 0.5*prismheight1+0.5*MCPactiveArea+hgap;
 
 1223         TGeoTranslation * evtr1 = 
new TGeoTranslation(
"evtr1",0,0,dz2); 
 
 1224         evtr1->RegisterYourself(); 
 
 1225         TGeoTranslation * evtr2 = 
new TGeoTranslation(
"evtr2",0,-sp/4.,-dz1); 
 
 1226         evtr2->RegisterYourself();
 
 1228         double covergap = 0.05;
 
 1229         evwidth += covergap; 
 
 1231         if(sob_angleB==90) evh += 2*covergap;
 
 1232         evb = evh*
sin(sob_angleB*
pi/180.);
 
 1233         dz1 = (sob_len - evh*
cos(sob_angleB*
pi/180.))/2.;
 
 1234         dz2 =  evh*
cos(sob_angleB*
pi/180.)/2.;
 
 1236         TGeoTrap *Trd0Air = 
new TGeoTrap(
"Trd0Air",sob_len/2., atan((evh-sp)/(2.*sob_len))*180./
pi+omang, 270, evh/2., evwidth, evwidth, 0, sp/2., evwidth, evwidth, 0);
 
 1237         TGeoTrap *Trd1Air = 
new TGeoTrap(
"Trd1Air",dz1, atan((evb-sp)/(4.*dz1))*180./
pi+omang, 270., evb/2., evwidth, evwidth, 0, sp/2., evwidth, evwidth, 0);   
 
 1238         TGeoTrap *Trd2Air = 
new TGeoTrap(
"Trd2Air",dz2, -atan((evb)/(4.*dz2))*180./
pi+omang, 270., 0.000001, evwidth, evwidth, 0, evb/2., evwidth, evwidth, 0); 
 
 1240         evwidth +=coverthick; 
 
 1242         if(sob_angleB==90) evh += 2*coverthick;
 
 1243         evb = evh*
sin(sob_angleB*
pi/180.);
 
 1244         dz1 = (sob_len - evh*
cos(sob_angleB*
pi/180.))/2.;
 
 1245         dz2 =  evh*
cos(sob_angleB*
pi/180.)/2.;
 
 1247         TGeoTrap *Trd0Carbon = 
new TGeoTrap(
"Trd0Carbon",sob_len/2., atan((evh-sp)/(2.*sob_len))*180./
pi+omang, 270, evh/2., evwidth, evwidth, 0, sp/2., evwidth, evwidth, 0);
 
 1248         TGeoTrap *Trd1Carbon = 
new TGeoTrap(
"Trd1Carbon",dz1, atan((evb-sp)/(4.*dz1))*180./
pi+omang, 270., evb/2., evwidth, evwidth, 0, sp/2., evwidth, evwidth, 0);     
 
 1249         TGeoTrap *Trd2Carbon = 
new TGeoTrap(
"Trd2Carbon",dz2, -atan((evb)/(4.*dz2))*180./
pi+omang, 270., 0.000001, evwidth, evwidth, 0, evb/2., evwidth, evwidth, 0);    
 
 1251         TGeoCompositeShape *Trd = 
new TGeoCompositeShape(
"Trd",
"Trd1:evtr1 + Trd2:evtr2");
 
 1252         TGeoCompositeShape *TrdAir = 
new TGeoCompositeShape(
"TrdAir",
"Trd1Air:evtr1 + Trd2Air:evtr2");
 
 1253         TGeoCompositeShape *TrdCarbon = 
new TGeoCompositeShape(
"TrdCarbon",
"Trd1Carbon:evtr1 + Trd2Carbon:evtr2");
 
 1255         TGeoVolume *baseEV0,*baseEVair;
 
 1256         if(sob_angleB==90) {
 
 1257           baseEV0 = 
new TGeoVolume(
"DrcEVSensor",Trd0,
gGeoManager->GetMedium(
"FusedSil"));
 
 1258           baseEVair = 
new TGeoVolume(
"DrcEVAir",Trd0Air,
gGeoManager->GetMedium(
"DIRCairNoSens"));
 
 1259           baseEV = 
new TGeoVolume(
"DrcEVCover",Trd0Carbon,
gGeoManager->GetMedium(
"DIRCcarbonFiber"));
 
 1261           baseEV0 = 
new TGeoVolume(
"DrcEVSensor",Trd,
gGeoManager->GetMedium(
"FusedSil"));
 
 1262           baseEVair = 
new TGeoVolume(
"DrcEVAir",TrdAir,
gGeoManager->GetMedium(
"DIRCairNoSens"));
 
 1263           baseEV = 
new TGeoVolume(
"DrcEVCover",TrdCarbon,
gGeoManager->GetMedium(
"DIRCcarbonFiber"));
 
 1266         baseEV0->SetLineColor(kCyan-2);
 
 1267         baseEVair->AddNode(baseEV0,0,0);
 
 1268         baseEVair->SetLineColor(kCyan-10);
 
 1269         baseEV->AddNode(baseEVair,0,0);
 
 1270         baseEV->SetLineColor(kMagenta-9);
 
 1271         baseEV->SetTransparency(0);
 
 1274       TGeoBBox* logicPDbase = 
new TGeoBBox(
"logicPDbase", 3*step/2., mcpRows*step/2., PDbaseLayer/2.);
 
 1275       Double_t pdLocShift = logicPDbase->GetDY() - 0.5*prismheight1 - hgap;
 
 1282         for(Int_t 
i=0; 
i<mcpRows; 
i++){  
 
 1283           for(Int_t j=0; j<3; j++){ 
 
 1284             xcurr = -0.5*(3.*step) + 0.5*step+j*step;
 
 1285             ycurr = -(2.*hthick+EVdrop+EVoffset+sob_len*tan(sob_angle*
pi/180.))/2. +(
i+0.5)*step + hgap;
 
 1286             if(mcpRows==4) ycurr+=0.5*step;
 
 1288             if(fMcpRows==40 && 
i==0)  {
 
 1289               xcurr = -0.5*(3.*step) + step+j*step;
 
 1293             pdbase->AddNode(oneMCP, totalnumbering, 
new TGeoCombiTrans(xcurr, ycurr, PDbaseLayer/2.-(PDsensitiveThick+CathodeThick+PDwindowThick+PDgreaseLayer)/2., 
new TGeoRotation(0)));
 
 1294             totalnumbering = totalnumbering + 1;   
 
 1297         Double_t evcorr90 = -logicPDbase->GetDZ();
 
 1298         if(sob_angleB!=90) {
 
 1299           pdLocShift +=  - (logicPDbase->GetDY()- hgap)*(1-
cos((90-sob_angleB)*
pi/180.))+logicPDbase->GetDZ()*
cos(sob_angleB*
pi/180.); 
 
 1300           evcorr90 = (logicPDbase->GetDY() - hgap)*
sin((90-sob_angleB)*
pi/180.) -logicPDbase->GetDZ()*
sin(sob_angleB*
pi/180.);
 
 1302         for(Int_t 
m = 0; 
m < bbnum; 
m ++){
 
 1303           phi_curr = (90. - 
phi0 - dphi*
m)/180.*
pi;    
 
 1304           if(
m > bbnum/2-1){ phi_curr = (90. - 
phi0 - dphi*
m - 2.*pipehAngle)/180.*
pi; }
 
 1305           dx = (radius-EVdrop) * 
cos(phi_curr);
 
 1306           dy = (radius-EVdrop) * 
sin(phi_curr);
 
 1308           TGeoRotation rotbbox,rotpbox;    
 
 1309           rotbbox.RotateZ( -
phi0 - 
m*dphi - (TMath::Floor(2.*
m/bbnum))*(2.*pipehAngle)); 
 
 1310           rotpbox.RotateX(90-sob_angleB);
 
 1311           rotpbox.RotateZ( -
phi0 - 
m*dphi - (TMath::Floor(2.*
m/bbnum))*(2.*pipehAngle));   
 
 1313           vLocalMother->AddNode(baseEV, 
m, 
new TGeoCombiTrans(dx + evLocShift*
cos(phi_curr), dy + evLocShift*
sin(phi_curr), bbox_zup - 2*entransewidth - sob_len/2.  , 
new TGeoRotation(rotbbox)));
 
 1314           vLocalMother->AddNode(pdbase, 
m, 
new TGeoCombiTrans(dx + pdLocShift*
cos(phi_curr), dy + pdLocShift*
sin(phi_curr), sob_shift-2*sum+evcorr90, 
new TGeoRotation(rotpbox)));
 
 1320     baseEV->SetLineColor(kMagenta-9);
 
 1321     baseEV->SetTransparency(50);
 
 1330     TGeoSphere* l0 = 
new TGeoSphere(
"l0",0 ,150, 0. ,180.,0.,360.); 
 
 1331     top = 
new TGeoVolume(
"DIRC", lTop, 
gGeoManager->GetMedium(
"air"));
 
 1334     TGeoSphere* l1 = 
new TGeoSphere(
"l1",0 ,120, 0. ,180.,0.,360.);
 
 1335     v1 = 
new TGeoVolume(
"v1", l1, 
gGeoManager->GetMedium(
"air"));
 
 1337     TGeoSphere* l2 = 
new TGeoSphere(
"l2",0 ,100, 0. ,180.,0.,360.);
 
 1338     v2 = 
new TGeoVolume(
"v2", l2, 
gGeoManager->GetMedium(
"FusedSil"));
 
 1345     v2->AddNode(baseEV,0,0);
 
 1346     v1->AddNode(
v2, 0,0);
 
 1347     top->AddNode(
v1, 0,0);
 
 1351   top->CheckOverlaps(0.0001, 
"");
 
 1360   if(!gROOT->IsBatch()) top->Draw(
"ogl");
 
 1362   TObjArray *listOfOverlaps = 
gGeoManager->GetListOfOverlaps();
 
 1363   cout<<listOfOverlaps->GetEntries()<<endl;
 
 1364   listOfOverlaps->Print(); 
 
friend F32vec4 cos(const F32vec4 &a)
friend F32vec4 sqrt(const F32vec4 &a)
friend F32vec4 sin(const F32vec4 &a)
TGeoManager * gGeoManager
FairGeoBuilder * geobuild
double eps(TVector3 v1, TVector3 v2)
int createdirc_prism(Int_t fEvType=3, Int_t fNBars=3, Int_t fFocusingSystem=6, Int_t fMcpRows=40, Int_t iter=0, TString geomPath=".", Double_t par1=-100, Double_t par2=-100, Double_t par3=-100, Double_t par4=-100, Double_t par5=-100, Double_t par6=-100, Double_t par7=-100, Double_t par8=-100, Double_t par9=-100)
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
friend F32vec4 fabs(const F32vec4 &a)
FairGeoInterface * geoFace