]>
Commit | Line | Data |
---|---|---|
31a920d3 | 1 | /************************************************************************** |
2 | * This file is property of and copyright by the ALICE HLT Project * | |
3 | * All rights reserved. * | |
4 | * * | |
5 | * Primary Author: Per Thomas Hille <perthi@fys.uio.no> * | |
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 | #include "AliAltroData.h" | |
17 | #include "AliAltroBunch.h" | |
18 | ||
19 | ClassImp(AliAltroData) | |
20 | ||
21 | AliAltroData::AliAltroData(): fData(0), | |
44443c72 | 22 | fBunchData(0), |
23 | fDataSize(0), | |
24 | fWc(0), | |
25 | fHadd(-1), | |
26 | fPrevHadd(-1), | |
27 | fBunchCounter(0), | |
28 | fIsComplete(0), | |
29 | fBufferLeft(0) | |
31a920d3 | 30 | { |
31 | ||
32 | ||
33 | } | |
34 | ||
35 | ||
36 | ||
37 | AliAltroData::~AliAltroData() | |
38 | { | |
39 | ||
40 | ||
41 | } | |
42 | ||
43 | ||
ac672c4c | 44 | /* |
45 | bool | |
46 | //AliHLTAltroData::NextBunch(AliHLTAltroBunch *altroBunch) | |
47 | AliAltroData::NextBunch(AliAltroBunch *altroBunch) | |
48 | { | |
49 | //comment | |
50 | if(fIsComplete == true) | |
51 | { | |
52 | ||
53 | if(fBunchCounter == 0) | |
54 | { | |
55 | fBunchData = &fData[fDataSize - 1]; | |
56 | altroBunch->fData = &fData[fDataSize - 1]; | |
57 | ||
58 | } | |
59 | ||
60 | if(fWc < fDataSize) | |
61 | { | |
62 | fWc += *fBunchData; | |
63 | altroBunch->fBunchSize = *fBunchData; | |
64 | altroBunch->fBunchDataSize = altroBunch->fBunchSize -2; | |
65 | ||
66 | fBunchData --; | |
67 | altroBunch->fEndTimeBin = *fBunchData; | |
68 | fBunchData ++; | |
69 | ||
70 | fBunchData = fBunchData - (altroBunch->fBunchSize); | |
71 | altroBunch->fData = altroBunch->fData - (altroBunch->fBunchSize); | |
72 | fBunchCounter ++; | |
73 | return true; | |
74 | ||
75 | } | |
76 | else | |
77 | { | |
78 | fBunchCounter = 0; | |
79 | fWc = 0; | |
80 | return false; | |
81 | } | |
82 | } | |
83 | else | |
84 | { | |
85 | printf("\nAliHLTAltroData::NextBunch: WARNING, dataset is not complet. 2AAA endmarker is missing "); | |
86 | printf("\nfor branch %d, card %d, chip %d, channel %d\n", GetBranch(), GetCard(), GetChip(), GetChannel()); | |
87 | return false; | |
88 | } | |
89 | } | |
90 | ||
91 | */ | |
92 | ||
93 | ||
94 | ||
95 | ||
44443c72 | 96 | //Bool_t AliAltroData::NextBunch(AliAltroBunch *altroBunch) |
97 | int AliAltroData::NextBunch(AliAltroBunch *altroBunch) | |
31a920d3 | 98 | { |
ac672c4c | 99 | |
31a920d3 | 100 | if(fIsComplete == kTRUE) |
101 | { | |
31a920d3 | 102 | if(fBunchCounter == 0) |
103 | { | |
104 | fBunchData = &fData[fDataSize - 1]; | |
105 | } | |
106 | ||
107 | if(fWc < fDataSize) | |
108 | { | |
109 | if(*fBunchData == 0){ fWc += 1;}; | |
110 | fWc += *fBunchData; | |
1f8ca0bc | 111 | altroBunch->SetData(fData + fDataSize - fWc); |
44443c72 | 112 | |
113 | int tmpsize = *fBunchData -2; | |
114 | ||
115 | // altroBunch->SetBunchSize( *fBunchData -2 ); | |
116 | altroBunch->SetBunchSize( tmpsize ); | |
117 | ||
118 | ||
119 | fBufferLeft -= *fBunchData; | |
120 | // printf("%s:%d, bufferleft = %d \n", __FILE__, __LINE__ , fBufferLeft); | |
31a920d3 | 121 | fBunchData --; |
122 | altroBunch->SetEndTimeBin( *fBunchData ); | |
44443c72 | 123 | |
124 | // if( (fBufferLeft <= 7 ) || ( fBufferLeft - tmpsize) <= 7) | |
125 | if( fBufferLeft - tmpsize <= 7) | |
126 | { | |
127 | // printf("%s:%d, ERROR, attempt too access buffer outside allowed range\n", __FILE__ , __LINE__ ); | |
128 | return kFALSE; | |
129 | } | |
130 | ||
131 | ||
132 | if(fBunchCounter >0) | |
133 | { | |
134 | int tmpret = altroBunch->CheckConsistency(); | |
135 | ||
136 | if(tmpret != kTRUE) | |
137 | { | |
138 | return tmpret; | |
139 | } | |
140 | ||
141 | /* | |
142 | if( altroBunch->CheckConsistency() == kFALSE) | |
143 | { | |
144 | return kFALSE; | |
145 | } | |
146 | */ | |
147 | } | |
148 | ||
1f8ca0bc | 149 | // altroBunch->SetStartTimeBin(*fBunchData - fBunchSize); |
31a920d3 | 150 | fBunchData -= (altroBunch->GetBunchSize() +1); |
84111923 | 151 | |
152 | // PATCH from Per Thomas Hille 250408 mke sure tha | |
153 | // Data is consistent by cheking the start timebin, should never be negative | |
154 | if( (int)altroBunch->GetStartTimeBin( ) < 0) | |
155 | { | |
156 | // printf("ERROR altroBunch->GetStartTimeBin( ) is %d", (int)altroBunch->GetStartTimeBin( ) ); | |
157 | return kFALSE; | |
158 | } | |
159 | ||
31a920d3 | 160 | fBunchCounter ++; |
161 | return kTRUE; | |
162 | } | |
163 | else | |
164 | { | |
165 | fBunchCounter = 0; | |
166 | fWc = 0; | |
167 | return kFALSE; | |
168 | } | |
169 | } | |
170 | else | |
171 | { | |
84111923 | 172 | // printf("\nAliAltroData::NextBunch: WARNING, dataset is not complet. 2AAA endmarker is missing "); |
44443c72 | 173 | // printf("\nfor branch %d, card %d, chip %d, channel %d\n", GetBranch(), GetCard(), GetChip(), GetChannel()); |
31a920d3 | 174 | return kFALSE; |
175 | } | |
176 | ||
177 | } | |
178 | ||
ac672c4c | 179 | |
180 | ||
31a920d3 | 181 | void AliAltroData::Reset() |
182 | { | |
183 | fWc = 0; | |
184 | fBunchCounter = 0; | |
185 | } | |
186 | ||
187 | ||
188 | Int_t AliAltroData::GetChannel() const | |
189 | { | |
190 | return fHadd & 0xf; | |
191 | } | |
192 | ||
193 | Int_t AliAltroData::GetChip() const | |
194 | { | |
195 | return (fHadd & 0x70) >> 4 ; | |
196 | } | |
197 | ||
198 | Int_t AliAltroData::GetCard() const | |
199 | { | |
200 | return (fHadd & 0x780) >> 7; | |
201 | } | |
202 | ||
203 | ||
204 | Int_t AliAltroData::GetBranch() const | |
205 | { | |
206 | return (fHadd & 0x800 ) >> 11; | |
207 | } |