]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/hlt-macros/homer_display.C
From Jochen - EveHLT development accumulated since the end of March.
[u/mrichter/AliRoot.git] / EVE / hlt-macros / homer_display.C
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          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
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
20 class AliRawReaderMemory;
21 class AliEveHOMERManager;
22 class AliHLTHOMERBlockDesc;
23
24 class TEvePointSet;
25 class TEveTrackList;
26 class TEveTrack;
27
28 class AliEveTPCLoader;
29 class AliEveTPCData;
30 class AliEveTPCSector2D;
31 class AliEveTPCSector3D;
32 class AliEveITSDigitsInfo;
33
34 //***********************************************************
35 #include "TTimer.h"
36 #include "TRandom.h"
37 #include "TVirtualPad.h"
38 #include "TGLViewer.h"
39 #include "TThread.h"
40 #include "TGFileBrowser.h"
41 #include "TStyle.h"
42 #include "TList.h"
43 #include "TDirectory.h"
44 //***********************************************************
45 #include "TEveManager.h"
46 #include "TEvePointSet.h"
47 #include "TEveTrack.h"
48 #include "TEveVSDStructs.h"
49 #include "TEveTrackPropagator.h"
50 #include "TEvePointSet.h"
51 #include "TEveScene.h"
52 #include "TEveElement.h"
53 // #include "TEveElementList.h"
54 #include "TEveEventManager.h"
55 //***********************************************************
56 #include "AliESDEvent.h"
57 #include "AliCDBManager.h"
58 #include "AliRawReaderMemory.h"
59 #include "AliTPCRawStream.h"
60 #include "AliGeomManager.h"
61 //***********************************************************
62 #include "AliEveHOMERManager.h"
63 #include "AliEveTPCLoader.h" 
64 #include "AliEveTPCData.h"
65 #include "AliEveITSDigitsInfo.h"
66 #include "AliEveITSModule.h"
67 //***********************************************************
68 #include "AliHLTHOMERBlockDesc.h"
69 #include "AliHLTHOMERReader.h"
70 //***********************************************************
71 #include "hlt_structs.C"
72 #include "TFile.h"
73 //***********************************************************
74 #include <AliHLTMUONUtils.h>
75 #include "AliHLTMUONDataBlockReader.h"
76 #include "tracking-ca/AliHLTTPCCATrackParam.h"
77
78 // -- globals --
79  
80 AliEveTPCLoader*                          gTPCLoader    = 0;
81 AliEveTPCData*                            gTPCData      = 0;
82 TEvePointSet*                             gTPCClusters  = 0;
83 TEveTrackList*                            gTPCTrack     = 0;
84
85 AliEveITSDigitsInfo*                      gITSDigits    = 0; 
86
87 AliRawReaderMemory*                       gMemReader    = 0;
88 AliEveHOMERManager*                       gHomerManager = 0;
89
90 TEvePointSet*                             gMUONClusters  = 0;
91 Double_t                                  gSolenoidField = 5;
92 //***********************************************************
93
94 Int_t globMaxPoint = 0 ;
95
96 //***********************************************************
97
98 // -- needed below ??
99
100 Int_t    event  = -1;
101
102 TTimer   timer;
103 TTimer   event_timer;
104
105 TThread* ldthread = 0;
106
107 TRandom  rnd(0);
108
109 Bool_t vC = kFALSE;
110 TGFileBrowser *g_hlt_browser = 0;
111 TCanvas       *g_hlt_canvas  = 0;
112
113 TGLViewer::ECameraType camera = TGLViewer::kCameraPerspXOZ;
114
115 //****************************************************************************
116 Int_t nextEvent();
117
118 //****************************************************************************
119 Int_t processSPDRawData( AliHLTHOMERBlockDesc* block );
120 Int_t drawSPDRawData();
121
122 //****************************************************************************
123 Int_t processTPCRawData( AliHLTHOMERBlockDesc* block );
124 Int_t processTPCClusters( AliHLTHOMERBlockDesc* block );
125 Int_t processTPCTracks( AliHLTHOMERBlockDesc* block );
126
127 Int_t processMUONClusters( AliHLTHOMERBlockDesc* block );
128
129 //****************************************************************************
130 TEveTrack* makeESDTrack( TEveTrackPropagator*   rnrStyle,
131                          Int_t                  idx,
132                          AliESDtrack*           at,
133                          AliExternalTrackParam* tp = 0 );
134
135 //****************************************************************************
136 void homer_display( Int_t run = 0) {
137
138   AliCDBManager::Instance()->SetRun(run);
139   AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
140   
141   gMemReader = new AliRawReaderMemory(0, 0);
142
143   gStyle->SetPalette(1, 0);
144   gEve->DisableRedraw();
145
146   // -- Create HOMER Manager
147   gHomerManager = new AliEveHOMERManager("/local/home/hlt/AliEVE-Config.xml");
148
149   // -- Set Realm  ( can be "GPN","ACR","HLT","KIP" )
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);
160   gTPCLoader->SetInitParams(40, 900, 2, 100);   // Sector params (mint, maxt, thr, maxval)
161   
162   // -- TPC Data
163   gTPCData = gTPCLoader->GetData();
164   gTPCData->SetLoadPedestal(0);
165   gTPCData->SetLoadThreshold(0);
166   gTPCData->SetAutoPedestal(kFALSE);             // For zero suppressed data.
167
168   gEve->AddElement(gTPCLoader);
169
170   gEve->Redraw3D(0,1); // (0, 1)
171   gEve->EnableRedraw();  
172 }
173
174 //****************************************************************************
175 Int_t nextEvent() {
176
177   Int_t iResult = 0;
178
179   gStyle->SetPalette(1, 0);
180   gEve->DisableRedraw();
181
182   // ** Get Next Event from HOMER
183   if ( gHomerManager->NextEvent() ) 
184     return ++iResult;
185
186   // ** Reset
187   if ( gTPCClusters ) gTPCClusters->Reset();
188   if ( gTPCTrack )    gTPCTrack->DestroyElements();
189   if ( gTPCData )     gTPCData->DropAllSectors();
190
191   if ( gITSDigits ) {
192     delete gITSDigits;
193     gITSDigits = NULL;
194   }
195   
196   if ( gMUONClusters ) gMUONClusters->Reset();
197
198
199   // ----------------------------------- foo A
200   vC = kFALSE;
201
202   // TList* hListKR = new TList;
203   // TList* hListCF = new TList;
204
205   // ----------------------------------- foo A
206
207   TIter next(gHomerManager->GetBlockList());
208   AliHLTHOMERBlockDesc* block = 0;
209
210   while ((block = (AliHLTHOMERBlockDesc*)next())) {
211    
212 //     printf ( "Det : %s\n" ,block->GetDetector().Data() );
213 //     printf ( "Datatype : %s\n" ,block->GetDataType().Data() );
214
215     
216     
217     // -- TPC
218     // -----------------------------------------------------
219     
220     if ( ! block->GetDetector().CompareTo("TPC") ){
221       
222
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 ) {
240       // +++ ESD BLOCK
241       // +++++++++++++++++++++++++++++++++++++++++++++++++++++++
242
243         // ** Initialize TPC Tracks
244         if ( !gTPCTrack ) {
245           gTPCTrack = new TEveTrackList("TPC Tracks");
246           gTPCTrack->SetMainColor(kBlue);
247           
248           gEve->AddElement(gTPCTrack);
249         
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 );
259       }
260       
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
282
283
284     }  else if ( ! block->GetDetector().CompareTo("SPD") ) {
285
286       // -- SPD 
287       // -----------------------------------------------------
288
289       if ( block->GetDataType().CompareTo("DDL_RAW") == 0 ) {
290         // ** Initialize SPD Digits
291         if ( !gITSDigits ) {
292           gITSDigits = new AliEveITSDigitsInfo();
293         }
294         
295         processSPDRawData( block );             
296       }
297
298     }else{
299
300       printf ("Detector \"%s\" has not been recognized",block->GetDetector().Data());
301     }
302     
303   }
304   
305   if ( gTPCLoader )   gTPCLoader->UpdateSectors( kTRUE );
306   if ( gTPCClusters ) gTPCClusters->ResetBBox();
307   if ( gTPCTrack )    gTPCTrack->MakeTracks();
308   if ( gITSDigits )   drawSPDRawData();
309   
310   if ( gMUONClusters ) gMUONClusters->ResetBBox();
311   
312   gEve->Redraw3D(0,1); // (0, 1)
313   gEve->EnableRedraw(); 
314     
315   return iResult;
316 }
317
318 //****************************************************************************
319 //****************************************************************************
320 //****************************************************************************
321 void loopEvent() {
322   event_timer.SetCommand("nextEvent()");
323   event_timer.Start(6000);
324 }
325
326 //****************************************************************************
327 void stopLoopEvent() {
328   event_timer.Stop();
329 }
330
331 //****************************************************************************
332 Int_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
343   printf("sector : %d %d %d -- %p %lu\n", sector, patch, eqId, block->GetData(), block->GetSize());
344
345   gMemReader->SetMemory( reinterpret_cast<UChar_t*> ( block->GetData() ), block->GetSize() );
346   gMemReader->SetEquipmentID( eqId );
347   gMemReader->Reset();
348
349   AliTPCRawStream tpcStream( gMemReader );
350   gMemReader->Select("TPC"); 
351   
352   gTPCData->LoadRaw( tpcStream, kTRUE, kTRUE );
353
354   return iResult;
355 }
356
357 //****************************************************************************
358 Int_t processTPCClusters(AliHLTHOMERBlockDesc* block) {
359   Int_t iResult = 0;
360
361   Int_t   slice = block->GetSubDetector().Atoi();
362   Int_t   patch = block->GetSubSubDetector().Atoi();
363   Float_t phi   = ( slice + 0.5 ) * TMath::Pi() / 9.0;  
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     }
381   }
382
383   return iResult;
384 }
385
386 //****************************************************************************
387 TEveTrack* makeESDTrack( TEveTrackPropagator*   rnrStyle,
388                          Int_t                  idx,
389                          AliESDtrack*           esdTrack,
390                          AliExternalTrackParam* trackParam  ) {
391   // Helper function
392   
393   Double_t     pbuf[3], vbuf[3];
394   TEveRecTrack rt;
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;
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();
420
421   Double_t x0 = trackParam->GetX();
422   Double_t dx = esdTrack->GetTPCPoints(2) - x0;
423
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;
431
432     startParam.GetXYZ(vbuf);
433     
434     { // get momentum manually because trackParam->GetPxPyPz doesn't works for straight lines
435
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     }
450   
451     break;
452   }
453
454   rt.fV.Set(vbuf);
455   rt.fP.Set(pbuf);
456   startPoint.fV.Set(vbuf);
457   startPoint.fP.Set(pbuf);
458   
459   Double_t ep = esdTrack->GetP(), mc = esdTrack->GetMass();
460   rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
461
462   TEveTrack* track = new TEveTrack(&rt, rnrStyle);
463
464   cout<<"startPoint = "<<vbuf[0]<<" "<<vbuf[1]<<" "<<vbuf[2]<<" "<<pbuf[0]<<" "<<pbuf[1]<<" "<<pbuf[2]<<endl;
465
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 );
474
475     if( TMath::Abs(endParam.GetSnp())>.99 ) continue;
476     
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       
489       endParam.GetXYZ(vbuf);
490       pbuf[0] = pt*(cT*cA - sT*sA);
491       pbuf[1] = pt*(sT*cA + cT*sA);
492       pbuf[2] = pt*endParam.GetTgl();
493     }
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
514
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;
547     
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;
566   }
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   
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];
585   sprintf(form,"TEveTrack %d", rt.fIndex);
586   track->SetName(form);
587   track->SetStdTitle();
588   return track;
589 }
590
591 //****************************************************************************
592 Int_t processTPCTracks(AliHLTHOMERBlockDesc* block) {
593
594   TTree *tr = (TTree*) block->GetTObject();
595
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);
613
614   TEveTrackPropagator* rnrStyle = gTPCTrack->GetPropagator();
615   rnrStyle->SetMagField( 0.1*esd->GetMagneticField() );
616   gSolenoidField = esd->GetMagneticField();
617
618   cout << "Number of tracks found :" << esd->GetNumberOfTracks() << endl;
619
620   Double_t pin[3];
621   
622   for (Int_t ii=0; ii< esd->GetNumberOfTracks(); ii++) {
623
624     AliESDtrack           *esdTrack = esd->GetTrack(ii);
625     AliExternalTrackParam *trackParam = esdTrack;
626     cout<<"\nESD track N"<<ii<<":"<<endl;
627     trackParam->Print();
628
629     TEveTrack* track = makeESDTrack( rnrStyle, ii, esdTrack, trackParam );
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  }
636   
637   delete esd;
638   
639   return 0;
640 }
641
642 //****************************************************************************
643 Int_t processSPDRawData(AliHLTHOMERBlockDesc* block) {
644   Int_t iResult = 0;
645
646   Int_t partition = block->GetSubDetector().Atoi();
647   Int_t eqId      = partition;
648
649   gMemReader->SetMemory( reinterpret_cast<UChar_t*> ( block->GetData() ), block->GetSize() );
650   gMemReader->SetEquipmentID( eqId );
651   gMemReader->Reset();
652
653   gITSDigits->ReadRaw( gMemReader, 3);
654
655   return iResult;
656 }
657
658 //****************************************************************************
659 Int_t drawSPDRawData() {
660
661   Int_t iResult = 0;
662
663   TString sSector;
664   TString bsSector="Sector";
665   TString sStave;
666   TString bsStave="Stave";
667
668   Int_t ndx=0;
669   Int_t sector, stave, module;
670
671   //gEve->DisableRedraw();
672
673   // ** first layer **
674
675   TEveElementList* layer1 = new TEveElementList( "SPD0" );
676   layer1->SetTitle( "SPDs' first layer" );
677   layer1->SetMainColor(2);
678   gEve->AddElement( layer1 );
679   
680   for ( sector=0; sector<10; sector++ ) {
681     sSector  = bsSector;
682     sSector += sector;
683
684     TEveElementList* relSector = new TEveElementList( sSector.Data() );
685     relSector->SetMainColor(2);
686     gEve->AddElement( relSector, layer1 );
687
688     for ( stave=0; stave<2; stave++ ) {
689       sStave  = bsStave;
690       sStave += stave;
691       
692       TEveElementList* relStave = new TEveElementList( sStave.Data() );
693       relStave->SetMainColor(2);
694       gEve->AddElement( relStave, relSector );
695
696       for ( module=0; module<4; module++ ) {
697         
698         if ( gITSDigits->GetDigits( ndx, 0 ) && 
699              gITSDigits->GetDigits( ndx, 0 )->GetEntriesFast() > 0) {
700           
701           AliEveITSModule* moduleITS = new AliEveITSModule( ndx, gITSDigits );
702           gEve->AddElement( moduleITS, relStave );
703         }
704
705         ++ndx; 
706
707       } // for ( module=0; module<4; module++ ) {
708     } // for ( stave=0; stave<2; stave++ ) {
709   } // for ( sector=0; sector<10; sector++ ) {
710
711   // ** second layer **
712
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;
721     
722     TEveElementList* relSector = new TEveElementList( sSector.Data() );
723     relSector->SetMainColor(2);
724     gEve->AddElement(relSector, layer2 );
725     
726     for ( stave=0; stave<4; stave++ ) {
727       sStave  = bsStave;
728       sStave += stave;
729
730       TEveElementList* relStave = new TEveElementList( sStave.Data() );
731       relStave->SetMainColor(2);
732       gEve->AddElement( relStave, relSector );
733
734       for ( module=0; module<4; module++) {
735
736         if ( gITSDigits->GetDigits( ndx, 0 ) && 
737              gITSDigits->GetDigits( ndx, 0 )->GetEntriesFast() > 0) {
738
739           AliEveITSModule* moduleITS = new AliEveITSModule( ndx, gITSDigits );
740           gEve->AddElement( moduleITS, relStave );
741         }
742          
743         ++ndx;
744       } // for ( module=0; module<4; module++) {
745     } // for ( stave=0; stave<2; stave++ ) {
746   } //for ( sector=0; sector<10; sector++ ) {
747
748   gEve->EnableRedraw();
749     
750   return iResult;
751 }
752
753 //****************************************************************************
754 Int_t processMUONClusters(AliHLTHOMERBlockDesc* block) {
755   Int_t iResult = 0;
756
757       unsigned long size = block->GetSize();
758       int * buffer ;
759
760       //       for(int idata=0;idata<int(size);idata++)
761       //        printf("\tbuffer[%d] : %d\n",idata,buffer[idata]);
762       
763       buffer = (int *)block->GetData();
764       
765       if(block->GetDataType().CompareTo("RECHITS") == 0){
766         
767         AliHLTMUONRecHitsBlockReader trackblock((char*)buffer, size);
768         const AliHLTMUONRecHitStruct* hit = trackblock.GetArray();
769       
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
779       
780       
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
800       
801       
802 //       //delete[] buffer;
803 //     }//nof Block received
804 //   }// if any event found
805   
806   
807 //   delete reader;
808
809
810   return iResult;
811 }
812
813
814 //****************************************************************************