Beispiel #1
0
void getBeamVisuals(TGeoManager* geom, TGeoVolume* top, float minZ, float maxZ) {
    TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
    TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
    TGeoVolume *xyaxis = geom->MakeBox( "xyaxis", Vacuum, 90., 90., 40. );

    TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
    TGeoMedium *Al = new TGeoMedium("Root Material",1, matAl);
    //TGeoVolume *line = geom->MakeTube( "BeamLine", Al, 0, .3, (maxZ - minZ) / 2 + 5);
    TGeoVolume *xaxis = geom->MakeTube( "XAxis", Al, 0, .1, 30.);
    TGeoVolume *yaxis = geom->MakeTube( "YAxis", Al, 0, .1, 30.);
    //TGeoVolume *pipe = geom->MakeTube( "BeamPipe", Al, _piperadius-.05, _piperadius+.05, (maxZ - minZ) / 2 + 5);
    //line->SetLineColor(kRed);
    xaxis->SetLineColor(kBlue);
    yaxis->SetLineColor(kBlue);
    //pipe->SetLineColor(kBlack);

    xyaxis->AddNode(xaxis, 1, new TGeoRotation( "rtyz", 0, 90, 0));
    xyaxis->AddNode(yaxis, 1, new TGeoRotation( "rtxz", 90, 90, 0));
    
    TGeoCombiTrans * pipecenter = new TGeoCombiTrans( *new TGeoTranslation(_pipexcoord, _pipeycoord, 0), *new TGeoRotation());
    //TGeoCombiTrans * linecenter = new TGeoCombiTrans( *new TGeoTranslation(_linexcoord, _lineycoord, 0), *new TGeoRotation());
    //top->AddNode( pipe, 1, pipecenter);
    //top->AddNode( line, 1, linecenter);
    top->AddNode( xyaxis, 1, pipecenter);
}
void Visualizer::Show(){

  std::cout<<"=============================================="<<std::endl;
  std::cout<<"========= Inside Expected SHOW() ============="<<std::endl;
  std::cout<<"=============================================="<<std::endl;

  TGeoVolume *top = gGeoManager->MakeBox("Top", NULL, kInfinity, kInfinity, kInfinity);
  gGeoManager->SetTopVolume(top);
  for(int i = 0 ; i < fVolumes.size() ; i++){
  top->AddNode(std::get<0>(fVolumes[i]), 1 , std::get<1>(fVolumes[i]));

  }

  top->SetLineColor(kGreen);
  gGeoManager->CloseGeometry();
  #ifndef USE_OGL
  top->Draw();
  #else
  top->Draw("ogl"); //to display the geometry using openGL
  #endif
  //
  //TPad::x3d("OPENGL");
  gGeoManager->Export("plane.root");
  //top->Export("planeTop.root");
  //fApp->Run();
}
TGeoVolume* create_tof_bar(Float_t dx, Float_t dy, Float_t dz)
{
  // needed materials
  TGeoMedium* boxVolMed = gGeoMan->GetMedium(BoxVolumeMedium);
  TGeoMedium* airVolMed = gGeoMan->GetMedium(KeepingVolumeMedium);
   
  Float_t width_alux=Pole_Thick_X;
  Float_t width_aluy=Pole_Thick_Y;
  Float_t width_aluz=Pole_Thick_Z;
  
  TGeoVolume* bar = new TGeoVolumeAssembly("Bar");
  TGeoBBox*   bar_alu_box = new TGeoBBox("", dx/2., dy/2., dz/2.);
  TGeoVolume* bar_alu_vol = 
    new TGeoVolume("bar_alu", bar_alu_box, boxVolMed);
  bar_alu_vol->SetLineColor(kGreen); // set line color for the alu box
  bar_alu_vol->SetTransparency(20); // set transparency for the TOF
  TGeoTranslation* bar_alu_trans 
    = new TGeoTranslation("", 0., 0., 0.);
  bar->AddNode(bar_alu_vol, 0, bar_alu_trans);

  TGeoBBox* bar_air_box = new TGeoBBox("", dx/2.-width_alux, dy/2.-width_aluy, dz/2.-width_aluz);
  TGeoVolume* bar_air_vol = 
    new TGeoVolume("bar_air", bar_air_box, airVolMed);
  bar_air_vol->SetLineColor(kYellow); // set line color for the alu box
  bar_air_vol->SetTransparency(70);   // set transparency for the TOF
  TGeoTranslation* bar_air_trans 
    = new TGeoTranslation("", 0., 0., 0.);
  bar_alu_vol->AddNode(bar_air_vol, 0, bar_air_trans);

  return bar;
}
TGeoVolume* create_tof_pole()
{
  // needed materials
  TGeoMedium* boxVolMed   = gGeoMan->GetMedium(BoxVolumeMedium);
  TGeoMedium* airVolMed   = gGeoMan->GetMedium(KeepingVolumeMedium);
   
  Float_t dx=Pole_Size_X;
  Float_t dy=Pole_Size_Y;
  Float_t dz=Pole_Size_Z;
  Float_t width_alux=Pole_Thick_X;
  Float_t width_aluy=Pole_Thick_Y;
  Float_t width_aluz=Pole_Thick_Z;
  
  TGeoVolume* pole = new TGeoVolumeAssembly("Pole");
  TGeoBBox*   pole_alu_box = new TGeoBBox("", dx/2., dy/2., dz/2.);
  TGeoVolume* pole_alu_vol = 
    new TGeoVolume("pole_alu", pole_alu_box, boxVolMed);
  pole_alu_vol->SetLineColor(kGreen); // set line color for the alu box
  pole_alu_vol->SetTransparency(20); // set transparency for the TOF
  TGeoTranslation* pole_alu_trans 
    = new TGeoTranslation("", 0., 0., 0.);
  pole->AddNode(pole_alu_vol, 0, pole_alu_trans);

  TGeoBBox* pole_air_box = new TGeoBBox("", dx/2.-width_alux, dy/2.-width_aluy, dz/2.-width_aluz);
  TGeoVolume* pole_air_vol = 
    new TGeoVolume("pole_air", pole_air_box, airVolMed);
  pole_air_vol->SetLineColor(kYellow); // set line color for the alu box
  pole_air_vol->SetTransparency(70); // set transparency for the TOF
  TGeoTranslation* pole_air_trans 
    = new TGeoTranslation("", 0., 0., 0.);
  pole_alu_vol->AddNode(pole_air_vol, 0, pole_air_trans);

  return pole;
}
TGeoVolume* create_tof_module(Int_t modType)
{
  Int_t cType = CounterTypeInModule[modType];
  Float_t dx=Module_Size_X[modType];
  Float_t dy=Module_Size_Y[modType];
  Float_t dz=Module_Size_Z[modType];
  Float_t width_aluxl=Module_Thick_Alu_X_left;
  Float_t width_aluxr=Module_Thick_Alu_X_right;
  Float_t width_aluy=Module_Thick_Alu_Y;
  Float_t width_aluz=Module_Thick_Alu_Z;

  Float_t shift_gas_box = (Module_Thick_Alu_X_right - Module_Thick_Alu_X_left)/2;

  Float_t dxpos=CounterXDistance[modType];
  Float_t startxpos=CounterXStartPosition[modType];
  Float_t dzoff=CounterZDistance[modType];
  Float_t rotangle=CounterRotationAngle[modType];

  TGeoMedium* boxVolMed          = gGeoMan->GetMedium(BoxVolumeMedium);
  TGeoMedium* noActiveGasVolMed  = gGeoMan->GetMedium(NoActivGasMedium);

  TString moduleName = Form("module_%d", modType);
  TGeoVolume* module = new TGeoVolumeAssembly(moduleName);

  TGeoBBox* alu_box = new TGeoBBox("", dx/2., dy/2., dz/2.);
  TGeoVolume* alu_box_vol = 
    new TGeoVolume("alu_box", alu_box, boxVolMed);
  alu_box_vol->SetLineColor(kGreen); // set line color for the alu box
  alu_box_vol->SetTransparency(20); // set transparency for the TOF
  TGeoTranslation* alu_box_trans 
    = new TGeoTranslation("", 0., 0., 0.);
  module->AddNode(alu_box_vol, 0, alu_box_trans);

  TGeoBBox* gas_box = new TGeoBBox("", (dx-(width_aluxl+width_aluxr))/2., (dy-2*width_aluy)/2., (dz-2*width_aluz)/2.);
  TGeoVolume* gas_box_vol = 
    new TGeoVolume("gas_box", gas_box, noActiveGasVolMed);
  gas_box_vol->SetLineColor(kYellow); // set line color for the gas box
  gas_box_vol->SetTransparency(70); // set transparency for the TOF
  TGeoTranslation* gas_box_trans 
    = new TGeoTranslation("", shift_gas_box, 0., 0.);
  alu_box_vol->AddNode(gas_box_vol, 0, gas_box_trans);
  
  for (Int_t j=0; j<5; j++){ //loop over counters (modules)
    Float_t zpos;
    if (0 == modType) {
      zpos = dzoff *=-1;
    } else {
      zpos = 0.;
    }
    TGeoTranslation* counter_trans 
      = new TGeoTranslation("", startxpos+ j*dxpos , 0.0 , zpos);

    TGeoRotation* counter_rot = new TGeoRotation();
    counter_rot->RotateY(rotangle);
    TGeoCombiTrans* counter_combi_trans = new TGeoCombiTrans(*counter_trans, *counter_rot);
    gas_box_vol->AddNode(gCounter[cType], j, counter_combi_trans);
  }

  return module;
}
Beispiel #6
0
void s_intersection()
{
   gROOT->GetListOfCanvases()->Delete();
   TCanvas *c = new TCanvas("composite shape", "Intersection boolean operation", 700, 1000);

   c->Divide(1,2,0,0);
   c->cd(2);
   gPad->SetPad(0,0,1,0.4);
   c->cd(1);
   gPad->SetPad(0,0.4,1,1);
   
   if (gGeoManager) delete gGeoManager;
   
   new TGeoManager("xtru", "poza12");
   TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
   TGeoMedium *med = new TGeoMedium("MED",1,mat);
   TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
   gGeoManager->SetTopVolume(top);

   // define shape components with names
   TGeoBBox *box = new TGeoBBox("bx", 40., 40., 40.); 
   TGeoSphere *sph = new TGeoSphere("sph", 40., 45.);
   // define named geometrical transformations with names
   TGeoTranslation *tr = new TGeoTranslation(0., 0., 45.);
   tr->SetName("tr");
   // register all used transformations
   tr->RegisterYourself();
   // create the composite shape based on a Boolean expression
   TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph:tr * bx");

   TGeoVolume *vol = new TGeoVolume("COMP2",cs);
   top->AddNode(vol,1);
   gGeoManager->CloseGeometry();
   gGeoManager->SetNsegments(100);
   top->Draw();
   MakePicture();

   c->cd(2);

   TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);

   pt->SetLineColor(1);

   TText *text = pt->AddText("TGeoCompositeShape - composite shape class");

   text->SetTextColor(2);
   pt->AddText("----- Here is an example of boolean intersection operation : A * B");
   pt->AddText("----- A == sphere (with inner radius non-zero), B == box");
   pt->AddText(" ");
   pt->SetAllWith("-----","color",4);
   pt->SetAllWith("-----","font",72);
   pt->SetAllWith("-----","size",0.04);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.044);
   pt->Draw();
   c->cd(1);
}
void Visualizer::Show(TGeoVolume *vol){
  TGeoVolume *top = gGeoManager->MakeBox("Top", NULL, kInfinity, kInfinity, kInfinity);
  gGeoManager->SetTopVolume(top);
  //TGeoVolume *vol = fGeoManager->MakeSphere("SPHERE", NULL, 30, 40, 0, 180, 0, 360);
  top->AddNode(vol, 1);
  gGeoManager->CloseGeometry();
  top->Draw();
  //fApp->Run();
}
void Create_TOF_Geometry_v12a() {
  // Load the necessary FairRoot libraries 
  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
  basiclibs();
  gSystem->Load("libGeoBase");
  gSystem->Load("libParBase");
  gSystem->Load("libBase");

  // Load needed material definition from media.geo file
  create_materials_from_media_file();

  // Get the GeoManager for later usage
  gGeoMan = (TGeoManager*) gROOT->FindObject("FAIRGeom");
  gGeoMan->SetVisLevel(7);  

  // Create the top volume 
  /*
  TGeoBBox* topbox= new TGeoBBox("", 1000., 1000., 1000.);
  TGeoVolume* top = new TGeoVolume("top", topbox, gGeoMan->GetMedium("air"));
  gGeoMan->SetTopVolume(top);
  */

  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
  gGeoMan->SetTopVolume(top);
 
  TGeoVolume* tof = new TGeoVolumeAssembly(geoVersion);
  top->AddNode(tof, 1);
  
  for(Int_t counterType = 0; counterType < NumberOfDifferentCounterTypes; counterType++) { 
    gCounter = create_new_counter(counterType);
  }

  for(Int_t moduleType = 0; moduleType < NofModuleTypes; moduleType++) { 
    gModules[moduleType] = create_new_tof_module(moduleType);
  }

  gPole = create_tof_pole();

  position_tof_poles();
  position_inner_tof_modules();
  position_outer_tof_modules();
  

  gGeoMan->CloseGeometry();
  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();

  TFile* outfile = new TFile(FileName,"RECREATE");
  top->Write();
  //gGeoMan->Write();
  outfile->Close();
  //  top->Draw("ogl");
  //top->Raytrace();

}
void KVFAZIALNS2016::BuildFAZIA()
{
   //Build geometry of FAZIASYM
   //All telescopes are : Si(300µm)-Si(500µm)-CsI(10cm)
   //No attempt has been made to implement real thicknesses
   //
   Info("BuildFAZIA", "Compact geometry, %f cm from target",
        fFDist);

   TGeoVolume* top = gGeoManager->GetTopVolume();

   Double_t distance_block_cible = fFDist * KVUnits::cm;
   Double_t thick_si1 = 300 * KVUnits::um;
   TGeoTranslation trans;
   trans.SetDz(distance_block_cible + thick_si1 / 2.);

   KVFAZIABlock* block = new KVFAZIABlock;

   TGeoRotation rot1, rot2;
   TGeoHMatrix h;
   TGeoHMatrix* ph = 0;
   Double_t theta = 0;
   Double_t phi = 0;

   Double_t theta_min = fFThetaMin;//smallest lab polar angle in degrees
   Double_t centre_hole = 2.*tan(theta_min * TMath::DegToRad()) * distance_block_cible;
   Double_t dx = (block->GetTotalSideWithBlindage()) / 2.;

   TVector3 centre;
   for (Int_t bb = 0; bb < fNblocks; bb += 1) {

      if (bb == 1)        centre.SetXYZ(-1 * (dx - centre_hole / 2), -dx - centre_hole / 2, distance_block_cible);
      else if (bb == 2)   centre.SetXYZ(-1 * (dx + centre_hole / 2), dx - centre_hole / 2, distance_block_cible);
      else if (bb == 3)   centre.SetXYZ(-1 * (-dx + centre_hole / 2), dx + centre_hole / 2, distance_block_cible);
      else if (bb == 0)   centre.SetXYZ(-1 * (-dx - centre_hole / 2), -dx + centre_hole / 2, distance_block_cible);
      else if (bb == 4)   centre.SetXYZ(-1 * (-dx - centre_hole / 2), -3 * dx + centre_hole / 2, distance_block_cible); //centre.SetXYZ(-1 * (dx - centre_hole / 2), -3 * dx - centre_hole / 2, distance_block_cible);
      else {
         Warning("BuildFAZIA", "Block position definition is done only for %d blocks", fNblocks);
      }
      theta = centre.Theta() * TMath::RadToDeg();
      phi = centre.Phi() * TMath::RadToDeg();
      printf("BLK #%d => theta=%1.2lf - phi=%1.2lf\n", bb, theta, phi);

      rot2.SetAngles(phi + 90., theta, 0.);
      rot1.SetAngles(-1.*phi, 0., 0.);
      h = rot2 * trans * rot1;
      ph = new TGeoHMatrix(h);
      top->AddNode(block, bb, ph);
   }

   // add telescope for elastic scattering monitoring
//   RutherfordTelescope();
   // Change default geometry import angular range for rutherford telescope
   SetGeometryImportParameters(.25, 1., 1.84);
}
Beispiel #10
0
void s_difference()
{
   gROOT->GetListOfCanvases()->Delete();
   TCanvas *c = new TCanvas("composite shape", "Difference boolean operation", 700, 1000);

   c->Divide(1,2,0,0);
   c->cd(2);
   gPad->SetPad(0,0,1,0.4);
   c->cd(1);
   gPad->SetPad(0,0.4,1,1);
   
   if (gGeoManager) delete gGeoManager;
   
   new TGeoManager("xtru", "poza12");
   TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
   TGeoMedium *med = new TGeoMedium("MED",1,mat);
   TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
   gGeoManager->SetTopVolume(top);

   // define shape components with names
   TGeoTorus *tor = new TGeoTorus("tor", 45., 15., 20., 45., 145.); 
   TGeoSphere *sph = new TGeoSphere("sph", 20., 45., 0., 180., 0., 270.);
   // create the composite shape based on a Boolean expression
   TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph - tor");

   TGeoVolume *vol = new TGeoVolume("COMP3",cs);
   top->AddNode(vol,1);
   gGeoManager->CloseGeometry();
   gGeoManager->SetNsegments(60);
   top->Draw();
   MakePicture();

   c->cd(2);

   TPaveText *pt = new TPaveText(.01, .01, .99, .99);

   pt->SetLineColor(1);

   TText *text = pt->AddText("TGeoCompositeShape - composite shape class");

   text->SetTextColor(2);

   pt->AddText("----- It's an example of boolean difference: A - B");
   pt->AddText("----- A == part of sphere (0-180, 0-270), B == partial torus (45-145)");
   pt->AddText(" ");
   pt->SetAllWith("-----","color",4);
   pt->SetAllWith("-----","font",72);
   pt->SetAllWith("-----","size",0.04);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.044);
   pt->Draw();
   c->cd(1);
}
Beispiel #11
0
void ATTPC_d2He() {
  // Load the necessary FairRoot libraries 
  //gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
  //basiclibs();
  //gSystem->Load("libGeoBase");
  //gSystem->Load("libParBase");
  //gSystem->Load("libBase");

  // Load needed material definition from media.geo file
  create_materials_from_media_file();

  // Get the GeoManager for later usage
  gGeoMan = (TGeoManager*) gROOT->FindObject("FAIRGeom");
  gGeoMan->SetVisLevel(7);  

  // Create the top volume 

  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
  gGeoMan->SetTopVolume(top);
 
  TGeoMedium* gas   = gGeoMan->GetMedium(MediumVacuum);
  TGeoVolume* tpcvac = new TGeoVolumeAssembly(geoVersion);
  tpcvac -> SetMedium(gas);
  top->AddNode(tpcvac, 1);
  
  gModules = create_detector();

  //position_detector();
 
  cout<<"Voxelizing."<<endl;
  top->Voxelize("");
  gGeoMan->CloseGeometry();

  //add_alignable_volumes();

  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();

  TFile* outfile = new TFile(FileName,"RECREATE");
  top->Write();
  outfile->Close();

  TFile* outfile1 = new TFile(FileName1,"RECREATE");
  gGeoMan->Write();
  outfile1->Close();

    top->Draw("ogl");
  //top->Raytrace();

}
Beispiel #12
0
void makeGeom()
{
  //--- Definition of a simple geometry
  //   gSystem->Load("libGeom");
   new TGeoManager("genfitGeom", "GENFIT geometry");
   gROOT->Macro("../../geometry/media.C");


   TGeoMedium *air = gGeoManager->GetMedium("air");
   assert(air!=NULL);
   TGeoMedium *vacuum = gGeoManager->GetMedium("vacuum");
   assert(vacuum!=NULL);
   TGeoMedium *sil = gGeoManager->GetMedium("silicon");
   assert(sil!=NULL);

   TGeoVolume *top = gGeoManager->MakeBox("TOPPER", air, 500., 500., 500.);
   gGeoManager->SetTopVolume(top); // mandatory !
   
   TGeoVolume *slab = gGeoManager->MakeBox("slab", sil, 5., 5., .012);
   top->AddNode(slab, 1, new TGeoTranslation(0.,0., 0.3));
   top->AddNode(slab, 2, new TGeoTranslation(0.,0., 0.6));
   top->AddNode(slab, 3, new TGeoTranslation(0.,0., 0.9));
   top->AddNode(slab, 4, new TGeoTranslation(0.,0., 1.2));
   top->AddNode(slab, 5, new TGeoTranslation(0.,0., 1.5));
   //   top->AddNode(slab, 6, new TGeoTranslation(0.,0., 1.8));


   //--- close the geometry
   gGeoManager->CloseGeometry();

   //--- draw the ROOT box
   gGeoManager->SetVisLevel(10);
   //top->Draw("ogl");
   TFile *outfile = TFile::Open("genfitGeom.root","RECREATE");
   gGeoManager->Write();
   outfile->Close();
}
Beispiel #13
0
void Draw3D(AliITSOnlineCalibrationSPDhandler *h){

  TGeoHMatrix m2t[240];
  for(Int_t imod=0; imod<240; imod++){
    int vid = AliITSAlignMille2Module::GetVolumeIDFromIndex(imod);
    AliITSAlignMille2Module::SensVolMatrix(vid,&m2t[imod]);
  }

  delete gGeoManager;

  new TGeoManager("SPD","active");

  TGeoMaterial *vacuum = new TGeoMaterial("vacuum",0,0,0);
  TGeoMedium *none = new TGeoMedium("Vacuum",0,vacuum);
  TGeoVolume *top = gGeoManager->MakeBox("TOP",none,500,500,500);
  gGeoManager->SetTopVolume(top);

  TGeoVolume *ladder = gGeoManager->MakeBox("ladder",none,0.6375,0.001/2,3.48);

  Int_t nActive[2]={0,0};
  for(Int_t imod=0; imod<240; imod++){
    TGeoRotation *rot  = new TGeoRotation();
    rot->SetMatrix(m2t[imod].GetRotationMatrix());
    TGeoCombiTrans *matrix = new TGeoCombiTrans(m2t[imod].GetTranslation()[0],m2t[imod].GetTranslation()[1],m2t[imod].GetTranslation()[2],rot);
    if((40960-h->GetNrBad(imod))>0) {
      top->AddNode(ladder,imod,matrix);
      if(imod<80) nActive[0]++;
      else nActive[1]++;
    }
  }

  printf("  \n\n   Number of Active SPD modules (->Total)  : inner %i (80) outer %i (160) \n\n\n",nActive[0],nActive[1]);
  gGeoManager->CloseGeometry();
  top->Draw("ogl");
  gPad->GetView()->ShowAxis();

}
void create_gfi_geo(const char* geoTag)
{

  fGlobalTrans->SetTranslation(0.0,0.0,0.0);

  // -------   Load media from media file   -----------------------------------
  FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
  TString medFile = geoPath + "/geometry/media_r3b.geo";
  geoFace->setMediaFile(medFile);
  geoFace->readMedia();
  gGeoMan = gGeoManager;
  // --------------------------------------------------------------------------



  // -------   Geometry file name (output)   ----------------------------------
  TString geoFileName = geoPath + "/geometry/gfi_";
  geoFileName = geoFileName + geoTag + ".geo.root";
  // --------------------------------------------------------------------------



  // -----------------   Get and create the required media    -----------------
  FairGeoMedia*   geoMedia = geoFace->getMedia();
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();

  FairGeoMedium* mAir      = geoMedia->getMedium("Air");
  if ( ! mAir ) Fatal("Main", "FairMedium Air not found");
  geoBuild->createMedium(mAir);
  TGeoMedium* pMed2 = gGeoMan->GetMedium("Air");
  if ( ! pMed2 ) Fatal("Main", "Medium Air not found");

  FairGeoMedium* mVac      = geoMedia->getMedium("vacuum");
  if ( ! mVac ) Fatal("Main", "FairMedium vacuum not found");
  geoBuild->createMedium(mVac);
  TGeoMedium* pMed1 = gGeoMan->GetMedium("vacuum");
  if ( ! pMed1 ) Fatal("Main", "Medium vacuum not found");
  
  FairGeoMedium* mGfi      = geoMedia->getMedium("plasticForGFI");
  if ( ! mGfi ) Fatal("Main", "FairMedium plasticForGFI not found");
  geoBuild->createMedium(mGfi);
  TGeoMedium* pMed35 = gGeoMan->GetMedium("plasticForGFI");
  if ( ! pMed35 ) Fatal("Main", "Medium plasticForGFI not found");

  FairGeoMedium* mAl      = geoMedia->getMedium("aluminium");
  if ( ! mAl ) Fatal("Main", "FairMedium aluminium not found");
  geoBuild->createMedium(mAl);
  TGeoMedium* pMed21 = gGeoMan->GetMedium("aluminium");
  if ( ! pMed21 ) Fatal("Main", "Medium aluminium not found");
  // --------------------------------------------------------------------------



  // --------------   Create geometry and top volume  -------------------------
  gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
  gGeoMan->SetName("GFIgeom");
  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
  gGeoMan->SetTopVolume(top);
  // --------------------------------------------------------------------------



  // out-of-file geometry definition
  Double_t dx,dy,dz;
  Double_t a;
  Double_t thx, phx, thy, phy, thz, phz;
  Double_t z, density, radl, absl, w;
  Int_t nel, numed;
  
  
  
  // TRANSFORMATION MATRICES
  // Combi transformation:
  //GFI1 position
  //dx = -71.973310; //Justyna
  //dy = 0.000000;   //Justyna
  //dz = 513.967775; //Justyna
  //dx = -72.164874; //Justyna new
  //dy = -0.010000;   //Justyna new
  //dz = 513.910302; //Justyna new
  //dx = -73.381; //dE tracker
  //dy = 0.070;
  //dz = 513.421;
  
  //LABPOS(GFI1,-73.274339,0.069976,513.649524)
  dx = -73.274339; //dE tracker, correction due to wrong angle
  dy = 0.069976;
  dz = 513.649524;
  
  /*
   dx = 73.700000;
   dy = 0.000000;
   dz = 525.400000;
   */
  // Rotation:
  thx = -106.700000;    phx = 0.000000;
  //   thx = 106.700000;    phx = 0.000000;
  thy = 90.000000;    phy = 90.000000;
  thz = -16.700000;    phz = 0.000000;
  TGeoRotation *pMatrix3 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
  TGeoCombiTrans*
  pMatrix2 = new TGeoCombiTrans("", dx,dy,dz,pMatrix3);
  // Combi transformation:
  dx = 0.000000;
  dy = 0.000000;
  dz = 0.000000;
  // Rotation:
  thx = 90.000000;    phx = 0.000000;
  thy = 90.000000;    phy = 90.000000;
  thz = 0.000000;    phz = 0.000000;
  TGeoRotation *pMatrix7 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
  TGeoCombiTrans*
  pMatrix6 = new TGeoCombiTrans("", dx,dy,dz,pMatrix7);
  // Combi transformation:
  dx = 0.000000;
  dy = 27.000000;
  dz = 0.000000;
  // Rotation:
  thx = 90.000000;    phx = 0.000000;
  thy = 90.000000;    phy = 90.000000;
  thz = 0.000000;    phz = 0.000000;
  TGeoRotation *pMatrix9 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
  TGeoCombiTrans*
  pMatrix8 = new TGeoCombiTrans("", dx,dy,dz,pMatrix9);
  // Combi transformation:
  dx = 0.000000;
  dy = -27.000000;
  dz = 0.000000;
  // Rotation:
  thx = 90.000000;    phx = 0.000000;
  thy = 90.000000;    phy = 90.000000;
  thz = 0.000000;    phz = 0.000000;
  TGeoRotation *pMatrix11 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
  TGeoCombiTrans*
  pMatrix10 = new TGeoCombiTrans("", dx,dy,dz,pMatrix11);
  // Combi transformation:
  dx = 27.000000;
  dy = 0.000000;
  dz = 0.000000;
  // Rotation:
  thx = 90.000000;    phx = 0.000000;
  thy = 90.000000;    phy = 90.000000;
  thz = 0.000000;    phz = 0.000000;
  TGeoRotation *pMatrix13 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
  TGeoCombiTrans*
  pMatrix12 = new TGeoCombiTrans("", dx,dy,dz,pMatrix13);
  // Combi transformation:
  dx = -27.000000;
  dy = 0.000000;
  dz = 0.000000;
  // Rotation:
  thx = 90.000000;    phx = 0.000000;
  thy = 90.000000;    phy = 90.000000;
  thz = 0.000000;    phz = 0.000000;
  TGeoRotation *pMatrix15 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
  TGeoCombiTrans*
  pMatrix14 = new TGeoCombiTrans("", dx,dy,dz,pMatrix15);
  // Combi transformation:
  //GFI2 position
  //dx = -145.270039; //Justyna
  //dy = 0.000000;    //Justyna
  //dz = 730.318956;  //Justyna
  //dx = -145.212570; //Justyna new
  //dy = -0.010000;    //Justyna new
  //dz = 730.336197;  //Justyna new
  //dx = -147.486; //dE tracker
  //dy = 0.070;
  //dz = 729.798;
  
  //LABPOS(GFI2,-147.135037,0.069976,729.680342)
  dx = -147.135037; //dE tracker, correction due to wrong angle
  dy = 0.069976;
  dz = 729.680342;
  
  /*
   dx = 141.800000;
   dy = 0.000000;
   dz = 727.300000;
   */
  // Rotation:
  thx = -106.700000;    phx = 0.000000;
  //   thx = 106.700000;    phx = 0.000000;
  thy = 90.000000;    phy = 90.000000;
  thz = -16.700000;    phz = 0.000000;
  TGeoRotation *pMatrix5 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
  TGeoCombiTrans*
  pMatrix4 = new TGeoCombiTrans("", dx,dy,dz,pMatrix5);
  
  
  // World definition
  TGeoVolume* pWorld = gGeoManager->GetTopVolume();
  pWorld->SetVisLeaves(kTRUE);
  
  
  
  
  // SHAPES, VOLUMES AND GEOMETRICAL HIERARCHY
  // Shape: GFIBoxWorld type: TGeoBBox
  dx = 29.00000;
  dy = 29.00000;
  dz = 0.050000;
  TGeoShape *pGFIBoxWorld = new TGeoBBox("GFIBoxWorld", dx,dy,dz);
  // Volume: GFILogWorld
  TGeoVolume*
  pGFILogWorld = new TGeoVolume("GFILogWorld",pGFIBoxWorld, pMed2);
  pGFILogWorld->SetVisLeaves(kTRUE);
  
  // Global positioning
  
  TGeoCombiTrans *pGlobal1 = GetGlobalPosition(pMatrix2);
  TGeoCombiTrans *pGlobal2 = GetGlobalPosition(pMatrix4);
    
  TGeoVolumeAssembly *pw1 = new TGeoVolumeAssembly("GFI");
  pWorld->AddNode(pw1, 0);
    
  pw1->AddNode( pGFILogWorld, 0, pGlobal1 );
  pw1->AddNode( pGFILogWorld, 1, pGlobal2 );
  
  
  
  // Shape: GFIBox type: TGeoBBox
  dx = 25.000000;
  dy = 25.000000;
  dz = 0.050000;
  TGeoShape *pGFIBox = new TGeoBBox("GFIBox", dx,dy,dz);
  // Volume: GFILog
  TGeoVolume*
  pGFILog = new TGeoVolume("GFILog",pGFIBox, pMed35);
  pGFILog->SetVisLeaves(kTRUE);
  pGFILogWorld->AddNode(pGFILog, 0, pMatrix6);
  
  // Shape: UpFrame type: TGeoBBox
  dx = 29.000000;
  dy = 2.000000;
  dz = 0.050000;
  TGeoShape *pUpFrame = new TGeoBBox("UpFrame", dx,dy,dz);
  // Volume: logicUpFrame
  TGeoVolume*
  plogicUpFrame = new TGeoVolume("logicUpFrame",pUpFrame, pMed21);
  plogicUpFrame->SetVisLeaves(kTRUE);
  pGFILogWorld->AddNode(plogicUpFrame, 0, pMatrix8);
  // Shape: DownFrame type: TGeoBBox
  dx = 29.000000;
  dy = 2.000000;
  dz = 0.050000;
  TGeoShape *pDownFrame = new TGeoBBox("DownFrame", dx,dy,dz);
  // Volume: logicDownFrame
  TGeoVolume*
  plogicDownFrame = new TGeoVolume("logicDownFrame",pDownFrame, pMed21);
  plogicDownFrame->SetVisLeaves(kTRUE);
  pGFILogWorld->AddNode(plogicDownFrame, 0, pMatrix10);
  // Shape: RightFrame type: TGeoBBox
  dx = 2.000000;
  dy = 25.000000;
  dz = 0.050000;
  TGeoShape *pRightFrame = new TGeoBBox("RightFrame", dx,dy,dz);
  // Volume: logicRightFrame
  TGeoVolume*
  plogicRightFrame = new TGeoVolume("logicRightFrame",pRightFrame, pMed21);
  plogicRightFrame->SetVisLeaves(kTRUE);
  pGFILogWorld->AddNode(plogicRightFrame, 0, pMatrix12);
  // Shape: LeftFrame type: TGeoBBox
  dx = 2.000000;
  dy = 25.000000;
  dz = 0.050000;
  TGeoShape *pLeftFrame = new TGeoBBox("LeftFrame", dx,dy,dz);
  // Volume: logicLeftFrame
  TGeoVolume*
  plogicLeftFrame = new TGeoVolume("logicLeftFrame",pLeftFrame, pMed21);
  plogicLeftFrame->SetVisLeaves(kTRUE);
  pGFILogWorld->AddNode(plogicLeftFrame, 0, pMatrix14);
  
  // Add the sensitive part
//  AddSensitiveVolume(pGFILog);
//  fNbOfSensitiveVol+=1;
  
  
  
  // ---------------   Finish   -----------------------------------------------
  gGeoMan->CloseGeometry();
  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();

  TFile* geoFile = new TFile(geoFileName, "RECREATE");
  top->Write();
  geoFile->Close();
  // --------------------------------------------------------------------------
}
Beispiel #15
0
void create_mtof_geo(const char* geoTag)
{
  // -------   Load media from media file   -----------------------------------
  FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
  TString medFile = geoPath + "/geometry/media_r3b.geo";
  geoFace->setMediaFile(medFile);
  geoFace->readMedia();
  gGeoMan = gGeoManager;
  // --------------------------------------------------------------------------



  // -------   Geometry file name (output)   ----------------------------------
  TString geoFileName = geoPath + "/geometry/mtof_";
  geoFileName = geoFileName + geoTag + ".geo.root";
  // --------------------------------------------------------------------------



  // -----------------   Get and create the required media    -----------------
  FairGeoMedia*   geoMedia = geoFace->getMedia();
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();

  FairGeoMedium* mAir      = geoMedia->getMedium("Air");
  if ( ! mAir ) Fatal("Main", "FairMedium Air not found");
  geoBuild->createMedium(mAir);
  TGeoMedium* pMed2 = gGeoMan->GetMedium("Air");
  if ( ! pMed2 ) Fatal("Main", "Medium Air not found");
  
  FairGeoMedium* mTof      = geoMedia->getMedium("plasticFormTOF");
  if ( ! mTof ) Fatal("Main", "FairMedium plasticFormTOF not found");
  geoBuild->createMedium(mTof);
  TGeoMedium* pMed34 = gGeoMan->GetMedium("plasticFormTOF");
  if ( ! pMed34 ) Fatal("Main", "Medium plasticFormTOF not found");
  // --------------------------------------------------------------------------



  // --------------   Create geometry and top volume  -------------------------
  gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
  gGeoMan->SetName("mTOFgeom");
  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
  gGeoMan->SetTopVolume(top);
  // --------------------------------------------------------------------------



  // out-of-file geometry definition
  Double_t dx,dy,dz;
  Double_t a;
  Double_t thx, phx, thy, phy, thz, phz;
  Double_t z, density, w;
  Int_t nel, numed;
  

  
  // TRANSFORMATION MATRICES
  // Combi transformation:
  //NTF position
  //dx = -154.815998;//Justyna
  //dy = 0.000000;  //Justyna
  //dz = 761.755160;//Justyna
  //dx = -157.536214;//Justyna new
  //dy = -0.010000;  //Justyna new
  ////dz = 760.939056;//Justyna new
  //dz = 760.139056;//Justyna
  //dx = -155.709;//dE tracker
  //dy = 0.524;
  ////dz = 761.487;
  //dz = 760.687;	//try -0.8 like Justyna
  
  //LABPOS(FTF,-155.824045,0.523976,761.870346)
  dx = -155.824045;//dE tracker, correction due to wrong angle
  dy = 0.523976;
  dz = 761.870346;
  
  // Rotation:
  thx = -106.700000;    phx = 0.000000;
  thy = 90.000000;    phy = 90.000000;
  thz = -16.700000;    phz = 0.000000;
  
  /*    dx = -171.1;
   dy = 2.400000;
   dz = 548.95;
   // dz = 0.;
   // Rotation:
   thx = -121.000000;    phx = 0.000000;
   thy = 90.000000;    phy = 90.000000;
   thz = -31.000000;    phz = 0.000000;*/
  
  TGeoRotation *pMatrix3 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
  TGeoCombiTrans*
  pMatrix2 = new TGeoCombiTrans("", dx,dy,dz,pMatrix3);
  
  /*
   // TRANSFORMATION MATRICES
   // Combi transformation:
   dx = 151.000000;
   dy = 0.000000;
   dz = 758.000000;
   // Rotation:
   thx = 106.700000;    phx = 0.000000;
   thy = 90.000000;    phy = 90.000000;
   thz = 16.700000;    phz = 0.000000;
   TGeoRotation *pMatrix3 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
   TGeoCombiTrans*
   pMatrix2 = new TGeoCombiTrans("", dx,dy,dz,pMatrix3);
   */
  
  // Shape: World type: TGeoBBox
  TGeoVolume* pWorld = gGeoManager->GetTopVolume();
  pWorld->SetVisLeaves(kTRUE);
  
  // Create a global Mother Volume
  /*
   dx = 200.000000;
   dy = 200.000000;
   dz = 200.000000;
   TGeoShape *pBoxWorld = new TGeoBBox("mTofBoxWorld", dx,dy,dz);
   TGeoVolume*
   pWorld  = new TGeoVolume("mTofBoxLogWorld",pBoxWorld, pMed2);
   pWorld->SetVisLeaves(kTRUE);
   TGeoCombiTrans *pGlobalc = GetGlobalPosition();
   
   // add the sphere as Mother Volume
   pAWorld->AddNode(pWorld, 0, pGlobalc);
   */
  
  
  // SHAPES, VOLUMES AND GEOMETRICAL HIERARCHY
  // Shape: mTOFBox type: TGeoBBox
  dx = 24.000000;
  dy = 24.000000;
  //dz = 0.250000;	//wrong: should be 0.5->1cm total
  dz = 0.500000;
  
  /*   dx = 94.450000;  //TFW size
   dy = 73.450000;
   dz = 0.500000;*/
  
  TGeoShape *pmTOFBox = new TGeoBBox("mTOFBox", dx,dy,dz);
  // Volume: mTOFLog
  TGeoVolume *
  pmTOFLog = new TGeoVolume("mTOFLog",pmTOFBox, pMed34);
  pmTOFLog->SetVisLeaves(kTRUE);
  
  TGeoVolumeAssembly *pmTof = new TGeoVolumeAssembly("mTOF");
  TGeoCombiTrans *t0 = new TGeoCombiTrans("t0");
  pmTof->AddNode(pmTOFLog, 0, t0);
  
  TGeoCombiTrans *pGlobal = GetGlobalPosition(pMatrix2);
  if (pGlobal){
    pWorld->AddNode(pmTof, 0, pGlobal);
  }else{
    pWorld->AddNode(pmTof, 0, pMatrix2);
  }
  
  
//  AddSensitiveVolume(pmTOFLog);
//  fNbOfSensitiveVol+=1;
  
  
  
  // ---------------   Finish   -----------------------------------------------
  gGeoMan->CloseGeometry();
  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();

  TFile* geoFile = new TFile(geoFileName, "RECREATE");
  top->Write();
  geoFile->Close();
  // --------------------------------------------------------------------------
}
Beispiel #16
0
void create_tof_geo(const char* geoTag)
{

    fGlobalTrans->SetTranslation(0.0,0.0,0.0);

    // -------   Load media from media file   -----------------------------------
    FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
    FairGeoInterface* geoFace = geoLoad->getGeoInterface();
    TString geoPath = gSystem->Getenv("VMCWORKDIR");
    TString medFile = geoPath + "/geometry/media_r3b.geo";
    geoFace->setMediaFile(medFile);
    geoFace->readMedia();
    gGeoMan = gGeoManager;
    // --------------------------------------------------------------------------



    // -------   Geometry file name (output)   ----------------------------------
    TString geoFileName = geoPath + "/geometry/tof_";
    geoFileName = geoFileName + geoTag + ".geo.root";
    // --------------------------------------------------------------------------



    // -----------------   Get and create the required media    -----------------
    FairGeoMedia*   geoMedia = geoFace->getMedia();
    FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();

    FairGeoMedium* mAir      = geoMedia->getMedium("Air");
    if ( ! mAir ) Fatal("Main", "FairMedium Air not found");
    geoBuild->createMedium(mAir);
    TGeoMedium* pMed2 = gGeoMan->GetMedium("Air");
    if ( ! pMed2 ) Fatal("Main", "Medium Air not found");

    FairGeoMedium* mTof      = geoMedia->getMedium("plasticForTOF");
    if ( ! mTof ) Fatal("Main", "FairMedium plasticForTOF not found");
    geoBuild->createMedium(mTof);
    TGeoMedium* pMed34 = gGeoMan->GetMedium("plasticForTOF");
    if ( ! pMed34 ) Fatal("Main", "Medium plasticForTOF not found");
    // --------------------------------------------------------------------------



    // --------------   Create geometry and top volume  -------------------------
    gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
    gGeoMan->SetName("TOFgeom");
    TGeoVolume* top = new TGeoVolumeAssembly("TOP");
    gGeoMan->SetTopVolume(top);
    // --------------------------------------------------------------------------



    // out-of-file geometry definition
    Double_t dx,dy,dz;
    Double_t a;
    //   Double_t thx, phx, thy, phy, thz, phz;
    Double_t z, density, w;
    Int_t nel, numed;



    // TRANSFORMATION MATRICES
    // Combi transformation:
    dx = -417.359574; //Justyna
    dy = 2.400000;    //Justyna
    dz = 960.777114;  //Justyna

    //    dx = -421.33683; //Christoph
    //    dy = 2.12;    //Christoph
    //    dz = 958.387337;  //Christoph

    /*    dx = -171.1;  //position directrly (15cm) after DCH2
     dy = 2.400000;
     dz = 548.95;*/
    // dz = 0.;
    /*   // Rotation:
     thx = -121.000000;    phx = 0.000000;
     thy = 90.000000;    phy = 90.000000;
     thz = -31.000000;    phz = 0.000000;*/  //this

    //   TGeoRotation *pMatrix3 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);  //this
    TGeoRotation *gRot = new TGeoRotation();
    gRot->RotateX(0.);
    gRot->RotateY(-31.000000);
    gRot->RotateZ(0.);

    TGeoCombiTrans*
    //   pMatrix2 = new TGeoCombiTrans("", dx,dy,dz,pMatrix3);  //this
    pMatrix2 = new TGeoCombiTrans("", dx,dy,dz,gRot);  //this







    /* PREVIOUS!!!
     // TRANSFORMATION MATRICES
     // Combi transformation:
     dx = 419.700000;
     dy = 0.000000;
     dz = 952.400000;
     // dz = 0.;
     // Rotation:
     thx = 121.000000;    phx = 0.000000;
     thy = 90.000000;    phy = 90.000000;
     thz = 31.000000;    phz = 0.000000;
     TGeoRotation *pMatrix3 = new TGeoRotation("",thx,phx,thy,phy,thz,phz);
     TGeoCombiTrans*
     pMatrix2 = new TGeoCombiTrans("", dx,dy,dz,pMatrix3);
     */

    //Top Volume
    TGeoVolume* pWorld = gGeoManager->GetTopVolume();
    pWorld->SetVisLeaves(kTRUE);


    TGeoVolumeAssembly *ptof = new TGeoVolumeAssembly("TOF");


    // SHAPES, VOLUMES AND GEOMETRICAL HIERARCHY
    // Shape: TOFBox type: TGeoBBox
    dx = 94.450000;
    dy = 73.450000;
    dz = 0.500000;
    TGeoShape *pTOFBox = new TGeoBBox("TOFBox", dx,dy,dz);
    // Volume: TOFLog
    TGeoVolume*
    pTOFLog = new TGeoVolume("TOFLog",pTOFBox, pMed34);
    pTOFLog->SetVisLeaves(kTRUE);

    TGeoCombiTrans *t0 = new TGeoCombiTrans("t0");
    ptof->AddNode(pTOFLog, 0, t0);

    TGeoCombiTrans *pGlobal = GetGlobalPosition(pMatrix2);
    if (pGlobal) {
        pWorld->AddNode(ptof, 0, pGlobal);
    } else {
        pWorld->AddNode(ptof, 0, pMatrix2);
    }

//  AddSensitiveVolume(pTOFLog);
//  fNbOfSensitiveVol+=1;



    // ---------------   Finish   -----------------------------------------------
    gGeoMan->CloseGeometry();
    gGeoMan->CheckOverlaps(0.001);
    gGeoMan->PrintOverlaps();
    gGeoMan->Test();

    TFile* geoFile = new TFile(geoFileName, "RECREATE");
    top->Write();
    geoFile->Close();
    // --------------------------------------------------------------------------
}
Beispiel #17
0
TGeoVolume *VP_SimpleECal(int nphi = 4, int nz = 3, double density = 8.28)
{
  const double world_x = 9000.;
  const double world_y = 9000.;
  const double world_z = 16000;

  TGeoManager *geom = new TGeoManager("SimpleECal", "Simplification of the CMS ECal");

  TGeoMaterial *world_mat = new TGeoMaterial("world", 1, 2, 0);
  TGeoMedium *world_med   = new TGeoMedium("world_medium", 0, world_mat);
  TGeoVolume *world       = geom->MakeBox("top", world_med, world_x, world_y, world_z);

  geom->SetTopVolume(world);
  geom->SetTopVisible(1);

  int crystal_nphi    = nphi;
  int crystal_nz      = nz;
  double ecal_density = density;

  const int crystal_n    = crystal_nphi * crystal_nz;
  const double ecal_zmin = -3000.;
  const double ecal_zmax = 3000.;

  const double ecal_rmin = 10.;
  const double ecal_rmax = 5000.;
  const double ecal_dz   = 0.5 * (ecal_zmax - ecal_zmin) / crystal_nz;
  const double ecal_sphi = 0.;
  //    const G4double ecal_dphi  =  2.0*M_PI/crystal_nphi;
  // G4 seems to be in radian while TGeo seems to be in degree.
  // const double ecal_dphi  =  2.0*TMath::Pi()/crystal_nphi;
  const double ecal_dphi = 2.0 * 180 / crystal_nphi;

  int iptr = 0;

  TGeoElementTable *table = gGeoManager->GetElementTable();
  // TGeoElement* elPb = new TGeoElement( "Lead", "Pb", 82., 207.19*g/mole );
  // TGeoElement* elW = new TGeoElement( "Tungstenm", "W",74., 183.85*g/mole);
  // TGeoElement* elO = new TGeoElement( "Oxygen", "O2", 8., 16.*g/mole );
  TGeoElement *elPb = table->GetElement(82);
  TGeoElement *elW  = table->GetElement(74);
  TGeoElement *elO  = table->GetElement(8);
  // TGeoMaterial *ecal_mat = new TGeoMaterial("ecal",90,120,density);
  TGeoMixture *ecal_mat = new TGeoMixture("ecal_mat", 3, density);
  ecal_mat->AddElement(elPb, 1);
  ecal_mat->AddElement(elW, 1);
  ecal_mat->AddElement(elO, 4);
  TGeoMedium *ecal_med = new TGeoMedium("ecal_med", 0, ecal_mat);

  for (int j = 0; j < crystal_nz; ++j) {
    for (int i = 0; i < crystal_nphi; ++i) {

      iptr = i + j * crystal_nphi;

      TGeoVolume *ecal = geom->MakeTubs(TString::Format("ecal-%d-%d", j, i), ecal_med, ecal_rmin, ecal_rmax, ecal_dz,
                                        ecal_sphi + i * ecal_dphi, ecal_sphi + (i + 1) * ecal_dphi);
      ecal->SetLineColor(iptr);
      // top->AddNode(ecal,1,new TGeoCombiTrans(0,0,0,new TGeoRotation("ecal",0,0,0)));

      // GPThreeVector ecal_trans = GPThreeVector_create(0,0,ecal_zmin+(2.0*j+1.0)*ecal_dz);
      double dx                   = 0.0;
      double dy                   = 0.0;
      double dz                   = ecal_zmin + (2.0 * j + 1.0) * ecal_dz;
      TGeoTranslation *ecal_trans = new TGeoTranslation("", dx, dy, dz);

      //         GPLogicalVolume_Constructor(ecal_log+iptr, (GPVSolid*)ecal, ecal_mat);
      // GPVPhysicalVolume_Constructor(ecal_phy+iptr, idRot, ecal_trans, ecal_log+iptr);
      world->AddNode(ecal, iptr, ecal_trans);

      // Set mother
      //         GPVPhysicalVolume_SetMotherLogical(ecal_phy+iptr, world_log);

      //         addLogicalVolumePointers( ecal_log+iptr);
      //         addPhysicalVolumePointers( ecal_phy+iptr);
    }
  }

  // add daughter volume
  //   for ( int j=0; j < crystal_nz ; ++j ) {
  //      for ( int i=0; i < crystal_nphi ; ++i ) {
  //         iptr = i+j*crystal_nphi;
  //         addLogicalVolumeDaughter( world_log, ecal_phy+iptr);
  //      }
  //   }

  // Register world volume pointers for relocation
  //   addLogicalVolumePointers( world_log );
  //   addPhysicalVolumePointers( world_phy );

  geom->CloseGeometry();

  return world;
}
Beispiel #18
0
void assembly()
{
//--- Definition of a simple geometry
    gSystem->Load("libGeom");
    TGeoManager *geom = new TGeoManager("Assemblies",
                                        "Geometry using assemblies");
    Int_t i;
    //--- define some materials
    TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
    TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
//   //--- define some media
    TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
    TGeoMedium *Al = new TGeoMedium("Aluminium",2, matAl);

    //--- make the top container volume
    TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 1000., 1000., 100.);
    geom->SetTopVolume(top);

    // Make the elementary assembly of the whole structure
    TGeoVolume *tplate = new TGeoVolumeAssembly("TOOTHPLATE");

    Int_t ntooth = 5;
    Double_t xplate = 25;
    Double_t yplate = 50;
    Double_t xtooth = 10;
    Double_t ytooth = 0.5*yplate/ntooth;
    Double_t dshift = 2.*xplate + xtooth;
    Double_t xt,yt;

    TGeoVolume *plate = geom->MakeBox("PLATE", Al, xplate,yplate,1);
    plate->SetLineColor(kBlue);
    TGeoVolume *tooth = geom->MakeBox("TOOTH", Al, xtooth,ytooth,1);
    tooth->SetLineColor(kBlue);
    tplate->AddNode(plate,1);
    for (i=0; i<ntooth; i++) {
        xt = xplate+xtooth;
        yt = -yplate + (4*i+1)*ytooth;
        tplate->AddNode(tooth, i+1, new TGeoTranslation(xt,yt,0));
        xt = -xplate-xtooth;
        yt = -yplate + (4*i+3)*ytooth;
        tplate->AddNode(tooth, ntooth+i+1, new TGeoTranslation(xt,yt,0));
    }

    TGeoRotation *rot1 = new TGeoRotation();
    rot1->RotateX(90);
    TGeoRotation *rot;
    // Make a hexagone cell out of 6 tooth plates. These can zip together
    // without generating overlaps (they are self-contained)
    TGeoVolume *cell = new TGeoVolumeAssembly("CELL");
    for (i=0; i<6; i++) {
        Double_t phi =  60.*i;
        Double_t phirad = phi*TMath::DegToRad();
        Double_t xp = dshift*TMath::Sin(phirad);
        Double_t yp = -dshift*TMath::Cos(phirad);
        rot = new TGeoRotation(*rot1);
        rot->RotateZ(phi);
        cell->AddNode(tplate,i+1,new TGeoCombiTrans(xp,yp,0,rot));
    }

    // Make a row as an assembly of cells, then combine rows in a honeycomb
    // structure. This again works without any need to define rows as
    // "overlapping"
    TGeoVolume *row = new TGeoVolumeAssembly("ROW");
    Int_t ncells = 5;
    for (i=0; i<ncells; i++) {
        Double_t ycell = (2*i+1)*(dshift+10);
        row->AddNode(cell, ncells+i+1, new TGeoTranslation(0,ycell,0));
        row->AddNode(cell,ncells-i,new TGeoTranslation(0,-ycell,0));
    }

    Double_t dxrow = 3.*(dshift+10.)*TMath::Tan(30.*TMath::DegToRad());
    Double_t dyrow = dshift+10.;
    Int_t nrows = 5;
    for (i=0; i<nrows; i++) {
        Double_t xrow = 0.5*(2*i+1)*dxrow;
        Double_t yrow = 0.5*dyrow;
        if ((i%2)==0) yrow = -yrow;
        top->AddNode(row, nrows+i+1, new TGeoTranslation(xrow,yrow,0));
        top->AddNode(row, nrows-i, new TGeoTranslation(-xrow,-yrow,0));
    }

    //--- close the geometry
    geom->CloseGeometry();

    geom->SetVisLevel(4);
    geom->SetVisOption(0);
    top->Draw();
}
Beispiel #19
0
void
show
(
 char* inpDir  = "",         // MuDST directory
 char* inpFile = "show.lis", // MuDST file(s);                      
 char* outFile = "show.root",// output tree file
 Int_t nFiles  = 50,         // # of MuDST file(s)
 Int_t nEvents = 100         // # of events
 )
  // remeber to adjust dbase timestamp below !!!! 
  // what a ... design
{ 
  //gErrorIgnoreLevel=1999;

  // load root/root4star libraries
  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
  loadSharedLibraries();

  // load more libraries :)
  gSystem->Load("libmysqlclient");
  gSystem->Load("libGeom");
  gSystem->Load("StDbLib");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");

  // load even more libraries (EEMC stuff) 
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StEEmcDbMaker");
  gSystem->Load("StEEmcPoolTTM");

  // create the chain    
  chain = new StChain("StChain"); 
  //

  now = new TDatime;
  // for display
  TCanvas    *c1   = new TCanvas("eemc","eemc",10,10,1000,1000);
  TPaveLabel *tlab = new TPaveLabel(-0.99,+0.99,+0.99,+0.90,
				    "EEMC TOWERS & TPC TRACKS     Piotr A Zolnierczuk (IU)");

  eventInfo = new TPaveText (-0.99,-0.99,+0.0 ,-0.75);
  dateInfo  = new TPaveLabel(+0.60,-0.99,+0.99,-0.95,now->AsString());

  TGeoManager  *gm    = new TGeoManager("eemc", "eemc tower display");
  TGeoVolume   *top   = gm->MakeBox("star",0, 200., 200., 350.);
  TGeoVolume   *smbox = gm->MakeBox("smbox1",0, 2., 2., 2.);
  smbox->SetLineColor(kRed);
  // eemc 
  eemc  = new EEmcTTDisplay();
  eemc->SetMagneticField(0.5); // in Tesla
  eemc->SetShowExtrapolatedTracks(true);
 
  TGeoTranslation *etra = new TGeoTranslation(0.0,0.0,0.5*(eemc->getZ1()+eemc->getZ2()));
  top->AddNode(smbox, 1,NULL);
  top->AddNode(eemc(),1,etra);
  gm->SetTopVolume(top);
  gm->CloseGeometry();
  gm->SetVisLevel(4);
  gm->SetVisOption(0);

  c1->SetTheta(90);
  c1->SetPhi(0);

  top->Draw();
  tlab->Draw();

  gPad->Update();
  
  // now we add Makers to the chain...  some of that is black magic :) 
  muDstMk  = new StMuDstMaker(0,0,inpDir,inpFile,"",nFiles);       // muDST main chain
  StMuDbReader  *db       = StMuDbReader::instance();              // need the database
  St_db_Maker   *dbMk        = new St_db_Maker("StarDb", "MySQL:StarDb");   // need another db(?) 
  new StEEmcDbMaker("eemcDb");                     // need EEMC database  

  // now comment in/out/change the below if you want it your way
  dbMk->setTimeStampDay(20040331);   // format: yyyymmdd

  // finally after so many lines we arrive at the good stuff

  ttm = new  EEmcTTMMaker ("TTM",muDstMk,eemcDbMk);
  ttm->Summary(cout);    // 

  StMuDebug::setLevel(0);

  chain->Init();

  StEEmcDb *eemcDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb");
  eemcDb->setSectors(1,12);            // request EEMC DB for sectors you need (dafault:1-12)
  eemcDb->setPreferedFlavor("onlped","eemcPMTped"); // request alternative flavor

  chain->ls(3);

  //---------------------------------------------------
  next();
}
Beispiel #20
0
void create_aladin_geo(const char* geoTag)
{
  fGlobalTrans->SetTranslation(0.0,0.0,0.0);

  Double_t Aladin_width = 156.0;
  Double_t Aladin_length = 176.0;
  Double_t Aladin_gap = 52.;
  Double_t Aladin_angle = -7.0;
  Double_t DistanceToTarget = 350.0;
  Double_t Yoke_thickness = 52.;
  Double_t Correction = -95.0;
  Double_t DistanceFromtargetToAladinCenter = DistanceToTarget + Correction;
  TGeoRotation *rot_aladin = new TGeoRotation("Aladinrot");
  rot_aladin->RotateY(Aladin_angle);
  TGeoRotation *rot_mirror = new TGeoRotation("mirror");
  rot_mirror->RotateZ(180.0);
  rot_mirror->RotateY(Aladin_angle);
  
  
  
  // -------   Load media from media file   -----------------------------------
  FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
  TString medFile = geoPath + "/geometry/media_r3b.geo";
  geoFace->setMediaFile(medFile);
  geoFace->readMedia();
  gGeoMan = gGeoManager;
  // --------------------------------------------------------------------------
  
  
  
  // -------   Geometry file name (output)   ----------------------------------
  TString geoFileName = geoPath + "/geometry/aladin_";
  geoFileName = geoFileName + geoTag + ".geo.root";
  // --------------------------------------------------------------------------
  
  
  
  // -----------------   Get and create the required media    -----------------
  FairGeoMedia*   geoMedia = geoFace->getMedia();
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
  
  FairGeoMedium* mFe      = geoMedia->getMedium("iron");
  if ( ! mFe ) Fatal("Main", "FairMedium iron not found");
  geoBuild->createMedium(mFe);
  TGeoMedium* pMedFe = gGeoMan->GetMedium("iron");
  if ( ! pMedFe ) Fatal("Main", "Medium iron not found");
  
  FairGeoMedium* mHe      = geoMedia->getMedium("helium");
  if ( ! mHe ) Fatal("Main", "FairMedium helium not found");
  geoBuild->createMedium(mHe);
  TGeoMedium* pMed4 = gGeoMan->GetMedium("helium");
  if ( ! pMed4 ) Fatal("Main", "Medium helium not found");
  
  FairGeoMedium* mAl      = geoMedia->getMedium("aluminium");
  if ( ! mAl ) Fatal("Main", "FairMedium aluminium not found");
  geoBuild->createMedium(mAl);
  TGeoMedium* pMed21 = gGeoMan->GetMedium("aluminium");
  if ( ! pMed21 ) Fatal("Main", "Medium aluminium not found");
  
  FairGeoMedium* mAir      = geoMedia->getMedium("Air");
  if ( ! mAir ) Fatal("Main", "FairMedium Air not found");
  geoBuild->createMedium(mAir);
  TGeoMedium* pMed2 = gGeoMan->GetMedium("Air");
  if ( ! pMed2 ) Fatal("Main", "Medium Air not found");
  
  FairGeoMedium* mSteel      = geoMedia->getMedium("Steel");
  if ( ! mSteel ) Fatal("Main", "FairMedium Steel not found");
  geoBuild->createMedium(mSteel);
  TGeoMedium* pMedSteel = gGeoMan->GetMedium("Steel");
  if ( ! pMedSteel ) Fatal("Main", "Medium Steel not found");
  
  FairGeoMedium* mMylar      = geoMedia->getMedium("mylar");
  if ( ! mMylar ) Fatal("Main", "FairMedium mylar not found");
  geoBuild->createMedium(mMylar);
  TGeoMedium* pMedMylar = gGeoMan->GetMedium("mylar");
  if ( ! pMedMylar ) Fatal("Main", "Medium mylar not found");
  // --------------------------------------------------------------------------
  
  
  
  // --------------   Create geometry and top volume  -------------------------
  gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
  gGeoMan->SetName("ALADINgeom");
  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
  gGeoMan->SetTopVolume(top);
  // --------------------------------------------------------------------------
  
  
  
  TGeoVolume *cell = new TGeoVolumeAssembly("ALADINCELL");
  
  
  Double_t degrad = TMath::Pi()/180.;
  Double_t dx,dy,dz;
  Double_t pDx1,pDx2,pDx3,pDx4,pDy1,pDy2,pDz,pTheta,pPhi,pAlp1,pAlp2;
  Double_t fDx1, fDx2, fDy1, fDy2, fDz;
  Double_t thx, phx, thy, phy, thz, phz;
  
  
  // Yoke UP
  TGeoShape *solidFeYoke_up = new TGeoBBox("FeYoke_up",
                                           Aladin_width/2.0,
                                           Yoke_thickness/2.0,
                                           Aladin_length/2.0);
  
  TGeoTranslation *tr1 = new TGeoTranslation(0.0,
                                             Aladin_gap/2.0 + Yoke_thickness/2.0,
                                             DistanceFromtargetToAladinCenter
                                             );
  
  TGeoCombiTrans *t1
  = new TGeoCombiTrans(*tr1,*rot_aladin);
  
  TGeoVolume* pVolFeYoke_up = new TGeoVolume("FeYokeVolup",solidFeYoke_up, pMedFe);
  pVolFeYoke_up->SetVisLeaves(kTRUE);
  
  // Yoke Down
  TGeoShape *solidFeYoke_down = new TGeoBBox("FeYoke_down",
                                             Aladin_width/2.0,
                                             Yoke_thickness/2.0,
                                             Aladin_length/2.0);
  
  TGeoTranslation *tr2 = new TGeoTranslation(0.0,
                                             -1.0*(Aladin_gap/2.0+ Yoke_thickness/2.0),
                                             DistanceFromtargetToAladinCenter
                                             );
  
  TGeoCombiTrans *t2
  = new TGeoCombiTrans(*tr2,*rot_aladin);
  
  TGeoVolume* pVolFeYoke_down = new TGeoVolume("FeYokeVoldown",solidFeYoke_down, pMedFe);
  pVolFeYoke_down->SetVisLeaves(kTRUE);
  
  // Body
  //  --- Left side
  Double_t x0,y0,z0;
  Double_t xrot,yrot,zrot;
  //
  x0 = Aladin_width/2.0 + Yoke_thickness/2.0;
  y0 = 0.0;
  z0 = 0.0;
  zrot = z0*TMath::Cos(Aladin_angle*degrad) - x0*TMath::Sin(Aladin_angle*degrad) +
  DistanceFromtargetToAladinCenter;
  xrot = -1.0*z0*TMath::Sin(Aladin_angle*degrad) + x0*TMath::Cos(Aladin_angle*degrad);
  yrot = y0;
  
  // Yoke Left sided
  TGeoShape *solidFeYoke_left = new TGeoBBox("FeYoke_left",
                                             Yoke_thickness/2.0,
                                             Aladin_gap/2.0+Yoke_thickness,
                                             Aladin_length/2.0);
  
  TGeoTranslation *tr3 = new TGeoTranslation(xrot,
                                             yrot,
                                             zrot
                                             );
  
  TGeoCombiTrans *t3
  = new TGeoCombiTrans(*tr3,*rot_aladin);
  
  TGeoVolume* pVolFeYoke_left = new TGeoVolume("FeYokeVolleft",solidFeYoke_left, pMedFe);
  pVolFeYoke_left->SetVisLeaves(kTRUE);
  
  //  --- Right side
  x0 = -1.0 *(Aladin_width/2.0 + Yoke_thickness/2.0) ;
  y0 = 0.0;
  z0 = 0.0;
  zrot = z0*cos(Aladin_angle*degrad) - x0*sin(Aladin_angle*degrad) +
  DistanceFromtargetToAladinCenter;
  xrot = -1.0*z0*sin(Aladin_angle*degrad) + x0*cos(Aladin_angle*degrad);
  yrot = y0;
  
  // Yoke Down
  TGeoShape *solidFeYoke_right = new TGeoBBox("FeYoke_right",
                                              Yoke_thickness/2.0,
                                              Aladin_gap/2.0+Yoke_thickness,
                                              Aladin_length/2.0);
  
  TGeoTranslation *tr4 = new TGeoTranslation(xrot,
                                             yrot,
                                             zrot
                                             );
  
  TGeoCombiTrans *t4
  = new TGeoCombiTrans(*tr4,*rot_aladin);
  
  TGeoVolume* pVolFeYoke_right = new TGeoVolume("FeYokeVolright",solidFeYoke_right, pMedFe);
  pVolFeYoke_right->SetVisLeaves(kTRUE);
  
  
  
  cell->AddNode(pVolFeYoke_up,   1, t1);
  cell->AddNode(pVolFeYoke_down, 2, t2);
  cell->AddNode(pVolFeYoke_left, 3, t3);
  cell->AddNode(pVolFeYoke_right,4, t4);
  
  
  
  //-----------------------------------------------------------
  
  TGeoCombiTrans *pMatrix0 = new TGeoCombiTrans("");
  
  // Aladin chamber part1
  // Combi transformation:
  dx = 6.000000;
  dy = 0.000000;
  dz = 206.0;
  TGeoRotation *gRot1 = new TGeoRotation();
  gRot1->RotateX(0.);
  gRot1->RotateY(-7.000000);
  gRot1->RotateZ(0.);
  TGeoCombiTrans *pMatrix58 = new TGeoCombiTrans("", dx,dy,dz,gRot1);
  
  // Aladin chamber part2
  // Combi transformation:
  dx = -5.000000;
  dy = 0.000000;
  dz = 295.3;
  TGeoRotation *gRot2 = new TGeoRotation();
  gRot2->RotateX(0.);
  gRot2->RotateY(-7.000000);
  gRot2->RotateZ(0.);
  TGeoCombiTrans *pMatrix59 = new TGeoCombiTrans("", dx,dy,dz,gRot2);
  
  // Aladin chamber part3
  // Combi transformation:
  dx = -11.000000;
  dy = 0.000000;
  dz = 344.0;
  TGeoRotation *gRot3 = new TGeoRotation();
  gRot3->RotateX(0.);
  gRot3->RotateY(-7.000000);
  gRot3->RotateZ(0.);
  TGeoCombiTrans *pMatrix60 = new TGeoCombiTrans("", dx,dy,dz,gRot3);
  
  
  
  // Helium-Aladin chamber part1
  // Combi transformation:
  dx = 6.000000;
  dy = 0.000000;
  dz = 206.0;
  TGeoRotation *gRot4 = new TGeoRotation();
  gRot4->RotateX(0.);
  gRot4->RotateY(-7.000000);
  gRot4->RotateZ(0.);
  TGeoCombiTrans *pMatrix61 = new TGeoCombiTrans("", dx,dy,dz,gRot4);
  
  // Helium-Aladin chamber part2
  // Combi transformation:
  dx = -5.000000;
  dy = 0.000000;
  dz = 295.3;
  TGeoRotation *gRot5 = new TGeoRotation();
  gRot5->RotateX(0.);
  gRot5->RotateY(-7.000000);
  gRot5->RotateZ(0.);
  TGeoCombiTrans *pMatrix62 = new TGeoCombiTrans("", dx,dy,dz,gRot5);
  
  // Helium-Aladin chamber part3
  // Combi transformation:
  dx = -11.000000;
  dy = 0.000000;
  dz = 344.0;
  TGeoRotation *gRot6 = new TGeoRotation();
  gRot6->RotateX(0.);
  gRot6->RotateY(-7.000000);
  gRot6->RotateZ(0.);
  TGeoCombiTrans *pMatrix63 = new TGeoCombiTrans("", dx,dy,dz,gRot6);
  
  
  
  // incoming window - Steel
  // Combi transformation:
  dx = 16.400000;
  dy = 0.000000;
  dz = 117.5;
  TGeoRotation *gRot7 = new TGeoRotation();
  gRot7->RotateX(0.);
  gRot7->RotateY(-0.500000);
  gRot7->RotateZ(0.);
  TGeoCombiTrans *pMatrix64 = new TGeoCombiTrans("", dx,dy,dz,gRot7);
  
  // outgoing window - Mylar
  // Combi transformation:
  dx = -16.000000;
  dy = 0.000000;
  dz = 375.0;
  TGeoRotation *gRot8 = new TGeoRotation();
  gRot8->RotateX(0.);
  gRot8->RotateY(-7.000000);
  gRot8->RotateZ(0.);
  TGeoCombiTrans *pMatrix65 = new TGeoCombiTrans("", dx,dy,dz,gRot8);
  
  
  
  // incoming helium chamber befor Aladin
  // Combi transformation:
  dx = 15.500000;
  dy = 0.000000;
  dz = 126.1;
  TGeoRotation *gRot9 = new TGeoRotation();
  gRot9->RotateX(0.);
  gRot9->RotateY(-93.700000);
  gRot9->RotateZ(0.);
  TGeoCombiTrans *pMatrix66 = new TGeoCombiTrans("", dx,dy,dz,gRot9);
  
  
  
  // Aladin chamber part1
  Double_t xy[8][2];
  xy[0][0] = 60.90;	xy[0][1] = -21.5;
  xy[1][0] = 60.90;	xy[1][1] = 21.5;
  xy[2][0] = -60.90;	xy[2][1] = 21.5;
  xy[3][0] = -60.90;	xy[3][1] = -21.5;
  xy[4][0] = 67.1;	xy[4][1] = -22.3;
  xy[5][0] = 67.1;	xy[5][1] = 22.3;
  xy[6][0] = -67.1;	xy[6][1] = 22.3;
  xy[7][0] = -67.1;	xy[7][1] = -22.3;
  TGeoShape *pAladinChamber1 = new TGeoArb8("AladinChamber1", 72.0, &xy[0][0]);
  TGeoVolume* pAladinChamberLog1 = new TGeoVolume("AladinChamberLog1",pAladinChamber1, pMed21);
  //   pAWorld->AddNode(pAladinChamberLog,1,pMatrix58);
  
  // Aladin chamber part2
  //   Double_t xy[8][2];
  xy[0][0] = 67.1;	xy[0][1] = -22.3;
  xy[1][0] = 67.1;	xy[1][1] = 22.3;
  xy[2][0] = -67.1;	xy[2][1] = 22.3;
  xy[3][0] = -67.1;	xy[3][1] = -22.3;
  xy[4][0] = 69.1;	xy[4][1] = -23.4;
  xy[5][0] = 69.1;	xy[5][1] = 23.4;
  xy[6][0] = -69.1;	xy[6][1] = 23.4;
  xy[7][0] = -69.1;	xy[7][1] = -23.4;
  TGeoShape *pAladinChamber2 = new TGeoArb8("AladinChamber2", 17.8, &xy[0][0]);
  TGeoVolume* pAladinChamberLog2 = new TGeoVolume("AladinChamberLog2",pAladinChamber2, pMed21);
  
  // Aladin chamber part3
  //   Double_t xy[8][2];
  xy[0][0] = 69.1;	xy[0][1] = -23.4;
  xy[1][0] = 69.1;	xy[1][1] = 23.4;
  xy[2][0] = -69.1;	xy[2][1] = 23.4;
  xy[3][0] = -69.1;	xy[3][1] = -23.4;
  xy[4][0] = 79.05;	xy[4][1] = -28.5;
  xy[5][0] = 79.05;	xy[5][1] = 28.5;
  xy[6][0] = -79.05;	xy[6][1] = 28.5;
  xy[7][0] = -79.05;	xy[7][1] = -28.5;
  TGeoShape *pAladinChamber3 = new TGeoArb8("AladinChamber3", 30.95, &xy[0][0]);
  TGeoVolume* pAladinChamberLog3 = new TGeoVolume("AladinChamberLog3",pAladinChamber3, pMed21);
  
  
  
  // Helium-Aladin chamber part1
  Double_t ab[8][2];
  ab[0][0] = 60.40;	ab[0][1] = -21;
  ab[1][0] = 60.40;	ab[1][1] = 21;
  ab[2][0] = -60.40;	ab[2][1] = 21;
  ab[3][0] = -60.40;	ab[3][1] = -21;
  ab[4][0] = 66.6;	ab[4][1] = -21.8;
  ab[5][0] = 66.6;	ab[5][1] = 21.8;
  ab[6][0] = -66.6;	ab[6][1] = 21.8;
  ab[7][0] = -66.6;	ab[7][1] = -21.8;
  TGeoShape *pHeliumAladinChamber1 = new TGeoArb8("HeliumAladinChamber1", 72.0, &ab[0][0]);
  TGeoVolume* pHeliumAladinChamberLog1 = new TGeoVolume("HeliumAladinChamberLog1",pHeliumAladinChamber1, pMed4);
  
  // Helium-Aladin chamber part2
  ab[0][0] = 66.6;	ab[0][1] = -21.8;
  ab[1][0] = 66.6;	ab[1][1] = 21.8;
  ab[2][0] = -66.6;	ab[2][1] = 21.8;
  ab[3][0] = -66.6;	ab[3][1] = -21.8;
  ab[4][0] = 68.6;	ab[4][1] = -22.9;
  ab[5][0] = 68.6;	ab[5][1] = 22.9;
  ab[6][0] = -68.6;	ab[6][1] = 22.9;
  ab[7][0] = -68.6;	ab[7][1] = -22.9;
  TGeoShape *pHeliumAladinChamber2 = new TGeoArb8("HeliumAladinChamber2", 17.8, &ab[0][0]);
  TGeoVolume* pHeliumAladinChamberLog2 = new TGeoVolume("HeliumAladinChamberLog2",pHeliumAladinChamber2, pMed4);
  
  // Helium-Aladin chamber part3
  ab[0][0] = 68.6;	ab[0][1] = -22.9;
  ab[1][0] = 68.6;	ab[1][1] = 22.9;
  ab[2][0] = -68.6;	ab[2][1] = 22.9;
  ab[3][0] = -68.6;	ab[3][1] = -22.9;
  ab[4][0] = 78.55;	ab[4][1] = -28.0;
  ab[5][0] = 78.55;	ab[5][1] = 28.0;
  ab[6][0] = -78.55;	ab[6][1] = 28.0;
  ab[7][0] = -78.55;	ab[7][1] = -28.0;
  TGeoShape *pHeliumAladinChamber3 = new TGeoArb8("HeliumAladinChamber3", 30.95, &ab[0][0]);
  TGeoVolume* pHeliumAladinChamberLog3 = new TGeoVolume("HeliumAladinChamberLog3",pHeliumAladinChamber3, pMed4);
  
  
  // incoming window shape - Steel
  dx = 61.000000;
  dy = 26.000000;
  dz = 0.006500;
  TGeoShape *pinWINBox = new TGeoBBox("inWINBox", dx,dy,dz);
  TGeoVolume *pinWINLog = new TGeoVolume("inWINLog",pinWINBox, pMedSteel);
  
  // outgoing window shape - Mylar
  dx = 84.000000;
  dy = 34.000000;
  dz = 0.004950;
  TGeoShape *poutWINBox = new TGeoBBox("outWINBox", dx,dy,dz);
  TGeoVolume *poutWINLog = new TGeoVolume("outWINLog",poutWINBox, pMedMylar);
  
  
  // incoming helium chamber befor Aladin
  pDx1 = 11.685500;  //down
  pDx2 = 11.685500;  //down
  pDx3 = 4.863500;  //up
  pDx4 = 4.863500;  //up
  pDy1 = 19.900000;  //down
  pDy2 = 19.900000;  //up
  pDz  = 60.400000;
  pTheta = 0.000000;
  pPhi = 0.000000;
  pAlp1 = 0.00000;
  pAlp2 = 0.00000;
  TGeoShape *pinHELBox = new TGeoTrap("inHELBox", pDz,pTheta,pPhi,pDy1,pDx1,pDx2,pAlp1,pDy2,pDx3,pDx4,pAlp2);
  TGeoVolume *pinHELLog = new TGeoVolume("inHELLog",pinHELBox, pMed4);
  
  //
  
  /******************************************************/
  /*************      Aladin Front Flange  ************************/
  /*****************************************************/
  
  //Material steel, thickness 4cm, inner diameter: 20cm, outer diameter: 133.4 cm. Distance from xb centre: 112.87 cm
  //Combi transformation:
  dx = 0.000000;
  dy = 0.000000;
  dz = 114.870000;	//cm
  // Rotation:
  //thx = 0.000000;    phx = 0.000000;
  //thy = 0.000000;    phy = 0.000000;
  //thz = 0.000000;    phz = 0.000000;
  TGeoRotation *pMatrix15 = new TGeoRotation("ro0");
  TGeoCombiTrans* pMatrix14 = new TGeoCombiTrans("", dx,dy,dz,pMatrix15);
  
  double rmin = 10.000000;//radius, not diameter
  double rmax = 66.700000;
  dz   = 2.000000;//half thickness
  double phi1 = 0.000000;
  double phi2 = 360.000000;
  TGeoShape *pAladinFrontFlange = new TGeoTubeSeg("AladinFrontFlange",rmin,rmax,dz,phi1,phi2);
  TGeoVolume*  pAladinFrontFlangeLog = new TGeoVolume("AladinFrontFlangeLog",pAladinFrontFlange, pMedSteel);
  
  cell->AddNode(pAladinFrontFlangeLog,1,pMatrix14);
  
  /******************************************************/
  /*************      Aladin shape corrections  ************************/
  /*****************************************************/
  
  // Combi transformation "up":
  dx = 0.000000;
  dy = 25.900000;
  dz = 255.0;
  TGeoRotation *gRot11 = new TGeoRotation();
  gRot11->RotateX(180.);
  gRot11->RotateY(-7.000000);
  gRot11->RotateZ(0.);
  TGeoCombiTrans *pMatrix67 = new TGeoCombiTrans("", dx,dy,dz,gRot11);
  
  // shape "up":
  Double_t cd[8][2];
  cd[0][0] = 78.0;     cd[0][1] = 0.0;
  cd[1][0] = 78.0;     cd[1][1] = 0.001;
  cd[2][0] = -78.0;    cd[2][1] = 0.001;
  cd[3][0] = -78.0;    cd[3][1] = 0.0;
  cd[4][0] = 78.0;     cd[4][1] = 0.0;
  cd[5][0] = 78.0;     cd[5][1] = 1.0;
  cd[6][0] = -78.0;    cd[6][1] = 1.0;
  cd[7][0] = -78.0;    cd[7][1] = 0.0;
  TGeoShape *pAupBox = new TGeoArb8("AupBox", 88.0, &cd[0][0]);
  TGeoVolume* pAupLog = new TGeoVolume("AupLog",pAupBox, pMedFe);
  
  
  // Combi transformation "down":
  dx = 0.000000;
  dy = -25.900000;
  dz = 255.0;
  TGeoRotation *gRot12 = new TGeoRotation();
  gRot12->RotateX(0.);
  gRot12->RotateY(-7.000000);
  gRot12->RotateZ(0.);
  TGeoCombiTrans *pMatrix68 = new TGeoCombiTrans("", dx,dy,dz,gRot12);
  
  // shape "down":
  cd[0][0] = 78.0;     cd[0][1] = 0.0;
  cd[1][0] = 78.0;     cd[1][1] = 1.0;
  cd[2][0] = -78.0;    cd[2][1] = 1.0;
  cd[3][0] = -78.0;    cd[3][1] = 0.0;
  cd[4][0] = 78.0;     cd[4][1] = 0.0;
  cd[5][0] = 78.0;     cd[5][1] = 0.001;
  cd[6][0] = -78.0;    cd[6][1] = 0.001;
  cd[7][0] = -78.0;    cd[7][1] = 0.0;
  TGeoShape *pAdownBox = new TGeoArb8("AdownBox", 88.0, &cd[0][0]);
  TGeoVolume* pAdownLog = new TGeoVolume("AdownLog",pAdownBox, pMedFe);
  
  
  
  //   pAWorld->AddNode(pHeliumAladinChamberLog1,1,pMatrix61);
  //   pAWorld->AddNode(pHeliumAladinChamberLog2,1,pMatrix62);
  //   pAWorld->AddNode(pHeliumAladinChamberLog3,1,pMatrix63);
  
  pAladinChamberLog1->AddNode(pHeliumAladinChamberLog1,1,pMatrix0);
  pAladinChamberLog2->AddNode(pHeliumAladinChamberLog2,1,pMatrix0);
  pAladinChamberLog3->AddNode(pHeliumAladinChamberLog3,1,pMatrix0);
  
  cell->AddNode(pAladinChamberLog1,1,pMatrix58);
  cell->AddNode(pAladinChamberLog2,1,pMatrix59);
  cell->AddNode(pAladinChamberLog3,1,pMatrix60);
  
  cell->AddNode(pinWINLog,1,pMatrix64);
  cell->AddNode(poutWINLog,1,pMatrix65);
  
  cell->AddNode(pinHELLog,1,pMatrix66);
  
  cell->AddNode(pAupLog,1,pMatrix67);
  cell->AddNode(pAdownLog,1,pMatrix68);


    TGeoVolumeAssembly* top_cell = new TGeoVolumeAssembly("ALADIN");

    TGeoCombiTrans* inverse_matr = new TGeoCombiTrans("");
    inverse_matr->SetTranslation(0., 0., -1. * DistanceFromtargetToAladinCenter);
    inverse_matr->RotateY(-1. * Aladin_angle);
    top_cell->AddNode(cell, 1, inverse_matr);

    TGeoCombiTrans* aladin_matr = new TGeoCombiTrans(0., 0., DistanceFromtargetToAladinCenter, rot_aladin);

  
  top->AddNode(top_cell, 1, aladin_matr);
  
  
  
  // ---------------   Finish   -----------------------------------------------
  gGeoMan->CloseGeometry();
  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();
  
  TFile* geoFile = new TFile(geoFileName, "RECREATE");
  top->Write();
  geoFile->Close();
  // --------------------------------------------------------------------------
}
Beispiel #21
0
void complex_1()
{
   gROOT->GetListOfCanvases()->Delete();
   TCanvas *c = new TCanvas("composite shape", "A * B - C", 700, 1000);

   c->Divide(1,2,0,0);
   c->cd(2);
   gPad->SetPad(0,0,1,0.4);
   c->cd(1);
   gPad->SetPad(0,0.4,1,1);
   
   if (gGeoManager) delete gGeoManager;
   
   new TGeoManager("xtru", "poza12");
   TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
   TGeoMedium *med = new TGeoMedium("MED",1,mat);
   TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
   gGeoManager->SetTopVolume(top);

   // define shape components with names
   TGeoBBox *box = new TGeoBBox("box", 20., 20., 20.); 
   TGeoBBox *box1 = new TGeoBBox("box1", 5., 5., 5.); 
   TGeoSphere *sph = new TGeoSphere("sph", 5., 25.);
   TGeoSphere *sph1 = new TGeoSphere("sph1", 1., 15.);
   // create the composite shape based on a Boolean expression
   TGeoTranslation *tr = new TGeoTranslation(0., 30., 0.);
   TGeoTranslation *tr1 = new TGeoTranslation(0., 40., 0.);
   TGeoTranslation *tr2 = new TGeoTranslation(0., 30., 0.);
   TGeoTranslation *tr3 = new TGeoTranslation(0., 30., 0.);
   tr->SetName("tr");
   tr1->SetName("tr1");
   tr2->SetName("tr2");
   tr3->SetName("tr3");
   // register all used transformations
   tr->RegisterYourself();
   tr1->RegisterYourself();
   tr2->RegisterYourself();
   tr3->RegisterYourself();

   TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "(sph * box) + (sph1:tr - box1:tr1)");

   TGeoVolume *vol = new TGeoVolume("COMP4",cs);
