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 **************************************************************************/
20 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
23 // --- ROOT system ---
24 #include <Riostream.h>
27 // --- AliRoot header files ---
28 #include "AliEMCALRawDigit.h"
31 ClassImp(AliEMCALRawDigit)
33 //____________________________________________________________________________
34 AliEMCALRawDigit::AliEMCALRawDigit() : TObject(),
44 //____________________________________________________________________________
45 AliEMCALRawDigit::AliEMCALRawDigit(Int_t id, Int_t timeSamples[], Int_t nSamples) : TObject(),
53 fSamples = new Int_t[fNSamples];
54 for (Int_t i = 0; i < fNSamples; i++) fSamples[i] = timeSamples[i];
57 //____________________________________________________________________________
58 AliEMCALRawDigit::~AliEMCALRawDigit()
60 //dtor, delete array of time samples
61 if(fSamples) delete [] fSamples;
64 //____________________________________________________________________________
65 void AliEMCALRawDigit::Clear(Option_t *)
67 // clear, delete array of time samples
68 if(fSamples) delete [] fSamples;
72 //____________________________________________________________________________
73 Bool_t AliEMCALRawDigit::GetTimeSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
76 if (iSample > fNSamples || iSample < 0) return kFALSE;
78 amp = fSamples[iSample] & 0xFFF;
79 timeBin = (fSamples[iSample] >> 12) & 0xFF;
84 //____________________________________________________________________________
85 void AliEMCALRawDigit::SetTimeSamples(const Int_t timeSamples[], const Int_t nSamples)
90 AliDebug(1,"Samples already filled: delete first!");
96 fSamples = new Int_t[fNSamples];
97 for (Int_t i = 0; i < fNSamples; i++) fSamples[i] = timeSamples[i];
100 //____________________________________________________________________________
101 Bool_t AliEMCALRawDigit::GetMaximum(Int_t& amplitude, Int_t& time) const
106 AliDebug(1,"Digit has no time sample");
111 for (Int_t i = 0; i < fNSamples; i++)
114 if (GetTimeSample(i, t, a))
127 //____________________________________________________________________________
128 Int_t AliEMCALRawDigit::Compare(const TObject * obj) const
130 // Compares two digits with respect to its Id
131 // to sort according increasing Id
135 AliEMCALRawDigit* digit = (AliEMCALRawDigit*)obj;
137 Int_t iddiff = fId - digit->GetId();
149 //____________________________________________________________________________
150 void AliEMCALRawDigit::Print(const Option_t* /*opt*/) const
153 printf("===\n| Digit id: %4d / %d Time Samples: \n",fId,fNSamples);
154 for (Int_t i=0; i < fNSamples; i++)
156 Int_t timeBin=-1, amp=0;
157 GetTimeSample(i, timeBin, amp);
158 printf("| (%d,%d) ",timeBin,amp);