35   gROOT->Macro(
"$VMCWORKDIR/gconfig/rootlogon.C");
 
   37   TString vmcWorkdir = getenv(
"VMCWORKDIR");
 
   40   gSystem->Load(
"libGeoBase");
 
   41   gSystem->Load(
"libParBase");
 
   42   gSystem->Load(
"libBase");
 
   43   gSystem->Load(
"libPndData");
 
   44   gSystem->Load(
"libPassive");
 
   66   Double_t bbox_hlen     =  0.5*(bbox_zdown - bbox_zup);           
 
   67   Double_t bbox_shift    =  bbox_zup + bbox_hlen; 
 
   81   Double_t sob_shift     =  -bbox_hlen + bbox_shift - sob_len; 
 
   84   Double_t sob_Rout      =  radius + hthick + sob_len*tan(sob_angle/180.*
pi)/
cos(
pi/bbnum/2.);
 
   86   Double_t bbAngle       =  ( 180. - 2.*pipehAngle - bbGap/radius/
pi*180.*(bbnum/2.-1.) )/(bbnum/2.);  
 
   88   cout<<
"bbAngle = "<<bbAngle<<
", bbX = "<<bbX<<endl;
 
   92   Double_t dphi = (180.-2.*pipehAngle)/bbnum*2.;
 
   95   cout<<
"dphi = "<<dphi<<
", phi0 = "<<phi0<<endl;  
 
  104   const Int_t NpixTotal = Npix*Npix; 
 
  106   cout<<
"pixel gap  = "<< PixelGap<<endl;
 
  122   Double_t pheight       =  2.*phlength * tan(pangle/180.*
pi);  
 
  124   Double_t sob_Rprizm    =  radius + hthick + poffset + pheight + EVoffset + (sob_len-2.*phlength)*tan(60./180.*
pi);
 
  126   cout<<
"prizm length = "<<phlength*2.<<endl;
 
  127   cout<<
"prizm height = "<<2.*phlength * tan(pangle/180.*
pi)<<endl;
 
  130   Double_t radiusCornerIn = (radius-hthick-EVdrop)/
cos(dphi/2./180.*
pi);
 
  131   Double_t radiusCornerOut = sob_Rout;
 
  132   Double_t radiusMiddleSmall = radius-hthick-EVdrop;    
 
  139   TString fGeoFile= Form(
"../../geometry/dirc_l%d_p%d_mirrorGap_MCPs1_updated.root",fFocusingSystem, fprizm);
 
  140   TFile* 
fi = 
new TFile(fGeoFile,
"RECREATE");
 
  141   cout<<
"Output file = "<<fGeoFile<<endl;
 
  146    Int_t nel, numed, nz;
 
  148    new TGeoManager(
"Drc", 
"Drc");
 
  154    TGeoMixture *
air = 
new TGeoMixture(
"air", nel,density);
 
  155       aa = 14.010000;   z = 7.000000;   w = 0.780000;  
 
  156    air->DefineElement(0,aa,z,w);
 
  157       aa = 16.000000;   z = 8.000000;   w = 0.210000;  
 
  158    air->DefineElement(1,aa,z,w);
 
  159       aa = 39.950000;   z = 18.000000;   w = 0.010000;  
 
  160    air->DefineElement(2,aa,z,w);
 
  172    TGeoMedium *air_m = 
new TGeoMedium(
"air", numed,air, par);   
 
  177    TGeoMixture *DIRCairNoSens = 
new TGeoMixture(
"DIRCairNoSens", nel,density);
 
  178       aa = 14.010000;   z = 7.000000;   w = 0.780000;  
 
  179    DIRCairNoSens->DefineElement(0,aa,z,w);
 
  180       aa = 16.000000;   z = 8.000000;   w = 0.210000;  
 
  181    DIRCairNoSens->DefineElement(1,aa,z,w);
 
  182       aa = 39.950000;   z = 18.000000;   w = 0.010000;  
 
  183    DIRCairNoSens->DefineElement(2,aa,z,w);
 
  195    TGeoMedium  *DIRCairNoSens_m = 
new TGeoMedium(
"DIRCairNoSens", numed, DIRCairNoSens, par);
 
  200    TGeoMixture* Epotek301_2 = 
new TGeoMixture(
"Epotek301_2", nel,density);
 
  201       aa = 28.090000;   z = 14.000000;   w = 0.467475;  
 
  202    Epotek301_2->DefineElement(0,aa,z,w);
 
  203       aa = 15.999400;   z = 8.000000;   w = 0.532525;  
 
  204    Epotek301_2->DefineElement(1,aa,z,w);
 
  216    TGeoMedium *Epotek301_2_m = 
new TGeoMedium(
"Epotek301_2", numed, Epotek301_2, par);  
 
  221    TGeoMixture* OpticalGrease = 
new TGeoMixture(
"OpticalGrease", nel,density);
 
  222       aa = 28.090000;   z = 14.000000;   w = 0.467475;  
 
  223    OpticalGrease->DefineElement(0,aa,z,w);
 
  224       aa = 15.999400;   z = 8.000000;   w = 0.532525;  
 
  225    OpticalGrease->DefineElement(1,aa,z,w);
 
  237    TGeoMedium *OpticalGrease_m = 
