FairRoot/PandaRoot
Functions
create_HV_MAPS.C File Reference
#include <TROOT.h>
#include <FairGeoLoader.h>
#include <FairGeoInterface.h>
#include <FairGeoBuilder.h>
#include <FairGeoPcon.h>
#include <FairGeoMedia.h>
#include <TGeoCompositeShape.h>
#include <TGeoMatrix.h>
#include <TGeoVolume.h>
#include <TGeoTube.h>
#include <TGeoArb8.h>
#include <TGeoPara.h>
#include <TSystem.h>
#include <TFile.h>
#include <TGeoPcon.h>
#include <TGeoManager.h>
#include <TGeoTorus.h>
#include <TMath.h>
#include <iostream>
#include <cmath>
#include <sstream>
#include <TApplication.h>

Go to the source code of this file.

Functions

int create_HV_MAPS ()
 
int main ()
 

Function Documentation

int create_HV_MAPS ( )

Definition at line 30 of file create_HV_MAPS.C.

References angle, cos(), Double_t, fi, geobuild, geoFace, geoLoad, gGeoMan, Media, nmed, outfile, Pi, rot, sin(), sqrt(), SubunitVol, top, TString, and CAMath::TwoPi().

Referenced by main().

30  {
31  // Lumi Si-Set Parameter
32  //-----------------------------
33 
34  //vars for trap-builder
35  /*
36  const Int_t kNumTraps = 12;
37  const Double_t kTrapHalfAngle = TMath::Pi() / (Double_t) kNumTraps; // (rad)
38 
39  const Double_t kShortSide = 1.673 / 2.;//kTrapInnerDist * tan(kTrapHalfAngle);
40  const Double_t kLongSide = 5.921 / 2.;//kTrapOuterDist * tan(kTrapHalfAngle);
41 
42  const Double_t kTrapInnerDist = 3.2;//kShortSide / tan(kTrapHalfAngle);;//2.6; // (cm) //Dimension of Trapezoid
43  const Double_t kTrapOuterDist = kTrapInnerDist + 7.927;//kLongSide / tan(kTrapHalfAngle);;//11.; // (cm)
44 
45  const Double_t kTrapHigh = 7.927;//kTrapOuterDist - kTrapInnerDist;
46 */
47  /* DIGI PAR
48  top_pitch:Double_t 0.005
49  bot_pitch:Double_t 0.00625
50  orient:Double_t 1.308995833 75deg=90deg-kTrapHalfAngle orientation
51  skew:Double_t 0.523598333 30deg=2*kTrapHalfAngle stereo angle
52  top_anchor_x:Double_t -2.8125 #-4.142135624 -kLongSide+DeadZone
53  top_anchor_y:Double_t 3.96 #3.5 kTrapHigh/2
54  bot_anchor_x:Double_t -2.8125 #-4.142135624
55  bot_anchor_y:Double_t 3.96 #3.5
56  */
57 
58  //(pos_z - end_seg_upstream - tan(phi_bend/2.)*r_bend)*tan(phi_bend);
59 
60  Double_t kPlaneZPosition[4];
61  kPlaneZPosition[0] = 0.0; // (cm) //Dist to IP before rotating
62  kPlaneZPosition[1] = 20.0; // (cm) //
63  kPlaneZPosition[2] = 30.0; // (cm) //
64  kPlaneZPosition[3] = 40.0; // (cm) //
65 
66  //const Double_t kHalfFoilThickness = 0.0075; // Thickness of sensitive foil (cm)
67  // const Double_t kHalfFoilThickness = 0.0035; // Thickness of sensitive foil (cm) TEST
68  double end_seg_upstream = 360.1; // where bending starts with
69  double r_bend = 5750.; // the bending radius
70  double phi_bend = 40.068e-3; // and the angle of the circle path
71 
72  const Double_t kRot = phi_bend/3.141*180.;//=2.295727;//2.326; //(deg) //Rotate to dipol
73  // the point where both tangents of the straight beam pipe tubes meet is
74  const Double_t kRotUmZ = end_seg_upstream + tan(phi_bend/2.)*r_bend;//476.03; //(cm) //z-point to rotate
75  //const Double_t kRot = 0; //(deg) //Rotate to dipol TEST
76  // const Double_t kRotUmZ = 0; //(cm) //z-point to rotate TEST
77 
78  const Double_t kTransZ = 1130.; //(cm) //move at z-position
79 
80  //double end_seg_bend = end_seg_upstream+sin(phi_bend)*r_bend;
81  //(pos_z - end_seg_upstream - tan(phi_bend/2.)*r_bend)*tan(phi_bend);
82  const Double_t kTransX = (kTransZ - end_seg_upstream - tan(phi_bend/2.)*r_bend)*tan(phi_bend); // 25 (cm) //move at x-position
83  std::cout << " translation in x by " << kTransX << std::endl;
84 
85  //--------------------------------------------------------------------
86  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
87 
88  // Load this libraries
89  gSystem->Load("libGeoBase");
90  gSystem->Load("libParBase");
91  gSystem->Load("libBase");
92  gSystem->Load("libPndData");
93  gSystem->Load("libPassive");
94 
95  TString outfile = "geo/HV_MAPS-Design.root";
96  TFile* fi = new TFile(outfile, "RECREATE");
97 
98  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
99  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
100  geoFace->setMediaFile("../../geometry/media_pnd.geo");
101  geoFace->readMedia();
102  geoFace->print();
103 
104  FairGeoMedia *Media = geoFace->getMedia();
105  FairGeoBuilder *geobuild = geoLoad->getGeoBuilder();
106 
107  FairGeoMedium *FairMediumSilicon = Media->getMedium("silicon");
108 
109  Int_t nmed = geobuild->createMedium(FairMediumSilicon);
110 
111  TGeoManager* gGeoMan = (TGeoManager*) gROOT->FindObject("FAIRGeom");
112 
113  TGeoVolume *top = new TGeoVolumeAssembly("lmd_HV_MAPS");
114 
115  gGeoMan->SetTopVolume(top);
116 
117  // ****************************** cvd cooling support discs ************************
118 
119  // cvd_diamond is cut out of 80 mm discs of 200 micron thickness
120  const double inner_rad = 3.6; //4.5;
121  const double outer_rad = 9.;
122  const int n_cvd_discs = 6;
123  const double cvd_disc_rad = 4.;
124  const double cvd_disc_thick_half = 0.01;
125  // even and odd discs in a plane will be shifted in z in order to prevent
126  // mechanical damage during assembly
127  const double cvd_disc_even_odd_offset = 0.25;
128  // angle from the division of a circle into n_cvd_discs
129  const double delta_phi = TMath::TwoPi() / ((double) (n_cvd_discs));
130  // a polygon of n_cvd_discs sides fitting a radius of inner_rad
131  // has a side length pol_side_lg of
132  const double pol_side_lg_half = inner_rad * sin(delta_phi / 2.);
133  // the minimum distance to the center of the polygone is given by
134  const double pol_side_dist_min = inner_rad * cos(delta_phi / 2.);
135  // the cvd disc has to be placed such that the disc crosses
136  // the inner ring at an angle of 0 and delta_phi
137  // this defines the distance to the center according to pythagoras
138  const double cvd_disc_dist = pol_side_dist_min + sqrt(
139  cvd_disc_rad * cvd_disc_rad - pol_side_lg_half * pol_side_lg_half);
140  //std::cout << cvd_disc_dist << std::endl;
141 
142  // the cvd disc shape
143  TGeoTube* shape_cvd_disc = new TGeoTube("shape_cvd_disc", 0., cvd_disc_rad,
144  cvd_disc_thick_half);
145  // The inner beam pipe defines the inner acceptance region for the cvd cut_out
146  TGeoTube* shape_cvd_cutout_inner = new TGeoTube("shape_cvd_cutout_inner",
147  0., inner_rad, 1.);
148  // finally cvd discs will be cut at the left and right down to 60 degree in phi
149  // for that we subtract tube segments
150  TGeoTubeSeg* shape_cvd_disc_cut_left =
151  new TGeoTubeSeg("shape_cvd_disc_cut_left",0., outer_rad, 1., 0.,-delta_phi/2./TMath::Pi()*180.+90.);
152  TGeoTubeSeg* shape_cvd_disc_cut_right =
153  new TGeoTubeSeg("shape_cvd_disc_cut_right",0., outer_rad, 1.,+delta_phi/2./TMath::Pi()*180.+90., +180.);
154  // move the cvd disc to the upper position in the circular arrangement
155  TGeoRotation* cvd_rotation = new TGeoRotation("cvd_rotation", 0, 0, 0);
156  TGeoTranslation* cvd_translation = new TGeoTranslation("cvd_translation", 0, cvd_disc_dist, 0);
157  TGeoCombiTrans* cvd_combtrans = new TGeoCombiTrans(*cvd_translation, *cvd_rotation);
158  cvd_combtrans->SetName("cvd_combtrans");
159  cvd_combtrans->RegisterYourself();
160  // move boxes to cut at the angles
161  //TGeoRotation* cut_rotation_plus = new TGeoRotation("cut_rotation_plus ", 0., 0., +delta_phi/2./TMath::Pi()*180.);
162  //TGeoRotation* cut_rotation_minus = new TGeoRotation("cut_rotation_minus", 0., 0., -delta_phi/2./TMath::Pi()*180.);
163  //TGeoTranslation* cut_translation_plus = new TGeoTranslation("cut_translation_plus" , +5., 0, 0);
164  //TGeoTranslation* cut_translation_minus = new TGeoTranslation("cut_translation_minus", -5., 0, 0);
165  //TGeoCombiTrans* cut_combtrans_plus = new TGeoCombiTrans(*cut_translation_plus, *cut_rotation_plus);
166  //cut_combtrans_plus->SetName("cut_combtrans_plus");
167  //cut_combtrans_plus->RegisterYourself();
168  //TGeoCombiTrans* cut_combtrans_minus = new TGeoCombiTrans(*cut_translation_minus, *cut_rotation_minus);
169  //cut_combtrans_minus->SetName("cut_combtrans_minus");
170  //cut_combtrans_minus->RegisterYourself();
171  // construct the cut cvd diamond disc
172  TGeoCompositeShape *shape_cvd_support = new TGeoCompositeShape(
173  "shape_cvd_support", "(shape_cvd_disc:cvd_combtrans-shape_cvd_cutout_inner-shape_cvd_disc_cut_left-shape_cvd_disc_cut_right)");
174 
175  // *********************************** HV-MAPS *************************************
176 
177  // x = origin
178  //
179  // |---------|----------|----------| top
180  // ||------|-||-------|-||-------|-|
181  // || | || | || | |
182  // || | || x | || | |
183  // || | || active| || | |
184  // ||------|-||-------|-||-------|-|
185  // | | passive | |
186  // |---------|----------|----------| bottom
187  // left right
188  //
189  // A y; maps_n_row; height
190  // |
191  // |
192  // --> x; maps_n_col; width
193  //
194 
195  // NOTE: MOST of the following VARIABLES are HALF of it
196  // due to geometry construction in GEANT
197  const double maps_thickness = 0.005 / 2.;
198  const double maps_active_width = 2.0 / 2.;
199  const double maps_active_height = 1.9 / 2.;
200  const double maps_passive_top = 0.01 / 2.;//*12000.;
201  const double maps_passive_bottom = 0.1 / 2.;
202  const double maps_passive_left = 0.01 / 2.;//*6000.;
203  const double maps_passive_right = 0.01 / 2.;//*3000.;
204 
205  const double maps_width = maps_passive_left + maps_active_width + maps_passive_right ;
206  const double maps_height = maps_passive_top + maps_active_height + maps_passive_bottom;
207 
208  // even when several maps are placed on one die
209  // those will be placed in the simulation next to
210  // each other as separate detectors
211  const int maps_n_col = 3;
212  const int maps_n_row = 1;
213 
214  const double maps_die_widht = maps_width * maps_n_col;
215  const double maps_die_height = maps_height * maps_n_row;
216 
217  TGeoRotation* no_rotation = new TGeoRotation("no_rotation", 0, 0, 0);
218 
219  // create basic shapes and their positions
220  TGeoBBox *shape_maps_active_centered = new TGeoBBox("shape_maps_active_centered", maps_active_width, maps_active_height, maps_thickness);
221  TGeoCombiTrans* combtrans_maps_active =
222  new TGeoCombiTrans("combtrans_maps_active",
223  - maps_width + maps_passive_left*2. + maps_active_width,
224  - maps_height + maps_passive_bottom*2. + maps_active_height, 0., no_rotation);
225  combtrans_maps_active->RegisterYourself();
226  TGeoBBox *shape_maps_passive_left = new TGeoBBox("shape_maps_passive_left", maps_passive_left, maps_height, maps_thickness);
227  TGeoCombiTrans* combtrans_maps_passive_left =
228  new TGeoCombiTrans("combtrans_maps_passive_left", - maps_width + maps_passive_left, 0., 0., no_rotation);
229  combtrans_maps_passive_left->RegisterYourself();
230  TGeoBBox *shape_maps_passive_right = new TGeoBBox("shape_maps_passive_right", maps_passive_right, maps_height, maps_thickness);
231  TGeoCombiTrans* combtrans_maps_passive_right =
232  new TGeoCombiTrans("combtrans_maps_passive_right", maps_width - maps_passive_right, 0., 0., no_rotation);
233  combtrans_maps_passive_right->RegisterYourself();
234  TGeoBBox *shape_maps_passive_top = new TGeoBBox("shape_maps_passive_top", maps_width, maps_passive_top, maps_thickness);
235  TGeoCombiTrans* combtrans_maps_passive_top =
236  new TGeoCombiTrans("combtrans_maps_passive_top", 0., maps_height - maps_passive_top, 0., no_rotation);
237  combtrans_maps_passive_top->RegisterYourself();
238  TGeoBBox *shape_maps_passive_bottom = new TGeoBBox("shape_maps_passive_bottom", maps_width, maps_passive_bottom, maps_thickness);
239  TGeoCombiTrans* combtrans_maps_passive_bottom =
240  new TGeoCombiTrans("combtrans_maps_passive_bottom", 0., - maps_height + maps_passive_bottom, 0., no_rotation);
241  combtrans_maps_passive_bottom->RegisterYourself();
242 
243  TGeoCompositeShape *shape_maps_passive = new TGeoCompositeShape(
244  "shape_maps_passive", "(shape_maps_passive_top:combtrans_maps_passive_top+shape_maps_passive_right:combtrans_maps_passive_right+shape_maps_passive_bottom:combtrans_maps_passive_bottom+shape_maps_passive_left:combtrans_maps_passive_left)");
245 
246  TGeoCompositeShape *shape_maps_active = new TGeoCompositeShape(
247  "shape_maps_active", "(shape_maps_active_centered:combtrans_maps_active-shape_maps_passive)");
248 
249 
250  // **************************************************************
251 
252 
253 
254  //TGeoVolumeAssembly* SubunitVol_active = new TGeoVolumeAssembly("Lumi_HV-MAPS_active");
255  //TGeoVolumeAssembly* SubunitVol_passive = new TGeoVolumeAssembly("Lumi_HV-MAPS_passive");
256  TGeoVolumeAssembly* SubunitVol = new TGeoVolumeAssembly("Lumi_HV-MAPS");
257 
258  for (int i_plane = 0; i_plane < 4; i_plane++) {
259  std::stringstream plane_name;
260  plane_name << "plane_" << (i_plane + 1);
261  for (int i_cvd_disc = 0; i_cvd_disc < n_cvd_discs; i_cvd_disc++) {
262  double angle = /*delta_phi / 2. +*/ delta_phi * i_cvd_disc;
263  double offset_z = cvd_disc_even_odd_offset;
264  if ((i_cvd_disc%2)==0) offset_z = -offset_z;
265  std::stringstream disc_name;
266  disc_name << "LumPassive_cvd_disc_" << plane_name.str() << "_disc_"
267  << (i_cvd_disc + 1);
268  std::stringstream rot_name;
269  rot_name << "rot_" << plane_name.str() << "_disc_" << (i_cvd_disc
270  + 1);
271  Double_t dreh = angle/TMath::Pi()*180;// -i_cvd_disc * 360. / n_cvd_discs;
272  TGeoVolume* tmpvol = new TGeoVolume(disc_name.str().c_str(),
273  shape_cvd_support, gGeoMan->GetMedium("silicon"));//HYPdiamond"));
274  tmpvol->SetLineColor(16);
275  TGeoRotation* rot = new TGeoRotation(rot_name.str().c_str(), dreh,
276  0, 0);
277  TGeoTranslation* trt = new TGeoTranslation(
278  0, 0,
279  kTransZ + kPlaneZPosition[i_plane] + offset_z - kRotUmZ);
280  TGeoCombiTrans* trctmp = new TGeoCombiTrans(*trt, *rot);
281  trctmp->SetName((rot_name.str() + "_comb").c_str());
282  trctmp->RegisterYourself();
283  delete rot;
284  delete trt;
285  //SubunitVol_passive->AddNode(tmpvol, 0, trctmp);
286  SubunitVol->AddNode(tmpvol, 0, trctmp);
287  //break;
288  for (int iside = 0; iside < 2; iside++){ // modules are placed on both sides
289  // the modules at the back are aligned at the cut edges
290  // of the cvd discs
291  // the modules at the front are centered
292  for (int idie = 0; idie < 2; idie++){
293  for (int maps_col = 0; maps_col < maps_n_col; maps_col++){
294  for (int maps_row = 0; maps_row < maps_n_row; maps_row++){
295  // place active and passive volume
296  std::stringstream _module_name;
297  _module_name << "_plane_" << i_plane << "_disc_"<< i_cvd_disc;
298  _module_name << "_side_" << iside << "_die_" << idie;
299  _module_name << "_col_" << maps_col << "_row_" << maps_row;
300  //"LumActiveRect" is the keyword for digitization of hits
301  TGeoVolume* _vol_active = new TGeoVolume(("LumActivePixelRect"+_module_name.str()).c_str(),
302  shape_maps_active, gGeoMan->GetMedium("silicon"));
303  _vol_active->SetLineColor(36);
304  TGeoVolume* _vol_passive = new TGeoVolume(("LumPassiveRect"+_module_name.str()).c_str(),
305  shape_maps_passive, gGeoMan->GetMedium("silicon"));
306  _vol_passive->SetLineColor(30);
307  double _rot_z(0.);
308  double _trans_z(0.);
309  double _trans_y(0.);
310  double _trans_x(0.);
311  if (iside == 0){
312  _trans_z = - cvd_disc_thick_half - maps_thickness;
313  _trans_y = inner_rad + maps_col * maps_width*2. + maps_width;
314  if (idie == 0){
315  _rot_z = -90.;
316  _trans_x = maps_height + maps_row * maps_height*2.;
317  // rotate now to the right cvd disc angle
318  double temp_trans_x = _trans_x;
319  _trans_x = _trans_x * cos(angle) - _trans_y * sin(angle);
320  _trans_y = temp_trans_x * sin(angle) + _trans_y * cos(angle);
321  } else {
322  _rot_z = +90.;
323  _trans_x = - maps_height - maps_row * maps_height*2.;
324  // rotate now to the right edge
325  double temp_trans_x = _trans_x;
326  _trans_x = _trans_x * cos(angle) - _trans_y * sin(angle);
327  _trans_y = temp_trans_x * sin(angle) + _trans_y * cos(angle);
328  }
329  } else {
330  _trans_z = + cvd_disc_thick_half + maps_thickness;
331  _trans_y = inner_rad + maps_col * maps_width*2. + maps_width;
332  if (idie == 0){ // align to the cutted edges
333  _rot_z = -90. -delta_phi/2./TMath::Pi()*180.;
334  // place it left of the middle line
335  _trans_x = - maps_height - maps_row * maps_height*2.;
336  // rotate now to the right edge
337  double temp_trans_x = _trans_x;
338  _trans_x = _trans_x * cos(-delta_phi/2.+angle) - _trans_y * sin(-delta_phi/2.+angle);
339  _trans_y = temp_trans_x * sin(-delta_phi/2.+angle) + _trans_y * cos(-delta_phi/2.+angle);
340  } else {
341  _rot_z = +90. +delta_phi/2./TMath::Pi()*180.;
342  // place it right of the middle line
343  _trans_x = maps_height + maps_row * maps_height*2.;
344  // rotate now to the left edge
345  double temp_trans_x = _trans_x;
346  _trans_x = _trans_x * cos(delta_phi/2.+angle) - _trans_y * sin(delta_phi/2.+angle);
347  _trans_y = temp_trans_x * sin(delta_phi/2.+angle) + _trans_y * cos(delta_phi/2.+angle);
348  }
349  }
350 
351  TGeoRotation* _rot = new TGeoRotation(("rot_"+_module_name.str()).c_str(), _rot_z + dreh,
352  0, 0);
353  TGeoTranslation* _trans = new TGeoTranslation(
354  _trans_x, _trans_y,
355  kTransZ + kPlaneZPosition[i_plane] + offset_z - kRotUmZ + _trans_z);
356  TGeoCombiTrans* _combtrans = new TGeoCombiTrans(*_trans, *_rot);
357  _combtrans->SetName(("combtrans_"+_module_name.str()).c_str());
358  _combtrans->RegisterYourself();
359  delete _rot;
360  delete _trans;
361  //SubunitVol_active->AddNode(_vol_active, 0, _combtrans);
362  //SubunitVol_passive->AddNode(_vol_passive, 0, _combtrans);
363  SubunitVol->AddNode(_vol_active, 0, _combtrans);
364  SubunitVol->AddNode(_vol_passive, 0, _combtrans);
365  }
366  }
367  }
368  }
369  //break;
370  }
371  }
372 
373 /*
374  TGeoVolume* tmpvol = new TGeoVolume("tmpvol", shape_maps_passive,
375  gGeoMan->GetMedium("silicon"));
376  tmpvol->SetLineColor(32);
377  TGeoRotation* rot = new TGeoRotation("arotation", 0, 0, 0);
378  TGeoTranslation* trt = new TGeoTranslation(0, 0, kTransZ - kRotUmZ);
379  TGeoCombiTrans* trctmp = new TGeoCombiTrans(*trt, *rot);
380  trctmp->SetName("comb");
381  SubunitVol->AddNode(tmpvol, 0, trctmp);
382  TGeoVolume* tmpvol2 = new TGeoVolume("tmpvol2", shape_maps_active,
383  gGeoMan->GetMedium("silicon"));
384  tmpvol2->SetLineColor(36);
385  SubunitVol->AddNode(tmpvol2, 0, trctmp);*/
386 
387  TGeoRotation* rotf = new TGeoRotation("final", 90, kRot, 0);
388  //TGeoRotation* rotf = new TGeoRotation("final", 0, 0, 0);
389  TGeoTranslation* trtf = new TGeoTranslation(0, 0, kRotUmZ);
390  TGeoCombiTrans *trcf = new TGeoCombiTrans(*trtf, *rotf);
391  //top->AddNode(SubunitVol_active, 0, trcf);
392  //top->AddNode(SubunitVol_passive, 0, trcf);
393  top->AddNode(SubunitVol, 0, trcf);
394 
395  gGeoMan->CloseGeometry();
396  top->Write();
397  fi->Close();
398  // gGeoManager->Export(outfile);
399 
400  top->Draw("ogl");
401  return 0;
402 }
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
FairGeoLoader * geoLoad
FairGeoMedia * Media
TGeoManager * gGeoMan
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
friend F32vec4 sin(const F32vec4 &a)
Definition: P4_F32vec4.h:111
TGeoVolume * top
TGeoVolume * SubunitVol
FairGeoBuilder * geobuild
TFile * fi
Double_t
static float TwoPi()
Definition: PndCAMath.h:61
TGeoRotation rot
FairGeoInterface * geoFace
Double_t angle
Double_t Pi
TString outfile
int main ( void  )

Definition at line 406 of file create_HV_MAPS.C.

References create_HV_MAPS().

406  {
407  TApplication myapp("myapp", 0, 0);
408  create_HV_MAPS();
409  myapp.Run();
410  return 0;
411 }
int create_HV_MAPS()