#define HEX_LADO 354.49/2.0 #define HEX_ALTU 307.00/2.0 #define HEX_VERT 66.4 #define VIDRO_NHSEG 100 #define VIDRO_NVSEG 30 #define PMT_RAIO 103.5 #define PMT_HEIGHT 82.9 #define COS30 cos(3.141592654/6.0) #define STEP_Y HEX_ALTU*2.0 #define STEP_X STEP_Y*COS30 #define DET_W1 1152.10 #define DET_W2 1381.5 #define DET_H 900.0 + 101.5 #define OFF_X (DET_W1/2.0 - HEX_LADO) #define OFF_Y1 (DET_W2/2.0 - HEX_ALTU) #define OFF_Y2 (DET_W2/2.0 - STEP_Y) void teste7() { // cria mundo --------------------------------------------------------- TGeoMaterial *mat = new TGeoMaterial("Agua",0,0,0); TGeoMedium *med = new TGeoMedium ("Agua",1,mat); // caixa do detector -------------------------------------------------- TGeoVolume *det = gGeoManager->MakeBox("Detector", med, DET_W1/2.0, DET_W2/2.0 + HEX_VERT, DET_H/2.0 + HEX_VERT); // espelho inferior --------------------------------------------------- TGeoVolume *mbox = gGeoManager->MakeBox ("mbox", med, DET_W1/2.0, DET_W2/2.0, HEX_VERT/2.0); TGeoVolume *cone = gGeoManager->MakeCone("cone", med, HEX_VERT/2.0*1.1, 0.0, PMT_RAIO, 0.0, HEX_LADO); TGeoTranslation *t1 = new TGeoTranslation("t1", -OFF_X, -OFF_Y1, 0); TGeoSubtraction *s1 = new TGeoSubtraction(mbox->GetShape(), cone->GetShape(), NULL, t1); TGeoCompositeShape *c1 = new TGeoCompositeShape("c1", s1); TGeoVolume *v1 = new TGeoVolume ("v1", c1); TGeoTranslation *t2 = new TGeoTranslation("t2", -OFF_X, -OFF_Y1+STEP_Y, 0); TGeoSubtraction *s2 = new TGeoSubtraction(v1->GetShape(), cone->GetShape(), NULL, t2); TGeoCompositeShape *c2 = new TGeoCompositeShape("c2", s2); TGeoVolume *v2 = new TGeoVolume ("v2", c2); TGeoTranslation *t3 = new TGeoTranslation("t3", -OFF_X, -OFF_Y1+2.0*STEP_Y, 0); TGeoSubtraction *s3 = new TGeoSubtraction(v2->GetShape(), cone->GetShape(), NULL, t3); TGeoCompositeShape *c3 = new TGeoCompositeShape("c3", s3); TGeoVolume *v3 = new TGeoVolume ("v3", c3); TGeoTranslation *t4 = new TGeoTranslation("t4", -OFF_X, -OFF_Y1+3.0*STEP_Y, 0); TGeoSubtraction *s4 = new TGeoSubtraction(v3->GetShape(), cone->GetShape(), NULL, t4); TGeoCompositeShape *c4 = new TGeoCompositeShape("c4", s4); TGeoVolume *v4 = new TGeoVolume ("v4", c4); TGeoTranslation *t5 = new TGeoTranslation("t5", -OFF_X+STEP_X, -OFF_Y2, 0); TGeoSubtraction *s5 = new TGeoSubtraction(v4->GetShape(), cone->GetShape(), NULL, t5); TGeoCompositeShape *c5 = new TGeoCompositeShape("c5", s5); TGeoVolume *v5 = new TGeoVolume ("v5", c5); TGeoTranslation *t6 = new TGeoTranslation("t6", -OFF_X+STEP_X, -OFF_Y2+STEP_Y, 0); TGeoSubtraction *s6 = new TGeoSubtraction(v5->GetShape(), cone->GetShape(), NULL, t6); TGeoCompositeShape *c6 = new TGeoCompositeShape("c6", s6); TGeoVolume *v6 = new TGeoVolume ("v6", c6); TGeoTranslation *t7 = new TGeoTranslation("t7", -OFF_X+STEP_X, -OFF_Y2+2.0*STEP_Y, 0); TGeoSubtraction *s7 = new TGeoSubtraction(v6->GetShape(), cone->GetShape(), NULL, t7); TGeoCompositeShape *c7 = new TGeoCompositeShape("c7", s7); TGeoVolume *v7 = new TGeoVolume ("v7", c7); TGeoTranslation *t8 = new TGeoTranslation("t8", -OFF_X+STEP_X, -OFF_Y2+3.0*STEP_Y, 0); TGeoSubtraction *s8 = new TGeoSubtraction(v7->GetShape(), cone->GetShape(), NULL, t8); TGeoCompositeShape *c8 = new TGeoCompositeShape("c8", s8); TGeoVolume *v8 = new TGeoVolume ("v8", c8); TGeoTranslation *t9 = new TGeoTranslation("t9", -OFF_X+2.0*STEP_X, -OFF_Y1, 0); TGeoSubtraction *s9 = new TGeoSubtraction(v8->GetShape(), cone->GetShape(), NULL, t9); TGeoCompositeShape *c9 = new TGeoCompositeShape("c9", s9); TGeoVolume *v9 = new TGeoVolume ("v9", c9); TGeoTranslation *t10 = new TGeoTranslation("t10", -OFF_X+2.0*STEP_X, -OFF_Y1+STEP_Y, 0); TGeoSubtraction *s10 = new TGeoSubtraction(v9->GetShape(), cone->GetShape(), NULL, t10); TGeoCompositeShape *c10 = new TGeoCompositeShape("c10", s10); TGeoVolume *v10 = new TGeoVolume ("v10", c10); TGeoTranslation *t11 = new TGeoTranslation("t11", -OFF_X+2.0*STEP_X, -OFF_Y1+2.0*STEP_Y, 0); TGeoSubtraction *s11 = new TGeoSubtraction(v10->GetShape(), cone->GetShape(), NULL, t11); TGeoCompositeShape *c11 = new TGeoCompositeShape("c11", s11); TGeoVolume *v11 = new TGeoVolume ("v11", c11); TGeoTranslation *t12 = new TGeoTranslation("t12", -OFF_X+2.0*STEP_X, -OFF_Y1+3.0*STEP_Y, 0); TGeoSubtraction *s12 = new TGeoSubtraction(v11->GetShape(), cone->GetShape(), NULL, t12); TGeoCompositeShape *c12 = new TGeoCompositeShape("c12", s12); TGeoVolume *v12 = new TGeoVolume ("v12", c12); TGeoTranslation *t13 = new TGeoTranslation("t13", -OFF_X+3.0*STEP_X, -OFF_Y2, 0); TGeoSubtraction *s13 = new TGeoSubtraction(v12->GetShape(), cone->GetShape(), NULL, t13); TGeoCompositeShape *c13 = new TGeoCompositeShape("c13", s13); TGeoVolume *v13 = new TGeoVolume ("v13", c13); TGeoTranslation *t14 = new TGeoTranslation("t14", -OFF_X+3.0*STEP_X, -OFF_Y2+STEP_Y, 0); TGeoSubtraction *s14 = new TGeoSubtraction(v13->GetShape(), cone->GetShape(), NULL, t14); TGeoCompositeShape *c14 = new TGeoCompositeShape("c14", s14); TGeoVolume *v14 = new TGeoVolume ("v14", c14); TGeoTranslation *t15 = new TGeoTranslation("t15", -OFF_X+3.0*STEP_X, -OFF_Y2+2.0*STEP_Y, 0); TGeoSubtraction *s15 = new TGeoSubtraction(v14->GetShape(), cone->GetShape(), NULL, t15); TGeoCompositeShape *c15 = new TGeoCompositeShape("c15", s15); TGeoVolume *v15 = new TGeoVolume ("v15", c15); TGeoTranslation *t16 = new TGeoTranslation("t16", -OFF_X+3.0*STEP_X, -OFF_Y2+3.0*STEP_Y, 0); TGeoSubtraction *s16 = new TGeoSubtraction(v15->GetShape(), cone->GetShape(), NULL, t16); TGeoCompositeShape *c16 = new TGeoCompositeShape("c16", s16); TGeoVolume *v16 = new TGeoVolume ("v16", c16); v16->SetLineColor(kGray); TGeoTranslation *t17 = new TGeoTranslation("t17", 0.0, 0.0, -(DET_H/2.0 + HEX_VERT/2.0)); TGeoRotation *r1 = new TGeoRotation("r1", 0.0, 180.0, 0.0); TGeoCombiTrans *ct1 = new TGeoCombiTrans("ct1", 0.0, 0.0, DET_H/2.0 + HEX_VERT/2.0, r1); det->AddNode(v16, 1, t17); det->AddNode(v16, 2, ct1); // espelho lateral ---------------------------------------------------- TGeoVolume *lbox = gGeoManager->MakeBox ("lbox", med, DET_W1/2.0, DET_H/2.0 + HEX_VERT, HEX_VERT/2.0); TGeoTranslation *t18 = new TGeoTranslation("t18", HEX_ALTU, 0, 0); TGeoSubtraction *s18 = new TGeoSubtraction(lbox->GetShape(), cone->GetShape(), NULL, t18); TGeoCompositeShape *c18 = new TGeoCompositeShape("c18", s18); TGeoVolume *v18 = new TGeoVolume ("v18", c18); TGeoTranslation *t19 = new TGeoTranslation("t19", -HEX_ALTU, 0, 0); TGeoSubtraction *s19 = new TGeoSubtraction(v18->GetShape(), cone->GetShape(), NULL, t19); TGeoCompositeShape *c19 = new TGeoCompositeShape("c19", s19); TGeoVolume *v19 = new TGeoVolume ("v19", c19); TGeoTranslation *t20 = new TGeoTranslation("t20", 0, STEP_X, 0); TGeoSubtraction *s20 = new TGeoSubtraction(v19->GetShape(), cone->GetShape(), NULL, t20); TGeoCompositeShape *c20 = new TGeoCompositeShape("c20", s20); TGeoVolume *v20 = new TGeoVolume ("v20", c20); TGeoTranslation *t21 = new TGeoTranslation("t21", 0, -STEP_X, 0); TGeoSubtraction *s21 = new TGeoSubtraction(v20->GetShape(), cone->GetShape(), NULL, t21); TGeoCompositeShape *c21 = new TGeoCompositeShape("c21", s21); TGeoVolume *v21 = new TGeoVolume ("v21", c21); v21->SetLineColor(kGray); TGeoRotation *r22 = new TGeoRotation("r22", 0.0, 90.0, 0.0); TGeoCombiTrans *ct22 = new TGeoCombiTrans("ct22", 0.0, DET_W2/2.0 + HEX_VERT/2.0, 0.0, r22); det->AddNode(v21, 1, ct22); TGeoTranslation *t23 = new TGeoTranslation("t23", STEP_X, 0, 0); TGeoSubtraction *s23 = new TGeoSubtraction(lbox->GetShape(), cone->GetShape(), NULL, t23); TGeoCompositeShape *c23 = new TGeoCompositeShape("c23", s23); TGeoVolume *v23 = new TGeoVolume ("v18", c23); TGeoTranslation *t24 = new TGeoTranslation("t24", -STEP_X, 0, 0); TGeoSubtraction *s24 = new TGeoSubtraction(v23->GetShape(), cone->GetShape(), NULL, t24); TGeoCompositeShape *c24 = new TGeoCompositeShape("c24", s24); TGeoVolume *v24 = new TGeoVolume ("v24", c24); TGeoTranslation *t25 = new TGeoTranslation("t25", 0, HEX_ALTU, 0); TGeoSubtraction *s25 = new TGeoSubtraction(v24->GetShape(), cone->GetShape(), NULL, t25); TGeoCompositeShape *c25 = new TGeoCompositeShape("c25", s25); TGeoVolume *v25 = new TGeoVolume ("v25", c25); TGeoTranslation *t26 = new TGeoTranslation("t26", 0, -HEX_ALTU, 0); TGeoSubtraction *s26 = new TGeoSubtraction(v25->GetShape(), cone->GetShape(), NULL, t26); TGeoCompositeShape *c26 = new TGeoCompositeShape("c26", s26); TGeoVolume *v26 = new TGeoVolume ("v26", c26); v26->SetLineColor(kGray); TGeoRotation *r27 = new TGeoRotation("r27", 0.0, -90.0, 0.0); TGeoCombiTrans *ct27 = new TGeoCombiTrans("ct27", 0.0, -DET_W2/2.0 - HEX_VERT/2.0, 0.0, r27); det->AddNode(v26, 1, ct27); // fecha a geometria -------------------------------------------------- gGeoManager->SetTopVolume(det); gGeoManager->CloseGeometry(); gGeoManager->SetTopVisible(); det->SetTransparency(50); det->Draw("ogl"); // Inicializa uma trajetoria aleatoriamente --------------------------- Double_t *pos; pos = new Double_t[3]; pos[0] = gRandom->Uniform(-200.0, 200.0); gRandom->Rndm(); pos[1] = gRandom->Uniform(-200.0, 200.0); gRandom->Rndm(); pos[2] = gRandom->Uniform(-200.0, 200.0); gRandom->Rndm(); Double_t *dir; dir = new Double_t[3]; dir[0] = gRandom->Uniform(-1.0, 1.0); gRandom->Rndm(); dir[1] = gRandom->Uniform(-1.0, 1.0); gRandom->Rndm(); dir[2] = gRandom->Uniform(-1.0, 1.0); gRandom->Rndm(); // Reflete photon ate encontrar um vidro de PMT ----------------------- Double_t m, cosa; Double_t *n; Int_t N = -1; Double_t comp_tot = 0.0; for (Int_t i = 0; i < 50; i++) { // normaliza direcao ------------------------------------------ m = sqrt(dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2]); dir[0] = dir[0]/m; dir[1] = dir[1]/m; dir[2] = dir[2]/m; // inicializa track ------------------------------------------- gGeoManager->InitTrack(pos, dir); TPolyLine3D *pl = new TPolyLine3D(2); pl->SetLineColor(kRed); pl->SetPoint(0, pos[0], pos[1], pos[2]); // propaga track ate proximo objeto --------------------------- gGeoManager->FindNextBoundaryAndStep(); comp_tot += gGeoManager->GetStep(); N++; gGeoManager->cd("/Detector_1"); pos = (Double_t *) gGeoManager->GetCurrentPoint(); pos[0] -= 1E-6*dir[0]; pos[1] -= 1E-6*dir[1]; pos[2] -= 1E-6*dir[2]; if (gGeoManager->GetStep() <= 1e-06) cout << "fudeu" << endl; // pega segundo ponto do track -------------------------------- pl->SetPoint(1, pos[0], pos[1], pos[2]); pl->Draw(); // pega e desenha normal no novo ponto ------------------------ n = gGeoManager->FindNormalFast(); if (strcmp(gGeoManager->GetNextNode()->GetVolume()->GetName(), "v16") == 0 || strcmp(gGeoManager->GetNextNode()->GetVolume()->GetName(), "v21") == 0 || strcmp(gGeoManager->GetNextNode()->GetVolume()->GetName(), "v26") == 0) { TPolyLine3D *norm = new TPolyLine3D(2); norm->SetLineColor(kGreen); norm->SetPoint(0, pos[0], pos[1], pos[2]); norm->SetPoint(1, pos[0] - n[0]*50.0, pos[1] - n[1]*50.0, pos[2] - n[2]*50.0); norm->Draw(); } // computa proxima direcao de propagacao ---------------------- cosa = dir[0]*n[0]+dir[1]*n[1]+dir[2]*n[2]; dir[0] = dir[0] - 2.0*cosa*n[0]; dir[1] = dir[1] - 2.0*cosa*n[1]; dir[2] = dir[2] - 2.0*cosa*n[2]; } cout << "Numero de reflexoes = " << N << endl; cout << "Comprimento total = " << comp_tot/1000.0 << " metros." << endl; }