//____________________________________________________________________________ void get_target_mass ( string geometry_file, string topvolname = "", double length_unit=units::cm, double density_unit=units::g_cm3, Bool_t checkoverlaps = kFALSE) { PDGLibrary* pdglib = PDGLibrary::Instance(); // get message out of the way gFileName = geometry_file; // import geometry TGeoManager *tgeo = new TGeoManager("TGeo","TGeo"); tgeo->Import( geometry_file.c_str() ); // set top volume if( ! set_top_volume(topvolname) ) return; // draw gGeoManager->GetTopVolume()->Draw(); // method fails if there are volume overlaps, check it if the user wants to... (takes some time) if(checkoverlaps) { Double_t overlap_acc = 0.05; gGeoManager->CheckOverlaps( overlap_acc ); } get_mass(length_unit, density_unit); }
void OpNoviceGeom() { // Create root geometry corresponding to OpNovice example double fExpHall_x, fExpHall_y, fExpHall_z; double fTank_x, fTank_y, fTank_z; double fBubble_x, fBubble_y, fBubble_z; double a, z, density; int nelements; fExpHall_x = fExpHall_y = fExpHall_z = 10000.0; fTank_x = fTank_y = fTank_z = 5000.0; fBubble_x = fBubble_y = fBubble_z = 500.0; TGeoManager *geom = new TGeoManager("OpNoviceGeom", "GEANT4 OpNovice example"); // Air // TGeoElement *N = new TGeoElement("Nitrogen", "N", z=7 , a=14.01); TGeoElement *O = new TGeoElement("Oxygen" , "O", z=8 , a=16.00); TGeoMixture *air = new TGeoMixture("Air", 2, density=1.29E-3); air->AddElement(N, 0.7); air->AddElement(O, 0.3); TGeoMedium *medair = new TGeoMedium("Air", 1, air); // Water // TGeoElement *H = new TGeoElement("Hydrogen", "H", z=1 , a=1.01); TGeoMixture *water = new TGeoMixture("Water", 2, density=1.0); water->AddElement(H,2); water->AddElement(O,1); TGeoMedium *medwater = new TGeoMedium("Water", 2, water); // The experimental Hall // TGeoBBox *expHall_box = new TGeoBBox("World",fExpHall_x,fExpHall_y,fExpHall_z); TGeoVolume *expHall_log = new TGeoVolume("World", expHall_box, medair); expHall_log->SetLineColor(1); expHall_log->SetVisContainers(); geom->SetTopVolume(expHall_log); // The Water Tank // TGeoBBox *waterTank_box = new TGeoBBox("Tank",fTank_x,fTank_y,fTank_z); TGeoVolume *waterTank_log = new TGeoVolume("Tank", waterTank_box, medwater); waterTank_log->SetLineColor(kBlue); waterTank_log->SetTransparency(70); waterTank_log->SetVisContainers(); expHall_log->AddNode(waterTank_log, 0); // The Air Bubble // TGeoBBox *bubbleAir_box = new TGeoBBox("Bubble",fBubble_x,fBubble_y,fBubble_z); TGeoVolume *bubbleAir_log = new TGeoVolume("Bubble", bubbleAir_box, medair); bubbleAir_log->SetLineColor(kCyan); bubbleAir_log->SetTransparency(70); waterTank_log->AddNode(bubbleAir_log, 0, new TGeoTranslation(0,2500,0)); geom->CloseGeometry(); geom->SetTopVisible(true); geom->Export("OpNoviceGeom.root"); }
void LCDDImp::init() { if (!m_world.isValid()) { TGeoManager* mgr = m_manager; Box worldSolid("world_x", "world_y", "world_z"); printout(INFO,"LCDD"," *********** created World volume with size : %7.0f %7.0f %7.0f", worldSolid->GetDX(), worldSolid->GetDY(), worldSolid->GetDZ()); m_materialAir = material("Air"); m_materialVacuum = material("Vacuum"); Volume world_vol("world_volume", worldSolid, m_materialAir); m_world = DetElement(new WorldObject(*this,"world")); m_worldVol = world_vol; // Set the world volume to invisible. VisAttr worldVis("WorldVis"); worldVis.setAlpha(1.0); worldVis.setVisible(false); worldVis.setShowDaughters(true); worldVis.setColor(1.0, 1.0, 1.0); worldVis.setLineStyle(VisAttr::SOLID); worldVis.setDrawingStyle(VisAttr::WIREFRAME); //m_worldVol.setVisAttributes(worldVis); m_worldVol->SetVisibility(kFALSE); m_worldVol->SetVisDaughters(kTRUE); m_worldVol->SetVisContainers(kTRUE); add(worldVis); #if 0 Tube trackingSolid(0.,"tracking_region_radius","2*tracking_region_zmax",2*M_PI); Volume tracking("tracking_volume",trackingSolid, m_materialAir); m_trackers = TopDetElement("tracking"); m_trackingVol = tracking; PlacedVolume pv = m_worldVol.placeVolume(tracking); m_trackers.setPlacement(pv); m_world.add(m_trackers); #endif m_detectors.append(m_world); m_manager->SetTopVolume(m_worldVol.ptr()); m_world.setPlacement(PlacedVolume(mgr->GetTopNode())); } }
void LCDDImp::endDocument() { TGeoManager* mgr = m_manager; if (!mgr->IsClosed()) { #if 0 Region trackingRegion("TrackingRegion"); trackingRegion.setThreshold(1); trackingRegion.setStoreSecondaries(true); add(trackingRegion); m_trackingVol.setRegion(trackingRegion); // Set the tracking volume to invisible. VisAttr trackingVis("TrackingVis"); trackingVis.setVisible(false); m_trackingVol.setVisAttributes(trackingVis); add(trackingVis); #endif /// Since we allow now for anonymous shapes, /// we will rename them to use the name of the volume they are assigned to mgr->CloseGeometry(); ShapePatcher patcher(m_volManager, m_world); patcher.patchShapes(); mapDetectorTypes(); } }
void AddLadder() { SvxTGeo *geo = new SvxTGeo; geo->ReadParFile("parfiles/svxPISA.par"); // Make an empty 100x100x100 cm^3 space in the experiment hall. geo->MakeTopVolume(200/2, 200/2, 200/2); // Place VTX sensors in the volume. geo->AddSensors(); // Get handles for further manipulation TGeoManager *mgr = geo->GeoManager(); TGeoVolume *top = mgr->GetTopVolume(); // Add a ladder with new index 20 and the same geometry as B1L9. double xyz[3] = {0}; geo->GetSensorXYZ(1, 9, 0, xyz); geo->AddLadder(1, 20, xyz[0], xyz[1], 0., geo->GetLadderPhiTilt(1,9)); // Now rotate B1L20 by angular difference between B1L9 and B1L8. double dphi = geo->SensorPhiRad(1,9,0) - geo->SensorPhiRad(1,8,0); geo->RotateLadder(1, 20, 0., 0., dphi); // Done building model. // Close geometry to check for problems (overlapping boundaries) mgr->CloseGeometry(); // Press j,k to zoom; u,i to look up/down; h,l to look left, right. TCanvas *c = new TCanvas("c", "svx model", 1400, 1000); c->SetFillColor(kBlack); top->Draw(); geo->WriteParFile("parfiles/svxPISA.newladders.par"); return; }
void event3D() { gSystem->Load("libGeom"); TGeoManager *geom = new TGeoManager("simple1", "Simple geometry"); //--- define some materials TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0); TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); // //--- define some media TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum); TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl); //--- make the top container volume Double_t worldx = 110.; Double_t worldy = 50.; Double_t worldz = 5.; TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 100., 100., 100.); geom->SetTopVolume(top); gGeoManager->GetVolume("TOP")->InvisibleAll(); //Measurements (in cm) Double_t target_rad = 0.3; Double_t target_len = 48.58; Double_t RTPC_len = 41.; Double_t foil1_R1 = 2.; Double_t foil1_R2 = 2.0000018; Double_t foil2_R1 = 3.; Double_t foil2_R2 = 3.0000018; Double_t GEM1_R1 = 7.; Double_t GEM1_R2 = 7.0005; Double_t GEM2_R1 = 7.3; Double_t GEM2_R2 = 7.3005; Double_t GEM3_R1 = 7.6; Double_t GEM3_R2 = 7.6005; Double_t Z_offset = 0; Int_t trans_lvl = 70; TGeoTube *target = new TGeoTube("target_tube",0, target_rad, target_len/2); TGeoVolume *target_vol = new TGeoVolume("target_vol",target, Al); //(*) top->AddNode(target_vol,1,new TGeoTranslation(0,0, Z_offset)); gGeoManager->GetVolume("target_vol")->SetTransparency(0); TGeoTube *foil1 = new TGeoTube("foil1_tube", foil1_R1, foil1_R2, RTPC_len/2); TGeoVolume *foil1_vol = new TGeoVolume("foil1_vol", foil1, Al); //(*) top->AddNode(foil1_vol,1,new TGeoTranslation(0,0, Z_offset)); TGeoTube *foil2 = new TGeoTube("foil2_tube", foil2_R1, foil2_R2, RTPC_len/2); TGeoVolume *foil2_vol = new TGeoVolume("foil2_vol", foil2, Al); //(*) top->AddNode(foil2_vol,1,new TGeoTranslation(0,0, Z_offset)); TGeoTube *gem1 = new TGeoTube("gem1_tube", GEM1_R1, GEM1_R2, RTPC_len/2); TGeoVolume *gem1_vol = new TGeoVolume("gem1_vol", gem1, Al); //(*) gem1_vol->SetLineColor(kOrange); top->AddNode(gem1_vol,1,new TGeoTranslation(0,0, Z_offset)); TGeoTube *gem2 = new TGeoTube("gem2_tube", GEM2_R1, GEM2_R2, RTPC_len/2); TGeoVolume *gem2_vol = new TGeoVolume("gem2_vol", gem2, Al); //(*) gem2_vol->SetLineColor(kGreen); top->AddNode(gem2_vol,1,new TGeoTranslation(0,0, Z_offset)); TGeoTube *gem3 = new TGeoTube("gem3_tube", GEM3_R1, GEM3_R2, RTPC_len/2); TGeoVolume *gem3_vol = new TGeoVolume("gem3_vol", gem3, Al); //(*) top->AddNode(gem3_vol,1,new TGeoTranslation(0,0, Z_offset)); gem3_vol->SetLineColor(kRed); gGeoManager->GetVolume("gem3_vol")->SetTransparency(trans_lvl); //--- draw the ROOT box. // by default the picture will appear in the standard ROOT TPad. //if you have activated the following line in system.rootrc, //it will appear in the GL viewer //#Viewer3D.DefaultDrawOption: ogl geom->CloseGeometry(); geom->SetVisLevel(4); // top->SetVisibility(kFALSE); top->Draw("ogl"); gWorld = top; }
void lego() { // Drawing a figure, made of lego block, using ROOT geometry class. // Name: lego.C // Author: Soon Gi Kwon([email protected]), Dept. of Physics, Univ. of Seoul // Reviewed by Sunman Kim ([email protected]) // Supervisor: Prof. Inkyu Park ([email protected]) // // How to run: .x lego.C in ROOT terminal, then use OpenGL // // This macro was created for the evaluation of Computational Physics course in 2006. // We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team // TGeoManager *geom = new TGeoManager("geom","My first 3D geometry"); TGeoMaterial *vacuum=new TGeoMaterial("vacuum",0,0,0); TGeoMaterial *Fe=new TGeoMaterial("Fe",55.845,26,7.87); TGeoMedium *Air=new TGeoMedium("Vacuum",0,vacuum); TGeoMedium *Iron=new TGeoMedium("Iron",1,Fe); // create volume TGeoVolume *top=geom->MakeBox("top",Air,100,100,100); geom->SetTopVolume(top); geom->SetTopVisible(0); // If you want to see the boundary, please input the number, 1 instead of 0. // Like this, geom->SetTopVisible(1); //---------------------------------------------------------------------- TGeoVolume *ha1=geom->MakeSphere("ha1",Iron,0,10,80,90,0,360); ha1->SetLineColor(41); top->AddNodeOverlap(ha1,1,new TGeoCombiTrans(0,0,4,new TGeoRotation("ha1",0,0,0))); TGeoVolume *ha2=geom->MakeSphere("ha2",Iron,0,7,90,180,0,360); ha2->SetLineColor(41); top->AddNodeOverlap(ha2,1,new TGeoCombiTrans(0,0,4,new TGeoRotation("ha2",0,180,0))); TGeoVolume *ha3=geom->MakeSphere("ha3",Iron,0,7.3,80,90,0,360); ha3->SetLineColor(2); top->AddNodeOverlap(ha3,1,new TGeoCombiTrans(0,0,4.8,new TGeoRotation("ha3",0,0,0))); TGeoVolume *h1=geom->MakeTubs("h1",Iron,0,6,4.5,0,0); h1->SetLineColor(5); top->AddNodeOverlap(h1,1,new TGeoCombiTrans(0,0,0,new TGeoRotation("h1",0,0,0))); TGeoVolume *h2=geom->MakeSphere("h2",Iron,0,7.5,0,52.5,0,360); h2->SetLineColor(5); top->AddNodeOverlap(h2,1,new TGeoCombiTrans(0,0,0,new TGeoRotation("h2",0,0,0))); TGeoVolume *h3=geom->MakeSphere("h3",Iron,0,7.5,0,52.5,0,360); h3->SetLineColor(5); top->AddNodeOverlap(h3,1,new TGeoCombiTrans(0,0,0,new TGeoRotation("h3",180,180,0))); TGeoVolume *h4=geom->MakeTubs("h4",Iron,2.5,3.5,1.5,0,0); h4->SetLineColor(5); top->AddNodeOverlap(h4,1,new TGeoCombiTrans(0,0,7.5,new TGeoRotation("h4",0,0,0))); TGeoVolume *t1_1=geom->MakeTubs("t1_1",Iron,0,0.8,1,0,360); t1_1->SetLineColor(12); top->AddNodeOverlap(t1_1,1,new TGeoCombiTrans(-5,2,1.5,new TGeoRotation("t1_1",-90,90,0))); TGeoVolume *t2_1=geom->MakeTubs("t2_1",Iron,0,0.8,1,0,360); t2_1->SetLineColor(12); top->AddNodeOverlap(t2_1,1,new TGeoCombiTrans(-5,-2,1.5,new TGeoRotation("t2_1",-90,90,0))); TGeoVolume *fb1=geom->MakeTubs("fb1",Iron,2,2.3,1,100,260); fb1->SetLineColor(12); top->AddNodeOverlap(fb1,1,new TGeoCombiTrans(-5,0,-1,new TGeoRotation("fb1",90,90,90))); TGeoVolume *m1=geom->MakeBox("m1",Iron,7,8,4); m1->SetLineColor(2); top->AddNodeOverlap(m1,1,new TGeoCombiTrans(0,0,-17,new TGeoRotation("m1",90,90,0))); TGeoVolume *m2=geom->MakeTubs("m2",Iron,0,1,7,90,180); m2->SetLineColor(2); top->AddNodeOverlap(m2,1,new TGeoCombiTrans(-3,0,-9,new TGeoRotation("m2",0,90,0))); TGeoVolume *m3=geom->MakeTubs("m3",Iron,0,1,7,0,90); m3->SetLineColor(2); top->AddNodeOverlap(m3,1,new TGeoCombiTrans(3,0,-9,new TGeoRotation("m3",0,90,0))); TGeoVolume *m4=geom->MakeBox("m4",Iron,3,7,0.5); m4->SetLineColor(2); top->AddNodeOverlap(m4,1,new TGeoCombiTrans(0,0,-8.5,new TGeoRotation("m4",90,0,90))); TGeoVolume *m5=geom->MakeTubs("m5",Iron,0,1.5,1.2,0,0); m5->SetLineColor(5); top->AddNodeOverlap(m5,1,new TGeoCombiTrans(0,0,-7.8,new TGeoRotation("m5",0,0,0))); TGeoVolume *m6=geom->MakeTrd2("m6",Iron,4,4,0,2,8); m6->SetLineColor(2); top->AddNodeOverlap(m6,1,new TGeoCombiTrans(0,-7,-17,new TGeoRotation("m6",0,180,0))); TGeoVolume *m7=geom->MakeTrd2("m7",Iron,4,4,0,2,8); m7->SetLineColor(2); top->AddNodeOverlap(m7,1,new TGeoCombiTrans(0,7,-17,new TGeoRotation("m7",0,180,0))); TGeoVolume *md1=geom->MakeBox("md1",Iron,4,8.5,0.7); md1->SetLineColor(37); top->AddNodeOverlap(md1,1,new TGeoCombiTrans(0,0,-25.5,new TGeoRotation("md1",0,0,0))); TGeoVolume *md2=geom->MakeBox("md2",Iron,3,0.4,2); md2->SetLineColor(37); top->AddNodeOverlap(md2,1,new TGeoCombiTrans(0,0,-28,new TGeoRotation("md2",0,0,0))); TGeoVolume *d1=geom->MakeTrd2("d1",Iron,3,4,4,4,7); d1->SetLineColor(37); top->AddNodeOverlap(d1,1,new TGeoCombiTrans(-4.8,4.5,-35,new TGeoRotation("d1",90,45,-90))); TGeoVolume *d2=geom->MakeTrd2("d2",Iron,3,4,4,4,7); d2->SetLineColor(37); top->AddNodeOverlap(d2,1,new TGeoCombiTrans(0,-4.5,-37,new TGeoRotation("d2",0,0,0))); TGeoVolume *d3=geom->MakeTubs("d3",Iron,0,4,3.98,0,180); d3->SetLineColor(37); top->AddNodeOverlap(d3,1,new TGeoCombiTrans(0,4.5,-30.2,new TGeoRotation("d3",0,90,-45))); TGeoVolume *d4=geom->MakeTubs("d4",Iron,0,4,3.98,0,180); d4->SetLineColor(37); top->AddNodeOverlap(d4,1,new TGeoCombiTrans(0,-4.5,-30,new TGeoRotation("d4",0,90,0))); TGeoVolume *d5=geom->MakeBox("d5",Iron,4,4,1); d5->SetLineColor(37); top->AddNodeOverlap(d5,1,new TGeoCombiTrans(-10.2,4.5,-39,new TGeoRotation("d5",90,45,-90))); TGeoVolume *d6=geom->MakeBox("d6",Iron,4,4,1); d6->SetLineColor(37); top->AddNodeOverlap(d6,1,new TGeoCombiTrans(-1,-4.5,-43.4,new TGeoRotation("d6",0,0,0))); TGeoVolume *a1=geom->MakeTubs("a1",Iron,0,1.5,4,0,0); a1->SetLineColor(1); top->AddNodeOverlap(a1,1,new TGeoCombiTrans(0,10,-15.1,new TGeoRotation("a1",0,20,45))); TGeoVolume *a2=geom->MakeSphere("a2",Iron,0,1.48,0,180,0,200); a2->SetLineColor(1); top->AddNodeOverlap(a2,1,new TGeoCombiTrans(0,8.6,-11.5,new TGeoRotation("a2",120,80,20))); TGeoVolume *a3=geom->MakeTubs("a3",Iron,0,1.5,2.2,0,0); a3->SetLineColor(1); top->AddNodeOverlap(a3,1,new TGeoCombiTrans(0,11.3,-20.6,new TGeoRotation("a3",300,0,40))); TGeoVolume *a4=geom->MakeTubs("a4",Iron,0,1,1,0,0); a4->SetLineColor(5); top->AddNodeOverlap(a4,1,new TGeoCombiTrans(0,11.3,-23.8,new TGeoRotation("a4",75,0,30))); TGeoVolume *a5=geom->MakeTubs("a5",Iron,1.5,2.5,2,0,270); a5->SetLineColor(5); top->AddNodeOverlap(a5,1,new TGeoCombiTrans(0,11.3,-26.5,new TGeoRotation("a5",-90,90,00))); TGeoVolume *a1_1=geom->MakeTubs("a1_1",Iron,0,1.5,4,0,0); a1_1->SetLineColor(1); top->AddNodeOverlap(a1_1,1,new TGeoCombiTrans(0,-10,-15.1,new TGeoRotation("a1_1",0,-20,-45))); TGeoVolume *a2_1=geom->MakeSphere("a2_1",Iron,0,1.48,0,180,0,200); a2_1->SetLineColor(1); top->AddNodeOverlap(a2_1,1,new TGeoCombiTrans(0,-8.6,-11.5,new TGeoRotation("a2_1",120,80,-20))); TGeoVolume *a3_1=geom->MakeTubs("a3_1",Iron,0,1.5,2.2,0,0); a3_1->SetLineColor(1); top->AddNodeOverlap(a3_1,1,new TGeoCombiTrans(0,-11.3,-20.6,new TGeoRotation("a3_1",-300,0,-40))); TGeoVolume *a4_1=geom->MakeTubs("a4_1",Iron,0,1,1,0,0); a4_1->SetLineColor(5); top->AddNodeOverlap(a4_1,1,new TGeoCombiTrans(0,-11.3,-23.8,new TGeoRotation("a4_1",-75,0,-30))); a5=geom->MakeTubs("a5_1",Iron,1.5,2.5,2,0,270); a5->SetLineColor(5); top->AddNodeOverlap(a5,1,new TGeoCombiTrans(0,-11.3,-26.5,new TGeoRotation("a5",90,90,00))); //**********************************NO,2****************** TGeoVolume *ha_1=geom->MakeSphere("ha_1",Iron,0,10,80,90,0,360); ha_1->SetLineColor(6); top->AddNodeOverlap(ha_1,1,new TGeoCombiTrans(0,36,4,new TGeoRotation("ha_1",0,0,0))); TGeoVolume *ha_2=geom->MakeTubs("ha_2",Iron,0,6,5,0,0); ha_2->SetLineColor(6); top->AddNodeOverlap(ha_2,1,new TGeoCombiTrans(0,36,10,new TGeoRotation("ha_2",0,180,0))); TGeoVolume *ha_3=geom->MakeTubs("ha_3",Iron,0,1,12,0,0); ha_3->SetLineColor(28); top->AddNodeOverlap(ha_3,1,new TGeoCombiTrans(0,36,8,new TGeoRotation("ha_3",0,90,0))); TGeoVolume *ha_4=geom->MakeTubs("ha_4",Iron,0,1,3,0,0); ha_4->SetLineColor(28); top->AddNodeOverlap(ha_4,1,new TGeoCombiTrans(0,22,10,new TGeoRotation("ha_4",0,0,0))); TGeoVolume *ha_5=geom->MakeTubs("ha_5",Iron,0,1,3,0,0); ha_5->SetLineColor(28); top->AddNodeOverlap(ha_5,1,new TGeoCombiTrans(0,46,10,new TGeoRotation("ha_5",0,0,0))); TGeoVolume *ha_6=geom->MakeTubs("ha_6",Iron,0,1,3,0,0); ha_6->SetLineColor(28); top->AddNodeOverlap(ha_6,1,new TGeoCombiTrans(0,24,10,new TGeoRotation("ha_6",0,0,0))); TGeoVolume *ha_7=geom->MakeTubs("ha_7",Iron,0,1,3,0,0); ha_7->SetLineColor(28); top->AddNodeOverlap(ha_7,1,new TGeoCombiTrans(0,48,10,new TGeoRotation("ha_7",0,0,0))); TGeoVolume *ha_8=geom->MakeBox("ha_8",Iron,2,0.5,2); ha_8->SetLineColor(19); top->AddNodeOverlap(ha_8,1,new TGeoCombiTrans(-4.2,36,9,new TGeoRotation("ha_8",0,45,0))); TGeoVolume *ha_9=geom->MakeBox("ha_9",Iron,2,0.5,2); ha_9->SetLineColor(19); top->AddNodeOverlap(ha_9,1,new TGeoCombiTrans(-4.2,36,9,new TGeoRotation("ha_9",0,135,0))); TGeoVolume *h_1=geom->MakeTubs("h_1",Iron,0,6,4.5,0,0); h_1->SetLineColor(5); top->AddNodeOverlap(h_1,1,new TGeoCombiTrans(0,36,0,new TGeoRotation("h_1",0,0,0))); TGeoVolume *h_2=geom->MakeSphere("h_2",Iron,0,7.5,0,52.5,0,360); h_2->SetLineColor(5); top->AddNodeOverlap(h_2,1,new TGeoCombiTrans(0,36,0,new TGeoRotation("h_2",0,0,0))); TGeoVolume *h_3=geom->MakeSphere("h_3",Iron,0,7.5,0,52.5,0,360); h_3->SetLineColor(5); top->AddNodeOverlap(h_3,1,new TGeoCombiTrans(0,36,0,new TGeoRotation("h_3",180,180,0))); TGeoVolume *h_4=geom->MakeTubs("h_4",Iron,2.5,3.5,1.5,0,0); h_4->SetLineColor(5); top->AddNodeOverlap(h_4,1,new TGeoCombiTrans(0,36,7.5,new TGeoRotation("h_4",0,0,0))); TGeoVolume *fa1=geom->MakeTubs("fa1",Iron,0,0.5,1,0,360); fa1->SetLineColor(12); top->AddNodeOverlap(fa1,1,new TGeoCombiTrans(-5,38,1.5,new TGeoRotation("fa1",-90,90,0))); TGeoVolume *fa2=geom->MakeTubs("fa2",Iron,0,0.5,1,0,360); fa2->SetLineColor(12); top->AddNodeOverlap(fa2,1,new TGeoCombiTrans(-5,34,1.5,new TGeoRotation("fa2",-90,90,0))); TGeoVolume *fa1_1=geom->MakeTubs("fa1_1",Iron,1,1.2,1,0,360); fa1_1->SetLineColor(12); top->AddNodeOverlap(fa1_1,1,new TGeoCombiTrans(-5,38,1.5,new TGeoRotation("fa1_1",-90,90,0))); TGeoVolume *fa2_1=geom->MakeTubs("fa2_1",Iron,1,1.2,1,0,360); fa2_1->SetLineColor(12); top->AddNodeOverlap(fa2_1,1,new TGeoCombiTrans(-5,34,1.5,new TGeoRotation("fa2_1",-90,90,0))); TGeoVolume *fa3=geom->MakeTubs("fa3",Iron,2,2.3,1,90,270); fa3->SetLineColor(12); top->AddNodeOverlap(fa3,1,new TGeoCombiTrans(-5,36,-1,new TGeoRotation("fa3",90,90,90))); TGeoVolume *m_1=geom->MakeBox("m_1",Iron,7,8,4); m_1->SetLineColor(25); top->AddNodeOverlap(m_1,1,new TGeoCombiTrans(0,36,-17,new TGeoRotation("m_1",90,90,0))); TGeoVolume *m_2=geom->MakeTubs("m_2",Iron,0,1,7,90,180); m_2->SetLineColor(25); top->AddNodeOverlap(m_2,1,new TGeoCombiTrans(-3,36,-9,new TGeoRotation("m_2",0,90,0))); TGeoVolume *m_3=geom->MakeTubs("m_3",Iron,0,1,7,0,90); m_3->SetLineColor(25); top->AddNodeOverlap(m_3,1,new TGeoCombiTrans(3,36,-9,new TGeoRotation("m_3",0,90,0))); TGeoVolume *m_4=geom->MakeBox("m_4",Iron,3,7,0.5); m_4->SetLineColor(25); top->AddNodeOverlap(m_4,1,new TGeoCombiTrans(0,36,-8.5,new TGeoRotation("m_4",90,0,90))); TGeoVolume *m_5=geom->MakeTubs("m_5",Iron,0,1.5,1.2,0,0); m_5->SetLineColor(5); top->AddNodeOverlap(m_5,1,new TGeoCombiTrans(0,36,-7.8,new TGeoRotation("m_5",0,0,0))); TGeoVolume *m_6=geom->MakeTrd2("m_6",Iron,4,4,0,2,8); m_6->SetLineColor(25); top->AddNodeOverlap(m_6,1,new TGeoCombiTrans(0,29,-17,new TGeoRotation("m_6",0,180,0))); TGeoVolume *m_7=geom->MakeTrd2("m_7",Iron,4,4,0,2,8); m_7->SetLineColor(25); top->AddNodeOverlap(m_7,1,new TGeoCombiTrans(0,43,-17,new TGeoRotation("m_7",0,180,0))); TGeoVolume *md_1=geom->MakeBox("md_1",Iron,4,8.5,0.7); md_1->SetLineColor(48); top->AddNodeOverlap(md_1,1,new TGeoCombiTrans(0,36,-25.5,new TGeoRotation("md_1",0,0,0))); TGeoVolume *md_2=geom->MakeBox("md_2",Iron,3,0.4,2); md_2->SetLineColor(48); top->AddNodeOverlap(md_2,1,new TGeoCombiTrans(0,36,-28,new TGeoRotation("md_2",0,0,0))); TGeoVolume *d_1=geom->MakeTrd2("d_1",Iron,3,4,4,4,7); d_1->SetLineColor(48); top->AddNodeOverlap(d_1,1,new TGeoCombiTrans(0,40.5,-37.2,new TGeoRotation("d_1",0,0,0))); TGeoVolume *d_2=geom->MakeTrd2("d_2",Iron,3,4,4,4,7); d_2->SetLineColor(48); top->AddNodeOverlap(d_2,1,new TGeoCombiTrans(0,31.5,-37.2,new TGeoRotation("d_2",0,0,0))); TGeoVolume *d_3=geom->MakeTubs("d_3",Iron,0,4,3.98,0,180); d_3->SetLineColor(48); top->AddNodeOverlap(d_3,1,new TGeoCombiTrans(0,40.5,-30.2,new TGeoRotation("d_3",0,90,0))); TGeoVolume *d_4=geom->MakeTubs("d_4",Iron,0,4,3.98,0,180); d_4->SetLineColor(48); top->AddNodeOverlap(d_4,1,new TGeoCombiTrans(0,31.5,-30.2,new TGeoRotation("d_4",0,90,0))); TGeoVolume *d_5=geom->MakeBox("d_5",Iron,4,4,1); d_5->SetLineColor(48); top->AddNodeOverlap(d_5,1,new TGeoCombiTrans(-1,40.5,-43.7,new TGeoRotation("d_5",0,0,0))); TGeoVolume *d_6=geom->MakeBox("d_6",Iron,4,4,1); d_6->SetLineColor(48); top->AddNodeOverlap(d_6,1,new TGeoCombiTrans(-1,31.5,-43.7,new TGeoRotation("d_6",0,0,0))); TGeoVolume *a_1=geom->MakeTubs("a_1",Iron,0,1.5,4,0,0); a_1->SetLineColor(45); top->AddNodeOverlap(a_1,1,new TGeoCombiTrans(0,46,-15.1,new TGeoRotation("a_1",0,20,45))); TGeoVolume *a_2=geom->MakeSphere("a_2",Iron,0,1.48,0,180,0,200); a_2->SetLineColor(45); top->AddNodeOverlap(a_2,1,new TGeoCombiTrans(0,44.6,-11.5,new TGeoRotation("a_2",120,80,20))); TGeoVolume *a_3=geom->MakeTubs("a_3",Iron,0,1.5,2.2,0,0); a_3->SetLineColor(45); top->AddNodeOverlap(a_3,1,new TGeoCombiTrans(0,47.3,-20.6,new TGeoRotation("a_3",300,0,40))); TGeoVolume *a_4=geom->MakeTubs("a_4",Iron,0,1,1,0,0); a_4->SetLineColor(12); top->AddNodeOverlap(a_4,1,new TGeoCombiTrans(0,47.3,-23.8,new TGeoRotation("a_4",75,0,30))); TGeoVolume *a_5=geom->MakeTubs("a_5",Iron,1.5,2.5,2,0,270); a_5->SetLineColor(12); top->AddNodeOverlap(a_5,1,new TGeoCombiTrans(0,47.3,-26.5,new TGeoRotation("a_5",-90,90,0))); TGeoVolume *Aa1=geom->MakeTubs("Aa1",Iron,0,1.5,4,0,0); Aa1->SetLineColor(45); top->AddNodeOverlap(Aa1,1,new TGeoCombiTrans(0,26,-15.1,new TGeoRotation("Aa1",0,-20,-45))); TGeoVolume *Aa2=geom->MakeSphere("Aa2",Iron,0,1.48,0,180,0,200); Aa2->SetLineColor(45); top->AddNodeOverlap(Aa2,1,new TGeoCombiTrans(0,27.4,-11.5,new TGeoRotation("Aa2",120,80,-20))); TGeoVolume *Aa3=geom->MakeTubs("Aa3",Iron,0,1.5,2.2,0,0); Aa3->SetLineColor(45); top->AddNodeOverlap(Aa3,1,new TGeoCombiTrans(0,24.7,-20.6,new TGeoRotation("Aa3",-300,0,-40))); TGeoVolume *Aa4=geom->MakeTubs("Aa4",Iron,0,1,1,0,0); Aa4->SetLineColor(12); top->AddNodeOverlap(Aa4,1,new TGeoCombiTrans(0,24.7,-23.8,new TGeoRotation("Aa4",-75,0,-30))); TGeoVolume *Aa5=geom->MakeTubs("Aa5",Iron,1.5,2.5,2,0,270); Aa5->SetLineColor(12); top->AddNodeOverlap(Aa5,1,new TGeoCombiTrans(0,24.7,-26.5,new TGeoRotation("Aa5",90,90,00))); TGeoVolume *bag1=geom->MakeBox("bag1",Iron,10,4,6); bag1->SetLineColor(19); top->AddNodeOverlap(bag1,1,new TGeoCombiTrans(0,48,-36,new TGeoRotation("bag1",0,0,0))); TGeoVolume *bag2=geom->MakeTubs("bag2",Iron,3,4,1,180,360); bag2->SetLineColor(19); top->AddNodeOverlap(bag2,1,new TGeoCombiTrans(0,48,-30,new TGeoRotation("bag2",0,270,0))); TGeoVolume *well=geom->MakeBox("well",Iron,5,10,3); well->SetLineColor(18); top->AddNodeOverlap(well,1,new TGeoCombiTrans(-26.5,-17,-42,new TGeoRotation("well",0,0,0))); TGeoVolume *K5=geom->MakeTubs("K5",Iron,0,3,3,0,0); K5->SetLineColor(18); top->AddNodeOverlap(K5,1,new TGeoCombiTrans(-27,-12.5,-39,new TGeoRotation("K5",0,0,0))); TGeoVolume *K4=geom->MakeTubs("K4",Iron,0,3,3,0,0); K4->SetLineColor(18); top->AddNodeOverlap(K4,1,new TGeoCombiTrans(-27,-21.5,-39,new TGeoRotation("K4",0,0,0))); //==============Board========= char nB[100]; int Z=0,Y=0; TGeoVolume *bo1; while(Y<6){ while(Z<10){ sprintf(nB,"B%d_Y%d",Z,Y); bo1=geom->MakeTubs(nB,Iron,0,3,3,0,0); bo1->SetLineColor(8); top->AddNodeOverlap(bo1,1,new TGeoCombiTrans(-27+(Y*9),-21.5+(Z*9),-45,new TGeoRotation("bo1",0,0,0))); Z++; } Y++; Z=0; } TGeoVolume *bo2=geom->MakeBox("bo2",Iron,27,45,3); bo2->SetLineColor(8); top->AddNodeOverlap(bo2,1,new TGeoCombiTrans(-4.5,18,-48,new TGeoRotation("bo2",0,0,0))); top->SetVisibility(0); geom->CloseGeometry(); top->Draw("ogl"); }
int main(int argc, char * argv[]) { TApplication app("app", &argc, argv); plottingEngine.SetDefaultStyle(); const bool debug = true; // Load the field map. ComponentAnsys123* fm = new ComponentAnsys123(); const std::string efile = "ELIST.lis"; const std::string nfile = "NLIST.lis"; const std::string mfile = "MPLIST.lis"; const std::string sfile = "PRNSOL.lis"; fm->Initialise(efile, nfile, mfile, sfile, "mm"); fm->EnableMirrorPeriodicityX(); fm->EnableMirrorPeriodicityY(); fm->PrintRange(); // Dimensions of the GEM const double pitch = 0.014; const double kapton = 50.e-4; const double metal = 5.e-4; const double outdia = 70.e-4; const double middia = 50.e-4; const bool plotField = false; if (plotField) { ViewField* fieldView = new ViewField(); fieldView->SetComponent(fm); fieldView->SetPlane(0., -1., 0., 0., 0., 0.); fieldView->SetArea(-pitch / 2., -0.02, pitch / 2., 0.02); fieldView->SetVoltageRange(-160., 160.); TCanvas* cF = new TCanvas(); fieldView->SetCanvas(cF); fieldView->PlotContour(); } // Setup the gas. MediumMagboltz* gas = new MediumMagboltz(); gas->SetComposition("ar", 70., "co2", 30.); gas->SetTemperature(293.15); gas->SetPressure(760.); gas->EnableDebugging(); gas->Initialise(); gas->DisableDebugging(); // Set the Penning transfer efficiency. const double rPenning = 0.57; const double lambdaPenning = 0.; gas->EnablePenningTransfer(rPenning, lambdaPenning, "ar"); // Load the ion mobilities. gas->LoadIonMobility("IonMobility_Ar+_Ar.txt"); // Associate the gas with the corresponding field map material. const int nMaterials = fm->GetNumberOfMaterials(); for (int i = 0; i < nMaterials; ++i) { const double eps = fm->GetPermittivity(i); if (fabs(eps - 1.) < 1.e-3) fm->SetMedium(i, gas); } fm->PrintMaterials(); // Create the sensor. Sensor* sensor = new Sensor(); sensor->AddComponent(fm); sensor->SetArea(-5 * pitch, -5 * pitch, -0.03, 5 * pitch, 5 * pitch, 0.03); AvalancheMicroscopic* aval = new AvalancheMicroscopic(); aval->SetSensor(sensor); AvalancheMC* drift = new AvalancheMC(); drift->SetSensor(sensor); drift->SetDistanceSteps(2.e-4); const bool plotDrift = true; ViewDrift* driftView = new ViewDrift(); if (plotDrift) { driftView->SetArea(-2 * pitch, -2 * pitch, -0.02, 2 * pitch, 2 * pitch, 0.02); // Plot every 10 collisions (in microscopic tracking). aval->SetCollisionSteps(10); aval->EnablePlotting(driftView); drift->EnablePlotting(driftView); } // Histograms int nBinsGain = 100; double gmin = 0.; double gmax = 100.; TH1F* hElectrons = new TH1F("hElectrons", "Number of electrons", nBinsGain, gmin, gmax); TH1F* hIons = new TH1F("hIons", "Number of ions", nBinsGain, gmin, gmax); int nBinsChrg = 100; TH1F* hChrgE = new TH1F("hChrgE", "Electrons on plastic", nBinsChrg, -0.5e4 * kapton, 0.5e4 * kapton); TH1F* hChrgI = new TH1F("hChrgI", "Ions on plastic", nBinsChrg, -0.5e4 * kapton, 0.5e4 * kapton); double sumIonsTotal = 0.; double sumIonsDrift = 0.; double sumIonsPlastic = 0.; double sumElectronsTotal = 0.; double sumElectronsPlastic = 0.; double sumElectronsUpperMetal = 0.; double sumElectronsLowerMetal = 0.; double sumElectronsTransfer = 0.; double sumElectronsOther = 0.; const int nEvents = 10; for (int i = nEvents; i--;) { if (debug || i % 10 == 0) std::cout << i << "/" << nEvents << "\n"; // Randomize the initial position. const double smear = pitch / 2.; double x0 = -smear + RndmUniform() * smear; double y0 = -smear + RndmUniform() * smear; double z0 = 0.025; double t0 = 0.; double e0 = 0.1; aval->AvalancheElectron(x0, y0, z0, t0, e0, 0., 0., 0.); int ne = 0, ni = 0; aval->GetAvalancheSize(ne, ni); hElectrons->Fill(ne); hIons->Fill(ni); const int np = aval->GetNumberOfElectronEndpoints(); double xe1, ye1, ze1, te1, e1; double xe2, ye2, ze2, te2, e2; double xi1, yi1, zi1, ti1; double xi2, yi2, zi2, ti2; int status; for (int j = np; j--;) { aval->GetElectronEndpoint(j, xe1, ye1, ze1, te1, e1, xe2, ye2, ze2, te2, e2, status); sumElectronsTotal += 1.; if (ze2 > -kapton / 2. && ze2 < kapton / 2.) { hChrgE->Fill(ze2 * 1.e4); sumElectronsPlastic += 1.; } else if (ze2 >= kapton / 2. && ze2 <= kapton / 2. + metal) { sumElectronsUpperMetal += 1.; } else if (ze2 <= -kapton / 2. && ze2 >= -kapton / 2. - metal) { sumElectronsLowerMetal += 1.; } else if (ze2 < -kapton / 2. - metal) { sumElectronsTransfer += 1.; } else { sumElectronsOther += 1.; } drift->DriftIon(xe1, ye1, ze1, te1); drift->GetIonEndpoint(0, xi1, yi1, zi1, ti1, xi2, yi2, zi2, ti2, status); if (zi1 < 0.01) { sumIonsTotal += 1.; if (zi2 > 0.01) sumIonsDrift += 1.; } if (zi2 > -kapton / 2. && zi2 < kapton / 2.) { hChrgI->Fill(zi2 * 1.e4); sumIonsPlastic += 1.; } } } double fFeedback = 0.; if (sumIonsTotal > 0.) fFeedback = sumIonsDrift / sumIonsTotal; std::cout << "Fraction of ions drifting back: " << fFeedback << "\n"; const double neMean = hElectrons->GetMean(); std::cout << "Mean number of electrons: " << neMean << "\n"; const double niMean = hIons->GetMean(); std::cout << "Mean number of ions: " << niMean << "\n"; std::cout << "Mean number of electrons on plastic: " << sumElectronsPlastic / nEvents << "\n"; std::cout << "Mean number of ions on plastic: " << sumIonsPlastic / nEvents << "\n"; std::cout << "Electron endpoints:\n"; const double fUpperMetal = sumElectronsUpperMetal / sumElectronsTotal; const double fPlastic = sumElectronsPlastic / sumElectronsTotal; const double fLowerMetal = sumElectronsLowerMetal / sumElectronsTotal; const double fTransfer = sumElectronsTransfer / sumElectronsTotal; const double fOther = sumElectronsOther / sumElectronsTotal; std::cout << " upper metal: " << fUpperMetal * 100. << "%\n"; std::cout << " plastic: " << fPlastic * 100. << "%\n"; std::cout << " lower metal: " << fLowerMetal * 100. << "%\n"; std::cout << " transfer: " << fTransfer * 100. << "%\n"; std::cout << " other: " << fOther * 100. << "%\n"; TCanvas* cD = new TCanvas(); const bool plotGeo = true; if (plotGeo && plotDrift) { // Build the geometry in Root. TGeoManager* geoman = new TGeoManager("world", "geometry"); TGeoMaterial* matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0); TGeoMedium* medVacuum = new TGeoMedium("Vacuum", 1, matVacuum); TGeoMaterial* matKapton = new TGeoMaterial("Kapton", 12, 6, 1.42); TGeoMedium* medKapton = new TGeoMedium("Kapton", 2, matKapton); TGeoMaterial* matCopper = new TGeoMaterial("Copper", 63, 29, 8.94); TGeoMedium* medCopper = new TGeoMedium("Copper", 3, matCopper); TGeoVolume* volTop = geoman->MakeBox("TOP", medVacuum, pitch, pitch, 0.02); volTop->SetVisibility(0); TGeoBBox* shpKapton = new TGeoBBox("K", pitch / 2., pitch / 2., kapton / 2.); TGeoPcon* shpHole = new TGeoPcon("H", 0., 360., 3); shpHole->DefineSection(0, -kapton / 2., 0., outdia / 2.); shpHole->DefineSection(1, 0., 0., middia / 2.); shpHole->DefineSection(2, kapton / 2., 0., outdia / 2.); TGeoCompositeShape* shpGem = new TGeoCompositeShape("G", "K - H"); TGeoVolume* volKapton = new TGeoVolume("Kapton", shpGem, medKapton); volKapton->SetLineColor(kGreen); volKapton->SetTransparency(50); TGeoBBox* shpMetal = new TGeoBBox("M", pitch / 2., pitch / 2., metal / 2.); TGeoTube* shpTube = new TGeoTube("T", 0., outdia / 2., metal / 2.); TGeoCompositeShape* shpElectrode = new TGeoCompositeShape("E", "M - T"); TGeoVolume* volElectrode = new TGeoVolume("Electrode", shpElectrode, medCopper); volElectrode->SetLineColor(kBlue); volElectrode->SetTransparency(50); TGeoVolumeAssembly* volGem = new TGeoVolumeAssembly("Gem"); const double shift = 0.5 * (metal + kapton); volGem->AddNode(volKapton, 1); volGem->AddNode(volElectrode, 2, new TGeoTranslation(0., 0., shift)); volGem->AddNode(volElectrode, 3, new TGeoTranslation(0., 0., -shift)); volTop->AddNode(volGem, 1); volTop->AddNode(volGem, 2, new TGeoTranslation(-pitch, 0., 0.)); volTop->AddNode(volGem, 3, new TGeoTranslation(+pitch, 0., 0.)); volTop->AddNode(volGem, 4, new TGeoTranslation(-pitch / 2., sqrt(3) * pitch / 2., 0.)); volTop->AddNode(volGem, 5, new TGeoTranslation(+pitch / 2., sqrt(3) * pitch / 2., 0.)); volTop->AddNode(volGem, 6, new TGeoTranslation(-pitch / 2., -sqrt(3) * pitch / 2., 0.)); volTop->AddNode(volGem, 7, new TGeoTranslation(+pitch / 2., -sqrt(3) * pitch / 2., 0.)); geoman->SetVerboseLevel(0); geoman->SetTopVolume(volTop); geoman->CloseGeometry(); geoman->CheckOverlaps(0.1e-4); geoman->SetNmeshPoints(100000); cD->cd(); geoman->GetTopVolume()->Draw("ogl"); } if (plotDrift) { driftView->SetCanvas(cD); driftView->Plot(); } const bool plotHistogram = true; if (plotHistogram) { TCanvas* cH = new TCanvas("cH", "Histograms", 800, 700); cH->Divide(2, 2); cH->cd(1); hElectrons->Draw(); cH->cd(2); hIons->Draw(); cH->cd(3); hChrgE->Draw(); cH->cd(4); hChrgI->Draw(); } app.Run(kTRUE); }
int visualizationTracker(float minZ, float maxZ, float minX, float maxX, float theta, float phi){ gSystem->Load("libGeom"); //++++++++++++++++++++ Set up stuff ++++++++++++++++++++// TGeoManager *geom = new TGeoManager("simple1", "Simple geometry"); //--- define some materials and media TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0); TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum); //--- make the top container volume TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 500., 500., 500.); //TGeoVolume *toptop = geom->MakeBox("TOPTOP", Vacuum, 1000., 1000., 500.); geom->SetTopVolume(top); int count = 0; for (int i = 0; i < _nEntries; ++i){ _inTree->GetEntry(i); if (isRightSubDet()&&(_zVal >= minZ && _zVal < maxZ)&&(_xVal >= minX && _xVal < maxX)/*&&(_rVal <= 12)&&(_rVal >=8)*/){ char modName[192]; sprintf(modName, "testModule%i", i); TGeoVolume* testMod = geom->MakeBox( modName, Vacuum, 90., 90., 40. ); getModule( geom, top, testMod ); count++; } } if(count == 0) return -1; getBeamVisuals(geom, top, minZ, maxZ); //--- close the geometry geom->CloseGeometry(); // -- draw geom->SetVisLevel(4); TCanvas * c = new TCanvas(); c->SetTheta(theta); c->SetPhi(phi); top->Draw(); //--- putting words on canvas... bool with0T = true; //can play with these numbers double widthofeach = 0.07; double textsize = 0.05; double xmax = 2*widthofeach; if (with0T) xmax = widthofeach; TPaveText* pt = new TPaveText(0,0,xmax,1,"brNDC"); pt->SetBorderSize(0); pt->SetFillStyle(0); pt->SetTextAlign(22); pt->SetTextFont(42); pt->SetTextSize(0.1); TText *text = pt->AddText(0,0,TString("#font[42]{"+_line1+"}")); text->SetTextSize(textsize); text->SetTextAngle(90); pt->Draw(); TPaveText *pt2 = new TPaveText(widthofeach, 0, 2*widthofeach, 1, "brNDC"); pt2->SetBorderSize(0); pt2->SetFillStyle(0); pt2->SetTextAlign(22); pt2->SetTextFont(42); pt2->SetTextSize(0.1); TText *text2 = pt2->AddText(0,0,TString("#font[42]{"+_line2+"}")); text2->SetTextSize(textsize); text2->SetTextAngle(90); pt2->Draw(); TPaveText *pt3 = new TPaveText(2*widthofeach, 0, 3*widthofeach, 1, "brNDC"); pt3->SetBorderSize(0); pt3->SetFillStyle(0); pt3->SetTextAlign(22); pt3->SetTextFont(42); pt3->SetTextSize(0.1); TText *text3 = pt3->AddText(0,0,TString("#font[42]{"+_line3+"}")); text3->SetTextSize(textsize); text3->SetTextAngle(90); pt3->Draw(); string str = string("i") + to_string(_i) + string(".gif"); c->SaveAs(TString(str)); gSystem->Exec(TString("mv "+str+" images/"+str)); delete c; cout << "Created image " << str << endl; return 0; }
void rootgeom() { //Definition of a simple geometry (the 4 ROOT characters) //Author: Andrei Gheata // gStyle->SetCanvasPreferGL(true); gSystem->Load("libGeom"); TGeoManager *geom = new TGeoManager("simple1", "Simple geometry"); //--- define some materials TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0); TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); // //--- define some media TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum); TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl); //--- define the transformations TGeoTranslation *tr1 = new TGeoTranslation(20., 0, 0.); TGeoTranslation *tr2 = new TGeoTranslation(10., 0., 0.); TGeoTranslation *tr3 = new TGeoTranslation(10., 20., 0.); TGeoTranslation *tr4 = new TGeoTranslation(5., 10., 0.); TGeoTranslation *tr5 = new TGeoTranslation(20., 0., 0.); TGeoTranslation *tr6 = new TGeoTranslation(-5., 0., 0.); TGeoTranslation *tr7 = new TGeoTranslation(7.5, 7.5, 0.); TGeoRotation *rot1 = new TGeoRotation("rot1", 90., 0., 90., 270., 0., 0.); TGeoCombiTrans *combi1 = new TGeoCombiTrans(7.5, -7.5, 0., rot1); TGeoTranslation *tr8 = new TGeoTranslation(7.5, -5., 0.); TGeoTranslation *tr9 = new TGeoTranslation(7.5, 20., 0.); TGeoTranslation *tr10 = new TGeoTranslation(85., 0., 0.); TGeoTranslation *tr11 = new TGeoTranslation(35., 0., 0.); TGeoTranslation *tr12 = new TGeoTranslation(-15., 0., 0.); TGeoTranslation *tr13 = new TGeoTranslation(-65., 0., 0.); TGeoTranslation *tr14 = new TGeoTranslation(0,0,-100); TGeoCombiTrans *combi2 = new TGeoCombiTrans(0,0,100, new TGeoRotation("rot2",90,180,90,90,180,0)); TGeoCombiTrans *combi3 = new TGeoCombiTrans(100,0,0, new TGeoRotation("rot3",90,270,0,0,90,180)); TGeoCombiTrans *combi4 = new TGeoCombiTrans(-100,0,0, new TGeoRotation("rot4",90,90,0,0,90,0)); TGeoCombiTrans *combi5 = new TGeoCombiTrans(0,100,0, new TGeoRotation("rot5",0,0,90,180,90,270)); TGeoCombiTrans *combi6 = new TGeoCombiTrans(0,-100,0, new TGeoRotation("rot6",180,0,90,180,90,90)); //--- make the top container volume Double_t worldx = 110.; Double_t worldy = 50.; Double_t worldz = 5.; TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 270., 270., 120.); geom->SetTopVolume(top); TGeoVolume *replica = geom->MakeBox("REPLICA", Vacuum,120,120,120); replica->SetVisibility(kFALSE); TGeoVolume *rootbox = geom->MakeBox("ROOT", Vacuum, 110., 50., 5.); rootbox->SetVisibility(kFALSE); //--- make letter 'R' TGeoVolume *R = geom->MakeBox("R", Vacuum, 25., 25., 5.); R->SetVisibility(kFALSE); TGeoVolume *bar1 = geom->MakeBox("bar1", Al, 5., 25, 5.); bar1->SetLineColor(kRed); R->AddNode(bar1, 1, tr1); TGeoVolume *bar2 = geom->MakeBox("bar2", Al, 5., 5., 5.); bar2->SetLineColor(kRed); R->AddNode(bar2, 1, tr2); R->AddNode(bar2, 2, tr3); TGeoVolume *tub1 = geom->MakeTubs("tub1", Al, 5., 15., 5., 90., 270.); tub1->SetLineColor(kRed); R->AddNode(tub1, 1, tr4); TGeoVolume *bar3 = geom->MakeArb8("bar3", Al, 5.); bar3->SetLineColor(kRed); TGeoArb8 *arb = (TGeoArb8*)bar3->GetShape(); arb->SetVertex(0, 15., -5.); arb->SetVertex(1, 0., -25.); arb->SetVertex(2, -10., -25.); arb->SetVertex(3, 5., -5.); arb->SetVertex(4, 15., -5.); arb->SetVertex(5, 0., -25.); arb->SetVertex(6, -10., -25.); arb->SetVertex(7, 5., -5.); R->AddNode(bar3, 1, gGeoIdentity); //--- make letter 'O' TGeoVolume *O = geom->MakeBox("O", Vacuum, 25., 25., 5.); O->SetVisibility(kFALSE); TGeoVolume *bar4 = geom->MakeBox("bar4", Al, 5., 7.5, 5.); bar4->SetLineColor(kYellow); O->AddNode(bar4, 1, tr5); O->AddNode(bar4, 2, tr6); TGeoVolume *tub2 = geom->MakeTubs("tub1", Al, 7.5, 17.5, 5., 0., 180.); tub2->SetLineColor(kYellow); O->AddNode(tub2, 1, tr7); O->AddNode(tub2, 2, combi1); //--- make letter 'T' TGeoVolume *T = geom->MakeBox("T", Vacuum, 25., 25., 5.); T->SetVisibility(kFALSE); TGeoVolume *bar5 = geom->MakeBox("bar5", Al, 5., 20., 5.); bar5->SetLineColor(kBlue); T->AddNode(bar5, 1, tr8); TGeoVolume *bar6 = geom->MakeBox("bar6", Al, 17.5, 5., 5.); bar6->SetLineColor(kBlue); T->AddNode(bar6, 1, tr9); rootbox->AddNode(R, 1, tr10); rootbox->AddNode(O, 1, tr11); rootbox->AddNode(O, 2, tr12); rootbox->AddNode(T, 1, tr13); replica->AddNode(rootbox, 1, tr14); replica->AddNode(rootbox, 2, combi2); replica->AddNode(rootbox, 3, combi3); replica->AddNode(rootbox, 4, combi4); replica->AddNode(rootbox, 5, combi5); replica->AddNode(rootbox, 6, combi6); top->AddNode(replica, 1, new TGeoTranslation(-150, -150, 0)); top->AddNode(replica, 2, new TGeoTranslation(150, -150, 0)); top->AddNode(replica, 3, new TGeoTranslation(150, 150, 0)); top->AddNode(replica, 4, new TGeoTranslation(-150, 150, 0)); //--- close the geometry geom->CloseGeometry(); //--- draw the ROOT box. // by default the picture will appear in the standard ROOT TPad. //if you have activated the following line in system.rootrc, //it will appear in the GL viewer //#Viewer3D.DefaultDrawOption: ogl geom->SetVisLevel(4); top->Draw("ogle"); }
void show ( char* inpDir = "", // MuDST directory char* inpFile = "show.lis", // MuDST file(s); char* outFile = "show.root",// output tree file Int_t nFiles = 50, // # of MuDST file(s) Int_t nEvents = 100 // # of events ) // remeber to adjust dbase timestamp below !!!! // what a ... design { //gErrorIgnoreLevel=1999; // load root/root4star libraries gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C"); loadSharedLibraries(); // load more libraries :) gSystem->Load("libmysqlclient"); gSystem->Load("libGeom"); gSystem->Load("StDbLib"); gSystem->Load("StDbBroker"); gSystem->Load("St_db_Maker"); // load even more libraries (EEMC stuff) gSystem->Load("StEEmcUtil"); gSystem->Load("StEEmcDbMaker"); gSystem->Load("StEEmcPoolTTM"); // create the chain chain = new StChain("StChain"); // now = new TDatime; // for display TCanvas *c1 = new TCanvas("eemc","eemc",10,10,1000,1000); TPaveLabel *tlab = new TPaveLabel(-0.99,+0.99,+0.99,+0.90, "EEMC TOWERS & TPC TRACKS Piotr A Zolnierczuk (IU)"); eventInfo = new TPaveText (-0.99,-0.99,+0.0 ,-0.75); dateInfo = new TPaveLabel(+0.60,-0.99,+0.99,-0.95,now->AsString()); TGeoManager *gm = new TGeoManager("eemc", "eemc tower display"); TGeoVolume *top = gm->MakeBox("star",0, 200., 200., 350.); TGeoVolume *smbox = gm->MakeBox("smbox1",0, 2., 2., 2.); smbox->SetLineColor(kRed); // eemc eemc = new EEmcTTDisplay(); eemc->SetMagneticField(0.5); // in Tesla eemc->SetShowExtrapolatedTracks(true); TGeoTranslation *etra = new TGeoTranslation(0.0,0.0,0.5*(eemc->getZ1()+eemc->getZ2())); top->AddNode(smbox, 1,NULL); top->AddNode(eemc(),1,etra); gm->SetTopVolume(top); gm->CloseGeometry(); gm->SetVisLevel(4); gm->SetVisOption(0); c1->SetTheta(90); c1->SetPhi(0); top->Draw(); tlab->Draw(); gPad->Update(); // now we add Makers to the chain... some of that is black magic :) muDstMk = new StMuDstMaker(0,0,inpDir,inpFile,"",nFiles); // muDST main chain StMuDbReader *db = StMuDbReader::instance(); // need the database St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb"); // need another db(?) new StEEmcDbMaker("eemcDb"); // need EEMC database // now comment in/out/change the below if you want it your way dbMk->setTimeStampDay(20040331); // format: yyyymmdd // finally after so many lines we arrive at the good stuff ttm = new EEmcTTMMaker ("TTM",muDstMk,eemcDbMk); ttm->Summary(cout); // StMuDebug::setLevel(0); chain->Init(); StEEmcDb *eemcDb = (StEEmcDb*)chain->GetDataSet("StEEmcDb"); eemcDb->setSectors(1,12); // request EEMC DB for sectors you need (dafault:1-12) eemcDb->setPreferedFlavor("onlped","eemcPMTped"); // request alternative flavor chain->ls(3); //--------------------------------------------------- next(); }
int main(int argc, char * argv[]) { // generate benchmark cases TransformationMatrix const * identity = new TransformationMatrix(0,0,0,0,0,0); double L = 10.; double Lz = 10.; const double Sqrt2 = sqrt(2.); TGeoManager * geom = new TGeoManager("simple1", "ToyDetector"); TGeoMaterial * matVacuum = new TGeoMaterial("Vacuum",0,0,0); TGeoMedium * vac = new TGeoMedium("Vacuum",1,matVacuum); TGeoVolume * world = geom->MakeBox("world", vac, L, L, Lz ); geom->SetTopVolume( world ); TGeoVolume * boxlevel2 = geom->MakeBox( "boxlevel2", vac, Sqrt2*L/2./2., Sqrt2*L/2./2.,Lz); TGeoVolume * boxlevel3 = geom->MakeBox( "boxlevel3", vac, L/2./2.,L/2./2.,Lz); TGeoVolume * boxlevel1 = geom->MakeBox( "boxlevel1", vac, L/2.,L/2., Lz); boxlevel2->AddNode( boxlevel3, 1, new TGeoRotation("mat1",0,0,-45)); boxlevel1->AddNode( boxlevel2, 1, new TGeoRotation("mat2",0,0,45)); world->AddNode( boxlevel1, 1, new TGeoTranslation("trans1",-L/2., 0,0 ) ); world->AddNode( boxlevel1, 2, new TGeoTranslation("trans2",L/2., 0,0 ) ); geom->CloseGeometry(); delete world->GetVoxels(); world->SetVoxelFinder(0); // perform basic tests TGeoNavigator * nav = geom->GetCurrentNavigator(); // new TGeoNavigator(geom); StopWatch timer; timer.Start(); int stepsdone=0; for(int n=0;n<1000;n++) { for(int i=0;i<100000;i++) // testing the NavigationAndStepInterface { int localstepsdone=0; double distancetravelled=0.; Vector3D p; PhysicalVolume::samplePoint( p, L, L, Lz, 1. ); //std::cerr << p << std::endl; //setup point in world Vector3D d(1,0,0); TGeoNode const * vol; nav->SetCurrentPoint( p.x, p.y, p.z ); nav->SetCurrentDirection( d.x, d.y, d.z); vol=nav->FindNode(p.x,p.y,p.z); while( vol!=NULL ) { localstepsdone++; // do one step ( this will internally adjust the current point and so on ) vol = nav->FindNextBoundaryAndStep(Utils::kInfinity); distancetravelled+=nav->GetStep(); //double const * p = nav->GetCurrentPoint(); //double const * pl = nav->GetLastPoint(); //double const * cd = nav->GetCurrentDirection(); //std::cerr << " proposed step: " << nav->GetStep(); //std::cerr << " current point " << p[0] << " " << p[1] << " " << p[2] << std::endl; //std::cerr << " last point " << pl[0] << " " << pl[1] << " " << pl[2] << std::endl; //std::cerr << " current dir " << cd[0] << " " << cd[1] << " " << cd[2] << std::endl; } // std::cerr << localstepsdone << " " << distancetravelled << std::endl; stepsdone+=localstepsdone; } } timer.Stop(); std::cout << " time for 100000 particles " << timer.getDeltaSecs( ) << std::endl; std::cout << " average steps done " << stepsdone / 100000. << std::endl; std::cout << " time per step " << timer.getDeltaSecs()/stepsdone << std::endl; }
void geom_Al() { // Set the range //---------------------------------------------------------------------------// // 0.314 Mev Ranges (g/cm2): /* 0.0025 0.0094 0.0181 0.0255 0.0336 0.0403 0.0477 0.0566 0.0654 0.0721 * 0.0810 0.0993 */ // 0.521 Mev Ranges (g/cm2): /* 0.0025 0.0094 0.0180 0.0255 0.0335 0.0405 0.0475 0.0566 0.0653 0.0721 * 0.0807 0.0992 0.1111 0.1259 0.1439 0.1596 0.1825 0.2125 */ // 1.033 Mev Ranges (g/cm2): /* 0.0025 0.0094 0.0180 0.0255 0.0336 0.0402 0.0476 0.0562 0.0654 0.0723 * 0.0808 0.0990 0.1110 0.1257 0.1440 0.1593 0.1821 0.2122 0.2225 0.2452 * 0.2521 0.2908 0.3141 0.3533 0.4188 0.4814 */ // Range of dose depth calculation in cm double range = 0.0993; //---------------------------------------------------------------------------// // Set up manager of the geometry world gSystem->Load( "libGeom" ); TGeoManager* geom = new TGeoManager( "geom_Al", "Geometry for electron energy deposition in Al test problems."); //---------------------------------------------------------------------------// // Material and Mixture Definitions //---------------------------------------------------------------------------// // Al ( density given as 2.7 not 2.69890 g/cm^3 ) density = 2.7; TGeoMaterial* mat_1 = new TGeoMaterial( "mat_1", 26.9815385, 13, -density ); // Void material TGeoMaterial* void_mat = new TGeoMaterial( "void", 0, 0, 0 ); // Graveyard (terminal) TGeoMaterial* graveyard_mat = new TGeoMaterial( "graveyard", 0, 0, 0 ); //---------------------------------------------------------------------------// // Medium Definitions //---------------------------------------------------------------------------// // Al TGeoMedium* med_1 = new TGeoMedium( "med_1", 1, mat_1 ); // Void TGeoMedium* void_med = new TGeoMedium( "void_med", 2, void_mat ); // Graveyard TGeoMedium* graveyard_med = new TGeoMedium( "graveyard", 3, graveyard_mat ); //---------------------------------------------------------------------------// // Volume Definitions //---------------------------------------------------------------------------// //---------------------------- // Create the calorimeter foil //---------------------------- // Thickness of the calorimeter foil (given in g/cm^2) double calorimeter_thickness = 5.050E-03/density; // Half the height double half_cal_thickness = calorimeter_thickness/2.0; // Height (given - largest dimension) double height = 8.255; // Half side length double half_height = height/2.0; TGeoVolume* calorimeter_foil = geom->MakeBox( "Calorimeter_Foil", med_1, half_height, half_height, half_cal_thickness ); calorimeter_foil->SetUniqueID( 1 ); calorimeter_foil->SetLineColor( 2 ); // //---------------------- // // Create the front foil // //---------------------- // Calculate the range = 0.4814; double range_cm = range/density; // Calculate the thickness of the front foil double front_thickness = range_cm - half_cal_thickness; TGeoVolume* front_foil; if (front_thickness > 0.0 ) { // Height (given - largest dimension) height = 8.89; // Half side length half_height = height/2.0; front_foil = geom->MakeBox( "Front_Foil", med_1, half_height, half_height, front_thickness/2.0 ); front_foil->SetUniqueID( 2 ); front_foil->SetLineColor( 3 ); } //-------------------------------------------------------- // Create the infinite plate (D = 7.62 cm, h = "infinite") //-------------------------------------------------------- double plate_radius = 3.81; double plate_half_length = 0.5; TGeoVolume* infinite_plate = geom->MakeTube( "Infinite_Plate", med_1, 0.0, plate_radius, plate_half_length ); infinite_plate->SetUniqueID( 3 ); infinite_plate->SetLineColor( 4 ); //-------------------------------------------------------- // Create the vacuum (R = "infinite" cm, h = "infinite") //-------------------------------------------------------- // Set a radius of 7 cm ( 167 x the CSDA range = 0.4814; double vacuum_radius = 7.0; // Set a vacuum length large enough to cover the whole geometry double vacuum_half_length = 2.0*plate_half_length + 5.0 + calorimeter_thickness + 0.5; // Add region TGeoVolume* void_region = geom->MakeTube( "Void", void_med, 0.0, vacuum_radius, vacuum_half_length ); void_region->SetUniqueID( 4 ); void_region->SetLineColor( 6 ); void_region->SetVisibility( true ); //-------------------------------------------------------- // Create the graveyard (encompasses the entire geometry) //-------------------------------------------------------- // Add region TGeoVolume* graveyard_region = geom->MakeTube( "Graveyard", graveyard_med, 0.0, vacuum_radius + 0.5, vacuum_half_length + 0.5 ); graveyard_region->SetUniqueID( 5 ); graveyard_region->SetLineColor( 7 ); graveyard_region->SetVisContainers( true ); //---------------------------------------------------------------------------// // Heirarchy (Volume) Definitions //---------------------------------------------------------------------------// // Set graveyard as the top volume geom->SetTopVolume(graveyard_region); //------------------------ // Add vacuum to graveyard //------------------------ // Get z position of the vacuum double vacuum_z = vacuum_half_length; // Add region graveyard_region->AddNode(void_region, 0 ); //----------------------------------- // Add the calorimeter foil to vacuum //----------------------------------- // Set the front of the calorimeter at a z of 5 cm double calorimeter_z = 5.0 + half_cal_thickness; // Add the front calorimeter foil to vacuum void_region->AddNode( calorimeter_foil, 1, new TGeoTranslation(0,0,calorimeter_z) ); //----------------------------------- // Add the front foil to vacuum //----------------------------------- if( front_thickness > 0.0 ) { // Set the front foil 0.1 cm in front of the calorimeter double front_z = 4.9 - front_thickness/2.0; // Add the region void_region->AddNode( front_foil, 2, new TGeoTranslation(0,0,front_z) ); } //----------------------------------- // Add the infinite plate to vacuum //----------------------------------- // Set the infinite plate 0.1 cm behind the calorimeter double plate_z = 5.1 + calorimeter_thickness + plate_half_length; // Add region void_region->AddNode( infinite_plate, 3, new TGeoTranslation(0,0,plate_z) ); //---------------------------------------------------------------------------// // Export and Drawing Capabilities //---------------------------------------------------------------------------// // Close the geometry geom->CloseGeometry(); // // Draw the geometry // geom->SetTopVisible(); // graveyard_region->Draw(); // TView *view = gPad->GetView(); // view->ShowAxis(); // Export the geometry geom->Export( "geom_Al.root" ); // Finished exit(0); }
void LCDDImp::dump() const { TGeoManager* mgr = m_manager; mgr->SetVisLevel(4); mgr->SetVisOption(1); m_worldVol->Draw("ogl"); }
int main() { Vectors3DSOA points, dirs, intermediatepoints, intermediatedirs; StructOfCoord rpoints, rintermediatepoints, rdirs, rintermediatedirs; int np=1024; int NREPS = 1000; points.alloc(np); dirs.alloc(np); intermediatepoints.alloc(np); intermediatedirs.alloc(np); rpoints.alloc(np); rdirs.alloc(np); rintermediatepoints.alloc(np); rintermediatedirs.alloc(np); double *distances = (double *) _mm_malloc(np*sizeof(double), ALIGNMENT_BOUNDARY); double *distancesROOTSCALAR = (double *) _mm_malloc(np*sizeof(double), ALIGNMENT_BOUNDARY); double *distancesUSOLIDSCALAR = (double *) _mm_malloc(np*sizeof(double), ALIGNMENT_BOUNDARY); double *distances2 = (double *) _mm_malloc(np*sizeof(double), ALIGNMENT_BOUNDARY); double *steps = (double *) _mm_malloc(np*sizeof(double), ALIGNMENT_BOUNDARY); for(auto i=0;i<np;++i) steps[i]=1E30; std::vector<Vector3D> conventionalpoints(np); std::vector<Vector3D> conventionaldirs(np); Vector3D * conventionalpoints2 = (Vector3D *) new Vector3D[np]; Vector3D * conventionaldirs2 = (Vector3D *) new Vector3D[np]; StopWatch timer; // generate benchmark cases TransformationMatrix const * identity = new TransformationMatrix(0,0,0,0,0,0); // the world volume is a tube double worldrmax = 100.; double worldrmin = 0.; double worldz = 200.; PhysicalVolume * world = GeoManager::MakePlacedTube( new TubeParameters<>(worldrmin, worldrmax, worldz, 0, 2.*M_PI), identity ); PhysicalVolume * beampipe = GeoManager::MakePlacedTube( new TubeParameters<>(worldrmax/40., worldrmax/20., worldz), identity ); world->AddDaughter( beampipe ); BoxParameters * plateparams = new BoxParameters(30,5.,2.*worldz/3.); PhysicalVolume * plate1 = GeoManager::MakePlacedBox( plateparams, new TransformationMatrix(50, 0, 0, 35, 0, 10) ); PhysicalVolume * plate2 = GeoManager::MakePlacedBox( plateparams, new TransformationMatrix(-50, 0, 0, 35, 0, 10) ); PhysicalVolume * plate3 = GeoManager::MakePlacedBox( plateparams, new TransformationMatrix(0, 50, 0, -35, 0, 10) ); PhysicalVolume * plate4 = GeoManager::MakePlacedBox( plateparams, new TransformationMatrix(0, -50, 0, -35, 0, 10) ); world->AddDaughter( plate1 ); world->AddDaughter( plate2 ); world->AddDaughter( plate3 ); world->AddDaughter( plate4 ); // TransformationMatrix * tm = new TransformationMatrix(TransCases[t][0], TransCases[t][1], TransCases[t][2], // EulerAngles[r][0], EulerAngles[r][1], EulerAngles[r][2]); // these dispatch to specialized matrices // TransformationMatrix const * sm = TransformationMatrix::createSpecializedMatrix( TransCases[t][0], TransCases[t][1], TransCases[t][2], // EulerAngles[r][0], EulerAngles[r][1], EulerAngles[r][2] ); double rmin = 10.; double rmax = 20.; double dz = 30.; double phis =0.; //double dphi = 2.*M_PI; double dphi = M_PI; TubeParameters<double> const *tp = gTestShapeContainer.GetTubeParams(0); PhysicalVolume * daughter = GeoManager::MakePlacedTube( tp, tm ); //std::cerr << daughter->UnplacedContains( Vector3D(15, 1, 15) ) << std::endl; //std::cerr << daughter->UnplacedContains( Vector3D(-15, 1, 15) ) << std::endl; // testing UnplacedContains // for(auto k=0;k<100;k++) // { // Vector3D x( cos(k/(100.)*2*M_PI), sin(k/(100.)*2*M_PI), 0 ); // std::cerr << "## " << k/100.*2*M_PI << " " << daughter->UnplacedContains( x ) << std::endl; // } world->AddDaughter(daughter); world->fillWithRandomPoints(points,np); world->fillWithBiasedDirections(points, dirs, np, 8/10.); daughter->fillWithRandomPoints(points,np); points.toStructureOfVector3D( conventionalpoints ); dirs.toStructureOfVector3D( conventionaldirs ); points.toStructureOfVector3D( conventionalpoints2 ); dirs.toStructureOfVector3D( conventionaldirs2 ); //// time performance for this placement ( we should probably include some random physical steps ) timer.Start(); for(int reps=0;reps< NREPS ;reps++) { daughter->DistanceToOut(points,dirs,steps,distances); } timer.Stop(); double t0 = timer.getDeltaSecs(); // // // std::cerr << tm->GetTranslationIdType() << " " << tm->getNumberOfZeroEntries() << " " << timer.getDeltaSecs() << std::endl; // // timer.Start(); // for(int reps=0;reps<NREPS;reps++) // { // daughter->DistanceToInIL(points,dirs,steps,distances); // } // timer.Stop(); // double til = timer.getDeltaSecs(); // // timer.Start(); // for(int reps=0;reps<NREPS;reps++) // { // daughter->DistanceToInIL( conventionalpoints2, conventionaldirs2, steps, distances, np ); // } // timer.Stop(); // double til2 = timer.getDeltaSecs(); // // // compare with case that uses external unspecialized transformation //0, 20, 30, M_PI PhysicalVolume * unplaceddaughter = GeoManager::MakePlacedTube( new TubeParameters<>( rmin, rmax ,dz, phis, dphi ), identity ); timer.Start(); for(int reps=0;reps<NREPS;reps++) { if(! tm->isIdentity() ) { tm->MasterToLocal(points, intermediatepoints ); tm->MasterToLocalVec( dirs, intermediatedirs ); unplaceddaughter->DistanceToIn( intermediatepoints, intermediatedirs, steps, distances2); } else { unplaceddaughter->DistanceToIn( points, dirs, steps, distances2); } } timer.Stop(); double t1 = timer.getDeltaSecs(); // // // // compare with external specialized transformation ( sm ) // sm->print(); timer.Start(); for(int reps=0;reps<NREPS;reps++) { sm->MasterToLocal(points, intermediatepoints ); sm->MasterToLocalVec( dirs, intermediatedirs ); unplaceddaughter->DistanceToIn( intermediatepoints, intermediatedirs, steps, distances2); } timer.Stop(); double t2 = timer.getDeltaSecs(); // std::cerr << "VECTOR " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t0 << " " << t1 << " " << t2 << " " << til << " " << til2 << std::endl; // cmpresults( distances, distances2, np ); // // // // now we do the scalar interface: first of all placed version // timer.Start(); // for(int reps=0;reps<NREPS;reps++) // { // for(auto j=0;j<np;++j) // { // distances[j]=daughter->DistanceToIn( conventionalpoints[j], conventionaldirs[j], steps[j]); // } // } // timer.Stop(); // double t3 = timer.getDeltaSecs(); // // // now unplaced version // timer.Start(); // for(int reps=0;reps<NREPS;reps++) // { // for(auto j=0;j<np;++j) // { // Vector3D localp, localdir; // tm->MasterToLocal(conventionalpoints[j], localp); // tm->MasterToLocalVec(conventionaldirs[j], localdir); // distances2[j]=unplaceddaughter->DistanceToIn( localp, localdir, steps[j]); // } // } // timer.Stop(); // double t4 = timer.getDeltaSecs(); // // // now unplaced version // timer.Start(); // for(int reps=0;reps<NREPS;reps++) // { // for(auto j=0;j<np;++j) // { // Vector3D localp, localdir; // sm->MasterToLocal(conventionalpoints[j], localp); // sm->MasterToLocalVec(conventionaldirs[j], localdir); // distances2[j]=unplaceddaughter->DistanceToIn( localp, localdir, steps[j]); // } // } // timer.Stop(); // double t5 = timer.getDeltaSecs(); // // // now unplaced version but inlined matrices // timer.Start(); // for(int reps=0;reps<NREPS;reps++) // { // for(auto j=0;j<np;++j) // { // Vector3D localp, localdir; // // this inlines I think // tm->MasterToLocal<-1,-1>(conventionalpoints[j], localp); // tm->MasterToLocalVec<-1>(conventionaldirs[j], localdir); // distances2[j]=unplaceddaughter->DistanceToIn( localp, localdir, 1E30); // } // } // timer.Stop(); // double t6 = timer.getDeltaSecs(); // // std::cerr << "SCALAR " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t3 << " " << t4 << " " << t5 << " " << t6 << std::endl; // TGeoMatrix * rootmatrix= new TGeoCombiTrans(TransCases[t][0], TransCases[t][1], TransCases[t][2], new TGeoRotation("rot1",EulerAngles[r][0], EulerAngles[r][1], EulerAngles[r][2])); TGeoManager *geom = new TGeoManager("",""); TGeoVolume * vol = geom->MakeTubs("atube",0, tp->GetRmin(), tp->GetRmax(), tp->GetDZ(),tp->GetSPhi() *360/(2.*M_PI), tp->GetSPhi()+360*tp->GetDPhi()/(2.*M_PI)); TGeoShape * roottube=vol->GetShape(); // now the scalar version from ROOTGeantV // timer.Start(); // for(int reps=0;reps<NREPS;reps++) // { // for(auto j=0;j<np;++j) // { // Vector3D localp, localdir; // rootmatrix->MasterToLocal( &conventionalpoints[j].x, &localp.x ); // rootmatrix->MasterToLocalVect( &conventionaldirs[j].x, &localdir.x ); // distancesROOTSCALAR[j]=roottube->DistFromOutside( &localp.x, &localdir.x, 3, Utils::kInfinity, 0); // } // } // timer.Stop(); // double t7 = timer.getDeltaSecs(); // now the scalar version from ROOTGeantV timer.Start(); for(int reps=0;reps<NREPS;reps++) { for(auto j=0;j<np;++j) { Vector3D localp, localdir; rootmatrix->MasterToLocal( &conventionalpoints[j].x, &localp.x ); rootmatrix->MasterToLocalVect( &conventionaldirs[j].x, &localdir.x ); distancesROOTSCALAR[j]=roottube->DistFromInside( &conventionalpoints[j].x, &conventionaldirs[j].x, 3, Utils::kInfinity, 0); } } timer.Stop(); double t7 = timer.getDeltaSecs(); // now the VECTOR version from ROOT // now the scalar version from ROOTGeantV timer.Start(); for(int reps=0;reps<NREPS;reps++) { rootmatrix->MasterToLocalCombined_v( reinterpret_cast<StructOfCoord const &>(points), reinterpret_cast<StructOfCoord &>(intermediatepoints), reinterpret_cast<StructOfCoord const &>(dirs), reinterpret_cast<StructOfCoord &>(intermediatedirs), np ); roottube->DistFromOutsideSOA_v( reinterpret_cast<StructOfCoord const &>(intermediatepoints), reinterpret_cast<StructOfCoord const &>(intermediatedirs), 3, steps, 0, distances2, np); } timer.Stop(); double t8 = timer.getDeltaSecs(); cmpresults( distancesROOTSCALAR, distances, np, daughter, conventionalpoints, conventionaldirs ); // now we compare with loop over USolids version (scalar; trying to inline matrices as done in Geant4 typically) VUSolid * utub = new UTubs("utubs1",rmin,rmax,dz, phis, dphi); timer.Start(); for(int reps=0;reps<NREPS;reps++) { for(auto j=0;j<np;++j) { Vector3D localp, localdir; // this inlines I think tm->MasterToLocal<1,-1>( conventionalpoints[j], localp ); tm->MasterToLocalVec<-1>( conventionaldirs[j], localdir ); distancesUSOLIDSCALAR[j]=utub->DistanceToIn( reinterpret_cast<UVector3 const & > (localp), reinterpret_cast<UVector3 &> ( localdir ), 1e30); } } timer.Stop(); double t9 = timer.getDeltaSecs(); std::cerr << "new vec (placed)" << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t0 << std::endl; std::cerr << "new vec (old matrix)" << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t1 << std::endl; std::cerr << "new vec (unplaced)" << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t2 << std::endl; std::cerr << "RSCAL " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t7 << std::endl; std::cerr << "RVEC " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t8 << std::endl; std::cerr << "USOLIDS SCAL " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t9 << std::endl; delete tm; delete sm; }
void assembly() { //--- Definition of a simple geometry gSystem->Load("libGeom"); TGeoManager *geom = new TGeoManager("Assemblies", "Geometry using assemblies"); Int_t i; //--- define some materials TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0); TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); // //--- define some media TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum); TGeoMedium *Al = new TGeoMedium("Aluminium",2, matAl); //--- make the top container volume TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 1000., 1000., 100.); geom->SetTopVolume(top); // Make the elementary assembly of the whole structure TGeoVolume *tplate = new TGeoVolumeAssembly("TOOTHPLATE"); Int_t ntooth = 5; Double_t xplate = 25; Double_t yplate = 50; Double_t xtooth = 10; Double_t ytooth = 0.5*yplate/ntooth; Double_t dshift = 2.*xplate + xtooth; Double_t xt,yt; TGeoVolume *plate = geom->MakeBox("PLATE", Al, xplate,yplate,1); plate->SetLineColor(kBlue); TGeoVolume *tooth = geom->MakeBox("TOOTH", Al, xtooth,ytooth,1); tooth->SetLineColor(kBlue); tplate->AddNode(plate,1); for (i=0; i<ntooth; i++) { xt = xplate+xtooth; yt = -yplate + (4*i+1)*ytooth; tplate->AddNode(tooth, i+1, new TGeoTranslation(xt,yt,0)); xt = -xplate-xtooth; yt = -yplate + (4*i+3)*ytooth; tplate->AddNode(tooth, ntooth+i+1, new TGeoTranslation(xt,yt,0)); } TGeoRotation *rot1 = new TGeoRotation(); rot1->RotateX(90); TGeoRotation *rot; // Make a hexagone cell out of 6 tooth plates. These can zip together // without generating overlaps (they are self-contained) TGeoVolume *cell = new TGeoVolumeAssembly("CELL"); for (i=0; i<6; i++) { Double_t phi = 60.*i; Double_t phirad = phi*TMath::DegToRad(); Double_t xp = dshift*TMath::Sin(phirad); Double_t yp = -dshift*TMath::Cos(phirad); rot = new TGeoRotation(*rot1); rot->RotateZ(phi); cell->AddNode(tplate,i+1,new TGeoCombiTrans(xp,yp,0,rot)); } // Make a row as an assembly of cells, then combine rows in a honeycomb // structure. This again works without any need to define rows as // "overlapping" TGeoVolume *row = new TGeoVolumeAssembly("ROW"); Int_t ncells = 5; for (i=0; i<ncells; i++) { Double_t ycell = (2*i+1)*(dshift+10); row->AddNode(cell, ncells+i+1, new TGeoTranslation(0,ycell,0)); row->AddNode(cell,ncells-i,new TGeoTranslation(0,-ycell,0)); } Double_t dxrow = 3.*(dshift+10.)*TMath::Tan(30.*TMath::DegToRad()); Double_t dyrow = dshift+10.; Int_t nrows = 5; for (i=0; i<nrows; i++) { Double_t xrow = 0.5*(2*i+1)*dxrow; Double_t yrow = 0.5*dyrow; if ((i%2)==0) yrow = -yrow; top->AddNode(row, nrows+i+1, new TGeoTranslation(xrow,yrow,0)); top->AddNode(row, nrows-i, new TGeoTranslation(-xrow,-yrow,0)); } //--- close the geometry geom->CloseGeometry(); geom->SetVisLevel(4); geom->SetVisOption(0); top->Draw(); }
void snoopy() { TGeoManager *geom = new TGeoManager("snoopy", "Snoopy Detector"); // define some materials TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0); TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7); TGeoMaterial *matFe = new TGeoMaterial("Fe", 55.84, 26, 7.9); // define some media TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum); TGeoMedium *Al = new TGeoMedium("Al", 2, matAl); TGeoMedium *Fe = new TGeoMedium("Fe", 3, matFe); // create top volume TGeoVolume *top = geom->MakeBox("top", Vacuum, 600, 600, 2500); geom->SetTopVolume(top); geom->SetTopVisible(0); // first part of vacuum chamber up to veto station TGeoVolume *tub1 = geom->MakeTube("tub1", Al, 245, 250, 50); tub1->SetLineColor(18); // silver/gray top->AddNode(tub1, 1, new TGeoTranslation(0, 0, -2450)); // veto station TGeoBBox *detbox1 = new TGeoBBox("detbox1", 250, 250, 10); TGeoBBox *detbox2 = new TGeoBBox("detbox2", 245, 245, 10); TGeoCompositeShape *detcomp1 = new TGeoCompositeShape("detcomp1", "detbox1-detbox2"); TGeoVolume *det1 = new TGeoVolume("det1", detcomp1,Vacuum); det1->SetLineColor(kRed); top->AddNode(det1, 1, new TGeoTranslation(0, 0, -2390)); TGeoRotation r0; r0.SetAngles(15,0,0); TGeoTranslation t0(0, 0, -2370); TGeoCombiTrans c0(t0, r0); TGeoHMatrix *h0 = new TGeoHMatrix(c0); top->AddNode(det1, 11, h0); // second part of vacuum chamber up to first tracking station TGeoVolume *tub2 = geom->MakeTube("tub2", Al, 245, 250, 3880/2); // 1890 tub2->SetLineColor(18); top->AddNode(tub2, 1, new TGeoTranslation(0, 0, -440)); // tracking station 1 top->AddNode(det1, 2, new TGeoTranslation(0, 0, 1510)); TGeoRotation r1; r1.SetAngles(15,0,0); TGeoTranslation t1(0, 0, 1530); TGeoCombiTrans c1(t1, r1); TGeoHMatrix *h1 = new TGeoHMatrix(c1); top->AddNode(det1, 3, h1); // third part of vacuum chamber up to second tracking station TGeoVolume *tub3 = geom->MakeTube("tub3", Al, 245, 250, 80); tub3->SetLineColor(18); top->AddNode(tub3, 1, new TGeoTranslation(0, 0, 1620)); // tracking station 2 top->AddNode(det1, 4, new TGeoTranslation(0, 0, 1710)); TGeoRotation r2; r2.SetAngles(15,0,0); TGeoTranslation t2(0, 0, 1730); TGeoCombiTrans c2(t2, r2); TGeoHMatrix *h2 = new TGeoHMatrix(c2); top->AddNode(det1, 5, h2); // fourth part of vacuum chamber up to third tracking station and being covered by magnet TGeoVolume *tub4 = geom->MakeTube("tub4", Al, 245, 250, 200); tub4->SetLineColor(18); top->AddNode(tub4, 1, new TGeoTranslation(0, 0, 1940)); // magnet yoke TGeoBBox *magyoke1 = new TGeoBBox("magyoke1", 350, 350, 125); TGeoBBox *magyoke2 = new TGeoBBox("magyoke2", 250, 250, 126); TGeoCompositeShape *magyokec = new TGeoCompositeShape("magyokec", "magyoke1-magyoke2"); TGeoVolume *magyoke = new TGeoVolume("magyoke", magyokec, Fe); magyoke->SetLineColor(kBlue); //magyoke->SetTransparency(50); top->AddNode(magyoke, 1, new TGeoTranslation(0, 0, 1940)); // magnet TGeoTubeSeg *magnet1a = new TGeoTubeSeg("magnet1a", 250, 300, 35, 45, 135); TGeoTubeSeg *magnet1b = new TGeoTubeSeg("magnet1b", 250, 300, 35, 45, 135); TGeoTubeSeg *magnet1c = new TGeoTubeSeg("magnet1c", 250, 270, 125, 45, 60); TGeoTubeSeg *magnet1d = new TGeoTubeSeg("magnet1d", 250, 270, 125, 120, 135); // magnet composite shape matrices TGeoTranslation *m1 = new TGeoTranslation(0, 0, 160); m1->SetName("m1"); m1->RegisterYourself(); TGeoTranslation *m2 = new TGeoTranslation(0, 0, -160); m2->SetName("m2"); m2->RegisterYourself(); TGeoCompositeShape *magcomp1 = new TGeoCompositeShape("magcomp1", "magnet1a:m1+magnet1b:m2+magnet1c+magnet1d"); TGeoVolume *magnet1 = new TGeoVolume("magnet1", magcomp1, Fe); magnet1->SetLineColor(kYellow); top->AddNode(magnet1, 1, new TGeoTranslation(0, 0, 1940)); TGeoRotation m3; m3.SetAngles(180, 0, 0); TGeoTranslation m4(0, 0, 1940); TGeoCombiTrans m5(m4, m3); TGeoHMatrix *m6 = new TGeoHMatrix(m5); top->AddNode(magnet1, 2, m6); // tracking station 3 top->AddNode(det1, 6, new TGeoTranslation(0, 0, 2150)); TGeoRotation r3; r3.SetAngles(15,0,0); TGeoTranslation t3(0, 0, 2170); TGeoCombiTrans c3(t3, r3); TGeoHMatrix *h3 = new TGeoHMatrix(c3); top->AddNode(det1, 7, h3); // fifth part of vacuum chamber up to fourth tracking station TGeoVolume *tub5 = geom->MakeTube("tub5", Al, 245, 250, 90); tub5->SetLineColor(18); top->AddNode(tub5, 1, new TGeoTranslation(0, 0, 2270)); // tracking station 4 top->AddNode(det1, 8, new TGeoTranslation(0, 0, 2370)); TGeoRotation r4; r4.SetAngles(15,0,0); TGeoTranslation t4(0, 0, 2390); TGeoCombiTrans c4(t4, r4); TGeoHMatrix *h4 = new TGeoHMatrix(c4); top->AddNode(det1, 9, h4); // ecal TGeoVolume *ecal = geom->MakeBox("ecal", Al, 250, 250, 40); ecal->SetLineColor(6); // purple top->AddNode(ecal, 1, new TGeoTranslation(0, 0, 2440)); // muon filter TGeoVolume *muonfilter = geom->MakeBox("muonfilter", Al, 250, 250, 20); muonfilter->SetLineColor(kGreen); top->AddNode(muonfilter, 1, new TGeoTranslation(0, 0, 2500)); // sixth part of vacuum chamber up to muon detector TGeoVolume *tub6 = geom->MakeTube("tub6", Al, 245, 250, 20); tub6->SetLineColor(18); top->AddNode(tub6, 1, new TGeoTranslation(0, 0, 2540)); // muon detector top->AddNode(det1, 10, new TGeoTranslation(0, 0, 2570)); TGeoRotation r5; r5.SetAngles(15,0,0); TGeoTranslation t5(0, 0, 2590); TGeoCombiTrans c5(t5, r5); TGeoHMatrix *h5 = new TGeoHMatrix(c5); top->AddNode(det1, 12, h5); geom->CloseGeometry(); top->Draw("ogl"); geom->Export("snoopy.gdml"); }
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(); }
void robot() { // Drawing a famous Korean robot, TaekwonV, using ROOT geometry class. // Name: robot.C // Author: Jin Hui Hwang, Dept. of Physics, Univ. of Seoul // Reviewed by Sunman Kim ([email protected]) // Supervisor: Prof. Inkyu Park ([email protected]) // // How to run: .x robot.C in ROOT terminal, then use OpenGL // // This macro was created for the evaluation of Computational Physics course in 2006. // We thank to Prof. Inkyu Park for his special lecture on ROOT and to all of ROOT team // TGeoManager *Robot = new TGeoManager("Robot", "This is Taegwon V"); TGeoMaterial *vacuum = new TGeoMaterial("vacuum", 0, 0, 0); TGeoMaterial *Fe = new TGeoMaterial("Fe", 55.845, 26, 7.87); TGeoMedium *Air = new TGeoMedium("Vacuum", 0, vacuum); TGeoMedium *Iron = new TGeoMedium("Iron", 1, Fe); // create volume TGeoVolume *top = Robot->MakeBox("top", Air, 1000, 1000, 1000); Robot->SetTopVolume(top); Robot->SetTopVisible(0); // If you want to see the boundary, please input the number, 1 instead of 0. // Like this, geom->SetTopVisible(1); // head TGeoVolume *Band = Robot->MakeEltu("Band", Iron, 20, 20, 2.5); Band->SetLineColor(12); Band->SetFillColor(12); TGeoVolume *Band_b = Robot->MakeSphere("Band_b", Iron, 0, 2, 0, 180, 180, 360); Band_b->SetLineColor(2); Band_b->SetFillColor(2); TGeoVolume *Head = Robot->MakeSphere("Head", Iron, 0, 19, 0, 180, 180, 360); Head->SetLineColor(17); Head->SetFillColor(17); TGeoVolume *Horn = Robot->MakeSphere("Horn", Iron, 0, 10, 60, 180, 240, 300); // drawing head top->AddNodeOverlap(Band, 1, new TGeoTranslation(0, 0, 90)); float Phi = 3.14; int N = 10; for (int i = 0; i <= N; i++) { top->AddNodeOverlap(Band_b, 1, new TGeoCombiTrans(sin(2 * Phi / N * i) * 19, -cos(2 * Phi / N * i) * 19, 90, new TGeoRotation("R1", -90 + (360 / N * i), -90, 90))); } top->AddNodeOverlap(Head, 1, new TGeoCombiTrans(0, 0, 87.5, new TGeoRotation("R2", 0, -90, 0))); char name[50]; float pcs = 30; for (int i = 1; i < pcs; i++) { sprintf(name, "Horn%d", i); Horn = Robot->MakeSphere(name, Iron, 10 - 10 / pcs * i, 10, 180 - (120 / pcs) * i, 180 - ((120 / pcs) * (i - 1)), 240, 300); Horn->SetLineColor(2); Horn->SetFillColor(2); top->AddNodeOverlap(Horn, 1, new TGeoCombiTrans(0, 8, 102, new TGeoRotation("R2", 0, 140, 0))); top->AddNodeOverlap(Horn, 1, new TGeoCombiTrans(0, -8, 102, new TGeoRotation("R2", 180, 140, 0))); } // face TGeoVolume *Migan = Robot->MakeGtra("Migan", Iron, 3, 0, 0, 0, 3, 2, 11, 0, 3, 3, 11, 0); Migan->SetLineColor(17); Migan->SetFillColor(17); TGeoVolume *Ko = Robot->MakeGtra("Ko", Iron, 7, 0, 0, 0, 3, 1, 5, 0, 3, 2, 5, 0); Ko->SetLineColor(17); Ko->SetFillColor(17); TGeoVolume *Ko_m = Robot->MakeBox("Ko_m", Iron, 2, 8, 4); Ko_m->SetLineColor(17); Ko_m->SetFillColor(17); TGeoVolume *Bol_1 = Robot->MakeBox("Bol_1", Iron, 7, 5.5, 7); Bol_1->SetLineColor(17); Bol_1->SetFillColor(17); TGeoVolume *Bol_2 = Robot->MakeGtra("Bol_2", Iron, 1, 0, 0, 0, 7, 0, 9, 0, 7, 0, 9, 0); Bol_2->SetLineColor(17); Bol_2->SetFillColor(17); TGeoVolume *Noon = Robot->MakeBox("Noon", Iron, 1, 10, 5); Noon->SetLineColor(12); Noon->SetFillColor(12); TGeoVolume *Tuck = Robot->MakeBox("Tuck", Iron, 2, 10, 5.5); Tuck->SetLineColor(2); Tuck->SetFillColor(2); TGeoVolume *Tuck_1 = Robot->MakeBox("Tuck_1", Iron, 2, 9, 1); Tuck_1->SetLineColor(2); Tuck_1->SetFillColor(2); TGeoVolume *Tuck_2 = Robot->MakeBox("Tuck_2", Iron, 3, 1, 14); Tuck_2->SetLineColor(2); Tuck_2->SetFillColor(2); TGeoVolume *Tuck_j = Robot->MakeSphere("Tuck_j", Iron, 0, 3.5, 0, 180, 0, 360); Tuck_j->SetLineColor(5); Tuck_j->SetFillColor(5); TGeoVolume *Ear = Robot->MakeCons("Ear", Iron, 1, 0, 3, 0, 3, 0, 360); Ear->SetLineColor(5); Ear->SetFillColor(5); TGeoVolume *Ear_2 = Robot->MakeCone("Ear_2", Iron, 5, 0, 0, 0, 3); Ear_2->SetLineColor(5); Ear_2->SetFillColor(5); // drawing face top->AddNodeOverlap(Migan, 1, new TGeoCombiTrans(-15, 0, 88, new TGeoRotation("R2", -90, 40, 0))); top->AddNodeOverlap(Ko, 1, new TGeoCombiTrans(-15, 0, 76.5, new TGeoRotation("R2", -90, -20, 0))); top->AddNodeOverlap(Ko_m, 1, new TGeoTranslation(-9, 0, 68)); top->AddNodeOverlap(Bol_1, 1, new TGeoCombiTrans(-7, 2, 76, new TGeoRotation("R2", -30, -10, 0))); top->AddNodeOverlap(Bol_1, 1, new TGeoCombiTrans(-7, -2, 76, new TGeoRotation("R2", 30, 10, 0))); top->AddNodeOverlap(Bol_2, 1, new TGeoCombiTrans(-6.5, -10.5, 76, new TGeoRotation("R2", -15, -90, -30))); top->AddNodeOverlap(Bol_2, 1, new TGeoCombiTrans(-4, -12.5, 82.5, new TGeoRotation("R2", -20, -90, -95))); top->AddNodeOverlap(Bol_2, 1, new TGeoCombiTrans(-7.5, 10.5, 76, new TGeoRotation("R2", 20, -90, -30))); top->AddNodeOverlap(Bol_2, 1, new TGeoCombiTrans(-4, 12.5, 82.5, new TGeoRotation("R2", 20, -90, -95))); top->AddNodeOverlap(Noon, 1, new TGeoCombiTrans(-5, -7, 86, new TGeoRotation("R2", 60, 0, 0))); top->AddNodeOverlap(Noon, 1, new TGeoCombiTrans(-5, 7, 86, new TGeoRotation("R2", -60, 0, 0))); top->AddNodeOverlap(Tuck, 1, new TGeoTranslation(-12, 0, 62.5)); for (int i = 0; i < 10; i++) { top->AddNodeOverlap(Tuck_1, 1, new TGeoCombiTrans(-4.2, 11, 61 + i, new TGeoRotation("R2", 90, -20, 20))); top->AddNodeOverlap(Tuck_1, 1, new TGeoCombiTrans(-4.2, -11, 61 + i, new TGeoRotation("R2", 90, -20, -20))); } top->AddNodeOverlap(Tuck_2, 1, new TGeoTranslation(2, -15.1, 76)); top->AddNodeOverlap(Tuck_2, 1, new TGeoTranslation(2, 15.1, 76)); top->AddNodeOverlap(Tuck_j, 1, new TGeoTranslation(-13, 0, 62.5)); top->AddNodeOverlap(Ear, 1, new TGeoCombiTrans(2, -16.5, 80, new TGeoRotation("R2", 0, -90, 0))); top->AddNodeOverlap(Ear, 1, new TGeoCombiTrans(2, 16.5, 80, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Ear_2, 1, new TGeoCombiTrans(2, -20, 80, new TGeoRotation("R2", 0, -90, 0))); top->AddNodeOverlap(Ear_2, 1, new TGeoCombiTrans(2, 20, 80, new TGeoRotation("R2", 0, 90, 0))); for (int i = 1; i < 28; i += 1) { float a = i * 0.2; TGeoVolume *Hear = Robot->MakeCons("Hear", Iron, 3, 13 + a, 16 + a, 13 + a, 16 + a, -60 - a, 60 + a); if (i < 27) { Hear->SetLineColor(12); Hear->SetFillColor(12); } else { Hear->SetLineColor(2); Hear->SetFillColor(2); } top->AddNodeOverlap(Hear, 1, new TGeoTranslation(0, 0, 89 - i)); } for (int i = 1; i < 28; i += 1) { float a = i * 0.2; TGeoVolume *Hear = Robot->MakeCons("Hear", Iron, 3, 13 + a, 16 + a, 13 + a, 16 + a, -70 - a, -60 - a); Hear->SetLineColor(2); Hear->SetFillColor(2); top->AddNodeOverlap(Hear, 1, new TGeoTranslation(0, 0, 89 - i)); } for (int i = 1; i < 28; i += 1) { float a = i * 0.2; TGeoVolume *Hear = Robot->MakeCons("Hear", Iron, 3, 13 + a, 16 + a, 13 + a, 16 + a, 60 + a, 70 + a); Hear->SetLineColor(2); Hear->SetFillColor(2); top->AddNodeOverlap(Hear, 1, new TGeoTranslation(0, 0, 89 - i)); } // neck TGeoVolume *Mock = Robot->MakeTrd2("Mock", Iron, 1, 1, 7, 6.5, 20); Mock->SetLineColor(17); Mock->SetFillColor(17); TGeoVolume *Mock_1 = Robot->MakeTrd2("Mock_1", Iron, 1, 1, 6, 5, 20); Mock_1->SetLineColor(17); Mock_1->SetFillColor(17); TGeoVolume *Mock_s = Robot->MakeTrd2("Mock_s", Iron, 1, 1, 5, 4.5, 20); Mock_s->SetLineColor(17); Mock_s->SetFillColor(17); // drawing neck top->AddNodeOverlap(Mock, 1, new TGeoCombiTrans(-5, 4.7, 50, new TGeoRotation("R2", -30, 0, -10))); top->AddNodeOverlap(Mock, 1, new TGeoCombiTrans(-5, -4.7, 50, new TGeoRotation("R2", 30, 0, 10))); top->AddNodeOverlap(Mock_1, 1, new TGeoCombiTrans(11, -4, 50, new TGeoRotation("R2", 130, -8, 10))); top->AddNodeOverlap(Mock_1, 1, new TGeoCombiTrans(11, 4, 50, new TGeoRotation("R2", -130, 8, -10))); top->AddNodeOverlap(Mock_s, 1, new TGeoCombiTrans(2.5, 9, 50, new TGeoRotation("R2", 90, 0, 0))); top->AddNodeOverlap(Mock_s, 1, new TGeoCombiTrans(2.5, -9, 50, new TGeoRotation("R2", 90, 0, 0))); // chest TGeoVolume *Gasem = Robot->MakeBox("Gasem", Iron, 16, 50, 20); Gasem->SetLineColor(12); Gasem->SetFillColor(12); TGeoVolume *Gasem_b1 = Robot->MakeSphere("Gasem_b1", Iron, 0, 15, 0, 180, 0, 360); Gasem_b1->SetLineColor(12); Gasem_b1->SetFillColor(12); TGeoVolume *Gasem_b2 = Robot->MakeSphere("Gasem_b2", Iron, 0, 13, 0, 180, 0, 360); Gasem_b2->SetLineColor(12); Gasem_b2->SetFillColor(12); TGeoVolume *Gasem_1 = Robot->MakeEltu("Gasem_1", Iron, 13, 13, 20); Gasem_1->SetLineColor(12); Gasem_1->SetFillColor(12); TGeoVolume *Gasem_2 = Robot->MakeEltu("Gasem_2", Iron, 13, 13, 19); Gasem_2->SetLineColor(12); Gasem_2->SetFillColor(12); TGeoVolume *Gasem_3 = Robot->MakeCone("Gasem_3", Iron, 19, 0, 13, 0, 15); Gasem_3->SetLineColor(12); Gasem_3->SetFillColor(12); TGeoVolume *Gasem_4 = Robot->MakeEltu("Gasem_4", Iron, 15, 15, 16); Gasem_4->SetLineColor(12); Gasem_4->SetFillColor(12); TGeoVolume *Gasem_5 = Robot->MakeEltu("Gasem_5", Iron, 13, 13, 16); Gasem_5->SetLineColor(12); Gasem_5->SetFillColor(12); TGeoVolume *Gasem_m1 = Robot->MakeBox("Gasem_m1", Iron, 19, 19, 5); Gasem_m1->SetLineColor(12); Gasem_m1->SetFillColor(12); TGeoVolume *Gasem_m2 = Robot->MakeTrd2("Gasem_m2", Iron, 13, 15, 2, 2, 19); Gasem_m2->SetLineColor(12); Gasem_m2->SetFillColor(12); TGeoVolume *V = Robot->MakeTrd2("V", Iron, 2, 2, 22, 30, 4); V->SetLineColor(2); V->SetFillColor(2); TGeoVolume *V_m = Robot->MakeBox("V_m", Iron, 2, 7, 1); V_m->SetLineColor(2); V_m->SetFillColor(2); // drawing chest top->AddNodeOverlap(Gasem, 1, new TGeoTranslation(4, 0, 19)); top->AddNodeOverlap(Gasem_b1, 1, new TGeoTranslation(-12, 50, 35)); top->AddNodeOverlap(Gasem_b1, 1, new TGeoTranslation(-12, -50, 35)); top->AddNodeOverlap(Gasem_b1, 1, new TGeoTranslation(20, 50, 35)); top->AddNodeOverlap(Gasem_b1, 1, new TGeoTranslation(20, -50, 35)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(-12, 50, -5)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(-12, -50, -5)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(20, 50, -5)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(20, -50, -5)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(20, 10, -5)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(20, -10, -5)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(-12, 10, -5)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(-12, -10, -5)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(20, 10, 35)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(20, -10, 35)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(-12, 10, 35)); top->AddNodeOverlap(Gasem_b2, 1, new TGeoTranslation(-12, -10, 35)); top->AddNodeOverlap(Gasem_1, 1, new TGeoCombiTrans(20, 31, -5, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gasem_1, 1, new TGeoCombiTrans(20, -31, -5, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gasem_1, 1, new TGeoCombiTrans(-12, 31, -5, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gasem_1, 1, new TGeoCombiTrans(-12, -31, -5, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gasem_2, 1, new TGeoCombiTrans(20, 10, 13, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Gasem_2, 1, new TGeoCombiTrans(20, -10, 13, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Gasem_2, 1, new TGeoCombiTrans(-12, 10, 13, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Gasem_2, 1, new TGeoCombiTrans(-12, -10, 13, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Gasem_3, 1, new TGeoCombiTrans(-12, 50, 16, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Gasem_3, 1, new TGeoCombiTrans(-12, -50, 16, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Gasem_3, 1, new TGeoCombiTrans(20, 50, 16, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Gasem_3, 1, new TGeoCombiTrans(20, -50, 16, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Gasem_3, 1, new TGeoCombiTrans(-12, 31, 35, new TGeoRotation("R2", 0, -90, 0))); top->AddNodeOverlap(Gasem_3, 1, new TGeoCombiTrans(-12, -31, 35, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gasem_3, 1, new TGeoCombiTrans(20, 31, 35, new TGeoRotation("R2", 0, -90, 0))); top->AddNodeOverlap(Gasem_3, 1, new TGeoCombiTrans(20, -31, 35, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gasem_4, 1, new TGeoCombiTrans(4, -50, 35, new TGeoRotation("R2", 90, 90, 0))); top->AddNodeOverlap(Gasem_4, 1, new TGeoCombiTrans(4, 50, 35, new TGeoRotation("R2", 90, 90, 0))); top->AddNodeOverlap(Gasem_5, 1, new TGeoCombiTrans(4, -50, -5, new TGeoRotation("R2", 90, 90, 0))); top->AddNodeOverlap(Gasem_5, 1, new TGeoCombiTrans(4, 50, -5, new TGeoRotation("R2", 90, 90, 0))); top->AddNodeOverlap(Gasem_m1, 1, new TGeoCombiTrans(-22, 30, 16, new TGeoRotation("R2", 90, 88, 0))); top->AddNodeOverlap(Gasem_m1, 1, new TGeoCombiTrans(-22, -30, 16, new TGeoRotation("R2", 90, 88, 0))); top->AddNodeOverlap(Gasem_m1, 1, new TGeoCombiTrans(29, 30, 16, new TGeoRotation("R2", 90, 92, 0))); top->AddNodeOverlap(Gasem_m1, 1, new TGeoCombiTrans(29, -30, 16, new TGeoRotation("R2", 90, 92, 0))); top->AddNodeOverlap(Gasem_m2, 1, new TGeoCombiTrans(2, -62, 16, new TGeoRotation("R2", 0, 3, 0))); top->AddNodeOverlap(Gasem_m2, 1, new TGeoCombiTrans(2, 62, 16, new TGeoRotation("R2", 0, -3, 0))); top->AddNodeOverlap(Gasem_m2, 1, new TGeoCombiTrans(2, -30, 47.5, new TGeoRotation("R2", 0, 87, 0))); top->AddNodeOverlap(Gasem_m2, 1, new TGeoCombiTrans(2, 30, 47.5, new TGeoRotation("R2", 0, -87, 0))); top->AddNodeOverlap(Gasem_m2, 1, new TGeoCombiTrans(2, -30, -16, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gasem_m2, 1, new TGeoCombiTrans(2, 30, -16, new TGeoRotation("R2", 0, -90, 0))); top->AddNodeOverlap(V, 1, new TGeoCombiTrans(-30, 18.3, 16, new TGeoRotation("R2", 0, -135, 0))); top->AddNodeOverlap(V, 1, new TGeoCombiTrans(-30, -18.3, 16, new TGeoRotation("R2", 0, 135, 0))); top->AddNodeOverlap(V_m, 1, new TGeoTranslation(-30, -37, 35)); top->AddNodeOverlap(V_m, 1, new TGeoTranslation(-30, 37, 35)); // abdomen TGeoVolume *Bea = Robot->MakeEltu("Bea", Iron, 20, 37, 25); Bea->SetLineColor(17); Bea->SetFillColor(17); TGeoVolume *Bea_d = Robot->MakeEltu("Bea_d", Iron, 21, 36, 5); Bea_d->SetLineColor(12); Bea_d->SetFillColor(12); TGeoVolume *Beakop = Robot->MakeEltu("Beakop", Iron, 15, 25, 5); Beakop->SetLineColor(10); Beakop->SetFillColor(10); // drawing abdomen top->AddNodeOverlap(Bea, 1, new TGeoTranslation(3, 0, -30)); top->AddNodeOverlap(Bea_d, 1, new TGeoTranslation(3, 0, -10)); top->AddNodeOverlap(Beakop, 1, new TGeoCombiTrans(-12.1, 0, -50, new TGeoRotation("R2", 90, 90, 0))); // Gungdi TGeoVolume *Gungdi = Robot->MakeEltu("Gungdi", Iron, 25, 50, 18); Gungdi->SetLineColor(12); Gungdi->SetFillColor(12); TGeoVolume *Gungdi_d = Robot->MakeEltu("Gungdi_d", Iron, 5, 5, 5); Gungdi_d->SetLineColor(2); Gungdi_d->SetFillColor(2); // drawing Gungdi top->AddNodeOverlap(Gungdi, 1, new TGeoTranslation(3, 0, -70)); for (int i = 0; i < 30; i++) { TGeoVolume *Gungdi_j = Robot->MakeEltu("Gungdi_j", Iron, 24 - 0.2 * i, 49 - 0.5 * i, 1); Gungdi_j->SetLineColor(12); Gungdi_j->SetFillColor(12); top->AddNodeOverlap(Gungdi_j, 1, new TGeoTranslation(3, 0, -51 + 0.5 * i)); } for (int i = 0; i < 40; i++) { if (i < 16) { TGeoVolume *Gungdi_h = Robot->MakeEltu("Gungdi_h", Iron, 24 - 0.1 * i, 49 - 0.3 * i, 1); Gungdi_h->SetLineColor(12); Gungdi_h->SetFillColor(12); top->AddNodeOverlap(Gungdi_h, 1, new TGeoTranslation(3, 0, -88 - 0.5 * i)); } else { TGeoVolume *Gungdi_h = Robot->MakeEltu("Gungdi_h", Iron, 27 - 0.3 * i, 52 - 0.5 * i, 1); Gungdi_h->SetLineColor(12); Gungdi_h->SetFillColor(12); top->AddNodeOverlap(Gungdi_h, 1, new TGeoTranslation(3, 0, -89 - 0.5 * i)); } } top->AddNodeOverlap(Gungdi_d, 1, new TGeoCombiTrans(3, -45, -62, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gungdi_d, 1, new TGeoCombiTrans(3, -45, -78, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gungdi_d, 1, new TGeoCombiTrans(3, 45, -62, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Gungdi_d, 1, new TGeoCombiTrans(3, 45, -78, new TGeoRotation("R2", 0, 90, 0))); // feet TGeoVolume *Jang = Robot->MakeEltu("Jang", Iron, 18, 18, 50); Jang->SetLineColor(17); Jang->SetFillColor(17); TGeoVolume *Jong = Robot->MakeEltu("Jong", Iron, 22, 22, 50); Jong->SetLineColor(12); Jong->SetFillColor(12); TGeoVolume *Bal = Robot->MakeSphere("Bal", Iron, 0, 22, 0, 180, 180, 360); Bal->SetLineColor(12); Bal->SetFillColor(12); // drawing Dary top->AddNodeOverlap(Jang, 1, new TGeoCombiTrans(3, -25, -120, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Jang, 1, new TGeoCombiTrans(3, 25, -120, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Jong, 1, new TGeoCombiTrans(3, -25, -220, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Jong, 1, new TGeoCombiTrans(3, 25, -220, new TGeoRotation("R2", 0, 0, 0))); for (int i = 0; i < 30; i++) { TGeoVolume *Mu = Robot->MakeCons("Mu", Iron, 1, 0, 22.1, 0, 22.1, 120 + 2 * i, -120 - 2 * i); Mu->SetLineColor(4); Mu->SetFillColor(4); top->AddNodeOverlap(Mu, 1, new TGeoTranslation(3, -25, -171 - i)); top->AddNodeOverlap(Mu, 1, new TGeoTranslation(3, 25, -171 - i)); } top->AddNodeOverlap(Bal, 1, new TGeoCombiTrans(-10, -25, -270, new TGeoRotation("R2", 270, -90, 0))); top->AddNodeOverlap(Bal, 1, new TGeoCombiTrans(-10, 25, -270, new TGeoRotation("R2", 270, -90, 0))); // arms TGeoVolume *S = Robot->MakeSphere("S", Iron, 0, 25, 0, 180, 180, 360); S->SetLineColor(17); S->SetFillColor(17); TGeoVolume *S_1 = Robot->MakeSphere("S_1", Iron, 0, 15, 0, 180, 0, 360); S_1->SetLineColor(17); S_1->SetFillColor(17); TGeoVolume *Pal = Robot->MakeEltu("Pal", Iron, 15, 15, 30); Pal->SetLineColor(17); Pal->SetFillColor(17); TGeoVolume *Fal = Robot->MakeEltu("Fal", Iron, 17, 17, 30); Fal->SetLineColor(4); Fal->SetFillColor(4); TGeoVolume *Bbul = Robot->MakeCone("Bbul", Iron, 8, 0, 0, 0, 5); Bbul->SetLineColor(17); Bbul->SetFillColor(17); // drawing arms top->AddNodeOverlap(S, 1, new TGeoCombiTrans(3, 73, 30, new TGeoRotation("R2", 0, -30, 0))); top->AddNodeOverlap(S, 1, new TGeoCombiTrans(3, -73, 30, new TGeoRotation("R2", 0, 210, 0))); top->AddNodeOverlap(S_1, 1, new TGeoCombiTrans(3, -73, 27, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(S_1, 1, new TGeoCombiTrans(3, 73, 27, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Pal, 1, new TGeoCombiTrans(3, -73, -5, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Pal, 1, new TGeoCombiTrans(3, 73, -5, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Fal, 1, new TGeoCombiTrans(3, -73, -60, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Fal, 1, new TGeoCombiTrans(3, 73, -60, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Bbul, 1, new TGeoCombiTrans(3, -97, -72, new TGeoRotation("R2", 0, -90, 0))); top->AddNodeOverlap(Bbul, 1, new TGeoCombiTrans(3, -97, -48, new TGeoRotation("R2", 0, -90, 0))); top->AddNodeOverlap(Bbul, 1, new TGeoCombiTrans(3, 97, -72, new TGeoRotation("R2", 0, 90, 0))); top->AddNodeOverlap(Bbul, 1, new TGeoCombiTrans(3, 97, -48, new TGeoRotation("R2", 0, 90, 0))); // hands TGeoVolume *Son_d = Robot->MakeBox("Son_d", Iron, 15, 15, 7); Son_d->SetLineColor(4); Son_d->SetFillColor(4); TGeoVolume *Son_g = Robot->MakeBox("Son_g", Iron, 4, 10, 4); Son_g->SetLineColor(4); Son_g->SetFillColor(4); TGeoVolume *Son_g1 = Robot->MakeBox("Son_g1", Iron, 6, 6, 6); Son_g1->SetLineColor(4); Son_g1->SetFillColor(4); TGeoVolume *Son_g2 = Robot->MakeBox("Son_g2", Iron, 8, 3, 3); Son_g2->SetLineColor(4); Son_g2->SetFillColor(4); TGeoVolume *Last_b = Robot->MakeCone("Last_b", Iron, 10, 0, 0, 0, 4); Last_b->SetLineColor(17); Last_b->SetFillColor(17); TGeoVolume *Last = Robot->MakeSphere("Last", Iron, 0, 3, 0, 180, 0, 360); Last->SetLineColor(2); Last->SetFillColor(2); // drawing hands top->AddNodeOverlap(Son_d, 1, new TGeoCombiTrans(3, -80, -105, new TGeoRotation("R2", 0, 90, 0))); for (int i = 0; i < 4; i++) { top->AddNodeOverlap(Son_g, 1, new TGeoCombiTrans(-6 + 6 * i, -72, -118, new TGeoRotation("R2", 0, -10, 0))); } for (int i = 0; i < 4; i++) { top->AddNodeOverlap(Son_g, 1, new TGeoCombiTrans(-6 + 6 * i, -67, -113, new TGeoRotation("R2", 0, 110, 0))); } top->AddNodeOverlap(Son_g1, 1, new TGeoCombiTrans(-5, -70, -98, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Son_g2, 1, new TGeoCombiTrans(-5, -65, -102, new TGeoRotation("R2", 0, 60, 0))); top->AddNodeOverlap(Son_d, 1, new TGeoCombiTrans(3, 80, -105, new TGeoRotation("R2", 0, 90, 0))); for (int i = 0; i < 4; i++) { top->AddNodeOverlap(Son_g, 1, new TGeoCombiTrans(-6 + 6 * i, 72, -118, new TGeoRotation("R2", 0, 10, 0))); } for (int i = 0; i < 4; i++) { top->AddNodeOverlap(Son_g, 1, new TGeoCombiTrans(-6 + 6 * i, 67, -113, new TGeoRotation("R2", 0, 70, 0))); } top->AddNodeOverlap(Son_g1, 1, new TGeoCombiTrans(-5, 70, -98, new TGeoRotation("R2", 0, 0, 0))); top->AddNodeOverlap(Son_g2, 1, new TGeoCombiTrans(-5, 65, -102, new TGeoRotation("R2", 0, 60, 0))); top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(3, -88, -103, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(12, -88, -103, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(-7, -88, -103, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(3, 88, -103, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(12, 88, -103, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last_b, 1, new TGeoCombiTrans(-7, 88, -103, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(3, -88, -112, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(12, -88, -112, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(-7, -88, -112, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(3, 88, -112, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(12, 88, -112, new TGeoRotation("R2", 0, 180, 0))); top->AddNodeOverlap(Last, 1, new TGeoCombiTrans(-7, 88, -112, new TGeoRotation("R2", 0, 180, 0))); for (int i = 1; i < 20; i += 1) { if (i < 7) { TGeoVolume *Effect = Robot->MakeCons("Effect", Iron, 3, 20 / sin(i), 21 / sin(i), 20 / sin(i), 21 / sin(i), 0, 70); Effect->SetLineColor(9); Effect->SetFillColor(9); top->AddNodeOverlap(Effect, 1, new TGeoTranslation(3, 0, -280)); } if (6 < i && i < 10) { TGeoVolume *Effect = Robot->MakeCons("Effect", Iron, 5, 20 / sin(i), 21 / sin(i), 20 / sin(i), 21 / sin(i), 50, 120); Effect->SetLineColor(38); Effect->SetFillColor(38); top->AddNodeOverlap(Effect, 1, new TGeoTranslation(3, 0, -280)); } if (9 < i && i < 20) { TGeoVolume *Effect = Robot->MakeCons("Effect", Iron, 4, 20 / sin(i), 21 / sin(i), 20 / sin(i), 21 / sin(i), 200, 330); Effect->SetLineColor(33); Effect->SetFillColor(33); top->AddNodeOverlap(Effect, 1, new TGeoTranslation(3, 0, -280)); } } // close geometry top->SetVisibility(0); Robot->CloseGeometry(); // in GL viewer top->Draw("ogl"); }
void nucleus(Int_t nProtons = 40,Int_t nNeutrons = 60) { Double_t NeutronRadius = 60, ProtonRadius = 60, NucleusRadius, distance = 60; Double_t vol = nProtons + nNeutrons; vol = 3 * vol / (4 * TMath::Pi()); NucleusRadius = distance * TMath::Power(vol, 1./3.); // cout << "NucleusRadius: " << NucleusRadius << endl; TGeoManager * geom = new TGeoManager("nucleus", "Model of a nucleus"); geom->SetNsegments(40); TGeoMaterial *matEmptySpace = new TGeoMaterial("EmptySpace", 0, 0, 0); TGeoMaterial *matProton = new TGeoMaterial("Proton" , .938, 1., 10000.); TGeoMaterial *matNeutron = new TGeoMaterial("Neutron" , .935, 0., 10000.); TGeoMedium *EmptySpace = new TGeoMedium("Empty", 1, matEmptySpace); TGeoMedium *Proton = new TGeoMedium("Proton", 1, matProton); TGeoMedium *Neutron = new TGeoMedium("Neutron",1, matNeutron); // the space where the nucleus lives (top container volume) Double_t worldx = 200.; Double_t worldy = 200.; Double_t worldz = 200.; TGeoVolume *top = geom->MakeBox("WORLD", EmptySpace, worldx, worldy, worldz); geom->SetTopVolume(top); TGeoVolume * proton = geom->MakeSphere("proton", Proton, 0., ProtonRadius); TGeoVolume * neutron = geom->MakeSphere("neutron", Neutron, 0., NeutronRadius); proton->SetLineColor(kRed); neutron->SetLineColor(kBlue); Double_t x, y, z, dummy; Int_t i = 0; while ( i< nProtons) { gRandom->Rannor(x, y); gRandom->Rannor(z,dummy); if ( TMath::Sqrt(x*x + y*y + z*z) < 1) { x = (2 * x - 1) * NucleusRadius; y = (2 * y - 1) * NucleusRadius; z = (2 * z - 1) * NucleusRadius; top->AddNode(proton, i, new TGeoTranslation(x, y, z)); i++; } } i = 0; while ( i < nNeutrons) { gRandom->Rannor(x, y); gRandom->Rannor(z,dummy); if ( TMath::Sqrt(x*x + y*y + z*z) < 1) { x = (2 * x - 1) * NucleusRadius; y = (2 * y - 1) * NucleusRadius; z = (2 * z - 1) * NucleusRadius; top->AddNode(neutron, i + nProtons, new TGeoTranslation(x, y, z)); i++; } } geom->CloseGeometry(); geom->SetVisLevel(4); top->Draw("ogl"); }
/* * 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"); }
TGeoVolume *VP_SimpleECal(int nphi = 4, int nz = 3, double density = 8.28) { const double world_x = 9000.; const double world_y = 9000.; const double world_z = 16000; TGeoManager *geom = new TGeoManager("SimpleECal", "Simplification of the CMS ECal"); TGeoMaterial *world_mat = new TGeoMaterial("world", 1, 2, 0); TGeoMedium *world_med = new TGeoMedium("world_medium", 0, world_mat); TGeoVolume *world = geom->MakeBox("top", world_med, world_x, world_y, world_z); geom->SetTopVolume(world); geom->SetTopVisible(1); int crystal_nphi = nphi; int crystal_nz = nz; double ecal_density = density; const int crystal_n = crystal_nphi * crystal_nz; const double ecal_zmin = -3000.; const double ecal_zmax = 3000.; const double ecal_rmin = 10.; const double ecal_rmax = 5000.; const double ecal_dz = 0.5 * (ecal_zmax - ecal_zmin) / crystal_nz; const double ecal_sphi = 0.; // const G4double ecal_dphi = 2.0*M_PI/crystal_nphi; // G4 seems to be in radian while TGeo seems to be in degree. // const double ecal_dphi = 2.0*TMath::Pi()/crystal_nphi; const double ecal_dphi = 2.0 * 180 / crystal_nphi; int iptr = 0; TGeoElementTable *table = gGeoManager->GetElementTable(); // TGeoElement* elPb = new TGeoElement( "Lead", "Pb", 82., 207.19*g/mole ); // TGeoElement* elW = new TGeoElement( "Tungstenm", "W",74., 183.85*g/mole); // TGeoElement* elO = new TGeoElement( "Oxygen", "O2", 8., 16.*g/mole ); TGeoElement *elPb = table->GetElement(82); TGeoElement *elW = table->GetElement(74); TGeoElement *elO = table->GetElement(8); // TGeoMaterial *ecal_mat = new TGeoMaterial("ecal",90,120,density); TGeoMixture *ecal_mat = new TGeoMixture("ecal_mat", 3, density); ecal_mat->AddElement(elPb, 1); ecal_mat->AddElement(elW, 1); ecal_mat->AddElement(elO, 4); TGeoMedium *ecal_med = new TGeoMedium("ecal_med", 0, ecal_mat); for (int j = 0; j < crystal_nz; ++j) { for (int i = 0; i < crystal_nphi; ++i) { iptr = i + j * crystal_nphi; TGeoVolume *ecal = geom->MakeTubs(TString::Format("ecal-%d-%d", j, i), ecal_med, ecal_rmin, ecal_rmax, ecal_dz, ecal_sphi + i * ecal_dphi, ecal_sphi + (i + 1) * ecal_dphi); ecal->SetLineColor(iptr); // top->AddNode(ecal,1,new TGeoCombiTrans(0,0,0,new TGeoRotation("ecal",0,0,0))); // GPThreeVector ecal_trans = GPThreeVector_create(0,0,ecal_zmin+(2.0*j+1.0)*ecal_dz); double dx = 0.0; double dy = 0.0; double dz = ecal_zmin + (2.0 * j + 1.0) * ecal_dz; TGeoTranslation *ecal_trans = new TGeoTranslation("", dx, dy, dz); // GPLogicalVolume_Constructor(ecal_log+iptr, (GPVSolid*)ecal, ecal_mat); // GPVPhysicalVolume_Constructor(ecal_phy+iptr, idRot, ecal_trans, ecal_log+iptr); world->AddNode(ecal, iptr, ecal_trans); // Set mother // GPVPhysicalVolume_SetMotherLogical(ecal_phy+iptr, world_log); // addLogicalVolumePointers( ecal_log+iptr); // addPhysicalVolumePointers( ecal_phy+iptr); } } // add daughter volume // for ( int j=0; j < crystal_nz ; ++j ) { // for ( int i=0; i < crystal_nphi ; ++i ) { // iptr = i+j*crystal_nphi; // addLogicalVolumeDaughter( world_log, ecal_phy+iptr); // } // } // Register world volume pointers for relocation // addLogicalVolumePointers( world_log ); // addPhysicalVolumePointers( world_phy ); geom->CloseGeometry(); return world; }
int main() { Vectors3DSOA points, dirs, intermediatepoints, intermediatedirs; StructOfCoord rpoints, rintermediatepoints, rdirs, rintermediatedirs; int np=1024; points.alloc(np); dirs.alloc(np); intermediatepoints.alloc(np); intermediatedirs.alloc(np); rpoints.alloc(np); rdirs.alloc(np); rintermediatepoints.alloc(np); rintermediatedirs.alloc(np); double *distances = (double *) _mm_malloc(np*sizeof(double), ALIGNMENT_BOUNDARY); double *distances2 = (double *) _mm_malloc(np*sizeof(double), ALIGNMENT_BOUNDARY); double *steps = (double *) _mm_malloc(np*sizeof(double), ALIGNMENT_BOUNDARY); for(auto i=0;i<np;++i) steps[i]=1E30; std::vector<Vector3D> conventionalpoints(np); std::vector<Vector3D> conventionaldirs(np); Vector3D * conventionalpoints2 = (Vector3D *) new Vector3D[np]; Vector3D * conventionaldirs2 = (Vector3D *) new Vector3D[np]; StopWatch timer; // generate benchmark cases for( int r=0; r< EulerAngles.size(); ++r ) // rotation cases for( int t=0; t<TransCases.size(); ++t ) // translation cases { TransformationMatrix const * identity = new TransformationMatrix(0,0,0,0,0,0); PhysicalVolume * world = GeoManager::MakePlacedBox( new BoxParameters(100,100,100), identity ); TransformationMatrix * tm = new TransformationMatrix(TransCases[t][0], TransCases[t][1], TransCases[t][2], EulerAngles[r][0], EulerAngles[r][1], EulerAngles[r][2]); // these dispatch to specialized matrices TransformationMatrix const * sm = TransformationMatrix::createSpecializedMatrix( TransCases[t][0], TransCases[t][1], TransCases[t][2], EulerAngles[r][0], EulerAngles[r][1], EulerAngles[r][2] ); PhysicalVolume * daughter = GeoManager::MakePlacedBox( new BoxParameters(10,15,20), tm ); world->AddDaughter(daughter); world->fillWithRandomPoints(points,np); world->fillWithBiasedDirections(points, dirs, np, 1./10); points.toStructureOfVector3D( conventionalpoints ); dirs.toStructureOfVector3D( conventionaldirs ); points.toStructureOfVector3D( conventionalpoints2 ); dirs.toStructureOfVector3D( conventionaldirs2 ); // time performance for this placement ( we should probably include some random physical steps ) timer.Start(); for(int reps=0;reps<1000;reps++) { daughter->DistanceToIn(points,dirs,steps,distances); } timer.Stop(); double t0 = timer.getDeltaSecs(); // std::cerr << tm->GetTranslationIdType() << " " << tm->getNumberOfZeroEntries() << " " << timer.getDeltaSecs() << std::endl; timer.Start(); for(int reps=0;reps<1000;reps++) { daughter->DistanceToInIL(points,dirs,steps,distances); } timer.Stop(); double til = timer.getDeltaSecs(); timer.Start(); for(int reps=0;reps<1000;reps++) { daughter->DistanceToInIL( conventionalpoints2, conventionaldirs2, steps, distances, np ); } timer.Stop(); double til2 = timer.getDeltaSecs(); // compare with case that uses external unspecialized transformation PhysicalVolume * unplaceddaughter = GeoManager::MakePlacedBox(new BoxParameters(10,15,20), identity); timer.Start(); for(int reps=0;reps<1000;reps++) { if(! tm->isIdentity() ) { tm->MasterToLocal(points, intermediatepoints ); tm->MasterToLocalVec( dirs, intermediatedirs ); unplaceddaughter->DistanceToIn( intermediatepoints, intermediatedirs, steps, distances2); } else { unplaceddaughter->DistanceToIn( points, dirs, steps, distances2); } } timer.Stop(); double t1 = timer.getDeltaSecs(); // compare with external specialized transformation ( sm ) sm->print(); timer.Start(); for(int reps=0;reps<1000;reps++) { sm->MasterToLocal(points, intermediatepoints ); sm->MasterToLocalVec( dirs, intermediatedirs ); unplaceddaughter->DistanceToIn( intermediatepoints, intermediatedirs, steps, distances2); } timer.Stop(); double t2 = timer.getDeltaSecs(); std::cerr << "VECTOR " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t0 << " " << t1 << " " << t2 << " " << til << " " << til2 << std::endl; cmpresults( distances, distances2, np ); // now we do the scalar interface: first of all placed version timer.Start(); for(int reps=0;reps<1000;reps++) { for(auto j=0;j<np;++j) { distances[j]=daughter->DistanceToIn( conventionalpoints[j], conventionaldirs[j], steps[j]); } } timer.Stop(); double t3 = timer.getDeltaSecs(); // now unplaced version timer.Start(); for(int reps=0;reps<1000;reps++) { for(auto j=0;j<np;++j) { Vector3D localp, localdir; tm->MasterToLocal(conventionalpoints[j], localp); tm->MasterToLocalVec(conventionaldirs[j], localdir); distances2[j]=unplaceddaughter->DistanceToIn( localp, localdir, steps[j]); } } timer.Stop(); double t4 = timer.getDeltaSecs(); // now unplaced version timer.Start(); for(int reps=0;reps<1000;reps++) { for(auto j=0;j<np;++j) { Vector3D localp, localdir; sm->MasterToLocal(conventionalpoints[j], localp); sm->MasterToLocalVec(conventionaldirs[j], localdir); distances2[j]=unplaceddaughter->DistanceToIn( localp, localdir, steps[j]); } } timer.Stop(); double t5 = timer.getDeltaSecs(); // now unplaced version but inlined matrices timer.Start(); for(int reps=0;reps<1000;reps++) { for(auto j=0;j<np;++j) { Vector3D localp, localdir; // this inlines I think tm->MasterToLocal<-1,-1>(conventionalpoints[j], localp); tm->MasterToLocalVec<-1>(conventionaldirs[j], localdir); distances2[j]=unplaceddaughter->DistanceToIn( localp, localdir, 1E30); } } timer.Stop(); double t6 = timer.getDeltaSecs(); std::cerr << "SCALAR " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t3 << " " << t4 << " " << t5 << " " << t6 << std::endl; TGeoMatrix * rootmatrix= new TGeoCombiTrans(TransCases[t][0], TransCases[t][1], TransCases[t][2], new TGeoRotation("rot1",EulerAngles[r][0], EulerAngles[r][1], EulerAngles[r][2])); TGeoManager *geom = new TGeoManager("",""); TGeoVolume * vol = geom->MakeBox("abox",0,10,15,20); TGeoShape * rootbox=vol->GetShape(); // now the scalar version from ROOTGeantV timer.Start(); for(int reps=0;reps<1000;reps++) { for(auto j=0;j<np;++j) { Vector3D localp, localdir; // this inlines I think rootmatrix->MasterToLocal( &conventionalpoints[j].x, &localp.x ); rootmatrix->MasterToLocalVect( &conventionaldirs[j].x, &localdir.x ); distances[j]=rootbox->DistFromOutside( &localp.x, &localdir.x, 3,1e30, 0); } } timer.Stop(); double t7 = timer.getDeltaSecs(); // now the VECTOR version from ROOT // now the scalar version from ROOTGeantV timer.Start(); for(int reps=0;reps<1000;reps++) { rootmatrix->MasterToLocalCombined_v( reinterpret_cast<StructOfCoord const &>(points), reinterpret_cast<StructOfCoord &>(intermediatepoints), reinterpret_cast<StructOfCoord const &>(dirs), reinterpret_cast<StructOfCoord &>(intermediatedirs), np ); rootbox->DistFromOutsideSOA_v( reinterpret_cast<StructOfCoord const &>(intermediatepoints), reinterpret_cast<StructOfCoord const &>(intermediatedirs), 3, steps, 0, distances2, np); } timer.Stop(); double t8 = timer.getDeltaSecs(); std::cerr << "RSCAL " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t7 << std::endl; std::cerr << "RVEC " << tm->isTranslation() << " " << tm->isRotation() << "("<<tm->getNumberOfZeroEntries()<<")" << " " << t8 << std::endl; cmpresults( distances, distances2, np ); delete tm; delete sm; } _mm_free(distances); return 1; }
void glViewerLOD(Int_t reqNodes = 1000, Bool_t randomDist = kTRUE, Bool_t reqSpheres = kTRUE, Bool_t reqTubes = kTRUE) { TGeoManager * geom = new TGeoManager("LODTest", "GL viewer LOD test"); geom->SetNsegments(4); // Doesn't matter keep low TGeoMaterial *matEmptySpace = new TGeoMaterial("EmptySpace", 0, 0, 0); TGeoMaterial *matSolid = new TGeoMaterial("Solid" , .938, 1., 10000.); TGeoMedium *medEmptySpace = new TGeoMedium("Empty", 1, matEmptySpace); TGeoMedium *medSolid = new TGeoMedium("Solid", 1, matSolid); Double_t sizeBase = 20.0; Double_t worldRadius; if (randomDist) { worldRadius = pow(reqNodes,.5)*sizeBase; } else { worldRadius = pow(reqNodes,.3)*sizeBase; } TGeoVolume *top = geom->MakeBox ("WORLD", medEmptySpace, worldRadius, worldRadius, worldRadius); geom->SetTopVolume(top); gRandom->SetSeed(); // Create random number of unique sphere shapes - up to 25% of // total placed sphere requested UInt_t volumeCount = gRandom->Integer(reqNodes/4)+1; TGeoVolume ** volumes = new TGeoVolume[volumeCount]; TGeoVolume * volume; Double_t dummy; for (UInt_t i = 0; i < volumeCount; i++) { char name[128]; sprintf(name, "Volume_%d", i); // Random volume shape Int_t type = -1; if (reqSpheres && reqTubes) { type = gRandom->Integer(2); if (type == 1) type += gRandom->Integer(3); } else if(reqSpheres) type = 0; else if(reqTubes) type = 1 + gRandom->Integer(3); // Random dimensions Double_t rMin = gRandom->Rndm() * sizeBase; Double_t rMax = rMin + gRandom->Rndm() * sizeBase * 2.0; Double_t dz = pow(gRandom->Rndm(),2.0) * sizeBase * 15.0; Double_t phi1 = gRandom->Rndm() * 90.0; Double_t phi2 = phi1 + gRandom->Rndm() * 270.0; // Pick random color (not black) Int_t color = gRandom->Integer(50); if (color == kBlack) color += 1; switch (type) { case 0: { // GL viewer only supports solid spheres (0. inner radius) volumes[i] = geom->MakeSphere(name, medSolid, 0., rMax); printf("Volume %d : Color %d, Sphere, Radius %f\n", i, color, rMax); break; } case 1: { volumes[i] = geom->MakeTube(name, medSolid, rMin, rMax, dz); printf("Volume %d : Color %d, Tube, Inner Radius %f, " "Outer Radius %f, Length %f\n", i, color, rMin, rMax, dz); break; } case 2: { volumes[i] = geom->MakeTubs(name, medSolid, rMin, rMax, dz, phi1, phi2); printf("Volume %d : Color %d, Tube Seg, Inner Radius %f, " "Outer Radius %f, Length %f, Phi1 %f, Phi2 %f\n", i, color, rMin, rMax, dz, phi1, phi2); break; } case 3: { Double_t n1[3], n2[3]; n1[0] = gRandom->Rndm()*.5; n1[1] = gRandom->Rndm()*.5; n1[2] = -1.0 + gRandom->Rndm()*.5; n2[0] = gRandom->Rndm()*.5; n2[1] = gRandom->Rndm()*.5; n2[2] = 1.0 - gRandom->Rndm()*.5; volumes[i] = geom->MakeCtub(name, medSolid, rMin, rMax, dz, phi1, phi2, n1[0], n1[1], n1[2], n2[0], n2[1], n2[2]); printf("Volume %d : Color %d, Cut Tube, Inner Radius %f, " "Outer Radius %f, Length %f, Phi1 %f, Phi2 %f, " "n1 (%f,%f,%f), n2 (%f,%f,%f)\n", i, color, rMin, rMax, dz, phi1, phi2, n1[0], n1[1], n1[2], n2[0], n2[1], n2[2]); break; } default: { assert(kFALSE); } } volumes[i]->SetLineColor(color); } printf("\nCreated %d volumes\n\n", volumeCount); // Scatter reqSpheres placed sphere randomly in space Double_t x, y, z; for (i = 0; i < reqNodes; i++) { // Pick random volume UInt_t useVolume = gRandom->Integer(volumeCount); TGeoTranslation * trans; TGeoRotation * rot; if (randomDist) { // Random translation gRandom->Rannor(x, y); gRandom->Rannor(z,dummy); trans = new TGeoTranslation(x*worldRadius, y*worldRadius, z*worldRadius); // Random rotation gRandom->Rannor(x, y); gRandom->Rannor(z,dummy); rot = new TGeoRotation("rot", x*360.0, y*360.0, z*360.0); } else { UInt_t perSide = pow(reqNodes,1.0/3.0)+0.5; Double_t distance = sizeBase*5.0; UInt_t xi, yi, zi; zi = i / (perSide*perSide); yi = (i / perSide) % perSide; xi = i % perSide; trans = new TGeoTranslation(xi*distance,yi*distance,zi*distance); rot = new TGeoRotation("rot",0.0, 0.0, 0.0); } top->AddNode(volumes[useVolume], i, new TGeoCombiTrans(*trans, *rot)); //printf("Added node %d (Volume %d)\n", i, useVolume); } geom->CloseGeometry(); top->Draw("ogl"); }