1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
5 * for The ALICE Off-line Project. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /** @file AliHLTTPCDisplayMain.cxx
17 @author Jochen Thaeder
19 @brief Interface class for ALICE HLT online Display
25 #if defined(HAVE_HOMERREADER)
26 #include "HOMERReader.h"
27 #endif // defined(HAVE_HOMERREADER)
29 #include "AliHLTTPCDisplayMain.h"
30 #include "AliHLTTPCDisplayCharge.h"
31 #include "AliHLTTPCDisplayPadRow.h"
32 #include "AliHLTTPCDisplayPad.h"
33 #include "AliHLTTPCDisplay3D.h"
34 #include "AliHLTTPCDisplayResiduals.h"
35 #include "AliHLTTPCDisplayFront.h"
37 #include "AliHLTStdIncludes.h"
38 #include "AliHLTTPCDefinitions.h"
39 #include "AliHLTDataTypes.h"
40 #include "AliHLTTPCSpacePointData.h"
41 #include "AliHLTTPCClusterDataFormat.h"
42 #include "AliHLTTPCTrackletDataFormat.h"
43 #include "AliHLTTPCDigitReader.h"
44 #include "AliHLTTPCDigitReaderRaw.h"
45 #include "AliHLTTPCPad.h"
46 #include "AliHLT_C_Component_WrapperInterface.h"
47 #include "AliHLTTPCLogging.h"
49 #include "AliHLTTPCTransform.h"
50 #include "AliHLTTPCTrack.h"
51 #include "AliHLTTPCTrackArray.h"
52 #include "AliHLTTPCMemHandler.h"
53 #include "AliHLTTPCDigitReaderPacked.h"
56 #include <TClonesArray.h>
58 #include <AliSimDigits.h>
59 #include <AliTPCParam.h>
66 // -- input datatypes , reverse
67 const Char_t* spptID = "SRETSULC"; // CLUSTERS
68 const Char_t* trksegID = "SGESKART"; // TRAKSEGS
69 const Char_t* trkID = " SKCART"; // TRACKS
70 const Char_t* padrowID = "KPWR_LDD"; // DDL_RWPK
72 ClassImp(AliHLTTPCDisplayMain)
74 //____________________________________________________________________________________________________
75 AliHLTTPCDisplayMain::AliHLTTPCDisplayMain(void* pt2GUI, void (*pt2Function)(void*, Int_t)) {
78 AliHLTLogging::SetGlobalLoggingLevel(kHLTLogError);
80 fCanvasArray = new TCanvas* [nCanvasTypes];
81 fWorkerArray = new void* [nWorkerTypes];
84 fgNTimeBins = 1024; // 446 or 1024
87 fZeroSuppressionThreshold = 10;
88 fOccupancyLimit = 1.0;
94 fPadCallback = pt2Function;
101 fDisplayCharge = NULL;
102 fDisplayPadRow = NULL;
105 fDisplayResiduals = NULL;
106 fDisplayFront = NULL;
108 fCanvasCharge = NULL;
109 fCanvasPadRow = NULL;
112 fCanvasResiduals = NULL;
114 fCanvasHits_S = NULL;
115 fCanvasQ_Track = NULL;
117 fCanvasPadRow_Pad = NULL;
120 fExistsRawData = kFALSE;
121 fExistsClusterData = kFALSE;
122 fExistsTrackData = kFALSE;
124 memset(fClusters,0,36*6*sizeof(AliHLTTPCSpacePointData*));
125 memset(fNcl, 0, 36*6*sizeof(UInt_t));
129 fZeroSuppression = kTRUE;
130 fNPads = AliHLTTPCTransform::GetNPads(0);
134 fSplitPadRow = kFALSE;
136 fFrontDataSwitch = 2;
138 fTimeBinMax = GetNTimeBins() -1;
139 fSplitFront = kFALSE;
142 fSelectTrackSlice = 0;
143 fSelectTrackSwitch = kFALSE;
160 fSwitch3DCluster = kFALSE;
161 fSwitch3DTracks = kFALSE;
162 fSwitch3DPadRow = kFALSE;
163 fSwitch3DGeometry = kTRUE;
174 fTrackParam.kappa = 0.;
175 fTrackParam.nHits = 0;
176 fTrackParam.charge = 0;
177 fTrackParam.radius = 0.;
178 fTrackParam.slice = 0;
179 fTrackParam.phi0 = 0.;
180 fTrackParam.psi = 0.;
181 fTrackParam.lambda = 0.;
184 fTrackParam.bfield = 0.;
188 //____________________________________________________________________________________________________
189 AliHLTTPCDisplayMain::~AliHLTTPCDisplayMain() {
191 if ( fTracks ) delete fTracks;
194 if ( fCanvasArray ) delete fTracks;
197 if ( fWorkerArray ) delete fWorkerArray;
200 #if defined(HAVE_HOMERREADER)
201 HOMERReader* reader= (HOMERReader*) fReader;
206 #endif // defined(HAVE_HOMERREADER)
208 if (fDisplayResiduals)
209 delete fDisplayResiduals;
210 fDisplayResiduals = NULL;
221 delete fDisplayPadRow;
222 fDisplayPadRow = NULL;
225 delete fDisplayFront;
226 fDisplayFront = NULL;
229 delete fDisplayCharge;
230 fDisplayCharge = NULL;
233 //____________________________________________________________________________________________________
234 Int_t AliHLTTPCDisplayMain::Connect( unsigned int cnt, const char** hostnames, unsigned short* ports, Char_t *gfile){
236 Char_t* defaultGeometry=NULL;
237 #if defined(DEFAULT_GEOMETRY)
238 defaultGeometry=DEFAULT_GEOMETRY;
241 HLTDebug("probing geometry file %s", gfile);
242 ifstream test(gfile);
244 HLTWarning("unable to find geometry file %s, using default file", gfile);
245 gfile=defaultGeometry;
249 HLTDebug("using default geometry file %s", gfile, defaultGeometry);
250 gfile=defaultGeometry;
253 HLTError("geometry file missing");
256 #if defined(HAVE_HOMERREADER)
262 // -- CONNECT to TCPDumpSubscriber via HOMER
263 // ---------------------------------------------
264 HOMERReader* reader = new HOMERReader( cnt, (const char**) hostnames, ports );
265 ret=reader->GetConnectionStatus();
268 Int_t ndx = reader->GetErrorConnectionNdx();
269 if ( ndx < (Int_t) cnt) HLTError("Error establishing connection to TCP source %s:%hu: %s (%d)\n", hostnames[ndx], ports[ndx], strerror(ret), ret );
270 else HLTError("Error establishing connection to unknown source with index %d: %s (%d)\n",ndx, strerror(ret), ret );
277 // -- ERROR HANDLING for HOMER (error codes and empty blocks)
278 // --------------------------------------------------------------
279 Int_t ret1 = reader->ReadNextEvent(3000000); // timeout in microseconds (3s)
282 Int_t ndx = reader->GetErrorConnectionNdx();
284 if ( ret1 == 111 || ret1 == 32 ) {
285 HLTError( "Error, No Connection to source %d: %s (%d)\n", ndx, strerror(ret1), ret1 );
292 else if (ret1 == 110){
293 HLTError( "Timout occured, reading event from source %d: %s (%d)\n", ndx, strerror(ret1), ret1 );
300 else if ( ret1 == 56 || ret1 == 6 ) {
301 HLTError( "Error reading event from source %d: %s (%d) -- RETRY\n", ndx, strerror(ret1), ret1 );
309 HLTError( "General Error reading event from source %d: %s (%d)\n", ndx, strerror(ret1), ret1 );
318 unsigned long blockCnt = reader->GetBlockCnt();
320 HLTDebug( "Event 0x%016LX (%Lu) with %lu blocks\n", (ULong64_t)reader->GetEventID(), (ULong64_t)reader->GetEventID(), blockCnt );
328 // SWITCH on the Display parts according what DATATAYPES are present
329 // ---------------------------------------------------------------------
330 for ( unsigned long i = 0; i < blockCnt; i++ ) {
332 memset( tmp1, 0, 9 );
334 ULong64_t* tmp12 = (ULong64_t*)tmp11;
335 *tmp12 = reader->GetBlockDataType( i );
337 if (!strcmp(tmp1,padrowID)) fExistsRawData = kTRUE;
338 else if (!strcmp(tmp1,spptID)) fExistsClusterData = kTRUE;
339 else if (!strcmp(tmp1,trksegID)) fExistsTrackData = kTRUE;
340 else if (!strcmp(tmp1,trkID)) fExistsTrackData = kTRUE;
343 // -- Set reader and eventID
344 // -------------------------------
345 fEventID = (ULong64_t)reader->GetEventID();
346 fReader = (void*) reader;
349 break; // leave while(1), if connected to source
353 // -- Initialize TPC Display Classes -- IMPORTANT... don't change the order of them
354 // Check if necessary data types are present
355 // ------------------------------------------------------------------------------------
356 fDisplay3D = new AliHLTTPCDisplay3D(this, gfile);
358 if (ExistsRawData()){
359 fDisplayPadRow = new AliHLTTPCDisplayPadRow(this);
360 fDisplayPad = new AliHLTTPCDisplayPad(this);
361 fDisplayFront = new AliHLTTPCDisplayFront(this);
364 if (ExistsClusterData()){
365 fDisplayCharge = new AliHLTTPCDisplayCharge(this);
368 if (ExistsTrackData() && ExistsClusterData() ){
369 fDisplayResiduals = new AliHLTTPCDisplayResiduals(this);
375 HLTFatal("HOMER reader not available");
376 #endif // defined(HAVE_HOMERREADER)
381 //____________________________________________________________________________________________________
382 Int_t AliHLTTPCDisplayMain::Disconnect(){
383 #if defined(HAVE_HOMERREADER)
384 // READ CLUSTER and TRACK data
385 HOMERReader* reader = (HOMERReader*)fReader;
392 HLTFatal("HOMER raeder not available");
393 #endif // defined(HAVE_HOMERREADER)
399 //____________________________________________________________________________________________________
400 Int_t AliHLTTPCDisplayMain::ReadData(Bool_t nextSwitch){
401 // READ CLUSTER and TRACK data
403 #if defined(HAVE_HOMERREADER)
404 HOMERReader* reader = (HOMERReader*)fReader;
406 // -- reset TracksPerSlice Array
407 for(Int_t ii=0;ii<36;ii++) fTracksPerSlice[ii] = 0;
412 // -- READ next event data and ERROR HANDLING for HOMER (error codes and empty blocks)
413 // ---------------------------------------------------------------------------------------
417 ret = reader->ReadNextEvent();
419 if ( ret == 111 || ret == 32 || ret == 6 ) {
420 Int_t ndx = reader->GetErrorConnectionNdx();
421 HLTError( "Error, No Connection to source %d: %s (%d)\n", ndx, strerror(ret), ret );
424 else if ( ret == 110 ) {
425 Int_t ndx = reader->GetErrorConnectionNdx();
426 HLTError( "Timout occured, reading event from source %d: %s (%d)\n", ndx, strerror(ret), ret );
429 else if ( ret == 56) {
430 Int_t ndx = reader->GetErrorConnectionNdx();
431 HLTError( "Error reading event from source %d: %s (%d) -- RETRY\n", ndx, strerror(ret), ret );
435 Int_t ndx = reader->GetErrorConnectionNdx();
436 HLTError( "General Error reading event from source %d: %s (%d)\n", ndx, strerror(ret), ret );
443 } // end if (nextSwitch)
445 // -- Get blockCnt and eventID
446 // -------------------------------
447 ULong_t blockCnt = reader->GetBlockCnt();
448 fEventID = (ULong64_t)reader->GetEventID();
450 HLTError( "Event 0x%016LX (%Lu) with %lu blocks\n", (ULong64_t)reader->GetEventID(), (ULong64_t)reader->GetEventID(), blockCnt );
452 // Loop for Debug only
453 for ( ULong_t i = 0; i < blockCnt; i++ ) {
454 Char_t tmp1[9], tmp2[5];
455 memset( tmp1, 0, 9 );
456 memset( tmp2, 0, 5 );
458 ULong64_t* tmp12 = (ULong64_t*)tmp11;
459 *tmp12 = reader->GetBlockDataType( i );
461 ULong_t* tmp22 = (ULong_t*)tmp21;
462 *tmp22 = reader->GetBlockDataOrigin( i );
464 HLTError( "Block %lu length: %lu - type: %s - origin: %s\n",i, reader->GetBlockDataLength( i ), tmp1, tmp2 );
465 } // end for ( ULong_t i = 0; i < blockCnt; i++ ) {
469 //---------------------
472 // -- READ CLUSTER DATA
473 //-------------------------
477 //-------------------
481 HLTFatal("HOMER raeder not available");
482 #endif // defined(HAVE_HOMERREADER)
487 //____________________________________________________________________________________________________
488 void AliHLTTPCDisplayMain::DisplayEvent(Bool_t newRawSlice){
489 #if defined(HAVE_HOMERREADER)
490 HOMERReader* reader = (HOMERReader*)fReader;
492 //--------------------------------------------------------------------------------------------
493 // READ RAW DATA for PADROW/PAD HISTOGRAM
494 //--------------------------------------------------------------------------------------------
495 if ( ExistsRawData() ){
496 fDisplayPadRow->Reset();
497 fDisplayPad->Reset();
498 fDisplayFront->Reset();
500 if (newRawSlice) ReadRawData();
504 fDisplayPadRow->Fill();
505 fDisplayFront->Fill();
509 fDisplayPadRow->Draw();
510 fDisplayFront->Draw();
513 //--------------------------------------------------------------------------------------------
515 //--------------------------------------------------------------------------------------------
516 if ( ExistsClusterData() && ExistsTrackData() ){
517 fDisplayResiduals->Reset();
518 fDisplayResiduals->Fill();
519 fDisplayResiduals->Draw();
522 //--------------------------------------------------------------------------------------------
524 //--------------------------------------------------------------------------------------------
525 if ( ExistsClusterData() ){
526 fDisplayCharge->Reset();
527 fDisplayCharge->Fill();
528 fDisplayCharge->Draw();
531 //--------------------------------------------------------------------------------------------
533 //--------------------------------------------------------------------------------------------
535 // TAKE CARE !!! EXISTSxxxData() HANDLING of 3D will be done IN this class !!!
538 cout << "afterdraw" << endl;
540 HLTFatal("HOMER raeder not available");
541 #endif // defined(HAVE_HOMERREADER)
545 //____________________________________________________________________________________________________
546 void AliHLTTPCDisplayMain::SaveHistograms(){
547 // Save histograms as eps
548 fDisplayCharge->Save();
549 fDisplayPadRow->Save();
552 fDisplayResiduals->Save();
553 fDisplayFront->Save();
554 fDisplayCharge->Save();
557 //----------------------------------------------------------------------------------------------------
559 //____________________________________________________________________________________________________
560 //____________________________________________________________________________________________________
561 void AliHLTTPCDisplayMain::ReadRawData(){
562 // -- READ raw data of one sector into 3D arrays fRawData and fRawDataZeroSuppressed
565 memset(fRawData, 0, 159*140*1024*sizeof(UInt_t));
566 memset(fRawDataZeroSuppressed, 0, 159*140*1024*sizeof(UInt_t));
568 #if defined(HAVE_HOMERREADER)
569 HOMERReader* reader = (HOMERReader*)fReader;
571 // -- read raw data blocks
572 // ---------------------------
574 Char_t* rawID = "KPWR_LDD";
575 blk = reader->FindBlockNdx( rawID, " CPT",0xFFFFFFFF );
577 while ( blk != ~(ULong_t)0 ) {
578 HLTDebug( "Found raw data block %lu\n", blk );
580 #if HOMER_VERSION >= 2
581 // -- Check for corrupt data
582 AliHLTUInt64_t corruptFlag = reader->GetBlockStatusFlags( blk );
583 if (corruptFlag & 0x00000001) {
584 HLTError( "Data block %lu is corrupt\n",blk );
585 blk = reader->FindBlockNdx( rawID, " CPT", 0xFFFFFFFF, blk+1 );
590 void* rawDataBlock = (void*) reader->GetBlockData( blk );
591 unsigned long rawDataLen = reader->GetBlockDataLength( blk );
593 ULong_t spec = reader->GetBlockDataSpec( blk );
594 Int_t patch = AliHLTTPCDefinitions::GetMinPatchNr( spec );
595 Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr( spec );
597 HLTDebug( "Raw data found for slice %u - patch %u\n", slice, patch );
599 // -- Wrong slice for raw data
600 if ( GetSlicePadRow() != slice) {
601 blk = reader->FindBlockNdx( rawID, " CPT", 0xFFFFFFFF, blk+1 );
605 #if defined(HAVE_TPC_MAPPING)
607 // -- Read data out of block
608 AliHLTTPCDigitReaderRaw digitReader( GetRawReaderMode() );
610 // Initialize RAW DATA
611 Int_t firstRow = AliHLTTPCTransform::GetFirstRow(patch);
612 Int_t lastRow = AliHLTTPCTransform::GetLastRow(patch);
614 // Outer sector, patches 2, 3, 4, 5 - start counting in patch 2 with row 0
616 if ( patch >= 2 ) rowOffset = AliHLTTPCTransform::GetFirstRow( 2 );
618 // Initialize block for reading packed data
619 digitReader.InitBlock(rawDataBlock,rawDataLen,firstRow,lastRow,patch,slice);
621 Bool_t readValue = digitReader.Next();
624 HLTError ( "No value in data block %lu \n", blk);
625 blk = reader->FindBlockNdx( rawID, " CPT", 0xFFFFFFFF, blk+1 );
629 // -- Fill Zero Suppressed Array
630 // ---------------------------------
633 UShort_t time=0,newTime=0;
634 UInt_t pad=0,newPad=0;
637 Int_t gatingGridOffset=50;
638 Int_t signalThreshold = GetZeroSuppressionThreshold();
639 AliHLTTPCPad baseline(gatingGridOffset, GetNTimeBins() );
641 // just to make later conversion to a list of objects easier
642 AliHLTTPCPad* pCurrentPad=NULL;
643 if ( signalThreshold >= 0) {
644 pCurrentPad=&baseline;
645 baseline.SetThreshold(signalThreshold);
648 while ( readValue ) { // Reads through all digits in block
650 while(1){ //Loop over time bins of current pad
651 // read all the values for one pad at once to calculate the base line
654 if (!pCurrentPad->IsStarted()) {
656 // HLTDebug("reading data for pad %d, padrow %d", digitReader.GetPad(), digitReader.GetRow()+rowOffset);
658 pCurrentPad->SetID(digitReader.GetRow()+rowOffset,digitReader.GetPad());
660 if ( (pCurrentPad->StartEvent()) >= 0) {
661 // loop over data of one pad and read it into AliHLTTPCPad class
663 if ( (digitReader.GetRow()+rowOffset) != pCurrentPad->GetRowNumber() ) break;
664 if ( digitReader.GetPad() != pCurrentPad->GetPadNumber() ) break;
665 pCurrentPad->SetRawData( digitReader.GetTime(), digitReader.GetSignal() );
667 // HLTDebug("set raw data to pad: bin %d charge %d", digitReader.GetTime(), digitReader.GetSignal());
669 } while ( (readValue = digitReader.Next()) != 0 );
672 // calculate baseline of pad
673 pCurrentPad->CalculateBaseLine( GetNTimeBins() / 2);
675 if ( pCurrentPad->Next(kTRUE/*do zero suppression*/) == 0 ) {
676 // HLTDebug("no data available after zero suppression");
678 pCurrentPad->StopEvent();
679 pCurrentPad->ResetHistory();
683 Int_t time = pCurrentPad->GetCurrentPosition();
684 if ( time > pCurrentPad->GetSize() ) {
685 HLTError("invalid time bin for pad");
688 } // end - if (!pCurrentPad->IsStarted()) {
689 } // end - if (pCurrentPad) {
692 Float_t occupancy=pCurrentPad->GetOccupancy();
693 if ( occupancy < GetOccupancyLimit() ) {
694 signal = pCurrentPad->GetCorrectedData();
698 HLTInfo("ignoring pad %d with occupancy level %f %%", pCurrentPad->GetPadNumber(), occupancy);
700 // signal = pCurrentPad->GetCorrectedData();
702 signal = digitReader.GetSignal();
705 fRawDataZeroSuppressed[ pCurrentPad->GetRowNumber() ][ pCurrentPad->GetPadNumber() ][ pCurrentPad->GetCurrentPosition() ] = (UInt_t)signal;
708 HLTDebug("get next charge value: position %d charge %d", time, signal);
710 if( time >= AliHLTTPCTransform::GetNTimeBins() ){
711 HLTWarning("Timebin (%d) out of range (%d)", time, AliHLTTPCTransform::GetNTimeBins());
717 if( (pCurrentPad->Next(kTRUE/*do zero suppression*/)) == 0 ) {
718 pCurrentPad->StopEvent();
719 pCurrentPad->ResetHistory();
722 newPad = digitReader.GetPad();
723 newTime = digitReader.GetTime();
724 newRow = digitReader.GetRow() + rowOffset;
729 newPad=pCurrentPad->GetPadNumber();
730 newTime=pCurrentPad->GetCurrentPosition();
731 newRow=pCurrentPad->GetRowNumber();
735 readValue = digitReader.Next();
737 //Check where to stop:
738 if(!readValue) break; //No more value
740 newPad = digitReader.GetPad();
741 newTime = digitReader.GetTime();
742 newRow = digitReader.GetRow() + rowOffset;
745 if(newPad != pad) break; //new pad
746 if(newTime != time+1) break; //end of sequence
750 } // end - while(1){ // Loop over time bins of current pad
752 if ( !readValue ) break;
754 } // end while ( readValue ) {
756 // -- END ZERO SUPPRESSION
758 // Rewind block for reading packed data
759 digitReader.InitBlock(rawDataBlock,rawDataLen,firstRow,lastRow,patch,slice);
762 // ---------------------
763 readValue = digitReader.Next();
765 // LOOP over raw data and fill arrays
768 Int_t row = digitReader.GetRow() + rowOffset;
769 Int_t pad = (Int_t) digitReader.GetPad();
770 Int_t time = (Int_t) digitReader.GetTime();
771 UInt_t signal = (UInt_t) digitReader.GetSignal();
773 fRawData[row][pad][time] = signal;
775 // -- read next value
776 readValue = digitReader.Next();
779 if(!readValue) break;
781 } // end while ( readValue ){
783 #else //! defined(HAVE_TPC_MAPPING)
784 HLTFatal("DigitReaderRaw not available - check your build");
785 #endif //defined(HAVE_TPC_MAPPING)
787 blk = reader->FindBlockNdx( rawID, " CPT", 0xFFFFFFFF, blk+1 );
789 } // end while ( blk != ~(ULong_t)0 ) {
792 HLTFatal("HOMER raeder not available");
793 #endif // defined(HAVE_HOMERREADER)
797 //____________________________________________________________________________________________________
798 void AliHLTTPCDisplayMain::ReadClusterData(){
799 // -- READ cluster data
800 #if defined(HAVE_HOMERREADER)
801 HOMERReader* reader = (HOMERReader*)fReader;
804 blk = reader->FindBlockNdx( (char*)spptID, " CPT",0xFFFFFFFF );
806 while ( blk != ~(ULong_t)0 ) {
807 HLTDebug( "Found clusters block %lu\n", blk );
809 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)reader->GetBlockData( blk );
810 if ( !clusterData ) {
811 HLTError( "No track data for block %lu\n", blk );
812 blk = reader->FindBlockNdx( (char*)spptID, " CPT", 0xFFFFFFFF, blk+1 );
816 ULong_t spec = reader->GetBlockDataSpec( blk );
817 Int_t patch = AliHLTTPCDefinitions::GetMinPatchNr( spec );
818 Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr( spec );
820 HLTDebug( "%lu Clusters found for slice %u - patch %u\n", clusterData->fSpacePointCnt, slice, patch );
822 void* tmp30 = (void*)clusterData;
823 Byte_t* tmp31 = (Byte_t*)tmp30;
825 offset = sizeof(clusterData->fSpacePointCnt);
826 if ( offset <= reader->GetBlockTypeAlignment( blk, 1 ) ) offset = reader->GetBlockTypeAlignment( blk, 1 );
829 AliHLTTPCSpacePointData* tmp32 = (AliHLTTPCSpacePointData*)tmp30;
831 SetupCluster( slice, patch, clusterData->fSpacePointCnt, tmp32 );
833 blk = reader->FindBlockNdx( (char*)spptID, " CPT", 0xFFFFFFFF, blk+1 );
837 HLTFatal("HOMER raeder not available");
838 #endif // defined(HAVE_HOMERREADER)
840 //____________________________________________________________________________________________________
841 void AliHLTTPCDisplayMain::ReadTrackData(){
842 // -- READ track data
844 if ( fTracks ) delete fTracks;
845 fTracks = new AliHLTTPCTrackArray;
847 #if defined(HAVE_HOMERREADER)
848 HOMERReader* reader = (HOMERReader*)fReader;
850 ULong_t blk=~(ULong_t)0;
851 const Char_t* searchIDs[]={trksegID, trkID, NULL};
852 const Char_t** currentID=searchIDs;
854 blk = reader->FindBlockNdx( (char*)*currentID, " CPT", 0xFFFFFFFF );
855 } while (blk==~(ULong_t)0 && *(++currentID)!=NULL);
857 while ( blk != ~(ULong_t)0 || (*currentID!=NULL && *(++currentID)!=NULL )) {
858 if (blk == ~(ULong_t)0) {
859 blk = reader->FindBlockNdx( (char*)*currentID, " CPT", 0xFFFFFFFF );
863 HLTDebug( "Found tracks in block %lu type %s\n", blk, *currentID );
865 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*)reader->GetBlockData( blk );
868 HLTError( "No track data for block %lu\n", blk );
869 blk = reader->FindBlockNdx( (char*)*currentID, " CPT", 0xFFFFFFFF, blk+1 );
873 ULong_t spec = reader->GetBlockDataSpec( blk );
874 Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr( spec );
875 Int_t patchmin = AliHLTTPCDefinitions::GetMinPatchNr( spec );
876 Int_t patchmax = AliHLTTPCDefinitions::GetMaxPatchNr( spec );
878 HLTDebug( "%lu tracks found for slice %u - patch %u-%u\n", trackData->fTrackletCnt, slice, patchmin, patchmax );
880 fTracksPerSlice[slice] = trackData->fTrackletCnt; // Fill number if tracks per slice
882 AliHLTTPCTrackSegmentData* tmp42 = (AliHLTTPCTrackSegmentData*) &(trackData->fTracklets[0]);
883 fTracks->FillTracks( trackData->fTrackletCnt, tmp42, slice, (*currentID==trksegID?1:0) );
885 blk = reader->FindBlockNdx( (char*)*currentID, " CPT", 0xFFFFFFFF, blk+1 );
891 HLTFatal("HOMER raeder not available");
892 #endif // defined(HAVE_HOMERREADER)
895 //----------------------------------------------------------------------------------------------------
897 //____________________________________________________________________________________________________
898 void AliHLTTPCDisplayMain::SetupCluster(Int_t slice, Int_t patch, UInt_t nofClusters, AliHLTTPCSpacePointData* data) {
900 if (data && slice>=0 && slice<36 && patch>=0 && patch<AliHLTTPCTransform::GetNPatches()) {
901 if (fClusters[slice][patch]!=NULL) {
902 delete(fClusters[slice][patch]);
903 fClusters[slice][patch]=NULL;
905 Int_t arraysize=nofClusters*sizeof(AliHLTTPCSpacePointData);
906 fClusters[slice][patch] = (AliHLTTPCSpacePointData*)new Byte_t[arraysize];
907 if (fClusters[slice][patch]) {
908 memcpy(fClusters[slice][patch], data, arraysize);
909 fNcl[slice][patch]=nofClusters;
911 fNcl[slice][patch]=nofClusters;
912 HLTError ( "Memory allocation failed!" );
914 } else HLTError ( "Invalid argument!" );
917 //____________________________________________________________________________________________________
918 void AliHLTTPCDisplayMain::SetupTracks() {
921 Int_t ntracks = fTracks->GetNTracks();
923 for(Int_t j=0; j<ntracks; j++) {
924 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
925 if(!gtrack) continue;
927 Int_t nHits = gtrack->GetNHits();
928 UInt_t *hitnum = gtrack->GetHitNumbers();
930 for(Int_t h=0; h<nHits; h++){
933 Int_t slice = (id>>25) & 0x7f;
934 Int_t patch = (id>>22) & 0x7;
935 UInt_t pos = id&0x3fffff;
937 AliHLTTPCSpacePointData *points = fClusters[slice][patch];
940 HLTError ( "No points at slice %d patch %d position %d!", slice, patch, pos );
944 if(pos>=fNcl[slice][patch]) {
945 HLTError ( "Pos is too large: pos %d ncl!", pos,fNcl[slice][patch] );
948 points[pos].fUsed = kTRUE;
949 points[pos].fTrackN = j;
954 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
955 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
956 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
957 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
958 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
959 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
960 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
961 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
962 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
963 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
964 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
965 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
968 //----------------------------------------------------------------------------------------------------
970 //____________________________________________________________________________________________________
972 //____________________________________________________________________________________________________
973 void AliHLTTPCDisplayMain::SetSliceArray() {
975 Int_t minSlice = fMinSlice;
976 Int_t maxSlice = fMaxSlice;
979 for (slice=0;slice< 36;slice++){
980 fSliceArray[slice] = kFALSE;
983 // Single Slice, or Range
984 if (minSlice > maxSlice) maxSlice += 17;
986 for (slice=minSlice;slice<=maxSlice;slice++){
987 realslice = slice % 18;
988 fSliceArray[realslice] = kTRUE;
989 fSliceArray[realslice+18] = kTRUE;
994 minSlice = fMinSlice + 9;
995 maxSlice = fMaxSlice + 9;
997 if (minSlice > maxSlice) maxSlice += 17;
999 for (slice=minSlice;slice<=maxSlice;slice++){
1000 realslice = slice % 18;
1001 fSliceArray[realslice] = kTRUE;
1002 fSliceArray[realslice+18] = kTRUE;
1008 //----------------------------------------------------------------------------------------------------
1010 //____________________________________________________________________________________________________
1011 Int_t AliHLTTPCDisplayMain::GetGlobalTrack(Int_t slice){
1012 // get global track out of the "selectTrack" parameters
1013 Int_t currenttrack= -1;
1014 Int_t trackcounter = 0;
1015 Int_t ntracks = fTracks->GetNTracks();
1017 if ( slice == fSelectTrackSlice) {
1018 for(Int_t j=0; j<ntracks; j++) {
1020 AliHLTTPCTrack *gtrack = fTracks->GetCheckedTrack(j);
1021 if(!gtrack) continue;
1023 // --- CHECK if track is should be drawn
1024 // select Single Track
1025 if(gtrack->GetSector() != fSelectTrackSlice) continue;
1027 if (trackcounter != fSelectTrack){
1033 //if((fPtThreshold > 0) && (gtrack->GetPt()< fPtThreshold)) continue;
1034 //if(gtrack->GetNHits() < fMinHits) continue;
1041 return currenttrack;
1044 //----------------------------------------------------------------------------------------------------
1046 //____________________________________________________________________________________________________
1047 void AliHLTTPCDisplayMain::ExecPadEvent(Int_t event, Int_t px, Int_t py, TObject *selected){
1048 TCanvas *c = (TCanvas *) gTQSender;
1050 if (event == 11 &&selected->InheritsFrom("TH2F")) {
1051 TH2F *hist = (TH2F*) selected;
1053 Int_t binx = hist->GetXaxis()->FindBin(c->AbsPixeltoX(px)) -1 ;
1054 // Int_t biny = hist->GetYaxis()->FindBin(c->AbsPixeltoY(py)) -1;
1056 fPadCallback(fPt2Gui, binx);