new TGeoMedium(
"OpticalGrease", numed, OpticalGrease, par);
 
  245   TGeoMaterial *DIRCcarbonFiber = 
new TGeoMaterial(
"DIRCcarbonFiber", aa,z,density,radl,absl);
 
  257    TGeoMedium *DIRCcarbonFiber_m = 
new TGeoMedium(
"DIRCcarbonFiber", numed,DIRCcarbonFiber, par);
 
  262    TGeoMixture* FusedSil = 
new TGeoMixture(
"FusedSil", nel,density);
 
  263       aa = 28.090000;   z = 14.000000;   w = 0.467475;  
 
  264    FusedSil->DefineElement(0,aa,z,w);
 
  265       aa = 15.999400;   z = 8.000000;   w = 0.532525;  
 
  266    FusedSil->DefineElement(1,aa,z,w);
 
  278    TGeoMedium *FusedSil_m = 
new TGeoMedium(
"FusedSil", numed,FusedSil, par);
 
  283    TGeoMixture* Mirror = 
new TGeoMixture(
"Mirror", nel,density);
 
  284       aa = 28.090000;   z = 14.000000;   w = 0.467475;  
 
  285    Mirror->DefineElement(0,aa,z,w);
 
  286       aa = 15.999400;   z = 8.000000;   w = 0.532525;  
 
  287    Mirror->DefineElement(1,aa,z,w);
 
  299    TGeoMedium *Mirror_m = 
new TGeoMedium(
"Mirror", numed,Mirror, par);
 
  304    TGeoMixture *Marcol82 = 
new TGeoMixture(
"Marcol82", nel,density);
 
  305       aa = 1.007940;   z = 1.000000;   w = 0.148605;  
 
  306    Marcol82->DefineElement(0,aa,z,w);
 
  307       aa = 12.010700;   z = 6.000000;   w = 0.851395;  
 
  308    Marcol82->DefineElement(1,aa,z,w);
 
  320    TGeoMedium *Marcol82_m = 
new TGeoMedium(
"Marcol82", numed,Marcol82, par);
 
  325    TGeoMixture *Marcol82_7 = 
new TGeoMixture(
"Marcol82-7", nel,density);
 
  326       aa = 1.007940;   z = 1.000000;   w = 0.148605;  
 
  327    Marcol82_7->DefineElement(0,aa,z,w);
 
  328       aa = 12.010700;   z = 6.000000;   w = 0.851395;  
 
  329    Marcol82_7->DefineElement(1,aa,z,w);
 
  341    TGeoMedium *Marcol82_7_m = 
new TGeoMedium(
"Marcol82-7", numed,Marcol82_7, par);
 
  347    TGeoMixture *NLAK33A = 
new TGeoMixture(
"NLAK33A", nel, density);
 
  348       aa = 28.090000;   z = 14.000000;   w = 0.467475;  
 
  349    NLAK33A->DefineElement(0,aa,z,w);
 
  350       aa = 15.999400;   z = 8.000000;   w = 0.532525;  
 
  351    NLAK33A->DefineElement(1,aa,z,w);
 
  363    TGeoMedium *NLAK33A_m = 
