]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TRD/AliHLTTRDClusterizer.cxx
- coverity fixes
[u/mrichter/AliRoot.git] / HLT / TRD / AliHLTTRDClusterizer.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 cluster finder                                                    //
19 //                                                                           //
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "AliHLTTRDClusterizer.h"
23 #include "AliHLTTRDCluster.h"
24 #include "AliTRDgeometry.h"
25 #include "AliTRDcluster.h"
26 #include "AliTRDReconstructor.h"
27 #include <TClonesArray.h>
28
29 ClassImp(AliHLTTRDClusterizer)
30
31 //_____________________________________________________________________________
32 AliHLTTRDClusterizer::AliHLTTRDClusterizer(const AliTRDReconstructor *const rec)
33   :AliTRDclusterizer(rec)
34   ,fClMemBlock(NULL)
35   ,fTrMemBlock(NULL)
36   ,fTrMemCurrPtr(NULL)
37   ,fLastDet(-1)
38   ,fClusters(NULL)
39   ,fAddedSize(0)
40 {
41   //
42   // AliHLTTRDClusterizer default constructor
43   //
44 }
45
46 //_____________________________________________________________________________
47 AliHLTTRDClusterizer::AliHLTTRDClusterizer(const Text_t *const name, const Text_t *const title, const AliTRDReconstructor *const rec)
48   : AliTRDclusterizer(name,title,rec)
49   ,fClMemBlock(NULL)
50   ,fTrMemBlock(NULL)
51   ,fTrMemCurrPtr(NULL)
52   ,fLastDet(-1)
53   ,fClusters(NULL)
54   ,fAddedSize(0)
55 {
56   //
57   // AliHLTTRDClusterizer constructor
58   //
59 }
60
61 //_____________________________________________________________________________
62 AliHLTTRDClusterizer::AliHLTTRDClusterizer(const AliHLTTRDClusterizer& c)
63   : AliTRDclusterizer(c)
64   ,fClMemBlock(NULL)
65   ,fTrMemBlock(NULL)
66   ,fTrMemCurrPtr(NULL)
67   ,fLastDet(-1)
68   ,fClusters(NULL)
69   ,fAddedSize(0)
70 {
71   //
72   // AliHLTTRDClusterizer copy constructor
73   //
74 }
75
76 //_____________________________________________________________________________
77 AliHLTTRDClusterizer& AliHLTTRDClusterizer::operator=(const AliHLTTRDClusterizer& c)
78 {
79   //
80   // Assignment operator
81   //
82   
83   if(this!=&c) 
84     c.Copy(*this);
85   return *this;
86 }
87
88 //_____________________________________________________________________________
89 void AliHLTTRDClusterizer::Copy(TObject& c) const
90 {
91   //
92   // Copy function
93   //
94
95   ((AliHLTTRDClusterizer&)c).fClMemBlock = NULL;
96   ((AliHLTTRDClusterizer&)c).fTrMemBlock = NULL;
97   ((AliHLTTRDClusterizer&)c).fTrMemCurrPtr = NULL;
98 }
99
100 //_____________________________________________________________________________
101 void AliHLTTRDClusterizer::AddClusterToArray(AliTRDcluster* cluster)
102 {
103   //
104   // Add a cluster to the array
105   //
106
107   if(fLastDet!=cluster->GetDetector()){
108     fLastDet = cluster->GetDetector();
109     fClusters = new(GetClMemBlock()+fAddedSize) AliHLTTRDClustersArray(fLastDet);
110     fAddedSize += sizeof(AliHLTTRDClustersArray);
111   }
112   new(&fClusters->fCluster[fClusters->fCount]) AliHLTTRDClustersArray::cluster_type(cluster);
113   fClusters->fCount++;
114   fAddedSize += sizeof(AliHLTTRDClustersArray::cluster_type);
115 }
116
117 //_____________________________________________________________________________
118 void AliHLTTRDClusterizer::AddTrackletsToArray()
119 {
120   //
121   // Add the online tracklets of this chamber to the array
122   //
123
124   // memcpy(&(((UInt_t*)GetTrMemBlock())[fNoOfTracklets]),fTrackletContainer[0],256*sizeof(UInt_t));
125   // memcpy(&(((UInt_t*)GetTrMemBlock())[fNoOfTracklets+256]),fTrackletContainer[1],256*sizeof(UInt_t));
126
127   // fNoOfTracklets += 512;
128
129   UInt_t* trackletword;
130   AliHLTTRDTrackletWordArray* trklArr = new(fTrMemCurrPtr) AliHLTTRDTrackletWordArray(fDet);
131   fTrMemCurrPtr += sizeof(AliHLTTRDTrackletWordArray);
132   for(Int_t side=0; side<2; side++)
133     {
134       Int_t trkl=0;
135       trackletword=fTrackletContainer[side];
136       while(trackletword[trkl]>0){
137         trkl++;
138       }
139       memcpy(fTrMemCurrPtr,fTrackletContainer[side],trkl*sizeof(UInt_t));
140       fTrMemCurrPtr += trkl*sizeof(UInt_t);
141       trklArr->fCount += trkl;
142     }
143
144   // fTrackletContainer[0]+=256;
145   // fTrackletContainer[1]+=256;
146   // fNoOfTracklets += 512;
147
148 }