FairRoot/PandaRoot
createdirc_prism.C
Go to the documentation of this file.
1 // macro that creates the Barrel DIRC geometry
2 
3 // input parameters are:
4 // fEvType = 1 - tank type with 90 degree PD
5 // fEvType = 2 - tank type with curved PD
6 // fEvType = 3 - prism type
7 
8 
9 // fFocusingSystem = 0 - no focusing is used
10 // fFocusingSystem = 1 - lens
11 // fFocusingSystem = 11 - one component lens with air gap
12 // fFocusingSystem = 15 - half of 11
13 // fFocusingSystem = 2 - forward mirror is used
14 // fFocusingSystem = 3 - cylindrical
15 // fFocusingSystem = 31 - wide cylindrical
16 // fFocusingSystem = 33 - wide three component cylindrical lens (same as 6 but cylindrical)
17 // fFocusingSystem = 34 - half of 33
18 // fFocusingSystem = 35 - half of two component cylindrical lens (one for each bar)
19 // fFocusingSystem = 36 - half of two component wide cylindrical lens (single lens for the bar box)
20 // fFocusingSystem = 4 - two component spherical lens is used
21 // fFocusingSystem = 45 - half of two component spherical lens
22 // fFocusingSystem = 6 - three component spherical lens is used
23 
24 // par1 and par2 - lens radii
25 // par3 - EVdrop [cm]
26 // par4 - EVoffset [cm]
27 // par5 - bottom tilt of the EV [degrees]
28 // par6 - depth of the EV [cm]
29 // par7 - EV back angle [degrees]
30 // par8 - number of mcp rows
31 // par9 - free parameter
32 
33 const Double_t pi = 4.*atan(1.);
34 
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){
36 
37  { // initialization
38  TString vmcWorkdir = getenv("VMCWORKDIR");
39 
40  // Load this libraries
41  gSystem->Load("libGeoBase");
42  gSystem->Load("libParBase");
43  gSystem->Load("libBase");
44  gSystem->Load("libPndData");
45  gSystem->Load("libPassive");
46 
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);
49 
50  // variable to achieve the DIRC basic parameters
51  PndGeoDrc* fGeo = new PndGeoDrc();
52 
53  // units = cm
54 
55  Double_t eps = 0.01; // epsilon
56  Double_t mirr_hthick = 0.02;
57  Double_t PDbaseLayer = 0.2; // [cm] thickness of the carbon at the back of the EV
58 
59  //parameters for MCPs:
60  Int_t mcpRows = (fMcpRows==40)? 4 : fMcpRows;
61  Double_t MCPsize = fGeo->McpSize();//5.76; //[cm] width=height of an MCP
62  Double_t MCPactiveArea = fGeo->McpActiveArea();//5.3; //[cm] width=height of the active area of an MCP
63  Double_t MCPgap = fGeo->McpGap(); //[cm] gap between MCPs
64  Double_t PixelSize = fGeo->PixelSize();//0.65; //[cm] size of a pixel
65  Int_t Npix = 8; // number of mcps in a row/column
66  const Int_t NpixTotal = Npix*Npix; // total number of pixels for 1 mcp
67  Double_t PixelGap = (MCPactiveArea - Double_t(Npix)*PixelSize)/(Double_t(Npix)-1.);
68  Double_t PDwindowThick = 0.1; //[cm]
69  Double_t CathodeThick = 0.01; //0.0001; //[cm] = 1 um
70  Double_t PDsensitiveThick = 0.05; // 0.01; //[cm]
71  Double_t PDgreaseLayer = fGeo->GreaseLayer(); //= 0.1; //[cm]
72  Double_t hgap = 0.5*(MCPsize - MCPactiveArea + MCPgap); // gap btw MCPs
73  Double_t step = MCPactiveArea + 2.*hgap; // step in which to locate MCPs = 6 for Mcp1, Mcp2; = 5.88 for Mcp2a. This is total size of one MCP with gaps in between
74 
75  Double_t prismWidth = 16; //2*(3*step/2. - hgap);
76  Double_t radius = fGeo->radius(); // 47.6 radius in middle of the barbox (x and y)
77  Double_t hthick = fGeo->barHalfThick(); // 1.7/2. half thickness of the bars
78  Double_t barhgap = fGeo->barhGap(); // 0.01 half gap between bars
79  Double_t boxgap = fGeo->boxGap(); // 0.1 gap between bars and the bar box
80  Double_t barwidth = 5.3; //(prismWidth-0.6)/(Double_t)fNBars; // 3.2 width of the radiator bar
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;
86 
87  Double_t bbnum = fGeo->BBoxNum(); //16. total number of sides = barboxes
88  Double_t bbGapAngle = fGeo->BBoxGap(); //1.5 gap btw the neighboring barboxes (at the middle height)
89  Double_t pipehAngle = fGeo->PipehAngle(); //3.6 [degrees] half of the angular space needed for the target pipe
90  Double_t barWin_hthick = 0.001/2.; //0.1/2.; // [cm]=15um thickness of the 'glas' window at the readout end of the barbox;
91  Double_t phi0 = (180.-2.*pipehAngle)/bbnum + pipehAngle;
92  Double_t dphi = (180.-2.*pipehAngle)/bbnum*2.;
93  Double_t dphi_rad = dphi/180.*pi;
94 
95  Double_t bbox_zdown = fGeo->barBoxZDown(); // 130. bar box z downstream
96  Double_t bbox_zup = fGeo->barBoxZUp(); // -120. bar box z upstream
97  Double_t bbox_hlen = 0.5*(bbox_zdown - bbox_zup); // 125. bar box half length
98  Double_t bbox_shift = bbox_zup + bbox_hlen; // 5. bar box shift
99  Double_t boxthick = fGeo->boxThick(); // 0.05 thickness of the bar box
100  Double_t gluehthick = fGeo->GlueLayer();// = 0.0005;//[cm] // glue layer, connects two halfs into one long radiator bar
101  Double_t len1,len2, len, lenm = 0.; // length of the lenses block. see further
102  Double_t fdz_mirr1 = 0.;
103  Double_t fdz_mirr2 = 0.;
104  Double_t fdz_lens3 = 0.;
105  Double_t fdz_lens2 = 0.;
106  Double_t fdz_lens1 = 0.;
107 
108  // EV parameters
109  Double_t sob_len = (par6==-100)? fGeo->EVlen() : par6; // 30. in current version
110  Double_t sob_shift = -bbox_hlen + bbox_shift - sob_len; // -150.
111  Double_t sob_angleB = (par7==-100)? fGeo->EVbackAngle() : par7; //90. [degrees] angle of the EV (usually it is 90)
112  if(fEvType==2) sob_angleB = 90;
113  Double_t EVdrop = (par3==-100)? fGeo->EVdrop(): par3; // drop of the EV - inner radius
114  if(fEvType<3) EVdrop += boxgap+boxthick;
115  Double_t EVoffset = (par4==-100)? fGeo->EVoffset() : par4; // offset of the EV - outer radius
116  Double_t EVgreaseLayer = 0.0015/2.; //[cm] grease layer half thickness btw the bar window and the EV
117 
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;
120 
121  Double_t barBoxWidth = 0.5*fNBars*(barwidth+2.*barhgap)+bbSideGap+boxthick;
122  Double_t barBoxHeight = hthick+boxgap+boxthick;
123 
124  Double_t sob_angle = atan((5*step + 2*hgap-2*hthick -EVoffset-EVdrop)/sob_len)/pi*180.;// [degrees] opening angle of the EV
125  Double_t sob_Rout = radius-hthick + 5*step -2*hgap-EVdrop;
126 
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;
130  Double_t coverthick = 0.1;
131 
132  Double_t mirrorAngle = (par8==-100)? 0 : par8; // tilt of the Mirror
133 
134 
135  // cout<<"radius = "<<radius<<"rad corner in = "<< radiusCornerIn<<", rad corner out = "<< radiusCornerOut<<endl; cout<<"pixel gap = "<< PixelGap<<endl;
136  // cout<<"sob_angle = "<<sob_angle<<endl;
137  cout<<"sob_Rout = "<<sob_Rout<<endl;
138  // cout<<"bbAngle = "<<bbAngle<<", bbX = "<<bbX<<endl;
139  // cout<<"dphi = "<<dphi<<", phi0 = "<<phi0<<endl;
140  //----------------------------------------------------------
141 
142  Double_t entranceh = 4; //4
143  // prism:
144  Double_t prismheight1= 4; //4
145  Double_t phlength = 5;//fGeo->PrismhLength(); //4.5 [cm] half length of the prism
146  Double_t pdrop = 1; //fGeo->PrismDrop(); //0.5 [cm] drop of the prism - inner side
147  Double_t pangle = fGeo->PrismAngle(); //30. [degrees] angle of the edge
148  Double_t poffset = fGeo->PrismOffset(); //1.[cm] prism offset - outer side
149  Double_t pheight = 2.*phlength * tan(pangle/180.*pi); // [cm] half heigth of the prism
150  Double_t sob_Rprism = radius + hthick + poffset + pheight + EVoffset + (sob_len-2.*phlength)*tan(60./180.*pi);
151  //----------------------------------------------------------
152 
153  // Rotations:
154  TGeoRotation rot1;
155  rot1.RotateZ(90.);
156 
157  TFile* fi = new TFile(fGeoFile,"RECREATE");
158  cout<<"Output file = "<<fGeoFile<<endl;
159 
160  Double_t par[10];
161  Double_t aa;
162  Double_t z, density, radl, absl, w;
163  Int_t nel, numed, nz;
164 
165  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
166  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
167  geoFace->setMediaFile(vmcWorkdir +"/geometry/media_pnd.geo");
168  geoFace->readMedia();
169 
170  FairGeoMedia *Media = geoFace->getMedia();
171  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();
172 
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");
186 
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);
200 
201  }
202 
203  TGeoVolume *CylLensWide1, *CylLensWide2, *Lens1, *Lens2, *Lens3, *Lens4;
204  Double_t halfshift = 0, halfheight = 0.5*entranceh;
205  { // focusing systems
206  if(fFocusingSystem == 0){ // no focusing
207  }
208 
209  if(fFocusingSystem == 1){ // 1L spherical lens with airgap
210  Double_t cr1(0.5*2);
211  Double_t r1 = 10;
212 
213  barWin_hthick=0;
214 
215  Double_t lenspw=barwidth+2*barhgap;
216  cr1=sqrt(lenspw*lenspw/4.+cr1*cr1);
217  Double_t min(0.2);
218  len=2*min+r1-sqrt(r1*r1-cr1*cr1);
219  std::cout<<"thicknes of the lens: "<< len <<std::endl;
220 
221  // =============== part1
222  TGeoSphere* lsr1 = new TGeoSphere("sr1",0 ,r1, 0. ,180.,0.,360.);
223  TGeoEltu* lcr1 = new TGeoEltu("cr1", cr1, cr1, 0.5*len);
224 
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);
230 
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);
234  tm1->SetName("tm1");
235  tm1->RegisterYourself();
236 
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);
240 
241  // =============== part2
242  TGeoTranslation tr3("tr3", 0., 0.,-min);
243  TGeoHMatrix *tm3 = new TGeoHMatrix(tr3);
244  tm3->SetName("tm3");
245  tm3->RegisterYourself();
246 
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);
250  }
251 
252  if(fFocusingSystem == 2){ // 2L spherical lense
253  Double_t cr1(0.5*2);
254  Double_t r1 = 7.3;//30; // [cm]
255 
256  barWin_hthick=0;
257 
258  Double_t lenspw=barwidth+2*barhgap;
259  cr1=sqrt(lenspw*lenspw/4.+cr1*cr1);
260  Double_t min(0.2);
261  len=2*min+r1-sqrt(r1*r1-cr1*cr1);
262  std::cout<<"thicknes of the lens: "<< len <<std::endl;
263 
264  // =============== part1
265  TGeoSphere* lsr1 = new TGeoSphere("sr1",0 ,r1, 0. ,180.,0.,360.);
266  TGeoEltu* lcr1 = new TGeoEltu("cr1", cr1, cr1, 0.5*len);
267 
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);
273 
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);
277  tm1->SetName("tm1");
278  tm1->RegisterYourself();
279 
280  TGeoCompositeShape *cslens1 = new TGeoCompositeShape("cslens1","cr1*(sr1:tm1)*BoxH*BoxW");
281  TGeoVolume *Lens1 = new TGeoVolume("DrcLENS1Sensor",cslens1, gGeoManager->GetMedium("NLAK33A"));//FusedSil //NLAK33A //DIRCairNoSens
282  Lens1->SetLineColor(kBlue);
283 
284  // =============== part2
285  TGeoTranslation tr3("tr3", 0., 0.,-min);
286  TGeoHMatrix *tm3 = new TGeoHMatrix(tr3);
287  tm3->SetName("tm3");
288  tm3->RegisterYourself();
289 
290  TGeoCompositeShape *cslens3 = new TGeoCompositeShape("cslens2","(BoxA:tm3)*BoxB-(sr1:tm1)");
291  TGeoVolume *Lens2 = new TGeoVolume("DrcLENS2Sensor",cslens3, gGeoManager->GetMedium("FusedSil"));//FusedSil //NLAK33A //DIRCairNoSens
292  Lens2->SetLineColor(kBlue+2);
293  }
294 
295  if(fFocusingSystem == 3){ // 2L cylindrical lens
296 
297  if(fFocusingSystem == 35) {
298  halfheight = hthick;
299  halfshift = -hthick;
300  }
301 
302  Double_t hlens1 = 0.4; //[cm] thickness in the middle of the first (focising) (FusedSil) lens
303  Double_t hlens2 = 0.2; //[cm] thickness in the middle of the second (defocusing) (FusedSil) lens
304  Double_t rlens = 7.35; // [cm]
305  Double_t llens = 0.5*prismWidth;
306  len = hlens1+hlens2;
307 
308  //lens1
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);
321 
322  fdz_lens1 = -bbox_hlen - barWin_hthick; // + 3*barWin_hthick - len/2. + rlens;
323 
324  //lens2
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();
330 
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);
335 
336  }
337 
338  if(fFocusingSystem == 4){ // 3L cylindrical lens
339 
340  Double_t cr1(0.5*2);
341  // Double_t r1 = 4.78;//30; // [cm]
342  // Double_t r2 = 2.91;//7; // [cm]
343 
344  Double_t r1 = 9.5;
345  Double_t r2 = 5;
346 
347  barWin_hthick=0;
348 
349  if(fNBars==3 || fNBars==4){
350  // r1 = 11;
351  // r2 = 4;
352  r1 = 9.5;
353  r2 = 5;
354  }
355  if(fNBars==2){
356  r1 = 12;
357  r2 = 6;
358  }
359  if(fNBars==1){
360  r1 = 12;
361  r2 = 6;
362  }
363 
364  r1 = (par1==-100)? r1: par1;
365  r2 = (par2==-100)? r2: par2;
366 
367  Double_t lenspw=barwidth+2*barhgap;
368  Double_t min(0.2);
369  len=2*min+r2-sqrt(r2*r2-cr1*cr1)+min;
370  std::cout<<"thicknes of the lens: "<< len <<std::endl;
371 
372  // =============== part1
373  TGeoEltu* lsr1 = new TGeoEltu("sr1",r1, r1, lenspw);
374  TGeoEltu* lsr2 = new TGeoEltu("sr2",r2, r2, lenspw);
375 
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);
379 
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);
382 
383  TGeoBBox* lBoxA = new TGeoBBox("BoxA", 0.5*lenspw+10, 0.5*entranceh+10,len);
384 
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);
388  tm1->SetName("tm1");
389  tm1->RegisterYourself();
390 
391  TGeoCompositeShape *cslens1 = new TGeoCompositeShape("cslens1","(sr1:tm1)*BoxH*BoxW");
392  TGeoVolume *Lens1 = new TGeoVolume("DrcLENS1Sensor",cslens1, gGeoManager->GetMedium("FusedSil"));//FusedSil //NLAK33A //DIRCairNoSens
393  Lens1->SetLineColor(kBlue+2);
394 
395  // =============== part2
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);
398  tm2->SetName("tm2");
399  tm2->RegisterYourself();
400 
401  TGeoCompositeShape *cslens2 = new TGeoCompositeShape("cslens2","(sr2:tm2)*BoxH1*BoxW1-(sr1:tm1)*BoxH*BoxW");
402  TGeoVolume* Lens2 = new TGeoVolume("DrcLENS2Sensor", cslens2, gGeoManager->GetMedium("PBF2"));// NLAK33A //FusedSil //BK7G18 //PBF2 //NLAK33A
403  Lens2->SetLineColor(kBlue);
404 
405  // =============== part3
406  TGeoTranslation tr3("tr3", 0., 0.,-2*min);
407  TGeoHMatrix *tm3 = new TGeoHMatrix(tr3);
408  tm3->SetName("tm3");
409  tm3->RegisterYourself();
410 
411  TGeoCompositeShape *cslens3 = new TGeoCompositeShape("cslens3","(BoxA:tm3)*BoxB-(sr2:tm2)");
412  TGeoVolume *Lens3 = new TGeoVolume("DrcLENS3Sensor",cslens3, gGeoManager->GetMedium("FusedSil"));//FusedSil //NLAK33A //DIRCairNoSens
413  Lens3->SetLineColor(kBlue+2);
414 
415  }
416 
417  if(fFocusingSystem == 6){ // 3L spherical lens
418 
419  Double_t cr1(0.5*2);
420  // Double_t r1 = 4.78;//30; // [cm]
421  // Double_t r2 = 2.91;//7; // [cm]
422 
423  Double_t r1 = 9.5;
424  Double_t r2 = 5;
425 
426  barWin_hthick=0;
427 
428  if(fNBars==3 || fNBars==4){
429  // r1 = 11;
430  // r2 = 4;
431  r1 = 9.5;
432  r2 = 5;
433  }
434  if(fNBars==2){
435  r1 = 12;
436  r2 = 6;
437  }
438  if(fNBars==1){
439  r1 = 20;
440  r2 = 10;
441  }
442 
443  r1 = (par1==-100)? r1: par1;
444  r2 = (par2==-100)? r2: par2;
445 
446  Double_t lenspw=barwidth+2*barhgap;
447  cr1=sqrt(lenspw*lenspw/4.+cr1*cr1);
448  Double_t min(0.2);
449  len=2*min+r2-sqrt(r2*r2-cr1*cr1)+min;
450  std::cout<<"thicknes of the lens: "<< len <<std::endl;
451 
452  // =============== part1
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);
456 
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);
462 
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);
466  tm1->SetName("tm1");
467  tm1->RegisterYourself();
468 
469  TGeoCompositeShape *cslens1 = new TGeoCompositeShape("cslens1","cr1*(sr1:tm1)*BoxH*BoxW");
470  TGeoVolume *Lens1 = new TGeoVolume("DrcLENS1Sensor",cslens1, gGeoManager->GetMedium("FusedSil"));//FusedSil //NLAK33A //DIRCairNoSens
471  Lens1->SetLineColor(kBlue+2);
472 
473  // =============== part2
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);
476  tm2->SetName("tm2");
477  tm2->RegisterYourself();
478 
479  TGeoCompositeShape *cslens2 = new TGeoCompositeShape("cslens2","(((sr2:tm2)*cr1)-(sr1:tm1))*BoxH*BoxW");
480  TGeoVolume* Lens2 = new TGeoVolume("DrcLENS2Sensor", cslens2, gGeoManager->GetMedium("PBF2"));// NLAK33A //FusedSil //BK7G18 //PBF2 //NLAK33A
481  Lens2->SetLineColor(kBlue);
482 
483  // =============== part3
484  TGeoTranslation tr3("tr3", 0., 0.,-2*min);
485  TGeoHMatrix *tm3 = new TGeoHMatrix(tr3);
486  tm3->SetName("tm3");
487  tm3->RegisterYourself();
488 
489  TGeoCompositeShape *cslens3 = new TGeoCompositeShape("cslens3","(BoxA:tm3)*BoxB-(sr2:tm2)");
490  TGeoVolume *Lens3 = new TGeoVolume("DrcLENS3Sensor",cslens3, gGeoManager->GetMedium("FusedSil"));//FusedSil //NLAK33A //DIRCairNoSens
491  Lens3->SetLineColor(kBlue+2);
492 
493  }
494 
495  if(fFocusingSystem == 15){ // Mirrors at front
496 
497  halfheight = hthick;
498  Double_t hlens1 = 0.1; //[cm] thickness in the middle of the first (focising) (FusedSil) lens
499  Double_t hlens2 = 0.1; //[cm] thickness in the middle of the second (defocusing) (FusedSil) lens
500  Double_t rlens = 500; // [cm]
501  rlens = (par1==-100)? rlens: par1;
502  Double_t llens = barwidth/2.;
503  lenm = (hlens1+hlens2)/2.;
504 
505  //lens1
506  TGeoSphere* lSphUp = new TGeoSphere("SphUp",0 ,rlens, 0. ,180.,0.,360.);
507  TGeoBBox* lCylBox = new TGeoBBox("LensBox", llens, halfheight, lenm);
508 
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();
515 
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);
520 
521  fdz_lens1 = -bbox_hlen + 3*barWin_hthick - lenm/2. + rlens;
522 
523  //lens2
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();
529 
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);
534  }
535 
536  // {
537  // TGeoVolume *top = gGeoManager->MakeBox("DIRC",gGeoManager->GetMedium("air"),100,100,100);
538  // top->AddNode(Lens1, 1, new TGeoCombiTrans(0, 0, +len2, new TGeoRotation(0)));
539  // top->AddNode(Lens2, 2, new TGeoCombiTrans(0, 0, +len2, new TGeoRotation(0)));
540  // top->AddNode(Lens3, 3, new TGeoCombiTrans(0, 0, -len1, new TGeoRotation(0)));
541 
542  // //gGeoManager->SetTopVolume(top);
543  // //gGeoManager->CloseGeometry();
544  // gGeoManager->SetNsegments(100);
545  // //top->CheckOverlaps(0.0001, "");
546  // //gGeoManager->CheckOverlaps(0.00001,"");
547  // //top->Write();
548  // //fi->Close();
549  // top->Draw("ogl");
550  // return;
551  // }
552 
553  }
554 
555  // create top volume:
556  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
557  gGeoManager->SetNsegments(100);
558 
559  TGeoBBox* lTop = new TGeoBBox(500,500,300);
560  TGeoVolume* top = new TGeoVolumeAssembly("BarrelDIRCa");
561  //new TGeoVolume("DIRC", lTop, gGeoManager->GetMedium("air"));
562  gGeoManager->SetTopVolume(top);
563 
564  // create pre-top volume:
565  TGeoVolume* vLocalMother;
566 
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;
571  TGeoPcon* shape;
572  if(fEvType != 1){
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.);
578  }else{
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.);
586  }
587  vLocalMother = new TGeoVolumeAssembly("BarrelDIRC");
588  vSupport = new TGeoVolumeAssembly("DrcSupport");
589  vBarBox = new TGeoVolumeAssembly("DrcBarBox");
590  //vLocalMother= new TGeoVolume("BarrelDIRC", shape, gGeoManager->GetMedium("DIRCairNoSens"));
591  top->AddNode(vLocalMother, 0,0);
592 
593 
594  Double_t entransewidth =0.5*len+barWin_hthick+EVgreaseLayer;
595  cout<<"entrance width = "<<entransewidth<<endl;
596  double aw = bbox_hlen+entransewidth;
597 
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); // gray
601 
602  //create BarBox
603  TGeoShape *lBarBoxCover, *lBarBoxAir;
604  if(mirrorAngle!=0){
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");
614 
615  TGeoBBox *lBarAirBox1 = new TGeoBBox("lBarAirBox1", barBoxWidth - 0.1, hthick + 0.1, bbox_hlen);
616  TGeoCompositeShape *lBarBoxAir = new TGeoCompositeShape("lBarBoxAir","lBarAirBox1 - lBarBox2:transfb1");
617 
618  }else{
619  lBarBoxCover = new TGeoBBox("lBarBoxCover", barBoxWidth, hthick+boxgap+boxthick, bbox_hlen);
620  lBarBoxAir = new TGeoBBox("lBarBoxAir", barBoxWidth - 0.1, hthick + 0.1, bbox_hlen);
621  }
622 
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);
628 
629  Double_t supportradius = 45.0;
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"));
636 
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();
647 
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);
651 
652  TGeoVolume *gBarBoxCover = new TGeoVolume("DrcBarBoxCover", lBarBoxCover,gGeoManager->GetMedium("DIRCcarbonFiber"));
653  gBarBoxCover->SetLineColor(30);
654 
655  TGeoVolume *gBarBoxAir = new TGeoVolume("DrcBarBoxAir", lBarBoxAir,gGeoManager->GetMedium("DIRCairNoSens"));
656  gBarBoxAir->SetLineColor(31);
657  gBarBoxCover->AddNode(gBarBoxAir, 0,0);
658 
659  // Layer of grease at the readout end of the bar boxes, between the windows and the EV
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);
663 
664  // Window at the readout end of the bar boxes
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);
668 
669  // Mirror
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);
673  Double_t mirrorCorr = 0;
674  if(mirrorAngle!=0) mirrorCorr = -0.5*mirr_hthick + 0.5*mirr_hthick/cos(mirrorAngle*pi/180.)-hthick*tan(mirrorAngle*pi/180.);
675 
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)));
679 
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)));
684  }
685 
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)));
688 
689  // put barboxes into right positions:
690  Double_t dx, dy, phi_curr;
691  Double_t dxs, dys, phi_currs;
692  Int_t supportid=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);
698 
699 
700  if(m==0 || m==8){
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)));
708  supportid++;
709  }
710 
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);
715 
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));
720 
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)));
723  supportid++;
724  }
725 
726  vSupport->AddNode(gSupport0, 0, new TGeoCombiTrans(0,0,bbox_zdown - bbox_hlen, new TGeoRotation(0)));
727  vLocalMother->AddNode(vSupport, 0, 0);
728 
729  TGeoShape *lBar;
730  if(mirrorAngle!=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");
740  }else{
741  lBar = new TGeoBBox("lBar", barwidth/2., hthick, bbox_hlen);
742  }
743 
744  TGeoVolume *bar = new TGeoVolume("DrcBarSensor",lBar, gGeoManager->GetMedium("FusedSil"));
745  bar->SetLineColor(kCyan-9);
746  bar->SetTransparency(60);
747 
748  // create glue layer inside the bar (connects two halves):
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)));
753 
754  for(Int_t j=0; j<fNBars; j++){
755  dx = - (bbX/2.) - bbSideGap + (j+0.5) * (barwidth+2.*barhgap);
756  dy = 0;
757  gBarBoxAir->AddNode(bar, j, new TGeoCombiTrans(dx, dy,-lenm, new TGeoRotation(0)));
758 
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)));
763  }
764 
765  if(fFocusingSystem == 5) { //forward lens
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)));
768  }
769  }
770 
771  { // Expansion volume:
772 
773  TGeoPgon* logicEV1, * logicEV2, *logicEV3, * logicEV4;
774  TGeoPgon* logicEV1c, * logicEV2c, *logicEV3c, * logicEV4c;
775  TGeoPgon* logicEV1s, * logicEV2s, *logicEV3s, * logicEV4s;
776  TGeoPgon* logicEV1b, * logicEV2b, *logicEV3b, * logicEV4b;
777 
778  Double_t cosFactor1 = cos(pipehAngle/180.*pi)/cos(dphi/180.*pi/2.);
779  Double_t dR = (radius+hthick+boxgap+boxthick)/cos(dphi/2./180.*pi) - (radius-hthick);
780  Double_t zEV = (5*step -2*hgap)*cos(sob_angleB*pi/180.);
781  Double_t hEV = (5*step -2*hgap)*sin(sob_angleB*pi/180.);
782  Double_t maxrz, evLocShift;
783 
784  Double_t
785  minrad = radiusMiddleSmall,
786  viscorrection = 0.000001, //fix visualization
787  mcptot = MCPsize + MCPgap,
788  alpharad = TMath::ATan(mcptot/sob_len),
789  steprad=0, stepz=0, currz = 0.;
790  Int_t totalnumbering = 0;
791  // PhotoDetector Basic material - Carbon. It is placed on the back side of the EV to simulate the support structure of the MCPs, the photons are to hit it in gaps between MCPs:
792  //TGeoVolume *pdbase;
793  TGeoVolumeAssembly *pdbase = new TGeoVolumeAssembly("DrcPDbase");
794 
795  { // cereate one MCP
796  //create pixel plates: one for each MCP:
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);
800 
801  // create photo cathodes for each MCP
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);
805 
806  // create Windows for each MCP
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);
810 
811  // create grease layers between MCP window and the EV back side
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);
815 
816 
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);
820 
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)));
825  }
826 
827  double btilt=(par5==-100)? 0 : par5*pi/180.;
828  double fixvisual = 0.000001;
829  double coverthickness = 0.05;
830  if(fEvType==1){
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);
844 
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);
857 
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);
875  }else{
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);
894  }
895 
896  TGeoCompositeShape *logicEV = new TGeoCompositeShape("logicEV","logicEV1 + logicEV3 + logicEV2 + logicEV4 ");
897  TGeoVolume* baseEV = new TGeoVolume("DrcEVSensor", logicEV, gGeoManager->GetMedium("Marcol82_7"));
898 
899  TGeoPgon *logicPDbase1, *logicPDbase2, *logicPDbase3, *logicPDbase4;
900 
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.),
926  addt-hgap,
927  addt-hgap+PDbaseLayer/cba);
928 
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);
933 
934 
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.),
939  addt-hgap,
940  addt-hgap+PDbaseLayer/cba);
941 
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);
946 
947 
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);
954 
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);
961 
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);
968 
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);
975 
976  }
977  if(sob_angleB <= 90.){
978  TGeoCompositeShape *logicPDbase = new TGeoCompositeShape("logicPDbase"," logicPDbase1 + logicPDbase2+ logicPDbase3 + logicPDbase4 ");
979  // pdbase = new TGeoVolume("DrcPDbase", logicPDbase, gGeoManager->GetMedium("DIRCcarbonFiber"));
980  // pdbase->SetLineColor(kGreen-6);
981  vLocalMother->AddNode(pdbase, 0, new TGeoCombiTrans(0., 0., sob_shift-2*sum-PDbaseLayer, new TGeoRotation(0)));
982  }
983 
984  TGeoCompositeShape *logicEVc = new TGeoCompositeShape("logicEVc","logicEV1c + logicEV3c + logicEV2c + logicEV4c ");
985  TGeoVolume* baseEVc = new TGeoVolume("DrcEVCoverSensor", logicEVc, gGeoManager->GetMedium("DIRCairNoSens"));
986 
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)));
989  { // PD plane
990  Double_t sectorWidth = 0.;
991  Int_t nmcp = 0;
992  TVector3 location;
993  Double_t phi_curr1 = 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.);
1001  }else{
1002  stepz = -pdthickness;
1003  }
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));
1007  // placement of MCPs in one sector
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;
1019  }
1020  if(sob_angleB != 90.){
1021  stepz += mcptot*cos(sob_angleB*pi/180.);
1022  steprad += -mcptot*(1-sin(sob_angleB*pi/180.));
1023  }
1024  }
1025  }
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.);
1030  }
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;
1041  }
1042  if(sob_angleB != 90.){
1043  stepz += mcptot*cos(sob_angleB*pi/180.);
1044  steprad += -mcptot*(1-sin(sob_angleB*pi/180.));
1045  }
1046  }
1047  }
1048  }
1049  }
1050  if(fEvType==2){
1051  { // EV
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); //fix visualization
1055  logicEV4 = new TGeoPgon("logicEV4", -90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 7);
1056 
1057  for(int i=0; i<6; i++){
1058  steprad = mcptot*TMath::Cos((i+1)*alpharad);
1059  stepz = mcptot*TMath::Sin((i+1)*alpharad);
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);
1065  minrad += steprad;
1066  currz += stepz;
1067  if(i==4) maxrz = currz;
1068  }
1069 
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);
1074 
1075 
1076  //small volume to constract EVcover
1077  minrad = radiusMiddleSmall;
1078  currz = 0.;
1079 
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); //fix visualization
1083  logicEV4s = new TGeoPgon("logicEV4s", -90 - pipehAngle-fixvisual, 2*(pipehAngle+fixvisual), 1, 7);
1084 
1085  Double_t airgap = 0.05, airdz=airgap/tan(pi/2.-alpharad);
1086  for(int i=0; i<6; i++){
1087  steprad = mcptot*TMath::Cos((i+1)*alpharad);
1088  stepz = mcptot*TMath::Sin((i+1)*alpharad);
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);
1094  minrad += steprad;
1095  currz += stepz;
1096  if(i==4) maxrz = currz;
1097 
1098  }
1099  airgap = 0.05;
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);
1104 
1105  //big volume to constract EVcover
1106  minrad = radiusMiddleSmall;
1107  mcptot = MCPsize + MCPgap;
1108  alpharad = TMath::ATan(mcptot/sob_len);
1109  currz = 0.;
1110 
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);
1115 
1116  Double_t tga,
1117  mcpcoverthick = 1;
1118  for(int i=0; i<6; i++){
1119  steprad = mcptot*TMath::Cos((i+1)*alpharad);
1120  stepz = mcptot*TMath::Sin((i+1)*alpharad);
1121 
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);
1126  if(i==5) {
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);
1133  }
1134  minrad += steprad;
1135  currz += stepz;
1136  if(i==4) maxrz = currz;
1137 
1138  }
1139 
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);
1144 
1145  TGeoCompositeShape *logicEV = new TGeoCompositeShape("logicEV","logicEV1 + logicEV3 + logicEV2 + logicEV4");
1146  TGeoVolume* baseEV = new TGeoVolume("DrcEVSensor", logicEV, gGeoManager->GetMedium("Marcol82_7"));
1147 
1148  TGeoCompositeShape *logicEVs = new TGeoCompositeShape("logicEVs","logicEV1s + logicEV3s + logicEV2s + logicEV4s"); //
1149  TGeoCompositeShape *logicEVb = new TGeoCompositeShape("logicEVb","logicEV1b + logicEV3b + logicEV2b + logicEV4b"); //
1150 
1151  TGeoCompositeShape *logicEVcover = new TGeoCompositeShape("logicEVcover","logicEVb - logicEVs");
1152  // pdbase = new TGeoVolume("DrcPDbase", logicEVcover, gGeoManager->GetMedium("DIRCcarbonFiber")); //DrcEVcover
1153  // pdbase->SetLineColor(kTeal-8);
1154  vLocalMother->AddNode(pdbase, 0, new TGeoCombiTrans(0., 0., sob_shift-2*sum, new TGeoRotation(0)));
1155  }
1156 
1157  vLocalMother->AddNode(baseEV, 0, new TGeoCombiTrans(0.,0.,sob_shift - 2*sum, new TGeoRotation(0)));
1158 
1159  { // PD plane
1160  Double_t sectorWidth = 0.;
1161  Int_t nmcp = 0;
1162  TVector3 location;
1163  Double_t phi_curr1 = 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; }
1167 
1168  stepz = mcptot*TMath::Sin(alpharad)/2.;
1169  steprad = mcptot*(1-TMath::Cos(alpharad))/2.;
1170 
1171  // placement of MCPs in one sector
1172  for(Int_t nrow=0; nrow < Int_t((sob_Rout+2*hgap-radiusMiddleSmall)/step); nrow++){
1173 
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));
1177 
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);
1185 
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;
1189  }
1190 
1191  stepz += mcptot*TMath::Sin((nrow+1)*alpharad)/2. + mcptot*TMath::Sin((nrow+2)*alpharad)/2.;
1192  steprad += mcptot*(1-TMath::Cos((nrow+1)*alpharad))/2. + mcptot*(1-TMath::Cos((nrow+2)*alpharad))/2.;
1193 
1194  }
1195  }
1196  }
1197  }
1198  if(fEvType>2){
1199  { //EV radius+hthick+boxgap+boxthick+EVoffset
1200 
1201  double sp = 2*(0.5*prismheight1+EVdrop/2.+EVoffset/2.);
1202  double evh = mcpRows*step - 2*hgap;
1203  Double_t omang(0);
1204  if(fEvType==4) {
1205  evh = 3*step - 2*hgap;
1206  omang=atan(MCPactiveArea/sob_len)*180./pi;
1207  }
1208 
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.;
1213 
1214  std::cout<<"h0 "<<prismheight1 <<" h1 "<<evh <<" w "<< prismWidth <<std::endl;
1215 
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);
1219 
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;
1222 
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();
1227 
1228  double covergap = 0.05;
1229  evwidth += covergap;
1230  sp += 2*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.;
1235 
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);
1239 
1240  evwidth +=coverthick;
1241  sp += 2*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.;
1246 
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);
1250 
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");
1254 
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"));
1260  }else {
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"));
1264  }
1265 
1266  baseEV0->SetLineColor(kCyan-2);// kMagenta+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);
1272  }
1273 
1274  TGeoBBox* logicPDbase = new TGeoBBox("logicPDbase", 3*step/2., mcpRows*step/2., PDbaseLayer/2.);
1275  Double_t pdLocShift = logicPDbase->GetDY() - 0.5*prismheight1 - hgap;
1276  // pdbase = new TGeoVolume("DrcPDbase", logicPDbase, gGeoManager->GetMedium("DIRCcarbonFiber"));
1277  // pdbase->SetLineColor(kGreen-6);
1278  // pdbase->SetTransparency(40);
1279 
1280  { //PD plane
1281  Double_t xcurr = 0., ycurr = 0.;
1282  for(Int_t i=0; i<mcpRows; i++){ // loop over y
1283  for(Int_t j=0; j<3; j++){ // loop over x
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;
1287 
1288  if(fMcpRows==40 && i==0) {
1289  xcurr = -0.5*(3.*step) + step+j*step;
1290  if(j==2) continue;
1291  }
1292 
1293  pdbase->AddNode(oneMCP, totalnumbering, new TGeoCombiTrans(xcurr, ycurr, PDbaseLayer/2.-(PDsensitiveThick+CathodeThick+PDwindowThick+PDgreaseLayer)/2., new TGeoRotation(0)));
1294  totalnumbering = totalnumbering + 1;
1295  }
1296  }
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.);
1301  }
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);
1307 
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));
1312 
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)));
1315  }
1316 
1317  }
1318  }
1319 
1320  baseEV->SetLineColor(kMagenta-9);
1321  baseEV->SetTransparency(50);
1322  }
1323 
1324  //if(pdbase) pdbase->SetTransparency(50);
1325 
1326  //gGeoManager->SetTopVisible();
1327  //pdbase->Draw("ogl"); return;
1328 
1329  if(false){
1330  TGeoSphere* l0 = new TGeoSphere("l0",0 ,150, 0. ,180.,0.,360.);
1331  top = new TGeoVolume("DIRC", lTop, gGeoManager->GetMedium("air"));
1332 
1333  gGeoManager->SetTopVolume(top);
1334  TGeoSphere* l1 = new TGeoSphere("l1",0 ,120, 0. ,180.,0.,360.);
1335  v1 = new TGeoVolume("v1", l1, gGeoManager->GetMedium("air"));
1336 
1337  TGeoSphere* l2 = new TGeoSphere("l2",0 ,100, 0. ,180.,0.,360.);
1338  v2 = new TGeoVolume("v2", l2, gGeoManager->GetMedium("FusedSil"));
1339 
1340  // v2->AddNode(Lens1, 0,new TGeoCombiTrans(0, 0, len2, new TGeoRotation(0)));
1341  // v2->AddNode(Lens2, 0,new TGeoCombiTrans(0, 0, len2, new TGeoRotation(0)));
1342  // v2->AddNode(Lens3, 0,new TGeoCombiTrans(0, 0, -len1, new TGeoRotation(0)));
1343  // v2->AddNode(Lens4, 0,new TGeoCombiTrans(0, 0, -len1, new TGeoRotation(0)));
1344 
1345  v2->AddNode(baseEV,0,0);
1346  v1->AddNode(v2, 0,0);
1347  top->AddNode(v1, 0,0);
1348  }
1349 
1350  gGeoManager->CloseGeometry();
1351  top->CheckOverlaps(0.0001, "");
1352  gGeoManager->CheckOverlaps(0.00001,""); // [cm]
1353  gGeoManager->SetNsegments(100);
1354  // gGeoManager->CheckGeometryFull();
1355  gGeoManager->SetVisLevel(5);
1356 
1357  top->Write();
1358  fi->Close();
1359 
1360  if(!gROOT->IsBatch()) top->Draw("ogl");
1361 
1362  TObjArray *listOfOverlaps = gGeoManager->GetListOfOverlaps();
1363  cout<<listOfOverlaps->GetEntries()<<endl;
1364  listOfOverlaps->Print();
1365  return 0;
1366 }
Int_t t1
Definition: hist-t7.C:106
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
Double_t EVbackAngle()
Definition: PndGeoDrc.h:148
double dy
Double_t GreaseLayer()
Definition: PndGeoDrc.h:88
Double_t BBoxNum()
Definition: PndGeoDrc.h:136
FairGeoLoader * geoLoad
Int_t i
Definition: run_full.C:25
FairGeoMedia * Media
__m128 m
Definition: P4_F32vec4.h:28
TGeoManager * gGeoMan
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
Double_t EVlen()
Definition: PndGeoDrc.h:127
static T Sin(const T &x)
Definition: PndCAMath.h:42
Double_t par[3]
double r1
Double_t BBoxGap()
Definition: PndGeoDrc.h:130
Double_t EVdrop()
Definition: PndGeoDrc.h:142
Double_t boxGap()
Definition: PndGeoDrc.h:116
TGeoManager * gGeoManager
static T Cos(const T &x)
Definition: PndCAMath.h:43
Double_t barBoxZDown()
Definition: PndGeoDrc.h:104
Double_t EVoffset()
Definition: PndGeoDrc.h:145
TGeoVolume * top
const Double_t pi
TGeoRotation * rot1
Double_t PipehAngle()
Definition: PndGeoDrc.h:139
Double_t PrismAngle()
Definition: PndGeoDrc.h:160
Double_t barBoxZUp()
Definition: PndGeoDrc.h:108
FairGeoBuilder * geobuild
TGeoShape * shape
TFile * fi
Double_t
Double_t phi0
Definition: checkhelixhit.C:60
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)
Double_t McpActiveArea()
Definition: PndGeoDrc.h:166
Double_t McpSize()
Definition: PndGeoDrc.h:163
vLocalMother
Double_t z
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
Double_t boxThick()
Definition: PndGeoDrc.h:120
Double_t barhGap()
Definition: PndGeoDrc.h:112
double dx
Double_t barHalfThick()
Definition: PndGeoDrc.h:96
Int_t t2
Definition: hist-t7.C:106
Double_t PrismOffset()
Definition: PndGeoDrc.h:151
TVector3 v1
Definition: bump_analys.C:40
TVector3 v2
Definition: bump_analys.C:40
FairGeoInterface * geoFace
Double_t par1[3]
Definition: reco_analys2.C:51
Double_t GlueLayer()
Definition: PndGeoDrc.h:84
TString fGeoFile
Double_t McpGap()
Definition: PndGeoDrc.h:169
Double_t PixelSize()
Definition: PndGeoDrc.h:175
double r2
Double_t radius()
Definition: PndGeoDrc.h:92