]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - EMCAL/AliEMCALRawDigit.cxx
Changing to centrality dependent corrections
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRawDigit.cxx
... / ...
CommitLineData
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
18
19
20 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
21*/
22
23// --- ROOT system ---
24#include <Riostream.h>
25#include <TMath.h>
26
27// --- AliRoot header files ---
28#include "AliEMCALRawDigit.h"
29#include "AliLog.h"
30
31ClassImp(AliEMCALRawDigit)
32
33//____________________________________________________________________________
34AliEMCALRawDigit::AliEMCALRawDigit() : TObject(),
35fId(-1),
36fNSamples(0),
37fSamples(0x0),
38fAmplitude(0),
39fTime(0)
40{
41 // default ctor
42}
43
44//____________________________________________________________________________
45AliEMCALRawDigit::AliEMCALRawDigit(Int_t id, Int_t timeSamples[], Int_t nSamples) : TObject(),
46fId(id),
47fNSamples(nSamples),
48fSamples(0x0),
49fAmplitude(0),
50fTime(0)
51{
52 //
53 fSamples = new Int_t[fNSamples];
54 for (Int_t i = 0; i < fNSamples; i++) fSamples[i] = timeSamples[i];
55}
56
57//____________________________________________________________________________
58AliEMCALRawDigit::~AliEMCALRawDigit()
59{
60 //dtor, delete array of time samples
61 if(fSamples) delete [] fSamples;
62}
63
64//____________________________________________________________________________
65void AliEMCALRawDigit::Clear(Option_t *)
66{
67 // clear, delete array of time samples
68 if(fSamples) delete [] fSamples;
69}
70
71
72//____________________________________________________________________________
73Bool_t AliEMCALRawDigit::GetTimeSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
74{
75 // returns the time and amplitude of a given time sample and if the sample was ok
76
77 if (iSample > fNSamples || iSample < 0) return kFALSE;
78
79 amp = fSamples[iSample] & 0xFFF;
80 timeBin = (fSamples[iSample] >> 12) & 0xFF;
81
82 return kTRUE;
83}
84
85//____________________________________________________________________________
86void AliEMCALRawDigit::SetTimeSamples(const Int_t timeSamples[], const Int_t nSamples)
87{
88 // Sets the time samples
89
90 if (fSamples)
91 {
92 AliDebug(1,"Samples already filled: delete first!");
93 fNSamples = 0;
94 delete [] fSamples;
95 }
96
97 fNSamples = nSamples;
98 fSamples = new Int_t[fNSamples];
99 for (Int_t i = 0; i < fNSamples; i++) fSamples[i] = timeSamples[i];
100}
101
102//____________________________________________________________________________
103Bool_t AliEMCALRawDigit::GetMaximum(Int_t& amplitude, Int_t& time) const
104{
105 // Checks the maximum amplitude in the time sample
106
107 if (!fNSamples)
108 {
109 AliDebug(1,"Digit has no time sample");
110 return kFALSE;
111 }
112
113 amplitude = 0;
114 for (Int_t i = 0; i < fNSamples; i++)
115 {
116 Int_t t, a;
117 if (GetTimeSample(i, t, a))
118 {
119 if (a > amplitude)
120 {
121 amplitude = a;
122 time = t;
123 }
124 }
125 }
126
127 return kTRUE;
128}
129
130//____________________________________________________________________________
131Int_t AliEMCALRawDigit::Compare(const TObject * obj) const
132{
133 // Compares two digits with respect to its Id
134 // to sort according increasing Id
135
136 Int_t rv=0;
137
138 AliEMCALRawDigit* digit = (AliEMCALRawDigit*)obj;
139
140 Int_t iddiff = fId - digit->GetId();
141
142 if (iddiff > 0)
143 rv = 1;
144 else if (iddiff < 0)
145 rv = -1;
146 else
147 rv = 0;
148
149 return rv;
150}
151
152//____________________________________________________________________________
153void AliEMCALRawDigit::Print(const Option_t* /*opt*/) const
154{
155 // print
156
157 printf("===\n| Digit id: %4d / %d Time Samples: \n",fId,fNSamples);
158 for (Int_t i=0; i < fNSamples; i++)
159 {
160 Int_t timeBin=-1, amp=0;
161 GetTimeSample(i, timeBin, amp);
162 printf("| (%d,%d) ",timeBin,amp);
163 }
164
165 printf("\n");
166}