]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TRD/AliHLTTRDUtils.cxx
addtional DSC alias from Tomek
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDUtils.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 ///////////////////////////////////////////////////////////////////////////////
17 //                                                                           //
18 // HLT TRD Utillities Class                                                  //
19 //                                                                           //
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "AliHLTTRDUtils.h"
23 #include <TClonesArray.h>
24 #include "AliHLTTRDTrack.h"
25 #include "AliHLTTRDCluster.h"
26
27 AliHLTUInt32_t AliHLTTRDUtils::AddClustersToOutput(TClonesArray* inClusterArray, AliHLTUInt8_t* outBlockPtr)
28 {
29   AliTRDcluster* cluster = 0;
30   AliHLTUInt32_t addedSize = 0;
31   //  == OUTdatatype pointer
32   AliHLTTRDCluster * outPtr = (AliHLTTRDCluster*)outBlockPtr;
33   
34   if (inClusterArray){
35     Int_t nbEntries  = inClusterArray->GetEntries();
36     for (Int_t iCluster = 0; iCluster<nbEntries; iCluster++){
37       //cout << "Geting cluster #" << iCluster << endl;
38       UInt_t blockSize=0;
39       
40       cluster = dynamic_cast<AliTRDcluster*>(inClusterArray->At(iCluster));
41
42       AliHLTTRDCluster *hltCluster = new (outPtr) AliHLTTRDCluster(cluster);
43       //cout << Form("cluster added at 0x%x (%i)\n",outPtr,outPtr);
44
45       blockSize = sizeof(*hltCluster);
46
47       addedSize += blockSize;
48       outBlockPtr += blockSize;
49       outPtr = (AliHLTTRDCluster*)outBlockPtr;
50     }
51   }
52   return addedSize;
53   
54 }
55
56 AliHLTUInt32_t AliHLTTRDUtils::AddTracksToOutput(TClonesArray* inTrackArray, AliHLTUInt8_t* output)
57 {
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;
63   
64   if (inTrackArray){
65     Int_t nbTracks  = inTrackArray->GetEntries();
66     for (Int_t iTrack = 0; iTrack<nbTracks; iTrack++){
67       AliHLTUInt32_t trackSize=0;
68       
69       track = dynamic_cast<AliTRDtrackV1*>(inTrackArray->At(iTrack));
70       //track->Print();
71       
72       AliHLTTRDTrack *hltTrack = new (outPtr) AliHLTTRDTrack(track);
73       trackSize = hltTrack->GetSize();
74       addedSize += trackSize;
75       //HLTDebug("addedSize %i, trackSize %i", addedSize, trackSize);
76       
77       iterPtr += trackSize;
78       outPtr = (AliHLTTRDTrack*)iterPtr;
79     }
80   }
81   return addedSize;
82   
83 }
84
85 /**
86  * Read cluster to the TClonesArray from the memory 
87  */
88 //============================================================================
89 AliHLTUInt32_t AliHLTTRDUtils::ReadClusters(TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size)
90 {
91   //HLTDebug("\nReading clusters from the Memory\n ============= \n");
92   AliHLTTRDCluster * curCluster;
93   UInt_t clusterSize = sizeof(AliHLTTRDCluster), curSize = 0;
94   Int_t i=0;
95   
96   curCluster = (AliHLTTRDCluster*) inputPtr;
97   while (curSize + clusterSize <= size)
98     {
99       //HLTDebug(" fX = %f; fY = %f; fZ = %f", curCluster->fX, curCluster->fY, curCluster->fZ);
100
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; 
105       i++;
106       curCluster++;
107       //cout << " current readed size is " << curSize << "/" << size << endl;
108     }
109   
110   return i;
111 }
112
113 AliHLTUInt32_t AliHLTTRDUtils::ReadTracks(TClonesArray *outArray, void* inputPtr, AliHLTUInt32_t size)
114 {
115   AliHLTUInt8_t* iterPtr = (AliHLTUInt8_t* )inputPtr;
116   
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;
121   Int_t counter=0;
122   
123   while (curSize < size)
124     {
125       hltTrack = (AliHLTTRDTrack*) iterPtr;
126       //HLTDebug("curSize %i, size %i",curSize, size);
127       
128       trackSize = hltTrack->GetSize();
129       //HLTDebug("GetSize() %i", trackSize);
130
131       hltTrack->ReadTrackletsFromMemory(iterPtr + sizeof(AliHLTTRDTrack));
132
133       AliTRDtrackV1* curTRDTrack = new((*outArray)[counter]) AliTRDtrackV1();
134       hltTrack->ExportTRDTrack(curTRDTrack);
135       
136       curSize += trackSize; 
137       iterPtr += trackSize;
138       counter++;
139     }
140
141   //CheckTrackArray(outArray);
142   
143   return counter;
144 }
145