EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FairPointSetDraw.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FairPointSetDraw.cxx
1 // -------------------------------------------------------------------------
2 // ----- FairPointSetDraw source file -----
3 // ----- Created 03/01/08 by M. Al-Turany -----
4 // -------------------------------------------------------------------------
5 
6 #include "FairPointSetDraw.h"
7 
8 #include "FairRootManager.h"
9 #include "FairEventManager.h"
10 
11 #include "TClonesArray.h"
12 #include "TEveManager.h"
13 #include "TEvePointSet.h"
14 #include "TEveTreeTools.h"
15 #include "TVector3.h"
16 
17 #include <iostream>
18 using std::cout;
19 using std::endl;
20 
21 // ----- Default constructor -------------------------------------------
23  : FairTask("FairPointSetDraw", 0),
24  fVerbose(0),
25  fPointList(NULL),
26  fEventManager(NULL),
27  fq(NULL),
28  fColor(0),
29  fStyle(0)
30 {
31 }
32 // -------------------------------------------------------------------------
33 
34 
35 
36 // ----- Standard constructor ------------------------------------------
37 FairPointSetDraw::FairPointSetDraw(const char* name, Color_t color ,Style_t mstyle,Int_t iVerbose)
38  : FairTask(name, iVerbose),
39  fVerbose(iVerbose),
40  fPointList(NULL),
41  fEventManager(NULL),
42  fq(NULL),
43  fColor(color),
44  fStyle(mstyle)
45 {
46 
47 }
48 // -------------------------------------------------------------------------
50 {
51  if(fVerbose>1) { cout<< "FairPointSetDraw::Init()" << endl; }
53  fPointList = (TClonesArray*)fManager->GetObject(GetName());
54  if(fPointList==0) {
55  cout << "FairPointSetDraw::Init() branch " << GetName() << " Not found! Task will be deactivated "<< endl;
56  SetActive(kFALSE);
57  }
58  if(fVerbose>2) { cout<< "FairPointSetDraw::Init() get track list" << fPointList<< endl; }
60  if(fVerbose>2) { cout<< "FairPointSetDraw::Init() get instance of FairEventManager " << endl; }
61  fq =0;
62 
63  // gEve->AddElement(fq, fEventManager );
64  return kSUCCESS;
65 }
66 // -------------------------------------------------------------------------
67 void FairPointSetDraw::Exec(Option_t* option)
68 {
69  if (IsActive()) {
70  Int_t npoints=fPointList->GetEntriesFast();
71  Reset();
72  TEvePointSet* q = new TEvePointSet(GetName(),npoints, TEvePointSelectorConsumer::kTVT_XYZ);
73  q->SetOwnIds(kTRUE);
74  q->SetMarkerColor(fColor);
75  q->SetMarkerSize(1.5);
76  q->SetMarkerStyle(fStyle);
77  //std::cout << "fPointList: " << fPointList << " " << fPointList->GetEntries() << std::endl;
78  for (Int_t i=0; i<npoints; ++i) {
79  TObject* p=(TObject*)fPointList->At(i);
80  if(p!=0) {
81  TVector3 vec(GetVector(p));
82  q->SetNextPoint(vec.X(),vec.Y(), vec.Z());
83  q->SetPointId(GetValue(p, i));
84  }
85  }
86  gEve->AddElement(q);
87  gEve->Redraw3D(kFALSE);
88  fq=q;
89  }
90 
91 }
92 
94 {
95  return new TNamed(Form("Point %d", i),"");
96 }
97 
98 // ----- Destructor ----------------------------------------------------
100 {
101 }
102 // -------------------------------------------------------------------------
104 {
105 
106 }
107 // -------------------------------------------------------------------------
110 {
111 }
112 // -------------------------------------------------------------------------
114 {
115  if(fq!=0) {
116  fq->Reset();
117  gEve->RemoveElement(fq, fEventManager );
118  }
119 }
120 
121 
123 
124