void create_materials_from_media_file()
{
  // Use the FairRoot geometry interface to load the media which are already defined
  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
  TString geoFile = geoPath + "/geometry/media.geo";
  geoFace->setMediaFile(geoFile);
  geoFace->readMedia();

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

  FairGeoMedium* air              = geoMedia->getMedium("air");
  FairGeoMedium* aluminium        = geoMedia->getMedium("aluminium");
  FairGeoMedium* RPCgas           = geoMedia->getMedium("RPCgas");
  FairGeoMedium* RPCgas_noact     = geoMedia->getMedium("RPCgas_noact");
  FairGeoMedium* RPCglass         = geoMedia->getMedium("RPCglass");
  FairGeoMedium* carbon           = geoMedia->getMedium("carbon");

  // include check if all media are found

  geoBuild->createMedium(air);
  geoBuild->createMedium(aluminium);
  geoBuild->createMedium(RPCgas);
  geoBuild->createMedium(RPCgas_noact);
  geoBuild->createMedium(RPCglass);
  geoBuild->createMedium(carbon);
}
Exemplo n.º 2
0
void create_materials_from_media_file()
{
  // Use the FairRoot geometry interface to load the media which are already defined
  FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
  TString geoFile = geoPath + "/geometry/media.geo";
  geoFace->setMediaFile(geoFile);
  geoFace->readMedia();

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

  FairGeoMedium* isobutan              = geoMedia->getMedium("isobutan");
  FairGeoMedium* steel          = geoMedia->getMedium("steel");
  FairGeoMedium* TargetD2          = geoMedia->getMedium("TargetD2");
  FairGeoMedium* vacuum4          = geoMedia->getMedium("vacuum4");
  FairGeoMedium* G10          = geoMedia->getMedium("G10");
  FairGeoMedium* Aluminum   = geoMedia->getMedium("Aluminum");

  // include check if all media are found

  geoBuild->createMedium(isobutan);
  geoBuild->createMedium(steel);
  geoBuild->createMedium(TargetD2);
  geoBuild->createMedium(vacuum4);
  geoBuild->createMedium(G10);
    geoBuild->createMedium(Aluminum);
}
Exemplo n.º 3
0
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();
  // --------------------------------------------------------------------------
}
Exemplo n.º 4
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"); 
}
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();
  // --------------------------------------------------------------------------
}
Exemplo n.º 6
0
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();
  // --------------------------------------------------------------------------
}
Exemplo n.º 7
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();
  // --------------------------------------------------------------------------
}
Exemplo n.º 8
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();
    // --------------------------------------------------------------------------
}
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();
  // --------------------------------------------------------------------------
}
Exemplo n.º 10
0
void create_target_geo(const char* geoTag = "LiH")
{
  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/target_";
  geoFileName = geoFileName + geoTag + ".geo.root";
  // --------------------------------------------------------------------------



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

  FairGeoMedium* mLead = gGeoMedia->getMedium("lead");
  if ( ! mLead ) Fatal("Main", "FairMedium lead not found");
  gGeoBuild->createMedium(mLead);
  TGeoMedium* lead = gGeoMan->GetMedium("lead");
  if ( ! lead ) Fatal("Main", "Medium lead not found");

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

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

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

  FairGeoMedium* mH2      = gGeoMedia->getMedium("H2");
  if ( ! mH2 ) Fatal("Main", "FairMedium H2 not found");
  gGeoBuild->createMedium(mH2);
  TGeoMedium* pMed3 = gGeoMan->GetMedium("H2");
  if ( ! pMed3 ) Fatal("Main", "Medium H2 not found");

  FairGeoMedium* mAu      = gGeoMedia->getMedium("gold");
  if ( ! mAu ) Fatal("Main", "FairMedium gold not found");
  gGeoBuild->createMedium(mAu);
  TGeoMedium* pMedAu = gGeoMan->GetMedium("gold");
  if ( ! pMedAu ) Fatal("Main", "Medium gold not found");

  FairGeoMedium* mCarbon      = gGeoMedia->getMedium("carbon");
  if ( ! mCarbon ) Fatal("Main", "FairMedium carbon not found");
  gGeoBuild->createMedium(mCarbon);
  TGeoMedium* pMedCarbon = gGeoMan->GetMedium("carbon");
  if ( ! pMedCarbon ) Fatal("Main", "Medium carbon not found");

  FairGeoMedium* mVac      = gGeoMedia->getMedium("vacuum");
  if ( ! mVac ) Fatal("Main", "FairMedium vacuum not found");
  gGeoBuild->createMedium(mVac);
  TGeoMedium* pMed = gGeoMan->GetMedium("vacuum");
  if ( ! pMed ) Fatal("Main", "Medium vacuum not found");
  // --------------------------------------------------------------------------



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



  if (0 == strncmp(geoTag, "LeadTarget", 10)) ConstructGeometry1(lead);  	//for s318
  //if (geoTag == "Para")       ConstructGeometry2(pMed2,pMed2); // equivalent to no target
  if (0 == strncmp(geoTag, "Para", 4))       ConstructGeometry2(pMed38,pMed2);
  if (0 == strncmp(geoTag, "Para45", 6))     ConstructGeometry3(pMed38,pMed2);
  if (0 == strncmp(geoTag, "LiH", 3))        ConstructGeometry4(pMed2, pMed15, pMed3, pMedAu);
  if (0 == strncmp(geoTag, "CTarget", 7))    ConstructGeometry5(pMedCarbon);	//for s318
  if (0 == strncmp(geoTag, "CH2Target", 9))  ConstructGeometry6(pMed38); 	//for s318
  if (0 == strncmp(geoTag, "ETTarget", 6))   ConstructGeometry7(pMed); 	//for s318, empty target



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

  TFile* geoFile = new TFile(geoFileName, "RECREATE");
  gTop->Write();
  geoFile->Close();
  // --------------------------------------------------------------------------
}
// -------   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();
  // --------------------------------------------------------------------------
}
Exemplo n.º 12
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();
  // --------------------------------------------------------------------------
}
void create_bpipe_geometry_v13e()
{
  // -----   Define beam pipe sections   --------------------------------------
  /** For v13e:   **/
  TString pipe1name = "pipe1 - vacuum chamber";
  const Int_t nSects1 = 6;
  Double_t z1[nSects1]    = { -50.,  25.,   35.,  230.17, 230.17, 230.87 }; // mm
  Double_t rin1[nSects1]  = {  25.,  25.,  130.,  130.,   110.,   110.   };
  Double_t rout1[nSects1] = {  25.7, 25.7, 130.7, 130.7,  130.7,  130.7  };
  TString pipe2name = "pipe2 - first window @ 220mm, h=0.7mm, R=600mm";
  const Int_t nSects2 = 7;
  Double_t z2[nSects2]    = { 220., 220.7, 221.45, 223.71, 227.49, 230.17, 230.87 }; // mm
  Double_t rin2[nSects2]  = {  18.,  18.,   30.,    60.,    90.,   105.86, 110.   };
  Double_t rout2[nSects2] = {  18.,  28.69, 39.3,   65.55,  94.14, 110.,   110.   };
  TString pipevac1name = "pipevac1";
  const Int_t nSects01 = 10;
  Double_t z01[nSects01]    = { -50., 25.,  35., 220., 220., 220.7,  221.45, 223.71, 227.49, 230.17 }; // mm
  Double_t rin01[nSects01]  = {   0.,  0.,   0.,   0.,  18.,  28.69,  39.3,   65.55,  94.14, 110.   };
  Double_t rout01[nSects01] = {  25., 25., 130., 130., 130., 130.,   130.,   130.,   130.,   130.   };
  TString pipe3name = "pipe3 - STS section";
  const Int_t nSects3 = 5;
  Double_t z3[nSects3]    = { 220.,  494.,  1250.,   1700., 1800. }; // mm
  Double_t rin3[nSects3]  = {  17.4,  17.4,   53.17,   58.5,  58.5};
  Double_t rout3[nSects3] = {  18.,   18.,    55.,     60.,   60. };
  TString pipevac2name = "pipevac2";
  const Int_t nSects02 = 5;
  Double_t z02[nSects02]    = { 220.,  494.,  1250.,   1700., 1800. }; // mm
  Double_t rin02[nSects02]  = {   0.,    0.,     0.,      0.,    0. };
  Double_t rout02[nSects02] = {  17.4,  17.4,   53.17,   58.5,  58.5};
  TString pipe4name = "pipe4 - RICH section";
  const Int_t nSects4 = 2;
  //Double_t z4[nSects4]    = { 1800., 3700.   }; // mm
  Double_t z4[nSects4]    = {    0., 1900.   }; // mm - 1800
  Double_t rin4[nSects4]  = {   58.5, 125.24 };
  Double_t rout4[nSects4] = {   60.,  129.56 };
  TString pipevac3name = "pipevac3";
  const Int_t nSects03 = 2;
  //Double_t z03[nSects03]    = { 1800., 3700.   }; // mm
  Double_t z03[nSects03]    = {    0., 1900.   }; // mm - 1800
  //Double_t rin03[nSects03]  = {    0.,    0.   };
  Double_t rin03[nSects03]  = {    0.00001,    0.00001   }; // TODO
  Double_t rout03[nSects03] = {   58.5, 125.24 };
  TString pipe5name = "pipe5 - TRD & TOF section";
  const Int_t nSects5 = 3;
  //Double_t z5[nSects5]    = { 3700.,   5996.97, 6000.   }; // mm
  Double_t z5[nSects5]    = { 1900.,   4196.97,  4200.  }; // mm - 1800
  Double_t rin5[nSects5]  = {  125.24,   183.6,   183.6 };
  Double_t rout5[nSects5] = {  129.56,   189.92,  190.  };
  TString pipevac4name = "pipevac4";
  const Int_t nSects04 = 7;
  //Double_t z04[nSects04]    = { 3700.,   5976.19, 5976.19, 5979.19, 5982.19, 5989.13, 5996.97 }; // mm
  Double_t z04[nSects04]    = { 1900.,   4176.19, 4176.19, 4179.19, 4182.19, 4189.13, 4196.97 }; // mm - 1800
  Double_t rin04[nSects04]  = {    0.,      0.,     30.,     75.41,  102.26,  146.38,  183.6  };
  Double_t rout04[nSects04] = {  125.24,  182.86,  182.86,  182.86,  183.,    183.19,  183.6  };
  TString pipe6name = "pipe6 - second window @ 6000mm, h=3mm, R=800mm";
  const Int_t nSects6 = 6;
  //Double_t z6[nSects6]     = {    0.,      3.,      6.,     12.94,   20.78,   23.81 }; // mm - 5976.19
  //Double_t z6[nSects6]     = { 5976.19, 5979.19, 5982.19, 5989.13, 5996.97, 6000.  }; // mm
  Double_t z6[nSects6]     = { 4176.19, 4179.19, 4182.19, 4189.13, 4196.97, 4200.  }; // mm - 1800
  Double_t rin6[nSects6]   = {   30.,     30.,     75.41,  129.22,  170.33,  183.6 };
  Double_t rout6[nSects6]  = {   30.,     75.41,  102.26,  146.38,  183.6,   183.6 };
  TString pipe7name = "pipe7 - PSD section";
  const Int_t nSects7 = 2;
  //Double_t z7[nSects7]    = { 5976.19, 7990. }; // mm
  Double_t z7[nSects7]    = { 4176.19,  6190. }; // mm - 1800
  Double_t rin7[nSects7]  = {   29.,      29. };
  Double_t rout7[nSects7] = {   30.,      30. };
  TString pipevac5name = "pipevac5";
  const Int_t nSects05 = 2;
  Double_t z05[nSects05]    = { 4176.19,  6190. }; // mm - 1800
  Double_t rin05[nSects05]  = {    0.,       0. };
  Double_t rout05[nSects05] = {   29.,      29. };
  // --------------------------------------------------------------------------

  // -------------  Load the necessary FairRoot libraries   -------------------
  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
  basiclibs();
  gSystem->Load("libGeoBase");
  gSystem->Load("libParBase");
  gSystem->Load("libBase");
  // --------------------------------------------------------------------------


  // -------   Open info file   -----------------------------------------------
  TString infoFileName = rootFileName;
  infoFileName.ReplaceAll("root", "info");
  fstream infoFile;
  fstream infoFileEmpty;
  infoFile.open(infoFileName.Data(), fstream::out);
  infoFile << "Beam pipe geometry created with " + macrosname << endl << endl;

  infoFile << " The beam pipe is composed of aluminium with a thickness proportional to the" << endl;
  infoFile << " diameter (0.017*D(z)mm). It is placed directly into the cave as mother " << endl;
  infoFile << " volume. The beam pipe consists of few sections (including RICH/MUCH " << endl;
  infoFile << " section). Each section has a PCON shape (including windows). There are two " << endl;
  infoFile << " windows: first one @ 220mm with R600mm and 0.7mm thickness, second one @ " << endl;
  infoFile << " 6000mm with R800mm and 3mm thickness. The last three sections (and second " << endl;
  infoFile << " window @ 6000mm) of beam pipe (1800-7990mm) are rotated by an angle of " << endl;
  infoFile << " " << Form("%.2f",rotangle) << 
              " degrees relative to point (0,0,1800) mm and the OY axis, following the " << endl;
  infoFile << " bend of the ions in the magnetic field (field_v12b was used)." << endl << endl;
  
  infoFile << "Material:  " << pipeMediumName << endl;
  infoFile << "Thickness: 0.017*D(z) mm" << endl << endl;
  // --------------------------------------------------------------------------


  // -------   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.geo";
  geoFace->setMediaFile(medFile);
  geoFace->readMedia();
  TGeoManager* gGeoMan = gGeoManager;
  // --------------------------------------------------------------------------



  // -----------------   Get and create the required media    -----------------
  FairGeoMedia*   geoMedia = geoFace->getMedia();
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
  
  // ---> pipe medium
  FairGeoMedium* fPipeMedium = geoMedia->getMedium(pipeMediumName.Data());
  TString fairError = "FairMedium " + pipeMediumName + " not found";
  if ( ! fPipeMedium ) Fatal("Main", fairError.Data());
  geoBuild->createMedium(fPipeMedium);
  TGeoMedium* pipeMedium = gGeoMan->GetMedium(pipeMediumName.Data());
  TString geoError = "Medium " + pipeMediumName + " not found";
  if ( ! pipeMedium ) Fatal("Main", geoError.Data());
  // ---> vacuum
  FairGeoMedium* mVacuum = geoMedia->getMedium("vacuum");
  if ( ! mVacuum ) Fatal("Main", "FairMedium vacuum not found");
  geoBuild->createMedium(mVacuum);
  TGeoMedium* vacuum = gGeoMan->GetMedium("vacuum");
  if ( ! vacuum ) Fatal("Main", "Medium vacuum not found");
  // --------------------------------------------------------------------------



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


  // -----   Create sections  -------------------------------------------------
  infoFile << endl << "Beam pipe section: " << pipe1name << endl;
  infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
  //*
  TGeoVolume* pipe1    = MakePipe  (1, nSects1,  z1,  rin1,  rout1,  pipeMedium, &infoFile); 
  pipe1->SetLineColor(kGray);
  pipe->AddNode(pipe1, 0);
  
  infoFile << endl << "Beam pipe section: " << pipe2name << endl;
  infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
  TGeoVolume* pipe2    = MakePipe  (2, nSects2,  z2,  rin2,  rout2,  pipeMedium, &infoFile); 
  pipe2->SetLineColor(kBlue);
  pipe->AddNode(pipe2, 0);
  TGeoVolume* pipevac1 = MakeVacuum(1, nSects01, z01, rin01, rout01, vacuum,     &infoFile); 
  pipevac1->SetLineColor(kCyan);
  pipe->AddNode(pipevac1, 0);
  
  infoFile << endl << "Beam pipe section: " << pipe3name << endl;
  infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
  TGeoVolume* pipe3    = MakePipe  (3, nSects3,  z3,  rin3,  rout3,  pipeMedium, &infoFile); 
  pipe3->SetLineColor(kGreen);
  pipe->AddNode(pipe3, 0);
  TGeoVolume* pipevac2 = MakeVacuum(2, nSects02, z02, rin02, rout02, vacuum,     &infoFile); 
  pipevac2->SetLineColor(kCyan);
  pipe->AddNode(pipevac2, 0);
  //*/
  
  // define some rotation & translation for pipe4-pipe7 & pipevac3-pipevac5
  // Initial phi   (Euler rotation angle about Z)
  // Initial theta (Euler rotation angle about new X)
  // Initial psi   (Euler rotation angle about new Z)
  cout<<endl<<"Rotation angle (@[0;0;1800]mm)="<< rotangle <<"deg";
  TGeoRotation    *r1 = new TGeoRotation("r1", 90., rotangle, 0.); // deg - Euler angles
  r1->RegisterYourself();
  Double_t shift = rotangle/10.+0.1; // cm - volume boolean operation correction - TODO
  Double_t dx=0., dy=0., dz=1800.-10.*shift; // mm
  TGeoCombiTrans  *c1 = new TGeoCombiTrans("c1", dx/10., dy/10., dz/10., r1); // mm->cm
  c1->RegisterYourself();
  TGeoTranslation *t1 = new TGeoTranslation("t1", 0., 0., 180.-shift); // cm
  t1->RegisterYourself();
  Double_t phi, theta, psi;
  c1->GetRotation()->GetAngles(phi, theta, psi);
  
  infoFile << endl << "Beam pipe section: " << pipe4name << endl;
  infoFile << "Traslation(dx,dy,dz):    "<< dx <<" "<< dy <<" "<< dz <<" mm" << endl;
  infoFile << "Rotation(phi,theta,psi): " << phi <<" "<< theta <<" "<< psi <<" deg"<< endl;
  infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
  // create shape components for pipe4
  TGeoPcon* p4 = MakeShape(nSects4, "p4", z4, rin4,  rout4, &infoFile);
  TGeoBBox* b  = new TGeoBBox("b", 7., 7., shift); // cm 0.13
  // create a composite for pipe4
  //*
  TGeoCompositeShape *cs1 = new TGeoCompositeShape("cs1", "p4:r1-b");
  TGeoVolume *pipe4 = new TGeoVolume("pipe4",cs1, pipeMedium);
  pipe4->SetLineColor(kGreen+2);
  pipe->AddNode(pipe4, 0, t1);
  //*/
  // create shape components for pipevac3
  TGeoPcon* p03 = MakeShape(nSects03, "p03", z03, rin03, rout03, &infoFileEmpty);
  // create a composite for pipevac3
  TGeoCompositeShape *cs2 = new TGeoCompositeShape("cs2", "p03:r1-b");
  TGeoVolume *pipevac3 = new TGeoVolume("pipevac3",cs2, vacuum);
  pipevac3->SetLineColor(kCyan);
  pipe->AddNode(pipevac3, 0, t1);
  //*
  infoFile << endl << "Beam pipe section: " << pipe5name << endl;
  infoFile << "Traslation(dx,dy,dz):    "<< dx <<" "<< dy <<" "<< dz <<" mm" << endl;
  infoFile << "Rotation(phi,theta,psi): " << phi <<" "<< theta <<" "<< psi <<" deg"<< endl;
  infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
  TGeoVolume* pipe5    = MakePipe  (5, nSects5,  z5,  rin5,  rout5,  pipeMedium, &infoFile); 
  pipe5->SetLineColor(kGreen);
  pipe->AddNode(pipe5, 0, c1);
  TGeoVolume* pipevac4 = MakeVacuum(4, nSects04, z04, rin04, rout04, vacuum,     &infoFile); 
  pipevac4->SetLineColor(kCyan);
  pipe->AddNode(pipevac4, 0, c1);
  
  infoFile << endl << "Beam pipe section: " << pipe6name << endl;
  infoFile << "Traslation(dx,dy,dz):    "<< dx <<" "<< dy <<" "<< dz <<" mm" << endl;
  infoFile << "Rotation(phi,theta,psi): " << phi <<" "<< theta <<" "<< psi <<" deg"<< endl;
  infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
  TGeoVolume* pipe6    = MakePipe  (6, nSects6,  z6,  rin6,  rout6,  pipeMedium, &infoFile); 
  pipe6->SetLineColor(kBlue);
  pipe->AddNode(pipe6, 0, c1);
  
  infoFile << endl << "Beam pipe section: " << pipe7name << endl;
  infoFile << "Traslation(dx,dy,dz):    "<< dx <<" "<< dy <<" "<< dz <<" mm" << endl;
  infoFile << "Rotation(phi,theta,psi): " << phi <<" "<< theta <<" "<< psi <<" deg"<< endl;
  infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl;
  TGeoVolume* pipe7    = MakePipe  (7, nSects7,  z7,  rin7,  rout7,  pipeMedium, &infoFile); 
  pipe7->SetLineColor(kGreen);
  pipe->AddNode(pipe7, 0, c1);
  TGeoVolume* pipevac5 = MakeVacuum(5, nSects05, z05, rin05, rout05, vacuum,     &infoFile); 
  pipevac5->SetLineColor(kCyan);
  pipe->AddNode(pipevac5, 0, c1);
  //*/
  
  // -----   End   --------------------------------------------------

  // ---------------   Finish   -----------------------------------------------
  top->AddNode(pipe, 1);
  cout << endl << endl;
  gGeoMan->CloseGeometry();
  gGeoMan->CheckOverlaps(0.001);
  gGeoMan->PrintOverlaps();
  gGeoMan->Test();
  
  // visualize it with ray tracing, OGL/X3D viewer
  //top->Raytrace();
  top->Draw("ogl");
  //top->Draw("x3d");

  TFile* rootFile = new TFile(rootFileName, "RECREATE");
  top->Write();
  cout << endl;
  cout << "Geometry " << top->GetName() << " written to " 
       << rootFileName << endl;
  rootFile->Close();
  infoFile.close();


}
Exemplo n.º 14
0
void create_sfi_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/sfi_";
  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);
  // --------------------------------------------------------------------------
  
  //LABPOS(GFI1,-73.274339,0.069976,513.649524)
  Float_t dx = -73.274339; //dE tracker, correction due to wrong angle
  Float_t dy = 0.069976;
  Float_t dz = 513.649524;
  
  TGeoRotation *pMatrix3 = new TGeoRotation();
  //pMatrix3->RotateY(-16.7);
  TGeoCombiTrans*
  pMatrix2 = new TGeoCombiTrans("", dx,dy,dz,pMatrix3);

  //LABPOS(GFI2,-147.135037,0.069976,729.680342)
  dx = -147.135037; //dE tracker, correction due to wrong angle
  dy = 0.069976;
  dz = 729.680342;

  TGeoRotation *pMatrix5 = new TGeoRotation();
  //pMatrix5->RotateY(-16.7);
  TGeoCombiTrans*
  pMatrix4 = new TGeoCombiTrans("", dx,dy,dz,pMatrix5);
  
  
  // World definition
  TGeoVolume* pWorld = gGeoManager->GetTopVolume();
  pWorld->SetVisLeaves(kTRUE);
  
  // SHAPES, VOLUMES AND GEOMETRICAL HIERARCHY 
  
  // Volume: GFILogWorld
  
  TGeoVolume*   pGFILogWorld = new TGeoVolumeAssembly("GFILogWorld");
  pGFILogWorld->SetVisLeaves(kTRUE);
  
  // Global positioning
  pWorld->AddNode( pGFILogWorld, 0, pMatrix2 );
  
  Float_t detector_size = 5.120000;
  Float_t fiber_thickness = 0.020000; 
  
  TGeoShape *pGFITube = new TGeoBBox("GFITube", fiber_thickness/2,detector_size/2,fiber_thickness/2);
  
  TGeoVolume* pGFILog = new TGeoVolume("SFILog",pGFITube, pMed35);

  TGeoShape *pGFITubeActive = new TGeoBBox("GFITubeActive", (fiber_thickness * .98)/2, detector_size/2-0.0001, (fiber_thickness * .98)/2);

  TGeoVolume* pGFILogActive = new TGeoVolume("SFI1Log",pGFITubeActive,pMed35);
  
  pGFILog->SetLineColor((Color_t) 1);
  pGFILog->SetVisLeaves(kTRUE);
  
  TGeoRotation *pMatrixTube = new TGeoRotation();
  pMatrixTube->RotateZ(90);
  
  pGFILog -> AddNode(pGFILogActive, 0, new TGeoCombiTrans());
  
  for(int fiber_id = 0; fiber_id < detector_size / fiber_thickness; fiber_id++)
  {
     pGFILogWorld->AddNode(pGFILog, fiber_id, 
		new TGeoCombiTrans("", 
			-detector_size / 2 + (fiber_id + .5) * fiber_thickness, 
			0,
			0,
			new TGeoRotation()
		)
	);
      pGFILogWorld->AddNode(pGFILog, fiber_id + detector_size / fiber_thickness, 
		new TGeoCombiTrans("", 
			0,
			-detector_size / 2 + (fiber_id + .5) * fiber_thickness,
			fiber_thickness,
			pMatrixTube
		)
	);
  }
  
  // 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();
  // --------------------------------------------------------------------------
}