]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFSDigit.cxx
Removing AliMC and AliMCProcess
[u/mrichter/AliRoot.git] / TOF / AliTOFSDigit.cxx
CommitLineData
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
f8014e68 31#include <Riostream.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"
5919c40c 39
40ClassImp(AliTOFSDigit)
41
42////////////////////////////////////////////////////////////////////////
ea7a588a 43 AliTOFSDigit::AliTOFSDigit()
5919c40c 44{
ea7a588a 45 //
46 // default ctor
47 //
5919c40c 48 fNDigits = 0;
49 fTdc = 0;
50 fAdc = 0;
51 fTracks = 0;
52}
53
54////////////////////////////////////////////////////////////////////////
55AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t *vol,Float_t *digit)
56{
ea7a588a 57 //
58 // Constructor of digit object
59 //
5919c40c 60 fSector = vol[0];
61 fPlate = vol[1];
62 fStrip = vol[2];
63 fPadx = vol[3];
64 fPadz = vol[4];
65 fNDigits = 1;
66 fTdc = new TArrayF(fNDigits);
67 (*fTdc)[0] = digit[0];
68 fAdc = new TArrayF(fNDigits);
69 (*fAdc)[0] = digit[1];
70 fTracks = new TArrayI(kMAXDIGITS*fNDigits);
71 (*fTracks)[0] = tracknum;
72 for (Int_t i = 1; i <kMAXDIGITS*fNDigits; i++) {
73 (*fTracks)[i] = -1;
74 }
75}
76
77////////////////////////////////////////////////////////////////////////
78AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit)
79{
80 //
81 // copy ctor for AliTOFSDigit object
82 //
83 fSector = digit.fSector;
84 fPlate = digit.fPlate;
85 fStrip = digit.fStrip;
86 fPadx = digit.fPadx;
87 fPadz = digit.fPadz;
88 fNDigits = digit.fNDigits;
89 fTdc = new TArrayF(*digit.fTdc);
90 fAdc = new TArrayF(*digit.fAdc);
91 fTracks = new TArrayI(*digit.fTracks);
92}
93
94////////////////////////////////////////////////////////////////////////
95AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx,
ea7a588a 96 Int_t padz, Float_t tdc, Float_t adc)
5919c40c 97{
ea7a588a 98 //
99 // Constructor for sdigit
100 //
5919c40c 101 fSector = sector;
102 fPlate = plate;
103 fStrip = strip;
104 fPadx = padx;
105 fPadz = padz;
106 fNDigits = 1;
107 fTdc = new TArrayF(fNDigits);
108 (*fTdc)[0] = tdc;
109 fAdc = new TArrayF(fNDigits);
ea7a588a 110 (*fAdc)[0] = adc;
111 // no tracks were specified, set them to -1
5919c40c 112 fTracks = new TArrayI(kMAXDIGITS*fNDigits);
113 for (Int_t i = 0; i <kMAXDIGITS*fNDigits; i++) {
114 (*fTracks)[i] = -1;
115 }
116}
ea7a588a 117
5919c40c 118////////////////////////////////////////////////////////////////////////
119void AliTOFSDigit::GetLocation(Int_t *Loc) const
120{
ea7a588a 121 //
122 // Get the coordinates of the digit
123 // in terms of Sector - Plate - Strip - Pad
124 //
125
126 Loc[0]=fSector;
127 Loc[1]=fPlate;
128 Loc[2]=fStrip;
129 Loc[3]=fPadx;
130 Loc[4]=fPadz;
5919c40c 131}
132
133////////////////////////////////////////////////////////////////////////
b213b8bd 134void AliTOFSDigit::Update(Float_t tdcbin, Int_t tdc, Int_t adc, Int_t track)
5919c40c 135{
ea7a588a 136 //
137 // Add charge and track
138 //
139
5919c40c 140 Int_t sameTime = -1;
b213b8bd 141 Float_t tdcwindow=((Float_t)AliTOFConstants::fgkTimeDiff)/tdcbin;
5919c40c 142 for (Int_t i = 0; i < fNDigits; i++) {
b213b8bd 143 if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
5919c40c 144 sameTime = i;
145 break;
146 }
147 }
ea7a588a 148
5919c40c 149 if (sameTime >= 0) {
150 (*fAdc)[sameTime] += static_cast<Float_t>(adc);
ea7a588a 151 // update track - find the first -1 value and replace it by the
152 // track number
5919c40c 153 for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
154 if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
155 (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
156 break;
157 }
ea7a588a 158 // write warning about many tracks going to this pad
5919c40c 159 if (iTrack == kMAXDIGITS) {
160 cerr<<"WARNING: AliTOFSDigit::Update Many hits in the padhit"<<endl;
161 cerr<<" ";
ea7a588a 162 // PrintPad();
5919c40c 163 }
164 }
165 } else {
ea7a588a 166 // add new time slot
5919c40c 167 fNDigits++;
168 fTdc->Set(fNDigits);
169 (*fTdc)[fNDigits-1] = tdc;
170 fAdc->Set(fNDigits);
171 (*fAdc)[fNDigits-1] = adc;
172 fTracks->Set(fNDigits*kMAXDIGITS);
173 (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
174 for (Int_t i = 1; i <kMAXDIGITS; i++) {
175 (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
176 }
177 }
ea7a588a 178
5919c40c 179}
8e72349e 180
181////////////////////////////////////////////////////////////////////////
182void AliTOFSDigit::Update(AliTOFSDigit* sdig)
183{
184
185 //
186 // Perform the sum with sdig
187 //
188
189 // start loop on all sdig locations
190 Int_t nlocations=sdig->GetNDigits();
191
192 for (Int_t j = 0; j < nlocations; j++) {
193 Float_t tdcbin=50.; // [ps] hardwired for the time being
194 Int_t tdc=(Int_t)sdig->GetTdc(j);
195 Int_t adc=(Int_t)sdig->GetAdc(j);
196 // getting here only the first track number
197 Int_t track=GetTrack(j,0);
198
199
200 Int_t sameTime = -1;
201 Float_t tdcwindow=((Float_t)AliTOFConstants::fgkTimeDiff)/tdcbin;
202 for (Int_t i = 0; i < fNDigits; i++) {
203 if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
204 sameTime = i;
205 break;
206 }
207 }
208
209 if (sameTime >= 0) {
210 (*fAdc)[sameTime] += static_cast<Float_t>(adc);
211 // update track - find the first -1 value and replace it by the
212 // track number
213 for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
214 if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
215 (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
216 break;
217 }
218 // write warning about many tracks going to this pad
219 if (iTrack == kMAXDIGITS) {
220 cerr<<"WARNING: AliTOFSDigit::Update Many hits in the padhit"<<endl;
221 cerr<<" ";
222 // PrintPad();
223 }
224 }
225 } else {
226 // add new time slot
227 fNDigits++;
228 fTdc->Set(fNDigits);
229 (*fTdc)[fNDigits-1] = tdc;
230 fAdc->Set(fNDigits);
231 (*fAdc)[fNDigits-1] = adc;
232 fTracks->Set(fNDigits*kMAXDIGITS);
233 (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
234 for (Int_t i = 1; i <kMAXDIGITS; i++) {
235 (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
236 } // for (Int_t i = 1; i <kMAXDIGITS; i++)
237 } // if (sameTime >= 0)
238 } // end loop on sdig locations
239}
240
5919c40c 241////////////////////////////////////////////////////////////////////////
242AliTOFSDigit::~AliTOFSDigit()
243{
ea7a588a 244 //
245 // dtor
246 //
5919c40c 247 delete fTdc;
248 delete fAdc;
249 delete fTracks;
250}
251
252////////////////////////////////////////////////////////////////////////
253
254Int_t AliTOFSDigit::GetTotPad() const
255{
ea7a588a 256 //
257 // Get the "total" index of the pad inside a Sector
258 // starting from the digits data.
259 //
260
b213b8bd 261 Int_t pad = fPadx+AliTOFConstants::fgkNpadX*(fPadz-1);
5919c40c 262 Int_t before=0;
ea7a588a 263
5919c40c 264 switch(fPlate){
265 case 1: before = 0;
ea7a588a 266 break;
b213b8bd 267 case 2: before = AliTOFConstants::fgkNStripC;
ea7a588a 268 break;
b213b8bd 269 case 3: before = AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC;
ea7a588a 270 break;
b213b8bd 271 case 4: before = AliTOFConstants::fgkNStripA + AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC;
ea7a588a 272 break;
b213b8bd 273 case 5: before = AliTOFConstants::fgkNStripA + 2*AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC;
ea7a588a 274 break;
5919c40c 275 }
276
277 Int_t strip = fStrip+before;
b213b8bd 278 Int_t padTot = AliTOFConstants::fgkPadXStrip*(strip-1)+pad;
5919c40c 279 return padTot;
280}
281