00001 class St_geant_Maker;
00002 St_geant_Maker *geant=0;
00003
00004 void GeomDrawUsage() {
00005 printf("\n");
00006 printf("Usage: root4star \'GeomDraw.C(const char *geomDescriptor,Float_t bombFactor=2.0, const char *outRootFile="")\' \n");
00007 printf("----- where \"geomDescriptor\" can be either \n");
00008 printf(" 1. STAR geometry version like \"year2003\" (see: http://www.star.bnl.gov/STAR/comp/prod/MCGeometry.html) \n");
00009 printf(" example: root4star \'GeomDraw.C(\"year2003\")\'\n");
00010 printf(" 2. the proper ZEBRA fz file, for example \n");
00011 printf(" example: root4star \'GeomDraw.C(\"/star/u/potekhin/gstardata/y2003x_complete.fz \")\'\n\n");
00012 printf(" \"Float_t bombFactor\" - the so-called \"bombFactor\" to get the exploiding view of the detector.\n");
00013 printf(" To get the normal view the bombFactor has to be set to 1.0\n");
00014 printf(" It is usually useless to apply bombFactor < 1.0 \n");
00015 printf("---------------\n");
00016 printf(" One can adjust the view via ROOT Browser or ROOT TCanvas \n");
00017 printf(" 1. Select the volume you are interesting in with left mouse button\n");
00018 printf(" 2. Bring the ROOT context menu up with the right mouse button click\n");
00019 printf(" 3. Select class method to execute and click it with left mouse button\n");
00020 printf("---------------\n");
00021 printf(" List of the usefull TVolume methods and its parameters:\n");
00022 printf(" 1. TVolume::Draw(const char *levels=\"3\") - \n");
00023 printf(" - define the number of the levels of the geometry hierarchy to be drawn\n");
00024 printf(" 2. TVolume::SetVisibility - \n");
00025 printf(" 0 - everything visible,\n");
00026 printf(" 2 - this invisible, but sons are visible\n");
00027 printf(" 1 - this visible but sons\n");
00028 printf(" 3 - neither this nor its sons are visible\n\n");
00029 printf("---------------\n");
00030 printf(" To get the OpenGL view one has to\n");
00031 printf(" 1. Turn Qt ROOT Layer on (see: http://www.rhic.bnl.gov/~fine/EventDisplay \n");
00032 printf(" 2. Select \"OpenGL view\" from the \"View\" menu of ROOT TCanvas \n");
00033 printf("---------------\n");
00034 printf(" To adjust the so-called bombFactor you can invoke \n");
00035 printf(" the C++ statement from the ROOT command prompt:\n\n");
00036 printf(" gGeometry->SetBomb(1.6);\n\n");
00037 printf(" To change the background color call:\\nn");
00038 printf(" gPad->SetFillColor(kWhite);\n\n");
00039 printf(" \"kWhite\" background is advised \n");
00040 printf(" if you want to print the image to the paper\n");
00041 printf("---------------\n");
00042
00043 printf("\n$Id: GeomDraw.C,v 1.10 2006/10/27 21:33:33 fine Exp $\n");
00044 }
00045
00046 void GeomDraw(const char *fzFile="complete",Float_t bombFactor=1.4, const char *out = "")
00047 {
00048
00049
00050
00051 TString geomAccess = fzFile;
00052 TString geomKuipCmd;
00053 if (gSystem->AccessPathName(geomAccess.Data()) )
00054 {
00055
00056 geomAccess.Strip(TString::kBoth);
00057 if (!geomAccess.CountChar(' ') && (geomAccess.First('y')==0 || geomAccess.First("complete") == 0 ) ) {
00058 geomKuipCmd = "detp geometry ";
00059 geomKuipCmd += geomAccess; geomAccess = "" ;
00060 } else {
00061 printf("\n *** Error *** Wrong input parameter: <%s>\n", fzFile);
00062 GeomDrawUsage();
00063 return;
00064 }
00065 }
00066
00067
00068
00069
00070
00071
00072
00073
00074 gSystem->Load("St_base");
00075 gSystem->Load("StChain");
00076 gSystem->Load("St_Tables");
00077 gSystem->Load("St_g2t.so");
00078 gSystem->Load("StarMagField");
00079 gSystem->Load("St_geant_Maker");
00080 gSystem->Load("StUtilities");
00081 chain = new StChain();
00082 geant = new St_geant_Maker();
00083 geant->SetActive(kFALSE);
00084 if (! geomAccess.IsNull() ) {
00085 printf("\n ----------------------------------------------------------\n");
00086 printf(" Draw the GEANT geometry from <%s> file\n", geomAccess.Data());
00087 printf(" ----------------------------------------------------------\n\n");
00088 geant->SetInputFile(geomAccess.Data());
00089 } else {
00090 printf("\n ----------------------------------------------------------\n");
00091 printf(" Draw the GEANT generated geometry <%s> \n", geomKuipCmd.Data());
00092 printf(" ----------------------------------------------------------\n\n");
00093 gSystem->Load("geometry");
00094 geant->LoadGeometry(geomKuipCmd.Data());
00095 }
00096 chain->Init();
00097 TVolume *v = (TVolume *)geant->Work();
00098 if (v) {
00099
00100 TVolume *cave = (TVolume *)v->FindByName("CAVE");
00101 if (cave) cave->SetVisibility(2);
00102 TVolume *hall = (TVolume *)v->FindByName("HALL");
00103 GeomDrawUsage();
00104 if (hall) {
00105 hall->SetVisibility(2);
00106 new TBrowser("STAR Geometry", hall);
00107 if (bombFactor < 1) bombFactor = 1.;
00108 gGeometry->SetBomb(bombFactor);
00109 hall->Draw("6");
00110 gPad->SetFillColor(kBlack);
00111 }
00112 gPad->Modified();
00113 gPad->Update();
00114 if (out && out[0]) {
00115 TFile outFile(out,"RECREATE");
00116 v->Write();
00117 outFile.Write();
00118 outFile.Close();
00119 }
00120 } else {
00121 fprintf(stderr,"\n\n, ** Error **, No suitable STAR geometry has been found. Abort !!! \n");
00122 }
00123
00124 }