BmnRoot
Loading...
Searching...
No Matches
MpdBoxSetDraw.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- MpdBoxSetDraw source file -----
3// ----- Created 03/01/08 by M. Al-Turany -----
4// -------------------------------------------------------------------------
5#include "MpdBoxSetDraw.h"
6#include "MpdBoxSet.h"
7
8#include "FairRunAna.h"
9
10#include "TEveManager.h" // for TEveManager, gEve
11
12#include <iostream>
13using namespace std;
14
15// ----- Default constructor -------------------------------------------
17 : FairTask("MpdBoxSetDraw", 0),
18 fVerbose(0),
19 fList(NULL),
20 fEventManager(NULL),
21 fManager(NULL),
22 fq(NULL),
23 fX(0.3),
24 fY(0.3),
25 fZ(0.3),
26 fTimeWindowPlus(0.),
27 fTimeWindowMinus(0.),
28 fStartTime(0.),
29 fUseEventTime(kTRUE),
30 isRedraw(kFALSE),
31 fStartFunctor(),
32 fStopFunctor()
33{
34}
35
36// ----- Standard constructor ------------------------------------------
37MpdBoxSetDraw::MpdBoxSetDraw(const char* name, Int_t iVerbose)
38 : FairTask(name, iVerbose),
39 fVerbose(iVerbose),
40 fList(NULL),
41 fEventManager(NULL),
42 fManager(NULL),
43 fq(NULL),
44 fX(0.3),
45 fY(0.3),
46 fZ(0.3),
47 fTimeWindowPlus(0.),
48 fTimeWindowMinus(0.),
49 fStartTime(0.),
50 fUseEventTime(kTRUE),
51 isRedraw(kFALSE),
52 fStartFunctor(),
53 fStopFunctor()
54{
55}
56
57// ----- Destructor ----------------------------------------------------
61
63{
64 if (fVerbose > 1) cout<<"MpdBoxSetDraw::Init()"<<endl;
65
66 fManager = FairRootManager::Instance();
67
68 fList = (TClonesArray*) FairRootManager::Instance()->GetObject(GetName());
69 if (fList == 0)
70 {
71 cout<<"MpdBoxSetDraw::Init() branch "<<GetName()<<" not found! Task will be deactivated"<<endl;
72 SetActive(kFALSE);
73 return kERROR;
74 }
75 if (fVerbose > 2) cout<<"MpdBoxSetDraw::Init() get track list "<<fList<<endl;
76
78 if (fVerbose > 2) cout<<"MpdBoxSetDraw::Init() get instance of MpdEventManager"<<endl;
79
80 fq = 0;
81 fStartFunctor = new StopTime();
82 fStopFunctor = new StopTime();
83
84 return kSUCCESS;
85}
86// -------------------------------------------------------------------------
87void MpdBoxSetDraw::Exec(Option_t* /*option*/)
88{
89 if (!IsActive())
90 return;
91
92 Reset();
93
95 if (FairRunAna::Instance()->IsTimeStamp())
96 {
97 fList->Clear();
98 Double_t eventTime = fManager->GetEventTime();
99 if (fUseEventTime)
100 fStartTime = eventTime - fTimeWindowMinus;
101 cout<<"EventTime: "<<eventTime<<" TimeWindow: "<<fStartTime<<" - "<<eventTime + fTimeWindowPlus<<endl;
102
103 fList = fManager->GetData(GetName(), fStartFunctor, fStartTime, fStopFunctor, eventTime + fTimeWindowPlus); //FairRootManager::Instance()->GetEventTime() +
104 }
105 if (fVerbose > 1) cout<<GetName()<<" fList: "<<fList->GetEntries()<<endl;
106
107 for (Int_t i = 0; i < fList->GetEntriesFast(); i++)
108 {
109 TObject* p = fList->At(i);
110 AddBoxes(fq, p, i);
111 }
112
113 gEve->AddElement(fq, fEventManager);
114 if (isRedraw) gEve->Redraw3D();
115}
116
117void MpdBoxSetDraw::AddBoxes(MpdBoxSet* set, TObject* obj, Int_t i)
118{
119 TVector3 point = GetVector(obj);
120 set->AddBox(point.X(), point.Y(), point.Z());
121 set->DigitValue(GetValue(obj, i));
122 if (fVerbose > 2) cout<<"MpdBoxSetDraw::Init() Add point "<<i<<": "<<point.X()<<" "<<point.Y()<<" "<<point.Z()<<" "<<endl;
123}
124
125
126Int_t MpdBoxSetDraw::GetValue(TObject* /*obj*/, Int_t i)
127{
128 return i;
129}
130
132{
133 MpdBoxSet* aBoxSet = new MpdBoxSet(this, GetName());
134 aBoxSet->Reset(MpdBoxSet::kBT_AABoxFixedDim, kFALSE, 64);
135 aBoxSet->SetDefWidth(fX);
136 aBoxSet->SetDefHeight(fY);
137 aBoxSet->SetDefDepth(fZ);
138
139 fq = aBoxSet;
140
141 return aBoxSet;
142}
143
147
150{
151}
152
154{
155 if (fq != 0)
156 {
157 fq->Reset();
158 gEve->RemoveElement(fq, fEventManager);
159 }
160}
int i
Definition P4_F32vec4.h:22
virtual TVector3 GetVector(TObject *obj)=0
TClonesArray * fList
virtual void SetParContainers()
Double_t fTimeWindowMinus
FairRootManager * fManager
virtual void Finish()
virtual void Exec(Option_t *option)
virtual void AddBoxes(MpdBoxSet *set, TObject *obj, Int_t i=0)
MpdBoxSet * CreateBoxSet()
virtual Int_t GetValue(TObject *obj, Int_t i)
Double_t fTimeWindowPlus
MpdEventManager * fEventManager
Bool_t fUseEventTime
MpdBoxSet * fq
virtual ~MpdBoxSetDraw()
Double_t fStartTime
virtual InitStatus Init()
static MpdEventManager * Instance()
STL namespace.