Removed stale printout.
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCLoader.cxx
CommitLineData
e9a38ea3 1// $Header$
2
3#include "TPCLoader.h"
4#include "TPCData.h"
5#include <Alieve/TPCSector2D.h>
6#include <Alieve/TPCSector3D.h>
7#include <Reve/RGTopFrame.h>
8
9#include <AliRawReaderRoot.h>
10#include <AliTPCRawStream.h>
11
12#include <TSystem.h>
13
14using namespace Reve;
15using namespace Alieve;
16
17//______________________________________________________________________
18// TPCLoader
19//
20
21ClassImp(TPCLoader)
22
23TPCLoader::TPCLoader(const Text_t* n, const Text_t* t) :
24 RenderElementList(n, t),
25
26 fEvent(-1),
8f50aad8 27 fDoubleSR(kFALSE),
e9a38ea3 28
29 fReader(0),
30 fData(0),
31
32 fSec2Ds(36),
33 fSec3Ds(36)
34{
35 SetMainColorPtr(0);
36}
37
38TPCLoader::~TPCLoader()
39{
40 delete fReader;
41 delete fData;
42}
43
44/**************************************************************************/
45
46
47void TPCLoader::SetData(TPCData* d)
48{
49 delete fData;
50 fData = d;
51}
52
53/**************************************************************************/
54
55void TPCLoader::OpenFile()
56{
57 static const Exc_t eH("TPCLoader::OpenFile ");
58
59 if(gSystem->AccessPathName(fFile, kReadPermission))
60 throw(eH + "can not read '" + fFile + "'.");
61
62 if(fData == 0)
63 fData = new TPCData;
64
65 delete fReader;
66 fReader = 0;
67 fEvent = -1;
68
69 fReader = new AliRawReaderRoot(fFile);
70 fReader->LoadEquipmentIdsMap
71 (gSystem->ExpandPathName("$(ALICE_ROOT)/TPC/mapping/EquipmentIdMap.data"));
72
73 NextEvent();
74 LoadEvent();
75 UpdateSectors();
76}
77
78void TPCLoader::LoadEvent()
79{
80 static const Exc_t eH("TPCLoader::LoadEvent ");
81
82 if(fReader == 0)
83 throw(eH + "data file not opened.");
84
85 printf("Now loading event %d\n", fEvent);
86 fReader->Reset();
87 AliTPCRawStream input(fReader);
88 input.SetOldRCUFormat(kTRUE);
89 fReader->Select(0);
90
91 fData->DropAllSectors();
92 fData->LoadRaw(input, kTRUE, kTRUE);
93}
94
95void TPCLoader::NextEvent(Bool_t rewindOnEnd)
96{
97 static const Exc_t eH("TPCLoader::NextEvent ");
98
99 if(fReader == 0)
100 throw(eH + "data file not opened.");
101
102 if(fReader->NextEvent() == kTRUE) {
103 ++fEvent;
104 } else {
105 if(fEvent == -1)
106 throw(eH + "no events available.");
107 if(rewindOnEnd) {
108 printf("Reached end of stream (event=%d), rewinding to first event.\n", fEvent);
109 fReader->RewindEvents();
110 fReader->NextEvent();
111 fEvent = 0;
112 } else {
113 throw(eH + "last event reached.");
114 }
115 }
116}
117
118void TPCLoader::GotoEvent(Int_t event)
119{
120 static const Exc_t eH("TPCLoader::GotoEvent ");
121
122 if(fReader == 0)
123 throw(eH + "data file not opened.");
124
125 if(event == fEvent)
126 return;
127 Bool_t checkEnd;
128 if(event < fEvent) {
129 fReader->RewindEvents();
130 fEvent = -1;
131 checkEnd = kFALSE;
132 } else {
133 checkEnd = kTRUE;
134 }
135 do {
136 NextEvent();
137 } while(fEvent != event && !(checkEnd == kTRUE && fEvent == 0));
138 LoadEvent();
139 UpdateSectors();
140}
141
142/**************************************************************************/
143
144void TPCLoader::UpdateSectors()
145{
146 gReve->DisableRedraw();
147 for(Int_t i=0; i<=35; ++i) {
148 if(fSec2Ds[i] != 0) {
149 fSec2Ds[i]->IncRTS();
150 } else {
151 TPCSectorData* sd = fData->GetSectorData(i);
152 if(sd != 0) {
153 TPCSector2D* s = new TPCSector2D(Form("Sector2D %d", i));
154 fSec2Ds[i] = s;
155 s->SetSectorID(i);
156 s->SetDataSource(fData);
8f50aad8 157
158 if(fDoubleSR)
159 s->SetMaxTime(1023);
e9a38ea3 160
75a20dc1 161 // Hack for front/back pulse
162 s->SetMinTime(50);
163 s->SetMaxTime(980);
164 s->SetThreshold(10);
165
e9a38ea3 166 s->SetTrans(kTRUE);
167 s->SetFrameColor(36);
168
169 gReve->AddRenderElement(s);
170 gReve->DrawRenderElement(s);
171 }
172 }
173
174 if(fSec3Ds[i] != 0) {
175 fSec3Ds[i]->IncRTS();
176 }
177 }
178 gReve->EnableRedraw();
179}
180
181void TPCLoader::CreateSectors3D()
182{
183 gReve->DisableRedraw();
184 for(Int_t i=0; i<=35; ++i) {
185 TPCSectorData* sd = fData->GetSectorData(i);
186 if(sd != 0 && fSec3Ds[i] == 0) {
187 TPCSector3D* s = new TPCSector3D(Form("Sector3D %d", i));
188 fSec3Ds[i] = s;
189 s->SetSectorID(i);
190 s->SetDataSource(fData);
8f50aad8 191
192 if(fDoubleSR)
193 s->SetDriftVel(2.273);
194 if(fSec2Ds[i] != 0)
195 s->CopyVizParams(*fSec2Ds[i]);
e9a38ea3 196
197 s->SetTrans(kTRUE);
198 s->SetFrameColor(36);
199
200 gReve->AddRenderElement(s);
201 gReve->DrawRenderElement(s);
202 }
203 }
204 gReve->EnableRedraw();
205}
206
207void TPCLoader::DeleteSectors3D()
208{
209 gReve->DisableRedraw();
210 for(Int_t i=0; i<=35; ++i) {
211 RenderElement* re = fSec3Ds[i];
212 if(re != 0) {
213 gReve->UndrawRenderElement(re);
214 delete re;
215 fSec3Ds[i] = 0;
216 }
217 }
218 gReve->EnableRedraw();
219}