Line data Source code
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 :
29 42 : ClassImp(AliEMCALTriggerRawDigit)
30 :
31 : //____________________________________________________________________________
32 37 : AliEMCALTriggerRawDigit::AliEMCALTriggerRawDigit() : AliEMCALRawDigit(),
33 37 : fTriggerBits(0),
34 37 : fNL0Times(0),
35 37 : fL0Times(),
36 37 : fL1TimeSum(-1),
37 37 : fL1SubRegion(-1)
38 185 : {
39 : // default ctor
40 814 : for (Int_t i = 0; i < 10; i++) fL0Times[i] = -1;
41 74 : }
42 :
43 : //____________________________________________________________________________
44 142 : AliEMCALTriggerRawDigit::AliEMCALTriggerRawDigit(Int_t id, Int_t timeSamples[], Int_t nSamples) : AliEMCALRawDigit(id, timeSamples, nSamples),
45 142 : fTriggerBits(0),
46 142 : fNL0Times(0),
47 142 : fL0Times(),
48 142 : fL1TimeSum(-1),
49 142 : fL1SubRegion(-1)
50 710 : {
51 : // Ctor
52 :
53 3124 : for (Int_t i = 0; i < 10; i++) fL0Times[i] = -1;
54 284 : }
55 :
56 : //____________________________________________________________________________
57 : AliEMCALTriggerRawDigit::~AliEMCALTriggerRawDigit()
58 716 : {
59 : // Dtor
60 :
61 : //delete [] fL0Times;
62 716 : }
63 :
64 : //____________________________________________________________________________
65 : Bool_t AliEMCALTriggerRawDigit::SetL0Time(const Int_t i)
66 : {
67 : // Set L0 times
68 :
69 251 : for (Int_t j = 0; j < fNL0Times; j++)
70 : {
71 49 : if (i == fL0Times[j])
72 : {
73 147 : AliDebug(1,Form("Digit id %d: L0 time %d already there! Won't add it twice",fId,i));
74 49 : return kFALSE;
75 : }
76 : }
77 :
78 26 : fNL0Times++;
79 :
80 26 : if (fNL0Times > 9)
81 : {
82 0 : AliError("More than 10 L0 times!");
83 0 : return kFALSE;
84 : }
85 :
86 26 : fL0Times[fNL0Times - 1] = i;
87 :
88 26 : return kTRUE;
89 75 : }
90 :
91 : //____________________________________________________________________________
92 : Bool_t AliEMCALTriggerRawDigit::GetL0Time(const Int_t i, Int_t& time) const
93 : {
94 : // Get L0 times
95 :
96 0 : if (i < 0 || i > fNL0Times)
97 : {
98 0 : AliError("Bad index!");
99 0 : return kFALSE;
100 : }
101 :
102 0 : time = fL0Times[i];
103 :
104 0 : return kTRUE;
105 0 : }
106 :
107 : //____________________________________________________________________________
108 : Bool_t AliEMCALTriggerRawDigit::GetL0Times(Int_t times[]) const
109 : {
110 : // Get L0 times
111 :
112 478 : for (Int_t i = 0; i < fNL0Times; i++) times[i] = fL0Times[i];
113 :
114 142 : return kTRUE;
115 : }
116 :
117 : //____________________________________________________________________________
118 : Int_t AliEMCALTriggerRawDigit::GetL0TimeSum(const Int_t time) const
119 : {
120 : // Get L0 time sum
121 :
122 : Int_t value = 0;
123 :
124 0 : for (Int_t i = 0; i < fNSamples; i++)
125 : {
126 0 : Int_t timeBin, amp;
127 0 : GetTimeSample(i, timeBin, amp);
128 :
129 0 : if (timeBin >= time && timeBin < time + 4) value += amp;
130 0 : }
131 :
132 0 : return value;
133 : }
134 :
135 : //____________________________________________________________________________
136 : Int_t AliEMCALTriggerRawDigit::GetTriggerBit(const TriggerType_t type, const Int_t mode) const
137 : {
138 : // Get trigger bit
139 :
140 0 : Int_t shift = kTriggerTypeEnd * mode;
141 0 : Int_t mask = 1 << type;
142 :
143 0 : return ((fTriggerBits >> shift) & mask);
144 : }
145 :
146 : //____________________________________________________________________________
147 : void AliEMCALTriggerRawDigit::Print(const Option_t* /*opt*/) const
148 : {
149 : // Dump
150 :
151 0 : printf("===\n| Digit id: %4d / %d Time Samples: \n",fId,fNSamples);
152 0 : for (Int_t i=0; i < fNSamples; i++)
153 : {
154 0 : Int_t timeBin, amp;
155 0 : GetTimeSample(i, timeBin, amp);
156 0 : printf("| (%d,%d) ",timeBin,amp);
157 0 : }
158 0 : printf("\n");
159 0 : printf("| L0: (%d,%d) / %d Time(s): \n",GetTriggerBit(kL0,1),GetTriggerBit(kL0,0),fNL0Times);
160 0 : for (Int_t i = 0; i < fNL0Times; i++)
161 : {
162 0 : Int_t time;
163 0 : if (GetL0Time(i, time)) printf("| %d ",time);
164 0 : }
165 0 : printf("\n");
166 0 : printf("| L1: g high (%d,%d) g low (%d,%d) j high (%d,%d) j low (%d,%d) / Time sum: %d\n",
167 0 : GetTriggerBit(kL1GammaHigh,1),GetTriggerBit(kL1GammaHigh,0),GetTriggerBit(kL1GammaLow,1),GetTriggerBit(kL1GammaLow,0),
168 0 : GetTriggerBit(kL1JetHigh,1), GetTriggerBit(kL1JetHigh,0), GetTriggerBit(kL1JetLow,1), GetTriggerBit(kL1JetLow,0),
169 0 : fL1TimeSum);
170 0 : }
171 :
|