1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 ///////////////////////////////////////////////////////////////////////////////
18 // HLT TRD Utillities Class //
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "AliHLTTRDUtils.h"
23 #include <TClonesArray.h>
24 #include "AliHLTTRDTrack.h"
25 #include "AliHLTTRDCluster.h"
27 AliHLTUInt32_t AliHLTTRDUtils::AddClustersToOutput(TClonesArray* inClusterArray, AliHLTUInt8_t* outBlockPtr)
29 AliTRDcluster* cluster = 0;
30 AliHLTUInt32_t addedSize = 0;
31 // == OUTdatatype pointer
32 AliHLTTRDCluster * outPtr = (AliHLTTRDCluster*)outBlockPtr;
35 Int_t nbEntries = inClusterArray->GetEntries();
36 for (Int_t iCluster = 0; iCluster<nbEntries; iCluster++){
37 //cout << "Geting cluster #" << iCluster << endl;
40 cluster = dynamic_cast<AliTRDcluster*>(inClusterArray->At(iCluster));
42 AliHLTTRDCluster *hltCluster = new (outPtr) AliHLTTRDCluster(cluster);
43 //cout << Form("cluster added at 0x%x (%i)\n",outPtr,outPtr);
45 blockSize = sizeof(*hltCluster);
47 addedSize += blockSize;
48 outBlockPtr += blockSize;
49 outPtr = (AliHLTTRDCluster*)outBlockPtr;
56 AliHLTUInt32_t AliHLTTRDUtils::AddTracksToOutput(TClonesArray* inTrackArray, AliHLTUInt8_t* output)
58 cout << "\nWriting tracks to the Memory\n ============= \n";
59 AliTRDtrackV1* track = 0;
60 AliHLTUInt32_t addedSize = 0;
61 AliHLTUInt8_t *iterPtr = output;
62 AliHLTTRDTrack * outPtr = (AliHLTTRDTrack*)iterPtr;
65 Int_t nbTracks = inTrackArray->GetEntries();
66 for (Int_t iTrack = 0; iTrack<nbTracks; iTrack++){
67 AliHLTUInt32_t trackSize=0;
69 track = dynamic_cast<AliTRDtrackV1*>(inTrackArray->At(iTrack));
72 AliHLTTRDTrack *hltTrack = new (outPtr) AliHLTTRDTrack(track);
73 trackSize = hltTrack->GetSize();
74 addedSize += trackSize;
75 //HLTDebug("addedSize %i, trackSize %i", addedSize, trackSize);
78 outPtr = (AliHLTTRDTrack*)iterPtr;
86 * Read cluster to the TClonesArray from the memory
88 //============================================================================
89 AliHLTUInt32_t AliHLTTRDUtils::ReadClusters(TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size)
91 //HLTDebug("\nReading clusters from the Memory\n ============= \n");
92 AliHLTTRDCluster * curCluster;
93 UInt_t clusterSize = sizeof(AliHLTTRDCluster), curSize = 0;
96 curCluster = (AliHLTTRDCluster*) inputPtr;
97 while (curSize + clusterSize <= size)
99 //HLTDebug(" fX = %f; fY = %f; fZ = %f", curCluster->fX, curCluster->fY, curCluster->fZ);
101 AliTRDcluster* curTRDCluster = new((*outArray)[i]) AliTRDcluster();
102 curCluster->ExportTRDCluster(curTRDCluster);
103 //HLTDebug(" fX = %f; fY = %f; fZ = %f", curTRDCluster->GetX(), curTRDCluster->GetY(), curTRDCluster->GetZ());
104 curSize += clusterSize;
107 //cout << " current readed size is " << curSize << "/" << size << endl;
113 AliHLTUInt32_t AliHLTTRDUtils::ReadTracks(TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size)
115 AliHLTUInt8_t* iterPtr = (AliHLTUInt8_t* )inputPtr;
117 //cout << "\nReading tracks from the Memory\n ============= \n";
118 //HLTDebug ("\nReading tracks from the Memory\n ============= \n");
119 AliHLTTRDTrack * hltTrack;
120 AliHLTUInt32_t trackSize = 0, curSize = 0;
123 while (curSize < size)
125 hltTrack = (AliHLTTRDTrack*) iterPtr;
126 //HLTDebug("curSize %i, size %i",curSize, size);
128 trackSize = hltTrack->GetSize();
129 //HLTDebug("GetSize() %i", trackSize);
131 hltTrack->ReadTrackletsFromMemory(iterPtr + sizeof(AliHLTTRDTrack));
133 AliTRDtrackV1* curTRDTrack = new((*outArray)[counter]) AliTRDtrackV1();
134 hltTrack->ExportTRDTrack(curTRDTrack);
136 curSize += trackSize;
137 iterPtr += trackSize;
141 //CheckTrackArray(outArray);