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