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