Move class fws decls to proper namespace.
[u/mrichter/AliRoot.git] / EVE / hlt-macros / homer_display.C
CommitLineData
87f60d9e 1// $Header$
2
3// Functions to read data from HOMER.
4//
5// Setup: edit location of HLT configuration in first line of
6// homer_display(). This is a temporary solution.
7//
8// Run as: alieve command_queue.C+ hlt_structs.C+ homer_display.C
9//
10// nextEvent() will get next event from HOMER.
11
12
13#include "TTimer.h"
14#include "TGLViewer.h"
15#include "TTimer.h"
16#include "TRandom.h"
17#include "TVirtualPad.h"
18//#include "AliEVEHOMERManager.h"
19
20class AliRawReaderMemory;
21
65ad0491 22class AliEVEHOMERManager;
23class AliHLTHOMERBlockDesc;
24
87f60d9e 25namespace Reve {
26class PointSet;
27class TrackList;
28class Track;
29}
30
31namespace Alieve {
32class TPCLoader;
33class TPCData;
34class TPCSector2D;
35class TPCSector3D;
87f60d9e 36}
37
38using namespace Reve;
39using namespace Alieve;
40
41TPCLoader* loader = 0;
42TPCData* tpcdata = 0;
43PointSet* tpc_cls = 0;
44TrackList* tpc_trk = 0;
45
46AliRawReaderMemory* memreader = 0;
47AliEVEHOMERManager* homerM = 0;
48
49Int_t event = -1;
50
51TTimer timer;
52TTimer event_timer;
53
54TThread* ldthread = 0;
55
56TRandom rnd(0);
57
58TGLViewer::ECameraType camera = TGLViewer::kCameraPerspXOZ;
59
60
61//****************************************************************************
62void nextEvent();
63
64//****************************************************************************
65void process_tpc_clusters(AliHLTHOMERBlockDesc* b);
66
67//****************************************************************************
68void homer_display()
69{
70 homerM = new AliEVEHOMERManager("/local/home/hlt/TPC-SCC1-Generate.xml");
71 // homerM = new AliEVEHOMERManager("/local/home/hlt/sampleConfig2.xml");
72
73 gReve->AddToListTree(homerM, kTRUE);
74
75 homerM->CreateHOMERSourcesList();
76 // homerM->SelectRawTPC();
77 homerM->SelectClusterTPC();
78 homerM->SelectESDTPC();
79 homerM->ConnectHOMER();
80
81 memreader = new AliRawReaderMemory(0, 0);
82 gStyle->SetPalette(1, 0);
83
84 loader = new TPCLoader;
85 loader->SetDoubleSR(kTRUE);
86 loader->SetInitParams(40, 900, 10, 100); // Sector params (mint, maxt, thr, maxval)
87 //loader->SetInitParams(40, 1023, 10); // Sector params (mint, maxt, thr)
88 tpcdata = loader->GetData();
89 tpcdata->SetLoadPedestal(0);
90 tpcdata->SetLoadThreshold(0);
91 // tpcdata->SetAutoPedestal(kTRUE); // For non-zero suppressed data.
92 tpcdata->SetAutoPedestal(kFALSE);
93 gReve->AddRenderElement(loader);
94
95 tpc_cls = new Reve::PointSet("TPC Clusters");
96 tpc_cls->SetMainColor((Color_t)kRed);
97 gReve->AddRenderElement(tpc_cls);
98
99 tpc_trk = new TrackList("TPC Tracks");
100 gReve->AddRenderElement(tpc_trk);
101 tpc_trk->SetMainColor(Color_t(6));
102 Reve::TrackRnrStyle* rnrStyle = tpc_trk->GetRnrStyle();
103 rnrStyle->SetMagField( 5 );
104
105 nextEvent();
106}
107
108
109//****************************************************************************
110void nextEvent()
111{
112 tpcdata->DropAllSectors();
113 tpc_cls->Reset();
114 tpc_trk->DestroyElements();
115
116 homerM->NextEvent();
117 TIter next(homerM->GetBlockList());
118 AliHLTHOMERBlockDesc* b = 0;
119 while ((b = (AliHLTHOMERBlockDesc*)next())) {
120
121 // printf("Q - %s\n", b->GetDataType().Data());
122
123 if (b->GetDataType().CompareTo("CLUSTERS") == 0) {
124 process_tpc_clusters(b);
125 tpc_cls->ElementChanged();
126 }
127
128 else if (b->GetDataType().CompareTo("DDL_RAW") == 0) {
129 Int_t slice = b->GetSubDetector().Atoi();
130 Int_t patch = b->GetSubSubDetector().Atoi();
131 Int_t eqid = 768 + patch;
132 if (patch >= 2)
133 eqid += 4*slice + 70;
134 else
135 eqid += 2*slice;
136
137 //printf("%d %d %d -- %p %d\n", slice, patch, eqid, b->GetData(), b->GetSize());
138
139 memreader->SetMemory(b->GetData(), b->GetSize());
140 memreader->SetEquipmentID(eqid);
141 memreader->Reset();
142
143 AliTPCRawStream input(memreader);
144 input.SetOldRCUFormat(kTRUE);
145 //input.SetOldRCUFormat(kFALSE);
146 memreader->Select("TPC"); // ("TPC", firstRCU, lastRCU);
147 tpcdata->LoadRaw(input, kTRUE, kTRUE);
148 }
149 }
150
151 loader->UpdateSectors(kTRUE); // true -> delete non present
152 tpc_cls->ResetBBox();
153 tpc_trk->MakeTracks();
154
155 gReve->Redraw3D(1, 1);
156}
157
158//****************************************************************************
159void process_tpc_clusters(AliHLTHOMERBlockDesc* b)
160{
161 AliHLTTPCClusterData *cd = (AliHLTTPCClusterData*) b->GetData();
162 UChar_t *data = (UChar_t*) cd->fSpacePoints;
163
164 // printf("XXX %p %d; sizeof=%d, calcsize=%d\n", b->GetData(), cd->fSpacePointCnt,
165 // sizeof(AliHLTTPCSpacePointData), (b->GetSize() - 4)/cd->fSpacePointCnt);
166
167 Int_t slice = b->GetSubDetector().Atoi();
168 Float_t phi = (slice+0.5)*TMath::Pi()/9.0;
169 Float_t cos = TMath::Cos(phi);
170 Float_t sin = TMath::Sin(phi);
171
172 for (Int_t i = 0; i < cd->fSpacePointCnt; ++i, data += sizeof(AliHLTTPCSpacePointData)) {
173 AliHLTTPCSpacePointData *sp = (AliHLTTPCSpacePointData *) data;
174 //if (i % 100 == 0)
175 //printf(" %4d %6.2f, %6.2f, %6.2f\n", i, sp->fX, sp->fY, sp->fZ);
176 tpc_cls->SetNextPoint(cos*sp->fX - sin*sp->fY,
177 sin*sp->fX + cos*sp->fY,
178 sp->fZ);
179 }
180}
181
182//****************************************************************************
183Reve::Track* esd_make_track(Reve::TrackRnrStyle* rnrStyle,
184 Int_t index,
185 AliESDtrack* at,
186 AliExternalTrackParam* tp=0)
187{
188 // Helper function
189 Double_t pbuf[3], vbuf[3];
190 Reve::RecTrack rt;
191
192 if(tp == 0) tp = at;
193
194 rt.label = at->GetLabel();
195 rt.index = index;
196 rt.status = (Int_t) at->GetStatus();
197 rt.sign = tp->GetSign();
198 tp->GetXYZ(vbuf);
199 rt.V.Set(vbuf);
200 tp->GetPxPyPz(pbuf);
201 rt.P.Set(pbuf);
202 Double_t ep = at->GetP(), mc = at->GetMass();
203 rt.beta = ep/TMath::Sqrt(ep*ep + mc*mc);
204
205 Reve::Track* track = new Reve::Track(&rt, rnrStyle);
206 //PH The line below is replaced waiting for a fix in Root
207 //PH which permits to use variable siza arguments in CINT
208 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
209 //PH track->SetName(Form("ESDTrack %d", rt.label));
210 //PH track->SetTitle(Form("pT=%.3f, pZ=%.3f; V=(%.3f, %.3f, %.3f)",
211 //PH rt.sign*TMath::Hypot(rt.P.x, rt.P.y), rt.P.z,
212 //PH rt.V.x, rt.V.y, rt.V.z));
213 char form[1000];
214 sprintf(form,"Track %d", rt.index);
215 track->SetName(form);
216 track->SetStdTitle();
217 return track;
218}
219
220//****************************************************************************
221void process_tpc_tracks(AliHLTHOMERBlockDesc* b)
222{
223 AliESDEvent* esd = (AliESDEvent*) b->GetTObject();
224
225 Reve::TrackRnrStyle* rnrStyle = tpc_trk->GetRnrStyle();
226
227 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
228 {
229 AliESDtrack *at = esd->GetTrack(n);
230 AliExternalTrackParam *tp = at;
231
232 Reve::Track* track = esd_make_track(rnrStyle, n, at, tp);
233 track->SetAttLineAttMarker(tpc_trk);
234 gReve->AddRenderElement(track, tpc_trk);
235 }
236
237}
238
239//****************************************************************************
240void process_tpc_xxxx(AliESDEvent* esd)
241{
242 Reve::TrackRnrStyle* rnrStyle = tpc_trk->GetRnrStyle();
243
244 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
245 {
246 AliESDtrack *at = esd->GetTrack(n);
247 AliExternalTrackParam *tp = at;
248
249 Reve::Track* track = esd_make_track(rnrStyle, n, at, tp);
250 track->SetAttLineAttMarker(tpc_trk);
251 gReve->AddRenderElement(track, tpc_trk);
252 }
253
254}
255
256//****************************************************************************
257/*
258 // Getting esd
259
260f=TFile::Open("AliESDs.root")
261AliESDEvent * esd = new AliESDEvent
262esd->ReadFromTree(esdTree)
263esdTree->GetEntry(0)
264esd->GetNumberOfTracks()
265///////////////////
266
267root [3] AliESDEvent * esd = new AliESDEvent
268root [4] esd->ReadFromTree(esdTree)
269W-TStreamerInfo::BuildOld: Cannot convert AliESDCaloCluster::fTracksMatched from type:TArrayS* to type:TArrayI, skip element
270W-TStreamerInfo::BuildOld: Cannot convert AliESDCaloCluster::fLabels from type:TArrayS* to type:TArrayI, skip element
271STEER/AliESDEvent.cxx 1040 AliESDEvent::ReadFromTree() TList contains less than the standard contents 21 < 22
272root [5] esdTree->GetEntry(0)
273(Int_t)(764314)
274root [6] esd->GetNumberOfTracks()
275(const Int_t)(275)
276root [7] process_tpc_xxxx(esd)
277root [8] gReve->Redraw3D(
278void Redraw3D(Bool_t resetCameras = kFALSE, Bool_t dropLogicals = kFALSE)
279root [8] gReve->Redraw3D(1,1)
280root [9] trk_cnt->Elem
281variable "trk_cnt" not defined.
282
283variable "trk_cnt->Elem" not defined.
284root [9] trk_cnt->Eleme
285variable "trk_cnt" not defined.
286
287variable "trk_cnt->Eleme" not defined.
288root [9] tpc_trk->ElementChanged(
289void ElementChanged(Bool_t update_scenes = kTRUE, Bool_t redraw = kFALSE)
290root [9] tpc_trk->ElementChanged(1,1)
291root [10] tpc_trk->SelectByP
292SelectByPt
293SelectByPt
294SelectByP
295SelectByP
296root [10] tpc_trk->SelectByPt(
297void SelectByPt(Float_t min_pt, Float_t max_pt)
298void SelectByPt(Float_t min_pt, Float_t max_pt, Reve::RenderElement* el)
299root [10] tpc_trk->SelectByPt(0,1000000000000)
300root [11] tpc_trk->MakeTracks(
301void MakeTracks(Bool_t recurse = kTRUE)
302root [11] tpc_trk->MakeTracks()
303root [12]
304
305
306
307*/
308
309
310
311
312//****************************************************************************
313void loopEvent()
314{
315 event_timer.SetCommand("nextEvent()");
316 event_timer.Start(60);
317}
318
319//****************************************************************************
320void stopLoopEvent()
321{
322 event_timer.Stop();
323}