2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
4 /**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
10 #include "AliEveTPCLoader.h"
11 #include "AliEveTPCData.h"
12 #include <Alieve/AliEveTPCSector2D.h>
13 #include <Alieve/AliEveTPCSector3D.h>
14 #include <TEveManager.h>
15 #include <TEveGedEditor.h>
17 #include <AliRawReaderRoot.h>
18 #include <AliTPCRawStream.h>
23 //______________________________________________________________________________
27 ClassImp(AliEveTPCLoader)
29 AliEveTPCLoader::AliEveTPCLoader(const Text_t* n, const Text_t* t) :
30 TEveElementList(n, t),
43 fSetInitSectorParams(kFALSE),
44 fInitMinTime(0), fInitMaxTime(460), fInitThreshold(5), fInitMaxVal(128)
46 fData = new AliEveTPCData;
49 AliEveTPCLoader::~AliEveTPCLoader()
55 /******************************************************************************/
57 void AliEveTPCLoader::RemoveElementLocal(TEveElement* el)
59 for(Int_t i=0; i<36; ++i) {
60 if(fSec2Ds[i] == el) fSec2Ds[i] = 0;
61 if(fSec3Ds[i] == el) fSec3Ds[i] = 0;
65 void AliEveTPCLoader::RemoveElementsLocal()
67 for(Int_t i=0; i<36; ++i) {
73 /******************************************************************************/
75 void AliEveTPCLoader::SetData(AliEveTPCData* d)
81 /******************************************************************************/
83 void AliEveTPCLoader::OpenFile()
85 static const TEveException eH("AliEveTPCLoader::OpenFile ");
87 if(gSystem->AccessPathName(fFile, kReadPermission))
88 throw(eH + "can not read '" + fFile + "'.");
90 fData->DeleteAllSectors();
96 fReader = new AliRawReaderRoot(fFile);
97 if(fTPCEquipementMap != "")
98 fReader->LoadEquipmentIdsMap
99 (gSystem->ExpandPathName(fTPCEquipementMap.Data()));
103 UpdateSectors(kTRUE);
106 void AliEveTPCLoader::LoadEvent()
108 static const TEveException eH("AliEveTPCLoader::LoadEvent ");
111 throw(eH + "data file not opened.");
113 printf("Now loading event %d\n", fEvent);
115 AliTPCRawStream input(fReader);
116 input.SetOldRCUFormat(kTRUE);
117 fReader->Select("TPC");
119 fData->DropAllSectors();
120 fData->LoadRaw(input, kTRUE, kTRUE);
123 void AliEveTPCLoader::NextEvent(Bool_t rewindOnEnd)
125 static const TEveException eH("AliEveTPCLoader::NextEvent ");
128 throw(eH + "data file not opened.");
130 if(fReader->NextEvent() == kTRUE) {
134 throw(eH + "no events available.");
136 printf("Reached end of stream (event=%d), rewinding to first event.\n", fEvent);
137 fReader->RewindEvents();
138 fReader->NextEvent();
141 throw(eH + "last event reached.");
146 void AliEveTPCLoader::GotoEvent(Int_t event)
148 static const TEveException eH("AliEveTPCLoader::GotoEvent ");
151 throw(eH + "data file not opened.");
157 fReader->RewindEvents();
165 } while(fEvent != event && !(checkEnd == kTRUE && fEvent == 0));
170 void* AliEveTPCLoader::LoopEvent(AliEveTPCLoader* loader)
174 loader->UpdateSectors();
175 if (gEve->GetEditor()->GetModel() == loader)
176 gEve->EditElement(loader);
180 /******************************************************************************/
182 void AliEveTPCLoader::UpdateSectors(Bool_t dropNonPresent)
184 gEve->DisableRedraw();
185 for(Int_t i=0; i<=35; ++i)
187 AliEveTPCSectorData* sd = fData->GetSectorData(i);
192 if (dropNonPresent && sd == 0) {
193 gEve->RemoveElement(fSec2Ds[i], this);
196 fSec2Ds[i]->IncRTS();
197 fSec2Ds[i]->ElementChanged();
203 AliEveTPCSector2D* s = new AliEveTPCSector2D(Form("Sector2D %d", i));
206 s->SetDataSource(fData);
211 if(fSetInitSectorParams) {
212 s->SetMinTime(fInitMinTime);
213 s->SetMaxTime(fInitMaxTime);
214 s->SetThreshold(fInitThreshold);
215 s->SetMaxVal(fInitMaxVal);
218 s->SetAutoTrans(kTRUE);
219 s->SetFrameColor(36);
221 gEve->AddElement(s, this);
228 if (dropNonPresent && sd == 0) {
229 gEve->RemoveElement(fSec3Ds[i], this);
232 fSec3Ds[i]->IncRTS();
233 fSec3Ds[i]->ElementChanged();
237 gEve->Redraw3D(kTRUE, kFALSE);
238 gEve->EnableRedraw();
241 void AliEveTPCLoader::ReloadSectors()
247 void AliEveTPCLoader::CreateSectors3D()
249 gEve->DisableRedraw();
250 for(Int_t i=0; i<=35; ++i) {
251 AliEveTPCSectorData* sd = fData->GetSectorData(i);
252 if(sd != 0 && fSec3Ds[i] == 0) {
253 AliEveTPCSector3D* s = new AliEveTPCSector3D(Form("Sector3D %d", i));
256 s->SetDataSource(fData);
259 s->SetDriftVel(2.273);
261 s->CopyVizParams(*fSec2Ds[i]);
263 s->SetAutoTrans(kTRUE);
264 s->SetFrameColor(36);
266 gEve->AddElement(s, this);
269 gEve->EnableRedraw();
272 void AliEveTPCLoader::DeleteSectors3D()
274 gEve->DisableRedraw();
275 for(Int_t i=0; i<=35; ++i) {
276 TEveElement* re = fSec3Ds[i];
278 gEve->RemoveElement(re, this);
279 // delete re; // Done automatically.
283 gEve->EnableRedraw();
286 /******************************************************************************/
288 void AliEveTPCLoader::SetInitParams(Int_t mint, Int_t maxt, Int_t thr, Int_t maxval)
290 fSetInitSectorParams = kTRUE;
293 fInitThreshold = thr;
294 fInitMaxVal = maxval;