]>
Commit | Line | Data |
---|---|---|
178dd351 | 1 | |
2 | /************************************************************************** | |
3 | * This file is property of and copyright by the ALICE HLT Project * | |
4 | * All rights reserved. * | |
5 | * * | |
6 | * Primary Authors: Per Thomas Hille, Oystein Djuvsland * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
72a884c8 | 17 | //#include "AliHLTCaloRawAnalyzer.h" |
18 | #include "AliCaloRawAnalyzer.h" | |
19 | #include "AliCaloBunchInfo.h" | |
20 | #include "AliCaloFitResults.h" | |
21 | ||
178dd351 | 22 | #include "AliHLTCaloRawAnalyzerComponentv3.h" |
23 | #include "AliHLTCaloChannelDataHeaderStruct.h" | |
24 | #include "AliHLTCaloChannelDataStruct.h" | |
25 | #include "AliHLTCaloMapper.h" | |
26 | #include "AliHLTCaloSanityInspector.h" | |
27 | #include "AliAltroRawStreamV3.h" | |
28 | #include "AliRawReaderMemory.h" | |
29 | #include "AliAltroRawStreamV3.h" | |
30 | #include "AliCaloRawStreamV3.h" | |
4f4b7ba4 | 31 | #include "AliHLTCaloConstantsHandler.h" |
77f350f7 | 32 | #include "AliHLTCaloConstants.h" |
c375e15d | 33 | #include "AliHLTCaloRcuProcessor.h" |
178dd351 | 34 | |
72a884c8 | 35 | |
36 | //#include "AliCALOBunchInfo.h" | |
37 | //AliCALORawAnalyzer | |
38 | ||
39 | #include <vector> | |
40 | using namespace std; | |
41 | ||
4f4b7ba4 | 42 | ClassImp(AliHLTCaloRawAnalyzerComponentv3); |
43 | ||
77f350f7 | 44 | AliHLTCaloRawAnalyzerComponentv3::AliHLTCaloRawAnalyzerComponentv3(TString det): |
4f4b7ba4 | 45 | AliHLTCaloConstantsHandler(det), |
c375e15d | 46 | AliHLTCaloRcuProcessor(), |
5fc8dce6 | 47 | // fCaloEventCount(0), |
3800a654 | 48 | fAnalyzerPtr(0), |
49 | fMapperPtr(0), | |
c375e15d | 50 | fkDoPushRawData(false), |
178dd351 | 51 | fSanityInspectorPtr(0), |
52 | fRawReaderMemoryPtr(0), | |
53 | fAltroRawStreamPtr(0), | |
3800a654 | 54 | fAlgorithm(0), |
178dd351 | 55 | fOffset(0), |
56 | fBunchSizeCut(0), | |
57 | fMinPeakPosition(0), | |
58 | fMaxPeakPosition(100), | |
3800a654 | 59 | fRawDataWriter(0) |
178dd351 | 60 | { |
61 | //comment | |
62 | ||
63 | // fMapperPtr = new AliHLTCaloMapper(); | |
4f4b7ba4 | 64 | |
178dd351 | 65 | fRawReaderMemoryPtr = new AliRawReaderMemory(); |
4f4b7ba4 | 66 | |
178dd351 | 67 | fAltroRawStreamPtr = new AliAltroRawStreamV3(fRawReaderMemoryPtr); |
4f4b7ba4 | 68 | |
178dd351 | 69 | fSanityInspectorPtr = new AliHLTCaloSanityInspector(); |
c375e15d | 70 | |
71 | if( fkDoPushRawData == true ) | |
72 | { | |
73 | fRawDataWriter = new RawDataWriter(fCaloConstants); | |
74 | } | |
75 | ||
76 | fAltroRawStreamPtr = new AliCaloRawStreamV3(fRawReaderMemoryPtr, det); | |
4b09a7ed | 77 | |
178dd351 | 78 | } |
79 | ||
80 | ||
81 | AliHLTCaloRawAnalyzerComponentv3::~AliHLTCaloRawAnalyzerComponentv3() | |
82 | { | |
83 | //comment | |
c375e15d | 84 | DoDeinit(); |
85 | } | |
86 | ||
87 | ||
88 | ||
89 | int | |
90 | AliHLTCaloRawAnalyzerComponentv3::DoInit( int argc, const char** argv ) | |
91 | { | |
92 | ||
93 | //See base class for documentation | |
94 | // fPrintInfo = kFALSE; | |
95 | ||
96 | int iResult=0; | |
97 | ||
98 | // fMapperPtr = new AliHLTCaloMapper(); | |
99 | ||
100 | //InitMapping(); | |
101 | ||
102 | for(int i = 0; i < argc; i++) | |
103 | { | |
104 | if(!strcmp("-offset", argv[i])) | |
105 | { | |
106 | fOffset = atoi(argv[i+1]); | |
107 | } | |
108 | if(!strcmp("-bunchsizecut", argv[i])) | |
109 | { | |
110 | fBunchSizeCut = atoi(argv[i+1]); | |
111 | } | |
112 | if(!strcmp("-minpeakposition", argv[i])) | |
113 | { | |
114 | fMinPeakPosition = atoi(argv[i+1]); | |
115 | } | |
116 | if(!strcmp("-maxpeakposition", argv[i])) | |
117 | { | |
118 | fMaxPeakPosition = atoi(argv[i+1]); | |
119 | } | |
120 | } | |
121 | ||
122 | /* | |
123 | if( fMapperPtr->GetIsInitializedMapping() == false) | |
124 | { | |
125 | Logging(kHLTLogFatal, __FILE__ , IntToChar( __LINE__ ) , "AliHLTCaloMapper::Could not initialise mapping from file %s, aborting", fMapperPtr->GetFilePath()); | |
126 | return -4; | |
127 | } | |
128 | */ | |
c375e15d | 129 | return iResult; |
178dd351 | 130 | } |
131 | ||
132 | ||
178dd351 | 133 | int |
c375e15d | 134 | AliHLTCaloRawAnalyzerComponentv3::DoDeinit() |
178dd351 | 135 | { |
136 | //comment | |
c375e15d | 137 | |
178dd351 | 138 | if(fAnalyzerPtr) |
139 | { | |
140 | delete fAnalyzerPtr; | |
141 | fAnalyzerPtr = 0; | |
142 | } | |
c375e15d | 143 | |
178dd351 | 144 | if(fMapperPtr) |
145 | { | |
146 | delete fMapperPtr; | |
147 | fMapperPtr = 0; | |
148 | } | |
c375e15d | 149 | |
178dd351 | 150 | if(fRawReaderMemoryPtr) |
151 | { | |
152 | delete fRawReaderMemoryPtr; | |
153 | fRawReaderMemoryPtr = 0; | |
154 | } | |
c375e15d | 155 | |
178dd351 | 156 | if(fAltroRawStreamPtr) |
157 | { | |
158 | delete fAltroRawStreamPtr; | |
159 | fAltroRawStreamPtr = 0; | |
160 | } | |
c375e15d | 161 | |
178dd351 | 162 | return 0; |
163 | } | |
164 | ||
c375e15d | 165 | |
72a884c8 | 166 | /* |
178dd351 | 167 | const char* |
168 | AliHLTCaloRawAnalyzerComponentv3::GetComponentID() | |
169 | { | |
170 | //comment | |
171 | return "CaloRawAnalyzerv3"; | |
172 | } | |
72a884c8 | 173 | */ |
178dd351 | 174 | |
175 | ||
c375e15d | 176 | |
72a884c8 | 177 | /* |
178dd351 | 178 | void |
179 | AliHLTCaloRawAnalyzerComponentv3::GetInputDataTypes( vector<AliHLTComponentDataType>& list) | |
180 | { | |
181 | //comment | |
182 | list.clear(); | |
183 | list.push_back( AliHLTCaloDefinitions::fgkDDLPackedRawDataType | kAliHLTDataOriginPHOS); | |
184 | } | |
72a884c8 | 185 | */ |
186 | ||
178dd351 | 187 | |
72a884c8 | 188 | /* |
c375e15d | 189 | AliHLTComponentDataType |
178dd351 | 190 | AliHLTCaloRawAnalyzerComponentv3::GetOutputDataType() |
191 | { | |
192 | //comment | |
193 | return AliHLTCaloDefinitions::fgkChannelDataType; | |
194 | } | |
72a884c8 | 195 | */ |
178dd351 | 196 | |
c375e15d | 197 | |
72a884c8 | 198 | /* |
178dd351 | 199 | void |
200 | AliHLTCaloRawAnalyzerComponentv3::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) | |
201 | { | |
202 | //comment | |
203 | constBase = sizeof(AliHLTCaloChannelDataHeaderStruct); | |
204 | inputMultiplier = 0.5; | |
205 | } | |
72a884c8 | 206 | */ |
4b09a7ed | 207 | |
178dd351 | 208 | |
209 | ||
210 | Int_t | |
211 | AliHLTCaloRawAnalyzerComponentv3::DoIt(const AliHLTComponentBlockData* iter, AliHLTUInt8_t* outputPtr, const AliHLTUInt32_t size, UInt_t& totSize) | |
212 | { | |
4b09a7ed | 213 | |
178dd351 | 214 | int tmpsize= 0; |
215 | Int_t crazyness = 0; | |
216 | Int_t nSamples = 0; | |
217 | Short_t channelCount = 0; | |
218 | ||
178dd351 | 219 | AliHLTCaloChannelDataHeaderStruct *channelDataHeaderPtr = reinterpret_cast<AliHLTCaloChannelDataHeaderStruct*>(outputPtr); |
220 | AliHLTCaloChannelDataStruct *channelDataPtr = reinterpret_cast<AliHLTCaloChannelDataStruct*>(outputPtr+sizeof(AliHLTCaloChannelDataHeaderStruct)); | |
4b09a7ed | 221 | |
222 | ||
223 | ||
224 | ||
178dd351 | 225 | totSize += sizeof( AliHLTCaloChannelDataHeaderStruct ); |
226 | fRawReaderMemoryPtr->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), static_cast<ULong_t>( iter->fSize ) ); | |
3800a654 | 227 | fRawReaderMemoryPtr->SetEquipmentID( fMapperPtr->GetDDLFromSpec( iter->fSpecification) + 4608 ); |
178dd351 | 228 | fRawReaderMemoryPtr->Reset(); |
229 | fRawReaderMemoryPtr->NextEvent(); | |
4b09a7ed | 230 | |
178dd351 | 231 | if( fkDoPushRawData == true) |
232 | { | |
233 | fRawDataWriter->NewEvent( ); | |
234 | } | |
4b09a7ed | 235 | |
236 | ||
237 | /* | |
178dd351 | 238 | if(fAltroRawStreamPtr != NULL) |
239 | { | |
240 | delete fAltroRawStreamPtr; | |
241 | fAltroRawStreamPtr=NULL; | |
242 | } | |
4b09a7ed | 243 | */ |
244 | ||
245 | ||
246 | //return 1; | |
247 | ||
178dd351 | 248 | |
4b09a7ed | 249 | // fAltroRawStreamPtr = new AliCaloRawStreamV3(fRawReaderMemoryPtr, TString("EMCAL")); |
250 | ||
178dd351 | 251 | |
4b09a7ed | 252 | // return 1; |
178dd351 | 253 | |
c89876f4 | 254 | if(fAltroRawStreamPtr->NextDDL()) |
178dd351 | 255 | { |
256 | int cnt = 0; | |
257 | while( fAltroRawStreamPtr->NextChannel() ) | |
258 | { | |
3800a654 | 259 | // cout << __FILE__ << ":" << __LINE__ << ":" <<__FUNCTION__ << "T3" << endl; |
178dd351 | 260 | if( fAltroRawStreamPtr->GetHWAddress() < 128 || ( fAltroRawStreamPtr->GetHWAddress() ^ 0x800) < 128 ) |
261 | { | |
262 | continue; | |
263 | } | |
264 | else | |
265 | { | |
8b848697 | 266 | ++ cnt; |
267 | UShort_t* firstBunchPtr = 0; | |
b850c417 | 268 | int chId = fMapperPtr->GetChannelID(iter->fSpecification, fAltroRawStreamPtr->GetHWAddress()); |
178dd351 | 269 | if( fkDoPushRawData == true) |
270 | { | |
271 | fRawDataWriter->SetChannelId( chId ); | |
272 | } | |
4b09a7ed | 273 | |
274 | // return 1; | |
72a884c8 | 275 | vector <AliCaloBunchInfo> bvctr; |
178dd351 | 276 | while( fAltroRawStreamPtr->NextBunch() == true ) |
277 | { | |
72a884c8 | 278 | bvctr.push_back( AliCaloBunchInfo( fAltroRawStreamPtr->GetStartTimeBin(), fAltroRawStreamPtr->GetBunchLength(), fAltroRawStreamPtr->GetSignals() ) ); |
279 | ||
178dd351 | 280 | nSamples = fAltroRawStreamPtr->GetBunchLength(); |
178dd351 | 281 | if( fkDoPushRawData == true) |
282 | { | |
178dd351 | 283 | fRawDataWriter->WriteBunchData( fAltroRawStreamPtr->GetSignals(), nSamples, fAltroRawStreamPtr->GetEndTimeBin() ); |
284 | } | |
285 | firstBunchPtr = const_cast< UShort_t* >( fAltroRawStreamPtr->GetSignals() ); | |
286 | } | |
4b09a7ed | 287 | |
288 | //return 1; | |
289 | ||
290 | totSize += sizeof( AliHLTCaloChannelDataStruct ); | |
178dd351 | 291 | if(totSize > size) |
292 | { | |
c375e15d | 293 | //HLTError("Buffer overflow: Trying to write data of size: %d bytes. Output buffer available: %d bytes.", totSize, size); |
178dd351 | 294 | return -1; |
295 | } | |
296 | ||
72a884c8 | 297 | // fAnalyzerPtr->SetData( firstBunchPtr, nSamples); |
298 | AliCaloFitResults res = fAnalyzerPtr->Evaluate( bvctr, fAltroRawStreamPtr->GetAltroCFG1(), fAltroRawStreamPtr->GetAltroCFG2() ); | |
299 | ||
b850c417 | 300 | |
178dd351 | 301 | // if(fAnalyzerPtr->GetTiming() > fMinPeakPosition && fAnalyzerPtr->GetTiming() < fMaxPeakPosition) |
302 | { | |
303 | channelDataPtr->fChannelID = chId; | |
72a884c8 | 304 | channelDataPtr->fEnergy = static_cast<Float_t>( res.GetAmp() ) - fOffset; |
4b09a7ed | 305 | |
72a884c8 | 306 | channelDataPtr->fTime = static_cast<Float_t>( res.GetTof() ); |
178dd351 | 307 | channelDataPtr->fCrazyness = static_cast<Short_t>(crazyness); |
308 | channelCount++; | |
309 | channelDataPtr++; // Updating position of the free output. | |
310 | } | |
311 | } | |
4b09a7ed | 312 | |
313 | // return 1; | |
314 | ||
315 | if( fkDoPushRawData == true) | |
316 | { | |
317 | fRawDataWriter->NewChannel(); | |
318 | } | |
319 | ||
178dd351 | 320 | } |
321 | } | |
322 | ||
4b09a7ed | 323 | // return 1; |
324 | ||
178dd351 | 325 | //Writing the header |
326 | channelDataHeaderPtr->fNChannels = channelCount; | |
327 | channelDataHeaderPtr->fAlgorithm = fAlgorithm; | |
328 | channelDataHeaderPtr->fInfo = 0; | |
329 | ||
4b09a7ed | 330 | // return 1; |
331 | ||
332 | ||
178dd351 | 333 | if( fkDoPushRawData == true) |
334 | { | |
335 | tmpsize += fRawDataWriter->CopyBufferToSharedMemory( (UShort_t *)channelDataPtr, size, totSize); | |
336 | } | |
337 | ||
338 | // channelDataHeaderPtr->fHasRawData = false; | |
339 | channelDataHeaderPtr->fHasRawData = fkDoPushRawData; | |
178dd351 | 340 | HLTDebug("Number of channels: %d", channelCount); |
178dd351 | 341 | tmpsize += sizeof(AliHLTCaloChannelDataStruct)*channelCount + sizeof(AliHLTCaloChannelDataHeaderStruct); |
178dd351 | 342 | return tmpsize; |
343 | ||
344 | } | |
345 | ||
4b09a7ed | 346 | |
347 | ||
348 | ||
178dd351 | 349 | |
77f350f7 | 350 | AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::RawDataWriter(AliHLTCaloConstants* cConst) : //fIsFirstChannel(true), |
178dd351 | 351 | fRawDataBuffer(0), |
352 | fCurrentChannelSize(0), | |
353 | // fIsFirstChannel(true), | |
354 | fBufferIndex(0), | |
355 | // fBufferSize( NZROWSRCU*NXCOLUMNSRCU*ALTROMAXSAMPLES*NGAINS +1000 ), | |
77f350f7 | 356 | fBufferSize( 64*56*cConst->GetNGAINS()*cConst->GetALTROMAXSAMPLES() +1000 ), |
178dd351 | 357 | fCurrentChannelIdPtr(0), |
358 | fCurrentChannelSizePtr(0), | |
359 | fCurrentChannelDataPtr(0), | |
360 | fTotalSize(0) | |
361 | { | |
178dd351 | 362 | fRawDataBuffer = new UShort_t[fBufferSize]; |
363 | Init(); | |
364 | } | |
365 | ||
366 | ||
367 | ||
368 | void | |
369 | AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::Init() | |
370 | { | |
178dd351 | 371 | fCurrentChannelIdPtr = fRawDataBuffer; |
372 | fCurrentChannelSizePtr = fRawDataBuffer +1; | |
373 | fCurrentChannelDataPtr = fRawDataBuffer +2; | |
374 | ResetBuffer(); | |
375 | } | |
376 | ||
377 | ||
378 | void | |
379 | AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::NewEvent() | |
380 | { | |
178dd351 | 381 | Init(); |
382 | fTotalSize = 0; | |
383 | } | |
384 | ||
385 | ||
386 | void | |
387 | AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::NewChannel( ) | |
388 | { | |
178dd351 | 389 | *fCurrentChannelSizePtr = fCurrentChannelSize; |
390 | fCurrentChannelIdPtr += fCurrentChannelSize; | |
391 | fCurrentChannelSizePtr += fCurrentChannelSize; | |
392 | fCurrentChannelDataPtr += fCurrentChannelSize; | |
393 | fBufferIndex = 0; | |
394 | fCurrentChannelSize = 2; | |
395 | fTotalSize += 2; | |
396 | } | |
397 | ||
398 | ||
399 | void | |
400 | AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::WriteBunchData(const UShort_t *bunchdata, const int length, const UInt_t starttimebin ) | |
401 | { | |
178dd351 | 402 | fCurrentChannelDataPtr[fBufferIndex] = starttimebin; |
403 | fCurrentChannelSize ++; | |
404 | fBufferIndex++; | |
405 | fCurrentChannelDataPtr[fBufferIndex] = length; | |
406 | fCurrentChannelSize ++; | |
407 | fBufferIndex++; | |
408 | ||
409 | fTotalSize +=2; | |
410 | ||
411 | for(int i=0; i < length; i++) | |
412 | { | |
413 | fCurrentChannelDataPtr[ fBufferIndex + i ] = bunchdata[i]; | |
414 | } | |
415 | ||
416 | fCurrentChannelSize += length; | |
417 | fTotalSize += length; | |
418 | fBufferIndex += length; | |
419 | } | |
420 | ||
421 | ||
422 | void | |
423 | AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::SetChannelId( const UShort_t channeldid ) | |
424 | { | |
178dd351 | 425 | *fCurrentChannelIdPtr = channeldid; |
426 | } | |
427 | ||
428 | ||
429 | void | |
430 | AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::ResetBuffer() | |
431 | { | |
178dd351 | 432 | for(int i=0; i < fBufferSize ; i++ ) |
433 | { | |
434 | fRawDataBuffer[i] = 0; | |
435 | } | |
436 | } | |
437 | ||
438 | ||
439 | int | |
440 | AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::CopyBufferToSharedMemory(UShort_t *memPtr, const int sizetotal, const int sizeused ) | |
441 | { | |
178dd351 | 442 | int sizerequested = (sizeof(int)*fTotalSize + sizeused); |
443 | ||
444 | if( sizerequested > sizetotal ) | |
445 | { | |
446 | return 0; | |
447 | } | |
448 | else | |
449 | { | |
450 | for(int i=0; i < fTotalSize; i++) | |
451 | { | |
452 | memPtr[i] = fRawDataBuffer[i]; | |
453 | } | |
454 | return fTotalSize; | |
455 | } | |
456 | } | |
457 |