00001 //*-- Author : Valery Fine 29/06/99 (E-mail: fine@bnl.gov) 00002 // $Id: St_geom_Maker.cxx,v 1.13 2009/01/21 18:58:59 fine Exp $ 00003 // $Log: St_geom_Maker.cxx,v $ 00004 // Revision 1.13 2009/01/21 18:58:59 fine 00005 // Draw the TGeoCompoisteShapes 00006 // 00007 // Revision 1.12 2007/04/19 23:27:58 fine 00008 // replace printf with LOG macro 00009 // 00010 // Revision 1.11 2001/06/01 03:04:25 perev 00011 // overloaded GetDataSet -> FindDataSet 00012 // 00013 // Revision 1.10 1999/11/21 01:40:48 fine 00014 // Temporary mark TPC and SVT modes unless Pavel does it 00015 // 00016 // Revision 1.9 1999/11/12 18:25:51 fine 00017 // Take in account GEANT maker 00018 // 00019 // Revision 1.8 1999/07/16 15:23:17 fisyak 00020 // Switch TWebFile => TFile 00021 // 00022 // Revision 1.7 1999/07/15 13:58:10 perev 00023 // cleanup 00024 // 00025 // Revision 1.6 1999/07/13 00:52:52 fine 00026 // Some corrections 00027 // 00028 // Revision 1.5 1999/07/02 20:04:11 fine 00029 // Init() can not be called from StDataSet since the last os const 00030 // 00031 // Revision 1.4 1999/07/02 20:01:21 fine 00032 // The name of the maker is the geom file name 00033 // 00034 // Revision 1.3 1999/06/30 16:27:41 fine 00035 // Comments make up 00036 // 00037 // Revision 1.2 1999/06/30 02:50:12 fine 00038 // Some comments 00039 // 00040 // Revision 1.1 1999/06/29 20:50:33 fine 00041 // Maker to provide a St_node geom structure for others 00042 // 00043 00045 // // 00046 // St_geom_Maker class for Makers // 00047 // // 00048 // This maker is to initialize the STAR GEANT geometry description. // 00049 // "Geometry description" is an instance of the St_Node class derived // 00050 // from St_DataSet class. // 00051 // // 00052 // This means one can apply St_DataSetIter and TBrowser to navigate it // 00053 // One can get a pointer to the top level St_Node object named "HALL" // 00054 // via // 00055 // St_Node *hallNode = (St_Node *)StMaker::GetDataSet("HALL") method // 00056 // // 00057 // It is assumed the St_geom_Maker object was instantiated and // 00058 // initialized by the the top level StChain object // 00059 // (see $STAR/StRoot/macros/graphics/PadBrowser.C macro as a pattern // 00060 // // 00061 // To get the ROOT Browser and graphics view of the full structure // 00062 // one try: // 00063 // ____________________________________________________________________ // 00064 // // 00065 // root [0] gSystem->Load("St_base"); 00066 // root [1] gSystem->Load("StChain"); 00067 // root [2] gSystem->Load("St_geom_Maker"); 00068 // root [3] St_geom_Maker geomMaker; 00069 // root [4] geomMaker.Init(); 00070 // 00071 // root [5] TBrowser b("HALL",geomMaker.GetDataSet("HALL")); 00072 // begin_html <P ALIGN=CENTER> <IMG SRC="gif/geomMakerBrowse.gif" ></P> end_html 00073 // root [6] ((St_Node *)geomMaker.GetDataSet("HALL"))->Draw(); 00074 // begin_html <P ALIGN=CENTER> <IMG SRC="gif/geomMakerPad.gif" ></P> end_html 00075 // root [7] // One can add two extra lines to get "Control Panel" 00076 // root [8] .x PadControlPanel.C 00077 // begin_html <P ALIGN=CENTER> <IMG SRC="gif/PadControlPanel.gif" ></P> end_html 00078 // root [9] // Plot 3D axice as follows: 00079 // root [10] St_PolyLine3D::Axis(); 00080 // ____________________________________________________________________ // 00081 // 00082 // Submit any problem with this code via begin_html <A HREF="http://www.rhic.bnl.gov/STAR/html/comp_l/sofi/bugs/send-pr.html"><B><I>"STAR Problem Report Form"</I></B></A> end_html 00083 // // 00085 00086 #include "St_geom_Maker.h" 00087 00088 #include "TWebFile.h" 00089 #include "TFile.h" 00090 #include "TGeometry.h" 00091 #include "TSystem.h" 00092 #include "TTUBE.h" 00093 00094 #include "StChain.h" 00095 #include "St_DataSetIter.h" 00096 #include "St_Node.h" 00097 ClassImp(St_geom_Maker) 00098 00099 //_____________________________________________________________________________ 00100 St_geom_Maker::St_geom_Maker(const char *name):StMaker(name){ 00101 00102 } 00103 //_____________________________________________________________________________ 00104 St_geom_Maker::~St_geom_Maker(){ 00105 //yf if (m_ConstSet) m_ConstSet->Delete(); 00106 } 00107 //_____________________________________________________________________________ 00108 St_DataSet *St_geom_Maker::FindDataSet (const char* logInput,const StMaker *uppMk, 00109 const StMaker *dowMk) const 00110 { 00111 St_DataSet *ds = StMaker::FindDataSet(logInput,uppMk,dowMk); 00112 if (!ds && strcmp(logInput,"HALL")==0) { 00113 #if 0 00114 Init(); 00115 ds = m_ConstSet->FindByName("HALL"); 00116 #endif 00117 } 00118 return ds; 00119 } 00120 //_____________________________________________________________________________ 00121 Int_t St_geom_Maker::Init() { 00122 //-- 00123 // reading STAR GEANT geometry database 00124 //-- 00125 PrintInfo(); 00126 #if 0 00127 TString fileName = "http://www.star.bnl.gov/~fine/"; 00128 fileName += GetName(); 00129 TWebFile *f = new TWebFile(fileName.Data()); 00130 #endif 00131 // Check whether GEANT maker is present 00132 if (GetMaker("geant")) return StMaker::Init(); 00133 00134 TString fileName = "$STAR/StDb/geometry/star.root.y1a"; 00135 gSystem->ExpandPathName(fileName); 00136 TFile *f = new TFile(fileName); 00137 // read STAR geometry database remotely 00138 TGeometry *star = (TGeometry *)f->Get("STAR"); 00139 star->SetName("STARGEOMNODE"); 00140 if (!star) { 00141 LOG_ERROR << "Sorry, STAR was not found !" << endm; 00142 return kStErr; 00143 } 00144 //-- 00145 // Remove hall from the list of ROOT nodes 00146 // to make it free of ROOT control 00147 //-- 00148 00149 TList *listOfNode = gGeometry->GetListOfNodes(); 00150 St_Node *hall = (St_Node *)listOfNode->First(); 00151 // Remove hall from the list of ROOT nodes to make it free of ROOT control 00152 listOfNode->Remove(hall); 00153 listOfNode->Remove(hall); 00154 // Artifact to be deleted just Pavel marks all volumes proeprly 00155 // --- Create "standard" TPC and SVT views ---- 00156 00157 // Create an iterator to navigate STAR geometry 00158 St_DataSetIter volume(hall,0); 00159 St_Node *sector = 0; 00160 const Char_t *volueNames[] = {"TPSS","SLDI","SFDM"}; 00161 const Int_t lvolueNames = sizeof(volueNames)/sizeof(Char_t *); 00162 while ( (sector = ( St_Node *)volume()) ){ 00163 Bool_t found = kFALSE; 00164 Int_t i; 00165 for (i =0; i < lvolueNames; i++) 00166 if (strcmp(sector->GetName(),volueNames[i]) == 0 ) {found = kTRUE; break; } 00167 if (found) { 00168 sector->SetVisibility(St_Node::kSonUnvisible); 00169 sector->Mark(); 00170 if (!i) { // special case for TPSS sectors 00171 TTUBE *tubs = (TTUBE *)sector->GetShape(); 00172 tubs->SetNumberOfDivisions(1); 00173 } 00174 } 00175 } 00176 00177 // Add "hall" into ".const" area of this maker 00178 AddConst(hall); 00179 if (Debug()) hall->ls(3); 00180 00181 return StMaker::Init(); 00182 } 00183 //_____________________________________________________________________________ 00184 Int_t St_geom_Maker::Make(){ 00185 // PrintInfo(); 00186 00187 return kStOK; 00188 } 00189 //_____________________________________________________________________________ 00190
1.5.9