]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
3 | ||
4 | /************************************************************************** | |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
9 | ||
10 | #include "AliEveTPCLoader.h" | |
11 | #include "AliEveTPCData.h" | |
b9df0156 | 12 | #include <AliEveTPCSector2D.h> |
13 | #include <AliEveTPCSector3D.h> | |
84aff7a4 | 14 | #include <TEveManager.h> |
15 | #include <TEveGedEditor.h> | |
e9a38ea3 | 16 | |
17 | #include <AliRawReaderRoot.h> | |
375fd576 | 18 | #include <AliTPCRawStreamV3.h> |
e9a38ea3 | 19 | |
20 | #include <TSystem.h> | |
d810d0de | 21 | |
a15e6d7d | 22 | //============================================================================== |
23 | //============================================================================== | |
24 | // AliEveTPCLoader | |
25 | //============================================================================== | |
e9a38ea3 | 26 | |
57ffa5fb | 27 | //______________________________________________________________________________ |
e9a38ea3 | 28 | // |
a97abca8 | 29 | // Front-end for stand-alone inspection of TPC raw-data. |
30 | // GUI is implemented in AliEveTPCLoaderEditor class. | |
e9a38ea3 | 31 | |
d810d0de | 32 | ClassImp(AliEveTPCLoader) |
e9a38ea3 | 33 | |
d810d0de | 34 | AliEveTPCLoader::AliEveTPCLoader(const Text_t* n, const Text_t* t) : |
84aff7a4 | 35 | TEveElementList(n, t), |
e9a38ea3 | 36 | |
265ecb21 | 37 | fFile(), |
e9a38ea3 | 38 | fEvent(-1), |
8f50aad8 | 39 | fDoubleSR(kFALSE), |
e9a38ea3 | 40 | |
61eeeb0e | 41 | fTPCEquipementMap(), |
e9a38ea3 | 42 | fReader(0), |
43 | fData(0), | |
44 | ||
45 | fSec2Ds(36), | |
e7c8d6ca | 46 | fSec3Ds(36), |
47 | ||
265ecb21 | 48 | fSetInitSectorParams(kFALSE), |
969e051c | 49 | fInitMinTime(0), fInitMaxTime(460), fInitThreshold(5), fInitMaxVal(128), |
50 | fCutOnEta(kFALSE), fEtaMax(1.5), fEtaMin(-1.5) | |
b1e0b894 | 51 | { |
a97abca8 | 52 | // Constructor. |
53 | ||
d810d0de | 54 | fData = new AliEveTPCData; |
b1e0b894 | 55 | } |
e9a38ea3 | 56 | |
d810d0de | 57 | AliEveTPCLoader::~AliEveTPCLoader() |
e9a38ea3 | 58 | { |
a97abca8 | 59 | // Destructor. |
60 | ||
e9a38ea3 | 61 | delete fReader; |
62 | delete fData; | |
63 | } | |
64 | ||
57ffa5fb | 65 | /******************************************************************************/ |
e9a38ea3 | 66 | |
d810d0de | 67 | void AliEveTPCLoader::RemoveElementLocal(TEveElement* el) |
4a378d74 | 68 | { |
a97abca8 | 69 | // Local removal an element, virtual from TEveElement. |
70 | // Need to search for it in visual sector representations and remove | |
71 | // it there as well. | |
72 | ||
73 | for (Int_t i=0; i<36; ++i) { | |
74 | if (fSec2Ds[i] == el) fSec2Ds[i] = 0; | |
75 | if (fSec3Ds[i] == el) fSec3Ds[i] = 0; | |
4a378d74 | 76 | } |
4a378d74 | 77 | } |
78 | ||
d810d0de | 79 | void AliEveTPCLoader::RemoveElementsLocal() |
4a378d74 | 80 | { |
a97abca8 | 81 | // Local removal of all elements, virtual from TEveElement. |
82 | // Must remove all visual sector representations. | |
83 | ||
84 | for (Int_t i=0; i<36; ++i) { | |
4a378d74 | 85 | fSec2Ds[i] = 0; |
86 | fSec3Ds[i] = 0; | |
87 | } | |
4a378d74 | 88 | } |
89 | ||
57ffa5fb | 90 | /******************************************************************************/ |
e9a38ea3 | 91 | |
d810d0de | 92 | void AliEveTPCLoader::SetData(AliEveTPCData* d) |
e9a38ea3 | 93 | { |
a97abca8 | 94 | // Set external TPC-data container. The old one is deleted. |
95 | ||
e9a38ea3 | 96 | delete fData; |
97 | fData = d; | |
98 | } | |
99 | ||
57ffa5fb | 100 | /******************************************************************************/ |
e9a38ea3 | 101 | |
d810d0de | 102 | void AliEveTPCLoader::OpenFile() |
e9a38ea3 | 103 | { |
a97abca8 | 104 | // Open the raw-data file, as set in fFile data-member. |
105 | // Raw-reader is also created and attached to the file. | |
106 | // First event is loaded and all sectors for which the data-exists | |
107 | // are created. | |
108 | ||
a15e6d7d | 109 | static const TEveException kEH("AliEveTPCLoader::OpenFile "); |
e9a38ea3 | 110 | |
a97abca8 | 111 | if (gSystem->AccessPathName(fFile, kReadPermission)) |
a15e6d7d | 112 | throw(kEH + "can not read '" + fFile + "'."); |
e9a38ea3 | 113 | |
b1e0b894 | 114 | fData->DeleteAllSectors(); |
e9a38ea3 | 115 | |
116 | delete fReader; | |
117 | fReader = 0; | |
118 | fEvent = -1; | |
119 | ||
120 | fReader = new AliRawReaderRoot(fFile); | |
a97abca8 | 121 | if (fTPCEquipementMap != "") |
61eeeb0e | 122 | fReader->LoadEquipmentIdsMap |
123 | (gSystem->ExpandPathName(fTPCEquipementMap.Data())); | |
e9a38ea3 | 124 | |
125 | NextEvent(); | |
126 | LoadEvent(); | |
42c8253f | 127 | UpdateSectors(kTRUE); |
e9a38ea3 | 128 | } |
129 | ||
d810d0de | 130 | void AliEveTPCLoader::LoadEvent() |
e9a38ea3 | 131 | { |
a97abca8 | 132 | // Load an event. |
133 | ||
a15e6d7d | 134 | static const TEveException kEH("AliEveTPCLoader::LoadEvent "); |
e9a38ea3 | 135 | |
a97abca8 | 136 | if (fReader == 0) |
a15e6d7d | 137 | throw(kEH + "data file not opened."); |
e9a38ea3 | 138 | |
139 | printf("Now loading event %d\n", fEvent); | |
140 | fReader->Reset(); | |
375fd576 | 141 | AliTPCRawStreamV3 input(fReader); |
61eeeb0e | 142 | fReader->Select("TPC"); |
e9a38ea3 | 143 | |
144 | fData->DropAllSectors(); | |
51346b82 | 145 | fData->LoadRaw(input, kTRUE, kTRUE); |
e9a38ea3 | 146 | } |
147 | ||
d810d0de | 148 | void AliEveTPCLoader::NextEvent(Bool_t rewindOnEnd) |
e9a38ea3 | 149 | { |
a97abca8 | 150 | // Go o the next event. |
151 | // When the last event is reached and rewindOnEnd is true, the file | |
152 | // is rewound back to the first event. Otherwise an exception is thrown. | |
153 | ||
a15e6d7d | 154 | static const TEveException kEH("AliEveTPCLoader::NextEvent "); |
e9a38ea3 | 155 | |
a97abca8 | 156 | if (fReader == 0) |
a15e6d7d | 157 | throw(kEH + "data file not opened."); |
e9a38ea3 | 158 | |
a97abca8 | 159 | if (fReader->NextEvent() == kTRUE) { |
e9a38ea3 | 160 | ++fEvent; |
161 | } else { | |
a97abca8 | 162 | if (fEvent == -1) |
a15e6d7d | 163 | throw(kEH + "no events available."); |
a97abca8 | 164 | if (rewindOnEnd) { |
e9a38ea3 | 165 | printf("Reached end of stream (event=%d), rewinding to first event.\n", fEvent); |
166 | fReader->RewindEvents(); | |
167 | fReader->NextEvent(); | |
168 | fEvent = 0; | |
169 | } else { | |
a15e6d7d | 170 | throw(kEH + "last event reached."); |
e9a38ea3 | 171 | } |
172 | } | |
173 | } | |
174 | ||
d810d0de | 175 | void AliEveTPCLoader::GotoEvent(Int_t event) |
e9a38ea3 | 176 | { |
a97abca8 | 177 | // Go to specified event. |
178 | ||
a15e6d7d | 179 | static const TEveException kEH("AliEveTPCLoader::GotoEvent "); |
e9a38ea3 | 180 | |
a97abca8 | 181 | if (fReader == 0) |
a15e6d7d | 182 | throw(kEH + "data file not opened."); |
e9a38ea3 | 183 | |
a97abca8 | 184 | if (event == fEvent) |
e9a38ea3 | 185 | return; |
186 | Bool_t checkEnd; | |
a97abca8 | 187 | if (event < fEvent) { |
e9a38ea3 | 188 | fReader->RewindEvents(); |
189 | fEvent = -1; | |
190 | checkEnd = kFALSE; | |
191 | } else { | |
192 | checkEnd = kTRUE; | |
193 | } | |
194 | do { | |
195 | NextEvent(); | |
a97abca8 | 196 | } while (fEvent != event && !(checkEnd == kTRUE && fEvent == 0)); |
e9a38ea3 | 197 | LoadEvent(); |
198 | UpdateSectors(); | |
199 | } | |
200 | ||
d810d0de | 201 | void* AliEveTPCLoader::LoopEvent(AliEveTPCLoader* loader) |
42c8253f | 202 | { |
a97abca8 | 203 | // Loop to next event on given loader. Static member to be used for |
204 | // external control during animations. | |
205 | // Calls NextEvent(), LoadEvent() and UpdateSectors(). | |
206 | ||
42c8253f | 207 | loader->NextEvent(); |
208 | loader->LoadEvent(); | |
209 | loader->UpdateSectors(); | |
84aff7a4 | 210 | if (gEve->GetEditor()->GetModel() == loader) |
211 | gEve->EditElement(loader); | |
42c8253f | 212 | return 0; |
213 | } | |
214 | ||
57ffa5fb | 215 | /******************************************************************************/ |
e9a38ea3 | 216 | |
d810d0de | 217 | void AliEveTPCLoader::UpdateSectors(Bool_t dropNonPresent) |
e9a38ea3 | 218 | { |
a97abca8 | 219 | // Update visual representations of sectors. |
220 | // If dropNonPresent is true, the sectors for which there is no data in | |
221 | // the current event are removed. | |
222 | ||
84aff7a4 | 223 | gEve->DisableRedraw(); |
a97abca8 | 224 | for (Int_t i=0; i<=35; ++i) |
42c8253f | 225 | { |
d810d0de | 226 | AliEveTPCSectorData* sd = fData->GetSectorData(i); |
42c8253f | 227 | |
228 | // 2D sectors | |
a97abca8 | 229 | if (fSec2Ds[i] != 0) |
42c8253f | 230 | { |
231 | if (dropNonPresent && sd == 0) { | |
84aff7a4 | 232 | gEve->RemoveElement(fSec2Ds[i], this); |
42c8253f | 233 | fSec2Ds[i] = 0; |
234 | } else { | |
235 | fSec2Ds[i]->IncRTS(); | |
32e219c2 | 236 | fSec2Ds[i]->ElementChanged(); |
42c8253f | 237 | } |
238 | } | |
239 | else | |
240 | { | |
a97abca8 | 241 | if (sd != 0) { |
d810d0de | 242 | AliEveTPCSector2D* s = new AliEveTPCSector2D(Form("Sector2D %d", i)); |
e9a38ea3 | 243 | fSec2Ds[i] = s; |
244 | s->SetSectorID(i); | |
245 | s->SetDataSource(fData); | |
8f50aad8 | 246 | |
a97abca8 | 247 | if (fDoubleSR) |
8f50aad8 | 248 | s->SetMaxTime(1023); |
e9a38ea3 | 249 | |
a97abca8 | 250 | if (fSetInitSectorParams) { |
e7c8d6ca | 251 | s->SetMinTime(fInitMinTime); |
252 | s->SetMaxTime(fInitMaxTime); | |
253 | s->SetThreshold(fInitThreshold); | |
b1e0b894 | 254 | s->SetMaxVal(fInitMaxVal); |
e7c8d6ca | 255 | } |
75a20dc1 | 256 | |
601bca51 | 257 | s->SetAutoTrans(kTRUE); |
e9a38ea3 | 258 | s->SetFrameColor(36); |
259 | ||
84aff7a4 | 260 | gEve->AddElement(s, this); |
e9a38ea3 | 261 | } |
262 | } | |
263 | ||
42c8253f | 264 | // 3D sectors |
a97abca8 | 265 | if (fSec3Ds[i] != 0) |
42c8253f | 266 | { |
267 | if (dropNonPresent && sd == 0) { | |
84aff7a4 | 268 | gEve->RemoveElement(fSec3Ds[i], this); |
42c8253f | 269 | fSec3Ds[i] = 0; |
270 | } else { | |
969e051c | 271 | fSec3Ds[i]->SetCutOnEta(fCutOnEta); |
272 | fSec3Ds[i]->SetEtaMax(fEtaMax); | |
273 | fSec3Ds[i]->SetEtaMin(fEtaMin); | |
42c8253f | 274 | fSec3Ds[i]->IncRTS(); |
32e219c2 | 275 | fSec3Ds[i]->ElementChanged(); |
42c8253f | 276 | } |
e9a38ea3 | 277 | } |
278 | } | |
84aff7a4 | 279 | gEve->Redraw3D(kTRUE, kFALSE); |
280 | gEve->EnableRedraw(); | |
e9a38ea3 | 281 | } |
282 | ||
d810d0de | 283 | void AliEveTPCLoader::ReloadSectors() |
c59e16e8 | 284 | { |
a97abca8 | 285 | // Reload current event and update sectors. |
286 | ||
c59e16e8 | 287 | LoadEvent(); |
288 | UpdateSectors(); | |
289 | } | |
290 | ||
d810d0de | 291 | void AliEveTPCLoader::CreateSectors3D() |
e9a38ea3 | 292 | { |
a97abca8 | 293 | // Create 3D representations of sectors. |
294 | ||
84aff7a4 | 295 | gEve->DisableRedraw(); |
a97abca8 | 296 | for (Int_t i=0; i<=35; ++i) { |
d810d0de | 297 | AliEveTPCSectorData* sd = fData->GetSectorData(i); |
a97abca8 | 298 | if (sd != 0 && fSec3Ds[i] == 0) { |
d810d0de | 299 | AliEveTPCSector3D* s = new AliEveTPCSector3D(Form("Sector3D %d", i)); |
e9a38ea3 | 300 | fSec3Ds[i] = s; |
301 | s->SetSectorID(i); | |
302 | s->SetDataSource(fData); | |
969e051c | 303 | s->SetCutOnEta(fCutOnEta); |
304 | s->SetEtaMax(fEtaMax); | |
305 | s->SetEtaMin(fEtaMin); | |
8f50aad8 | 306 | |
a97abca8 | 307 | if (fDoubleSR) |
8f50aad8 | 308 | s->SetDriftVel(2.273); |
a97abca8 | 309 | if (fSec2Ds[i] != 0) |
5aec5309 | 310 | s->CopyVizParams(fSec2Ds[i]); |
e9a38ea3 | 311 | |
601bca51 | 312 | s->SetAutoTrans(kTRUE); |
e9a38ea3 | 313 | s->SetFrameColor(36); |
314 | ||
84aff7a4 | 315 | gEve->AddElement(s, this); |
e9a38ea3 | 316 | } |
317 | } | |
84aff7a4 | 318 | gEve->EnableRedraw(); |
e9a38ea3 | 319 | } |
320 | ||
d810d0de | 321 | void AliEveTPCLoader::DeleteSectors3D() |
e9a38ea3 | 322 | { |
a97abca8 | 323 | // Delete 3D representations of sectors. |
324 | ||
84aff7a4 | 325 | gEve->DisableRedraw(); |
a97abca8 | 326 | for (Int_t i=0; i<=35; ++i) { |
84aff7a4 | 327 | TEveElement* re = fSec3Ds[i]; |
a97abca8 | 328 | if (re != 0) { |
84aff7a4 | 329 | gEve->RemoveElement(re, this); |
4a378d74 | 330 | // delete re; // Done automatically. |
e9a38ea3 | 331 | fSec3Ds[i] = 0; |
332 | } | |
333 | } | |
84aff7a4 | 334 | gEve->EnableRedraw(); |
e9a38ea3 | 335 | } |
e7c8d6ca | 336 | |
57ffa5fb | 337 | /******************************************************************************/ |
e7c8d6ca | 338 | |
d810d0de | 339 | void AliEveTPCLoader::SetInitParams(Int_t mint, Int_t maxt, Int_t thr, Int_t maxval) |
e7c8d6ca | 340 | { |
a97abca8 | 341 | // Set initial viualization parameters for 2D and 3D sector representations. |
342 | ||
e7c8d6ca | 343 | fSetInitSectorParams = kTRUE; |
344 | fInitMinTime = mint; | |
345 | fInitMaxTime = maxt; | |
346 | fInitThreshold = thr; | |
b1e0b894 | 347 | fInitMaxVal = maxval; |
e7c8d6ca | 348 | } |