Example #1
0
void TestMatrix()
{
  TGeoHMatrix identity;
  /** translations **/
  TGeoTranslation tr1(1., 2., 3.);
  // Copy ctor
  TGeoTranslation tr2(tr1);
  myassert(tr2 == tr1, "translation copy ctor wrong");
  // Assignment
  tr2 = tr1;
  myassert(tr2 == tr1, "translation assignment wrong");
  myassert(tr2.IsTranslation(), "translation flag not set");
  // Composition
  TGeoTranslation trref1(2., 4., 6.);
  TGeoTranslation tr3 = tr1 * tr2;
  myassert(tr3 == trref1, "translation multiplication wrong");
  tr2 *= tr1;
  myassert(tr2 == trref1, "translation inplace multiplication wrong");
  tr2 *= tr2.Inverse();
  myassert(tr2 == identity, "translation inverse wrong");

  /** rotations **/
  TGeoRotation r1;
  r1.RotateZ(90.);
  // Copy ctor
  TGeoRotation r2(r1);
  myassert(r2 == r1, "rotation copy ctor wrong");
  // Assignment
  r2 = r1;
  myassert(r2 == r1, "rotation assignment wrong");
  myassert(r2.IsRotation(), "rotation flag not set");
  // Composition
  TGeoRotation r3  = r1 * r1 * r1 * r1;
  myassert(r3 == identity, "rotation multiplication wrong");
  r2 *= r2.Inverse();
  myassert(r2 == identity, "rotation inplace multiplication wrong");

   /** scale **/
  TGeoScale scl1(1., 2., 3.);
  // Copy ctor
  TGeoScale scl2(scl1);
  myassert(scl2 == scl1, "scale copy ctor wrong");
  // Assignment
  scl2 = scl1;
  myassert(scl2 == scl1, "scale assignment wrong");
  myassert(scl2.IsScale(), "scale flag not set");
  // Composition
  TGeoScale sclref1(1., 4., 9.);
  TGeoScale scl3 = scl1 * scl2;
  myassert(scl3 == sclref1, "scale multiplication wrong");
  scl2 *= scl1;
  myassert(scl2 == sclref1, "scale inplace multiplication wrong");
  scl2 *= scl2.Inverse();
  myassert(scl2 == identity, "scale inverse wrong");

  /** HMatrix **/
  // Copy constructor
  TGeoHMatrix h1(tr1);
  myassert(h1 == tr1 && h1.IsTranslation(), "hmatrix constructor from translation wrong");

  // Assignment
  TGeoHMatrix h2 = r1;
  TGeoHMatrix h3 = scl1;
  myassert(h2 == r1 && h3 == scl1 && h2.IsRotation() && h3.IsScale(), "hmatrix assignment wrong");

  TGeoHMatrix h4 = h1 * h2;
  myassert(tr1 == h4 && r1 == h4 && h4.IsTranslation() && h4.IsRotation(), "hmatrix multiplication wrong");

  h4 *= h4.Inverse();
  myassert(h4 == identity, "hmatrix inverse wrong");

  /** Combi trans **/
  // Copy constructor
  TGeoCombiTrans c1(tr1);
  myassert(c1 == tr1 && c1.IsTranslation(), "combi trans constructor from translation wrong");

  // Assignment
  TGeoCombiTrans c2 = r1;
  myassert(c2 == r1 && c2.IsRotation(), "combi trans assignment wrong");

  TGeoCombiTrans c3 = c1 * c2;
  myassert(tr1 == c3 && r1 == c3 && c3.IsTranslation() && c3.IsRotation(), "combi trans multiplication wrong");

  c3 *= c3.Inverse();
  myassert(c3 == identity, "combi trans inverse wrong");

  TGeoCombiTrans c4(1., 2., 3., &r1);
  c4.Print();
  TGeoCombiTrans c5(c4);
  c5.Print();
  myassert(c4.GetRotation() == &r1 && c5.GetRotation() != &r1, "combi trans copy constructor wrong");

  // Test for Wolfgang Korsch's case
  TGeoHMatrix href = tr1;
  href *= TGeoRotation("", 0, 120, 0);
  TGeoRotation r4;
  r4.SetAngles(0, 90, 0);
  TGeoRotation r5 = r4;
  r4.SetAngles(0, 30, 0);
  r5 = r5 * r4;
  TGeoHMatrix combiH1TB = tr1 * r5;
  myassert(combiH1TB == href, "translation multiplication demoted");

  // Test for David Rohr's case
  TGeoHMatrix h5 = href, h6 = href;
  h5 *= h6.Inverse();
  h6.Multiply(h6.Inverse());
  myassert(h5 == h6 && h5 == identity, "inverse not matching");
}
Example #2
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"); 
}
Example #3
0
double Func(const double* par)
{
  static bool initialized = kFALSE;
  static TGeoRotation rot[kNtheta];
  static TGeoTranslation tr("tr", 0, 0, -3*mm);

  if(!initialized){
    for(int i = 0; i < kNtheta; i++){
      rot[i] = TGeoRotation();
      rot[i].SetAngles(0, kTheta[i], 0.);
    } // i
    initialized = kTRUE;
  } // if
  
  if(gOpticsManager){
    delete gOpticsManager;
  } // if
  gOpticsManager = new AOpticsManager("manager", "manager");
  gOpticsManager->DisableFresnelReflection(kTRUE);

  // Make the world
  TGeoBBox* box = new TGeoBBox("box", 100*mm, 100*mm, 100*mm);
  AOpticalComponent* top = new AOpticalComponent("top", box);
  gOpticsManager->SetTopVolume(top);

  AGeoAsphericDisk* disk = new AGeoAsphericDisk("disk", 0*mm, 0., par[0], par[1], kRadius, 0.*mm);
  disk->SetConicConstants(0, par[2]);
  double f1 = disk->CalcF1(kRadius);
  double f2 = disk->CalcF2(kRadius);
  if(f2 - f1 < 0){ // negative edge thickness
    return 1e100;
  } // if

  ALens* lens = new ALens("lens", disk);
  lens->SetRefractiveIndex(AGlassCatalog::GetRefractiveIndex("N-BK7"));
  gOpticsManager->GetTopVolume()->AddNode(lens, 1);
  
  double origin[3] = {0, 0, 50*mm + 1*um};
  TGeoBBox* box2 = new TGeoBBox("box2", 10*mm, 10*mm, 1*um, origin);
  AFocalSurface* screen = new AFocalSurface("screen", box2);
  top->AddNode(screen, 1);

  AGeoAsphericDisk* disk2 = new AGeoAsphericDisk("disk2", 0*mm, 0., par[0], 0., kRadius*1.2, kRadius);
  AObscuration* obs = new AObscuration("obs", disk2);
  gOpticsManager->GetTopVolume()->AddNode(obs, 1);
  
  gOpticsManager->CloseGeometry();

  double total = 0.;

  for(int i = 0; i < kNtheta; i++){
    if(gArray[i]){
      delete gArray[i];
      gArray[i] = 0;
    } // if

    const double kLambda = 587.6*nm;
    gArray[i] = ARayShooter::Circle(kLambda, kRadius*1.1, 20, 10, &rot[i], &tr);
    gOpticsManager->TraceNonSequential(gArray[i]);
    
    total += TMath::Power(GetSpotSize(gArray[i]), 2);
  } // i

  if(total == 0){
    return 1e100;
  } // if

  return total;
}