New Trigger Emulation and Trigger access from data (Rachid Guernane)
[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{
67 // Delete array of time samples
68 delete [] fSamples;
69}
70
71//____________________________________________________________________________
72Bool_t AliEMCALRawDigit::GetTimeSample(const Int_t iSample, Int_t& timeBin, Int_t& amp) const
73{
74 if (iSample > fNSamples || iSample < 0) return kFALSE;
75
76 amp = fSamples[iSample] & 0xFFF;
77 timeBin = (fSamples[iSample] >> 12) & 0xFF;
78
79 return kTRUE;
80}
81
82//____________________________________________________________________________
83void AliEMCALRawDigit::Print(const Option_t* /*opt*/) const
84{
85 printf("===\nDigit id: %4d / %d Time Samples: \n",fId,fNSamples);
86 for (Int_t i=0; i < fNSamples; i++)
87 {
88 Int_t timeBin, amp;
89 GetTimeSample(i, timeBin, amp);
90 printf("(%d,%d) ",timeBin,amp);
91 }
92
93 printf("\n");
94}
95
96//____________________________________________________________________________
97Int_t AliEMCALRawDigit::Compare(const TObject* obj) const
98{
99 // Compares two digits with respect to its Id
100 // to sort according increasing Id
101
102 Int_t rv;
103
104 AliEMCALRawDigit* digit = (AliEMCALRawDigit *)obj;
105
106 Int_t iddiff = fId - digit->GetId();
107
108 if ( iddiff > 0 )
109 rv = 1;
110 else if ( iddiff < 0 )
111 rv = -1;
112 else
113 rv = 0;
114
115 return rv;
116}
117
118//____________________________________________________________________________
119Bool_t AliEMCALRawDigit::operator==(AliEMCALRawDigit const & digit) const
120{
121 // Two digits are equal if they have the same Id
122
123 if(fId == digit.fId)
124 return kTRUE;
125 else
126 return kFALSE;
127}