00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 class St_Node;
00034 class St_NodeView;
00035 class St_g2t_tpc_hit;
00036
00037
00038 St_Node *hall = 0;
00039 St_NodeView *fullView = 0;
00040 St_NodeView *shortView = 0;
00041 St_NodeView *sensible = 0;
00042 St_NodeView *singleSector = 0;
00043 St_g2t_tpc_hit *points = 0;
00044
00045
00046 Color_t trackColor(Long_t geantId)
00047 {
00048 Color_t color = kYellow;
00049 switch (geantId) {
00050 case 1:
00051 case 2:
00052 case 3:
00053 color = kRed;
00054 break;
00055 case 4:
00056 case 5:
00057 case 6:
00058 color = kGreen;
00059 break;
00060 case 7:
00061 case 8:
00062 case 9:
00063 color = kYellow;
00064 break;
00065 default:
00066 color = kBlue;
00067 };
00068 return color;
00069 }
00070
00071
00072
00073 void x3dHelpDraw(){
00074 TCanvas *paveCanvas = new TCanvas("x3d","X3D Help",500,20,540,220);
00075 TPaveText *label = new TPaveText(0,0,1,1);
00076 const Char_t *myMessage[] = {"Plot 3D view"
00077 ,"Note: Under Windows NT OpenGL will be used by default instead x3d for UNIX"
00078 ,"Select x3d windows and type \"m\" in there to get x3d HELP windows"
00079 ,"DON NOT FORGET to type \"q\" letter to terminate x3d widget"
00080 ,"to continue this session"};
00081
00082 Int_t lenMessage = 0;
00083 lenMessage = sizeof(myMessage)/4;
00084 Int_t j;
00085 label->Draw();
00086 for (j=lenMessage-1;j>0;j--) {
00087 label->InsertText(myMessage[j]);
00088 gPad->Update();
00089 }
00090 paveCanvas->Modified();
00091 paveCanvas->Update();
00092 }
00093
00094
00095
00096 void Load() {
00097 gSystem->Load("St_base");
00098 gSystem->Load("xdf2root");
00099 gSystem->Load("St_Tables");
00100 }
00101
00102
00103 void HitsDraw(){
00104 TCanvas *m_TreeD = new TCanvas("STAF","Events",10,600,200,200);
00105 Load();
00106
00107
00108
00109
00110
00111
00112
00113 TFile f("/star/u2a/fine/WWW/star.root");
00114
00115 TGeometry *star = f.Get("STAR");
00116 if (!star) {
00117 printf("Sorry, STAR was not found !\n");
00118 return;
00119 }
00120
00121
00122
00123
00124
00125 TList *listOfNode = gGeometry->GetListOfNodes();
00126 St_Node *hall = listOfNode->First();
00127
00128 listOfNode->Remove(hall);
00129 listOfNode->Remove(hall);
00130
00131
00132
00133
00134 St_DataSetIter volume(hall);
00135
00136
00137
00138
00139
00140
00141
00142 St_XDFFile file("/disk00000/star/test/dev/trs_Linux/Fri/year_1b/set0352_01_35evts.dst.xdf");
00143
00144 St_DataSet *skip = file.NextEventGet();
00145 if (skip) delete skip;
00146
00147 St_DataSet *muons = file.NextEventGet();
00148 if (!muons) return;
00149
00150
00151
00152
00153 St_DataSetIter next(muons);
00154 const Char_t *table = "event/geant/Event/g2t_tpc_hit";
00155 const Char_t *trackTable = "event/geant/Event/g2t_track";
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 points = (St_g2t_tpc_hit *)next(table);
00169 if (!points) {
00170 next.Du();
00171 return;
00172 }
00173 points->Print(0,10);
00174 g2t_tpc_hit_st *p = 0;
00175 if (points)
00176 g2t_tpc_hit_st *p = points->GetTable();
00177 else {
00178 printf("Error. The table <%s> was not found\n",table);
00179 return;
00180 }
00181
00182
00183
00184
00185
00186
00187
00188 St_g2t_track *trackT = (St_g2t_track *)next(trackTable);
00189 trackT->Print(0,10);
00190 g2t_track_st *geTrack = trackT->GetTable();
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 St_Table3Points *track = 0;
00204 TString tr;
00205 tr = "track_p";
00206 St_Table &ttt = *((St_Table *)points);
00207
00208
00209 St_TableSorter *Track2Line = new St_TableSorter (ttt,tr);
00210
00211 Int_t i = 0;
00212 Char_t buffer[10];
00213 Int_t ntracks = 0;
00214
00215 const Int_t maxtracks = 5;
00216
00217 gBenchmark->Start("Fill time");
00218
00219 long currentId = -1;
00220 long newId = 0;
00221 g2t_tpc_hit_st *hitPoint = 0;
00222 printf(" new track found:");
00223 St_Node *thisTrack[7] = {0,0,0,0,0,0,0};
00224 Int_t MaxRowtoCount = 5000;
00225 Int_t MaxTracks = Track2Line->CountKeys();
00226 printf(" Total tracks here %d \n",MaxTracks);
00227 MaxTracks = 100;
00228
00229 St_Node *allTracks = new St_Node(".hits","Global Hits", (TShape *)0);
00230 if (!allTracks) { printf("Bug !!!\n"); return; }
00231 allTracks->Mark();
00232 allTracks->SetVisibility();
00233 hall->Add(allTracks);
00234 for (i=0;i<Track2Line->GetNRows() && ntracks < MaxTracks ;i++)
00235 {
00236 hitPoint = p + Track2Line->GetIndex(i);
00237 newId = hitPoint->track_p;
00238
00239 if (newId != currentId) {
00240 printf(".");
00241 const Char_t *xName = "x[0]";
00242 const Char_t *yName = "x[1]";
00243 const Char_t *zName = "x[2]";
00244 track = new St_Table3Points(Track2Line,(const void *)&newId,xName,yName,zName);
00245
00246
00247 St_PolyLineShape *trackShape = new St_PolyLineShape(track);
00248 trackShape->SetVisibility(1);
00249 Int_t colorIndx = ntracks%7;
00250
00251 trackShape->SetColorAttribute(colorIndx+kGreen);
00252 trackShape->SetLineStyle(1); trackShape->SetSizeAttribute(2);
00253
00254 if (!thisTrack[colorIndx]) {
00255 thisTrack[colorIndx] = new St_Node("hits","hits",trackShape);
00256 thisTrack[colorIndx]->Mark(); thisTrack[colorIndx]->SetVisibility();
00257 St_NodePosition *pp = allTracks->Add(thisTrack[colorIndx]);
00258 if (!pp) printf(" no position %d\n",ntrack);
00259 }
00260 else
00261 thisTrack[colorIndx]->Add(trackShape);
00262 currentId = newId;
00263 ntracks++;
00264 }
00265 }
00266 printf("\n");
00267 printf("%d tracks have been read\n",ntracks);
00268 gBenchmark->Stop("Fill time");
00269
00270 printf(" Now we will try to draw something \n");
00271 Int_t irep;
00272 gBenchmark->Stop("Draw time");
00273
00274 ((St_Node *)volume.FindByName("ZCAL"))->SetVisibility(0);
00275 ((St_Node *)volume.FindByName("QDIV"))->SetVisibility(0);
00276 fullView = new St_NodeView(*hall);
00277
00278 sensible = new St_NodeView(fullView);
00279 printf(" drawing the STAR geometry sensible volumes and hits \n");
00280 sensible->Draw();
00281
00282
00283
00284 gPad->Update();
00285
00286 printf(" drawing the HELP windows\n");
00287
00288
00289
00290
00291 printf(" Marking the current structure to create another simplified one\n");
00292 sensible->Mark();
00293 shortView = (St_NodeView *)sensible->FindByName("TPGV");
00294 if (shortView) shortView->Mark();
00295
00296
00297 sensible->FindByName(".hits")->Mark();
00298 St_DataSetIter nextHits(sensible->FindByName(".hits"));
00299 while (shortView = (St_NodeView *) nextHits()) shortView->Mark();
00300
00301 nextHits.Reset(sensible);
00302 while (shortView = (St_NodeView *) nextHits()) {
00303 if (strcmp(shortView->GetName(),"ZCAL")==0) continue;
00304 shortView->Mark();
00305 }
00306
00307
00308 printf(" Creating a new structure simplified structure\n");
00309 shortView = new St_NodeView(sensible);
00310 TCanvas *m_simpleD = new TCanvas("Detector","Simple view and hits",500,500,400,400);
00311 shortView->Draw("L");
00312
00313
00314
00315 printf(" Drawing the new structure simplified structure\n");
00316 gPad->Update();
00317 gBenchmark->Summary();
00318 printf(" Drawing 3d solid view of the last structure\n");
00319
00320
00321
00322
00323 printf(" The following global variables are available:\n");
00324 printf("\tSt_Node *hall - \"closed\" full GEANT geometry structure\n");
00325 printf("\tSt_NodeView *fullView - \"open\" full GEANT geometry structure\n");
00326 printf("\tSt_NodeView *sensible - all \"sensible\" detector elements of the full GEANT structure\n");
00327 printf("\tSt_NodeView *shortView - subset of the structure above\n");
00328
00329
00330 St_NodeView *singleSector = new St_NodeView(fullView,".hits","TPSS");
00331 St_NodeView *sector = (St_NodeView *)singleSector->FindByName("TPSS");
00332 sector->SetVisibility(2);
00333 TCanvas *ccc = new TCanvas("STARTPC","Sectors",500,10,200,200);
00334 ccc.cd();
00335 singleSector->Draw();
00336 gPad->Update();
00337
00338 #if 1
00339 Float_t min[3];
00340 Float_t max[3];
00341 TVirtualPad *thisPad = gPad;
00342 TView *view = thisPad->GetView();
00343 sector->GetGlobalRange(singleSector,min,max);
00344 view->SetRange(min,max);
00345
00346 thisPad->Modified();
00347 thisPad->Update();
00348 #endif
00349
00350 }