]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHTransientDigit.cxx
01-feb-2003 NvE Memberfunction Info() renamed to Data() in various classes in order to
[u/mrichter/AliRoot.git] / RICH / AliRICHTransientDigit.cxx
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
16 /*
17   $Log$
18   Revision 1.3  2001/08/30 09:51:23  hristov
19   The operator[] is replaced by At() or AddAt() in case of TObjArray.
20
21   Revision 1.2  2000/10/02 15:53:28  jbarbosa
22   Fixed memory leak (delete fTrackList).
23
24   Revision 1.1  2000/06/12 15:35:17  jbarbosa
25   Cleaned up version.
26
27 */
28
29
30 #include "AliRICHTransientDigit.h"
31 #include <TObjArray.h>
32 #include "TVector.h"
33
34 ClassImp(AliRICHTransientDigit)
35     
36 //____________________________________________________________________________
37 AliRICHTransientDigit::AliRICHTransientDigit(Int_t ich, Int_t *digits): 
38     AliRICHDigit(digits)
39 {
40     //
41     // Creates a RICH digit list object
42     //
43     
44     fChamber = ich;
45     fTrackList   = new TObjArray;
46     
47 }
48 //_____________________________________________________________________________
49
50 AliRICHTransientDigit::~AliRICHTransientDigit()
51 {
52   fTrackList->Delete();
53   delete fTrackList;
54 }
55
56 ////////////////////////////////////////////////////////////////////////
57 void AliRICHTransientDigit::AddToTrackList(Int_t track, Int_t charge)
58 {
59   TVector *pTrInfo = new TVector(2);
60   TVector &trInfo = *pTrInfo;
61   trInfo(0) = track;
62   trInfo(1) = charge;
63   fTrackList->Add(pTrInfo);
64 }
65
66 ////////////////////////////////////////////////////////////////////////
67 void AliRICHTransientDigit::UpdateTrackList(Int_t track, Int_t charge)
68 {
69   Int_t lastEntry = fTrackList->GetLast();
70   TVector *pVect = static_cast<TVector*>(fTrackList->At(lastEntry));
71   if ( static_cast<Int_t>((*pVect)(0)) == track) {
72     (*pVect)(1) += charge;  // update charge
73   } else {
74     AddToTrackList(track,charge);
75   }
76 }
77
78 ////////////////////////////////////////////////////////////////////////
79 Int_t AliRICHTransientDigit::GetTrack(Int_t i) const
80 {
81   if (i > fTrackList->GetEntriesFast()) return 0;
82   TVector *pVect = static_cast<TVector*>(fTrackList->At(i));
83   return static_cast<Int_t>((*pVect)(0));
84 }
85
86
87 ////////////////////////////////////////////////////////////////////////
88 Int_t AliRICHTransientDigit::GetCharge(Int_t i) const
89 {
90   if (i > fTrackList->GetEntriesFast()) return 0;
91   TVector *pVect = static_cast<TVector*>(fTrackList->At(i));
92   return static_cast<Int_t>((*pVect)(1));
93 }