]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDEdepMap.cxx
Fix coverity issues
[u/mrichter/AliRoot.git] / FMD / AliFMDEdepMap.cxx
CommitLineData
e802be3e 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 **************************************************************************/
e802be3e 15/* $Id$ */
c2fc1258 16/** @file AliFMDEdepMap.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Mon Mar 27 12:39:50 2006
19 @brief Per strip map of energy deposited and number of hits
02a27b50 20 @ingroup FMD_sim
c2fc1258 21*/
e802be3e 22//____________________________________________________________________
23//
02a27b50 24// Contains a pair of energy deposited fEdep and number of hits
25// fN, fEdep is the summed energy deposition, and fN is the
26// number of hits. The map contains one such object or each strip.
27// It is used to cache the data in the digitization classes
28// AliFMDBaseDigitizer and so on.
e802be3e 29//
30//
31#include "AliFMDEdepMap.h" // ALIFMDEDEPMAP_H
32
33//____________________________________________________________________
925e6570 34ClassImp(AliFMDEdepMap)
1a1fdef7 35#if 0
36 ; // This is here to keep Emacs for indenting the next line
37#endif
e802be3e 38
39//____________________________________________________________________
40AliFMDEdepMap::AliFMDEdepMap(const AliFMDEdepMap& other)
41 : AliFMDMap(other.fMaxDetectors, other.fMaxRings, other.fMaxSectors,
42 other.fMaxStrips),
021f1396 43 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
e802be3e 44 fData(0)
45{
088f8e79 46 // Copy constructor
021f1396 47 if (fTotal == 0) fTotal = 51200;
bfdc7f5d 48 fData = new AliFMDEdepHitPair[fTotal];
0ed9abeb 49 for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
e802be3e 50}
51
52
021f1396 53//____________________________________________________________________
54AliFMDEdepMap::AliFMDEdepMap()
55 : AliFMDMap(),
56 fTotal(0),
57 fData(0)
58{
59 // Construct a map
60 //
61 // Parameters:
62 // None
63}
e802be3e 64
65//____________________________________________________________________
6e79feeb 66AliFMDEdepMap::AliFMDEdepMap(UShort_t maxDet,
67 UShort_t maxRing,
68 UShort_t maxSec,
69 UShort_t maxStr)
e802be3e 70 : AliFMDMap(maxDet, maxRing, maxSec, maxStr),
021f1396 71 fTotal(fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips),
e802be3e 72 fData(0)
73{
74 // Construct a map
75 //
76 // Parameters:
77 // maxDet Maximum # of detectors
78 // maxRinf Maximum # of rings
79 // maxSec Maximum # of sectors
80 // maxStr Maximum # of strips
021f1396 81 if (fTotal == 0) fTotal = 51200;
bfdc7f5d 82 fData = new AliFMDEdepHitPair[fTotal];
e802be3e 83}
84
85//____________________________________________________________________
86AliFMDEdepMap&
87AliFMDEdepMap::operator=(const AliFMDEdepMap& other)
88{
088f8e79 89 // Assignment operator
e802be3e 90 fMaxDetectors = other.fMaxDetectors;
91 fMaxRings = other.fMaxRings;
92 fMaxSectors = other.fMaxSectors;
93 fMaxStrips = other.fMaxStrips;
94 if (fData) delete [] fData;
bfdc7f5d 95 fTotal = fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips;
021f1396 96 if (fTotal == 0) fTotal = 51200;
bfdc7f5d 97 fData = new AliFMDEdepHitPair[fTotal];
0ed9abeb 98 for (Int_t i = 0; i < fTotal; i++) fData[i] = other.fData[i];
e802be3e 99 return *this;
100}
101
088f8e79 102//____________________________________________________________________
103void
104AliFMDEdepMap::Reset()
105{
106 // Reset to zero
0ed9abeb 107 for (Int_t i = 0; i < fTotal; i++) {
83ad576a 108 fData[i].fEdep = 0;
109 fData[i].fN = 0;
110 fData[i].fNPrim = 0;
8d00dfa3 111 fData[i].fLabels.Reset();
bfdc7f5d 112 };
088f8e79 113}
114
e802be3e 115//____________________________________________________________________
116void
69b696b9 117AliFMDEdepMap::Reset(const AliFMDEdepHitPair& val)
e802be3e 118{
088f8e79 119 // Reset to val
0ed9abeb 120 for (Int_t i = 0; i < fTotal; i++) {
8d00dfa3 121 fData[i].fEdep = val.fEdep;
122 fData[i].fN = val.fN;
123 fData[i].fNPrim = val.fNPrim;
124 fData[i].fLabels = val.fLabels;
bfdc7f5d 125 };
e802be3e 126}
127
128//____________________________________________________________________
129AliFMDEdepHitPair&
83ad576a 130AliFMDEdepMap::operator()(UShort_t det, Char_t ring,
131 UShort_t sec, UShort_t str)
e802be3e 132{
133 // Get data
134 //
135 // Parameters:
136 // det Detector #
137 // ring Ring ID
138 // sec Sector #
139 // str Strip #
140 //
141 // Returns appropriate data
142 //
143 return fData[CalcIndex(det, ring, sec, str)];
144}
145
146//____________________________________________________________________
147const AliFMDEdepHitPair&
83ad576a 148AliFMDEdepMap::operator()(UShort_t det, Char_t ring,
149 UShort_t sec, UShort_t str) const
e802be3e 150{
151 // Get data
152 //
153 // Parameters:
154 // det Detector #
155 // ring Ring ID
156 // sec Sector #
157 // str Strip #
158 //
159 // Returns appropriate data
160 //
161 return fData[CalcIndex(det, ring, sec, str)];
162}
163
164
165//___________________________________________________________________
166//
167// EOF
168//