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