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
75 // returns the time and amplitude of a given time sample and if the sample was ok
77 if (iSample > fNSamples || iSample < 0) return kFALSE;
79 amp = fSamples[iSample] & 0xFFF;
80 timeBin = (fSamples[iSample] >> 12) & 0xFF;
85 //____________________________________________________________________________
86 void AliEMCALRawDigit::SetTimeSamples(const Int_t timeSamples[], const Int_t nSamples)
88 // Sets the time samples
92 AliDebug(1,"Samples already filled: delete first!");
98 fSamples = new Int_t[fNSamples];
99 for (Int_t i = 0; i < fNSamples; i++) fSamples[i] = timeSamples[i];
102 //____________________________________________________________________________
103 Bool_t AliEMCALRawDigit::GetMaximum(Int_t& amplitude, Int_t& time) const
105 // Checks the maximum amplitude in the time sample
109 AliDebug(1,"Digit has no time sample");
114 for (Int_t i = 0; i < fNSamples; i++)
117 if (GetTimeSample(i, t, a))
130 //____________________________________________________________________________
131 Int_t AliEMCALRawDigit::Compare(const TObject * obj) const
133 // Compares two digits with respect to its Id
134 // to sort according increasing Id
138 AliEMCALRawDigit* digit = (AliEMCALRawDigit*)obj;
140 Int_t iddiff = fId - digit->GetId();
152 //____________________________________________________________________________
153 void AliEMCALRawDigit::Print(const Option_t* /*opt*/) const
157 printf("===\n| Digit id: %4d / %d Time Samples: \n",fId,fNSamples);
158 for (Int_t i=0; i < fNSamples; i++)
160 Int_t timeBin=-1, amp=0;
161 GetTimeSample(i, timeBin, amp);
162 printf("| (%d,%d) ",timeBin,amp);