new TGeoMedium(
"NLAK33A", numed,NLAK33A, par);
 
  370   if(fFocusingSystem == 0){
 
  372     fSlabEnd = -bbox_hlen + bbox_shift + flen;  
 
  373     cout<<
"bar ends at = "<<fSlabEnd<<endl;
 
  378   if (fFocusingSystem == 1){  
 
  387     cout<<
" DIRC a,b = "<<a<<
" "<<b<<endl;
 
  400     len = b + 0.2 + b3 + 0.5;
 
  402     cout<<
"DIRC len= "<<len<<endl;
 
  404     fSlabEnd = -bbox_hlen + bbox_shift + len; 
 
  405     cout<<
"bar ends at = "<<fSlabEnd<<endl;
 
  412     TGeoSphere* logicSphere= 
new TGeoSphere(
"S",0.,r, 0. ,180.,0.,360.);
 
  413     TGeoBBox* lBox = 
new TGeoBBox(
"B", (bbX/barnum)/2-bargap, hthick, b/2.);
 
  414     TGeoTranslation *tr1 = 
new TGeoTranslation(
"tr1", 0.,0., t);
 
  415     tr1->RegisterYourself();
 
  416     TGeoCompositeShape *cs = 
new TGeoCompositeShape(
"cs",
"S*(B:tr1)");
 
  417     TGeoVolume *lens1 = 
new TGeoVolume(
"DrcLENS1Sensor",cs, 
gGeoManager->GetMedium(
"FusedSil"));
 
  418     lens1->SetLineColor(kRed-8);
 
  419     lens1->SetTransparency(40); 
 
  425   fdz_lens1 = -(bbox_hlen)+len -(-r+b);
 
  430     TGeoSphere* logicSphere2 = 
new TGeoSphere(
"S2",0 ,r2, 0. ,180.,0.,360.);
 
  431     TGeoBBox*   lBox2        = 
new TGeoBBox(
"B2", (bbX/barnum)/2.-bargap, hthick, b2/2.); 
 
  432     TGeoTranslation *tr2     = 
new TGeoTranslation(
"tr2", 0.,0., t2);
 
  433     tr2->RegisterYourself();
 
  434     TGeoCompositeShape *cs2 = 
new TGeoCompositeShape(
"cs2",
"(B2:tr2)-S2");
 
  435     TGeoVolume *lens2 = 
new TGeoVolume(
"DrcLENS2Sensor",cs2, 
gGeoManager->GetMedium(
"NLAK33A"));
 
  436     lens2->SetLineColor(kRed+2);
 
  437     lens2->SetTransparency(40); 
 
  445   fdz_lens2 = -(bbox_hlen)+len -(-r2) -
b;
 
  449     TGeoSphere* logicSphere3= 
new TGeoSphere(
"S3",0.,r3, 0. ,180.,0.,360.);
 
  450     TGeoBBox* lBox3 = 
new TGeoBBox(
"B3", (bbX/barnum)/2-bargap, hthick, b3/2.); 
 
  451     TGeoTranslation *tr3 = 
new TGeoTranslation(
"tr3", 0.,0., t3);
 
  452     tr3->RegisterYourself();
 
  453     TGeoCompositeShape *cs3 = 
new TGeoCompositeShape(
"cs3",
"S3*(B3:tr3)");
 
  454     TGeoVolume *lens3 = 
new TGeoVolume(
"DrcLENS3Sensor",cs3, 
gGeoManager->GetMedium(
"NLAK33A"));
 
  455     lens3->SetLineColor(kRed-6);
 
  456     lens3->SetTransparency(40); 
 
  465   fdz_lens3 = -(bbox_hlen)+len -(-r3+b3) -b - b2/2. ;  
 
  471   if (fFocusingSystem == 2){  
 
  477      len = -130. + zpos + 1.;
 
  483      Double_t focal_length  = 2. * bbox_hlen + sob_len - 
fabs(len) + len1;
 
  484      Double_t mirror_radius = 2. * focal_length;
 
  486      cout<<
" mirror radius: "<<mirror_radius<<endl;
 
  491      TGeoSphere* logicSphere = 
new TGeoSphere(
"S",0.,mirror_radius, 0. ,180.,0.,360.);
 
  492      TGeoBBox*   lBox        = 
new TGeoBBox(
"B", (bbX/barnum)/2-bargap, hthick, 
fabs(len1)/2.); 
 
  494      Double_t t = mirror_radius - len1/2.;
 
  496      TGeoTranslation *tr1 = 
new TGeoTranslation(
"tr1", 0.,0., t);
 
  497      tr1->RegisterYourself();
 
  498      TGeoCompositeShape *cs = 
new TGeoCompositeShape(
"cs",
"S*(B:tr1)");
 
  500      TGeoVolume *block1 = 
new TGeoVolume(
"DrcBlock1",cs, 
gGeoManager->GetMedium(
"FusedSil"));
 
  501      block1->SetLineColor(kRed);
 
  502      block1->SetTransparency(40);
 
  505      Double_t shift1 = len1-mirror_radius; 
 
  506      shift1         += bbox_hlen-
fabs(len)-2.*mirr_hthick;
 
  518      TGeoSphere* logicSphere2 = 
new TGeoSphere(
"S2",0,mirror_radius,             0. ,180.,0.,360.);
 
  519      TGeoBBox*   lBox2        = 
new TGeoBBox(
"B2", (bbX/barnum)/2-bargap, hthick, 
fabs(len2)/2.); 
 
  522      Double_t t2 = mirror_radius + len2/2 - 1;
 
  524      TGeoTranslation *tr2 = 
new TGeoTranslation(
"tr2", 0.,0., t2);
 
  525      tr2->RegisterYourself();
 
  526      TGeoCompositeShape *cs2 = 
new TGeoCompositeShape(
"cs2",
"(B2:tr2)-S2");
 
  528      TGeoVolume *block2 = 
new TGeoVolume(
"DrcBlock2",cs2, 
gGeoManager->GetMedium(
"Mirror"));
 
  529      block2->SetLineColor(kGreen);
 
  530      block2->SetTransparency(40);
 
  534      shift2          += bbox_hlen-
fabs(len)-2*mirr_hthick; 
 
  535      shift2          += len1 + gap;
 
  554      fSlabEnd = -bbox_hlen + bbox_shift + flen;  
 
  555      cout<<
"bar ends at = "<<fSlabEnd<<endl;
 
  560    if(fFocusingSystem == 3){ 
 
  566      Double_t Lcyl = (bbX/barnum)/2.-bargap;  
 
  571      cout<<
"DIRC: len = "<<len<<endl;
 
  573      cout<<
"length = "<< Lcyl<<
", angle = "<<Acyl/3.1415*180.<<
", translation = "<<Tcyl1<<endl;
 
  574      cout<<
"lens 0.5*width = "<<hthick<<
", 0.5*thickness = "<< 0.5*Rcyl*(1.-
TMath::Cos(Acyl))<<
", 0.5*heigth = "<<Lcyl <<endl;
 
  577      TGeoEltu* lCylinder = 
new TGeoEltu(
"Cyl",Rcyl,Rcyl,Lcyl);
 
  578      TGeoBBox* lCylBox = 
new TGeoBBox(
"CylBox", hthick, hthick, Lcyl);
 
  581      TGeoTranslation *trCyl1 = 
new TGeoTranslation(
"trCyl", 0., Rcyl*
TMath::Cos(Acyl)+hthick, 0.);
 
  582      trCyl1->RegisterYourself();
 
  583      TGeoCompositeShape *llens1 = 
new TGeoCompositeShape(
"llens1",
"Cyl*(CylBox:trCyl)");
 
  584      TGeoVolume *CylLens1 = 
new TGeoVolume(
"DrcLENS1Sensor",llens1, 
gGeoManager->GetMedium(
"NLAK33A"));
 
  585      CylLens1->SetLineColor(kRed-8);
 
  586      CylLens1->SetTransparency(40);
 
  588      fdz_lens1 = -(bbox_hlen) + len - (-Rcyl + Rcyl*(1.-
TMath::Cos(Acyl)));
 
  591      TGeoTranslation *trCyl2 = 
new TGeoTranslation(
"trCyl2", 0., Rcyl + Hcyl2 - hthick, 0.);
 
  592      trCyl2->RegisterYourself();
 
  593      TGeoCompositeShape *llens2 = 
new TGeoCompositeShape(
"llens2", 
"(CylBox:trCyl2) - Cyl");
 
  594      TGeoVolume* CylLens2 = 
new TGeoVolume(
"DrcLENS2Sensor", llens2, 
gGeoManager->GetMedium(
"FusedSil"));
 
  595      CylLens2->SetLineColor(kRed+2);
 
  596      CylLens2->SetTransparency(40);
 
  604      fdz_lens2 = -(bbox_hlen) + len + (hthick - Rcyl*(1.-
TMath::Cos(Acyl)) - Hcyl2);
 
  605      fSlabEnd = -bbox_hlen + bbox_shift;
 
  606      cout<<
"bar ends at = "<<fSlabEnd<<endl;
 
  614   TGeoBBox*   lTop = 
new TGeoBBox(500,500,300);
 
  615   cave = 
new TGeoVolume(
"DIRC", lTop, air_m);
 
  620   TGeoPcon*   
shape = 
new TGeoPcon(
"BarrelDIRCShape", 0, 360., 4);
 
  621   shape->DefineSection(0, bbox_zdown, 35., 60.);
 
  622   shape->DefineSection(1, bbox_zup, 35., 60.);
 
  623   shape->DefineSection(2, bbox_zup - sob_len, 35., sob_Rout+poffset+pheight+EVoffset+1.);
 
  624   shape->DefineSection(3, bbox_zup - sob_len - PDbaseLayer - EVgreaseLayer, 35., sob_Rout+poffset+pheight+EVoffset+1.);
 
  625   vLocalMother = 
new TGeoVolume(
"BarrelDIRC", shape, air_m); 
 
  626   cave->AddNode(vLocalMother, 0,0);
 
  628   cout<<
"bbox length = "<<2.*(bbox_hlen-0.5*(boxgap+boxthick))<<
", prizm length = "<<2.*(phlength+0.5*(boxgap+boxthick))<<endl;
 
  629   cout<<
"prizm shift = "<<-bbox_hlen+0.5*(boxgap+boxthick)-phlength<<endl;
 
  634   logicbbL = 
new TGeoBBox(
"logicbbL", bbX/2.+boxthick, hthick+boxgap+boxthick, bbox_hlen);
 
  635   bbox = 
new TGeoVolume(
"DrcBarBox", logicbbL,DIRCcarbonFiber_m); 
 
  636   bbox->SetLineColor(30); 
 
  642   logicbbS = 
new TGeoBBox(
"logicbbS", bbX/2., hthick+boxgap, bbox_hlen-barWin_hthick);
 
  643   abox = 
new TGeoVolume(
"DrcAirBox", logicbbS, DIRCairNoSens_m);
 
  644   bbox->AddNode(abox, 1, 
new TGeoCombiTrans(0., 0., barWin_hthick, 
new TGeoRotation(0)));
 
  645   abox->SetLineColor(19); 
 
  648   TGeoBBox* logicBarWin = 
new  TGeoBBox(
"logicBarWin", bbX/2., hthick+boxgap, barWin_hthick);
 
  649   TGeoVolume* barwin = 
new TGeoVolume(
"DrcBarboxWindow", logicBarWin, FusedSil_m);
 
  650   barwin->SetLineColor(kBlue-4);
 
  651   bbox->AddNode(barwin, 1, 
new TGeoCombiTrans(0.,0.,-bbox_hlen+barWin_hthick,
new TGeoRotation(0)));
 
  654   TGeoBBox* logicEVgrease = 
new  TGeoBBox(
"logicEVgrease", bbX/2., hthick+boxgap, EVgreaseLayer/2.);
 
  655   TGeoVolume* evgrease = 
new TGeoVolume(
"DrcEVgrease", logicEVgrease, OpticalGrease_m);  
 
  656   evgrease->SetLineColor(kSpring);
 
  659   Double_t dx_bbox, dy_bbox, dz_bbox, phi_curr;    
 
  661   for(Int_t 
m = 0; 
m < bbnum; 
m ++){       
 
  662     phi_curr = (90. - phi0 - dphi*
m)/180.*
pi;    
 
  663     if(
m > bbnum/2-1){ phi_curr = (90. - phi0 - dphi*
m - 2.*pipehAngle)/180.*
pi; }
 
  664     dx_bbox = radius * 
cos(phi_curr);
 
  665     dy_bbox = radius * 
sin(phi_curr);
 
  666     dz_bbox = bbox_shift;
 
  668     TGeoRotation rot_bbox;    
 
  669     rot_bbox.RotateZ( -phi0 - 
m*dphi - (TMath::Floor(2.*
m/bbnum))*(2.*pipehAngle));    
 
  670     vLocalMother->AddNode(bbox, 
m+1, 
new TGeoCombiTrans(dx_bbox, dy_bbox, dz_bbox, 
new TGeoRotation(rot_bbox)));
 
  671     vLocalMother->AddNode(evgrease, 
m+1, 
new TGeoCombiTrans(dx_bbox, dy_bbox, bbox_zup-EVgreaseLayer/2.,
new TGeoRotation(rot_bbox)));    
 
  674   cout<<
"bar width = "<<2.*(((bbX/barnum)/2.)-bargap) << 
", bar with gaps = "<<(bbX/barnum)<<endl;
 
  675   cout<<
"barboxL width = "<<bbX/2.+boxgap+boxthick<<
", barboxS width = "<<bbX/2.+boxgap<<endl;
 
  678   TGeoBBox* logicBar = 
new TGeoBBox(
"logicBar", ((bbX/barnum)/2.)-bargap, hthick, bbox_hlen-
fabs(len)/2.-mirr_hthick-barWin_hthick); 
 
  680   bar = 
new TGeoVolume(
"DrcBarSensor",logicBar, FusedSil_m );
 
  681   bar->SetLineColor(kCyan-9);
 
  682   bar->SetTransparency(60);
 
  685   TGeoBBox* logicMirror  = 
new TGeoBBox(
"logicMirror", bbX/barnum/2.-bargap, hthick, mirr_hthick /2.); 
 
  686   TGeoVolume *mirr  = 
new TGeoVolume(
"DrcMirr", logicMirror,  Mirror_m);
 
  687   mirr->SetLineColor(5);
 
  690   TGeoBBox* logicBarGlue  = 
new TGeoBBox(
"logicBarGlue", bbX/barnum/2.-bargap, hthick, gluehthick); 
 
  691   TGeoVolume *barglue  = 
new TGeoVolume(
"DrcBarGlue", logicBarGlue,  Epotek301_2_m);
 
  692   barglue->SetLineColor(kSpring-5);
 
  693   bar->AddNode(barglue, 1, 
new TGeoCombiTrans(0., 0., 0., 
new TGeoRotation (0)));
 
  697   for(Int_t j=0; j<barnum; j++){
 
  698     dx      = - (bbX/2.) + (bbX/barnum)/2. + j * (bbX/barnum); 
 
  700     dz_bar = len/2.-mirr_hthick;
 
  701     dz_mirr = bbox_hlen - barWin_hthick - mirr_hthick;
 
  702     if(fFocusingSystem == 1){ 
 
  703       abox->AddNode(lens1,  1+j, 
new TGeoCombiTrans(dx, dy, fdz_lens1, 
new TGeoRotation (0)));
 
  704       abox->AddNode(lens2,  1+j, 
new TGeoCombiTrans(dx, dy, fdz_lens2, 
new TGeoRotation (0)));
 
  705       abox->AddNode(lens3,  1+j, 
new TGeoCombiTrans(dx, dy, fdz_lens3, 
new TGeoRotation (0)));
 
  707     if(fFocusingSystem == 2){ 
 
  708       abox->AddNode(block1, 1+j, 
new TGeoCombiTrans(dx, dy, fdz_mirr1, 
new TGeoRotation (0)));
 
  709       abox->AddNode(block2, 1+j, 
new TGeoCombiTrans(dx, dy, fdz_mirr2, 
new TGeoRotation (0)));
 
  711     if(fFocusingSystem == 3){
 
  712       TGeoRotation rot_lens3;
 
  713       rot_lens3.RotateZ(-90.);
 
  714       rot_lens3.RotateY( 90.);               
 
  715       abox->AddNode(CylLens1, 1+j, 
new TGeoCombiTrans(dx, dy, fdz_lens1, 
new TGeoRotation(rot_lens3)));
 
  716       abox->AddNode(CylLens2, 1+j, 
new TGeoCombiTrans(dx, dy, fdz_lens1, 
new TGeoRotation(rot_lens3)));
 
  719     abox->AddNode(bar,  1+j, 
new TGeoCombiTrans(dx, dy, dz_bar, 
new TGeoRotation(0)));
 
  720     if(fFocusingSystem != 2){ 
 
  721       abox->AddNode(mirr, 1+j, 
new TGeoCombiTrans(dx, dy, dz_mirr, 
new TGeoRotation(0))); 
 
  730   TGeoPgon* logicEV1, * logicEV2, *logicEV3, * logicEV4;
 
  731   cosFactor1 = 
cos(pipehAngle/180.*
pi)/
cos(dphi/180.*
pi/2.);  
 
  732   dR = (radius+hthick+boxgap+boxthick)/
cos(dphi/2./180.*
pi) - (radius-hthick);
 
  733   xEV = (dR + sob_len*tan(sob_angle/180.*
pi))/ (tan(sob_angle/180.*
pi) + tan(sob_angleB/180.*
pi));    
 
  734   if(sob_angleB == 90.){
 
  735     logicEV1 = 
new TGeoPgon(
"logicEV1", 93.6, 172.8, bbnum/2, 2);
 
  736     logicEV1->DefineSection(0, 0.,      radiusMiddleSmall,  sob_Rout);
 
  737     logicEV1->DefineSection(1, sob_len, radiusMiddleSmall,  (radius+hthick+boxgap+boxthick+EVoffset)/
cos(dphi/2./180.*
pi));
 
  738     logicEV2 = 
new TGeoPgon(
"logicEV2", -86.4, 172.8, bbnum/2, 2);
 
  739     logicEV2->DefineSection(0, 0.,      radiusMiddleSmall,  sob_Rout);
 
  740     logicEV2->DefineSection(1, sob_len, radiusMiddleSmall,  (radius+hthick+boxgap+boxthick+EVoffset)/
cos(dphi/2./180.*
pi));     
 
  741     logicEV3 = 
new TGeoPgon(
"logicEV3", 86.4, 7.2, 1, 2);
 
  742     logicEV3->DefineSection(0, 0.,      (radiusMiddleSmall)*cosFactor1,  sob_Rout*cosFactor1);
 
  743     logicEV3->DefineSection(1, sob_len, (radiusMiddleSmall)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset)/
cos(dphi/2./180.*
pi)*cosFactor1);     
 
  744     logicEV4 = 
new TGeoPgon(
"logicEV4", -93.6, 7.2, 1, 2);
 
  745     logicEV4->DefineSection(0, 0.,      (radiusMiddleSmall)*cosFactor1,  sob_Rout*cosFactor1);
 
  746     logicEV4->DefineSection(1, sob_len, (radiusMiddleSmall)*cosFactor1,  (radius+hthick+boxgap+boxthick+EVoffset)/
cos(dphi/2./180.*
pi)*cosFactor1);     
 
  749   if(sob_angleB != 90.){  
 
  750     logicEV1 = 
new TGeoPgon(
"logicEV1", 93.6, 172.8, bbnum/2, 3);
 
  751     logicEV1->DefineSection(0, 0.,      radius-hthick,  radius-hthick+eps);
 
  752     logicEV1->DefineSection(1, xEV,     radius-hthick,  sob_Rout - xEV*tan(sob_angle/180.*
pi));
 
  753     logicEV1->DefineSection(2, sob_len, radius-hthick,  (radius+hthick+boxgap+boxthick)/
cos(dphi/2./180.*
pi));
 
  754     logicEV2 = 
new TGeoPgon(
"logicEV2", -86.4, 172.8, bbnum/2, 3);
 
  755     logicEV2->DefineSection(0, 0.,      radius-hthick,  radius-hthick+eps);
 
  756     logicEV2->DefineSection(1, xEV,     radius-hthick,  sob_Rout - xEV*tan(sob_angle/180.*
pi));
 
  757     logicEV2->DefineSection(2, sob_len, radius-hthick,  (radius+hthick+boxgap+boxthick)/
cos(dphi/2./180.*
pi));
 
  758     logicEV3 = 
new TGeoPgon(
"logicEV3", 86.4, 7.2, 1, 3);
 
  759     logicEV3->DefineSection(0, 0.,      (radius-hthick)*cosFactor1,  (radius-hthick+eps)*cosFactor1);
 
  760     logicEV3->DefineSection(1, xEV,     (radius-hthick)*cosFactor1,  (sob_Rout - xEV*tan(sob_angle/180.*
pi))*cosFactor1);
 
  761     logicEV3->DefineSection(2, sob_len, (radius-hthick)*cosFactor1,  (radius+hthick+boxgap+boxthick)/
cos(dphi/2./180.*
pi)*cosFactor1);
 
  762     logicEV4 = 
new TGeoPgon(
"logicEV4", -93.6, 7.2, 1, 3);
 
  763     logicEV4->DefineSection(0, 0.,      (radius-hthick)*cosFactor1,  (radius-hthick+eps)*cosFactor1);
 
  764     logicEV4->DefineSection(1, xEV,     (radius-hthick)*cosFactor1,  (sob_Rout - xEV*tan(sob_angle/180.*
pi))*cosFactor1);
 
  765     logicEV4->DefineSection(2, sob_len, (radius-hthick)*cosFactor1,  (radius+hthick+boxgap+boxthick)/
cos(dphi/2./180.*
pi)*cosFactor1);           
 
  768   TGeoCompositeShape *logicEV = 
new TGeoCompositeShape(
"logicEV",
"logicEV1 + logicEV2 + logicEV3 + logicEV4");
 
  769   TGeoVolume* baseEV = 
new TGeoVolume(
"DrcEVSensor", logicEV, FusedSil_m);
 
  770   baseEV->SetLineColor(kMagenta+2);
 
  771   baseEV->SetTransparency(50);
 
  772   vLocalMother->AddNode(baseEV, 1, 
new TGeoCombiTrans(0.,0.,sob_shift - EVgreaseLayer, 
new TGeoRotation(0)));
 
  775   TGeoPgon *logicPDbase1 = 
new TGeoPgon(
"logicPDbase1",  93.6, 172.8, bbnum/2, 2);
 
  776   TGeoPgon *logicPDbase2 = 
new TGeoPgon(
"logicPDbase2", -86.4, 172.8, bbnum/2, 2);
 
  777   TGeoPgon *logicPDbase3 = 
new TGeoPgon(
"logicPDbase3",  86.4,   7.2,       1, 2);
 
  778   TGeoPgon *logicPDbase4 = 
new TGeoPgon(
"logicPDbase4", -93.6,   7.2,       1, 2);
 
  779   Double_t rad_delta = (MCPsize-MCPactiveArea)/2./
cos(45./180.*
pi);
 
  780   if(sob_angleB == 90.){       
 
  781     logicPDbase1->DefineSection(0, 0.,  radiusMiddleSmall-rad_delta, sob_Rout);
 
  782     logicPDbase1->DefineSection(1, PDbaseLayer,  radiusMiddleSmall-rad_delta, sob_Rout);           
 
  783     logicPDbase2->DefineSection(0, 0.,  radiusMiddleSmall-rad_delta, sob_Rout);
 
  784     logicPDbase2->DefineSection(1, PDbaseLayer,  radiusMiddleSmall-rad_delta, sob_Rout);      
 
  785     logicPDbase3->DefineSection(0, 0., (radiusMiddleSmall)*cosFactor1-rad_delta, sob_Rout*cosFactor1);
 
  786     logicPDbase3->DefineSection(1, PDbaseLayer, (radiusMiddleSmall)*cosFactor1-rad_delta, sob_Rout*cosFactor1);
 
  787     logicPDbase4->DefineSection(0, 0., (radiusMiddleSmall)*cosFactor1-rad_delta, sob_Rout*cosFactor1);
 
  788     logicPDbase4->DefineSection(1, PDbaseLayer, (radiusMiddleSmall)*cosFactor1-rad_delta, sob_Rout*cosFactor1);
 
  801   TGeoCompositeShape *logicPDbase = 
new TGeoCompositeShape(
"logicPDbase",
"logicPDbase1 + logicPDbase2 + logicPDbase3 + logicPDbase4");
 
  802   TGeoVolume *pdbase = 
new TGeoVolume(
"DrcPDbase", logicPDbase, DIRCcarbonFiber_m);
 
  803   pdbase->SetLineColor(kGreen-6);
 
  804   if(sob_angleB == 90.){
 
  805     vLocalMother->AddNode(pdbase, 1, 
new TGeoCombiTrans(0., 0., sob_shift-EVgreaseLayer-PDbaseLayer, 
new TGeoRotation(0)));
 
  812   TGeoBBox* logicPixel = 
new TGeoBBox(
"logicPixel", PixelSize/2., PixelSize/2., PDsensitiveThick/2.);
 
  813   TGeoVolume* pix = 
new TGeoVolume(
"DrcPDSensor",logicPixel, FusedSil_m);
 
  814   pix->SetLineColor(kGreen+1);
 
  817   TGeoBBox* logicPixelHolder = 
new TGeoBBox(
"logicPixelHolder", MCPactiveArea/2., MCPactiveArea/2., PDsensitiveThick/2.); 
 
  818   TGeoVolume *pixelholder  = 
new TGeoVolume(
"DrcPixelHolder", logicPixelHolder,  DIRCcarbonFiber_m);
 
  819   pixelholder->SetLineColor(kOrange-8);
 
  822  for(Int_t itr=0; itr<Npix; itr++){
 
  823    Double_t dy_row = (-Npix/2 + itr)*(PixelSize + PixelGap) + 0.5*(PixelSize+PixelGap);
 
  824    for(Int_t jtr=0; jtr<Npix; jtr++){
 
  825     Double_t dx_row = (-Npix/2 + jtr)*(PixelSize + PixelGap) + 0.5*(PixelSize+PixelGap);              
 
  826     pixelholder->AddNode(pix, itr*Npix+jtr, 
new TGeoCombiTrans(dx_row, dy_row, 0., 
new TGeoRotation(0)));
 
  831   TGeoBBox* logicPhCathode = 
new TGeoBBox(
"logicPhCathode", MCPactiveArea/2., MCPactiveArea/2., PhCathodeThick/2.); 
 
  832   TGeoVolume *phcathode  = 
new TGeoVolume(
"DrcPhCathodeSensor", logicPhCathode,  FusedSil_m);
 
  833   phcathode->SetLineColor(kGray+1);
 
  836   TGeoBBox* logicWindow = 
new TGeoBBox(
"logicWindow", MCPsize/2., MCPsize/2., PDwindowThick/2.); 
 
  837   TGeoVolume *window  = 
new TGeoVolume(
"DrcPDwindowSensor", logicWindow,  FusedSil_m);
 
  838   window->SetLineColor(kBlue-4);
 
  841   TGeoBBox* logicMCPgrease = 
new TGeoBBox(
"logicMCPgrease", MCPsize/2., MCPsize/2., PDgreaseLayer/2.); 
 
  842   TGeoVolume *mcpgrease  = 
new TGeoVolume(
"DrcMcpGrease", logicMCPgrease,  OpticalGrease_m);
 
  843   mcpgrease->SetLineColor(kSpring);
 
  846   Double_t hgap = 0.5*(MCPsize - MCPactiveArea + MCPgap);
 
  847   Double_t step = MCPactiveArea + 2.*hgap;  
 
  852   Double_t xsmall, xlarge, lastxsmall;
 
  854   cout<<
"hgap = "<<hgap<<
", step = "<<step<<endl;
 
  855   xpos = radiusCornerIn + 0.5*MCPactiveArea;
 
  860   for(Int_t nquat =0; nquat<4; nquat++){
 
  861     for(Int_t i=0; i<Int_t((radiusCornerOut)/step); i++){  
 
  862       cas1 = 
findSectorIn(ypos-step/2., dphi_rad, radius, EVdrop, hthick);
 
  863       cout<<
"+++++++++++++++ nquat = "<<nquat<<
", i = "<<i<<
", xpos = "<<xpos<<
", ypos = "<<ypos<<endl;
 
  864       cout << 
"calculated sector1 from  y =" << ypos << 
" is " << cas1 << endl;
 
  865       getXrange(dphi, radiusCornerOut+1.3, radiusCornerIn, MCPactiveArea, cas1, cas2, ypos-(step/2.), step, xsmall, xlarge);
 
  868         for(Int_t j=0; j<TMath::Ceil((xlarge-xsmall)/step); j++){     
 
  869         cout<<
"j = "<<j<<
". quat = "<<nquat<<
", xsmall = "<<xsmall<<
", xlarge = "<<xlarge<<
", cas1 = "<<cas1<<
", limit = "<<(Int_t((xlarge-xsmall)/step))+1<<endl;    
 
  871           if(nquat == 1 || nquat == 2){
 
  874           if(nquat == 0 || nquat == 3){
 
  877           if(nquat == 0 || nquat == 1){
 
  880           if(nquat == 2 || nquat == 3){
 
  884           pdbase->AddNode(phcathode, TotalNmcp, 
new TGeoCombiTrans(xcurr, ycurr, PDbaseLayer-PDgreaseLayer-PhCathodeThick/2.-PDwindowThick, 
new TGeoRotation(0)));       
 
  886           pdbase->AddNode(window, TotalNmcp, 
new TGeoCombiTrans(xcurr, ycurr, PDbaseLayer-PDgreaseLayer-PDwindowThick/2., 
new TGeoRotation(0)));        
 
  888           pdbase->AddNode(mcpgrease, TotalNmcp, 
new TGeoCombiTrans(xcurr, ycurr, PDbaseLayer-PDgreaseLayer/2., 
new TGeoRotation(0)));
 
  890           pdbase->AddNode(pixelholder, TotalNmcp, 
new TGeoCombiTrans(xcurr, ycurr, PDbaseLayer-PDgreaseLayer-PDwindowThick-PhCathodeThick-PDsensitiveThick/2., 
new TGeoRotation(0)));   
 
  891           TotalNmcp = TotalNmcp + 1;
 
  895         cas2 = 
findSectorOut(ypos+step/2., dphi_rad, radiusCornerOut);
 
  896         cout<<
"calculated sector2 from y = "<<ypos+step/2. << 
" is "<< cas2<<endl;  
 
  898         if(i == 12){ypos = step/2.;cas2 = 1;}   
 
  902   cout<<
"version 1: totally "<<TotalNmcp+1<<
" mcps on the PD plane"<<endl;  
 
  954   cave->CheckOverlaps(0.0001, 
"");
 
  963   TObjArray *listOfOverlaps = 
gGeoManager->GetListOfOverlaps();
 
  964   cout<<listOfOverlaps->GetEntries()<<endl;
 
static T ASin(const T &x)
friend F32vec4 cos(const F32vec4 &a)
friend F32vec4 sin(const F32vec4 &a)
TGeoManager * gGeoManager
double eps(TVector3 v1, TVector3 v2)
int findSectorOut(double y, double dphi_rad, double radiusCornerOut)
friend F32vec4 fabs(const F32vec4 &a)
void getXrange(double dphi, double radiusCornerOut, double radiusCornerIn, double MCPactiveArea, int cas1, int cas2, double ylow, double step, double &x1, double &x2)
int findSectorIn(double y, double dphi, double radius, double EVdrop, double hthick)