FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairBoxSetDraw.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -------------------------------------------------------------------------
9 // ----- FairBoxSetDraw source file -----
10 // ----- Created 03/01/08 by M. Al-Turany -----
11 // -------------------------------------------------------------------------
12 #include "FairBoxSetDraw.h"
13 
14 #include "FairBoxSet.h" // for FairBoxSet
15 #include "FairEventManager.h" // for FairEventManager
16 #include "FairLogger.h"
17 #include "FairRootManager.h" // for FairRootManager
18 #include "FairRunAna.h" // for FairRunAna
19 #include "FairTCASource.h"
20 #include "FairTSBufferFunctional.h" // for StopTime
21 #include "FairTimeStamp.h" // for FairTimeStamp
22 
23 #include <TClonesArray.h> // for TClonesArray
24 #include <TEveBoxSet.h>
25 #include <TEveManager.h> // for TEveManager, gEve
26 #include <TVector3.h> // for TVector3
27 #include <iostream> // for operator<<, basic_ostream, etc
28 
30 Double_t fX, fY, fZ;
31 
33  : FairTask("FairBoxSetDraw", 0)
34  , fVerbose(0)
35 {}
36 
37 FairBoxSetDraw::FairBoxSetDraw(const char* name, FairDataSourceI* dataSource, Int_t iVerbose)
38  : FairTask(name, iVerbose)
39  , fVerbose(iVerbose)
40  , fDataSource(dataSource)
41 {}
42 
43 FairBoxSetDraw::FairBoxSetDraw(const char* name, Int_t iVerbose)
44  : FairTask(name, iVerbose)
45  , fVerbose(iVerbose)
46  , fDataSource(nullptr)
47 {}
48 
50 {
51  LOG(debug) << "FairBoxSetDraw::Init()";
52 
53  if (fDataSource == nullptr) {
54  fDataSource = new FairTCASource(GetName());
55  }
56 
57  if (fDataSource->Init() != kSUCCESS) {
58  LOG(error) << "FairBoxSetDraw::Init() branch " << GetName() << " Not found! Task will be deactivated ";
59  SetActive(kFALSE);
60  return kERROR;
61  }
62 
64 
65  fq = 0;
66 
67  return kSUCCESS;
68 }
69 
70 void FairBoxSetDraw::Exec(Option_t* /*option*/)
71 {
72  if (IsActive()) {
73  TObject* p;
74  Reset();
75  // cout<< "FairBoxSetDraw::Init() Exec! " << fList->GetEntriesFast() << endl;
76  CreateBoxSet();
77  if (FairEventManager::Instance()->GetClearHandler() == kTRUE) {
78  fDataSource->Reset();
79  }
81 
82  double tmin = -1.;
83  double tmax = -1.;
85  bool checkTime = tmin < tmax;
86 
87  for (Int_t i = 0; i < fDataSource->GetNData(); ++i) {
88  p = fDataSource->GetData(i);
89  if (checkTime) {
90  double time = fDataSource->GetTime(i);
91  if (time + fTimeWindowMinus > 0) {
92  if (time + fTimeWindowMinus < tmin || time - fTimeWindowPlus > tmax) {
93  continue;
94  }
95  }
96  }
97  AddBoxes(fq, p, i);
98  }
99  gEve->AddElement(fq, fEventManager);
100  gEve->Redraw3D(kFALSE);
101  }
102 }
103 
104 void FairBoxSetDraw::AddBoxes(FairBoxSet* set, TObject* obj, Int_t i)
105 {
106  TVector3 point = GetVector(obj);
107  set->AddBox(point.X(), point.Y(), point.Z());
108  set->DigitValue(GetValue(obj, i));
109  LOG(debug2) << "FairBoxSetDraw::Init() Add point " << i << ": " << point.X() << " " << point.Y() << " " << point.Z()
110  << " ";
111 }
112 
113 Int_t FairBoxSetDraw::GetValue(TObject* /*obj*/, Int_t i) { return i; }
114 
116 {
117  FairBoxSet* aBoxSet = new FairBoxSet(this, GetName());
118  aBoxSet->Reset(FairBoxSet::kBT_AABoxFixedDim, kFALSE, 64);
119  aBoxSet->SetDefWidth(fX);
120  aBoxSet->SetDefHeight(fY);
121  aBoxSet->SetDefDepth(fZ);
122  fq = aBoxSet;
123 
124  return aBoxSet;
125 }
126 
128 
130 
132 
134 
137 
139 {
140  if (fq != 0) {
141  fq->Reset();
142  gEve->RemoveElement(fq, fEventManager);
143  }
144 }
145 
FairEventManager * fEventManager
virtual void Exec(Option_t *option)
virtual InitStatus Init()
virtual Int_t GetValue(TObject *obj, Int_t i)
InitStatus
Definition: FairTask.h:33
virtual ~FairBoxSetDraw()
Float_t GetEvtTime()
current time in ns to display in the event display. Either set value or event time taken from FairRoo...
virtual void RetrieveData(double time)
FairDataSourceI * fDataSource
ClassImp(FairEventBuilder)
Double_t fTimeWindowPlus
Handles a TClonesArray as input object. No timebased operations are done and the TClonesArray is hand...
Definition: FairTCASource.h:19
Double_t fZ
FairBoxSet * fq
virtual TVector3 GetVector(TObject *obj)=0
virtual void Finish()
virtual void SetParContainers()
virtual double GetTime(int index)
virtual TObject * GetData(int index)=0
Double_t fY
void GetTimeLimits(Double_t &min, Double_t &max)
FairBoxSet * CreateBoxSet()
Abstract interface class to handle different input data for event and timebased data.
virtual void SetTimeWindowMinus(Double_t val)
virtual void Reset()=0
virtual void AddBoxes(FairBoxSet *set, TObject *obj, Int_t i=0)
static FairEventManager * Instance()
virtual int GetNData()=0
Double_t fX
Double_t fTimeWindowMinus
virtual InitStatus Init()
virtual void SetTimeWindowPlus(Double_t val)