Extacting the OCDB in a separate module. The detectors have write permission in the...
[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
87f60d9e 19
20class AliRawReaderMemory;
d810d0de 21class AliEveHOMERManager;
65ad0491 22class AliHLTHOMERBlockDesc;
23
84aff7a4 24class TEvePointSet;
25class TEveTrackList;
26class TEveTrack;
87f60d9e 27
d810d0de 28class AliEveTPCLoader;
29class AliEveTPCData;
30class AliEveTPCSector2D;
31class AliEveTPCSector3D;
46eadbb4 32class AliEveITSDigitsInfo;
33
7279ee15 34//***********************************************************
35#include "TTimer.h"
36#include "TRandom.h"
37#include "TVirtualPad.h"
46eadbb4 38#include "TGLViewer.h"
39#include "TThread.h"
40#include "TGFileBrowser.h"
41#include "TStyle.h"
42#include "TList.h"
43#include "TDirectory.h"
7279ee15 44//***********************************************************
46eadbb4 45#include "TEveManager.h"
46#include "TEvePointSet.h"
47#include "TEveTrack.h"
48#include "TEveVSDStructs.h"
49#include "TEveTrackPropagator.h"
7279ee15 50#include "TEvePointSet.h"
51#include "TEveScene.h"
46eadbb4 52#include "TEveElement.h"
7279ee15 53// #include "TEveElementList.h"
54#include "TEveEventManager.h"
55//***********************************************************
46eadbb4 56#include "AliESDEvent.h"
57#include "AliCDBManager.h"
58#include "AliRawReaderMemory.h"
7279ee15 59#include "AliTPCRawStream.h"
60#include "AliGeomManager.h"
61//***********************************************************
46eadbb4 62#include "AliEveHOMERManager.h"
7279ee15 63#include "AliEveTPCLoader.h"
46eadbb4 64#include "AliEveTPCData.h"
65#include "AliEveITSDigitsInfo.h"
66#include "AliEveITSModule.h"
7279ee15 67//***********************************************************
46eadbb4 68#include "AliHLTHOMERBlockDesc.h"
7279ee15 69#include "AliHLTHOMERReader.h"
46eadbb4 70//***********************************************************
7279ee15 71#include "hlt_structs.C"
72#include "TFile.h"
46eadbb4 73//***********************************************************
7279ee15 74#include <AliHLTMUONUtils.h>
75#include "AliHLTMUONDataBlockReader.h"
76#include "tracking-ca/AliHLTTPCCATrackParam.h"
46eadbb4 77
78// -- globals --
7279ee15 79
46eadbb4 80AliEveTPCLoader* gTPCLoader = 0;
81AliEveTPCData* gTPCData = 0;
82TEvePointSet* gTPCClusters = 0;
83TEveTrackList* gTPCTrack = 0;
d810d0de 84
46eadbb4 85AliEveITSDigitsInfo* gITSDigits = 0;
87f60d9e 86
46eadbb4 87AliRawReaderMemory* gMemReader = 0;
88AliEveHOMERManager* gHomerManager = 0;
89
7279ee15 90TEvePointSet* gMUONClusters = 0;
91Double_t gSolenoidField = 5;
46eadbb4 92//***********************************************************
93
46eadbb4 94Int_t globMaxPoint = 0 ;
95
96//***********************************************************
97
98// -- needed below ??
87f60d9e 99
100Int_t event = -1;
101
102TTimer timer;
103TTimer event_timer;
104
105TThread* ldthread = 0;
106
107TRandom rnd(0);
108
46eadbb4 109Bool_t vC = kFALSE;
110TGFileBrowser *g_hlt_browser = 0;
111TCanvas *g_hlt_canvas = 0;
112
87f60d9e 113TGLViewer::ECameraType camera = TGLViewer::kCameraPerspXOZ;
114
46eadbb4 115//****************************************************************************
7279ee15 116Int_t nextEvent();
87f60d9e 117
118//****************************************************************************
46eadbb4 119Int_t processSPDRawData( AliHLTHOMERBlockDesc* block );
120Int_t drawSPDRawData();
87f60d9e 121
122//****************************************************************************
46eadbb4 123Int_t processTPCRawData( AliHLTHOMERBlockDesc* block );
124Int_t processTPCClusters( AliHLTHOMERBlockDesc* block );
125Int_t processTPCTracks( AliHLTHOMERBlockDesc* block );
87f60d9e 126
7279ee15 127Int_t processMUONClusters( AliHLTHOMERBlockDesc* block );
87f60d9e 128
46eadbb4 129//****************************************************************************
130TEveTrack* makeESDTrack( TEveTrackPropagator* rnrStyle,
131 Int_t idx,
132 AliESDtrack* at,
133 AliExternalTrackParam* tp = 0 );
134
135//****************************************************************************
7279ee15 136void homer_display( Int_t run = 0) {
87f60d9e 137
46eadbb4 138 AliCDBManager::Instance()->SetRun(run);
162637e4 139 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
a15e6d7d 140
46eadbb4 141 gMemReader = new AliRawReaderMemory(0, 0);
87f60d9e 142
87f60d9e 143 gStyle->SetPalette(1, 0);
7279ee15 144 gEve->DisableRedraw();
87f60d9e 145
46eadbb4 146 // -- Create HOMER Manager
147 gHomerManager = new AliEveHOMERManager("/local/home/hlt/AliEVE-Config.xml");
148
7279ee15 149 // -- Set Realm ( can be "GPN","ACR","HLT","KIP" )
46eadbb4 150 gHomerManager->SetRealm("ACR");
151
152 gEve->AddToListTree(gHomerManager, kTRUE);
153
154 // -- Create list of HOMER sources
155 gHomerManager->CreateHOMERSourcesList();
156
157 // -- TPC Loader
158 gTPCLoader = new AliEveTPCLoader;
159 gTPCLoader->SetDoubleSR(kTRUE);
7279ee15 160 gTPCLoader->SetInitParams(40, 900, 2, 100); // Sector params (mint, maxt, thr, maxval)
46eadbb4 161
162 // -- TPC Data
163 gTPCData = gTPCLoader->GetData();
164 gTPCData->SetLoadPedestal(0);
165 gTPCData->SetLoadThreshold(0);
166 gTPCData->SetAutoPedestal(kFALSE); // For zero suppressed data.
87f60d9e 167
46eadbb4 168 gEve->AddElement(gTPCLoader);
7279ee15 169
170 gEve->Redraw3D(0,1); // (0, 1)
171 gEve->EnableRedraw();
46eadbb4 172}
87f60d9e 173
174//****************************************************************************
7279ee15 175Int_t nextEvent() {
87f60d9e 176
46eadbb4 177 Int_t iResult = 0;
87f60d9e 178
7279ee15 179 gStyle->SetPalette(1, 0);
180 gEve->DisableRedraw();
181
46eadbb4 182 // ** Get Next Event from HOMER
183 if ( gHomerManager->NextEvent() )
184 return ++iResult;
87f60d9e 185
46eadbb4 186 // ** Reset
187 if ( gTPCClusters ) gTPCClusters->Reset();
188 if ( gTPCTrack ) gTPCTrack->DestroyElements();
189 if ( gTPCData ) gTPCData->DropAllSectors();
87f60d9e 190
46eadbb4 191 if ( gITSDigits ) {
192 delete gITSDigits;
193 gITSDigits = NULL;
194 }
195
7279ee15 196 if ( gMUONClusters ) gMUONClusters->Reset();
46eadbb4 197
198
199 // ----------------------------------- foo A
200 vC = kFALSE;
201
202 // TList* hListKR = new TList;
203 // TList* hListCF = new TList;
204
46eadbb4 205 // ----------------------------------- foo A
206
207 TIter next(gHomerManager->GetBlockList());
208 AliHLTHOMERBlockDesc* block = 0;
209
210 while ((block = (AliHLTHOMERBlockDesc*)next())) {
7279ee15 211
212// printf ( "Det : %s\n" ,block->GetDetector().Data() );
213// printf ( "Datatype : %s\n" ,block->GetDataType().Data() );
46eadbb4 214
46eadbb4 215
46eadbb4 216
7279ee15 217 // -- TPC
218 // -----------------------------------------------------
219
220 if ( ! block->GetDetector().CompareTo("TPC") ){
221
46eadbb4 222
7279ee15 223 // +++ CLUSTERS BLOCK
224 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++
225
226 if ( block->GetDataType().CompareTo("CLUSTERS") == 0 ) {
227 if ( !gTPCClusters ) {
228 gTPCClusters = new TEvePointSet("TPC Clusters");
229 gTPCClusters->SetMainColor(kRed);
230 gTPCClusters->SetMarkerStyle((Style_t)kFullDotSmall);
231 gEve->AddElement(gTPCClusters);
232 }
233
234 // ** Process Clusters
235 processTPCClusters( block );
236
237 gTPCClusters->ElementChanged();
238
239 }else if ( block->GetDataType().CompareTo("ESD_TREE") == 0 ) {
46eadbb4 240 // +++ ESD BLOCK
241 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++
46eadbb4 242
7279ee15 243 // ** Initialize TPC Tracks
244 if ( !gTPCTrack ) {
245 gTPCTrack = new TEveTrackList("TPC Tracks");
246 gTPCTrack->SetMainColor(kBlue);
247
248 gEve->AddElement(gTPCTrack);
46eadbb4 249
7279ee15 250 TEveTrackPropagator* rnrStyle = gTPCTrack->GetPropagator();
251 rnrStyle->SetMagField( 0 );
252 rnrStyle->SetFitDecay( 1 );
253 }
254 cout<<"SIZE : "<<block->GetSize()<<endl;
255 // ** Proces Tracks
256 processTPCTracks( block );
257 }else if ( block->GetDataType().CompareTo("DDL_RAW") == 0 ) {
258 processTPCRawData( block );
46eadbb4 259 }
46eadbb4 260
7279ee15 261 } else if ( ! block->GetDetector().CompareTo("MUON") ) {
262
263 // -- MUON
264 //-----------------------------------------------------
265 if ( (block->GetDataType().CompareTo("RECHITS") == 0) || (block->GetDataType().CompareTo("TRIGRECS") == 0) ) {
266
267// printf ( "Inside : Datatype : %s\n" ,block->GetDataType().Data() );
268// printf ( "Inside : DataSize : %d\n" ,block->GetSize() );
269 if ( !gMUONClusters ) {
270 gMUONClusters = new TEvePointSet("MUON RecHits");
271 gMUONClusters->SetMainColor(kBlue);
272 gMUONClusters->SetMarkerStyle(20);
273 gEve->AddElement(gMUONClusters);
274 }
275
276 // ** Process Clusters
277 processMUONClusters( block );
278
279 gMUONClusters->ElementChanged();
280
281 }//MUON Clusters
46eadbb4 282
7279ee15 283
284 } else if ( ! block->GetDetector().CompareTo("SPD") ) {
46eadbb4 285
286 // -- SPD
287 // -----------------------------------------------------
46eadbb4 288
7279ee15 289 if ( block->GetDataType().CompareTo("DDL_RAW") == 0 ) {
46eadbb4 290 // ** Initialize SPD Digits
291 if ( !gITSDigits ) {
292 gITSDigits = new AliEveITSDigitsInfo();
293 }
7279ee15 294
46eadbb4 295 processSPDRawData( block );
296 }
297
7279ee15 298 }else{
46eadbb4 299
7279ee15 300 printf ("Detector \"%s\" has not been recognized",block->GetDetector().Data());
87f60d9e 301 }
46eadbb4 302
87f60d9e 303 }
7279ee15 304
46eadbb4 305 if ( gTPCLoader ) gTPCLoader->UpdateSectors( kTRUE );
306 if ( gTPCClusters ) gTPCClusters->ResetBBox();
307 if ( gTPCTrack ) gTPCTrack->MakeTracks();
308 if ( gITSDigits ) drawSPDRawData();
46eadbb4 309
7279ee15 310 if ( gMUONClusters ) gMUONClusters->ResetBBox();
311
312 gEve->Redraw3D(0,1); // (0, 1)
313 gEve->EnableRedraw();
314
46eadbb4 315 return iResult;
87f60d9e 316}
317
318//****************************************************************************
7279ee15 319//****************************************************************************
320//****************************************************************************
321void loopEvent() {
322 event_timer.SetCommand("nextEvent()");
323 event_timer.Start(6000);
46eadbb4 324}
325
326//****************************************************************************
7279ee15 327void stopLoopEvent() {
328 event_timer.Stop();
46eadbb4 329}
330
46eadbb4 331//****************************************************************************
332Int_t processTPCRawData(AliHLTHOMERBlockDesc* block) {
333
334 Int_t iResult = 0;
335
336 Int_t sector = block->GetSubDetector().Atoi();
337 Int_t patch = block->GetSubSubDetector().Atoi();
338 Int_t eqId = 768 + patch;
339
340 if ( patch >= 2) eqId += 4 * sector + 70;
341 else eqId += 2 * sector;
342
7279ee15 343 printf("sector : %d %d %d -- %p %lu\n", sector, patch, eqId, block->GetData(), block->GetSize());
46eadbb4 344
345 gMemReader->SetMemory( reinterpret_cast<UChar_t*> ( block->GetData() ), block->GetSize() );
346 gMemReader->SetEquipmentID( eqId );
347 gMemReader->Reset();
348
349 AliTPCRawStream tpcStream( gMemReader );
46eadbb4 350 gMemReader->Select("TPC");
351
352 gTPCData->LoadRaw( tpcStream, kTRUE, kTRUE );
353
354 return iResult;
355}
356
357//****************************************************************************
358Int_t processTPCClusters(AliHLTHOMERBlockDesc* block) {
359 Int_t iResult = 0;
360
361 Int_t slice = block->GetSubDetector().Atoi();
362 Int_t patch = block->GetSubSubDetector().Atoi();
7279ee15 363 Float_t phi = ( slice + 0.5 ) * TMath::Pi() / 9.0;
46eadbb4 364 Float_t cos = TMath::Cos( phi );
365 Float_t sin = TMath::Sin( phi );
366
367 AliHLTTPCClusterData *cd = (AliHLTTPCClusterData*) block->GetData();
368 UChar_t *data = (UChar_t*) cd->fSpacePoints;
369
370 if ( cd->fSpacePointCnt == 0 ) {
371 printf ("No Clusters found in sector %d patch %d.\n", slice, patch );
372 iResult = -1;
373 }
374 else {
375
376 for (Int_t ii = 0; ii < cd->fSpacePointCnt; ++ii, data += sizeof(AliHLTTPCSpacePointData)) {
377 AliHLTTPCSpacePointData *sp = (AliHLTTPCSpacePointData *) data;
378
379 gTPCClusters->SetNextPoint(cos*sp->fX - sin*sp->fY, sin*sp->fX + cos*sp->fY, sp->fZ);
380 }
87f60d9e 381 }
46eadbb4 382
383 return iResult;
87f60d9e 384}
385
386//****************************************************************************
46eadbb4 387TEveTrack* makeESDTrack( TEveTrackPropagator* rnrStyle,
388 Int_t idx,
389 AliESDtrack* esdTrack,
390 AliExternalTrackParam* trackParam ) {
87f60d9e 391 // Helper function
7279ee15 392
46eadbb4 393 Double_t pbuf[3], vbuf[3];
394 TEveRecTrack rt;
7279ee15 395 TEvePathMark startPoint(TEvePathMark::kReference);
396 TEvePathMark midPoint(TEvePathMark::kReference);
397 TEvePathMark mid1Point(TEvePathMark::kReference);
398 TEvePathMark endPoint(TEvePathMark::kReference);
399 TEvePathMark decPoint(TEvePathMark::kDecay);
400
401 /*printf("ESD track: %f, %f, %f, %f, %f, %f, %f",
402 esdTrack->GetAlpha(),
403 esdTrack->GetX(),
404 esdTrack->GetY(),
405 esdTrack->GetZ(),
406 esdTrack->GetSnp(),
407 esdTrack->GetTgl(),
408 esdTrack->GetSigned1Pt()
409 );
410 */
411 cout<<"TPCPoints::"<<esdTrack->GetTPCPoints(0)<<" "<<esdTrack->GetTPCPoints(1)<<" "<<esdTrack->GetTPCPoints(2)<<" "<<esdTrack->GetTPCPoints(3)<<endl;
46eadbb4 412
413 if ( trackParam == 0 )
414 trackParam = esdTrack;
415
416 rt.fLabel = esdTrack->GetLabel();
417 rt.fIndex = idx;
418 rt.fStatus = (Int_t) esdTrack->GetStatus();
419 rt.fSign = (Int_t) trackParam->GetSign();
46eadbb4 420
7279ee15 421 Double_t x0 = trackParam->GetX();
422 Double_t dx = esdTrack->GetTPCPoints(2) - x0;
46eadbb4 423
7279ee15 424 for( Double_t x1=x0; x1<x0+dx; x1+=(dx)*.1 ){//SG
425 AliExternalTrackParam startParam = *trackParam;
426 AliHLTTPCCATrackParam t;
427 t.SetExtParam(startParam, gSolenoidField );
428 if( !t.TransportToX(x1) ) continue;
429 t.GetExtParam( startParam, startParam.GetAlpha(), gSolenoidField );
430 if( TMath::Abs(startParam.GetSnp())>.99 ) continue;
46eadbb4 431
7279ee15 432 startParam.GetXYZ(vbuf);
433
434 { // get momentum manually because trackParam->GetPxPyPz doesn't works for straight lines
46eadbb4 435
7279ee15 436 Double_t pt= TMath::Abs(startParam.GetSigned1Pt());
437 pt = (pt>kAlmost0) ?1./pt :100.;
438
439 Double_t cA=TMath::Cos(startParam.GetAlpha()), sA=TMath::Sin(startParam.GetAlpha());
440
441 Double_t sT=startParam.GetSnp();
442 if( sT>kAlmost1 ){ sT = kAlmost1; }
443 else if( sT<-kAlmost1 ){ sT = -kAlmost1; }
444 Double_t cT = TMath::Sqrt(TMath::Abs(1 - sT*sT));
445
446 pbuf[0] = pt*(cT*cA - sT*sA);
447 pbuf[1] = pt*(sT*cA + cT*sA);
448 pbuf[2] = pt*startParam.GetTgl();
449 }
46eadbb4 450
7279ee15 451 break;
452 }
453
454 rt.fV.Set(vbuf);
46eadbb4 455 rt.fP.Set(pbuf);
7279ee15 456 startPoint.fV.Set(vbuf);
457 startPoint.fP.Set(pbuf);
46eadbb4 458
459 Double_t ep = esdTrack->GetP(), mc = esdTrack->GetMass();
460 rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
51346b82 461
84aff7a4 462 TEveTrack* track = new TEveTrack(&rt, rnrStyle);
46eadbb4 463
7279ee15 464 cout<<"startPoint = "<<vbuf[0]<<" "<<vbuf[1]<<" "<<vbuf[2]<<" "<<pbuf[0]<<" "<<pbuf[1]<<" "<<pbuf[2]<<endl;
46eadbb4 465
7279ee15 466
467 for( ; TMath::Abs(dx)>=1.; dx*=.9 ){
468 AliExternalTrackParam endParam = *trackParam;
469 //if( !endParam.PropagateTo(x0+dx, gSolenoidField) ) continue;
470 AliHLTTPCCATrackParam t;
471 t.SetExtParam(endParam, gSolenoidField );
472 if( !t.TransportToX(x0+dx) ) continue;
473 t.GetExtParam( endParam, endParam.GetAlpha(), gSolenoidField );
46eadbb4 474
7279ee15 475 if( TMath::Abs(endParam.GetSnp())>.99 ) continue;
476
46eadbb4 477 { // get momentum manually because trackParam->GetPxPyPz doesn't works for straight lines
478
479 Double_t pt= TMath::Abs(endParam.GetSigned1Pt());
480 pt = (pt>kAlmost0) ?1./pt :100.;
481
482 Double_t cA=TMath::Cos(endParam.GetAlpha()), sA=TMath::Sin(endParam.GetAlpha());
483
484 Double_t sT=endParam.GetSnp();
485 if( sT>=kAlmost1 ){ sT = kAlmost1; }
486 else if( sT<-kAlmost1 ){ sT = -kAlmost1; }
487 Double_t cT = TMath::Sqrt(TMath::Abs(1 - sT*sT));
488
7279ee15 489 endParam.GetXYZ(vbuf);
490 pbuf[0] = pt*(cT*cA - sT*sA);
491 pbuf[1] = pt*(sT*cA + cT*sA);
46eadbb4 492 pbuf[2] = pt*endParam.GetTgl();
493 }
7279ee15 494 break;
495 }
496 endPoint.fV.Set(vbuf);
497 endPoint.fP.Set(pbuf);
498 decPoint.fV.Set(vbuf);
499 decPoint.fP.Set(pbuf);
500
501 cout<<"endPoint = "<<vbuf[0]<<" "<<vbuf[1]<<" "<<vbuf[2]<<" "<<pbuf[0]<<" "<<pbuf[1]<<" "<<pbuf[2]<<endl;
502
503 dx*=.6;
504 for( ; TMath::Abs(dx)>=.5; dx*=.8 ){
505 AliExternalTrackParam endParam = *trackParam;
506 //if( !endParam.PropagateTo(x0+dx, gSolenoidField) ) continue;
507 AliHLTTPCCATrackParam t;
508 t.SetExtParam(endParam, gSolenoidField );
509 if( !t.TransportToX(x0+dx) ) continue;
510 t.GetExtParam( endParam, endParam.GetAlpha(), gSolenoidField );
511 if( TMath::Abs(endParam.GetSnp())>.99 ) continue;
512
513 { // get momentum manually because trackParam->GetPxPyPz doesn't works for straight lines
46eadbb4 514
7279ee15 515 Double_t pt= TMath::Abs(endParam.GetSigned1Pt());
516 pt = (pt>kAlmost0) ?1./pt :100.;
517
518 Double_t cA=TMath::Cos(endParam.GetAlpha()), sA=TMath::Sin(endParam.GetAlpha());
519
520 Double_t sT=endParam.GetSnp();
521 if( sT>=kAlmost1 ){ sT = kAlmost1; }
522 else if( sT<-kAlmost1 ){ sT = -kAlmost1; }
523 Double_t cT = TMath::Sqrt(TMath::Abs(1 - sT*sT));
524
525 endParam.GetXYZ(vbuf);
526 pbuf[0] = pt*(cT*cA - sT*sA);
527 pbuf[1] = pt*(sT*cA + cT*sA);
528 pbuf[2] = pt*endParam.GetTgl();
529 }
530 break;
531 }
532
533 mid1Point.fV.Set(vbuf);
534 mid1Point.fP.Set(pbuf);
535
536 //cout<<"midPoint = "<<vbuf[0]<<" "<<vbuf[1]<<" "<<vbuf[2]<<" "<<pbuf[0]<<" "<<pbuf[1]<<" "<<pbuf[2]<<endl;
537
538 dx*=.5;
539 for( ; TMath::Abs(dx)>=.5; dx*=.8 ){
540 AliExternalTrackParam endParam = *trackParam;
541 //if( !endParam.PropagateTo(x0+dx, gSolenoidField) ) continue;
542 AliHLTTPCCATrackParam t;
543 t.SetExtParam(endParam, gSolenoidField );
544 if( !t.TransportToX(x0+dx) ) continue;
545 t.GetExtParam( endParam, endParam.GetAlpha(), gSolenoidField );
546 if( TMath::Abs(endParam.GetSnp())>.99 ) continue;
46eadbb4 547
7279ee15 548 { // get momentum manually because trackParam->GetPxPyPz doesn't works for straight lines
549
550 Double_t pt= TMath::Abs(endParam.GetSigned1Pt());
551 pt = (pt>kAlmost0) ?1./pt :100.;
552
553 Double_t cA=TMath::Cos(endParam.GetAlpha()), sA=TMath::Sin(endParam.GetAlpha());
554
555 Double_t sT=endParam.GetSnp();
556 if( sT>=kAlmost1 ){ sT = kAlmost1; }
557 else if( sT<-kAlmost1 ){ sT = -kAlmost1; }
558 Double_t cT = TMath::Sqrt(TMath::Abs(1 - sT*sT));
559
560 endParam.GetXYZ(vbuf);
561 pbuf[0] = pt*(cT*cA - sT*sA);
562 pbuf[1] = pt*(sT*cA + cT*sA);
563 pbuf[2] = pt*endParam.GetTgl();
564 }
565 break;
46eadbb4 566 }
7279ee15 567
568 midPoint.fV.Set(vbuf);
569 midPoint.fP.Set(pbuf);
570
571 track->AddPathMark( startPoint );
572 track->AddPathMark( midPoint );
573 track->AddPathMark( mid1Point );
574 track->AddPathMark( endPoint );
575 track->AddPathMark( decPoint );
576
87f60d9e 577 //PH The line below is replaced waiting for a fix in Root
578 //PH which permits to use variable siza arguments in CINT
579 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
580 //PH track->SetName(Form("ESDTrack %d", rt.label));
581 //PH track->SetTitle(Form("pT=%.3f, pZ=%.3f; V=(%.3f, %.3f, %.3f)",
582 //PH rt.sign*TMath::Hypot(rt.P.x, rt.P.y), rt.P.z,
583 //PH rt.V.x, rt.V.y, rt.V.z));
584 char form[1000];
46eadbb4 585 sprintf(form,"TEveTrack %d", rt.fIndex);
87f60d9e 586 track->SetName(form);
587 track->SetStdTitle();
588 return track;
589}
590
591//****************************************************************************
46eadbb4 592Int_t processTPCTracks(AliHLTHOMERBlockDesc* block) {
593
594 TTree *tr = (TTree*) block->GetTObject();
595
7279ee15 596// ofstream fout("ESD_TPC.dat",ios::binary);
597// fout.write((char*)block->GetData(),block->GetSize());
598// fout.close();
599 TFile f("ESD_TPC.root","recreate");
600 tr->Write();
601 f.Close();
602
603 TFile* esdFile = TFile::Open("ESD_TPC.root");
604
605 AliESDEvent* esd = new AliESDEvent();
606 TTree* tree = (TTree*) esdFile->Get("esdTree");
607 esd->ReadFromTree(tree);
608 //tr->SetBranchAddress("ESD", &esd);
609 // if(tr->GetBranch("ESD"))
610 // return 0;
611
612 tree->GetEntry(0);
46eadbb4 613
614 TEveTrackPropagator* rnrStyle = gTPCTrack->GetPropagator();
615 rnrStyle->SetMagField( 0.1*esd->GetMagneticField() );
7279ee15 616 gSolenoidField = esd->GetMagneticField();
87f60d9e 617
46eadbb4 618 cout << "Number of tracks found :" << esd->GetNumberOfTracks() << endl;
619
7279ee15 620 Double_t pin[3];
621
46eadbb4 622 for (Int_t ii=0; ii< esd->GetNumberOfTracks(); ii++) {
623
624 AliESDtrack *esdTrack = esd->GetTrack(ii);
625 AliExternalTrackParam *trackParam = esdTrack;
7279ee15 626 cout<<"\nESD track N"<<ii<<":"<<endl;
627 trackParam->Print();
628
46eadbb4 629 TEveTrack* track = makeESDTrack( rnrStyle, ii, esdTrack, trackParam );
7279ee15 630 esdTrack->GetPxPyPz(pin);
631
632 //cout<<"pt : "<<sqrt(pin[0]*pin[0] + pin[1]*pin[1])<<endl;
633 track->SetAttLineAttMarker(gTPCTrack);
634 gEve->AddElement(track, gTPCTrack);
635 }
46eadbb4 636
7279ee15 637 delete esd;
46eadbb4 638
639 return 0;
640}
87f60d9e 641
7279ee15 642//****************************************************************************
643Int_t processSPDRawData(AliHLTHOMERBlockDesc* block) {
644 Int_t iResult = 0;
46eadbb4 645
7279ee15 646 Int_t partition = block->GetSubDetector().Atoi();
647 Int_t eqId = partition;
46eadbb4 648
7279ee15 649 gMemReader->SetMemory( reinterpret_cast<UChar_t*> ( block->GetData() ), block->GetSize() );
650 gMemReader->SetEquipmentID( eqId );
651 gMemReader->Reset();
46eadbb4 652
7279ee15 653 gITSDigits->ReadRaw( gMemReader, 3);
46eadbb4 654
7279ee15 655 return iResult;
87f60d9e 656}
46eadbb4 657
7279ee15 658//****************************************************************************
659Int_t drawSPDRawData() {
46eadbb4 660
7279ee15 661 Int_t iResult = 0;
46eadbb4 662
7279ee15 663 TString sSector;
664 TString bsSector="Sector";
665 TString sStave;
666 TString bsStave="Stave";
87f60d9e 667
7279ee15 668 Int_t ndx=0;
669 Int_t sector, stave, module;
46eadbb4 670
7279ee15 671 //gEve->DisableRedraw();
46eadbb4 672
7279ee15 673 // ** first layer **
46eadbb4 674
7279ee15 675 TEveElementList* layer1 = new TEveElementList( "SPD0" );
676 layer1->SetTitle( "SPDs' first layer" );
677 layer1->SetMainColor(2);
678 gEve->AddElement( layer1 );
46eadbb4 679
7279ee15 680 for ( sector=0; sector<10; sector++ ) {
681 sSector = bsSector;
682 sSector += sector;
46eadbb4 683
7279ee15 684 TEveElementList* relSector = new TEveElementList( sSector.Data() );
685 relSector->SetMainColor(2);
686 gEve->AddElement( relSector, layer1 );
46eadbb4 687
7279ee15 688 for ( stave=0; stave<2; stave++ ) {
689 sStave = bsStave;
690 sStave += stave;
46eadbb4 691
7279ee15 692 TEveElementList* relStave = new TEveElementList( sStave.Data() );
693 relStave->SetMainColor(2);
694 gEve->AddElement( relStave, relSector );
46eadbb4 695
7279ee15 696 for ( module=0; module<4; module++ ) {
46eadbb4 697
7279ee15 698 if ( gITSDigits->GetDigits( ndx, 0 ) &&
699 gITSDigits->GetDigits( ndx, 0 )->GetEntriesFast() > 0) {
46eadbb4 700
7279ee15 701 AliEveITSModule* moduleITS = new AliEveITSModule( ndx, gITSDigits );
702 gEve->AddElement( moduleITS, relStave );
703 }
46eadbb4 704
7279ee15 705 ++ndx;
46eadbb4 706
7279ee15 707 } // for ( module=0; module<4; module++ ) {
708 } // for ( stave=0; stave<2; stave++ ) {
709 } // for ( sector=0; sector<10; sector++ ) {
46eadbb4 710
7279ee15 711 // ** second layer **
46eadbb4 712
7279ee15 713 TEveElementList* layer2 = new TEveElementList( "SPD1" );
714 layer2->SetTitle( "SPDs' second layer" );
715 layer2->SetMainColor(2);
716 gEve->AddElement(layer2);
717
718 for ( sector=0; sector<10; sector++ ) {
719 sSector = bsSector;
720 sSector += sector;
46eadbb4 721
7279ee15 722 TEveElementList* relSector = new TEveElementList( sSector.Data() );
723 relSector->SetMainColor(2);
724 gEve->AddElement(relSector, layer2 );
46eadbb4 725
7279ee15 726 for ( stave=0; stave<4; stave++ ) {
727 sStave = bsStave;
728 sStave += stave;
87f60d9e 729
7279ee15 730 TEveElementList* relStave = new TEveElementList( sStave.Data() );
731 relStave->SetMainColor(2);
732 gEve->AddElement( relStave, relSector );
87f60d9e 733
7279ee15 734 for ( module=0; module<4; module++) {
87f60d9e 735
7279ee15 736 if ( gITSDigits->GetDigits( ndx, 0 ) &&
737 gITSDigits->GetDigits( ndx, 0 )->GetEntriesFast() > 0) {
46eadbb4 738
7279ee15 739 AliEveITSModule* moduleITS = new AliEveITSModule( ndx, gITSDigits );
740 gEve->AddElement( moduleITS, relStave );
46eadbb4 741 }
7279ee15 742
743 ++ndx;
744 } // for ( module=0; module<4; module++) {
745 } // for ( stave=0; stave<2; stave++ ) {
746 } //for ( sector=0; sector<10; sector++ ) {
46eadbb4 747
7279ee15 748 gEve->EnableRedraw();
46eadbb4 749
7279ee15 750 return iResult;
46eadbb4 751}
87f60d9e 752
753//****************************************************************************
7279ee15 754Int_t processMUONClusters(AliHLTHOMERBlockDesc* block) {
755 Int_t iResult = 0;
46eadbb4 756
7279ee15 757 unsigned long size = block->GetSize();
758 int * buffer ;
46eadbb4 759
7279ee15 760 // for(int idata=0;idata<int(size);idata++)
761 // printf("\tbuffer[%d] : %d\n",idata,buffer[idata]);
46eadbb4 762
7279ee15 763 buffer = (int *)block->GetData();
46eadbb4 764
7279ee15 765 if(block->GetDataType().CompareTo("RECHITS") == 0){
766
767 AliHLTMUONRecHitsBlockReader trackblock((char*)buffer, size);
768 const AliHLTMUONRecHitStruct* hit = trackblock.GetArray();
46eadbb4 769
7279ee15 770 for(AliHLTUInt32_t ientry = 0; ientry < trackblock.Nentries(); ientry++){
771// cout << setw(13) << left << hit->fX << setw(0);
772// cout << setw(13) << left << hit->fY << setw(0);
773// cout << hit->fZ << setw(0) << endl;
774 gMUONClusters->SetNextPoint(hit->fX,hit->fY,hit->fZ);
775 hit++;
776
777 }// track hit loop
778 }else{// if rechits
46eadbb4 779
46eadbb4 780
7279ee15 781// if(!strcmp((BlockType(ULong64_t(reader->GetBlockDataType(i)))).Data(),"TRIGRECS")){
782
783 AliHLTMUONTriggerRecordsBlockReader trigblock(buffer, size);
784 const AliHLTMUONTriggerRecordStruct* trigrec = trigblock.GetArray();
785 for(AliHLTUInt32_t ientry = 0; ientry < trigblock.Nentries(); ientry++){
786
787 const AliHLTMUONRecHitStruct* hit = &trigrec->fHit[0];
788 for(AliHLTUInt32_t ch = 0; ch < 4; ch++)
789 {
790// cout << setw(10) << left << ch + 11 << setw(0);
791// cout << setw(13) << left << hit->fX << setw(0);
792// cout << setw(13) << left << hit->fY << setw(0);
793// cout << hit->fZ << setw(0) << endl;
794 gMUONClusters->SetNextPoint(hit->fX,hit->fY,hit->fZ);
795 hit++;
796 }// trig chamber loop
797
798 }//trig hit loop
799 }// if trigrecs
46eadbb4 800
46eadbb4 801
7279ee15 802// //delete[] buffer;
803// }//nof Block received
804// }// if any event found
46eadbb4 805
7279ee15 806
807// delete reader;
46eadbb4 808
809
7279ee15 810 return iResult;
87f60d9e 811}
812
46eadbb4 813
7279ee15 814//****************************************************************************