Ejemplo n.º 1
0
void OpNoviceGeom()
{
// Create root geometry corresponding to OpNovice example
  double fExpHall_x, fExpHall_y, fExpHall_z;
  double fTank_x, fTank_y, fTank_z;
  double fBubble_x, fBubble_y, fBubble_z;
  double a, z, density;
  int nelements;

  fExpHall_x = fExpHall_y = fExpHall_z = 10000.0;
  fTank_x    = fTank_y    = fTank_z    =  5000.0;
  fBubble_x  = fBubble_y  = fBubble_z  =  500.0;
  TGeoManager *geom = new TGeoManager("OpNoviceGeom", "GEANT4 OpNovice example");
// Air
//
  TGeoElement *N = new TGeoElement("Nitrogen", "N", z=7 , a=14.01);
  TGeoElement *O = new TGeoElement("Oxygen"  , "O", z=8 , a=16.00);
  TGeoMixture *air = new TGeoMixture("Air", 2, density=1.29E-3);
  air->AddElement(N, 0.7);
  air->AddElement(O, 0.3);
  TGeoMedium *medair = new TGeoMedium("Air", 1, air);
// Water
//
  TGeoElement *H = new TGeoElement("Hydrogen", "H", z=1 , a=1.01);
  TGeoMixture *water = new TGeoMixture("Water", 2, density=1.0); 
  water->AddElement(H,2);
  water->AddElement(O,1);
  TGeoMedium *medwater = new TGeoMedium("Water", 2, water);
// The experimental Hall
//
  TGeoBBox *expHall_box = new TGeoBBox("World",fExpHall_x,fExpHall_y,fExpHall_z);
  TGeoVolume *expHall_log = new TGeoVolume("World", expHall_box, medair);
  expHall_log->SetLineColor(1);
  expHall_log->SetVisContainers();
  geom->SetTopVolume(expHall_log);
// The Water Tank
//
  TGeoBBox *waterTank_box = new TGeoBBox("Tank",fTank_x,fTank_y,fTank_z);
  TGeoVolume *waterTank_log = new TGeoVolume("Tank", waterTank_box, medwater);
  waterTank_log->SetLineColor(kBlue);
  waterTank_log->SetTransparency(70);
  waterTank_log->SetVisContainers();
  expHall_log->AddNode(waterTank_log, 0);
// The Air Bubble
//
  TGeoBBox *bubbleAir_box = new TGeoBBox("Bubble",fBubble_x,fBubble_y,fBubble_z);
  TGeoVolume *bubbleAir_log = new TGeoVolume("Bubble", bubbleAir_box, medair);
  bubbleAir_log->SetLineColor(kCyan);
  bubbleAir_log->SetTransparency(70);
  waterTank_log->AddNode(bubbleAir_log, 0, new TGeoTranslation(0,2500,0));
  
  geom->CloseGeometry();
  geom->SetTopVisible(true);
  geom->Export("OpNoviceGeom.root");
}
Ejemplo n.º 2
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");

}
Ejemplo n.º 3
0
void geom_Al()
{
// Set the range
//---------------------------------------------------------------------------//

  // 0.314 Mev Ranges (g/cm2):
  /* 0.0025 0.0094 0.0181 0.0255 0.0336 0.0403 0.0477 0.0566 0.0654 0.0721
   * 0.0810 0.0993 */

  // 0.521 Mev Ranges (g/cm2):
  /* 0.0025 0.0094 0.0180 0.0255 0.0335 0.0405 0.0475 0.0566 0.0653 0.0721
   * 0.0807 0.0992 0.1111 0.1259 0.1439 0.1596 0.1825 0.2125 */

  // 1.033 Mev Ranges (g/cm2):
  /* 0.0025 0.0094 0.0180 0.0255 0.0336 0.0402 0.0476 0.0562 0.0654 0.0723
   * 0.0808 0.0990 0.1110 0.1257 0.1440 0.1593 0.1821 0.2122 0.2225 0.2452
   * 0.2521 0.2908 0.3141 0.3533 0.4188 0.4814 */

  // Range of dose depth calculation in cm
  double range = 0.0993;
//---------------------------------------------------------------------------//


  // Set up manager of the geometry world
  gSystem->Load( "libGeom" );
  TGeoManager* geom = new TGeoManager(
    "geom_Al",
    "Geometry for electron energy deposition in Al test problems.");

//---------------------------------------------------------------------------//
// Material and Mixture Definitions
//---------------------------------------------------------------------------//

  // Al ( density given as 2.7 not 2.69890 g/cm^3 )
  density = 2.7;
  TGeoMaterial* mat_1 = new TGeoMaterial( "mat_1", 26.9815385, 13, -density );

  // Void material
  TGeoMaterial* void_mat = new TGeoMaterial( "void", 0, 0, 0 );

  // Graveyard (terminal)
  TGeoMaterial* graveyard_mat = new TGeoMaterial( "graveyard", 0, 0, 0 );

//---------------------------------------------------------------------------//
// Medium Definitions
//---------------------------------------------------------------------------//

  // Al
  TGeoMedium* med_1 = new TGeoMedium( "med_1", 1, mat_1 );

  // Void
  TGeoMedium* void_med = new TGeoMedium( "void_med", 2, void_mat );

  // Graveyard
  TGeoMedium* graveyard_med = new TGeoMedium( "graveyard", 3, graveyard_mat );

//---------------------------------------------------------------------------//
// Volume Definitions
//---------------------------------------------------------------------------//

  //----------------------------
  // Create the calorimeter foil
  //----------------------------

  // Thickness of the calorimeter foil (given in g/cm^2)
  double calorimeter_thickness = 5.050E-03/density;
  // Half the height
  double half_cal_thickness = calorimeter_thickness/2.0;

  // Height (given - largest dimension)
  double height = 8.255;
  // Half side length
  double half_height = height/2.0;

  TGeoVolume* calorimeter_foil =
    geom->MakeBox( "Calorimeter_Foil", med_1, half_height, half_height, half_cal_thickness );

  calorimeter_foil->SetUniqueID( 1 );
  calorimeter_foil->SetLineColor( 2 );

  // //----------------------
  // // Create the front foil
  // //----------------------

  // Calculate the range = 0.4814;
  double range_cm = range/density;

  // Calculate the thickness of the front foil
  double front_thickness = range_cm - half_cal_thickness;

  TGeoVolume* front_foil;
  if (front_thickness > 0.0 )
  {
    // Height (given - largest dimension)
    height = 8.89;
    // Half side length
    half_height = height/2.0;

    front_foil =
      geom->MakeBox( "Front_Foil", med_1, half_height, half_height, front_thickness/2.0 );

    front_foil->SetUniqueID( 2 );
    front_foil->SetLineColor( 3 );
  }

  //--------------------------------------------------------
  // Create the infinite plate (D = 7.62 cm, h = "infinite")
  //--------------------------------------------------------

  double plate_radius = 3.81;
  double plate_half_length = 0.5;
  TGeoVolume* infinite_plate =
    geom->MakeTube( "Infinite_Plate", med_1, 0.0, plate_radius, plate_half_length );

  infinite_plate->SetUniqueID( 3 );
  infinite_plate->SetLineColor( 4 );

  //--------------------------------------------------------
  // Create the vacuum (R = "infinite" cm, h = "infinite")
  //--------------------------------------------------------

  // Set a radius of 7 cm ( 167 x the CSDA range = 0.4814;
  double vacuum_radius = 7.0;
  // Set a vacuum length large enough to cover the whole geometry
  double vacuum_half_length = 2.0*plate_half_length + 5.0 + calorimeter_thickness + 0.5;
  // Add region
  TGeoVolume* void_region =
    geom->MakeTube( "Void", void_med, 0.0, vacuum_radius, vacuum_half_length );

  void_region->SetUniqueID( 4 );
  void_region->SetLineColor( 6 );
  void_region->SetVisibility( true );

  //--------------------------------------------------------
  // Create the graveyard (encompasses the entire geometry)
  //--------------------------------------------------------

  // Add region
  TGeoVolume* graveyard_region =
    geom->MakeTube( "Graveyard", graveyard_med, 0.0, vacuum_radius + 0.5, vacuum_half_length + 0.5 );

  graveyard_region->SetUniqueID( 5 );
  graveyard_region->SetLineColor( 7 );
  graveyard_region->SetVisContainers( true );

//---------------------------------------------------------------------------//
// Heirarchy (Volume) Definitions
//---------------------------------------------------------------------------//

// Set graveyard as the top volume
geom->SetTopVolume(graveyard_region);

  //------------------------
  // Add vacuum to graveyard
  //------------------------
  // Get z position of the vacuum
  double vacuum_z = vacuum_half_length;
  // Add region
  graveyard_region->AddNode(void_region, 0 );

    //-----------------------------------
    // Add the calorimeter foil to vacuum
    //-----------------------------------

    // Set the front of the calorimeter at a z of 5 cm
    double calorimeter_z = 5.0 + half_cal_thickness;
    // Add the front calorimeter foil to vacuum
    void_region->AddNode( calorimeter_foil, 1, new TGeoTranslation(0,0,calorimeter_z) );

    //-----------------------------------
    // Add the front foil to vacuum
    //-----------------------------------

    if( front_thickness > 0.0 )
    {
      // Set the front foil 0.1 cm in front of the calorimeter
      double front_z = 4.9 - front_thickness/2.0;
      // Add the region
      void_region->AddNode( front_foil, 2, new TGeoTranslation(0,0,front_z) );
    }

    //-----------------------------------
    // Add the infinite plate to vacuum
    //-----------------------------------

    // Set the infinite plate 0.1 cm behind the  calorimeter
    double plate_z = 5.1 + calorimeter_thickness + plate_half_length;
    // Add region
    void_region->AddNode( infinite_plate, 3, new TGeoTranslation(0,0,plate_z) );


//---------------------------------------------------------------------------//
// Export and Drawing Capabilities
//---------------------------------------------------------------------------//

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

  // // Draw the geometry
  // geom->SetTopVisible();
  // graveyard_region->Draw();

  // TView *view = gPad->GetView();
  // view->ShowAxis();

  // Export the geometry
  geom->Export( "geom_Al.root" );

  // Finished
  exit(0);
}