1 //_________________________________________________________________________
2 // TOF digit: member variables
3 // fSector : TOF sector
5 // fStrip : strips number
6 // fPadx : pad number along x
7 // fPadz : pad number along z
8 // fTdc : TArrayF of TDC values
9 // fAdc : TArrayF of ADC values
11 // Getters, setters and member functions defined here
13 //*-- Authors: F. Pierella, A. Seganti, D. Vicinanza
16 /**************************************************************************
17 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
19 * Author: The ALICE Off-line Project. *
20 * Contributors are mentioned in the code where appropriate. *
22 * Permission to use, copy, modify and distribute this software and its *
23 * documentation strictly for non-commercial purposes is hereby granted *
24 * without fee, provided that the above copyright notice appears in all *
25 * copies and that both the copyright notice and this permission notice *
26 * appear in the supporting documentation. The authors make no claims *
27 * about the suitability of this software for any purpose. It is *
28 * provided "as is" without express or implied warranty. *
29 **************************************************************************/
37 #include "AliTOFSDigit.h"
38 #include "AliTOFConstants.h"
42 ClassImp(AliTOFSDigit)
44 ////////////////////////////////////////////////////////////////////////
45 AliTOFSDigit::AliTOFSDigit()
56 ////////////////////////////////////////////////////////////////////////
57 AliTOFSDigit::AliTOFSDigit(Int_t tracknum, Int_t *vol,Float_t *digit)
60 // Constructor of digit object
68 fTdc = new TArrayF(fNDigits);
69 (*fTdc)[0] = digit[0];
70 fAdc = new TArrayF(fNDigits);
71 (*fAdc)[0] = digit[1];
72 fTracks = new TArrayI(kMAXDIGITS*fNDigits);
73 (*fTracks)[0] = tracknum;
74 for (Int_t i = 1; i <kMAXDIGITS*fNDigits; i++) {
79 ////////////////////////////////////////////////////////////////////////
80 AliTOFSDigit::AliTOFSDigit(const AliTOFSDigit & digit)
83 // copy ctor for AliTOFSDigit object
85 fSector = digit.fSector;
86 fPlate = digit.fPlate;
87 fStrip = digit.fStrip;
90 fNDigits = digit.fNDigits;
91 fTdc = new TArrayF(*digit.fTdc);
92 fAdc = new TArrayF(*digit.fAdc);
93 fTracks = new TArrayI(*digit.fTracks);
96 ////////////////////////////////////////////////////////////////////////
97 AliTOFSDigit::AliTOFSDigit(Int_t sector, Int_t plate, Int_t strip, Int_t padx,
98 Int_t padz, Float_t tdc, Float_t adc)
101 // Constructor for sdigit
109 fTdc = new TArrayF(fNDigits);
111 fAdc = new TArrayF(fNDigits);
113 // no tracks were specified, set them to -1
114 fTracks = new TArrayI(kMAXDIGITS*fNDigits);
115 for (Int_t i = 0; i <kMAXDIGITS*fNDigits; i++) {
120 ////////////////////////////////////////////////////////////////////////
121 void AliTOFSDigit::GetLocation(Int_t *Loc) const
124 // Get the coordinates of the digit
125 // in terms of Sector - Plate - Strip - Pad
135 ////////////////////////////////////////////////////////////////////////
136 void AliTOFSDigit::Update(Int_t tdc, Int_t adc, Int_t track)
139 // Add charge and track
144 for (Int_t i = 0; i < fNDigits; i++) {
145 if (TMath::Abs(tdc-fTdc->At(i)) < AliTOFConstants::fgkTimeDiff) {
152 (*fAdc)[sameTime] += static_cast<Float_t>(adc);
153 // update track - find the first -1 value and replace it by the
155 for (Int_t iTrack=0; iTrack<kMAXDIGITS; iTrack++) {
156 if ((*fTracks)[sameTime*kMAXDIGITS+iTrack] == -1) {
157 (*fTracks)[sameTime*kMAXDIGITS+iTrack] = track;
160 // write warning about many tracks going to this pad
161 if (iTrack == kMAXDIGITS) {
162 cerr<<"WARNING: AliTOFSDigit::Update Many hits in the padhit"<<endl;
171 (*fTdc)[fNDigits-1] = tdc;
173 (*fAdc)[fNDigits-1] = adc;
174 fTracks->Set(fNDigits*kMAXDIGITS);
175 (*fTracks)[(fNDigits-1)*kMAXDIGITS] = track;
176 for (Int_t i = 1; i <kMAXDIGITS; i++) {
177 (*fTracks)[(fNDigits-1)*kMAXDIGITS+i] = -1;
182 ////////////////////////////////////////////////////////////////////////
183 AliTOFSDigit::~AliTOFSDigit()
193 ////////////////////////////////////////////////////////////////////////
195 Int_t AliTOFSDigit::GetTotPad() const
198 // Get the "total" index of the pad inside a Sector
199 // starting from the digits data.
205 tof =(AliTOF*) gAlice->GetDetector("TOF");
207 printf("AliTOFSDigit::GetTotPad - No AliRun object present, exiting");
211 Int_t pad = fPadx+tof->GetNpadX()*(fPadz-1);
217 case 2: before = tof->GetNStripC();
219 case 3: before = tof->GetNStripB() + tof->GetNStripC();
221 case 4: before = tof->GetNStripA() + tof->GetNStripB() + tof->GetNStripC();
223 case 5: before = tof->GetNStripA() + 2*tof->GetNStripB() + tof->GetNStripC();
227 Int_t strip = fStrip+before;
228 Int_t padTot = tof->GetPadXStr()*(strip-1)+pad;
232 ////////////////////////////////////////////////////////////////////////
233 //void AliTOFSDigit::AddTrack(Int_t track)
236 // Add a new and different track to the digit -- but to which digit??
237 // do not implemet this function
239 ////////////////////////////////////////////////////////////////////////
241 // Overloading of Streaming, Sum and Comparison operators
243 ////////////////////////////////////////////////////////////////////////
245 Bool_t AliTOFSDigit::operator==(AliTOFSDigit const &digit) const
248 // Overloading of Comparison operator
250 if (fSector==digit.fSector &&
251 fPlate==digit.fPlate &&
252 fStrip==digit.fStrip &&
253 fPadx==digit.fPadx &&
254 fPadz==digit.fPadz &&
256 fAdc==digit.fAdc) return kTRUE;
260 ////////////////////////////////////////////////////////////////////////
262 ostream& operator << (ostream& out, const AliTOFSDigit &digit)
265 // Output streamer: output of the digit data
267 out << "Sector " << digit.fSector << ", Plate " << digit.fPlate << ", Strip " << digit.fStrip << endl;
268 out << "Padx" << digit.fPadx << ", Padz " << digit.fPadz << endl;
269 out << "TDC " << digit.fTdc->At(0) << ", ADC "<< digit.fAdc->At(0) << endl;