//   vol->SetLineColor(randomColor());
   top->AddNode(vol,1);
   gGeoManager->CloseGeometry();
   gGeoManager->SetNsegments(80);
   top->Draw();
   MakePicture();

   c->cd(2);
   TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
   pt->SetLineColor(1);
   TText *text = pt->AddText("TGeoCompositeShape - composite shape class");
   text->SetTextColor(2);
   pt->AddText("----- (sphere * box) + (sphere - box) ");

   pt->AddText(" ");
   pt->SetAllWith("-----","color",4);
   pt->SetAllWith("-----","font",72);
   pt->SetAllWith("-----","size",0.04);
   pt->SetTextAlign(12);
   pt->SetTextSize(0.044);
   pt->Draw();
   c->cd(1);

}
Beispiel #22
0
void glViewerLOD(Int_t reqNodes = 1000, Bool_t randomDist = kTRUE,
                 Bool_t reqSpheres = kTRUE, Bool_t reqTubes = kTRUE)
{
   TGeoManager * geom = new TGeoManager("LODTest", "GL viewer LOD test");
   geom->SetNsegments(4); // Doesn't matter keep low
   TGeoMaterial *matEmptySpace = new TGeoMaterial("EmptySpace", 0, 0, 0);
   TGeoMaterial *matSolid      = new TGeoMaterial("Solid"    , .938, 1., 10000.);

   TGeoMedium *medEmptySpace = new TGeoMedium("Empty", 1, matEmptySpace);
   TGeoMedium *medSolid      = new TGeoMedium("Solid", 1, matSolid);

   Double_t sizeBase = 20.0;
   Double_t worldRadius;
   if (randomDist) {
      worldRadius = pow(reqNodes,.5)*sizeBase;
   } else {
      worldRadius = pow(reqNodes,.3)*sizeBase;
   }

   TGeoVolume *top = geom->MakeBox
      ("WORLD", medEmptySpace, worldRadius, worldRadius, worldRadius);
   geom->SetTopVolume(top);

   gRandom->SetSeed();

   // Create random number of unique sphere shapes - up to 25% of
   // total placed sphere requested
   UInt_t volumeCount = gRandom->Integer(reqNodes/4)+1;
   TGeoVolume ** volumes = new TGeoVolume[volumeCount];
   TGeoVolume * volume;

   Double_t dummy;

   for (UInt_t i = 0; i < volumeCount; i++) {
      char name[128];
      sprintf(name, "Volume_%d", i);

      // Random volume shape
      Int_t type = -1;
      if (reqSpheres && reqTubes) {
         type = gRandom->Integer(2);
         if (type == 1)
            type += gRandom->Integer(3);
      }
      else if(reqSpheres)
         type = 0;
      else if(reqTubes)
         type = 1 + gRandom->Integer(3);

      // Random dimensions
      Double_t rMin = gRandom->Rndm() * sizeBase;
      Double_t rMax = rMin + gRandom->Rndm() * sizeBase * 2.0;
      Double_t dz   = pow(gRandom->Rndm(),2.0) * sizeBase * 15.0;
      Double_t phi1 = gRandom->Rndm() * 90.0;
      Double_t phi2 = phi1 + gRandom->Rndm() * 270.0;

      // Pick random color (not black)
      Int_t color = gRandom->Integer(50);
      if (color == kBlack) color += 1;

      switch (type) {
        case 0: {
            // GL viewer only supports solid spheres (0. inner radius)
            volumes[i] = geom->MakeSphere(name,  medSolid,  0., rMax);
            printf("Volume %d : Color %d, Sphere, Radius %f\n", i, color, rMax);
            break;
         }
         case 1: {
            volumes[i] = geom->MakeTube(name,  medSolid,  rMin, rMax, dz);
            printf("Volume %d : Color %d, Tube, Inner Radius %f, "
                   "Outer Radius %f, Length %f\n",
                   i, color, rMin, rMax, dz);
            break;
         }
         case 2: {
            volumes[i] = geom->MakeTubs(name,  medSolid,  rMin, rMax, dz,
                                        phi1, phi2);
            printf("Volume %d : Color %d, Tube Seg, Inner Radius %f, "
                   "Outer Radius %f, Length %f, Phi1 %f, Phi2 %f\n",
                   i, color, rMin, rMax, dz, phi1, phi2);
            break;
         }
         case 3: {
            Double_t n1[3], n2[3];
            n1[0] = gRandom->Rndm()*.5;
            n1[1] = gRandom->Rndm()*.5; n1[2] = -1.0 + gRandom->Rndm()*.5;
            n2[0] = gRandom->Rndm()*.5;
            n2[1] = gRandom->Rndm()*.5; n2[2] =  1.0 - gRandom->Rndm()*.5;

            volumes[i] = geom->MakeCtub(name,  medSolid,  rMin, rMax, dz,
                                        phi1, phi2, n1[0], n1[1], n1[2],
                                        n2[0], n2[1], n2[2]);
            printf("Volume %d : Color %d, Cut Tube, Inner Radius %f, "
                   "Outer Radius %f, Length %f, Phi1 %f, Phi2 %f, "
                   "n1 (%f,%f,%f), n2 (%f,%f,%f)\n",
                   i, color, rMin, rMax, dz, phi1, phi2,
                   n1[0], n1[1], n1[2], n2[0], n2[1], n2[2]);
            break;
         }
         default: {
            assert(kFALSE);
         }
      }

      volumes[i]->SetLineColor(color);
   }

   printf("\nCreated %d volumes\n\n", volumeCount);

   // Scatter reqSpheres placed sphere randomly in space
   Double_t x, y, z;
   for (i = 0; i < reqNodes; i++) {
      // Pick random volume
      UInt_t useVolume = gRandom->Integer(volumeCount);

      TGeoTranslation * trans;
      TGeoRotation * rot;
      if (randomDist) {
         // Random translation
         gRandom->Rannor(x, y);
         gRandom->Rannor(z,dummy);
         trans = new TGeoTranslation(x*worldRadius, y*worldRadius, z*worldRadius);

         // Random rotation
         gRandom->Rannor(x, y);
         gRandom->Rannor(z,dummy);
         rot = new TGeoRotation("rot", x*360.0, y*360.0, z*360.0);
      } else {
         UInt_t perSide = pow(reqNodes,1.0/3.0)+0.5;
         Double_t distance = sizeBase*5.0;
         UInt_t xi, yi, zi;
         zi = i / (perSide*perSide);
         yi = (i / perSide) % perSide;
         xi = i % perSide;
         trans = new TGeoTranslation(xi*distance,yi*distance,zi*distance);
         rot = new TGeoRotation("rot",0.0, 0.0, 0.0);
      }
      top->AddNode(volumes[useVolume], i, new TGeoCombiTrans(*trans, *rot));
      //printf("Added node %d (Volume %d)\n", i, useVolume);
   }
   geom->CloseGeometry();
   top->Draw("ogl");
}
Beispiel #23
0
void snoopy()
{
   TGeoManager *geom = new TGeoManager("snoopy", "Snoopy Detector");

   // define some materials
   TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0);
   TGeoMaterial *matAl     = new TGeoMaterial("Al", 26.98, 13, 2.7);
   TGeoMaterial *matFe     = new TGeoMaterial("Fe", 55.84, 26, 7.9);
      
   // define some media
   TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum);
   TGeoMedium *Al     = new TGeoMedium("Al", 2, matAl);
   TGeoMedium *Fe     = new TGeoMedium("Fe", 3, matFe);
      
   // create top volume
   TGeoVolume *top = geom->MakeBox("top", Vacuum, 600, 600, 2500);
   geom->SetTopVolume(top);
   geom->SetTopVisible(0);
   
   // first part of vacuum chamber up to veto station
   TGeoVolume *tub1 = geom->MakeTube("tub1", Al, 245, 250, 50);
   tub1->SetLineColor(18);  // silver/gray
   top->AddNode(tub1, 1, new TGeoTranslation(0, 0, -2450));
   
   // veto station
   TGeoBBox *detbox1 = new TGeoBBox("detbox1", 250, 250, 10);
   TGeoBBox *detbox2 = new TGeoBBox("detbox2", 245, 245, 10);
   
   TGeoCompositeShape *detcomp1 = new TGeoCompositeShape("detcomp1", "detbox1-detbox2");
   TGeoVolume *det1 = new TGeoVolume("det1", detcomp1,Vacuum);
   det1->SetLineColor(kRed);
   top->AddNode(det1, 1, new TGeoTranslation(0, 0, -2390));
   TGeoRotation r0;
   r0.SetAngles(15,0,0);
   TGeoTranslation t0(0, 0, -2370);
   TGeoCombiTrans c0(t0, r0);
   TGeoHMatrix *h0 = new TGeoHMatrix(c0);
   top->AddNode(det1, 11, h0);
   
   // second part of vacuum chamber up to first tracking station
   TGeoVolume *tub2 = geom->MakeTube("tub2", Al, 245, 250, 3880/2);  // 1890
   tub2->SetLineColor(18);
   top->AddNode(tub2, 1, new TGeoTranslation(0, 0, -440));
   
   // tracking station 1
   top->AddNode(det1, 2, new TGeoTranslation(0, 0, 1510));
   TGeoRotation r1;
   r1.SetAngles(15,0,0);
   TGeoTranslation t1(0, 0, 1530);
   TGeoCombiTrans c1(t1, r1);
   TGeoHMatrix *h1 = new TGeoHMatrix(c1);
   top->AddNode(det1, 3, h1);
   
   // third part of vacuum chamber up to second tracking station
   TGeoVolume *tub3 = geom->MakeTube("tub3", Al, 245, 250, 80);
   tub3->SetLineColor(18);
   top->AddNode(tub3, 1, new TGeoTranslation(0, 0, 1620));
   
   // tracking station 2
   top->AddNode(det1, 4, new TGeoTranslation(0, 0, 1710));
   TGeoRotation r2;
   r2.SetAngles(15,0,0);
   TGeoTranslation t2(0, 0, 1730);
   TGeoCombiTrans c2(t2, r2);
   TGeoHMatrix *h2 = new TGeoHMatrix(c2);
   top->AddNode(det1, 5, h2);
 
   // fourth part of vacuum chamber up to third tracking station and being covered by magnet
   TGeoVolume *tub4 = geom->MakeTube("tub4", Al, 245, 250, 200);
   tub4->SetLineColor(18);
   top->AddNode(tub4, 1, new TGeoTranslation(0, 0, 1940));

   // magnet yoke
   TGeoBBox *magyoke1 = new TGeoBBox("magyoke1", 350, 350, 125);
   TGeoBBox *magyoke2 = new TGeoBBox("magyoke2", 250, 250, 126);
   
   TGeoCompositeShape *magyokec = new TGeoCompositeShape("magyokec", "magyoke1-magyoke2");
   TGeoVolume *magyoke = new TGeoVolume("magyoke", magyokec, Fe);
   magyoke->SetLineColor(kBlue);
   //magyoke->SetTransparency(50);
   top->AddNode(magyoke, 1, new TGeoTranslation(0, 0, 1940));

   // magnet
   TGeoTubeSeg *magnet1a = new TGeoTubeSeg("magnet1a", 250, 300, 35, 45, 135);
   TGeoTubeSeg *magnet1b = new TGeoTubeSeg("magnet1b", 250, 300, 35, 45, 135);
   TGeoTubeSeg *magnet1c = new TGeoTubeSeg("magnet1c", 250, 270, 125, 45, 60);
   TGeoTubeSeg *magnet1d = new TGeoTubeSeg("magnet1d", 250, 270, 125, 120, 135);

   // magnet composite shape matrices   
   TGeoTranslation *m1 = new TGeoTranslation(0, 0, 160);
   m1->SetName("m1");
   m1->RegisterYourself();
   TGeoTranslation *m2 = new TGeoTranslation(0, 0, -160);
   m2->SetName("m2");
   m2->RegisterYourself();

   TGeoCompositeShape *magcomp1 = new TGeoCompositeShape("magcomp1", "magnet1a:m1+magnet1b:m2+magnet1c+magnet1d");
   TGeoVolume *magnet1 = new TGeoVolume("magnet1", magcomp1, Fe);
   magnet1->SetLineColor(kYellow);
   top->AddNode(magnet1, 1, new TGeoTranslation(0, 0, 1940));

   TGeoRotation m3;
   m3.SetAngles(180, 0, 0);
   TGeoTranslation m4(0, 0, 1940);
   TGeoCombiTrans m5(m4, m3);
   TGeoHMatrix *m6 = new TGeoHMatrix(m5);
   top->AddNode(magnet1, 2, m6);

   // tracking station 3
   top->AddNode(det1, 6, new TGeoTranslation(0, 0, 2150));
   TGeoRotation r3;
   r3.SetAngles(15,0,0);
   TGeoTranslation t3(0, 0, 2170);
   TGeoCombiTrans c3(t3, r3);
   TGeoHMatrix *h3 = new TGeoHMatrix(c3);
   top->AddNode(det1, 7, h3);
   
   // fifth part of vacuum chamber up to fourth tracking station
   TGeoVolume *tub5 = geom->MakeTube("tub5", Al, 245, 250, 90);
   tub5->SetLineColor(18);
   top->AddNode(tub5, 1, new TGeoTranslation(0, 0, 2270));

   // tracking station 4
   top->AddNode(det1, 8, new TGeoTranslation(0, 0, 2370));
   TGeoRotation r4;
   r4.SetAngles(15,0,0);
   TGeoTranslation t4(0, 0, 2390);
   TGeoCombiTrans c4(t4, r4);
   TGeoHMatrix *h4 = new TGeoHMatrix(c4);
   top->AddNode(det1, 9, h4);

   // ecal
   TGeoVolume *ecal = geom->MakeBox("ecal", Al, 250, 250, 40);
   ecal->SetLineColor(6); // purple
   top->AddNode(ecal, 1, new TGeoTranslation(0, 0, 2440)); 
   
   // muon filter
   TGeoVolume *muonfilter = geom->MakeBox("muonfilter", Al, 250, 250, 20);
   muonfilter->SetLineColor(kGreen);
   top->AddNode(muonfilter, 1, new TGeoTranslation(0, 0, 2500));

   // sixth part of vacuum chamber up to muon detector
   TGeoVolume *tub6 = geom->MakeTube("tub6", Al, 245, 250, 20);
   tub6->SetLineColor(18);
   top->AddNode(tub6, 1, new TGeoTranslation(0, 0, 2540));

   // muon detector
   top->AddNode(det1, 10, new TGeoTranslation(0, 0, 2570));
   TGeoRotation r5;
   r5.SetAngles(15,0,0);
   TGeoTranslation t5(0, 0, 2590);
   TGeoCombiTrans c5(t5, r5);
   TGeoHMatrix *h5 = new TGeoHMatrix(c5);
   top->AddNode(det1, 12, h5);
   
   geom->CloseGeometry();   
   top->Draw("ogl");
   geom->Export("snoopy.gdml");

}
// -------   Main function for creating the geo   ------------------------------
void create_tragaldabas_geo(const char* geoTag)
{
  // Usage: select the geoTag when calling the macro for a new CALIFA geo
  // Possible geoTag values: 
  // geoTag           - Short description 
  // 0                - Initial Tragaldabas basic geometry


  // -------   Load media from media file   -----------------------------------
  FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
  TString medFile = geoPath + "/tragaldabas/geometry/media_ensar.geo";
  geoFace->setMediaFile(medFile);
  geoFace->readMedia();
  gGeoMan = gGeoManager;
  // --------------------------------------------------------------------------

  // -------   Geometry file name (output)   ----------------------------------
  TString geoFileName = geoPath + "/tragaldabas/geometry/tragaldabas_";
  geoFileName = geoFileName + geoTag + ".geo.root";
  // --------------------------------------------------------------------------

  // -----------------   Get and create the required media    -----------------
  FairGeoMedia*   geoMedia = geoFace->getMedia();
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();

  FairGeoMedium* mAir      = geoMedia->getMedium("Air");
  if ( ! mAir ) Fatal("Main", "FairMedium Air not found");
  geoBuild->createMedium(mAir);
  TGeoMedium* pAirMedium = gGeoMan->GetMedium("Air");
  if ( ! pAirMedium ) Fatal("Main", "Medium Air not found");

  FairGeoMedium* mAluminium      = geoMedia->getMedium("aluminium");
  if ( ! mAluminium ) Fatal("Main", "FairMedium Aluminium not found");
  geoBuild->createMedium(mAluminium);
  TGeoMedium* pAluminiumMedium = gGeoMan->GetMedium("aluminium");
  if ( ! pAluminiumMedium ) Fatal("Main", "Medium Aluminium not found");

  FairGeoMedium* mCopper      = geoMedia->getMedium("copper");
  if ( ! mCopper ) Fatal("Main", "FairMedium Copper not found");
  geoBuild->createMedium(mCopper);
  TGeoMedium* pCopperMedium = gGeoMan->GetMedium("copper");
  if ( ! pCopperMedium ) Fatal("Main", "Medium Copper not found");

  FairGeoMedium* mCar      = geoMedia->getMedium("CarbonFibre");
  if ( ! mCar ) Fatal("Main", "FairMedium CarbonFibre not found");
  geoBuild->createMedium(mCar);
  TGeoMedium* pCarbonFibreMedium = gGeoMan->GetMedium("CarbonFibre");
  if ( ! pCarbonFibreMedium ) Fatal("Main", "Medium CarbonFibre not found");

//TODO: create metacrilate!!!! (create in media_ensar.geo)
  //FairGeoMedium* mMetacrilate      = geoMedia->getMedium("metacrilate");
  //if ( ! mMetacrilate ) Fatal("Main", "FairMedium Metacrilate not found");
  //geoBuild->createMedium(mMetacrilate);
  //TGeoMedium* pMetacrilateMedium = gGeoMan->GetMedium("Metacrilate");
  //if ( ! pMetacrilateMedium ) Fatal("Main", "Medium Metacrilate not found");

  FairGeoMedium* mRPCGlass      = geoMedia->getMedium("RPCglass");
  if ( ! mRPCGlass ) Fatal("Main", "FairMedium RPCGlass not found");
  geoBuild->createMedium(mRPCGlass);
  TGeoMedium* pRPCGlassMedium = gGeoMan->GetMedium("RPCglass");
  if ( ! pRPCGlassMedium ) Fatal("Main", "Medium RPCGlass not found");

//TODO: change to RPCGasR134A material  (create in media_ensar.geo)
  FairGeoMedium* mRPCGasR134A      = geoMedia->getMedium("RPCgas");
  if ( ! mRPCGasR134A ) Fatal("Main", "FairMedium RPCGasR134A not found");
  geoBuild->createMedium(mRPCGasR134A);
  TGeoMedium* pRPCGasR134AMedium = gGeoMan->GetMedium("RPCgas");
  if ( ! pRPCGasR134AMedium ) Fatal("Main", "Medium RPCGasR134A not found");
 
  FairGeoMedium* mTfl      = geoMedia->getMedium("Tefflon");
  if ( ! mTfl ) Fatal("Main", "FairMedium Tefflon not found");
  geoBuild->createMedium(mTfl);
  TGeoMedium* pWrappingMedium = gGeoMan->GetMedium("Tefflon");
  if ( ! pWrappingMedium ) Fatal("Main", "Medium Tefflon not found");
  // --------------------------------------------------------------------------

  // --------------   Create geometry and top volume  -------------------------
  gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
  gGeoMan->SetName("TragaldabasGeom");
  TGeoVolume* top = new TGeoVolumeAssembly("TRA_World");
  gGeoMan->SetTopVolume(top);
  // --------------------------------------------------------------------------

  //WORLD
  //TGeoVolume *pAWorld  =  top;
  
  // Defintion of the Mother Volume (cube of 2.0 meters side)
  Double_t length = 200.;
  TGeoShape *pTragaShape = new TGeoBBox("Traga_boxOut",
  		length/2.0,length/2.0,length/2.0);
  TGeoVolume* pTragaWorld = new TGeoVolume("TragaWorld",pTragaShape, pAirMedium);
  
  TGeoCombiTrans *t0 = new TGeoCombiTrans();
  TGeoCombiTrans *pGlobalc = GetGlobalPosition(t0);
  
  // add the cube (pTragaWorld) as Mother Volume
  top->AddNode(pTragaWorld, 0, pGlobalc);

//TODO: Check the X-Y dimensions for all the objects defined below!!

  //MODULE KeepIn Volume, 1 cm larger in each dimension than aluminum box
  TGeoVolume *RPC_KeepInVolume=gGeoManager->MakeBox("RPC_KeepInVolume", pAirMedium,
  		166.0/2,129.5/2,3.6/2); 
  RPC_KeepInVolume->SetVisibility(kFALSE); //invisible KIV

  TGeoRotation *rotUni = new TGeoRotation(); //unitary rotation  

  pTragaWorld->AddNode(RPC_KeepInVolume,0,new TGeoCombiTrans(0.,0.,-90.,rotUni)); 
  pTragaWorld->AddNode(RPC_KeepInVolume,1,new TGeoCombiTrans(0.,0.,0.,rotUni)); 
  pTragaWorld->AddNode(RPC_KeepInVolume,2,new TGeoCombiTrans(0.,0.,30.,rotUni)); 
  pTragaWorld->AddNode(RPC_KeepInVolume,3,new TGeoCombiTrans(0.,0.,90.,rotUni)); 

  //Aluminum box containing the whole chamber, 3mm thick, laterals 5mm thick
  TGeoVolume *RPC_AluBox=gGeoManager->MakeBox("RPC_AluBox", pAluminiumMedium,
  		165.0/2,128.5/2,2.6/2); 
  RPC_KeepInVolume->AddNode(RPC_AluBox,0,new TGeoCombiTrans(0.,0.,0.,rotUni));
  RPC_AluBox->SetVisibility(kTRUE); //invisible KIV
  RPC_AluBox->SetLineColor(kRed); 

  TGeoVolume *RPC_AluInBox=gGeoManager->MakeBox("RPC_AluInBox", pAirMedium,
  		164.0/2,127.5/2,2.0/2); 
  RPC_AluBox->AddNode(RPC_AluInBox,0,new TGeoCombiTrans(0.,0.,0,rotUni)); 
  RPC_AluInBox->SetVisibility(kFALSE); //invisible interior volume (air)

  //Foam (box) between aluminium box and copper PCB 
  //TODO! Change to a proper Medium: needed the density and composition 
  TGeoVolume *RPC_FoamBox=gGeoManager->MakeBox("RPC_FoamBox", pAirMedium, 	
  		163.0/2,126.5/2,0.87/2); 
  RPC_AluInBox->AddNode(RPC_FoamBox,0,new TGeoCombiTrans(0.,0.,0.565,rotUni)); 
  RPC_FoamBox->SetLineColor(kYellow); 

  //copper (box) between foam box and the PCB
  //NOTE: It is not divided at this stage. It is also NOT the sensitive
  //material, but signals are going to be taken from the gas, dividing it
  //with the proper copper-pad segmentation.
  TGeoVolume *RPC_CopperBox=gGeoManager->MakeBox("RPC_CopperBox", pCopperMedium, 	
  		163.0/2,126.5/2,0.003/2); 
  RPC_AluInBox->AddNode(RPC_CopperBox,0,new TGeoCombiTrans(0.,0.,0.1285,rotUni)); 
  RPC_CopperBox->SetLineColor(kRed); 

 //PCB (box) between copper and the metacrilate
  //NOTE (TODO?) Using Carbon Fibre material for the PCB. Ask for more info.
  TGeoVolume *RPC_PCBBox=gGeoManager->MakeBox("RPC_PCBBox", pCarbonFibreMedium, 	
  		163.0/2,126.5/2,0.157/2); 
  RPC_AluInBox->AddNode(RPC_PCBBox,0,new TGeoCombiTrans(0.,0.,0.0485,rotUni)); 
  RPC_PCBBox->SetLineColor(kGreen); 


  //Metacrilate box containing gas and glass
  //TODO: change the medium to metacrilate
  TGeoVolume *RPC_MetaBox=gGeoManager->MakeBox("RPC_MetaBox", pRPCGlassMedium, 	
  		163.0/2,126.5/2,0.97/2); 
  RPC_AluInBox->AddNode(RPC_MetaBox,0,new TGeoCombiTrans(0.,0.,-0.515,rotUni)); 
  RPC_MetaBox->SetLineColor(kWhite); 

  TGeoVolume *RPC_MetaInBox=gGeoManager->MakeBox("RPC_MetaInBox", pRPCGasR134AMedium, 	
  		160.0/2,123.5/2,0.77/2); 
  RPC_MetaBox->AddNode(RPC_MetaInBox,0,new TGeoCombiTrans(0.,0.,0.,rotUni)); 
  RPC_MetaInBox->SetVisibility(kFALSE); //invisible interior volume (gas)

  //Glass planes in the gas (medium of RPC_MetaInBox volume)
  TGeoVolume *RPC_GlassBox=gGeoManager->MakeBox("RPC_GlassBox", pRPCGlassMedium, 	
  		155.5/2,122.5/2,0.19/2); 
  RPC_MetaInBox->AddNode(RPC_GlassBox,0,new TGeoCombiTrans(0.,0.,-0.29,rotUni)); 
  RPC_MetaInBox->AddNode(RPC_GlassBox,1,new TGeoCombiTrans(0.,0.,0.,rotUni)); 
  RPC_MetaInBox->AddNode(RPC_GlassBox,2,new TGeoCombiTrans(0.,0.,0.29,rotUni)); 
  RPC_GlassBox->SetLineColor(kBlue); 

  //Gas (planes) already in the gas (sensitive volumes where ionization takes place)
  TGeoVolume *RPC_GasBox=gGeoManager->MakeBox("RPC_GasBox", pRPCGasR134AMedium, 	
  		151.2/2,121.0/2,0.1/2); 
  RPC_MetaInBox->AddNode(RPC_GasBox,0,new TGeoCombiTrans(0.,0.,-0.145,rotUni)); 
  RPC_MetaInBox->AddNode(RPC_GasBox,1,new TGeoCombiTrans(0.,0.,0.145,rotUni)); 
  RPC_GasBox->SetVisibility(kFALSE); //invisible interior volume (gas)

  // ---------------   Finish   -----------------------------------------------
  gGeoMan->CloseGeometry();
  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();

  TFile* geoFile = new TFile(geoFileName, "RECREATE");
  top->Write();
  geoFile->Close();
  // --------------------------------------------------------------------------
}
void create_neuland_geo(const char* geoTag)
{

  fGlobalTrans->SetTranslation(0.0,0.0,0.0);

  Double_t neuLAND_paddle_dimx   = 125.;   // half of the length [cm]
  Double_t neuLAND_paddle_dimy   = 2.4;    // half of the width [cm]
  Double_t neuLAND_paddle_dimz   = 2.4;    // half of the depth [cm]
  Double_t neuLAND_depth_dim     = 20.;   // half detector depth [cm]
  Double_t neuLAND_gap_dim       = 0.03;   // total detector depth [cm]
  Double_t neuLAND_wrapping1_dim = 0.02;   // thickness of wrapping material [cm]
  Double_t neuLAND_wrapping2_dim = 0.05;   // thickness of wrapping material [cm]
  

  // -------   Load media from media file   -----------------------------------
  FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
  TString medFile = geoPath + "/geometry/media_r3b.geo";
  geoFace->setMediaFile(medFile);
  geoFace->readMedia();
  gGeoMan = gGeoManager;
  // --------------------------------------------------------------------------



  // -------   Geometry file name (output)   ----------------------------------
  TString geoFileName = geoPath + "/geometry/neuland_";
  geoFileName = geoFileName + geoTag + ".geo.root";
  // --------------------------------------------------------------------------



  // -----------------   Get and create the required media    -----------------
  FairGeoMedia*   geoMedia = geoFace->getMedia();
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();

  FairGeoMedium* mBC408      = geoMedia->getMedium("BC408");
  if ( ! mBC408 ) Fatal("Main", "FairMedium BC408 not found");
  geoBuild->createMedium(mBC408);
  TGeoMedium* pMed37 = gGeoMan->GetMedium("BC408");
  if ( ! pMed37 ) Fatal("Main", "Medium BC408 not found");

  FairGeoMedium* mCH2      = geoMedia->getMedium("CH2");
  if ( ! mCH2 ) Fatal("Main", "FairMedium CH2 not found");
  geoBuild->createMedium(mCH2);
  TGeoMedium* pMed38 = gGeoMan->GetMedium("CH2");
  if ( ! pMed38 ) Fatal("Main", "Medium CH2 not found");

  FairGeoMedium* mAl      = geoMedia->getMedium("aluminium");
  if ( ! mAl ) Fatal("Main", "FairMedium aluminium not found");
  geoBuild->createMedium(mAl);
  TGeoMedium* pMedAl = gGeoMan->GetMedium("aluminium");
  if ( ! pMedAl ) Fatal("Main", "Medium aluminium not found");
  // --------------------------------------------------------------------------



  // --------------   Create geometry and top volume  -------------------------
  gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
  gGeoMan->SetName("NEULANDgeom");
  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
  gGeoMan->SetTopVolume(top);
  // --------------------------------------------------------------------------



  Double_t tx,ty,tz;
  //------------------ BC408 paddles -----------------------------------------
  TGeoVolume *padle_h_box5 = gGeoManager->MakeBox("padle_h_box5", pMed37,
						  neuLAND_paddle_dimx,
						  neuLAND_paddle_dimy,
						  neuLAND_paddle_dimz);

  //------------------ wrapping Alu------------------------------------------
  TGeoShape* padle_h_box1 = new TGeoBBox("padle_h_box1",
					 neuLAND_paddle_dimx, 
					 neuLAND_paddle_dimy + neuLAND_wrapping1_dim, 
					 neuLAND_paddle_dimz + neuLAND_wrapping1_dim);
  TGeoShape* padle_h_box2 = new TGeoBBox("padle_h_box2",
					 neuLAND_paddle_dimx, 
					 neuLAND_paddle_dimy, 
					 neuLAND_paddle_dimz);
  
  // Create a composite shape
  TGeoCompositeShape *wrapping1 = new TGeoCompositeShape("diffbox", "padle_h_box1 - padle_h_box2");
  TGeoVolume *bvol1 = new TGeoVolume("wrapping1", wrapping1, pMedAl);

  //------------------ wrapping Tape------------------------------------------
  TGeoShape* padle_h_box3 = new TGeoBBox("padle_h_box3",
					 neuLAND_paddle_dimx,
					 neuLAND_paddle_dimy + neuLAND_wrapping1_dim + neuLAND_wrapping2_dim, 
					 neuLAND_paddle_dimz + neuLAND_wrapping1_dim + neuLAND_wrapping2_dim);
  TGeoShape* padle_h_box4 = new TGeoBBox("padle_h_box4",
					 neuLAND_paddle_dimx, 
					 neuLAND_paddle_dimy + neuLAND_wrapping1_dim, 
					 neuLAND_paddle_dimz + neuLAND_wrapping1_dim);

  // Create a composite shape
  TGeoCompositeShape *wrapping2 = new TGeoCompositeShape("diffbox", "padle_h_box3 - padle_h_box4");
  TGeoVolume *bvol2 = new TGeoVolume("wrapping2", wrapping2, pMed38);



  // Make the elementary assembly of the whole structure
  TGeoVolume *aLand = new TGeoVolumeAssembly("ALAND");

  Double_t total_dimx = neuLAND_paddle_dimx;
  Double_t total_dimy = neuLAND_paddle_dimy +
    neuLAND_wrapping1_dim + 
    neuLAND_wrapping2_dim + 
    neuLAND_gap_dim;
  Double_t total_dimz = neuLAND_paddle_dimz +
    neuLAND_wrapping1_dim +
    neuLAND_wrapping2_dim +
    neuLAND_gap_dim;
  
  //paddles
  TGeoRotation *zeroRotation = new TGeoRotation();
  zeroRotation->RotateX(0.);
  zeroRotation->RotateY(0.);
  zeroRotation->RotateZ(0.);

  TGeoRotation *rot1 = new TGeoRotation();
  rot1->RotateX(0.);
  rot1->RotateY(0.);
  rot1->RotateZ(90.);

  Double_t xx = 0.;
  Double_t yy = 0.;
  Double_t zz = 0.;
  
  aLand->AddNode(padle_h_box5, 1, new TGeoCombiTrans(xx, yy, zz, zeroRotation));
  aLand->AddNode(bvol1, 1, new TGeoCombiTrans(xx, yy, zz, zeroRotation));
  aLand->AddNode(bvol2, 1, new TGeoCombiTrans(xx, yy, zz, zeroRotation));

  TGeoVolume *cell = new TGeoVolumeAssembly("CELL");

  Int_t nindex = 0, i = 0;
  tx = 0.;
  tz = -neuLAND_depth_dim + total_dimz;
  for(tz = -neuLAND_depth_dim + total_dimz; tz < neuLAND_depth_dim; tz += total_dimz*2) {
    i += 1;
    for (ty = -total_dimx + total_dimy; ty < total_dimx; ty += total_dimy*2) {
      nindex++;
      if (i % 2 == 1) {
        cell->AddNode(aLand, nindex, new TGeoCombiTrans(tx, ty, tz, zeroRotation));
      } else {
        cell->AddNode(aLand, nindex, new TGeoCombiTrans(ty, tx, tz, rot1));
      }
    }
  }

  tx = 0.0;
  ty = 0.0;
  tz = fZ;
  TGeoCombiTrans *t0 = new TGeoCombiTrans(tx, ty, tz, zeroRotation);

  top->AddNode(cell, 1, /*GetGlobalPosition(t0)*/t0);



  // ---------------   Finish   -----------------------------------------------
  gGeoMan->CloseGeometry();
  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();

  TFile* geoFile = new TFile(geoFileName, "RECREATE");
  top->Write();
  geoFile->Close();
  // --------------------------------------------------------------------------
}
void create_dch_geo(const char* geoTag)
{

  fGlobalTrans->SetTranslation(0.0,0.0,0.0);

  // -------   Load media from media file   -----------------------------------
  FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
  TString medFile = geoPath + "/geometry/media_r3b.geo";
  geoFace->setMediaFile(medFile);
  geoFace->readMedia();
  gGeoMan = gGeoManager;
  // --------------------------------------------------------------------------



  // -------   Geometry file name (output)   ----------------------------------
  TString geoFileName = geoPath + "/geometry/dch_";
  geoFileName = geoFileName + geoTag + ".geo.root";
  // --------------------------------------------------------------------------



  // -----------------   Get and create the required media    -----------------
  FairGeoMedia*   geoMedia = geoFace->getMedia();
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();

  FairGeoMedium* mAir      = geoMedia->getMedium("Air");
  if ( ! mAir ) Fatal("Main", "FairMedium Air not found");
  geoBuild->createMedium(mAir);
  TGeoMedium* pMed2 = gGeoMan->GetMedium("Air");
  if ( ! pMed2 ) Fatal("Main", "Medium Air not found");

  FairGeoMedium* mAl      = geoMedia->getMedium("aluminium");
  if ( ! mAl ) Fatal("Main", "FairMedium aluminium not found");
  geoBuild->createMedium(mAl);
  TGeoMedium* pMed21 = gGeoMan->GetMedium("aluminium");
  if ( ! pMed21 ) Fatal("Main", "Medium aluminium not found");

  FairGeoMedium* mMylar      = geoMedia->getMedium("mylar");
  if ( ! mMylar ) Fatal("Main", "FairMedium mylar not found");
  geoBuild->createMedium(mMylar);
  TGeoMedium* pMed15 = gGeoMan->GetMedium("mylar");
  if ( ! pMed15 ) Fatal("Main", "Medium mylar not found");

  FairGeoMedium* mHe      = geoMedia->getMedium("helium");
  if ( ! mHe ) Fatal("Main", "FairMedium helium not found");
  geoBuild->createMedium(mHe);
  TGeoMedium* pMed4 = gGeoMan->GetMedium("helium");
  if ( ! pMed4 ) Fatal("Main", "Medium helium not found");

  FairGeoMedium* mDCH      = geoMedia->getMedium("DCHgas");
  if ( ! mDCH ) Fatal("Main", "FairMedium DCHgas not found");
  geoBuild->createMedium(mDCH);
  TGeoMedium* pMed33 = gGeoMan->GetMedium("DCHgas");
  if ( ! pMed33 ) Fatal("Main", "Medium DCHgas not found");
  // --------------------------------------------------------------------------



  // --------------   Create geometry and top volume  -------------------------
  gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
  gGeoMan->SetName("DCHgeom");
  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
  gGeoMan->SetTopVolume(top);
  // --------------------------------------------------------------------------



  Double_t dx,dy,dz;
  Double_t theta, phi;
  Double_t thx, phx, thy, phy, thz, phz;
  Double_t alpha;



  // Define DCH Geometry
  TGeoVolume* topDCH = new TGeoVolumeAssembly("DCH");


  //Active volume	(envelope box enclosing the sense wires)	
  Double_t actGasDx = 99.07/2.; // [cm]	//99.07326
  Double_t actGasDy = 77.60/2.;  // [cm]	//77.59584
  Double_t actGasDz = 5.20/2.;     // [cm]
  //distance of x and y planes centres is 4 cm. Distance between the first x halfplane and the second y halfplane is 4cm + 2*0.69*cos30 cm.

  TGeoShape* pActGasBox = new TGeoBBox("ActGasBox",
				       actGasDx,
				       actGasDy,
				       actGasDz);
  TGeoVolume*
    pActGasDchLog = new TGeoVolume("ActGASBoxLog",pActGasBox, pMed33);
  pActGasDchLog->SetVisLeaves(kTRUE);
  pActGasDchLog->SetVisContainers(kTRUE);


  // Gas box
  Double_t gasDx = 106.4/2.; // [cm]
  Double_t gasDy = 83.4/2.;  // [cm]
  Double_t gasDz = 7.50;     // [cm]	

  TGeoShape* pGasBox = new TGeoBBox("GasBox",
				    gasDx,
				    gasDy,
				    gasDz);
  TGeoVolume*
    pGasDchLog = new TGeoVolume("GASBoxLog",pGasBox, pMed33);
  pGasDchLog->SetVisLeaves(kTRUE);
  pGasDchLog->SetVisContainers(kTRUE);


  // Al Frame
  Double_t alDx = 125.8/2.; // [cm]
  Double_t alDy = 103.4/2.; // [cm]
  //Double_t alDz = 4.06;     // [cm]
  Double_t alDz = 7.50;     // [cm]	//modified

  TGeoShape* pAlBox = new TGeoBBox("AlBox",
				   alDx,
				   alDy,
				   alDz);

  TGeoVolume*
    pAlDchLog = new TGeoVolume("ALBoxLog",pAlBox, pMed21);
  pAlDchLog->SetVisLeaves(kTRUE);



  // Mylar Entrance exit windows
  Double_t mylDx= gasDx; //[cm]
  Double_t mylDy= gasDy; //[cm]
  Double_t mylDz= 0.0006; //[cm]
  TGeoShape* pMylarBox = new TGeoBBox("MylarBox",
				      mylDx,
				      mylDy,
				      mylDz);

  TGeoVolume*
    pMylDchLog = new TGeoVolume("MYLBoxLog",pMylarBox, pMed15);
  pMylDchLog->SetVisLeaves(kTRUE);



  // First assembly
  TGeoVolume *dch1 = new TGeoVolumeAssembly("DCH1");

  TGeoRotation *rot = new TGeoRotation();
  rot->RotateX(0.);
  rot->RotateY(0.);
  rot->RotateZ(0.);
  //Double_t tx = -3.5;	//correct values? active-area vs Al frame offsets?
  //Double_t ty = -5.;
  Double_t tx = +3.5;	//corrected values, active-area vs Al frame offsets. F.Wamers.
  Double_t ty = -3.5;
  Double_t tz = 0.;

  TGeoCombiTrans*
    pTransfo1 = new TGeoCombiTrans("", 0.,0.,0.,rot);
  TGeoCombiTrans*
    pTransfo2 = new TGeoCombiTrans("", tx,ty,tz,rot);
  TGeoCombiTrans*
    pTransfo3 = new TGeoCombiTrans("", -tx,-ty,-tz,rot); //new, in order to compensate Al vs Gas

  dch1->AddNode(pAlDchLog,0,pTransfo3);	//1->3
  pAlDchLog->AddNode(pGasDchLog,0,pTransfo2);	//place gas in aluminum, shifted
  pGasDchLog->AddNode(pActGasDchLog, 0,pTransfo1);	//place active in gas, centrally
  // Mylar Windows front+back
  //dch1->AddNode(pMylDchLog,0,new TGeoCombiTrans("", tx,ty,-alDz-mylDz,rot));
  //dch1->AddNode(pMylDchLog,1,new TGeoCombiTrans("", tx,ty, alDz+mylDz,rot));
  dch1->AddNode(pMylDchLog,0,new TGeoCombiTrans("", 0.,0.,-alDz-mylDz,rot));
  dch1->AddNode(pMylDchLog,1,new TGeoCombiTrans("", 0.,0., alDz+mylDz,rot));



  // Global Positioning
  //in agreement with the s318 tracker, those are supposed to be the centres of the active volumes!!!
  //Double_t pDch1x = -123.22 ; //Justyna 
  //Double_t pDch1y = 3.6 ;     //Justyna
  //Double_t pDch1z = 444.13 ;  //Justyna

  //Double_t pDch2x = -167.0 ;  //Justyna
  //Double_t pDch2y = 1.02 ;    //Justyna
  //Double_t pDch2z = 535.1 ;   //Justyna

  //use identical values as for the tracker config and the digitizer. F. Wamers. 
  Double_t pDch1x = -123.219446 ; //Felix 
  Double_t pDch1y = 3.597104 ;     //Felix
  Double_t pDch1z = 444.126271 ;  //Felix

  Double_t pDch2x = -167.015888 ;  //Felix
  Double_t pDch2y = 1.016917 ;    //Felix
  Double_t pDch2z = 535.093884 ;   //Felix
   
  //   Double_t pDch1x = -132.233355 ; //Christoph  
  //   Double_t pDch1y = 1.037475 ;     //Christoph 
  //   Double_t pDch1z = 438.710168 ;  //Christoph

  //   Double_t pDch2x = -170.8653 ;  //Christoph
  //   Double_t pDch2y = 2.075139 ;    //Christoph
  //   Double_t pDch2z = 538.614091 ;   //Christoph
   

  //The order of rotation matters!!! Rotate first z, and then y! Felix

  Double_t aDch1 = -31.0 ; 
  Double_t aDch2 = -31.0 ; 

  TGeoRotation *gRot1 = new TGeoRotation();
  gRot1->RotateX(0.);
  gRot1->RotateZ(-8.880000); //Justyna
  //gRot1->RotateZ(+8.880000); //Felix
  //   gRot1->RotateZ(-2.5); //Christoph
  gRot1->RotateY(aDch1);
   
  TGeoRotation *gRot2 = new TGeoRotation();
  gRot2->RotateX(0.);
  gRot2->RotateZ(9.350000); //Justyna
  //gRot2->RotateZ(-9.350000); //Felix
  //   gRot2->RotateZ(8.4); //Christoph
  gRot2->RotateY(aDch2);


  // Helium Bag definition
  Double_t heDx= alDx ; //[cm]
  Double_t heDy= alDy ; //[cm]
  Double_t heDz=(pDch2z-pDch1z)*0.953874/2.; //[cm]
  alpha=0.;     //[degre]
  Double_t beta =0.;     //[degre]
  phi  =15.20; //[degre]

  TGeoShape* pHePara = new TGeoPara("HePara", heDx, heDy, heDz,
				    alpha,beta,phi);

  TGeoVolume*
    pHeDchLog = new TGeoVolume("HeParaLog",pHePara, pMed4);
  pHeDchLog->SetVisLeaves(kTRUE);




  topDCH->AddNode(dch1,0,new TGeoCombiTrans("",pDch1x,pDch1y,pDch1z,gRot1) );
  topDCH->AddNode(dch1,1,new TGeoCombiTrans("",pDch2x,pDch2y,pDch2z,gRot2) );
  topDCH->AddNode(pHeDchLog,0,new TGeoCombiTrans("",(pDch1x+pDch2x)/2.,
						 pDch2y,
						 (pDch1z+pDch2z)/2.,
						 gRot1) );


  TGeoCombiTrans *temp1 = new TGeoCombiTrans();
  top->AddNode(topDCH, 0, GetGlobalPosition(temp1));
  
   
   
  // ---------------   Finish   -----------------------------------------------
  gGeoMan->CloseGeometry();
  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();

  TFile* geoFile = new TFile(geoFileName, "RECREATE");
  top->Write();
  geoFile->Close();
  // --------------------------------------------------------------------------
}
Beispiel #27
0
/*
 * CreateLambdaGeometry.C
 *
 *  Created on: Mar 21, 2013
 *      Author: stockman
 */
