Changes for report #76227: ZDC TDC info in ESD and physics selection (for release...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTriggerRawDigit.cxx
CommitLineData
de39a0ff 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 ---AliEMCALTriggerRawDigit
24#include <Riostream.h>
25#include <TMath.h>
26
27#include "AliEMCALTriggerRawDigit.h"
28#include "AliLog.h"
29
30ClassImp(AliEMCALTriggerRawDigit)
31
32//____________________________________________________________________________
33AliEMCALTriggerRawDigit::AliEMCALTriggerRawDigit() : AliEMCALRawDigit(),
34fL0Trigger(0),
35fNL0Times(0),
36fL0Times(),
37fL1TimeSum(-1)
38{
39 // default ctor
40 for (Int_t i = 0; i < 10; i++) fL0Times[i] = -1;
41}
42
43//____________________________________________________________________________
44AliEMCALTriggerRawDigit::AliEMCALTriggerRawDigit(Int_t id, Int_t timeSamples[], Int_t nSamples) : AliEMCALRawDigit(id, timeSamples, nSamples),
45fL0Trigger(0),
46fNL0Times(0),
47fL0Times(),
48fL1TimeSum(-1)
49{
50 //
51 for (Int_t i = 0; i < 10; i++) fL0Times[i] = -1;
52}
53
54//____________________________________________________________________________
55AliEMCALTriggerRawDigit::~AliEMCALTriggerRawDigit()
56{
57 //
58 //delete [] fL0Times;
59}
60
61//____________________________________________________________________________
62Bool_t AliEMCALTriggerRawDigit::SetL0Time(const Int_t i)
63{
64 //
65 for (Int_t j = 0; j < fNL0Times; j++)
66 {
67 if (i == fL0Times[j])
68 {
69 AliWarning("L0 time already there! Won't add it twice");
70 return kFALSE;
71 }
72 }
73
74 fNL0Times++;
75
76 if (fNL0Times > 9)
77 {
78 AliError("More than 10 L0 times!");
79 return kFALSE;
80 }
81
82 fL0Times[fNL0Times - 1] = i;
83
84 return kTRUE;
85}
86
87//____________________________________________________________________________
88Bool_t AliEMCALTriggerRawDigit::GetL0Time(const Int_t i, Int_t& time) const
89{
90 //
91 if (i < 0 || i > fNL0Times)
92 {
93 AliError("Bad index!");
94 return kFALSE;
95 }
96
97 time = fL0Times[i];
98
99 return kTRUE;
100}
101
102//____________________________________________________________________________
103Bool_t AliEMCALTriggerRawDigit::GetL0Times(Int_t times[]) const
104{
105 //
106 if (sizeof(times) < (sizeof(Int_t) * fNL0Times))
107 {
108 AliError("Array size too small!");
109 return kFALSE;
110 }
111
112 for (Int_t i = 0; i < fNL0Times; i++) times[i] = fL0Times[i];
113
114 return kTRUE;
115}
116
117//____________________________________________________________________________
118Int_t AliEMCALTriggerRawDigit::GetL0TimeSum(const Int_t time) const
119{
120 //
121
122 Int_t value = 0;
123
124 for (Int_t i = 0; i < fNSamples; i++)
125 {
126 Int_t timeBin, amp;
127 GetTimeSample(i, timeBin, amp);
128
129 if (timeBin >= time && timeBin < time + 4) value += amp;
130 }
131
132 return value;
133}
134
135//____________________________________________________________________________
136void AliEMCALTriggerRawDigit::Print(const Option_t* /*opt*/) const
137{
138 //
139 printf("===\n| Digit id: %4d / %d Time Samples: \n",fId,fNSamples);
140 for (Int_t i=0; i < fNSamples; i++)
141 {
142 Int_t timeBin, amp;
143 GetTimeSample(i, timeBin, amp);
144 printf("| (%d,%d) ",timeBin,amp);
145 }
146 printf("\n");
147 printf("| L0: %4d / %d Time(s): \n",fL0Trigger,fNL0Times);
148 for (Int_t i = 0; i < fNL0Times; i++)
149 {
150 Int_t time;
151 if (GetL0Time(i, time)) printf("| %d ",time);
152 }
153 printf("\n");
154 printf("| Time sum: %d\n", fL1TimeSum);
155}
156