CbmRoot
Loading...
Searching...
No Matches
CbmTimeslicePixelHitSetDraw.cxx
Go to the documentation of this file.
1/* Copyright (C) 2009-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
6
7#include "CbmEvent.h" // for CbmEvent
8#include "CbmPixelHit.h" // for CbmPixelHit
9#include "CbmTimesliceManager.h" // for CbmTimesliceManager
10
11#include "FairDataSourceI.h" // for FairDataSourceI
12#include "FairTCASource.h" // for FairTCASource
13#include <Logger.h> // for LOG, Logger
14
15#include <Rtypes.h> // for ClassImp
16#include <TClonesArray.h> // for TClonesArray
17#include <TEveManager.h> // for TEveManager, gEve
18#include <TEvePointSet.h> // for TEvePointSet
19#include <TEveTreeTools.h> // for TEvePointSelectorConsumer, etc
20#include <TVector3.h> // for TVector3
21
22CbmTimeslicePixelHitSetDraw::CbmTimeslicePixelHitSetDraw(const char* name, Color_t color, Style_t mstyle,
23 Int_t iVerbose)
24 : FairPointSetDraw(name, color, mstyle, iVerbose)
25{
29 fLocalDataSourcePtr = new FairTCASource(GetName());
30 SetDataSource(fLocalDataSourcePtr);
31}
32
34{
35 LOG(debug) << "CbmTimeslicePixelHitSetDraw::Init()";
36
38 FairPointSetDraw::Init();
39
41 FairRootManager* fManager = FairRootManager::Instance();
42 fCbmEvents = dynamic_cast<TClonesArray*>(fManager->GetObject("CbmEvent"));
43 if (nullptr == fCbmEvents) {
44 LOG(fatal) << "CbmTimeslicePixelHitSetDraw::Init() => CbmEvents branch not found! Task will be deactivated";
45 SetActive(kFALSE);
46 }
47
50 std::string sName = GetName(); // Needed for comparisoon with string literal
51 if ("MvdHit" == sName) { //
53 }
54 else if ("StsHit" == sName) { //
56 }
57 else if ("RichHit" == sName) { //
59 }
60 else if ("MuchHit" == sName) { //
62 }
63 else if ("TrdHit" == sName) { //
65 }
66 else if ("TofHit" == sName) { //
68 }
69 else if ("PsdHit" == sName) { //
71 }
72 else if ("BmonHit" == sName) { //
74 }
75 else {
77 }
78
79 if (IsActive()) { return kSUCCESS; }
80 else {
81 return kERROR;
82 }
83}
84
85void CbmTimeslicePixelHitSetDraw::Exec(Option_t* /*option*/)
86{
87 fLocalDataSourcePtr->Reset();
88 fLocalDataSourcePtr->RetrieveData(CbmTimesliceManager::Instance()->GetTimesliceTime());
89
90 if (0 < fCbmEvents->GetEntriesFast()) {
92 GotoEvent(0);
93 }
94}
95
97{
98 LOG(debug) << "CbmTimeslicePixelHitSetDraw::GotoEvent " << uEventIdx << " target " << GetName();
99
100 if (fCbmEvents->GetEntriesFast() <= static_cast<Int_t>(uEventIdx)) {
101 LOG(fatal) << "CbmTimeslicePixelHitSetDraw::GotoEvent() => Failure, tried to load event " << uEventIdx
102 << " while only " << fCbmEvents->GetEntriesFast() << " events available in this TS!!!";
103 }
104
105 fEventIdx = uEventIdx;
106
107 CbmEvent* event = dynamic_cast<CbmEvent*>(fCbmEvents->At(uEventIdx));
108
109 int32_t iNbHitsInTs = fLocalDataSourcePtr->GetNData();
110 int32_t iNbHitsInEvent = event->GetNofData(fDataType);
111
112 if (iNbHitsInTs < iNbHitsInEvent) {
113 LOG(fatal) << "CbmTimeslicePixelHitSetDraw::GotoEvent() => Failure, more " << GetName() << " in event " << uEventIdx
114 << " than available in the TS: " << iNbHitsInEvent << " VS " << iNbHitsInTs;
115 }
116
117 if (CbmTimesliceManager::Instance()->GetClearHandler()) { //
118 Reset();
119 }
120
121 TEvePointSet* q = new TEvePointSet(GetName(), iNbHitsInEvent, TEvePointSelectorConsumer::kTVT_XYZ);
122 q->SetOwnIds(kTRUE);
123 q->SetMarkerColor(fColor);
124 q->SetMarkerSize(1.5);
125 q->SetMarkerStyle(fStyle);
126
127 for (int32_t iHitIdxInEvt = 0; iHitIdxInEvt < iNbHitsInEvent; ++iHitIdxInEvt) {
128 TVector3 vec(GetVector(fLocalDataSourcePtr->GetData(event->GetIndex(fDataType, iHitIdxInEvt))));
129 q->SetNextPoint(vec.X(), vec.Y(), vec.Z());
130 // q->SetPointId(GetValue(p, i));
131 }
132 gEve->AddElement(q);
133 gEve->Redraw3D(kFALSE);
134 fq = q;
135}
136
138{
139 if (fq != 0) {
140 fq->Reset();
141 gEve->RemoveElement(fq, CbmTimesliceManager::Instance());
142 }
143}
144
145
147{
148 CbmPixelHit* p = dynamic_cast<CbmPixelHit*>(obj);
149 if (nullptr == p) {
150 LOG(fatal) << "CbmTimesliceRecoTracks::GetVector() => Failure, object not derived from CbmPixelHit";
151 }
152 LOG(debug) << "-I- CbmTimeslicePixelHitSetDraw::GetVector: " << p->GetX() << " " << p->GetY() << " " << p->GetZ();
153 return TVector3(p->GetX(), p->GetY(), p->GetZ());
154}
155
156
ClassImp(CbmConverterManager)
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
size_t GetNofData() const
Definition CbmEvent.cxx:53
double GetZ() const
Definition CbmHit.h:71
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
static CbmTimesliceManager * Instance()
void GotoEvent(uint32_t uEventIdx)
Load hits from selected event in timeslice. RESERVED FOR GUI CALLS!
CbmTimeslicePixelHitSetDraw(const char *name, Color_t color, Style_t mstyle, Int_t iVerbose=1)
Constructor.
virtual void Exec(Option_t *option)