]>
Commit | Line | Data |
---|---|---|
5919c40c | 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 | ||
5919c40c | 16 | |
ea7a588a | 17 | //_________________________________________________________________________ |
18 | // TOF sdigit: member variables | |
19 | // fSector : TOF sector | |
20 | // fPlate : TOF plate | |
21 | // fStrip : strips number | |
22 | // fPadx : pad number along x | |
23 | // fPadz : pad number along z | |
24 | // fTdc : TArrayF of TDC values | |
25 | // fAdc : TArrayF of ADC values | |
26 | // | |
27 | // Getters, setters and member functions defined here | |
28 | // | |
29 | //*-- Authors: F. Pierella, A. Seganti, D. Vicinanza | |
30 | ||
31 | #include <iostream.h> | |
5919c40c | 32 | #include "TArrayF.h" |
33 | #include "TArrayI.h" | |
34 | ||
35 | #include "AliTOF.h" | |
36 | #include "AliTOFSDigit.h" | |
37 | #include "AliTOFConstants.h" | |
38 | #include "AliRun.h" | |
39 | #include "AliMC.h" | |
40 | ||
41 | ClassImp(AliTOFSDigit) | |
42 | ||
43 | //////////////////////////////////////////////////////////////////////// | |
ea7a588a | 44 | AliTOFSDigit::AliTOFSDigit() |
5919c40c | 45 | { |
ea7a588a | 46 | // |
47 | // default ctor | |
48 | // | |
5919c40c | 49 | fNDigits = 0; |
50 | fTdc = 0; | |
51 | fAdc = 0; | |
52 | fTracks = 0; | |
53 | } | |
54 | ||
55 | //////////////////////////////////////////////////////////////////////// | |
56 | AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t *vol,Float_t *digit) | |
57 | { | |
ea7a588a | 58 | // |
59 | // Constructor of digit object | |
60 | // | |
5919c40c | 61 | fSector = vol[0]; |
62 | fPlate = vol[1]; | |
63 | fStrip = vol[2]; | |
64 | fPadx = vol[3]; | |
65 | fPadz = vol[4]; | |
66 | fNDigits = 1; | |
67 | fTdc = new TArrayF(fNDigits); | |
68 | (*fTdc)[0] = digit[0]; | |
69 | fAdc = new TArrayF(fNDigits); | |
70 | (*fAdc)[0] = digit[1]; | |
71 | fTracks = new TArrayI(kMAXDIGITS*fNDigits); | |
72 | (*fTracks)[0] = tracknum; | |
73 | for (Int_t i = 1; i <kMAXDIGITS*fNDigits; i++) { | |
74 | (*fTracks)[i] = -1; | |
75 | } | |
76 | } | |
77 | ||
78 | //////////////////////////////////////////////////////////////////////// | |
79 | AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit) | |
80 | { | |
81 | // | |
82 | // copy ctor for AliTOFSDigit object | |
83 | // | |
84 | fSector = digit.fSector; | |
85 | fPlate = digit.fPlate; | |
86 | fStrip = digit.fStrip; | |
87 | fPadx = digit.fPadx; | |
88 | fPadz = digit.fPadz; | |
89 | fNDigits = digit.fNDigits; | |
90 | fTdc = new TArrayF(*digit.fTdc); | |
91 | fAdc = new TArrayF(*digit.fAdc); | |
92 | fTracks = new TArrayI(*digit.fTracks); | |
93 | } | |
94 | ||
95 | //////////////////////////////////////////////////////////////////////// | |
96 | AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx, | |
ea7a588a | 97 | Int_t padz, Float_t tdc, Float_t adc) |
5919c40c | 98 | { |
ea7a588a | 99 | // |
100 | // Constructor for sdigit | |
101 | // | |
5919c40c | 102 | fSector = sector; |
103 | fPlate = plate; | |
104 | fStrip = strip; | |
105 | fPadx = padx; | |
106 | fPadz = padz; | |
107 | fNDigits = 1; | |
108 | fTdc = new TArrayF(fNDigits); | |
109 | (*fTdc)[0] = tdc; | |
110 | fAdc = new TArrayF(fNDigits); | |
ea7a588a | 111 | (*fAdc)[0] = adc; |
112 | // no tracks were specified, set them to -1 | |
5919c40c | 113 | fTracks = new TArrayI(kMAXDIGITS*fNDigits); |
114 | for (Int_t i = 0; i <kMAXDIGITS*fNDigits; i++) { | |
115 | (*fTracks)[i] = -1; | |
116 | } | |
117 | } | |
ea7a588a | 118 | |
5919c40c | 119 | //////////////////////////////////////////////////////////////////////// |
120 | void AliTOFSDigit::GetLocation(Int_t *Loc) const | |
121 | { | |
ea7a588a | 122 | // |
123 | // Get the coordinates of the digit | |
124 | // in terms of Sector - Plate - Strip - Pad | |
125 | // | |
126 | ||
127 | Loc[0]=fSector; | |
128 | Loc[1]=fPlate; | |
129 | Loc[2]=fStrip; | |
130 | Loc[3]=fPadx; | |
131 | Loc[4]=fPadz; | |
5919c40c | 132 | } |
133 | ||
134 | //////////////////////////////////////////////////////////////////////// | |
b213b8bd | 135 | void AliTOFSDigit::Update(Float_t tdcbin, Int_t tdc, Int_t adc, Int_t track) |
5919c40c | 136 | { |
ea7a588a | 137 | // |
138 | // Add charge and track | |
139 | // | |
140 | ||
5919c40c | 141 | Int_t sameTime = -1; |
b213b8bd | 142 | Float_t tdcwindow=((Float_t)AliTOFConstants::fgkTimeDiff)/tdcbin; |
5919c40c | 143 | for (Int_t i = 0; i < fNDigits; i++) { |
b213b8bd | 144 | if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) { |
5919c40c | 145 | sameTime = i; |
146 | break; | |
147 | } | |
148 | } | |
ea7a588a | 149 | |
5919c40c | 150 | if (sameTime >= 0) { |
151 | (*fAdc)[sameTime] += static_cast<Float_t>(adc); | |
ea7a588a | 152 | // update track - find the first -1 value and replace it by the |
153 | // track number | |
5919c40c | 154 | for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) { |
155 | if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) { | |
156 | (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track; | |
157 | break; | |
158 | } | |
ea7a588a | 159 | // write warning about many tracks going to this pad |
5919c40c | 160 | if (iTrack == kMAXDIGITS) { |
161 | cerr<<"WARNING: AliTOFSDigit::Update Many hits in the padhit"<<endl; | |
162 | cerr<<" "; | |
ea7a588a | 163 | // PrintPad(); |
5919c40c | 164 | } |
165 | } | |
166 | } else { | |
ea7a588a | 167 | // add new time slot |
5919c40c | 168 | fNDigits++; |
169 | fTdc->Set(fNDigits); | |
170 | (*fTdc)[fNDigits-1] = tdc; | |
171 | fAdc->Set(fNDigits); | |
172 | (*fAdc)[fNDigits-1] = adc; | |
173 | fTracks->Set(fNDigits*kMAXDIGITS); | |
174 | (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track; | |
175 | for (Int_t i = 1; i <kMAXDIGITS; i++) { | |
176 | (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1; | |
177 | } | |
178 | } | |
ea7a588a | 179 | |
5919c40c | 180 | } |
181 | //////////////////////////////////////////////////////////////////////// | |
182 | AliTOFSDigit::~AliTOFSDigit() | |
183 | { | |
ea7a588a | 184 | // |
185 | // dtor | |
186 | // | |
5919c40c | 187 | delete fTdc; |
188 | delete fAdc; | |
189 | delete fTracks; | |
190 | } | |
191 | ||
192 | //////////////////////////////////////////////////////////////////////// | |
193 | ||
194 | Int_t AliTOFSDigit::GetTotPad() const | |
195 | { | |
ea7a588a | 196 | // |
197 | // Get the "total" index of the pad inside a Sector | |
198 | // starting from the digits data. | |
199 | // | |
200 | ||
b213b8bd | 201 | Int_t pad = fPadx+AliTOFConstants::fgkNpadX*(fPadz-1); |
5919c40c | 202 | Int_t before=0; |
ea7a588a | 203 | |
5919c40c | 204 | switch(fPlate){ |
205 | case 1: before = 0; | |
ea7a588a | 206 | break; |
b213b8bd | 207 | case 2: before = AliTOFConstants::fgkNStripC; |
ea7a588a | 208 | break; |
b213b8bd | 209 | case 3: before = AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC; |
ea7a588a | 210 | break; |
b213b8bd | 211 | case 4: before = AliTOFConstants::fgkNStripA + AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC; |
ea7a588a | 212 | break; |
b213b8bd | 213 | case 5: before = AliTOFConstants::fgkNStripA + 2*AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC; |
ea7a588a | 214 | break; |
5919c40c | 215 | } |
216 | ||
217 | Int_t strip = fStrip+before; | |
b213b8bd | 218 | Int_t padTot = AliTOFConstants::fgkPadXStrip*(strip-1)+pad; |
5919c40c | 219 | return padTot; |
220 | } | |
221 |