2 * Requirements: Running HLT Analysis Framework
3 * with TCP-Dump Subscribe listining on
4 * - Cluster: Hostname, Port
5 * - Tracker: Hostname, Port
6 * - Controlled FilePublisher: Hostname, Port
9 * (1) USE the StartDisplayMacro.C , by adding
10 * gROOT->Macro("StartDisplayMacro.C");
11 * to the rootlogon.C file
13 * (2) IN StartDisplayMacro.C subject to change are:
14 * ODH_INIT("<PATH TO GEO FILE>", "<PATH TO LIBRARIES>");
15 * - <PATH TO LIBRARIES> : The path where libHOMERReader_ROOT.so and libHOMERReader.so are located.
16 * - <PATH TO GEO FILE> : The path where alice.geom is located.
17 * ODH_CONNECT("<NODE>",<PORT>,"<NODE>",<PORT>,"<NODE>",<PORT>);
18 * - <NODE> : The port on which the TCPDumpSubscriber is running.
19 * - <PORT> : The port specified in the TCPDumpSubscriber in the XML configuration file.
20 * use first pair for Cluster Data, second for Tracks Data and third for Raw Data...
21 * but it doesn't matter if you change it.
24 * When starting root, Display and Control Bar will pop up.
25 * Nothing will be displayed at the beginning.
26 * - In order to display the geometry. Click <Show Geometry> first.
27 * Different sets of sectors can be selected also.
28 * - In order to dislpay event's click <Next clusters>, <Next tracks> or <Next clusters and tracks>
29 * Displaying PadRow's:
31 * once : <Setup PadRow 20 with Histogram>
32 * next event : <Display PadRow>
34 * once : <Setup PadRow 20 with Geometry>
35 * next event : <Display PadRow>, <Display PadRow with Clusters>, <Display PadRow with Tracks> or <Display PadRow with Clusters and Tracks>
39 // gROOT->GetInterpreter()->AddIncludePath( "$ALIHLT_TOPDIR/BASE" );
40 // gROOT->GetInterpreter()->AddIncludePath( "$ALIHLT_TOPDIR/TPCLib" );
42 #include "AliHLTDataTypes.h"
43 #include "AliHLTTPCSpacePointData.h"
44 #include "AliHLTTPCClusterDataFormat.h"
45 #include "AliHLTTPCTrackletDataFormat.h"
46 #include "AliHLTTPCDefinitions.h"
47 #include "AliHLTTPCDigitReader.h"
49 // include because of connecttofile()
52 //#include <sys/time.h>
53 //#include <sys/types.h>
60 // #include "MLUCString.hpp"
61 // #include "MLUCCmdlineParser.hpp"
62 // #include "MLUCDynamicLibrary.hpp"
63 #include "AliHLTDataTypes.h"
64 #include "AliHLT_C_Component_WrapperInterface.h"
68 //#include "AliHLTTPCTrackArray.h"
70 void* gODH_Reader; /* really HOMERReader* */
71 void* gODH_Display; /* really AliHLTTPCDisplay* */
74 /* Dummy function to work around the problem that the interpreter does not load the first function properly... */
79 // ########################################################################################################################################
80 int HLT_OnlineDisplay_HOMER() {
85 // ########################################################################################################################################
86 int ODH_Init( char* path_to_geom_file, char* path_to_homer_lib = NULL ) {
89 cout << "Loading ROOT libraries (ROOTSYS has to be set)" << endl;
91 gSystem->Load("libPhysics");
92 gSystem->Load("libEG");
93 // if(gSystem->Load("libMC")==-1) {
94 gSystem->Load("libGeom");
95 gSystem->Load("libVMC");
98 cout << "Loading ALICE TPC libraries (ALICE_ROOT & ALICE_TARGET have to be set)" << endl;
99 gSystem->Load("libESD");
100 gSystem->Load("libSTEER");
101 gSystem->Load("libRAWDatabase");
102 gSystem->Load("libRAWDatarec");
103 // gSystem->Load("libCONTAINERS");
104 // if(gSystem->Load("libTPC")!=0) {
105 gSystem->Load("libTPCbase");
106 gSystem->Load("libTPCrec");
107 gSystem->Load("libTPCsim");
108 gSystem->Load("libTPCfast");
111 cout << "Loading HLT libraries (ALIHLT_LIBDIR has to be set)" << endl;
112 gSystem->Load("$(ALIHLT_LIBDIR)/libHLTbase.so");
113 gSystem->Load("$(ALIHLT_LIBDIR)/libAliHLTTPC.so");
114 cout << "Loading HOMER library" << endl;
116 if ( path_to_homer_lib ) {
117 lib = path_to_homer_lib;
124 lib += "libHOMERReader_ROOT.so";
125 gSystem->Load( lib );
128 // --- Create DISPLAY
129 cout << "Creating display" << endl;
131 Char_t *gfile="alice.geom"; // geometrie file
133 if ( path_to_geom_file ){
134 geoPath = path_to_geom_file;
142 Int_t slices[] = { 0, 35 };
143 AliHLTTPCDisplay* display = new AliHLTTPCDisplay( slices, geoPath.Data() );
145 display->SetSlices();
146 display->DisplayAll(0,kFALSE,kFALSE,kFALSE,kFALSE);
148 gODH_Display = (void*)display;
152 int ODH_SetSliceRange(int minslice,int maxslice){
153 // sets a range of Slices
154 if (!gODH_Display ) return -1;
155 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
157 display->SetSlices(minslice,maxslice);
158 display->DisplayAll(0,kFALSE,kFALSE,kFALSE,kFALSE);
161 int ODH_SetSliceRange(int slice){
163 if (!gODH_Display ) return -1;
164 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
166 display->SetSlices(slice);
167 display->DisplayAll(0,kFALSE,kFALSE,kFALSE,kFALSE);
170 int ODH_SetSliceRange(){
172 if (!gODH_Display ) return -1;
173 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
175 display->SetSlices();
176 display->DisplayAll(0,kFALSE,kFALSE,kFALSE,kFALSE);
179 int ODH_SetSlicePair(int slice){
180 // sets a pair of slices
181 if (!gODH_Display ) return -1;
182 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
184 display->SetSlicesPair(slice);
185 display->DisplayAll(0,kFALSE,kFALSE,kFALSE,kFALSE);
188 int ODH_SetSlicePair(int minslice, int maxslice){
189 // sets a pair of slices
190 if (!gODH_Display ) return -1;
191 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
193 display->SetSlicesPair(minslice,maxslice);
194 display->DisplayAll(0,kFALSE,kFALSE,kFALSE,kFALSE);
198 // sets a pair of slices
199 if (!gODH_Display ) return -1;
200 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
202 display->SetInvert();
203 display->DisplayAll(0,kFALSE,kFALSE,kFALSE,kFALSE);
206 int ODH_SetDrawGeo(){
207 // sets a pair of slices
208 if (!gODH_Display ) return -1;
209 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
211 display->SetDrawGeo();
212 display->DisplayAll(0,kFALSE,kFALSE,kFALSE,kFALSE);
215 // ########################################################################################################################################
216 int ODH_Connect( char* hostname_clusters, short port_clusters, char* hostname_tracks, short port_tracks, char* hostname_raw, short port_raw ) {
218 char* hostnames[] = { "NULL", "NULL","NULL" };
219 unsigned short ports[] = { 0, 0, 0 };
221 if ( hostname_clusters ){
222 hostnames[cnt] = hostname_clusters;
223 ports[cnt] = port_clusters;
226 if ( hostname_tracks ){
227 hostnames[cnt] = hostname_tracks;
228 ports[cnt] = port_tracks;
232 hostnames[cnt] = hostname_raw;
233 ports[cnt] = port_raw;
237 reader = new HOMERReader( cnt, hostnames, ports );
239 ret=reader->GetConnectionStatus();
241 int ndx = reader->GetErrorConnectionNdx();
243 printf( "Error establishing connection to TCP source %s:%hu: %s (%d)\n",
244 hostnames[ndx], ports[ndx],
245 strerror(ret), ret );
248 printf( "Error establishing connection to unknown source with index %d: %s (%d)\n",
250 strerror(ret), ret );
255 gODH_Reader = (void*)reader;
259 // ########################################################################################################################################
260 int ODH_Disconnect() {
263 HOMERReader* reader = (HOMERReader*)gODH_Reader;
269 // ########################################################################################################################################
270 Int_t ODH_SetupPadRow(Int_t histswitch, Int_t slice, Int_t padrow){
272 if (!gODH_Display ) return -1;
273 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
275 // Setup Geometry: histswitch = 0;
276 // Setup Histogram: histswitch = 1|2|3;
277 display->SetupPadRow(histswitch,slice,padrow);
282 // ########################################################################################################################################
283 int ODH_DisplayNextEvent( Bool_t clusterswitch, Bool_t trackswitch, Bool_t padrowswitch, Float_t* clustersEtaRange = NULL ) {
285 if ( !gODH_Reader || !gODH_Display ) return -1;
287 // -- input datatypes , reverse
288 char* spptID="SRETSULC";
289 //char* spptID="STPECAPS";
290 char* trkID = "SGESKART";
291 //char* trkID = "SGESCART";
292 char* padrowID = "KPWR_LDD";
295 Bool_t x3don = kFALSE;
297 HOMERReader* reader = (HOMERReader*)gODH_Reader;
298 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
299 int ret = reader->ReadNextEvent();
302 int ndx = reader->GetErrorConnectionNdx();
303 printf( "------------ TRY AGAIN --------------->Error reading event from source %d: %s (%d)\n", ndx, strerror(ret), ret );
304 ODH_DisplayNextEvent( clusterswitch, trackswitch, padrowswitch, clustersEtaRange);
308 unsigned long blockCnt = reader->GetBlockCnt();
309 printf( "Event 0x%016LX (%Lu) with %lu blocks\n", (ULong64_t)reader->GetEventID(), (ULong64_t)reader->GetEventID(), blockCnt );
311 for ( unsigned long i = 0; i < blockCnt; i++ ) {
312 char tmp1[9], tmp2[5];
313 memset( tmp1, 0, 9 );
314 memset( tmp2, 0, 5 );
316 ULong64_t* tmp12 = (ULong64_t*)tmp11;
317 *tmp12 = reader->GetBlockDataType( i );
319 ULong_t* tmp22 = (ULong_t*)tmp21;
320 *tmp22 = reader->GetBlockDataOrigin( i );
321 printf( "Block %lu length: %lu - type: %s - origin: %s\n",
322 i, reader->GetBlockDataLength( i ), tmp1, tmp2 );
325 display->ResetDisplay();
327 // -------------- CLUSTER
328 if ( clusterswitch ) {
329 unsigned long blk = reader->FindBlockNdx( spptID, " CPT",0xFFFFFFFF );
330 printf( "blk: %lu\n", blk );
331 while ( blk != ~(unsigned long)0 ) {
332 printf( "Found clusters block %lu\n", blk );
333 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)reader->GetBlockData( blk );
334 unsigned long dataLen = reader->GetBlockDataLength( blk );
336 ULong_t spec = reader->GetBlockDataSpec( blk );
337 Int_t patch = AliHLTTPCDefinitions::GetMinPatchNr( spec );
338 Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr( spec );
339 printf( "%lu Clusters found for slice %u - patch %u\n", clusterData->fSpacePointCnt, slice, patch );
341 void* tmp30 = clusterData;
342 Byte_t* tmp31 = (Byte_t*)tmp30;
343 unsigned long offset;
344 offset = sizeof(clusterData->fSpacePointCnt);
345 if ( offset <= reader->GetBlockTypeAlignment( blk, 1 ) )
346 offset = reader->GetBlockTypeAlignment( blk, 1 );
349 AliHLTTPCSpacePointData* tmp32 = (AliHLTTPCSpacePointData*)tmp30;
351 display->SetupClusterDataForPatch( slice, patch, clusterData->fSpacePointCnt, tmp32 );
353 blk = reader->FindBlockNdx( spptID, " CPT", 0xFFFFFFFF, blk+1 );
354 printf( "blk: %lu\n", blk );
358 // -------------- PADROW
359 if ( padrowswitch ) {
360 Int_t padrow = display->GetPadrow();
361 Int_t patch = AliHLTTPCTransform::GetPatch(padrow);
362 Int_t maxpatch = patch;
363 AliHLTUInt8_t padslice = (AliHLTUInt8_t) display->GetSlice();
365 if (padrow == 30 || padrow == 90 || padrow == 139) maxpatch++;
367 for (Int_t tpatch=patch;tpatch <= maxpatch;tpatch++){
370 AliHLTUInt32_t padrowSpec = AliHLTTPCDefinitions::EncodeDataSpecification( padslice, padslice,(AliHLTUInt8_t) tpatch,(AliHLTUInt8_t) tpatch );
374 // READ RAW DATA BLOCK
375 blk = reader->FindBlockNdx( padrowID, " CPT", padrowSpec );
376 printf( "Raw Data found for slice %u/patch %u\n", padslice, tpatch );
378 unsigned long rawDataBlock = reader->GetBlockData( blk );
379 unsigned long rawDataLen = reader->GetBlockDataLength( blk );
381 // READ CLUSTERS BLOCK
382 blk = reader->FindBlockNdx( spptID, " CPT", padrowSpec );
384 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)reader->GetBlockData( blk );
386 printf( "%lu Clusters found for slice %u - patch %u\n", clusterData->fSpacePointCnt, padslice, tpatch );
388 void* tmp30 = clusterData;
389 Byte_t* tmp31 = (Byte_t*)tmp30;
390 unsigned long offset;
391 offset = sizeof(clusterData->fSpacePointCnt);
392 if ( offset <= reader->GetBlockTypeAlignment( blk, 1 ) )
393 offset = reader->GetBlockTypeAlignment( blk, 1 );
396 AliHLTTPCSpacePointData* tmp32 = (AliHLTTPCSpacePointData*)tmp30;
398 // DISPLAY RAW DATA AND CLUSTERS
399 display->FillPadRow( tpatch, rawDataBlock, rawDataLen, clusterData->fSpacePointCnt, tmp32);
405 AliHLTTPCTrackArray* trackArray = NULL;
406 trackArray = new AliHLTTPCTrackArray;
408 printf( "No track array\n" );
412 // -------------- TRACKS
414 unsigned long blk = reader->FindBlockNdx( trkID, " CPT", 0xFFFFFFFF );
416 while ( blk != ~(unsigned long)0 ) {
417 printf( "Found tracks in block %lu\n", blk );
418 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*)reader->GetBlockData( blk );
420 printf( "No track data for block %lu\n", blk );
424 ULong_t spec = reader->GetBlockDataSpec( blk );
425 Int_t patchmin = AliHLTTPCDefinitions::GetMinPatchNr( spec );
426 Int_t patchmax = AliHLTTPCDefinitions::GetMaxPatchNr( spec );
427 Int_t slice = AliHLTTPCDefinitions::GetMinSliceNr( spec );
429 printf( "%lu tracks found for slice %u - patch %u-%u\n", trackData->fTrackletCnt, slice, patchmin, patchmax );
431 void* tmp40 = trackData;
432 Byte_t* tmp41 = (Byte_t*)tmp40;
433 unsigned long offset;
435 offset = sizeof(trackData->fTrackletCnt);
437 if ( offset <= reader->GetBlockTypeAlignment( blk, 1 ) ) offset = reader->GetBlockTypeAlignment( blk, 1 );
441 AliHLTTPCTrackSegmentData* tmp42 = (AliHLTTPCTrackSegmentData*)tmp40;
443 trackArray->FillTracks( trackData->fTrackletCnt, tmp42, slice );
445 blk = reader->FindBlockNdx( trkID, " CPT", 0xFFFFFFFF, blk+1 );
451 display->SetTracks( trackArray );
454 display->DisplayAll( minHits, clusterswitch, trackswitch, x3don, 0. /*, clustersEtaRange */ );
455 if ( padrowswitch) display->DrawPadRow(x3don);
457 if ( trackArray ) delete trackArray;
462 // ########################################################################################################################################
463 // ########################################################################################################################################
464 // ########################################################################################################################################
465 int ODH_SimpleDisplay(char * infiles[7],unsigned int slice){
466 if ( !gODH_Display ) return -1;
469 AliHLTTPCDisplay* display = (AliHLTTPCDisplay*)gODH_Display;
475 AliHLTComponent_DataType dataType;
476 AliHLTUInt32_t dataSpec = ~(AliHLTUInt32_t)0;
477 dataType.fStructSize = sizeof(dataType);
478 memset( dataType.fID, '*', 8 );
479 memset( dataType.fOrigin, '*', 4 );
480 AliHLTComponent_BlockData blocks[7];
481 unsigned long totalRead = 0;
484 for (int ii = 0;ii<7;ii++){
486 inFH = fopen( infiles[ii], "r");
488 error = "Unable to open input file for reading";
494 AliHLTComponent_BlockData newBlock;
495 newBlock.fStructSize = sizeof(AliHLTComponent_BlockData);
497 newBlock.fShmKey.fStructSize = sizeof(AliHLTComponent_ShmData);
498 newBlock.fShmKey.fShmType = gkAliHLTComponent_InvalidShmType;
499 newBlock.fShmKey.fShmID = gkAliHLTComponent_InvalidShmID;
501 fseek( inFH, 0, SEEK_END );
502 long sz = ftell(inFH);
504 fseek( inFH, 0, SEEK_SET);
505 newBlock.fPtr = new uint8[ sz ];
507 if ( !newBlock.fPtr ) {
508 fprintf( stderr, "Out of memory trying to allocate memory for input file '%s' of %lu bytes.\n",
513 unsigned long curSize = 0;
515 void * tmp50 = newBlock.fPtr;
516 uint8* tmp51 = (uint8*)tmp50;
518 ret = fread(tmp51+curSize,1, sz-curSize,inFH);
521 curSize += (unsigned long)ret;
522 if ( curSize >= (unsigned long)sz ) {
524 blocks[ii] = newBlock;
529 fprintf( stderr, "%s error reading data from input file after %lu bytes.\n", infile, curSize );
535 // --- Setup CLUSTERS
536 for (int ii = 1;ii<7;ii++){
537 unsigned int patch = ii - 1;
538 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) blocks[ii].fPtr;
540 if ( !clusterData ) {
541 printf( "No ClusterData\n" );
545 void* tmp30 = clusterData;
546 Byte_t* tmp31 = (Byte_t*)tmp30;
547 unsigned long offset;
549 offset = sizeof(clusterData->fSpacePointCnt);
553 AliHLTTPCSpacePointData* tmp32 = (AliHLTTPCSpacePointData*)tmp30;
555 display->SetupClusterDataForPatch( slice, patch, clusterData->fSpacePointCnt, tmp32 );
559 AliHLTTPCTrackArray* trackArray = NULL;
560 trackArray = new AliHLTTPCTrackArray;
563 printf( "No track array\n" );
567 const AliHLTTPCTrackletData* trackData = (const AliHLTTPCTrackletData*) blocks[0].fPtr;
570 printf( "No track data for block %lu\n", blk );
574 void* tmp40 = trackData;
575 Byte_t* tmp41 = (Byte_t*)tmp40;
576 unsigned long offset;
578 offset = sizeof(trackData->fTrackletCnt);
582 AliHLTTPCTrackSegmentData* tmp42 = (AliHLTTPCTrackSegmentData*)tmp40;
584 trackArray->FillTracks( trackData->fTrackletCnt, tmp42, slice );
586 display->SetTracks( trackArray );
591 display->SetSlices(0,4);
592 display->DisplayAll( minHits, clusterswitch, trackswitch, kFALSE, 0. /*, clustersEtaRange */ );
593 if ( trackArray ) delete trackArray;
597 } // END ODH_SimpleDisplay