CbmRoot
CbmPointSetArrayDraw.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmPointSetArrayDraw source file -----
3 // ----- Created 18/06/22 by J. Brandt -----
4 // ----- Following class FairPointSetDraw -----
5 // -------------------------------------------------------------------------
6 #include "CbmPointSetArrayDraw.h"
7 
8 #include "CbmPixelHit.h" // for CbmPixelHit
9 #include "CbmPointSetArray.h" // for CbmPointSetArray
10 #include "CbmTofHit.h" // for CbmTofHit
11 
12 #include <FairEventManager.h> // for FairEventManager
13 #include <FairLogger.h> // for LOG, Logger
14 #include <FairRootManager.h> // for FairRootManager
15 #include <FairTask.h> // for FairTask, InitStatus, kSUCCESS
16 
17 #include <Rtypes.h> // for kRed, ClassImp
18 #include <TClonesArray.h> // for TClonesArray
19 #include <TEveManager.h> // for TEveManager, gEve
20 #include <TEveTreeTools.h> // for TEvePointSelectorConsumer, TEvePointS...
21 #include <TGenericClassInfo.h> // for TGenericClassInfo
22 #include <TVector3.h> // for TVector3
23 
24 #include <iomanip> // for operator<<, setprecision
25 
26 // ----- Default constructor -------------------------------------------
28  : FairTask("CbmPointSetArrayDraw", 0)
29  , fVerbose(0)
30  , fPointList(nullptr)
31  , fEventManager(nullptr)
32  , fl(nullptr)
33  , fColor(0)
34  , fStyle(0)
35  , fTimeOffset(0)
36  , fTimeMax(0)
37  , fColorMode(1)
38  , fMarkerMode(1)
39  , fRender(kTRUE) {}
40 // -------------------------------------------------------------------------
41 
42 
43 // ----- Standard constructor ------------------------------------------
45  Int_t colorMode,
46  Int_t markerMode,
47  Int_t iVerbose,
48  Bool_t render)
49  : FairTask(name, iVerbose)
50  , fVerbose(iVerbose)
51  , fPointList(nullptr)
52  , fEventManager(nullptr)
53  , fl(nullptr)
54  , fColor(kRed)
55  , fStyle(4)
56  , fTimeOffset(0)
57  , fTimeMax(0)
58  , fColorMode(colorMode)
59  , fMarkerMode(markerMode)
60  , fRender(render) {}
61 // -------------------------------------------------------------------------
63  LOG(debug) << "CbmPointSetArrayDraw::Init()";
64  FairRootManager* fManager = FairRootManager::Instance();
65  fPointList = static_cast<TClonesArray*>(fManager->GetObject(GetName()));
66  if (fPointList == 0) {
67  LOG(warn) << "CbmPointSetArrayDraw::Init() branch " << GetName()
68  << " Not found! Task will be deactivated ";
69  SetActive(kFALSE);
70  }
71  LOG(debug1) << "CbmPointSetArrayDraw::Init() get track list" << fPointList;
72  fEventManager = FairEventManager::Instance();
73  LOG(debug1)
74  << "CbmPointSetArrayDraw::Init() get instance of FairEventManager ";
75  fl = 0;
76 
77  return kSUCCESS;
78 }
79 // -------------------------------------------------------------------------
80 void CbmPointSetArrayDraw::Exec(Option_t* /*option*/) {
81  if (IsActive()) {
82  Int_t npoints = fPointList->GetEntriesFast();
83  Reset();
84 
85  // initialize CbmPointSetArray to display set of hits
86  CbmPointSetArray* l = new CbmPointSetArray("TofHitTime", "");
89  l->SetSourceCS(TEvePointSelectorConsumer::kTVT_XYZ);
90  l->SetMarkerColor(kRed);
91  l->SetMarkerStyle(4);
92  l->SetMarkerSize(2.0);
93 
95  l->InitBins("Hits", npoints, 0.5, npoints + 0.5);
96  l->InitValues(npoints);
97 
98  for (Int_t i = 1; i <= npoints; i++) { //loop over all hits in event
99  TObject* p = static_cast<TObject*>(fPointList->At(i - 1));
100  if (p != 0) {
101  TVector3 vec(GetVector(p));
102  l->Fill(vec.X(), vec.Y(), vec.Z(), i); // fill 3D position
103  l->FillValues(
104  GetPointId(p),
105  GetTime(p),
106  GetTot(p),
107  GetClusterSize(p),
108  i); // fill physical information used for color and markersize
109  }
110  }
111 
112  l->ApplyColorMode(); // apply colorMode and calculate color of each bin
113  l->ApplyMarkerMode(); // apply markerMode and calculate markersize of each bin
114  l->ApplyTitles(); // set BBox-title of each bin and computeBBox
115 
116  l->SetRnrChildren(fRender);
117  gEve->AddElement(l);
118  gEve->Redraw3D(kFALSE);
119  fl = l;
120  }
121 }
122 // --------------------------------------------------------------------------------
123 // returns 3D-vector with position data of hit
124 TVector3 CbmPointSetArrayDraw::GetVector(TObject* obj) {
125  CbmPixelHit* p = (CbmPixelHit*) obj;
126  LOG(debug2) << "-I- CbmPointSetArrayDraw::GetVector(): " << p->GetX() << " "
127  << p->GetY() << " " << p->GetZ() << " ";
128  return TVector3(p->GetX(), p->GetY(), p->GetZ());
129 }
130 // --------------------------------------------------------------------------------
131 // returns hit-time against first hit
132 Double_t CbmPointSetArrayDraw::GetTime(TObject* obj) {
133  CbmPixelHit* p = (CbmPixelHit*) obj;
134  LOG(debug2) << "-I- CbmPointSetArrayDraw::GetTime(): "
135  << p->GetTime() - fTimeOffset;
136  return p->GetTime() - fTimeOffset;
137 }
138 // --------------------------------------------------------------------------------
139 // returns ClusterSize of Hit
141  //CluSize of TofHit is stored in Flag-Variable (set in Clusterizer)
142  CbmTofHit* p = (CbmTofHit*) obj;
143  Double_t cluSize = p->GetFlag();
144  //Flag= #digis = 2*cluSize +100 if used for track
145  if (cluSize > 100) {
146  cluSize = (cluSize - 100) / 2;
147  } else {
148  cluSize /= 2;
149  }
150  LOG(debug3) << "-I- CbmPointSetArrayDraw::GetClusterSize(): " << cluSize;
151  return cluSize;
152 }
153 // --------------------------------------------------------------------------------
154 // returns ToT of hit
155 Double_t CbmPointSetArrayDraw::GetTot(TObject* obj) {
156  // ToT of TofHit is stored in Channel-Variable (set in Clusterizer)
157  CbmTofHit* p = (CbmTofHit*) obj;
158  Double_t tot = Double_t(p->GetCh()) / (20 * GetClusterSize(p));
159  LOG(debug3) << "-I- CbmPointSetArrayDraw::GetTot(): " << tot;
160  return tot;
161 }
162 // --------------------------------------------------------------------------------
163 // returns Id of hit
164 Int_t CbmPointSetArrayDraw::GetPointId(TObject* obj) {
165  CbmPixelHit* p = (CbmPixelHit*) obj;
166  return p->GetRefId();
167 }
168 // ---------------------------------------------------------------------------------
169 // Determine time of first hit in event to use as offset
171  Int_t npoints = fPointList->GetEntriesFast();
172  fTimeOffset = 115200000000000; //32hours in ns as maximum of clock
173  fTimeMax = 0;
174  Double_t currtime;
175  CbmPixelHit* hit;
176  for (Int_t i = 0; i < npoints; i++) { //loop over all hits in event
177  hit = static_cast<CbmPixelHit*>(fPointList->At(i));
178  currtime = hit->GetTime();
179  if (currtime < fTimeOffset) {
180  fTimeOffset = currtime;
181  } else if (currtime > fTimeMax) {
182  fTimeMax = currtime;
183  }
184  }
185  fTimeMax -= fTimeOffset; //time of latest hit in event
186  LOG(debug3) << std::setprecision(15)
187  << "-I- CbmPointSetArrayDraw::DetermineTimeBins: fTimeOffset "
188  << fTimeOffset;
189 }
190 
191 // ----- Destructor ----------------------------------------------------
193 // -------------------------------------------------------------------------
195 // -------------------------------------------------------------------------
198 // -------------------------------------------------------------------------
200  if (fl != 0) {
201  fl->RemoveElementsLocal();
202  gEve->RemoveElement(fl, fEventManager);
203  }
204 }
205 
206 
CbmHit::GetZ
Double_t GetZ() const
Definition: CbmHit.h:70
CbmPointSetArrayDraw
Definition: CbmPointSetArrayDraw.h:29
CbmPointSetArrayDraw::fEventManager
FairEventManager * fEventManager
Definition: CbmPointSetArrayDraw.h:83
CbmPointSetArray::ApplyColorMode
void ApplyColorMode()
Apply ColorMode to bins.
Definition: CbmPointSetArray.cxx:71
CbmPixelHit::GetX
Double_t GetX() const
Definition: CbmPixelHit.h:83
CbmPointSetArrayDraw::fColorMode
Int_t fColorMode
Definition: CbmPointSetArrayDraw.h:90
CbmPixelHit::GetY
Double_t GetY() const
Definition: CbmPixelHit.h:84
CbmPointSetArrayDraw::~CbmPointSetArrayDraw
virtual ~CbmPointSetArrayDraw()
Definition: CbmPointSetArrayDraw.cxx:192
CbmPointSetArray
Definition: CbmPointSetArray.h:23
CbmPointSetArray::ApplyMarkerMode
void ApplyMarkerMode()
Apply MarkerMode to bins.
Definition: CbmPointSetArray.cxx:126
CbmPointSetArrayDraw::fMarkerMode
Int_t fMarkerMode
Definition: CbmPointSetArrayDraw.h:91
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmPointSetArrayDraw::Reset
void Reset()
Definition: CbmPointSetArrayDraw.cxx:199
CbmHit::GetRefId
Int_t GetRefId() const
Definition: CbmHit.h:72
CbmPointSetArrayDraw.h
CbmTofHit::GetCh
Int_t GetCh() const
Definition: core/data/tof/CbmTofHit.h:92
CbmPointSetArrayDraw::fPointList
TClonesArray * fPointList
Definition: CbmPointSetArrayDraw.h:82
CbmPointSetArray::SetMarkerMode
void SetMarkerMode(Int_t markerMode)
Definition: CbmPointSetArray.h:45
CbmPointSetArrayDraw::fTimeMax
Double_t fTimeMax
Definition: CbmPointSetArrayDraw.h:89
ClassImp
ClassImp(CbmPointSetArrayDraw)
CbmPointSetArrayDraw::CbmPointSetArrayDraw
CbmPointSetArrayDraw()
Definition: CbmPointSetArrayDraw.cxx:27
CbmHit::GetTime
Double_t GetTime() const
Definition: CbmHit.h:75
CbmPointSetArrayDraw::fTimeOffset
Double_t fTimeOffset
Definition: CbmPointSetArrayDraw.h:88
CbmPointSetArray::FillValues
void FillValues(Int_t id, Double_t time, Double_t tot, Int_t cluSize, Int_t index)
FillQuantities.
Definition: CbmPointSetArray.cxx:57
CbmPointSetArrayDraw::fRender
Bool_t fRender
Definition: CbmPointSetArrayDraw.h:92
CbmPointSetArray.h
CbmPixelHit.h
CbmPointSetArray::SetColorMode
void SetColorMode(Int_t colorMode)
Definition: CbmPointSetArray.h:44
CbmPointSetArrayDraw::DetermineTimeOffset
void DetermineTimeOffset()
Definition: CbmPointSetArrayDraw.cxx:170
CbmTofHit::GetFlag
Int_t GetFlag() const
Definition: core/data/tof/CbmTofHit.h:91
CbmPointSetArrayDraw::GetVector
TVector3 GetVector(TObject *obj)
Definition: CbmPointSetArrayDraw.cxx:124
CbmPointSetArrayDraw::Finish
virtual void Finish()
Definition: CbmPointSetArrayDraw.cxx:197
CbmPointSetArrayDraw::SetParContainers
virtual void SetParContainers()
Definition: CbmPointSetArrayDraw.cxx:194
CbmPointSetArrayDraw::GetClusterSize
Int_t GetClusterSize(TObject *obj)
Definition: CbmPointSetArrayDraw.cxx:140
CbmPointSetArrayDraw::Exec
virtual void Exec(Option_t *option)
Definition: CbmPointSetArrayDraw.cxx:80
CbmPointSetArrayDraw::GetTot
Double_t GetTot(TObject *obj)
Definition: CbmPointSetArrayDraw.cxx:155
CbmPointSetArrayDraw::Init
virtual InitStatus Init()
Definition: CbmPointSetArrayDraw.cxx:62
CbmPointSetArrayDraw::GetPointId
Int_t GetPointId(TObject *obj)
Definition: CbmPointSetArrayDraw.cxx:164
CbmPixelHit
Definition: CbmPixelHit.h:21
CbmTofHit
Definition: core/data/tof/CbmTofHit.h:26
CbmPointSetArray::ApplyTitles
void ApplyTitles()
Apply BBox-Titles to all bins.
Definition: CbmPointSetArray.cxx:147
CbmPointSetArrayDraw::GetTime
Double_t GetTime(TObject *obj)
Definition: CbmPointSetArrayDraw.cxx:132
CbmPointSetArray::InitValues
void InitValues(Int_t npoints)
Init Arrays for physical Quantities.
Definition: CbmPointSetArray.cxx:46
CbmPointSetArrayDraw::fl
CbmPointSetArray * fl
Definition: CbmPointSetArrayDraw.h:85