]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFSDigit.cxx
Mostly minor style modifications to be ready for cloning with EMCAL
[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
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
41ClassImp(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////////////////////////////////////////////////////////////////////////
56AliTOFSDigit::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////////////////////////////////////////////////////////////////////////
79AliTOFSDigit::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////////////////////////////////////////////////////////////////////////
96AliTOFSDigit::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////////////////////////////////////////////////////////////////////////
120void 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 135void 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}
8e72349e 181
182////////////////////////////////////////////////////////////////////////
183void AliTOFSDigit::Update(AliTOFSDigit* sdig)
184{
185
186 //
187 // Perform the sum with sdig
188 //
189
190 // start loop on all sdig locations
191 Int_t nlocations=sdig->GetNDigits();
192
193 for (Int_t j = 0; j < nlocations; j++) {
194 Float_t tdcbin=50.; // [ps] hardwired for the time being
195 Int_t tdc=(Int_t)sdig->GetTdc(j);
196 Int_t adc=(Int_t)sdig->GetAdc(j);
197 // getting here only the first track number
198 Int_t track=GetTrack(j,0);
199
200
201 Int_t sameTime = -1;
202 Float_t tdcwindow=((Float_t)AliTOFConstants::fgkTimeDiff)/tdcbin;
203 for (Int_t i = 0; i < fNDigits; i++) {
204 if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
205 sameTime = i;
206 break;
207 }
208 }
209
210 if (sameTime >= 0) {
211 (*fAdc)[sameTime] += static_cast<Float_t>(adc);
212 // update track - find the first -1 value and replace it by the
213 // track number
214 for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
215 if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
216 (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
217 break;
218 }
219 // write warning about many tracks going to this pad
220 if (iTrack == kMAXDIGITS) {
221 cerr<<"WARNING: AliTOFSDigit::Update Many hits in the padhit"<<endl;
222 cerr<<" ";
223 // PrintPad();
224 }
225 }
226 } else {
227 // add new time slot
228 fNDigits++;
229 fTdc->Set(fNDigits);
230 (*fTdc)[fNDigits-1] = tdc;
231 fAdc->Set(fNDigits);
232 (*fAdc)[fNDigits-1] = adc;
233 fTracks->Set(fNDigits*kMAXDIGITS);
234 (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
235 for (Int_t i = 1; i <kMAXDIGITS; i++) {
236 (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
237 } // for (Int_t i = 1; i <kMAXDIGITS; i++)
238 } // if (sameTime >= 0)
239 } // end loop on sdig locations
240}
241
5919c40c 242////////////////////////////////////////////////////////////////////////
243AliTOFSDigit::~AliTOFSDigit()
244{
ea7a588a 245 //
246 // dtor
247 //
5919c40c 248 delete fTdc;
249 delete fAdc;
250 delete fTracks;
251}
252
253////////////////////////////////////////////////////////////////////////
254
255Int_t AliTOFSDigit::GetTotPad() const
256{
ea7a588a 257 //
258 // Get the "total" index of the pad inside a Sector
259 // starting from the digits data.
260 //
261
b213b8bd 262 Int_t pad = fPadx+AliTOFConstants::fgkNpadX*(fPadz-1);
5919c40c 263 Int_t before=0;
ea7a588a 264
5919c40c 265 switch(fPlate){
266 case 1: before = 0;
ea7a588a 267 break;
b213b8bd 268 case 2: before = AliTOFConstants::fgkNStripC;
ea7a588a 269 break;
b213b8bd 270 case 3: before = AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC;
ea7a588a 271 break;
b213b8bd 272 case 4: before = AliTOFConstants::fgkNStripA + AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC;
ea7a588a 273 break;
b213b8bd 274 case 5: before = AliTOFConstants::fgkNStripA + 2*AliTOFConstants::fgkNStripB + AliTOFConstants::fgkNStripC;
ea7a588a 275 break;
5919c40c 276 }
277
278 Int_t strip = fStrip+before;
b213b8bd 279 Int_t padTot = AliTOFConstants::fgkPadXStrip*(strip-1)+pad;
5919c40c 280 return padTot;
281}
282