#include "TGeoMatrix.h" #include "TGeoElement.h" #include "TGeoCompositeShape.h" #include "TGeoManager.h" #include "TGeoMaterial.h" #include "TGeoMedium.h" #include "TGeoVolume.h" #include "TSystem.h" #include "TMath.h" void Chamfer(Int_t X, Int_t Y, Int_t Z, Int_t CUT) { gSystem->Load("libGeom"); TGeoManager* geom = new TGeoManager("geom", "Geometry Base"); //--- define some materials (dummy) TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl); Double_t cm = 1.; Double_t mm = cm/10.; Double_t dx = X*mm; Double_t dy = Y*mm; Double_t dz = Z*mm; Double_t cut= CUT*mm; //--- make the top container volumej Double_t worldx = 100*cm; Double_t worldy = 100*cm; Double_t worldz = 100*cm; TGeoVolume* world = geom->MakeBox("World", Al, worldx, worldy, worldz); geom->SetTopVolume(world); TGeoBBox* box = new TGeoBBox("box", dx/2., dy/2., dz/2.); Double_t sq2 = TMath::Sqrt(2.); TGeoBBox* chamX = new TGeoBBox("chamX", dx/2, cut*sq2/2, cut*sq2/2); TGeoBBox* chamY = new TGeoBBox("chamY", cut*sq2/2, dy/2, cut*sq2/2); TGeoBBox* chamZ = new TGeoBBox("chamZ", cut*sq2/2, cut*sq2/2, dz/2); TGeoRotation* rotX = new TGeoRotation("rotX", 0, 45, 0); TGeoRotation* rotY = new TGeoRotation("rotY", 45, 0, 90, 90, 45, 180); TGeoRotation* rotZ = new TGeoRotation("rotZ", 45, 0, 0); TGeoCombiTrans* comX1 = new TGeoCombiTrans("comX1", 0, +dy/2, +dz/2, rotX); TGeoCombiTrans* comX2 = new TGeoCombiTrans("comX2", 0, +dy/2, -dz/2, rotX); TGeoCombiTrans* comX3 = new TGeoCombiTrans("comX3", 0, -dy/2, +dz/2, rotX); TGeoCombiTrans* comX4 = new TGeoCombiTrans("comX4", 0, -dy/2, -dz/2, rotX); TGeoCombiTrans* comY1 = new TGeoCombiTrans("comY1", +dx/2, 0, +dz/2, rotY); TGeoCombiTrans* comY2 = new TGeoCombiTrans("comY2", +dx/2, 0, -dz/2, rotY); TGeoCombiTrans* comY3 = new TGeoCombiTrans("comY3", -dx/2, 0, +dz/2, rotY); TGeoCombiTrans* comY4 = new TGeoCombiTrans("comY4", -dx/2, 0, -dz/2, rotY); TGeoCombiTrans* comZ1 = new TGeoCombiTrans("comZ1", +dx/2, +dy/2, 0, rotZ); TGeoCombiTrans* comZ2 = new TGeoCombiTrans("comZ2", +dx/2, -dy/2, 0, rotZ); TGeoCombiTrans* comZ3 = new TGeoCombiTrans("comZ3", -dx/2, +dy/2, 0, rotZ); TGeoCombiTrans* comZ4 = new TGeoCombiTrans("comZ4", -dx/2, -dy/2, 0, rotZ); TGeoMatrix* mat[] = {rotX, rotY, rotZ, comX1, comX2, comX3, comX4, comY1, comY2, comY3, comY4, comZ1, comZ2, comZ3, comZ4}; for(Int_t i = 0; i < sizeof(mat)/sizeof(TGeoMatrix*); i++){ mat[i]->RegisterYourself(); } // i TGeoCompositeShape* cut_cs = new TGeoCompositeShape("cut_cs", "box - box*" "(chamX:comX1 + chamX:comX2 + chamX:comX3 + chamX:comX4 + " " chamY:comY1 + chamY:comY2 + chamY:comY3 + chamY:comY4 + " " chamZ:comZ1 + chamZ:comZ2 + chamZ:comZ3 + chamZ:comZ4)"); TGeoVolume* bgo = new TGeoVolume("BGO_block", cut_cs); bgo->SetMedium(Al); bgo->SetLineColor(kBlue); world->AddNode(bgo, 1, new TGeoTranslation(0, dy/2., 0)); TGeoVolume* apd = geom->MakeBox("SiO2_APD", Al, 10.*mm/2., 1*mm/2., 10*mm/2.); // not precise apd->SetLineColor(kRed); world->AddNode(apd, 1, new TGeoTranslation(0, -1*mm/2., 0.)); geom->CloseGeometry(); world->Draw("ogle"); // geom->Export(Form("Chamfer_%d_%d_%d_%d.gdml", X, Y, Z, CUT)); }