StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GeomDraw.C
1 class St_geant_Maker;
2 St_geant_Maker *geant=0;
3 //_________________________________________________________________________________________________________________
4 void GeomDrawUsage() {
5  printf("\n");
6  printf("Usage: root4star \'GeomDraw.C(const char *geomDescriptor,Float_t bombFactor=2.0, const char *outRootFile="")\' \n");
7  printf("----- where \"geomDescriptor\" can be either \n");
8  printf(" 1. STAR geometry version like \"year2003\" (see: http://www.star.bnl.gov/STAR/comp/prod/MCGeometry.html) \n");
9  printf(" example: root4star \'GeomDraw.C(\"year2003\")\'\n");
10  printf(" 2. the proper ZEBRA fz file, for example \n");
11  printf(" example: root4star \'GeomDraw.C(\"/star/u/potekhin/gstardata/y2003x_complete.fz \")\'\n\n");
12  printf(" \"Float_t bombFactor\" - the so-called \"bombFactor\" to get the exploiding view of the detector.\n");
13  printf(" To get the normal view the bombFactor has to be set to 1.0\n");
14  printf(" It is usually useless to apply bombFactor < 1.0 \n");
15  printf("---------------\n");
16  printf(" One can adjust the view via ROOT Browser or ROOT TCanvas \n");
17  printf(" 1. Select the volume you are interesting in with left mouse button\n");
18  printf(" 2. Bring the ROOT context menu up with the right mouse button click\n");
19  printf(" 3. Select class method to execute and click it with left mouse button\n");
20  printf("---------------\n");
21  printf(" List of the usefull TVolume methods and its parameters:\n");
22  printf(" 1. TVolume::Draw(const char *levels=\"3\") - \n");
23  printf(" - define the number of the levels of the geometry hierarchy to be drawn\n");
24  printf(" 2. TVolume::SetVisibility - \n");
25  printf(" 0 - everything visible,\n");
26  printf(" 2 - this invisible, but sons are visible\n");
27  printf(" 1 - this visible but sons\n");
28  printf(" 3 - neither this nor its sons are visible\n\n");
29  printf("---------------\n");
30  printf(" To get the OpenGL view one has to\n");
31  printf(" 1. Turn Qt ROOT Layer on (see: http://www.rhic.bnl.gov/~fine/EventDisplay \n");
32  printf(" 2. Select \"OpenGL view\" from the \"View\" menu of ROOT TCanvas \n");
33  printf("---------------\n");
34  printf(" To adjust the so-called bombFactor you can invoke \n");
35  printf(" the C++ statement from the ROOT command prompt:\n\n");
36  printf(" gGeometry->SetBomb(1.6);\n\n");
37  printf(" To change the background color call:\\nn");
38  printf(" gPad->SetFillColor(kWhite);\n\n");
39  printf(" \"kWhite\" background is advised \n");
40  printf(" if you want to print the image to the paper\n");
41  printf("---------------\n");
42 
43  printf("\n$Id: GeomDraw.C,v 1.10 2006/10/27 21:33:33 fine Exp $\n");
44 }
45 //_____________________________________________________________________________________________________________
46 void GeomDraw(const char *fzFile="complete",Float_t bombFactor=1.4, const char *out = "")
47 {
48  // Read the ZEBRA file with GEANT geometry
49  // Convert it to TVolume format
50  // draw it out with OpenGL Viewer
51  TString geomAccess = fzFile;
52  TString geomKuipCmd;
53  if (gSystem->AccessPathName(geomAccess.Data()) )
54  {
55  // Check
56  geomAccess.Strip(TString::kBoth);
57  if (!geomAccess.CountChar(' ') && (geomAccess.First('y')==0 || geomAccess.First("complete") == 0 ) ) {
58  geomKuipCmd = "detp geometry ";
59  geomKuipCmd += geomAccess; geomAccess = "" ;
60  } else {
61  printf("\n *** Error *** Wrong input parameter: <%s>\n", fzFile);
62  GeomDrawUsage();
63  return;
64  }
65  }
66 
67  // Workaroung of STAR bug with ROOT 4.00.04
68  //- TString unixLDPath = "$ROOT/$ROOT_LEVEL.qt/.$STAR_HOST_SYS/rootdeb/lib:";
69  //- unixLDPath += gEnv->GetValue("Root.DynamicPath","");
70  //- gEnv->SetValue("Root.DynamicPath",unixLDPath.Data());
71  //- gSystem->Load("$ROOT/$ROOT_LEVEL.qt/.$STAR_HOST_SYS/rootdeb/lib/libRQTGL.so");
72  //- end of workaroung
73 
74  gSystem->Load("St_base");
75  gSystem->Load("StChain");
76  gSystem->Load("St_Tables");
77  gSystem->Load("St_g2t.so");
78  gSystem->Load("StarMagField");
79  gSystem->Load("St_geant_Maker");
80  gSystem->Load("StUtilities");
81  chain = new StChain();
82  geant = new St_geant_Maker();
83  geant->SetActive(kFALSE);
84  if (! geomAccess.IsNull() ) {
85  printf("\n ----------------------------------------------------------\n");
86  printf(" Draw the GEANT geometry from <%s> file\n", geomAccess.Data());
87  printf(" ----------------------------------------------------------\n\n");
88  geant->SetInputFile(geomAccess.Data());
89  } else {
90  printf("\n ----------------------------------------------------------\n");
91  printf(" Draw the GEANT generated geometry <%s> \n", geomKuipCmd.Data());
92  printf(" ----------------------------------------------------------\n\n");
93  gSystem->Load("geometry");
94  geant->LoadGeometry(geomKuipCmd.Data());
95  }
96  chain->Init();
97  TVolume *v = (TVolume *)geant->Work();
98  if (v) {
99  // Make CAVE invisible
100  TVolume *cave = (TVolume *)v->FindByName("CAVE");
101  if (cave) cave->SetVisibility(2);
102  TVolume *hall = (TVolume *)v->FindByName("HALL");
103  GeomDrawUsage();
104  if (hall) {
105  hall->SetVisibility(2);
106  new TBrowser("STAR Geometry", hall);
107  if (bombFactor < 1) bombFactor = 1.;
108  gGeometry->SetBomb(bombFactor);
109  hall->Draw("6");
110  gPad->SetFillColor(kBlack);
111  }
112  gPad->Modified();
113  gPad->Update();
114  if (out && out[0]) {
115  TFile outFile(out,"RECREATE");
116  v->Write();
117  outFile.Write();
118  outFile.Close();
119  }
120  } else {
121  fprintf(stderr,"\n\n, ** Error **, No suitable STAR geometry has been found. Abort !!! \n");
122  }
123 // delete chain; chain = 0;
124 }
virtual void Draw(Option_t *depth="3")
Definition: TVolume.cxx:433
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Definition: TDataSet.cxx:893
virtual void SetVisibility(ENodeSEEN vis=TVolume::kBothVisible)
Definition: TVolume.cxx:753
virtual TDataSet * FindByName(const char *name, const char *path="", Option_t *opt="") const
Definition: TDataSet.cxx:378
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
Definition: StMaker.h:208
virtual void LoadGeometry(const Char_t *option="detp geometry field_only")
Specifies GEANT3 geometry command.