]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALRawDigit.cxx
Define Clear for AliEMCALDigits to delete the owned arrays when the TClonesArray...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRawDigit.cxx
CommitLineData
916f1e76 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// --- ROOT system ---
17#include <Riostream.h>
18#include <TMath.h>
19
20// --- Standard library ---
21
22// --- AliRoot header files ---
23
24#include "AliEMCALRawDigit.h"
25
26ClassImp(AliEMCALRawDigit)
27
28//____________________________________________________________________________
29AliEMCALRawDigit::AliEMCALRawDigit() : TObject(),
30fId(-1),
31fNSamples(0),
32fSamples(0x0)
33{
34 // default ctor
35}
36
37//____________________________________________________________________________
38AliEMCALRawDigit::AliEMCALRawDigit(Int_t id, Int_t timeSamples[], Int_t nSamples) : TObject(),
39fId(id),
40fNSamples(nSamples),
41fSamples(0x0)
42{
43 //
44 fSamples = new Int_t[fNSamples] ;
45 for (Int_t i=0; i < fNSamples; i++) fSamples[i] = timeSamples[i];
46}
47
48//____________________________________________________________________________
49AliEMCALRawDigit::AliEMCALRawDigit(const AliEMCALRawDigit& digit) : TObject(),//AliDigitNew(digit),
50fId(digit.fId),
51fNSamples(digit.fNSamples),
52fSamples(0x0)
53
54{
55 // Copy ctor
56 // Data members of the base class (AliNewDigit)
57
58// fAmp = digit.fAmp;
59// fIndexInList = digit.fIndexInList;
60 fSamples = new Int_t[fNSamples];
61 for (Int_t i=0; i < digit.fNSamples; i++) fSamples[i] = digit.fSamples[i];
62}
63
64//____________________________________________________________________________
65AliEMCALRawDigit::~AliEMCALRawDigit()
66{
e0dc3f7d 67 // Delete array of time samples
68 delete [] fSamples;
916f1e76 69}
70
e0dc3f7d 71//____________________________________________________________________________
72void AliEMCALRawDigit::Clear(Option_t *)
73{
74 // Delete array of time samples
75 delete [] fSamples;
76}
77
78
916f1e76 79//____________________________________________________________________________
80Bool_t AliEMCALRawDigit::GetTimeSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
81{
82 if (iSample > fNSamples || iSample < 0) return kFALSE;
83
84 amp = fSamples[iSample] & 0xFFF;
85 timeBin = (fSamples[iSample] >> 12) & 0xFF;
86
87 return kTRUE;
88}
89
90//____________________________________________________________________________
91void AliEMCALRawDigit::Print(const Option_t* /*opt*/) const
92{
93 printf("===\nDigit id: %4d / %d Time Samples: \n",fId,fNSamples);
94 for (Int_t i=0; i < fNSamples; i++)
95 {
96 Int_t timeBin, amp;
97 GetTimeSample(i, timeBin, amp);
98 printf("(%d,%d) ",timeBin,amp);
99 }
100
101 printf("\n");
102}
103
104//____________________________________________________________________________
105Int_t AliEMCALRawDigit::Compare(const TObject* obj) const
106{
107 // Compares two digits with respect to its Id
108 // to sort according increasing Id
109
110 Int_t rv;
111
112 AliEMCALRawDigit* digit = (AliEMCALRawDigit *)obj;
113
114 Int_t iddiff = fId - digit->GetId();
115
116 if ( iddiff > 0 )
117 rv = 1;
118 else if ( iddiff < 0 )
119 rv = -1;
120 else
121 rv = 0;
122
123 return rv;
124}
125
126//____________________________________________________________________________
127Bool_t AliEMCALRawDigit::operator==(AliEMCALRawDigit const & digit) const
128{
129 // Two digits are equal if they have the same Id
130
131 if(fId == digit.fId)
132 return kTRUE;
133 else
134 return kFALSE;
135}