StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DrawTrackTpcHits.C
1 //*-- Author : Valery Fine 25/05/99 (E-mail: fine@bnl.gov)
2 // $Id: DrawTrackTpcHits.C,v 1.3 1999/06/27 22:45:34 fisyak Exp $
3 // $Log: DrawTrackTpcHits.C,v $
4 // Revision 1.3 1999/06/27 22:45:34 fisyak
5 // Merge StRootEvent and StEvent
6 //
7 // Revision 1.2 1999/06/24 16:49:00 fine
8 // StTrack.length method replaced the 120.0 cm constant
9 //
10 // Revision 1.1 1999/05/29 20:56:17 fine
11 // An example of 3D representation of StEventStGlobalTrack and StHits objects
12 //
13 {
14 //_______________________________________
15 //
16 // reading STAR GEANT geometry database
17 //_______________________________________
18  TCanvas *m_TreeD = new TCanvas("STAF","Events",10,600,200,200);
19  TFile f("/star/u2a/fine/WWW/star.root");
20  // TWebFile f("http://www.star.bnl.gov/~fine/star.root");
21  // read STAR geometry database remotely
22  TGeometry *star = f.Get("STAR");
23  if (!star) {
24  printf("Sorry, STAR was not found !\n");
25  return;
26  }
27  TList *listOfNode = star->GetListOfNodes();
28  St_Node *hall = listOfNode->First();
29  // Remove hall from the kist of ROOT nodes to make it free of ROOT control
30  listOfNode->Remove(hall);
31  listOfNode->Remove(hall);
32  St_DataSetIter volume(hall);
33 
34 //_______________________________________
35 //
36 // Creating tracks and hits shapes
37 //_______________________________________
38  St_Node *thisTrack = 0;
39 // StTpcHitCollection *t = ((StEvent *)Event)->tpcHitCollection();
40  StTrackCollection *tracks = ((StEvent *)Event)->trackCollection();
41  if (tracks) {
42  StGlobalTrackIterator next(tracks);
43  StGlobalTrack *globTrack = 0;
44  Int_t trackCounter = 0;
45  while (globTrack = (StGlobalTrack *)next() && trackCounter < 50) {
46  printf ("Track %d\n",trackCounter);
47  StVecPtrTpcHit *hits = globTrack->tpcHits();
48  StHits3DPoints *hitPoints = new StHits3DPoints(hits);
49  StHelix3DPoints *helixPoints = new StHelix3DPoints(globTrack,globTrack->length(),30);
50  if (hitPoints->Size()>1) {
51  St_PolyLineShape *trackShape = new St_PolyLineShape(hitPoints);
52  trackShape->SetVisibility(1); trackShape->SetColorAttribute(kYellow);
53  trackShape->SetLineStyle(1); trackShape->SetSizeAttribute(1);
54  }
55  Int_t colorIndx = trackCounter%7;
56  St_PolyLineShape *helixShape = new St_PolyLineShape(helixPoints,"L");
57  helixShape->SetVisibility(1); helixShape->SetColorAttribute(colorIndx+kGreen);
58  helixShape->SetLineStyle(1); helixShape->SetSizeAttribute(2);
59 
60  thisTrack = new St_Node("hits","hits",helixShape);
61  thisTrack->Mark(); thisTrack->SetVisibility();
62 
63  thisTrack->Add(trackShape);
64  St_NodePosition *pp = hall->Add(thisTrack);
65  trackCounter++;
66  if (!pp)
67  printf(" no position %d\n",trackCounter);
68  }
69  printf(" %d tracks has been found\n",trackCounter);
70  }
71 // hall->ls(2);
72 //_______________________________________
73 
74  gBenchmark->Stop("Draw time");
75 // Select sensors
76  fullView = new St_NodeView(*hall);
77  // Create the "open" sub-structure from the full one
78  sensible = new St_NodeView(fullView);
79  printf(" drawing the STAR geometry sensible volumes and hits \n");
80  //==== sensible->Draw();
81 
82 // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/HitsDrawFullView.gif"> </P> End_Html //
83 
84 //=== gPad->Update();
85 
86 //_______________________________________
87 //
88 // Make simple view
89 // Select node to be left
90 //_______________________________________
91  printf(" Marking the current structure to create another simplified one\n");
92  sensible->Mark(); // Select HALL
93  shortView = (St_NodeView *)sensible->FindByName("TPGV"); // Select TPGV
94  if (shortView) shortView->Mark();
95 
96 //_______________________________________
97 //
98 // Select all hits
99 //_______________________________________
100  St_DataSetIter nextHits(sensible);
101  while (shortView = (St_NodeView *) nextHits()) {
102  if (strcmp(shortView->GetName(),"ZCAL")==0) continue; // skip ZCAL detector element
103  shortView->Mark();
104  }
105 
106 //_______________________________________
107 //
108 // Create new short view // New "short" dataset
109 //_______________________________________
110  printf(" Creating a new structure simplified structure\n");
111  shortView = new St_NodeView(sensible);
112  TCanvas *m_simpleD = new TCanvas("Detector","Simple view and hits",500,500,400,400);
113  shortView->Draw("L");
114 
115  // Begin_Html <P ALIGN=CENTER> <IMG SRC="gif/HitsDrawSimpleView.gif"> </P> End_Html //
116 
117 //_______________________________________
118 //
119 // Final comments
120 //_______________________________________
121  printf(" Drawing the new structure simplified structure\n");
122  gPad->Update();
123  gBenchmark->Summary();
124  printf(" Drawing 3d solid view of the last structure\n");
125 
126 }
virtual TDataSet * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TDataSet.cxx:403
virtual Size_t SetSizeAttribute(Size_t size)
to be documented
virtual void Remove(TDataSet *set)
Remiove the &quot;set&quot; from this TDataSet.
Definition: TDataSet.cxx:641
virtual void SetVisibility(ENodeSEEN vis=TVolume::kBothVisible)
Definition: TVolume.cxx:753
virtual Color_t SetColorAttribute(Color_t color)
to be documented
Definition: AgUStep.h:26