Dear,
I am running root 4.01/04 under RedHat 9.0
I am using the TGeo classes in a project where I am doing some geometry monitoring of a detector.
Let say I have two classes one name “Plan” and the other name “Box”.
The boxes are objects which are fixed on the Plan.
Both object have pointers to a TGeoVolume, a TGeoRotation and a TGeoCombiTrans.
Here is a part of the file Plan.h
public:
TGeoVolume *fVolume;
TGeoCombiTrans *fVolCombiTrans;
TGeoRotation *fVolRotation;[/code]
This is the main program:
[code]
#include <TROOT.h>
#include <TCanvas.h>
#include <TApplication.h>
#include <TGeoManager.h>
#include <TGeoVolume.h>
#include <TGeoMatrix.h>
TGeoManager *geom;
TGeoMaterial *mat;
TGeoMedium *med0 ;
TGeoMedium *med1 ;
TGeoVolume *TOP ;
int main(int argc, char *argv[])
{
TApplication theApp("App", &argc, argv);
TCanvas *Canvas = new TCanvas("c1","c1");
Canvas->cd();
//--- Definition of a simple geometry
geom = new TGeoManager("GMS", "GMS Geometry");
//---> create some materials
mat = new TGeoMaterial("Vacuum",0,0,0);
mat->SetUniqueID(0);
mat = new TGeoMaterial("Al", 26.98,13,2.7);
mat->SetUniqueID(1);
//---> create mediums
med0 = new TGeoMedium("Vacuum",0,0,0,0,0,20,0.1000000E+11,0.212,0.1000000E-02,1.150551);
med1 = new TGeoMedium("Al",1,1,0,0,0,20,0.1000000E+11,0.212,0.1000000E-02,1.150551);
//Create Top volume
TOP = geom->MakeBox("TOP", med0, 20000, 20000, 2000);
geom->SetTopVolume(TOP);
TOP->SetVisibility(kFALSE);
Plan *plan= new Plan();
Box *box = new Box(plan);
//--- close the geometry
geom->CloseGeometry();
TOP->Draw();
theApp.Run();
delete plan;
delete med1;
delete med0;
delete mat;
delete geom;
}
[/code]
Here is part of the constructeur of "Plan":
[code] Plan::Plan()
{
sprintf(fName,"Chamber_%d",fID);
char Name[30], RotName[30];
sprintf(RotName,"Rot_%s",fName);
fVolRotation = new TGeoRotation(RotName, ang_th[0]*RadToDeg, ang_th[1]*RadToDeg, ang_th[2]*RadToDeg);
fVolCombiTrans = new TGeoCombiTrans(pos_th[0]*100.,pos_th[1]*100.,pos_th[2]*100., fVolRotation);
fVolume = geom->MakeBox(fName, med1, Size[0]/2.*100., Size[1]/2.*100., Size[2]/2.*100.);
fVolume->SetLineColor(kBlue);
TOP->AddNode(fVolume, 1, fVolCombiTrans);
}
And here part of the constructeur of box:
[code]Box::Box(Plan* Ch){
sprintf(fName,"Box_%d_%d_%d",fChID,fPlatformID,fLocationID);
char RotName[30];
sprintf(RotName,"Rot_%s",fName);
fVolume = geom->MakeBox(fName,med1, fVolSize[0]/2.*100., fVolSize[1]/2.*100., fVolSize[2]/2.*100.);
fVolRotation = new TGeoRotation(RotName, fAngles[0]*RadToDeg, fAngles[1]*RadToDeg, fAngles[2]*RadToDeg);
fVolCombiTrans = new TGeoCombiTrans(centre[0]*100.,centre[1]*100.,centre[2]*100.
, fVolRotation);
(Ch->fVolume)->AddNode(fVolume, 1, fVolCombiTrans);
}[/code]
I thank you in advance for your help,
Raphael