本文整理汇总了C++中TGeoVolume::SetLineColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TGeoVolume::SetLineColor方法的具体用法?C++ TGeoVolume::SetLineColor怎么用?C++ TGeoVolume::SetLineColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGeoVolume
的用法示例。
在下文中一共展示了TGeoVolume::SetLineColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getBeamVisuals
void getBeamVisuals(TGeoManager* geom, TGeoVolume* top, float minZ, float maxZ) {
TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
TGeoVolume *xyaxis = geom->MakeBox( "xyaxis", Vacuum, 90., 90., 40. );
TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
TGeoMedium *Al = new TGeoMedium("Root Material",1, matAl);
//TGeoVolume *line = geom->MakeTube( "BeamLine", Al, 0, .3, (maxZ - minZ) / 2 + 5);
TGeoVolume *xaxis = geom->MakeTube( "XAxis", Al, 0, .1, 30.);
TGeoVolume *yaxis = geom->MakeTube( "YAxis", Al, 0, .1, 30.);
//TGeoVolume *pipe = geom->MakeTube( "BeamPipe", Al, _piperadius-.05, _piperadius+.05, (maxZ - minZ) / 2 + 5);
//line->SetLineColor(kRed);
xaxis->SetLineColor(kBlue);
yaxis->SetLineColor(kBlue);
//pipe->SetLineColor(kBlack);
xyaxis->AddNode(xaxis, 1, new TGeoRotation( "rtyz", 0, 90, 0));
xyaxis->AddNode(yaxis, 1, new TGeoRotation( "rtxz", 90, 90, 0));
TGeoCombiTrans * pipecenter = new TGeoCombiTrans( *new TGeoTranslation(_pipexcoord, _pipeycoord, 0), *new TGeoRotation());
//TGeoCombiTrans * linecenter = new TGeoCombiTrans( *new TGeoTranslation(_linexcoord, _lineycoord, 0), *new TGeoRotation());
//top->AddNode( pipe, 1, pipecenter);
//top->AddNode( line, 1, linecenter);
top->AddNode( xyaxis, 1, pipecenter);
}
示例2: Show
void Visualizer::Show(){
std::cout<<"=============================================="<<std::endl;
std::cout<<"========= Inside Expected SHOW() ============="<<std::endl;
std::cout<<"=============================================="<<std::endl;
TGeoVolume *top = gGeoManager->MakeBox("Top", NULL, kInfinity, kInfinity, kInfinity);
gGeoManager->SetTopVolume(top);
for(int i = 0 ; i < fVolumes.size() ; i++){
top->AddNode(std::get<0>(fVolumes[i]), 1 , std::get<1>(fVolumes[i]));
}
top->SetLineColor(kGreen);
gGeoManager->CloseGeometry();
#ifndef USE_OGL
top->Draw();
#else
top->Draw("ogl"); //to display the geometry using openGL
#endif
//
//TPad::x3d("OPENGL");
gGeoManager->Export("plane.root");
//top->Export("planeTop.root");
//fApp->Run();
}
示例3: GetGeoVolume
TGeoVolume* KVSpectroDetector::GetGeoVolume(const Char_t* name, const Char_t* material, const Char_t* shape_name, const Char_t* params){
// Construct a TGeoVolume shape which can be used to represent
// a detector in the current geometry managed by gGeoManager.
// If the argument material is empty, the name of the detector is used.
// Input: name - name given to the volume.
// material - material of the volume. The list of available
// materials can be found with
// det->GetRangeTable()->GetListOfMaterials()->ls()
// where det is a KVSpectroDetector or another
// object inheriting from KVMaterial.
// shape_name - name of the shape associated to the volum
// (Box, Arb8, Cone, Sphere, ...), given
// by the short name of the shape used in
// the methods XXX:
// TGeoManger::MakeXXX(...)
TGeoMedium *med = GetGeoMedium(material);
if(!med) return NULL;
TString method = Form("Make%s",shape_name);
TString parameters = Form("%p,%p,%s",name,med,params);
Info("GetGeoVolume","Trying to run the command gGeoManager->%s(%s)",method.Data(),parameters.Data());
gGeoManager->Execute(method.Data(),parameters.Data());
TGeoVolume* vol = (TGeoVolume*)gGeoManager->GetListOfVolumes()->Last();
if(vol) vol->SetLineColor(med->GetMaterial()->GetDefaultColor());
return vol;
}
示例4: set_volume_color_by_material
void set_volume_color_by_material(const char* material_re, Color_t color, Char_t transparency=-1)
{
// Note: material_re is a perl regexp!
// If you want exact match, enclose in begin / end meta characters (^ / $):
// set_volume_color_by_material("^materials:Silicon$", kRed);
TPMERegexp re(material_re, "o");
TGeoMaterial *m;
TIter it(gGeoManager->GetListOfMaterials());
while ((m = (TGeoMaterial*) it()) != 0)
{
if (re.Match(m->GetName()))
{
if (transparency != -1)
{
m->SetTransparency(transparency);
}
TGeoVolume *v;
TIter it2(gGeoManager->GetListOfVolumes());
while ((v = (TGeoVolume*) it2()) != 0)
{
if (v->GetMaterial() == m)
{
v->SetLineColor(color);
}
}
}
}
full_update();
}
示例5: fw_simGeo_set_volume_color_by_material
void fw_simGeo_set_volume_color_by_material(const char* material_re, Bool_t use_names, Color_t color, Char_t transparency=-1)
{
// Note: material_re is a perl regexp!
// If you want exact match, enclose in begin / end meta characters (^ / $):
// set_volume_color_by_material("^materials:Silicon$", kRed);
TPMERegexp re(material_re, "o");
TGeoMaterial *m;
TIter it(FWGeometryTableViewManager_GetGeoManager()->GetListOfMaterials());
while ((m = (TGeoMaterial*) it()) != 0)
{
if (re.Match(use_names ? m->GetName() : m->GetTitle()))
{
if (transparency != -1)
{
m->SetTransparency(transparency);
}
TGeoVolume *v;
TIter it2(FWGeometryTableViewManager_GetGeoManager()->GetListOfVolumes());
while ((v = (TGeoVolume*) it2()) != 0)
{
if (v->GetMaterial() == m)
{
v->SetLineColor(color);
}
}
}
}
}
示例6: create_new_tof_module
TGeoVolume* create_new_tof_module(Int_t modType)
{
Int_t cType = CounterTypeInModule[modType];
Float_t dx=Module_Size_X[modType];
Float_t dy=Module_Size_Y[modType];
Float_t dz=Module_Size_Z[modType];
Float_t width_aluxl=Module_Thick_Alu_X_left;
Float_t width_aluxr=Module_Thick_Alu_X_right;
Float_t width_aluy=Module_Thick_Alu_Y;
Float_t width_aluz=Module_Thick_Alu_Z;
Float_t shift_gas_box = (Module_Thick_Alu_X_right - Module_Thick_Alu_X_left)/2;
Float_t dxpos=CounterXDistance[modType];
Float_t startxpos=CounterXStartPosition[modType];
Float_t dzoff=CounterZDistance[modType];
Float_t rotangle=CounterRotationAngle[modType];
TGeoMedium* boxVolMed = gGeoMan->GetMedium(BoxVolumeMedium);
TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
TString moduleName = Form("module_%d", modType);
TGeoBBox* module_box = new TGeoBBox("", dx/2., dy/2., dz/2.);
TGeoVolume* module =
new TGeoVolume(moduleName, module_box, boxVolMed);
module->SetLineColor(kGreen); // set line color for the alu box
module->SetTransparency(20); // set transparency for the TOF
TGeoBBox* gas_box = new TGeoBBox("", (dx-(width_aluxl+width_aluxr))/2., (dy-2*width_aluy)/2., (dz-2*width_aluz)/2.);
TGeoVolume* gas_box_vol =
new TGeoVolume("gas_box", gas_box, noActiveGasVolMed);
gas_box_vol->SetLineColor(kBlue); // set line color for the alu box
gas_box_vol->SetTransparency(50); // set transparency for the TOF
TGeoTranslation* gas_box_trans
= new TGeoTranslation("", shift_gas_box, 0., 0.);
module->AddNode(gas_box_vol, 0, gas_box_trans);
for (Int_t j=0; j< NCounterInModule[modType]; j++){ //loop over counters (modules)
Float_t zpos;
if (0 == modType || 3 == modType || 4 == modType || 5 == modType) {
zpos = dzoff *=-1;
} else {
zpos = 0.;
}
TGeoTranslation* counter_trans
= new TGeoTranslation("", startxpos+ j*dxpos , 0.0 , zpos);
TGeoRotation* counter_rot = new TGeoRotation();
counter_rot->RotateY(rotangle);
TGeoCombiTrans* counter_combi_trans = new TGeoCombiTrans(*counter_trans, *counter_rot);
gas_box_vol->AddNode(gCounter[cType], j, counter_combi_trans);
}
return module;
}
示例7: set_vis
void set_vis()
{
/// Macro for setting visualization for Example TR
if ( TString(gMC->GetName()) == "TGeant3TGeo" ) {
// Set drawing options
TGeoVolume* vol;
vol = gGeoManager->GetVolume("Radiator");
if (vol) vol->SetLineColor(kMagenta);
vol = gGeoManager->GetVolume("Absorber");
if (vol) vol->SetLineColor(kYellow);
gMC->SetCollectTracks(kTRUE);
}
if (TString(gMC->GetName()) == "TGeant4") {
// Setting Geant4 visualization
((TGeant4*)gMC)->ProcessGeantMacro("g4vis.in");
}
}
示例8: MakeCopyVolume
virtual TGeoVolume* MakeCopyVolume(TGeoShape *newshape) {
// make a copy of this volume. build a volume with same name, shape and medium
TGeoVolume *vol = _copyVol(newshape);
vol->SetVisibility(IsVisible());
vol->SetLineColor(GetLineColor());
vol->SetLineStyle(GetLineStyle());
vol->SetLineWidth(GetLineWidth());
vol->SetFillColor(GetFillColor());
vol->SetFillStyle(GetFillStyle());
vol->SetField(fField);
if (fFinder)
vol->SetFinder(fFinder);
CloneNodesAndConnect(vol);
((TObject*) vol)->SetBit(kVolumeClone);
return vol;
}
示例9: CloneVolume
virtual TGeoVolume* CloneVolume() const {
TGeoVolume *vol = _copyVol(fShape);
Int_t i;
// copy volume attributes
vol->SetLineColor(GetLineColor());
vol->SetLineStyle(GetLineStyle());
vol->SetLineWidth(GetLineWidth());
vol->SetFillColor(GetFillColor());
vol->SetFillStyle(GetFillStyle());
// copy other attributes
Int_t nbits = 8 * sizeof(UInt_t);
for (i = 0; i < nbits; i++)
vol->SetAttBit(1 << i, TGeoAtt::TestAttBit(1 << i));
for (i = 14; i < 24; i++)
vol->SetBit(1 << i, this->TGeoVolume::TestBit(1 << i));
// copy field
vol->SetField(fField);
// Set bits
for (i = 0; i < nbits; i++)
vol->SetBit(1 << i, this->TGeoVolume::TestBit(1 << i));
vol->SetBit(kVolumeClone);
// copy nodes
// CloneNodesAndConnect(vol);
vol->MakeCopyNodes(this);
// if volume is divided, copy finder
vol->SetFinder(fFinder);
// copy voxels
if (fVoxels) {
TGeoVoxelFinder *voxels = new TGeoVoxelFinder(vol);
vol->SetVoxelFinder(voxels);
}
// copy option, uid
vol->SetOption(fOption);
vol->SetNumber(fNumber);
vol->SetNtotal(fNtotal);
return vol;
}
示例10: makeGeom
void makeGeom()
{
//--- Definition of a simple geometry
// gSystem->Load("libGeom");
new TGeoManager("genfitGeom", "GENFIT geometry");
gROOT->Macro("../../geometry/media.C");
TGeoMedium *vacuum = gGeoManager->GetMedium("vacuum");
assert(vacuum!=NULL);
TGeoMedium *air = gGeoManager->GetMedium("air");
assert(air!=NULL);
TGeoMedium *sil = gGeoManager->GetMedium("silicon");
assert(sil!=NULL);
TGeoVolume *top = gGeoManager->MakeBox("TOPPER", vacuum, 500., 500., 500.);
gGeoManager->SetTopVolume(top); // mandatory !
TGeoVolume *redBullCan = gGeoManager->MakeTube("redBullCan", sil, 3.-5.e-3, 3., 10.);//, 90., 270.);
redBullCan->SetLineColor(kRed);
//top->AddNode(redBullCan, 1, gGeoIdentity);
TGeoVolume *redBullCan2 = gGeoManager->MakeTube("redBullCan2", sil, 4.-5.e-3, 4., 10.);//, 90., 270.);
redBullCan2->SetLineColor(kRed);
//top->AddNode(redBullCan2, 1, gGeoIdentity);
//--- close the geometry
gGeoManager->CloseGeometry();
//--- draw the ROOT box
gGeoManager->SetVisLevel(10);
//top->Draw("ogl");
TFile *outfile = TFile::Open("genfitGeom.root","RECREATE");
gGeoManager->Write();
outfile->Close();
}
示例11: getModule
void getModule(TGeoManager* geom, TGeoVolume* top, TGeoVolume* mod){
//--- define some materials
TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7);
//--- define some media
TGeoMedium *Al = new TGeoMedium("Root Material",1, matAl);
TGeoVolume *refMod = geom->MakeBox( "refMod", Al, 0.5*_surWidth*_sclfmodulesizex, 0.5*_surLength*_sclfmodulesizey, 0.30*_sclfmodulesizez );
refMod->SetLineColor( 38 );
refMod->SetFillColor( 13 );
TGeoVolume *curMod = geom->MakeBox( "curMod", Al, 0.5*_surWidth*_sclfmodulesizex, 0.5*_surLength*_sclfmodulesizey, 0.30*_sclfmodulesizez );
if ((_yVal < 0)&&(_zVal>=0)) curMod->SetLineColor( kRed );
if ((_yVal < 0)&&(_zVal<0)) curMod->SetLineColor( kGreen );
if ((_yVal >= 0)&&(_zVal>=0)) curMod->SetLineColor( kBlue );
if ((_yVal >= 0)&&(_zVal<0)) curMod->SetLineColor( kMagenta );
refMod->SetLineColor( 14 );
//curMod->SetLineColor(kBlue);
//refMod->SetLineColor(kRed);
const Double_t radc = 180./TMath::Pi();
TGeoTranslation *tr1 = new TGeoTranslation( 0., 0., 0. );
TGeoRotation *rt1 = new TGeoRotation();
double rota[9];
rota[0] = _surRot[0]; rota[1] = _surRot[3]; rota[2] = _surRot[6];
rota[3] = _surRot[1]; rota[4] = _surRot[4]; rota[5] = _surRot[7];
rota[6] = _surRot[2]; rota[7] = _surRot[5]; rota[8] = _surRot[8];
rt1->SetMatrix( rota );
TGeoTranslation *tr2 = new TGeoTranslation( _sclftr*_dxVal, _sclftr*_dyVal, _sclftr*_dzVal );
TGeoRotation *rt2 = new TGeoRotation( "rt2", _sclfrt*_dalphaVal*radc, _sclfrt*_dbetaVal*radc, _sclfrt*_dgammaVal*radc );
rt2->MultiplyBy( rt1 );
TGeoCombiTrans *combi1 = new TGeoCombiTrans( *tr1, *rt1 );
TGeoCombiTrans *combi2 = new TGeoCombiTrans( *tr2, *rt2 );
mod->AddNode( curMod, 1, combi2 );
mod->AddNode( refMod, 1, combi1 );
TGeoTranslation *trG = new TGeoTranslation( _xVal - _dxVal, _yVal - _dyVal, _zVal - _dzVal);
TGeoRotation *rtG = new TGeoRotation( "rtG", -1*_dalphaVal, -1*_dbetaVal, -1*_dgammaVal );
TGeoCombiTrans *combi = new TGeoCombiTrans( *trG, *rtG );
top->AddNode( mod, 1, combi );
}
示例12: create_new_counter
TGeoVolume* create_new_counter(Int_t modType)
{
//glass
Float_t gdx=Glass_X[modType];
Float_t gdy=Glass_Y[modType];
Float_t gdz=Glass_Z[modType];
//gas gap
Int_t nstrips=NumberOfReadoutStrips[modType];
Int_t ngaps=NumberOfGaps[modType];
Float_t ggdx=GasGap_X[modType];
Float_t ggdy=GasGap_Y[modType];
Float_t ggdz=GasGap_Z[modType];
Float_t gsdx=ggdx/(Float_t)(nstrips);
// electronics
//pcb dimensions
Float_t dxe=Electronics_X[modType];
Float_t dye=Electronics_Y[modType];
Float_t dze=Electronics_Z[modType];
Float_t yele=gdy/2.+dye/2.;
// counter size (calculate from glas, gap and electronics sizes)
Float_t cdx = TMath::Max(gdx, ggdx);
cdx = TMath::Max(cdx, dxe)+ 0.2;
Float_t cdy = TMath::Max(gdy, ggdy) + 2*dye + 0.2;
Float_t cdz = ngaps * (gdz+ggdz) + gdz + 0.2;
//calculate thickness and first position in coonter of single stack
Float_t dzpos=gdz+ggdz;
Float_t startzposglas=(-cdz+gdz)/2.;
Float_t startzposgas=-cdz/2.+ gdz + ggdz/2.;
// needed materials
TGeoMedium* glassPlateVolMed = gGeoMan->GetMedium(GlasMedium);
TGeoMedium* noActiveGasVolMed = gGeoMan->GetMedium(NoActivGasMedium);
TGeoMedium* activeGasVolMed = gGeoMan->GetMedium(ActivGasMedium);
TGeoMedium* electronicsVolMed = gGeoMan->GetMedium(ElectronicsMedium);
// define counter volume
TGeoBBox* counter_box = new TGeoBBox("", cdx/2., cdy/2., cdz/2.);
TGeoVolume* counter =
new TGeoVolume("counter", counter_box, noActiveGasVolMed);
counter->SetLineColor(kCyan); // set line color for the counter
counter->SetTransparency(70); // set transparency for the TOF
// define single glass plate volume
TGeoBBox* glass_plate = new TGeoBBox("", gdx/2., gdy/2., gdz/2.);
TGeoVolume* glass_plate_vol =
new TGeoVolume("tof_glass", glass_plate, glassPlateVolMed);
glass_plate_vol->SetLineColor(kMagenta); // set line color for the glass plate
glass_plate_vol->SetTransparency(20); // set transparency for the TOF
// define single gas gap volume
TGeoBBox* gas_gap = new TGeoBBox("", ggdx/2., ggdy/2., ggdz/2.);
TGeoVolume* gas_gap_vol =
new TGeoVolume("Gap", gas_gap, activeGasVolMed);
gas_gap_vol->Divide("Cell",1,nstrips,-ggdx/2.,0);
gas_gap_vol->SetLineColor(kRed); // set line color for the gas gap
gas_gap_vol->SetTransparency(99); // set transparency for the TOF
// place 8 gas gaps and 9 glas plates in the counter
for( Int_t igap = 0; igap < ngaps; igap++) {
Float_t zpos_glas = startzposglas + igap*dzpos;
Float_t zpos_gas = startzposgas + igap*dzpos;
// cout <<"Zpos(Glas): "<< zpos_glas << endl;
// cout <<"Zpos(Gas): "<< zpos_gas << endl;
TGeoTranslation* glass_plate_trans
= new TGeoTranslation("", 0., 0., zpos_glas);
TGeoTranslation* gas_gap_trans
= new TGeoTranslation("", 0., 0., zpos_gas);
counter->AddNode(glass_plate_vol, igap, glass_plate_trans);
counter->AddNode(gas_gap_vol, igap, gas_gap_trans);
}
Float_t zpos_glas = startzposglas + (ngaps+1)*dzpos;
TGeoTranslation* glass_plate_trans
= new TGeoTranslation("", 0., 0., zpos_glas);
counter->AddNode(glass_plate_vol, ngaps, glass_plate_trans);
// create and place the electronics above and below the glas stack
TGeoBBox* pcb = new TGeoBBox("", dxe/2., dye/2., dze/2.);
TGeoVolume* pcb_vol =
new TGeoVolume("pcb", pcb, electronicsVolMed);
pcb_vol->SetLineColor(kCyan); // set line color for electronics
pcb_vol->SetTransparency(10); // set transparency for the TOF
for (Int_t l=0; l<2; l++){
yele *= -1.;
TGeoTranslation* pcb_trans
= new TGeoTranslation("", 0., yele, 0.);
counter->AddNode(pcb_vol, l, pcb_trans);
}
//.........这里部分代码省略.........
示例13: initializeTGeoDescription
/**
* Initialise ROOT geometry objects from GEAR objects
*
* @param geomName name of ROOT geometry object
* @param dumpRoot dump automatically generated ROOT geometry file for further inspection
*/
void EUTelGeometryTelescopeGeoDescription::initializeTGeoDescription( std::string& geomName, bool dumpRoot = false ) {
// #ifdef USE_TGEO
// get access to ROOT's geometry manager
if( _isGeoInitialized )
{
streamlog_out( WARNING3 ) << "EUTelGeometryTelescopeGeoDescription: Geometry already initialized, using old initialization" << std::endl;
return;
}
else
{
_geoManager = new TGeoManager("Telescope", "v0.1");
}
if( !_geoManager )
{
streamlog_out( ERROR3 ) << "Can't instantiate ROOT TGeoManager " << std::endl;
return;
}
// Create top world volume containing telescope/DUT geometry
// Create air mixture
// see http://pdg.lbl.gov/2013/AtomicNuclearProperties/HTML_PAGES/104.html
double air_density = 1.2e-3; // g/cm^3
double air_radlen = 36.62; // g/cm^2
TGeoMixture* pMatAir = new TGeoMixture("AIR",3,air_density);
pMatAir->DefineElement(0, 14.007, 7., 0.755267 ); //Nitrogen
pMatAir->DefineElement(1, 15.999, 8., 0.231781 ); //Oxygen
pMatAir->DefineElement(2, 39.948, 18., 0.012827 ); //Argon
pMatAir->DefineElement(3, 12.011, 6., 0.000124 ); //Carbon
pMatAir->SetRadLen( air_radlen );
// Medium: medium_World_AIR
TGeoMedium* pMedAir = new TGeoMedium("medium_World_AIR", 3, pMatAir );
// The World is the 10 x 10m x 10m box filled with air mixture
Double_t dx,dy,dz;
dx = 5000.000000; // [mm]
dy = 5000.000000; // [mm]
dz = 5000.000000; // [mm]
TGeoShape *pBoxWorld = new TGeoBBox("Box_World", dx,dy,dz);
// Volume: volume_World
TGeoVolume* pvolumeWorld = new TGeoVolume("volume_World",pBoxWorld, pMedAir);
pvolumeWorld->SetLineColor(4);
pvolumeWorld->SetLineWidth(3);
pvolumeWorld->SetVisLeaves(kTRUE);
// Set top volume of geometry
gGeoManager->SetTopVolume( pvolumeWorld );
// Iterate over registered GEAR objects and construct their TGeo representation
const Double_t PI = 3.141592653589793;
const Double_t DEG = 180./PI;
double xc, yc, zc; // volume center position
double alpha, beta, gamma;
IntVec::const_iterator itrPlaneId;
for ( itrPlaneId = _sensorIDVec.begin(); itrPlaneId != _sensorIDVec.end(); ++itrPlaneId ) {
std::stringstream strId;
strId << *itrPlaneId;
// Get sensor center position
xc = siPlaneXPosition( *itrPlaneId );
yc = siPlaneYPosition( *itrPlaneId );
zc = siPlaneZPosition( *itrPlaneId );
// Get sensor orientation
alpha = siPlaneXRotation( *itrPlaneId ); // [rad]
beta = siPlaneYRotation( *itrPlaneId ); // [rad]
gamma = siPlaneZRotation( *itrPlaneId ); // [rad]
// Spatial translations of the sensor center
string stTranslationName = "matrixTranslationSensor";
stTranslationName.append( strId.str() );
TGeoTranslation* pMatrixTrans = new TGeoTranslation( stTranslationName.c_str(), xc, yc, zc );
//ALL clsses deriving from TGeoMatrix are not owned by the ROOT geometry manager, invoking RegisterYourself() transfers
//ownership and thus ROOT will clean up
pMatrixTrans->RegisterYourself();
// Spatial rotation around sensor center
// TGeoRotation requires Euler angles in degrees
string stRotationName = "matrixRotationSensorX";
stRotationName.append( strId.str() );
TGeoRotation* pMatrixRotX = new TGeoRotation( stRotationName.c_str(), 0., alpha*DEG, 0.); // around X axis
stRotationName = "matrixRotationSensorY";
stRotationName.append( strId.str() );
TGeoRotation* pMatrixRotY = new TGeoRotation( stRotationName.c_str(), 90., beta*DEG, 0.); // around Y axis (combination of rotation around Z axis and new X axis)
//.........这里部分代码省略.........
示例14: south_gate
void south_gate()
{
// Drawing a famous Korean gate, the South gate, called Namdeamoon in Korean, using ROOT geometry class.
// Name: south_gate.C
// Author: Lan Hee Yang([email protected]), Dept. of Physics, Univ. of Seoul
// Reviewed by Sunman Kim ([email protected])
// Supervisor: Prof. Inkyu Park ([email protected])
//
// How to run: .x south_gate.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);//a,z,rho
TGeoMaterial *Fe=new TGeoMaterial("Fe",55.845,26,7.87);
//Creat media
TGeoMedium *Air = new TGeoMedium("Vacuum",0,vacuum);
TGeoMedium *Iron = new TGeoMedium("Iron",1,Fe);
//Creat volume
TGeoVolume *top = geom->MakeBox("top",Air,1000,1000,1000);
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);
//base
char nBlocks[100];
int i=1;
int N = 0;
int f=0;
int di[2]; di[0] = 0; di[1] = 30;
TGeoVolume *mBlock;
while (f<11){
while (i<14){
if (i==6 && f<8){
i = i+3;
}
sprintf(nBlocks,"f%d_bg%d",f,N++);
mBlock = geom->MakeBox(nBlocks, Iron, 29,149,9);
mBlock->SetLineColor(20);
if (f<8){
if (i<=5 && f<8){
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-120-((i-1)*60)-di[f%2],5,5+(20*f)));
} else if (i>5 && f<8){
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(120+((i-9)*60) +di[f%2],5,5+(20*f)));
}
} else {
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-420+(i*60)-di[f%2],5,5+(20*f)));
}
i++;
if (i>=14 && f>=8 && f%2 == 1){
sprintf(nBlocks,"f%d_bg%d",f,N++);
mBlock = geom->MakeBox(nBlocks, Iron, 29,149,9);
mBlock->SetLineColor(20);
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-420+(i*60)-di[f%2],5,5+(20*f)));
i++;
}
if (f%2 ==0){
sprintf(nBlocks,"f%d_bg%d",f,N++);
mBlock = geom->MakeBox(nBlocks, Iron, 14.5,149,9);
mBlock->SetLineColor(20);
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-405,5,5+(20*f)));
sprintf(nBlocks,"f%d_bg%d",f,N++);
mBlock = geom->MakeBox(nBlocks, Iron, 14.5,149,9);
mBlock->SetLineColor(20);
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(405,5,5+(20*f)));
} else if (f<5){
sprintf(nBlocks,"f%d_bg%d",f,N++);
mBlock = geom->MakeBox(nBlocks, Iron, 14.5,149,9);
mBlock->SetLineColor(20);
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-105,5,5+(20*f)));
sprintf(nBlocks,"f%d_bg%d",f,N++);
mBlock = geom->MakeBox(nBlocks, Iron, 14.5,149,9);
mBlock->SetLineColor(20);
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(105,5,5+(20*f)));
}
}
sprintf(nBlocks,"f%d_bg%d",8,N++);
mBlock = geom->MakeBox(nBlocks, Iron, 40,149,9);
mBlock->SetLineColor(20);
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(-80,5,145));
sprintf(nBlocks,"f%d_bg%d",8,N++);
mBlock = geom->MakeBox(nBlocks, Iron, 40,149,9);
mBlock->SetLineColor(20);
top->AddNodeOverlap(mBlock,1,new TGeoTranslation(80,5,145));
sprintf(nBlocks,"f%d_bg%d",7,N++);
//.........这里部分代码省略.........
示例15: robot
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);
//.........这里部分代码省略.........