TEveBoxSet* boxset_cones(Float_t x=0, Float_t y=0, Float_t z=0, Int_t num=100, Bool_t register=kTRUE) { TEveManager::Create(); using namespace TMath; TEveStraightLineSet* lines = new TEveStraightLineSet("StraightLines"); lines->SetLineColor(kYellow); lines->SetLineWidth(2); TRandom r(0); gStyle->SetPalette(1, 0); TEveRGBAPalette* pal = new TEveRGBAPalette(0, 500); TEveBoxSet* cones = new TEveBoxSet("ConeSet"); cones->SetPalette(pal); cones->Reset(TEveBoxSet::kBT_Cone, kFALSE, 64); Float_t a = 40; // max distance between cones TEveVector dir, pos; Float_t theta, phi, height, rad; for (Int_t i=0; i<num; ++i) { theta = r.Uniform(0,TMath::Pi()); phi = r.Uniform (-TMath::Pi(), TMath::Pi()); height = r.Uniform(5, 15); rad = r.Uniform(3, 5); dir.Set(Cos(phi)*Cos(theta), Sin(phi)*Cos(theta), Sin(theta)); dir *= height; pos.Set(r.Uniform(-a,a), r.Uniform(-a, a), r.Uniform(-a, a)); cones->AddCone(pos, dir, rad); cones->DigitValue(r.Uniform(0, 500)); // draw axis line 30% longer than cone height TEveVector end = pos + dir*1.3f; lines->AddLine(pos.fX, pos.fY, pos.fZ, end.fX, end.fY, end.fZ); } // by default cone cap not drawn if (r.Integer(2)>0) cones->SetDrawConeCap(kTRUE); cones->RefitPlex(); TEveTrans& t = cones->RefMainTrans(); t.SetPos(x, y, z); gEve->AddElement(cones); gEve->AddElement(lines); gEve->Redraw3D(kTRUE); return cones; }
TEveBoxSet* boxset_freebox(Int_t num=100, Bool_t registerSet=kTRUE) { TEveManager::Create(); TRandom r(0); gStyle->SetPalette(1, 0); TEveRGBAPalette* pal = new TEveRGBAPalette(0, 130); TEveBoxSet* q = new TEveBoxSet("BoxSet"); q->SetPalette(pal); q->Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 64); #define RND_BOX(x) (Float_t)r.Uniform(-(x), (x)) Float_t verts[24]; for (Int_t i=0; i<num; ++i) { Float_t x = RND_BOX(10); Float_t y = RND_BOX(10); Float_t z = RND_BOX(10); Float_t a = r.Uniform(0.2, 0.5); Float_t d = 0.05; Float_t verts[24] = { x - a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d), x - a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d), x + a + RND_BOX(d), y + a + RND_BOX(d), z - a + RND_BOX(d), x + a + RND_BOX(d), y - a + RND_BOX(d), z - a + RND_BOX(d), x - a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d), x - a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d), x + a + RND_BOX(d), y + a + RND_BOX(d), z + a + RND_BOX(d), x + a + RND_BOX(d), y - a + RND_BOX(d), z + a + RND_BOX(d) }; q->AddBox(verts); q->DigitValue(r.Uniform(0, 130)); } q->RefitPlex(); #undef RND_BOX // Uncomment these two lines to get internal highlight / selection. // q->SetPickable(1); // q->SetAlwaysSecSelect(1); if (registerSet) { gEve->AddElement(q); gEve->Redraw3D(kTRUE); } return q; }
TEveBoxSet* boxset(Float_t x=0, Float_t y=0, Float_t z=0, Int_t num=100, Bool_t registerSet=kTRUE) { TEveManager::Create(); TRandom r(0); gStyle->SetPalette(1, 0); TEveRGBAPalette* pal = new TEveRGBAPalette(0, 130); TEveFrameBox* frm = new TEveFrameBox(); frm->SetAABoxCenterHalfSize(0, 0, 0, 12, 12, 12); frm->SetFrameColor(kCyan); frm->SetBackColorRGBA(120,120,120,20); frm->SetDrawBack(kTRUE); TEveBoxSet* q = new TEveBoxSet("BoxSet"); q->SetPalette(pal); q->SetFrame(frm); q->Reset(TEveBoxSet::kBT_AABox, kFALSE, 64); for (Int_t i=0; i<num; ++i) { q->AddBox(r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(-10, 10), r.Uniform(0.2, 1), r.Uniform(0.2, 1), r.Uniform(0.2, 1)); q->DigitValue(r.Uniform(0, 130)); } q->RefitPlex(); TEveTrans& t = q->RefMainTrans(); t.SetPos(x, y, z); // Uncomment these two lines to get internal highlight / selection. // q->SetPickable(1); // q->SetAlwaysSecSelect(1); if (registerSet) { gEve->AddElement(q); gEve->Redraw3D(kTRUE); } return q; }
void display(bool showChannelIndex = false, TString fileNameCenters="../geom/dpgageom.csv", TString fileNameFull="../geom/dpgafullgeom.csv", Bool_t register=kTRUE) { TEveManager::Create(); gStyle->SetPalette(1, 0); TEveRGBAPalette* pal = new TEveRGBAPalette(0, 130); // Draw coordinate system TEveArrow* xAxis = new TEveArrow(150., 0., 0., 0., 0., 0.); TEveArrow* yAxis = new TEveArrow(0., 150., 0., 0., 0., 0.); TEveArrow* zAxis = new TEveArrow(0., 0., 150., 0., 0., 0.); xAxis->SetMainColor(15); xAxis->SetTubeR(0.042); xAxis->SetConeR(0.077); xAxis->SetConeL(0.245); xAxis->SetPickable(kTRUE); yAxis->SetMainColor(15); yAxis->SetTubeR(0.042); yAxis->SetConeR(0.077); yAxis->SetConeL(0.245); yAxis->SetPickable(kTRUE); zAxis->SetMainColor(15); zAxis->SetTubeR(0.042); zAxis->SetConeR(0.077); zAxis->SetConeL(0.245); zAxis->SetPickable(kTRUE); gEve->AddElement(xAxis); gEve->AddElement(yAxis); gEve->AddElement(zAxis); TEveText* tx = new TEveText("x"); tx->SetFontSize(20); TEveVector tvx = xAxis->GetVector()*1.1+xAxis->GetOrigin(); tx->RefMainTrans().SetPos(tvx.Arr()); //xAxis->AddElement(tx); TEveText* ty = new TEveText("y"); ty->SetFontSize(20); TEveVector tvy = yAxis->GetVector()*1.1+yAxis->GetOrigin(); ty->RefMainTrans().SetPos(tvy.Arr()); //yAxis->AddElement(ty); TEveText* tz = new TEveText("z"); tz->SetFontSize(20); TEveVector tvz = zAxis->GetVector()*1.1+zAxis->GetOrigin(); tz->RefMainTrans().SetPos(tvz.Arr()); //zAxis->AddElement(tz); // Read full coordinates of scintillators and put them in a box set TEveBoxSet* bsright = new TEveBoxSet("BoxSetRight"); bsright->Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 64); bsright->SetPalette(pal); TEveBoxSet* bsleft = new TEveBoxSet("BoxSetLeft"); bsleft->Reset(TEveBoxSet::kBT_FreeBox, kFALSE, 64); bsleft->SetPalette(pal); ifstream infull(fileNameFull.Data()); if (!infull) { cerr << "ERROR ! Unable to open file '" << fileNameFull << "' !" << endl; return; } for(; !infull.eof() ;) { string line; if (!getline(infull,line)) break; if (!line.empty() && line[0]!='#') { istringstream istr(line); int iChannelAbs240; float X0, Y0, Z0; float X1, Y1, Z1; float X2, Y2, Z2; float X3, Y3, Z3; float X4, Y4, Z4; float X5, Y5, Z5; float X6, Y6, Z6; float X7, Y7, Z7; istr >> iChannelAbs240 >> X0 >> Y0 >> Z0 >> X1 >> Y1 >> Z1 >> X2 >> Y2 >> Z2 >> X3 >> Y3 >> Z3 >> X4 >> Y4 >> Z4 >> X5 >> Y5 >> Z5 >> X6 >> Y6 >> Z6 >> X7 >> Y7 >> Z7; Float_t verts[24] = { X0 , Y0 , Z0, X1 , Y1 , Z1, X2 , Y2 , Z2, X3 , Y3 , Z3, X4 , Y4 , Z4, X5 , Y5 , Z5, X6 , Y6 , Z6, X7 , Y7 , Z7}; // Color code: // 100 -> yellow // 10 -> blue if(iChannelAbs240 < 120) { bsright->AddBox(verts); bsright->DigitValue(100); } else { bsleft->AddBox(verts); bsleft->DigitValue(10); } } }