1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________//
20 // TOF sdigit: member variables //
21 // fSector : TOF sector //
22 // fPlate : TOF plate //
23 // fStrip : strips number //
24 // fPadx : pad number along x //
25 // fPadz : pad number along z //
26 // fTdc : TArrayI of TDC values //
27 // fAdc : TArrayI of ADC values //
29 // Getters, setters and member functions defined here //
31 // -- Authors: F. Pierella, A. Seganti, D. Vicinanza //
32 //_________________________________________________________________________//
34 //#include "TArrayI.h"
38 #include "AliTOFGeometry.h"
39 #include "AliTOFSDigit.h"
41 ClassImp(AliTOFSDigit)
43 ////////////////////////////////////////////////////////////////////////
44 AliTOFSDigit::AliTOFSDigit():
60 ////////////////////////////////////////////////////////////////////////
61 AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t *vol,Int_t *digit):
74 // Constructor of digit object
83 fTdc = new TArrayI(fNDigits);
84 (*fTdc)[0] = digit[0];
85 fAdc = new TArrayI(fNDigits);
86 (*fAdc)[0] = digit[1];
87 fTracks = new TArrayI(kMAXDIGITS*fNDigits);
88 (*fTracks)[0] = tracknum;
89 for (Int_t i = 1; i <kMAXDIGITS*fNDigits; i++) {
94 ////////////////////////////////////////////////////////////////////////
95 AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit):
108 // copy ctor for AliTOFSDigit object
110 fSector = digit.fSector;
111 fPlate = digit.fPlate;
112 fStrip = digit.fStrip;
115 fNDigits = digit.fNDigits;
116 fTdc = new TArrayI(*digit.fTdc);
117 fAdc = new TArrayI(*digit.fAdc);
118 fTracks = new TArrayI(*digit.fTracks);
121 ////////////////////////////////////////////////////////////////////////
122 AliTOFSDigit& AliTOFSDigit::operator=(const AliTOFSDigit & digit)
125 // copy ctor for AliTOFSDigit object
127 this->fSector = digit.fSector;
128 this->fPlate = digit.fPlate;
129 this->fStrip = digit.fStrip;
130 this->fPadx = digit.fPadx;
131 this->fPadz = digit.fPadz;
132 this->fNDigits = digit.fNDigits;
133 this->fTdc = digit.fTdc;
134 this->fAdc = digit.fAdc;
135 this->fTracks = digit.fTracks;
140 ////////////////////////////////////////////////////////////////////////
141 AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx,
142 Int_t padz, Int_t tdc, Int_t adc):
154 // Constructor for sdigit
156 fTdc = new TArrayI(fNDigits);
158 fAdc = new TArrayI(fNDigits);
160 // no tracks were specified, set them to -1
161 fTracks = new TArrayI(kMAXDIGITS*fNDigits);
162 for (Int_t i = 0; i <kMAXDIGITS*fNDigits; i++) {
167 ////////////////////////////////////////////////////////////////////////
168 void AliTOFSDigit::GetLocation(Int_t *Loc) const
171 // Get the coordinates of the digit
172 // in terms of Sector - Plate - Strip - Pad
182 ////////////////////////////////////////////////////////////////////////
183 void AliTOFSDigit::Update(Float_t tdcbin, Int_t tdc, Int_t adc, Int_t track)
186 // Add charge and track
190 Float_t tdcwindow=((Float_t)AliTOFGeometry::TimeDiff())/tdcbin;
191 for (Int_t i = 0; i < fNDigits; i++) {
192 if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
199 (*fAdc)[sameTime] += adc;
200 // update track - find the first -1 value and replace it by the
202 for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
203 if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
204 (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
207 // write warning about many tracks going to this pad
208 if (iTrack == kMAXDIGITS) {
209 AliWarning("Many hits in the padhit");
210 // ToAliWarning(PrintPad());
217 (*fTdc)[fNDigits-1] = tdc;
219 (*fAdc)[fNDigits-1] = adc;
220 fTracks->Set(fNDigits*kMAXDIGITS);
221 (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
222 for (Int_t i = 1; i <kMAXDIGITS; i++) {
223 (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
229 ////////////////////////////////////////////////////////////////////////
230 void AliTOFSDigit::Update(AliTOFSDigit* sdig)
234 // Perform the sum with sdig
237 // start loop on all sdig locations
238 Int_t nlocations=sdig->GetNDigits();
240 for (Int_t j = 0; j < nlocations; j++) {
241 Float_t tdcbin = AliTOFGeometry::TdcBinWidth();// [ps] hardwired for the time being
242 Int_t tdc=(Int_t)sdig->GetTdc(j);
243 Int_t adc=(Int_t)sdig->GetAdc(j);
244 // getting here only the first track number
245 Int_t track=GetTrack(j,0);
249 Float_t tdcwindow=((Float_t)AliTOFGeometry::TimeDiff())/tdcbin;
250 for (Int_t i = 0; i < fNDigits; i++) {
251 if (TMath::Abs(tdc-fTdc->At(i)) < tdcwindow) {
258 (*fAdc)[sameTime] += adc;
259 // update track - find the first -1 value and replace it by the
261 for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
262 if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
263 (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
266 // write warning about many tracks going to this pad
267 if (iTrack == kMAXDIGITS) {
268 AliWarning("Many hits in the padhit");
269 // ToAliWarning(PrintPad());
276 (*fTdc)[fNDigits-1] = tdc;
278 (*fAdc)[fNDigits-1] = adc;
279 fTracks->Set(fNDigits*kMAXDIGITS);
280 (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
281 for (Int_t i = 1; i <kMAXDIGITS; i++) {
282 (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
283 } // for (Int_t i = 1; i <kMAXDIGITS; i++)
284 } // if (sameTime >= 0)
285 } // end loop on sdig locations
288 ////////////////////////////////////////////////////////////////////////
289 AliTOFSDigit::~AliTOFSDigit()
299 ////////////////////////////////////////////////////////////////////////
301 Int_t AliTOFSDigit::GetTotPad() const
304 // Get the "total" index of the pad inside a Sector
305 // starting from the digits data.
308 Int_t pad = 2*fPadx + fPadz;
309 //Int_t pad = fPadx+AliTOFGeometry::NpadX()*fPadz;
317 before = AliTOFGeometry::NStripC();
320 before = AliTOFGeometry::NStripB() + AliTOFGeometry::NStripC();
323 before = AliTOFGeometry::NStripA() + AliTOFGeometry::NStripB() + AliTOFGeometry::NStripC();
326 before = AliTOFGeometry::NStripA() + 2*AliTOFGeometry::NStripB() + AliTOFGeometry::NStripC();
330 Int_t strip = fStrip + before;
331 Int_t padTot = AliTOFGeometry::NpadXStrip()*strip + pad;