startdetector1()
{
	  //-----------------------------
	Double_t positionOfDisk1inZ = 40.0;		//in cm
	//Double_t positionOfDisk2inZ = 53.0;		//in cm

	  //--------------------------------------------------------------------
	  gROOT->Macro("$VMCWORKDIR/gconfig/rootlogon.C");
	  
	  // Load this libraries
	  gSystem->Load("libGeoBase");
	  gSystem->Load("libParBase");
	  gSystem->Load("libBase");
	  gSystem->Load("libPndData");
	  gSystem->Load("libPassive");
	  
	  TString outfile= "../../geometry/startdetector.root";
	  TFile* fi = new TFile(outfile,"RECREATE");  
	  
	  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
	  FairGeoInterface *geoFace = geoLoad->getGeoInterface();
	  geoFace->setMediaFile("../../geometry/media_pnd.geo");	
	  geoFace->readMedia();
	  geoFace->print();

	  FairGeoMedia *Media =  geoFace->getMedia();
	  FairGeoBuilder *geobuild=geoLoad->getGeoBuilder();

	  FairGeoMedium *CbmMediumHYPdiamond  = Media->getMedium("HYPdiamond");
	  FairGeoMedium *CbmMediumCarbon  = Media->getMedium("carbon");
	  FairGeoMedium *CbmMediumCarbonFoam  = Media->getMedium("carbonfoam");
	  FairGeoMedium *CbmMediumAluminium = Media->getMedium("aluminium");
	  
	  Int_t nmed=geobuild->createMedium(CbmMediumHYPdiamond);
	  nmed=geobuild->createMedium(CbmMediumCarbon);
	  nmed=geobuild->createMedium(CbmMediumCarbonFoam);
	  nmed=geobuild->createMedium(CbmMediumAluminium);

	  TGeoManager* gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");

	  TGeoVolume *top = new TGeoVolumeAssembly("top");
	                    
	  gGeoMan->SetTopVolume(top);
	  
	TGeoVolume *combinedLambdaDisks = new TGeoVolumeAssembly("CombinedLambdaDisks");
	TGeoVolumeAssembly* lambdaDisk = new TGeoVolumeAssembly("LambdaDisk");
	TGeoVolumeAssembly* largeRing = new TGeoVolumeAssembly("LargeRing");
	TGeoVolumeAssembly* smallRing = new TGeoVolumeAssembly("SmallRing");

//	lambdaDisk->AddNode(largeSensorVolume,0,trc1);
//	TGeoShape* largeSensorShape  = new TGeoTrd1("StripSensorActiveLargeShape", 3.4593/2, 1.9936/2,0.03/2, 5.5665/2);
	Double_t points [16];
	points[0] = -1.7297;		points[1] = 2.7833;
	points[2] = 1.7297; 		points[3] = 2.7833;
	points[4] = 0.9968; 		points[5] = -2.7833;
	points[6] = -0.9968; 		points[7] = -2.7833;

	points[8] = -1.7297; 		points[9] = 2.7833;
	points[10] = 1.7297; 		points[11] = 2.7833;
	points[12] = 0.9968; 		points[13] = -2.7833;
	points[14] = -0.9968; 		points[15] = -2.7833;

	TGeoShape* largeSensorShape  = new TGeoArb8("StripSensorActiveLargeShape", 0.03/2, points);
	TGeoVolume* largeSensorVolume = new TGeoVolume("StripSensorActiveLargeTrap",largeSensorShape,gGeoMan->GetMedium("HYPdiamond"));

//	TGeoRotation rotSensor("rotSensor",0,90,0);
	TGeoRotation rotSensor("rotSensor",0,0,0);
	TGeoTranslation transLargeSensor(0,(14.8669 + 5.5665)/2,0);
	TGeoCombiTrans combined1(transLargeSensor, rotSensor);

	for (int i = 0; i < 12; i++){
		TString rotName("rotLargeSens");
		rotName.Append(i+1);
		TGeoRotation rotSens(rotName.Data(), 0,0, i*2 * 360/24);
		TGeoHMatrix sens = rotSens * combined1;
		largeRing->AddNode(largeSensorVolume, i, new TGeoHMatrix(sens));
	}

	Double_t pointsSmall [16];
	pointsSmall[0] = -1.9579/2;		pointsSmall[1] = 5.3358/2;
	pointsSmall[2] = 1.9579/2; 		pointsSmall[3] = 5.3358/2;
	pointsSmall[4] = 0.5529/2; 		pointsSmall[5] = -5.3358/2;
	pointsSmall[6] = -0.5529/2; 		pointsSmall[7] = -5.3358/2;

	pointsSmall[8] = -1.9579/2;		pointsSmall[9] = 5.3358/2;
	pointsSmall[10] = 1.9579/2; 	pointsSmall[11] = 5.3358/2;
	pointsSmall[12] = 0.5529/2; 	pointsSmall[13] = -5.3358/2;
	pointsSmall[14] = -0.5529/2; 	pointsSmall[15] = -5.3358/2;

//	TGeoShape* smallSensorShape = new TGeoTrd1("StripSensorActiveSmallShape", 1.9579/2, 0.5529/2, 0.03/2, 5.3358/2);
	TGeoShape* smallSensorShape = new TGeoArb8("StripSensorActiveSmallShape", 0.03/2, pointsSmall);
	TGeoVolume* smallSensorVolume = new TGeoVolume("StripSensorActiveSmallTrap", smallSensorShape, gGeoMan->GetMedium("HYPdiamond"));

	TGeoTranslation transSmallSensor(0,5.3358/2+2.1,0);
	TGeoCombiTrans combined2(transSmallSensor, rotSensor);

	for (int i = 0; i < 12; i++){
		TString rotName("rotSmallSens");
		rotName.Append(i+1);
		TGeoRotation rotSens(rotName.Data(), 0,0, i*2 * 360/24);
		TGeoHMatrix sens = rotSens * combined2;
		smallRing->AddNode(smallSensorVolume, i+12, new TGeoHMatrix(sens));
	}

	lambdaDisk->AddNode(largeRing, 0, new TGeoTranslation(0,0,-0.5));
	lambdaDisk->AddNode(largeRing, 1, new TGeoRotation("largeRingRot",0,0,360/24));

	TGeoCombiTrans combiSmallRing2(TGeoTranslation(0,0,-1.5), TGeoRotation("smallRingRot",0,0,360/24));
	lambdaDisk->AddNode(smallRing, 0, new TGeoTranslation(0,0,-1.0));
	lambdaDisk->AddNode(smallRing, 1, new TGeoHMatrix(combiSmallRing2));

	TGeoVolumeAssembly* supportDisk = new TGeoVolumeAssembly("SupportDisk");

	TGeoVolumeAssembly* supportLarge = new TGeoVolumeAssembly("SupportLarge");
		TGeoShape* carbonFoamShape = new TGeoBBox(3.4/2, 0.2/2, 3.5/2);
		TGeoVolume* carbonFoam = new TGeoVolume("CarbonFoam", carbonFoamShape, gGeoMan->GetMedium("carbonfoam"));
		TGeoShape* carbonFiberShape = new TGeoBBox(3.4/2, 0.02/2, 3.5/2);
		TGeoVolume* carbonFiber = new TGeoVolume("CarbonFiber", carbonFiberShape, gGeoMan->GetMedium("carbon"));
		TGeoShape* HYPdiamondReadoutShape = new TGeoBBox(3.4/2, 0.02/2, 3.5/2);
		TGeoVolume* HYPdiamondReadout = new TGeoVolume("HYPdiamondReadout", HYPdiamondReadoutShape, gGeoMan->GetMedium("HYPdiamond"));
		TGeoShape* aluCablesShape = new TGeoBBox(3.4/2, 0.4/2, 3.5/2);
		TGeoVolume* aluCables = new TGeoVolume("AluCables", aluCablesShape, gGeoMan->GetMedium("aluminium"));

		supportLarge->AddNode(carbonFoam, 1);
		supportLarge->AddNode(carbonFiber, 1, new TGeoTranslation(0,(0.2 + 0.02)/2, 0));
		supportLarge->AddNode(carbonFiber, 2, new TGeoTranslation(0,-(0.2 + 0.02)/2, 0));
		supportLarge->AddNode(HYPdiamondReadout, 1, new TGeoTranslation(0,(0.2 + 0.02 + 0.02)/2, 0));
		supportLarge->AddNode(HYPdiamondReadout, 2, new TGeoTranslation(0,-(0.2 + 0.02 + 0.02)/2, 0));
		supportLarge->AddNode(aluCables, 1, new TGeoTranslation(0,(0.2 + 0.02 + 0.02 + 0.4)/2, 0));
		supportLarge->AddNode(aluCables, 2, new TGeoTranslation(0,-(0.2 + 0.02 + 0.02 + 0.4)/2, 0));

		TGeoTranslation transSupportLarge(0,(14.8669)/2 + 5.5665 + 1,0);

		for (int i = 0; i < 24; i++){
			TString rotName("rotSupportLarge");
			rotName.Append(i+1);
			TGeoRotation rotSens(rotName.Data(), 0,0, i * 360/24);
			TGeoHMatrix sens = rotSens * transSupportLarge;
			supportDisk->AddNode(supportLarge, i+1, new TGeoHMatrix(sens));
		}

		TGeoVolumeAssembly* supportSmall = new TGeoVolumeAssembly("SupportSmall");
		TGeoShape* carbonFoamShapeSmall = new TGeoBBox(1.8/2, 0.2/2, 3.5/2);
		TGeoVolume* carbonFoamSmall = new TGeoVolume("CarbonFoamSmall", carbonFoamShapeSmall, gGeoMan->GetMedium("carbonfoam"));
		TGeoShape* carbonFiberShapeSmall = new TGeoBBox(1.8/2, 0.02/2, 3.5/2);
		TGeoVolume* carbonFiberSmall = new TGeoVolume("CarbonFiberSmall", carbonFiberShapeSmall, gGeoMan->GetMedium("carbon"));
		TGeoShape* HYPdiamondReadoutShapeSmall = new TGeoBBox(1.8/2, 0.02/2, 3.5/2);
		TGeoVolume* HYPdiamondReadoutSmall = new TGeoVolume("HYPdiamondReadoutSmall", HYPdiamondReadoutShapeSmall, gGeoMan->GetMedium("HYPdiamond"));
		TGeoShape* aluCablesShapeSmall = new TGeoBBox(1.8/2, 0.4/2, 3.5/2);
		TGeoVolume* aluCablesSmall = new TGeoVolume("AluCablesSmall", aluCablesShapeSmall, gGeoMan->GetMedium("aluminium"));

		supportSmall->AddNode(carbonFoamSmall, 1);
		supportSmall->AddNode(carbonFiberSmall, 1, new TGeoTranslation(0,(0.2 + 0.02)/2, 0));
		supportSmall->AddNode(carbonFiberSmall, 2, new TGeoTranslation(0,-(0.2 + 0.02)/2, 0));
		supportSmall->AddNode(HYPdiamondReadoutSmall, 1, new TGeoTranslation(0,(0.2 + 0.02 + 0.02)/2, 0));
		supportSmall->AddNode(HYPdiamondReadoutSmall, 2, new TGeoTranslation(0,-(0.2 + 0.02 + 0.02)/2, 0));
		supportSmall->AddNode(aluCablesSmall, 1, new TGeoTranslation(0,(0.2 + 0.02 + 0.02 + 0.4)/2, 0));
		supportSmall->AddNode(aluCablesSmall, 2, new TGeoTranslation(0,-(0.2 + 0.02 + 0.02 + 0.4)/2, 0));

		TGeoTranslation transSupportSmall(0,2.1 + 5.3358 + 0.5,0);

		for (int i = 0; i < 24; i++){
			TString rotName("rotSupportSmall");
			rotName.Append(i+1);
			TGeoRotation rotSens(rotName.Data(), 0,0, i * 360/24);
			TGeoHMatrix sens = rotSens * transSupportSmall;
			supportDisk->AddNode(supportSmall, i+1, new TGeoHMatrix(sens));
		}

	combinedLambdaDisks->AddNode(lambdaDisk,1,new TGeoTranslation(0,0,positionOfDisk1inZ));
	//combinedLambdaDisks->AddNode(lambdaDisk,2,new TGeoTranslation(0,0,positionOfDisk2inZ));
	//combinedLambdaDisks->AddNode(supportDisk,1, new TGeoTranslation(0,0,(positionOfDisk1inZ + positionOfDisk2inZ)/2));

	top->AddNode(combinedLambdaDisks,0);

	  gGeoMan->CloseGeometry();
	  top->Write();
	  fi->Close();
	//   gGeoManager->Export(outfile);
	  gGeoManager->SetVisLevel(30);
	  top->Draw("ogl"); 
}
Beispiel #28
0
void rootgeom()
{
//Definition of a simple geometry (the 4 ROOT characters)
//Author: Andrei Gheata
   
   // gStyle->SetCanvasPreferGL(true);
   gSystem->Load("libGeom");
   TGeoManager *geom = new TGeoManager("simple1", "Simple geometry");
   
   //--- define some materials
   TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
   TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
//   //--- define some media
   TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
   TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl);

   //--- define the transformations
   TGeoTranslation *tr1 = new TGeoTranslation(20., 0, 0.);
   TGeoTranslation *tr2 = new TGeoTranslation(10., 0., 0.);
   TGeoTranslation *tr3 = new TGeoTranslation(10., 20., 0.);
   TGeoTranslation *tr4 = new TGeoTranslation(5., 10., 0.);
   TGeoTranslation *tr5 = new TGeoTranslation(20., 0., 0.);
   TGeoTranslation *tr6 = new TGeoTranslation(-5., 0., 0.);
   TGeoTranslation *tr7 = new TGeoTranslation(7.5, 7.5, 0.);
   TGeoRotation   *rot1 = new TGeoRotation("rot1", 90., 0., 90., 270., 0., 0.);
   TGeoCombiTrans *combi1 = new TGeoCombiTrans(7.5, -7.5, 0., rot1);
   TGeoTranslation *tr8 = new TGeoTranslation(7.5, -5., 0.);
   TGeoTranslation *tr9 = new TGeoTranslation(7.5, 20., 0.);
   TGeoTranslation *tr10 = new TGeoTranslation(85., 0., 0.);
   TGeoTranslation *tr11 = new TGeoTranslation(35., 0., 0.);
   TGeoTranslation *tr12 = new TGeoTranslation(-15., 0., 0.);
   TGeoTranslation *tr13 = new TGeoTranslation(-65., 0., 0.);
   
   TGeoTranslation  *tr14 = new TGeoTranslation(0,0,-100);
   TGeoCombiTrans *combi2 = new TGeoCombiTrans(0,0,100, 
                                   new TGeoRotation("rot2",90,180,90,90,180,0));
   TGeoCombiTrans *combi3 = new TGeoCombiTrans(100,0,0, 
                                   new TGeoRotation("rot3",90,270,0,0,90,180));
   TGeoCombiTrans *combi4 = new TGeoCombiTrans(-100,0,0, 
                                   new TGeoRotation("rot4",90,90,0,0,90,0));
   TGeoCombiTrans *combi5 = new TGeoCombiTrans(0,100,0, 
                                   new TGeoRotation("rot5",0,0,90,180,90,270));
   TGeoCombiTrans *combi6 = new TGeoCombiTrans(0,-100,0, 
                                   new TGeoRotation("rot6",180,0,90,180,90,90));
   
   //--- make the top container volume
   Double_t worldx = 110.;
   Double_t worldy = 50.;
   Double_t worldz = 5.;
   TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 270., 270., 120.);
   geom->SetTopVolume(top);
   TGeoVolume *replica = geom->MakeBox("REPLICA", Vacuum,120,120,120);
   replica->SetVisibility(kFALSE);
   TGeoVolume *rootbox = geom->MakeBox("ROOT", Vacuum, 110., 50., 5.);
   rootbox->SetVisibility(kFALSE);
   
   //--- make letter 'R'
   TGeoVolume *R = geom->MakeBox("R", Vacuum, 25., 25., 5.);
   R->SetVisibility(kFALSE);
   TGeoVolume *bar1 = geom->MakeBox("bar1", Al, 5., 25, 5.);
   bar1->SetLineColor(kRed);
   R->AddNode(bar1, 1, tr1);
   TGeoVolume *bar2 = geom->MakeBox("bar2", Al, 5., 5., 5.);
   bar2->SetLineColor(kRed);
   R->AddNode(bar2, 1, tr2);
   R->AddNode(bar2, 2, tr3);
   TGeoVolume *tub1 = geom->MakeTubs("tub1", Al, 5., 15., 5., 90., 270.);
   tub1->SetLineColor(kRed);
   R->AddNode(tub1, 1, tr4);
   TGeoVolume *bar3 = geom->MakeArb8("bar3", Al, 5.);
   bar3->SetLineColor(kRed);
   TGeoArb8 *arb = (TGeoArb8*)bar3->GetShape();
   arb->SetVertex(0, 15., -5.);
   arb->SetVertex(1, 0., -25.);
   arb->SetVertex(2, -10., -25.);
   arb->SetVertex(3, 5., -5.);
   arb->SetVertex(4, 15., -5.);
   arb->SetVertex(5, 0., -25.);
   arb->SetVertex(6, -10., -25.);
   arb->SetVertex(7, 5., -5.);
   R->AddNode(bar3, 1, gGeoIdentity);
   
   //--- make letter 'O'
   TGeoVolume *O = geom->MakeBox("O", Vacuum, 25., 25., 5.);
   O->SetVisibility(kFALSE);
   TGeoVolume *bar4 = geom->MakeBox("bar4", Al, 5., 7.5, 5.);
   bar4->SetLineColor(kYellow);
   O->AddNode(bar4, 1, tr5);
   O->AddNode(bar4, 2, tr6);
   TGeoVolume *tub2 = geom->MakeTubs("tub1", Al, 7.5, 17.5, 5., 0., 180.);
   tub2->SetLineColor(kYellow);
   O->AddNode(tub2, 1, tr7);
   O->AddNode(tub2, 2, combi1);
   
   //--- make letter 'T'
   TGeoVolume *T = geom->MakeBox("T", Vacuum, 25., 25., 5.);
   T->SetVisibility(kFALSE);
   TGeoVolume *bar5 = geom->MakeBox("bar5", Al, 5., 20., 5.);
   bar5->SetLineColor(kBlue);
   T->AddNode(bar5, 1, tr8);
   TGeoVolume *bar6 = geom->MakeBox("bar6", Al, 17.5, 5., 5.);
   bar6->SetLineColor(kBlue);
   T->AddNode(bar6, 1, tr9);
      
   

   rootbox->AddNode(R, 1, tr10);
   rootbox->AddNode(O, 1, tr11);
   rootbox->AddNode(O, 2, tr12);
   rootbox->AddNode(T, 1, tr13);
   
   replica->AddNode(rootbox, 1, tr14);
   replica->AddNode(rootbox, 2, combi2);
   replica->AddNode(rootbox, 3, combi3);
   replica->AddNode(rootbox, 4, combi4);
   replica->AddNode(rootbox, 5, combi5);
   replica->AddNode(rootbox, 6, combi6);
   
   top->AddNode(replica, 1, new TGeoTranslation(-150, -150, 0));
   top->AddNode(replica, 2, new TGeoTranslation(150, -150, 0));
   top->AddNode(replica, 3, new TGeoTranslation(150, 150, 0));
   top->AddNode(replica, 4, new TGeoTranslation(-150, 150, 0));

   //--- close the geometry
   geom->CloseGeometry();
   
   //--- draw the ROOT box.
   // by default the picture will appear in the standard ROOT TPad.
   //if you have activated the following line in system.rootrc, 
   //it will appear in the GL viewer
   //#Viewer3D.DefaultDrawOption:   ogl
   
   geom->SetVisLevel(4);
   top->Draw("ogle");
}   
void create_actar_geo(const char* geoTag)
{

  fGlobalTrans->SetTranslation(0.0,0.0,0.0);

  //Design values for the R3B ACTAR detector (from E. Maev info, [email protected])
  Double_t worldLength = 60.;  //60cm^3 world box side
  Double_t chamberInnerRadius = 20.0; //cylindrical inner radius (cm)
  Double_t chamberThickness = 0.6;  //chamber aluminum thickness (cm)
  Double_t chamberPlateRadius = 23.5; //back stainless steel part (cm)
  Double_t chamberPlateThickness = 2.0;  //back part thickness (cm)
  Double_t chamberHalfLength = 23.5; //half-length APPROX. (cm)
  Double_t backwardsBeamWindowRadius = 2.5; // inlet radius(cm)
  Double_t forwardsBeamWindowRadius = 3.5; //outlet radius (cm)
  Double_t inletWindowRadius = 2.45; // inlet berylium window radius (cm)
  Double_t inletWindowThickness = 0.05; //inlet berylium window thickness (cm)
  Double_t inletWindowCenter = -chamberHalfLength-chamberPlateThickness-1.0-inletWindowRadius-inletWindowThickness; // Z coordinate of inlet window center (cm)
  Double_t outletWindowRadius = 3.45; // inlet berylium window radius (cm)
  Double_t outletWindowThickness = 0.05; //inlet berylium window thickness (cm)
  Double_t outletWindowCenter = chamberHalfLength+outletWindowRadius+outletWindowThickness; // Z coordinate of inlet window center (cm)

  Double_t anodeThickness = 0.10;  //(cm)
  Double_t cathodeThickness = 0.10;  //(cm)
  Double_t anodeRadius = 32.4/2; //back stainless steel part (cm)
  Double_t positionAnode = -10.0; //anode center Z position (cm)
  Double_t positionCathode = positionAnode + 21.6; //anode center Z position (cm)
  Double_t positionGrid = positionAnode + 0.3; //grid center Z position (cm)
  Double_t gridThickness = 0.001; //55 microm, 1mm step, RECALCULATE!!! (cm)
  Double_t ringRadius = 34.0/2; //field mapping rings radius (cm)
  Double_t ringGauge = 0.1; //field mapping rings gauge (diameter) (cm)
  Double_t ringDistance = 1.8; //distance between rings (cm)


  // -------   Load media from media file   -----------------------------------
  FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
  TString medFile = geoPath + "/geometry/media_r3b.geo";
  geoFace->setMediaFile(medFile);
  geoFace->readMedia();
  gGeoMan = gGeoManager;
  // --------------------------------------------------------------------------


  // -------   Geometry file name (output)   ----------------------------------
  TString geoFileName = geoPath + "/geometry/actar_";
  geoFileName = geoFileName + geoTag + ".geo.root";
  // --------------------------------------------------------------------------



  // -----------------   Get and create the required media    -----------------
  FairGeoMedia*   geoMedia = geoFace->getMedia();
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();

  FairGeoMedium* mAir      = geoMedia->getMedium("Air");
  if ( ! mAir ) Fatal("Main", "FairMedium Air not found");
  geoBuild->createMedium(mAir);
  TGeoMedium* pAirMedium = gGeoMan->GetMedium("Air");
  if ( ! pAirMedium ) Fatal("Main", "Medium Air not found");

  FairGeoMedium* mCar      = geoMedia->getMedium("CarbonFibre");
  if ( ! mCar ) Fatal("Main", "FairMedium CarbonFibre not found");
  geoBuild->createMedium(mCar);
  TGeoMedium* pCarbonFibreMedium = gGeoMan->GetMedium("CarbonFibre");
  if ( ! pCarbonFibreMedium ) Fatal("Main", "Medium CarbonFibre not found");

  FairGeoMedium* mTfl      = geoMedia->getMedium("Tefflon");
  if ( ! mTfl ) Fatal("Main", "FairMedium Tefflon not found");
  geoBuild->createMedium(mTfl);
  TGeoMedium* pWrappingMedium = gGeoMan->GetMedium("Tefflon");
  if ( ! pWrappingMedium ) Fatal("Main", "Medium Tefflon not found");

  FairGeoMedium* mAl      = geoMedia->getMedium("aluminium");
  if ( ! mAl ) Fatal("Main", "FairMedium aluminium not found");
  geoBuild->createMedium(mAl);
  TGeoMedium* pAlHousing = gGeoMan->GetMedium("aluminium");
  if ( ! pAlHousing ) Fatal("Main", "Medium aluminium not found");

  FairGeoMedium* mSteel      = geoMedia->getMedium("Steel");
  if ( ! mSteel ) Fatal("Main", "FairMedium Steel not found");
  geoBuild->createMedium(mSteel);
  TGeoMedium* pMedSteel = gGeoMan->GetMedium("Steel");
  if ( ! pMedSteel ) Fatal("Main", "Medium Steel not found");

  FairGeoMedium* mHe      = geoMedia->getMedium("ArCO2");
  if ( ! mHe ) Fatal("Main", "FairMedium ArCO2 not found");
  geoBuild->createMedium(mHe);
  TGeoMedium* pMed4 = gGeoMan->GetMedium("ArCO2");
  if ( ! pMed4 ) Fatal("Main", "Medium ArCO2 not found");

  FairGeoMedium* mBeryllium = geoMedia->getMedium("beryllium");
  if ( ! mBeryllium ) Fatal("Main", "FairMedium beryllium not found");
  geoBuild->createMedium(mBeryllium);
  TGeoMedium* pMedBe = gGeoMan->GetMedium("beryllium");
  if ( ! pMedBe ) Fatal("Main", "Medium beryllium not found");

  FairGeoMedium* mCopper = geoMedia->getMedium("copper");
  if ( ! mCopper ) Fatal("Main", "FairMedium copper not found");
  geoBuild->createMedium(mCopper);
  TGeoMedium* pMedCu = gGeoMan->GetMedium("copper");
  if ( ! pMedCu ) Fatal("Main", "Medium copper not found");
  // --------------------------------------------------------------------------



  // --------------   Create geometry and top volume  -------------------------
  gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
  gGeoMan->SetName("ACTARgeom");
  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
  gGeoMan->SetTopVolume(top);
  // --------------------------------------------------------------------------


  // Defintion of the Mother Volume Actar
  TGeoShape *pActarWorldOut = new TGeoBBox("Actar_boxOut",
					worldLength/2.0,
					worldLength/2.0,
					worldLength/2.0);

  TGeoVolume* pWorld = new TGeoVolume("ActarWorld", pActarWorldOut, pAirMedium);

  TGeoCombiTrans *t0 = new TGeoCombiTrans();
  TGeoCombiTrans *pGlobalc = GetGlobalPosition(t0);
  t0->RegisterYourself();

  //defining top volume
  top->AddNode(pWorld, 0, pGlobalc);

  //Colors in visualization
  Color_t col_chamber = kBlue-6;
  Color_t col_anode = kGray+3;
  Color_t col_cathode = kGray+5;
  Color_t col_grid = kGray;
  Color_t col_rings = kOrange;
  Color_t col_windows = kGray-1;

  /*** Some definitions ***/
  TGeoRotation *rotUni = new TGeoRotation();          //unitary rotation

  //CHAMBER, BACKWARD FLANGE
  TGeoVolume *Actar_chamber_1 = gGeoManager->MakeTube("Actar_chamber_1",pAlHousing,chamberInnerRadius, chamberInnerRadius+chamberThickness, chamberHalfLength);
  Actar_chamber_1->SetLineColor(col_chamber);

  TGeoVolume *Actar_chamber_2 = gGeoManager->MakeTube("Actar_chamber_2",pMedSteel,backwardsBeamWindowRadius, chamberPlateRadius, chamberPlateThickness/2);
  Actar_chamber_2->SetLineColor(col_chamber);
  TGeoCombiTrans *t_chamber_2 = new TGeoCombiTrans("t_chamber_2",0.,0.,-chamberHalfLength-chamberPlateThickness/2,rotUni);
  t_chamber_2->RegisterYourself();

  TGeoVolume *Actar_chamber_3 = gGeoManager->MakeTube("Actar_chamber_3",pAlHousing,forwardsBeamWindowRadius, chamberInnerRadius+chamberThickness, chamberThickness/2);
  Actar_chamber_3->SetLineColor(col_chamber);
  TGeoCombiTrans *t_chamber_3 = new TGeoCombiTrans("t_chamber_3",0.,0.,chamberHalfLength+chamberThickness/2,rotUni);
  t_chamber_3->RegisterYourself();

  TGeoVolume *Actar_chamber_4 = gGeoManager->MakeTube("Actar_chamber_4",pMedSteel,backwardsBeamWindowRadius, 5.0,3.5/2);
  Actar_chamber_3->SetLineColor(col_chamber);
  TGeoCombiTrans *t_chamber_4 = new TGeoCombiTrans("t_chamber_4",0.,0.,inletWindowCenter+3.5/2,rotUni);
  t_chamber_4->RegisterYourself();

  TGeoVolume *Actar_chamber_5 = gGeoManager->MakeTube("Actar_chamber_5",pMedSteel,forwardsBeamWindowRadius, 6.0,3.5/2);
  Actar_chamber_3->SetLineColor(col_chamber);
  TGeoCombiTrans *t_chamber_5 = new TGeoCombiTrans("t_chamber_5",0.,0.,outletWindowCenter-3.5/2+chamberThickness,rotUni);
  t_chamber_5->RegisterYourself();

  //BERYLIUM WINDOWS
  TGeoVolume *Actar_BeInletWindow = gGeoManager->MakeSphere("Actar_BeInletWindow",pMedBe,inletWindowRadius,inletWindowRadius+inletWindowThickness, 0.,90.,0.,360.);
  Actar_BeInletWindow->SetLineColor(col_windows);

  TGeoVolume *Actar_BeOutletWindow = gGeoManager->MakeSphere("Actar_BeOutletWindow",pMedBe,outletWindowRadius,outletWindowRadius+outletWindowThickness, 90.,180.,0.,360.);
  Actar_BeOutletWindow->SetLineColor(col_windows);

  TGeoVolume *Actar_chamber_inner = gGeoManager->MakeTube("Actar_chamber_inner",pMed4,0, chamberInnerRadius, chamberHalfLength);

  //ANODE, CATHODE, GRID, RINGS
  TGeoVolume *Actar_anode = gGeoManager->MakeTube("Actar_anode",pMedSteel, 0., anodeRadius, anodeThickness/2);
  Actar_anode->SetLineColor(col_anode);

  TGeoVolume *Actar_cathode = gGeoManager->MakeTube("Actar_cathode",pMedSteel, 0., anodeRadius, cathodeThickness/2);
  Actar_cathode->SetLineColor(col_cathode);

  TGeoVolume *Actar_grid = gGeoManager->MakeTube("Actar_grid",pMedSteel, 0., anodeRadius, gridThickness/2);
  Actar_grid->SetLineColor(col_grid);

  TGeoVolume *Actar_rings = gGeoManager->MakeTorus("Actar_rings",pMedCu, ringRadius, 0., ringGauge/2, 0, 360);
  Actar_rings->SetLineColor(col_rings);

  for(Int_t ringNumber=0;ringNumber<11;ringNumber++)
    Actar_chamber_inner->AddNode(Actar_rings,ringNumber,new TGeoCombiTrans(0.,0., positionAnode+ ringDistance*(ringNumber+1),rotUni));

  Actar_chamber_inner->AddNode(Actar_anode,0,new TGeoCombiTrans(0.,0.,positionAnode,rotUni));
  Actar_chamber_inner->AddNode(Actar_grid,0,new TGeoCombiTrans(0.,0.,positionGrid,rotUni));
  Actar_chamber_inner->AddNode(Actar_cathode,0,new TGeoCombiTrans(0.,0.,positionCathode,rotUni));

  pWorld->AddNode(Actar_chamber_1,0,t0);
  pWorld->AddNode(Actar_chamber_2,0,t_chamber_2);
  pWorld->AddNode(Actar_chamber_3,0,t_chamber_3);
  pWorld->AddNode(Actar_chamber_4,0,t_chamber_4);
  pWorld->AddNode(Actar_chamber_5,0,t_chamber_5);
  pWorld->AddNode(Actar_BeInletWindow,0,new TGeoCombiTrans(0.,0.,inletWindowCenter,rotUni));
  pWorld->AddNode(Actar_BeOutletWindow,0,new TGeoCombiTrans(0.,0.,outletWindowCenter,rotUni));
  pWorld->AddNode(Actar_chamber_inner,0,t0);


  // ---------------   Finish   -----------------------------------------------
  gGeoMan->CloseGeometry();
  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();

  TFile* geoFile = new TFile(geoFileName, "RECREATE");
  top->Write();
  geoFile->Close();
  // --------------------------------------------------------------------------
}
Beispiel #30
0
void event3D()
{
  gSystem->Load("libGeom");
   TGeoManager *geom = new TGeoManager("simple1", "Simple geometry");

   //--- define some materials
   TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
   TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
//   //--- define some media
   TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
   TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl);

     //--- make the top container volume
   Double_t worldx = 110.;
   Double_t worldy = 50.;
   Double_t worldz = 5.;

   TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 100., 100., 100.);
   geom->SetTopVolume(top);

   gGeoManager->GetVolume("TOP")->InvisibleAll();

   //Measurements (in cm)
   
   Double_t target_rad = 0.3;
   Double_t target_len = 48.58;

   Double_t RTPC_len = 41.;
   
   Double_t foil1_R1 = 2.;
   Double_t foil1_R2 = 2.0000018;

   Double_t foil2_R1 = 3.;
   Double_t foil2_R2 = 3.0000018;

   Double_t GEM1_R1 = 7.;
   Double_t GEM1_R2 = 7.0005;

   Double_t GEM2_R1 = 7.3;
   Double_t GEM2_R2 = 7.3005;

   Double_t GEM3_R1 = 7.6;
   Double_t GEM3_R2 = 7.6005;

   Double_t Z_offset = 0;

   Int_t trans_lvl = 70;
   
   TGeoTube *target = new TGeoTube("target_tube",0, target_rad, target_len/2);
   
   TGeoVolume *target_vol = new TGeoVolume("target_vol",target, Al); //(*)

   top->AddNode(target_vol,1,new TGeoTranslation(0,0, Z_offset));
   gGeoManager->GetVolume("target_vol")->SetTransparency(0);   

   TGeoTube *foil1 = new TGeoTube("foil1_tube", foil1_R1, foil1_R2, RTPC_len/2);
   
   TGeoVolume *foil1_vol = new TGeoVolume("foil1_vol", foil1, Al); //(*)

   top->AddNode(foil1_vol,1,new TGeoTranslation(0,0, Z_offset));


   TGeoTube *foil2 = new TGeoTube("foil2_tube", foil2_R1, foil2_R2, RTPC_len/2);
   
   TGeoVolume *foil2_vol = new TGeoVolume("foil2_vol", foil2, Al); //(*)

   top->AddNode(foil2_vol,1,new TGeoTranslation(0,0, Z_offset));


   TGeoTube *gem1 = new TGeoTube("gem1_tube", GEM1_R1, GEM1_R2, RTPC_len/2);
   TGeoVolume *gem1_vol = new TGeoVolume("gem1_vol", gem1, Al); //(*)
   gem1_vol->SetLineColor(kOrange);
   top->AddNode(gem1_vol,1,new TGeoTranslation(0,0, Z_offset));

   TGeoTube *gem2 = new TGeoTube("gem2_tube", GEM2_R1, GEM2_R2, RTPC_len/2);
   TGeoVolume *gem2_vol = new TGeoVolume("gem2_vol", gem2, Al); //(*)
   gem2_vol->SetLineColor(kGreen);
   top->AddNode(gem2_vol,1,new TGeoTranslation(0,0, Z_offset));

   TGeoTube *gem3 = new TGeoTube("gem3_tube", GEM3_R1, GEM3_R2, RTPC_len/2);
   TGeoVolume *gem3_vol = new TGeoVolume("gem3_vol", gem3, Al); //(*)
   top->AddNode(gem3_vol,1,new TGeoTranslation(0,0, Z_offset));
   gem3_vol->SetLineColor(kRed);
   gGeoManager->GetVolume("gem3_vol")->SetTransparency(trans_lvl);   

   
   //--- draw the ROOT box.
   // by default the picture will appear in the standard ROOT TPad.
   //if you have activated the following line in system.rootrc,
   //it will appear in the GL viewer
   //#Viewer3D.DefaultDrawOption:   ogl
   
   geom->CloseGeometry();
   
   geom->SetVisLevel(4);
  
   //   top->SetVisibility(kFALSE);
   top->Draw("ogl");
   gWorld = top;
}