]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFRawMap.cxx
Fixes for coverity: SELF_ASSIGN
[u/mrichter/AliRoot.git] / TOF / AliTOFRawMap.cxx
CommitLineData
15ec34b9 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/* $Id$ */
17
18/////////////////////////////////////////////////////////////////////////
19// //
20// AliTOFRawMap class //
21// //
22// It enables fast check if the TDC channel was already engaged //
23// for a measurement. //
24// The index of a AliTOFrawData is saved in the each rawdatamap "cell" //
25// (there is an offset +1, because the index can be zero and //
26// zero means empty cell. //
27// //
28/////////////////////////////////////////////////////////////////////////
29
30#include "TClonesArray.h"
31
32#include "AliLog.h"
33
34#include "AliTOFGeometry.h"
35#include "AliTOFRawMap.h"
36
37ClassImp(AliTOFRawMap)
38
39AliTOFRawMap::AliTOFRawMap():
8a190ba2 40 TObject(),
15ec34b9 41 fNtrm(-1),
42 fNtrmChain(-1),
43 fNtdc(-1),
44 fNtdcChannel(-1),
45 fRawData(0x0),
46 fMaxIndex(-1),
47 fRawMap(0x0)
48{
49//
50// Default ctor
51//
52}
53
54////////////////////////////////////////////////////////////////////////
8a190ba2 55AliTOFRawMap::AliTOFRawMap(TClonesArray *dig)://, AliTOFGeometry *tofGeom:
56 TObject(),
57 fNtrm(AliTOFGeometry::NTRM()+2),
58 fNtrmChain(AliTOFGeometry::NChain()),
59 fNtdc(AliTOFGeometry::NTdc()),
60 fNtdcChannel(AliTOFGeometry::NCh()),
15ec34b9 61 fRawData(dig),
62 fMaxIndex(-1),
63 fRawMap(0x0)
64{
65//
66// ctor
67//
68
69// of course, these constants must not be hardwired
70// change later
71
15ec34b9 72 fMaxIndex = fNtrm*fNtrmChain*fNtdc*fNtdcChannel;
73 fRawMap = new Int_t[fMaxIndex];
74 Clear();
75}
76
77////////////////////////////////////////////////////////////////////////
a3b608e8 78AliTOFRawMap::AliTOFRawMap(const AliTOFRawMap & rawMap) :
79 TObject(rawMap),
8a190ba2 80 fNtrm(rawMap.fNtrm),
81 fNtrmChain(rawMap.fNtrmChain),
82 fNtdc(rawMap.fNtdc),
83 fNtdcChannel(rawMap.fNtdcChannel),
84 fRawData(rawMap.fRawData),
15ec34b9 85 fMaxIndex(-1),
86 fRawMap(0x0)
87{
88//
89// Dummy copy constructor
90//
91
8a190ba2 92 fMaxIndex = fNtrm*fNtrmChain*fNtdc*fNtdcChannel;
93 fRawMap = new Int_t[fMaxIndex];
a3b608e8 94 for (Int_t i=0; i<fMaxIndex; i++)
95 fRawMap[i]=rawMap.fRawMap[i];
96
8a190ba2 97}
98
99////////////////////////////////////////////////////////////////////////
a3b608e8 100AliTOFRawMap & AliTOFRawMap::operator=(const AliTOFRawMap & rawMap)
8a190ba2 101{
102//
ce4b5362 103// Assignment operator
8a190ba2 104//
a3b608e8 105
106 if (this == &rawMap)
107 return *this;
108
109 fNtrm=rawMap.fNtrm;
110 fNtrmChain=rawMap.fNtrmChain;
111 fNtdc=rawMap.fNtdc;
112 fNtdcChannel=rawMap.fNtdcChannel;
ce4b5362 113
114 fRawData=rawMap.fRawData; // coverity: to be solved
115
116 /*
117 fRawData = new TClonesArray("AliTOFrawData");
118 for (Int_t ii=0; ii<rawMap.fRawMap->GetEntriesFast(); ii++)
119 fRawMap->AddLast(rawMap.fRawMap->UncheckedAt(ii));
120 */
121 //fRawData = TClonesArray(&rawMap.fRawMap);
122
a3b608e8 123 fMaxIndex=fNtrm*fNtrmChain*fNtdc*fNtdcChannel;
124 fRawMap = new Int_t[fMaxIndex];
125 for (Int_t i=0; i<fMaxIndex; i++)
126 fRawMap[i]=rawMap.fRawMap[i];
8a190ba2 127 return *this;
a3b608e8 128
15ec34b9 129}
130
131
132////////////////////////////////////////////////////////////////////////
133AliTOFRawMap::~AliTOFRawMap()
134{
135//
136// Destructor
137//
8a190ba2 138 if (fRawMap)
139 delete[] fRawMap;
15ec34b9 140
141}
142
143////////////////////////////////////////////////////////////////////////
144void AliTOFRawMap::Clear(const char *)
145{
146//
147// Clear hitmap
148//
149 memset(fRawMap,0,sizeof(int)*fMaxIndex);
150}
151
152////////////////////////////////////////////////////////////////////////
0e74c396 153Int_t AliTOFRawMap::CheckedIndex(const Int_t * const slot) const
15ec34b9 154{
155//
156// Return checked indices for vol
157//
158 Int_t index =
159 slot[0]*fNtrmChain*fNtdc*fNtdcChannel + // TRM
160 slot[1]*fNtdc*fNtdcChannel + // TRM chain
161 slot[2]*fNtdcChannel + // TDC
162 slot[3]; // TDC channel
163
164 if (index >= fMaxIndex) {
165 AliError("CheckedIndex - input outside bounds");
166 return -1;
167 } else {
168 return index;
169 }
170}
171
172////////////////////////////////////////////////////////////////////////
173void AliTOFRawMap::SetHit(Int_t *slot, Int_t idigit)
174{
175//
176// Assign digit to pad vol
177//
178
179// 0 means empty pad, we need to shift indeces by 1
180 fRawMap[CheckedIndex(slot)]=idigit+1;
181}
182
183////////////////////////////////////////////////////////////////////////
184void AliTOFRawMap::SetHit(Int_t *slot)
185{
186//
187// Assign last digit to channel slot
188//
189
190// 0 means empty pad, we need to shift indeces by 1
191 fRawMap[CheckedIndex(slot)]=fRawData->GetLast()+1;
192}
193
194////////////////////////////////////////////////////////////////////////
195Int_t AliTOFRawMap::GetHitIndex(Int_t *slot) const
196{
197//
198// Get contents of channel slot
199//
200
201// 0 means empty pad, we need to shift indeces by 1
202 return fRawMap[CheckedIndex(slot)]-1;
203}
204
205////////////////////////////////////////////////////////////////////////
206TObject* AliTOFRawMap::GetHit(Int_t *slot) const
207{
208//
209// Get pointer to object at alot
210// return 0 if vol out of bounds
211 Int_t index = GetHitIndex(slot);
212 return (index <0) ? 0 : fRawData->UncheckedAt(index);
213}
214
215////////////////////////////////////////////////////////////////////////
216FlagType AliTOFRawMap::TestHit(Int_t *slot) const
217{
218//
219// Check if hit cell is empty, used or unused
220//
221 Int_t inf = fRawMap[CheckedIndex(slot)];
222 if (inf > 0) {
223 return kUsed;
224 } else if (inf == 0) {
225 return kEmpty;
226 } else {
227 return kUnused;
228 }
229}
230