CbmRoot
Loading...
Searching...
No Matches
CbmTrdDigiDraw.cxx
Go to the documentation of this file.
1/* Copyright (C) 2008-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Mohammad Al-Turany, Florian Uhlig [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmTrdDigiDraw source file -----
7// ----- Created 03/01/08 by M. Al-Turany -----
8// -------------------------------------------------------------------------
9#include "CbmTrdDigiDraw.h"
10
11#include "CbmTrdAddress.h" // for CbmTrdAddress
12#include "CbmTrdDigi.h" // for CbmTrdDigi
13#include "CbmTrdParModDigi.h" // for CbmTrdParModDigi
14#include "CbmTrdParSetDigi.h" // for CbmTrdParSetDigi
15
16#include <FairEventManager.h> // for FairEventManager
17#include <FairRootManager.h> // for FairRootManager
18#include <FairRunAna.h> // for FairRunAna
19#include <FairRuntimeDb.h> // for FairRuntimeDb
20#include <Logger.h> // for Logger, LOG
21
22#include <TClonesArray.h> // for TClonesArray
23#include <TEveBoxSet.h> // for TEveBoxSet, TEveBoxSet::kBT_AABox
24#include <TEveManager.h> // for TEveManager, gEve
25#include <TVector3.h> // for TVector3
26
27#include <iomanip> // for setprecision
28
29using std::setprecision;
30
31// ----- Default constructor -------------------------------------------
33 : FairTask()
34 , fVerbose(0)
35 , fPointList(nullptr)
36 , fDigiPar(nullptr)
37 , fModuleInfo(nullptr)
38 , fEventManager(nullptr)
39 , fq(nullptr)
40 , fColor()
41 , fStyle()
42 , fActiveLayers()
43{
44}
45// -------------------------------------------------------------------------
46
47
48// ----- Standard constructor ------------------------------------------
49CbmTrdDigiDraw::CbmTrdDigiDraw(const char* name, Color_t color, Style_t mstyle, Int_t iVerbose)
50 : FairTask(name, iVerbose)
51 , fVerbose(iVerbose)
52 , fPointList(nullptr)
53 , fDigiPar(nullptr)
54 , fModuleInfo(nullptr)
55 , fEventManager(nullptr)
56 , fq(nullptr)
57 , fColor(color)
58 , fStyle(mstyle)
59 , fActiveLayers()
60{
61 for (Int_t i = 0; i < 15; i++) {
62 fActiveLayers[i] = kTRUE;
63 }
64}
65// ---- Initialisation ----------------------------------------------
67{
68 LOG(debug) << " * CbmTrdDigiDraw * :: SetParContainers() ";
69
70
71 // Get Base Container
72 FairRunAna* ana = FairRunAna::Instance();
73 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
74
75 fDigiPar = (CbmTrdParSetDigi*) (rtdb->getContainer("CbmTrdParSetDigi"));
76}
77// --------------------------------------------------------------------
78
79// -------------------------------------------------------------------------
81{
82 LOG(debug) << "CbmTrdDigiDraw::Init()";
83 FairRootManager* fManager = FairRootManager::Instance();
84 fPointList = (TClonesArray*) fManager->GetObject(GetName());
85 if (fPointList == 0) {
86 LOG(warn) << "CbmTrdDigiDraw::Init() branch " << GetName() << " Not found! Task will be deactivated ";
87 SetActive(kFALSE);
88 }
89 LOG(debug1) << "CbmTrdDigiDraw::Init() get track list" << fPointList;
90 fEventManager = FairEventManager::Instance();
91 LOG(debug1) << "CbmTrdDigiDraw::Init() get instance of FairEventManager ";
92 fq = 0;
93
94 // gEve->AddElement(fq, fEventManager );
95
96 return kSUCCESS;
97}
98// -------------------------------------------------------------------------
99void CbmTrdDigiDraw::Exec(Option_t* /*option*/)
100{
101 if (IsActive()) {
102
103 CbmTrdDigi* digi = 0;
104
105 Int_t npoints = fPointList->GetEntriesFast();
106 Reset();
107
108 TEveBoxSet* q = new TEveBoxSet(GetName(), "");
109 q->Reset(TEveBoxSet::kBT_AABox, kTRUE, npoints);
110 q->SetMainColor(kBlue);
111
112 // q->SetMainAlpha(1.);
113 // q->SetMarkerSize(1.5);
114 // q->SetMarkerStyle(fStyle);
115
116 // q->SetDefDepth();
117 // q->SetDefHeight();
118 // q->SetDefDepth();
119
120 Int_t refCounter = 0;
121
122 for (Int_t i = 0; i < npoints; ++i) {
123
124 digi = (CbmTrdDigi*) fPointList->At(i);
125
126
127 if (digi != 0) {
128
129
130 //Double_t ELoss = digi-> GetCharge();
131
132 Int_t address = digi->GetAddress();
133 Int_t Col = CbmTrdAddress::GetColumnId(address);
134 Int_t Row = CbmTrdAddress::GetRowId(address);
135 Int_t Sector = CbmTrdAddress::GetSectorId(address);
136 Int_t moduleId = CbmTrdAddress::GetModuleAddress(address);
137 Int_t layerId = CbmTrdAddress::GetLayerId(address);
138
140
141 TVector3 posHit, padSize;
143 /*moduleId, */ Sector, Col, Row, posHit, padSize);
144
145 // The given point is used as the edge of the box but it is
146 // the middle point of the pad. So we have to do a transformation
147
148
149 Double_t X = posHit.X() - (padSize.X() / 2);
150 Double_t Y = posHit.Y() - (padSize.Y() / 2);
151
152
153 // LOG(bebug1)<<"*** CbmTrdHitProducerDigi::CalculateHitPosition ***";
154 LOG(debug1) << "Col: " << Col;
155 LOG(debug1) << "Row: " << Row;
156 LOG(debug1) << setprecision(5) << "fPadX: " << padSize.X();
157 LOG(debug1) << setprecision(5) << "fPadY: " << padSize.Y();
158 LOG(debug1) << setprecision(5) << "fPosX: " << posHit.X();
159 LOG(debug1) << setprecision(5) << "fPosY: " << posHit.Y();
160 LOG(debug1) << setprecision(5) << "fPosZ: " << posHit.Z();
161
162 if (fActiveLayers[layerId]) {
163 q->AddBox(X, Y, posHit.Z(), padSize.X(), padSize.Y(), 0.);
164 refCounter++;
165 }
166 }
167 }
168 gEve->AddElement(q);
169 gEve->Redraw3D(kFALSE);
170 fq = q;
171 }
172}
173// ----- Destructor ----------------------------------------------------
175// -------------------------------------------------------------------------
176// -------------------------------------------------------------------------
179// -------------------------------------------------------------------------
181{
182 if (fq != 0) {
183 fq->Reset();
184 gEve->RemoveElement(fq, fEventManager);
185 }
186}
187
188void CbmTrdDigiDraw::SetActiveLayer(Bool_t Layer1, Bool_t Layer2, Bool_t Layer3, Bool_t Layer4, Bool_t Layer5,
189 Bool_t Layer6, Bool_t Layer7, Bool_t Layer8, Bool_t Layer9, Bool_t Layer10,
190 Bool_t Layer11, Bool_t Layer12, Bool_t Layer13, Bool_t Layer14, Bool_t Layer15)
191
192{
193 fActiveLayers[0] = Layer1;
194 fActiveLayers[1] = Layer2;
195 fActiveLayers[2] = Layer3;
196 fActiveLayers[3] = Layer4;
197 fActiveLayers[4] = Layer5;
198 fActiveLayers[5] = Layer6;
199 fActiveLayers[6] = Layer7;
200 fActiveLayers[7] = Layer8;
201 fActiveLayers[8] = Layer9;
202 fActiveLayers[9] = Layer10;
203 fActiveLayers[10] = Layer11;
204 fActiveLayers[11] = Layer12;
205 fActiveLayers[12] = Layer13;
206 fActiveLayers[13] = Layer14;
207 fActiveLayers[14] = Layer15;
208}
209
210
ClassImp(CbmConverterManager)
Helper class to convert unique channel ID back and forth.
static FairEventManager * fEventManager
static uint32_t GetSectorId(uint32_t address)
Return sector ID from address.
static uint32_t GetColumnId(uint32_t address)
Return column ID from address.
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.
static uint32_t GetModuleAddress(uint32_t address)
Return unique module ID from address.
static uint32_t GetRowId(uint32_t address)
Return row ID from address.
void SetActiveLayer(Bool_t Layer1=kTRUE, Bool_t Layer2=kFALSE, Bool_t Layer3=kFALSE, Bool_t Layer4=kFALSE, Bool_t Layer5=kFALSE, Bool_t Layer6=kFALSE, Bool_t Layer7=kFALSE, Bool_t Layer8=kFALSE, Bool_t Layer9=kFALSE, Bool_t Layer10=kFALSE, Bool_t Layer11=kFALSE, Bool_t Layer12=kFALSE, Bool_t Layer13=kFALSE, Bool_t Layer14=kFALSE, Bool_t Layer15=kFALSE)
TEveBoxSet * fq
virtual void Exec(Option_t *option)
virtual ~CbmTrdDigiDraw()
virtual InitStatus Init()
CbmTrdParSetDigi * fDigiPar
FairEventManager * fEventManager
virtual void SetParContainers()
Bool_t fActiveLayers[15]
virtual void Finish()
CbmTrdParModDigi * fModuleInfo
TClonesArray * fPointList
int32_t GetAddress() const
Address getter for module in the format defined by CbmTrdDigi (format of CbmTrdAddress can be accesse...
Definition CbmTrdDigi.h:112
Definition of chamber gain conversion for one TRD module.
void GetPosition(Int_t sectorId, Int_t columnId, Int_t rowId, TVector3 &padPos, TVector3 &padSize) const
virtual const CbmTrdParMod * GetModulePar(Int_t detId) const