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