]>
Commit | Line | Data |
---|---|---|
cbab66dd | 1 | /************************************************************************** |
99388135 | 2 | * This file is property of and copyright by the Experimental Nuclear * |
3 | * Physics Group, Dep. of Physics * | |
4 | * University of Oslo, Norway, 2007 * | |
5 | * * | |
6 | * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.* | |
cbab66dd | 7 | * Contributors are mentioned in the code where appropriate. * |
99388135 | 8 | * Please report bugs to perthi@fys.uio.no * |
cbab66dd | 9 | * * |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | #include "AliHLTPHOSRawAnalyzerComponent.h" | |
20 | #include <iostream> | |
9dfd64cf | 21 | #include "stdio.h" |
0a211711 | 22 | |
9dfd64cf | 23 | #include "AliRawReaderMemory.h" |
0a211711 | 24 | #include "AliCaloRawStream.h" |
2947a32c | 25 | #include <cstdlib> |
bde48b84 | 26 | #include "AliHLTPHOSRcuCellEnergyDataStruct.h" |
0a211711 | 27 | |
cbab66dd | 28 | |
ee7849e6 | 29 | const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array |
2bcb5a06 | 30 | int AliHLTPHOSRawAnalyzerComponent::fEventCount = 0; |
ee7849e6 | 31 | |
68d9caee | 32 | AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), fEquippmentID(0), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(), fRawMemoryReader(0), outPtr(0) |
cbab66dd | 33 | { |
cf434398 | 34 | |
cbab66dd | 35 | } |
36 | ||
37 | AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent() | |
38 | { | |
0a211711 | 39 | if(fRawMemoryReader != 0) |
40 | { | |
41 | delete fRawMemoryReader; | |
42 | } | |
43 | if(fPHOSRawStream != 0) | |
44 | { | |
45 | delete fPHOSRawStream; | |
46 | } | |
47 | ||
cbab66dd | 48 | } |
49 | ||
50 | ||
0a211711 | 51 | |
68d9caee | 52 | AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), fEquippmentID(0), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(), fRawMemoryReader(0), outPtr(0) |
cbab66dd | 53 | { |
cbab66dd | 54 | } |
55 | ||
9dfd64cf | 56 | |
cbab66dd | 57 | int |
58 | AliHLTPHOSRawAnalyzerComponent::Deinit() | |
59 | { | |
60 | return 0; | |
61 | } | |
62 | ||
63 | int | |
64 | AliHLTPHOSRawAnalyzerComponent::DoDeinit() | |
65 | { | |
9dfd64cf | 66 | Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit"); |
67 | ||
0a211711 | 68 | if(fRawMemoryReader !=0) |
69 | { | |
70 | delete fRawMemoryReader; | |
71 | } | |
72 | ||
73 | if(fPHOSRawStream != 0) | |
74 | { | |
75 | delete fPHOSRawStream; | |
76 | } | |
cbab66dd | 77 | return 0; |
cbab66dd | 78 | |
cbab66dd | 79 | } |
80 | ||
9dfd64cf | 81 | const char* |
82 | AliHLTPHOSRawAnalyzerComponent::GetComponentID() | |
83 | { | |
84 | return "AliPhosTestRaw"; | |
85 | } | |
ee7849e6 | 86 | |
cbab66dd | 87 | void |
ee7849e6 | 88 | AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
cbab66dd | 89 | { |
ee7849e6 | 90 | const AliHLTComponentDataType* pType=inputDataTypes; |
91 | while (pType->fID!=0) { | |
92 | list.push_back(*pType); | |
93 | pType++; | |
94 | } | |
cbab66dd | 95 | } |
96 | ||
97 | AliHLTComponentDataType | |
98 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataType() | |
99 | { | |
53740333 | 100 | return AliHLTPHOSDefinitions::gkCellEnergyDataType; |
cbab66dd | 101 | } |
102 | ||
103 | void | |
9dfd64cf | 104 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) |
105 | ||
cbab66dd | 106 | { |
ef408bb3 | 107 | constBase = 30; |
108 | inputMultiplier = 0.1; | |
cbab66dd | 109 | } |
110 | ||
0a211711 | 111 | |
112 | int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, | |
113 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, | |
114 | AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) | |
cbab66dd | 115 | { |
bde48b84 | 116 | Int_t tmpMod = 0; |
117 | Int_t tmpRow = 0; | |
118 | Int_t tmpCol = 0; | |
119 | Int_t tmpGain = 0; | |
120 | Int_t sampleCnt = 0; | |
2947a32c | 121 | Int_t processedChannels = 0; |
bde48b84 | 122 | UInt_t offset = 0; |
123 | UInt_t mysize = 0; | |
124 | UInt_t tSize = 0; | |
2bcb5a06 | 125 | Int_t tmpChannelCnt = 0; |
126 | ||
127 | ||
68d9caee | 128 | // cout << "analyzing event: " << fEventCount << endl; |
53740333 | 129 | AliHLTUInt8_t* outBPtr; |
53740333 | 130 | outBPtr = outputPtr; |
0a211711 | 131 | const AliHLTComponentBlockData* iter = NULL; |
132 | unsigned long ndx; | |
cf434398 | 133 | |
68d9caee | 134 | if((fEventCount % 100) == 0) |
135 | { | |
136 | cout << "analyzing event: " << fEventCount << endl; | |
137 | } | |
138 | // Reset(); | |
2947a32c | 139 | |
0a211711 | 140 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
141 | { | |
0a211711 | 142 | iter = blocks+ndx; |
53740333 | 143 | mysize = 0; |
144 | offset = tSize; | |
145 | ||
0a211711 | 146 | if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType ) |
147 | { | |
148 | cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl; | |
149 | continue; | |
150 | } | |
ef408bb3 | 151 | |
bde48b84 | 152 | fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize ); |
153 | analyzerPtr->SetData(fTmpChannelData); | |
154 | outPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr; | |
155 | mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct); | |
156 | outPtr->fRcuX = fRcuX; | |
157 | outPtr->fRcuZ = fRcuZ; | |
158 | outPtr->fModuleID = fModuleID; | |
2bcb5a06 | 159 | tmpChannelCnt = 0; |
2bcb5a06 | 160 | |
2947a32c | 161 | while(fPHOSRawStream->Next()) |
162 | { | |
163 | if (fPHOSRawStream->IsNewHWAddress()) | |
164 | { | |
68d9caee | 165 | // cout << "samplCount =" << sampleCnt <<endl; |
166 | // sampleCnt = 0; | |
167 | ||
168 | ||
2947a32c | 169 | if(processedChannels > 0) |
170 | { | |
171 | analyzerPtr->SetData(fTmpChannelData); | |
bde48b84 | 172 | |
68d9caee | 173 | // DumpChannelData(fTmpChannelData); |
174 | ||
175 | analyzerPtr->Evaluate(0, sampleCnt); | |
2bcb5a06 | 176 | outPtr->fCellEnergies[tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy(); |
2bcb5a06 | 177 | |
68d9caee | 178 | |
179 | sampleCnt = 0; | |
2bcb5a06 | 180 | outPtr->fValidData[tmpChannelCnt].fGain = tmpGain; |
181 | outPtr->fValidData[tmpChannelCnt].fRow = tmpRow; | |
182 | outPtr->fValidData[tmpChannelCnt].fCol = tmpCol; | |
2bcb5a06 | 183 | tmpChannelCnt ++; |
68d9caee | 184 | ResetDataPtr(); |
185 | sampleCnt = 0; | |
bde48b84 | 186 | |
2947a32c | 187 | } |
188 | ||
2bcb5a06 | 189 | tmpMod = fPHOSRawStream->GetModule() ; |
190 | tmpRow = fPHOSRawStream->GetRow() - fRcuRowOffeset; | |
191 | tmpCol = fPHOSRawStream->GetColumn() - fRcuColOffeset; | |
2947a32c | 192 | tmpGain = fPHOSRawStream->IsLowGain(); |
193 | processedChannels ++; | |
194 | } | |
2947a32c | 195 | fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal(); |
bde48b84 | 196 | sampleCnt ++; |
68d9caee | 197 | |
2947a32c | 198 | } |
68d9caee | 199 | |
200 | ||
201 | ||
2bcb5a06 | 202 | outPtr->fCnt = tmpChannelCnt; |
53740333 | 203 | AliHLTComponentBlockData bd; |
204 | FillBlockData( bd ); | |
53740333 | 205 | bd.fOffset = offset; |
206 | bd.fSize = mysize; | |
53740333 | 207 | bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType; |
9ce19a20 | 208 | bd.fSpecification = 0xFFFFFFFF; |
53740333 | 209 | outputBlocks.push_back( bd ); |
53740333 | 210 | tSize += mysize; |
211 | outBPtr += mysize; | |
212 | ||
cf434398 | 213 | if( tSize > size ) |
53740333 | 214 | { |
215 | Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data", | |
216 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu." | |
217 | , tSize, size ); | |
218 | return EMSGSIZE; | |
219 | } | |
68d9caee | 220 | |
221 | // DumpData(); | |
222 | ||
cf434398 | 223 | |
2947a32c | 224 | } |
53740333 | 225 | |
2947a32c | 226 | fEventCount++; |
53740333 | 227 | size = tSize; |
2947a32c | 228 | return 0; |
229 | }//end DoEvent | |
0a211711 | 230 | |
231 | ||
232 | ||
233 | int | |
234 | AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) | |
235 | { | |
53740333 | 236 | int equippmentID = atoi(argv[6]); |
2947a32c | 237 | Reset(); |
0a211711 | 238 | fRawMemoryReader = new AliRawReaderMemory(); |
239 | fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS"); | |
53740333 | 240 | fRawMemoryReader->SetEquipmentID(equippmentID); |
53740333 | 241 | SetEquippmentID(equippmentID); |
242 | SetCoordinates(equippmentID); | |
0a211711 | 243 | if (argc==0 && argv==NULL) { |
244 | // this is currently just to get rid of the warning "unused parameter" | |
245 | } | |
246 | return 0; | |
247 | } | |
9dfd64cf | 248 | |
2947a32c | 249 | void |
250 | AliHLTPHOSRawAnalyzerComponent::DumpData() | |
0a211711 | 251 | { |
2947a32c | 252 | for(int mod = 0; mod <5; mod ++) |
253 | { | |
254 | printf("\n *********** MODULE %d ************\n", mod); | |
255 | for(int row = 0; row < 64; row ++) | |
256 | { | |
257 | for(int col = 0; col < 56; col ++) | |
258 | { | |
259 | if( fMaxValues[mod][row][col][0] != 0) | |
260 | { | |
261 | cout << fMaxValues[mod][row][col][0] << "\t"; | |
262 | } | |
263 | } | |
264 | } | |
265 | } | |
266 | } | |
9dfd64cf | 267 | |
68d9caee | 268 | void |
269 | AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data) | |
270 | { | |
271 | cout << endl; | |
272 | ||
273 | for(int i=0; i< 1008; i++) | |
274 | { | |
275 | if (data[i] != 0) | |
276 | { | |
277 | cout <<i <<"\t"; | |
278 | } | |
279 | } | |
280 | cout << endl; | |
281 | ||
282 | for(int i=0; i< 1008; i++) | |
283 | { | |
284 | if (data[i] != 0) | |
285 | { | |
286 | cout <<data[i] <<"\t"; | |
287 | } | |
288 | } | |
289 | ||
290 | cout << endl; | |
291 | } | |
292 | ||
293 | ||
0a211711 | 294 | |
2947a32c | 295 | void |
296 | AliHLTPHOSRawAnalyzerComponent::Reset() | |
297 | { | |
298 | for(int mod = 0; mod <5; mod ++) | |
9dfd64cf | 299 | { |
2947a32c | 300 | for(int row = 0; row < 64; row ++) |
301 | { | |
302 | for(int col = 0; col < 56; col ++) | |
303 | { | |
304 | for(int gain = 0; gain <2; gain ++ ) | |
305 | { | |
306 | fMaxValues[mod][row][col][gain] = 0; | |
307 | } | |
308 | } | |
309 | } | |
310 | } | |
9dfd64cf | 311 | |
2947a32c | 312 | for(int i = 0 ; i< 1008; i++) |
313 | { | |
314 | fTmpChannelData[i] = 0; | |
0a211711 | 315 | } |
2947a32c | 316 | } // end Reset |
9dfd64cf | 317 | |
2947a32c | 318 | void |
319 | AliHLTPHOSRawAnalyzerComponent::ResetDataPtr() | |
320 | { | |
321 | for(int i = 0 ; i< 1008; i++) | |
322 | { | |
323 | fTmpChannelData[i] = 0; | |
324 | } | |
cbab66dd | 325 | } |
ef408bb3 | 326 | |
327 | ||
328 | void | |
53740333 | 329 | AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id) |
ef408bb3 | 330 | { |
53740333 | 331 | fEquippmentID = id; |
ef408bb3 | 332 | } |
333 | ||
334 | int | |
53740333 | 335 | AliHLTPHOSRawAnalyzerComponent::GetEquippmentID() |
336 | { | |
337 | return fEquippmentID; | |
338 | } | |
339 | ||
53740333 | 340 | void |
341 | AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID) | |
ef408bb3 | 342 | { |
53740333 | 343 | int rcuIndex = (fEquippmentID - 1792)%4; |
cf434398 | 344 | fModuleID = (fEquippmentID -1792 -rcuIndex)/5; |
53740333 | 345 | |
346 | if(rcuIndex == 0) | |
347 | { | |
348 | fRcuX = 0; | |
cf434398 | 349 | fRcuZ = 0; |
53740333 | 350 | } |
351 | ||
352 | if(rcuIndex == 1) | |
353 | { | |
cf434398 | 354 | fRcuX = 0; |
355 | fRcuZ = 1; | |
53740333 | 356 | } |
357 | ||
358 | if(rcuIndex == 2) | |
359 | { | |
cf434398 | 360 | fRcuX = 1; |
361 | fRcuZ = 0; | |
53740333 | 362 | } |
363 | ||
364 | ||
cf434398 | 365 | if(rcuIndex == 3) |
53740333 | 366 | { |
367 | fRcuX = 1; | |
cf434398 | 368 | fRcuZ = 1; |
53740333 | 369 | } |
370 | ||
cf434398 | 371 | fRcuRowOffeset = 32*fRcuX; |
372 | fRcuColOffeset = 28*fRcuZ; | |
373 | ||
ef408bb3 | 374 | } |