]>
Commit | Line | Data |
---|---|---|
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 | ||
14 | using namespace Reve; | |
15 | using namespace Alieve; | |
16 | ||
17 | //______________________________________________________________________ | |
18 | // TPCLoader | |
19 | // | |
20 | ||
21 | ClassImp(TPCLoader) | |
22 | ||
23 | TPCLoader::TPCLoader(const Text_t* n, const Text_t* t) : | |
24 | RenderElementList(n, t), | |
25 | ||
265ecb21 | 26 | fFile(), |
e9a38ea3 | 27 | fEvent(-1), |
8f50aad8 | 28 | fDoubleSR(kFALSE), |
e9a38ea3 | 29 | |
61eeeb0e | 30 | fTPCEquipementMap(), |
e9a38ea3 | 31 | fReader(0), |
32 | fData(0), | |
33 | ||
34 | fSec2Ds(36), | |
e7c8d6ca | 35 | fSec3Ds(36), |
36 | ||
265ecb21 | 37 | fSetInitSectorParams(kFALSE), |
38 | fInitMinTime(0), fInitMaxTime(460), fInitThreshold(5) | |
4a378d74 | 39 | {} |
e9a38ea3 | 40 | |
41 | TPCLoader::~TPCLoader() | |
42 | { | |
43 | delete fReader; | |
44 | delete fData; | |
45 | } | |
46 | ||
47 | /**************************************************************************/ | |
48 | ||
4a378d74 | 49 | void TPCLoader::RemoveElementLocal(RenderElement* el) |
50 | { | |
51 | for(Int_t i=0; i<36; ++i) { | |
52 | if(fSec2Ds[i] == el) fSec2Ds[i] = 0; | |
53 | if(fSec3Ds[i] == el) fSec3Ds[i] = 0; | |
54 | } | |
55 | ||
2caed564 | 56 | RenderElement::RemoveElementLocal(el); |
4a378d74 | 57 | } |
58 | ||
59 | void TPCLoader::RemoveElements() | |
60 | { | |
61 | for(Int_t i=0; i<36; ++i) { | |
62 | fSec2Ds[i] = 0; | |
63 | fSec3Ds[i] = 0; | |
64 | } | |
65 | ||
2caed564 | 66 | RenderElement::RemoveElements(); |
4a378d74 | 67 | } |
68 | ||
69 | /**************************************************************************/ | |
e9a38ea3 | 70 | |
71 | void TPCLoader::SetData(TPCData* d) | |
72 | { | |
73 | delete fData; | |
74 | fData = d; | |
75 | } | |
76 | ||
77 | /**************************************************************************/ | |
78 | ||
79 | void TPCLoader::OpenFile() | |
80 | { | |
81 | static const Exc_t eH("TPCLoader::OpenFile "); | |
82 | ||
83 | if(gSystem->AccessPathName(fFile, kReadPermission)) | |
84 | throw(eH + "can not read '" + fFile + "'."); | |
85 | ||
86 | if(fData == 0) | |
87 | fData = new TPCData; | |
88 | ||
89 | delete fReader; | |
90 | fReader = 0; | |
91 | fEvent = -1; | |
92 | ||
93 | fReader = new AliRawReaderRoot(fFile); | |
61eeeb0e | 94 | if(fTPCEquipementMap != "") |
95 | fReader->LoadEquipmentIdsMap | |
96 | (gSystem->ExpandPathName(fTPCEquipementMap.Data())); | |
e9a38ea3 | 97 | |
98 | NextEvent(); | |
99 | LoadEvent(); | |
100 | UpdateSectors(); | |
101 | } | |
102 | ||
103 | void TPCLoader::LoadEvent() | |
104 | { | |
105 | static const Exc_t eH("TPCLoader::LoadEvent "); | |
106 | ||
107 | if(fReader == 0) | |
108 | throw(eH + "data file not opened."); | |
109 | ||
110 | printf("Now loading event %d\n", fEvent); | |
111 | fReader->Reset(); | |
112 | AliTPCRawStream input(fReader); | |
113 | input.SetOldRCUFormat(kTRUE); | |
61eeeb0e | 114 | fReader->Select("TPC"); |
e9a38ea3 | 115 | |
116 | fData->DropAllSectors(); | |
117 | fData->LoadRaw(input, kTRUE, kTRUE); | |
118 | } | |
119 | ||
120 | void TPCLoader::NextEvent(Bool_t rewindOnEnd) | |
121 | { | |
122 | static const Exc_t eH("TPCLoader::NextEvent "); | |
123 | ||
124 | if(fReader == 0) | |
125 | throw(eH + "data file not opened."); | |
126 | ||
127 | if(fReader->NextEvent() == kTRUE) { | |
128 | ++fEvent; | |
129 | } else { | |
130 | if(fEvent == -1) | |
131 | throw(eH + "no events available."); | |
132 | if(rewindOnEnd) { | |
133 | printf("Reached end of stream (event=%d), rewinding to first event.\n", fEvent); | |
134 | fReader->RewindEvents(); | |
135 | fReader->NextEvent(); | |
136 | fEvent = 0; | |
137 | } else { | |
138 | throw(eH + "last event reached."); | |
139 | } | |
140 | } | |
141 | } | |
142 | ||
143 | void TPCLoader::GotoEvent(Int_t event) | |
144 | { | |
145 | static const Exc_t eH("TPCLoader::GotoEvent "); | |
146 | ||
147 | if(fReader == 0) | |
148 | throw(eH + "data file not opened."); | |
149 | ||
150 | if(event == fEvent) | |
151 | return; | |
152 | Bool_t checkEnd; | |
153 | if(event < fEvent) { | |
154 | fReader->RewindEvents(); | |
155 | fEvent = -1; | |
156 | checkEnd = kFALSE; | |
157 | } else { | |
158 | checkEnd = kTRUE; | |
159 | } | |
160 | do { | |
161 | NextEvent(); | |
162 | } while(fEvent != event && !(checkEnd == kTRUE && fEvent == 0)); | |
163 | LoadEvent(); | |
164 | UpdateSectors(); | |
165 | } | |
166 | ||
167 | /**************************************************************************/ | |
168 | ||
169 | void TPCLoader::UpdateSectors() | |
170 | { | |
171 | gReve->DisableRedraw(); | |
172 | for(Int_t i=0; i<=35; ++i) { | |
173 | if(fSec2Ds[i] != 0) { | |
174 | fSec2Ds[i]->IncRTS(); | |
175 | } else { | |
176 | TPCSectorData* sd = fData->GetSectorData(i); | |
177 | if(sd != 0) { | |
178 | TPCSector2D* s = new TPCSector2D(Form("Sector2D %d", i)); | |
179 | fSec2Ds[i] = s; | |
180 | s->SetSectorID(i); | |
181 | s->SetDataSource(fData); | |
8f50aad8 | 182 | |
183 | if(fDoubleSR) | |
184 | s->SetMaxTime(1023); | |
e9a38ea3 | 185 | |
e7c8d6ca | 186 | if(fSetInitSectorParams) { |
187 | s->SetMinTime(fInitMinTime); | |
188 | s->SetMaxTime(fInitMaxTime); | |
189 | s->SetThreshold(fInitThreshold); | |
190 | } | |
75a20dc1 | 191 | |
601bca51 | 192 | s->SetAutoTrans(kTRUE); |
e9a38ea3 | 193 | s->SetFrameColor(36); |
194 | ||
4a378d74 | 195 | gReve->AddRenderElement(this, s); |
e9a38ea3 | 196 | } |
197 | } | |
198 | ||
199 | if(fSec3Ds[i] != 0) { | |
200 | fSec3Ds[i]->IncRTS(); | |
201 | } | |
202 | } | |
203 | gReve->EnableRedraw(); | |
204 | } | |
205 | ||
c59e16e8 | 206 | void TPCLoader::ReloadSectors() |
207 | { | |
208 | LoadEvent(); | |
209 | UpdateSectors(); | |
210 | } | |
211 | ||
e9a38ea3 | 212 | void TPCLoader::CreateSectors3D() |
213 | { | |
214 | gReve->DisableRedraw(); | |
215 | for(Int_t i=0; i<=35; ++i) { | |
216 | TPCSectorData* sd = fData->GetSectorData(i); | |
217 | if(sd != 0 && fSec3Ds[i] == 0) { | |
218 | TPCSector3D* s = new TPCSector3D(Form("Sector3D %d", i)); | |
219 | fSec3Ds[i] = s; | |
220 | s->SetSectorID(i); | |
221 | s->SetDataSource(fData); | |
8f50aad8 | 222 | |
223 | if(fDoubleSR) | |
224 | s->SetDriftVel(2.273); | |
225 | if(fSec2Ds[i] != 0) | |
226 | s->CopyVizParams(*fSec2Ds[i]); | |
e9a38ea3 | 227 | |
601bca51 | 228 | s->SetAutoTrans(kTRUE); |
e9a38ea3 | 229 | s->SetFrameColor(36); |
230 | ||
4a378d74 | 231 | gReve->AddRenderElement(this, s); |
e9a38ea3 | 232 | } |
233 | } | |
234 | gReve->EnableRedraw(); | |
235 | } | |
236 | ||
237 | void TPCLoader::DeleteSectors3D() | |
238 | { | |
239 | gReve->DisableRedraw(); | |
240 | for(Int_t i=0; i<=35; ++i) { | |
241 | RenderElement* re = fSec3Ds[i]; | |
242 | if(re != 0) { | |
4a378d74 | 243 | gReve->RemoveRenderElement(this, re); |
244 | // delete re; // Done automatically. | |
e9a38ea3 | 245 | fSec3Ds[i] = 0; |
246 | } | |
247 | } | |
248 | gReve->EnableRedraw(); | |
249 | } | |
e7c8d6ca | 250 | |
251 | /**************************************************************************/ | |
252 | ||
253 | void TPCLoader::SetInitParams(Int_t mint, Int_t maxt, Int_t thr) | |
254 | { | |
255 | fSetInitSectorParams = kTRUE; | |
256 | fInitMinTime = mint; | |
257 | fInitMaxTime = maxt; | |
258 | fInitThreshold = thr; | |
259 | } |