]>
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 | ||
2b7cf4fb | 19 | |
20 | /// @class AliHLTPHOSRawAnalyzerComponent | |
21 | /// Base class of PHOS HLT online raw analysis component. | |
22 | /// The class provides a common interface for the implementation of PHOS | |
23 | /// HLT raw data | |
24 | /// processors components. The class is intended for processing of | |
25 | /// arrays of raw data samples to evaluate energy and timing. | |
26 | /// The Energy will be given in entities of ADC leves ranging from 0 to | |
27 | /// 1023. Timing will be given in entities of samples periods. | |
28 | /// Drived clases must implement the fucntions | |
29 | /// - @ref GetComponentID | |
30 | /// - @ref Spawn | |
31 | ||
32 | ||
33 | ||
34 | #include "AliHLTPHOSRawAnalyzer.h" | |
cbab66dd | 35 | #include "AliHLTPHOSRawAnalyzerComponent.h" |
9dfd64cf | 36 | #include "AliRawReaderMemory.h" |
0a211711 | 37 | #include "AliCaloRawStream.h" |
bde48b84 | 38 | #include "AliHLTPHOSRcuCellEnergyDataStruct.h" |
2b7cf4fb | 39 | #include "AliHLTPHOSRcuChannelDataStruct.h" |
cbab66dd | 40 | |
ee7849e6 | 41 | |
d2a0b488 | 42 | using namespace std; |
4df5dd10 | 43 | |
2b7cf4fb | 44 | |
d504c864 | 45 | //_________________________________________________________________________________________________ |
d2a0b488 | 46 | AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTPHOSProcessor(), fAnalyzerPtr(0), |
47 | fSendChannelData(kFALSE),fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0) | |
cbab66dd | 48 | { |
cbab66dd | 49 | |
d504c864 | 50 | } |
2b7cf4fb | 51 | |
d504c864 | 52 | //_________________________________________________________________________________________________ |
cbab66dd | 53 | AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent() |
54 | { | |
0a211711 | 55 | if(fRawMemoryReader != 0) |
56 | { | |
57 | delete fRawMemoryReader; | |
58 | } | |
59 | if(fPHOSRawStream != 0) | |
60 | { | |
61 | delete fPHOSRawStream; | |
62 | } | |
cbab66dd | 63 | } |
64 | ||
d504c864 | 65 | //_________________________________________________________________________________________________ |
d2a0b488 | 66 | AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTPHOSProcessor(), fAnalyzerPtr(0), |
67 | fSendChannelData(kFALSE),fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0) | |
cbab66dd | 68 | { |
cbab66dd | 69 | |
cbab66dd | 70 | } |
71 | ||
d504c864 | 72 | //_________________________________________________________________________________________________ |
cbab66dd | 73 | int |
d2a0b488 | 74 | AliHLTPHOSRawAnalyzerComponent::Deinit() |
cbab66dd | 75 | { |
d2a0b488 | 76 | Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen Deinit"); |
9dfd64cf | 77 | |
0a211711 | 78 | if(fRawMemoryReader !=0) |
79 | { | |
80 | delete fRawMemoryReader; | |
81 | } | |
82 | ||
83 | if(fPHOSRawStream != 0) | |
84 | { | |
85 | delete fPHOSRawStream; | |
86 | } | |
cbab66dd | 87 | return 0; |
cbab66dd | 88 | |
d2a0b488 | 89 | return 0; |
cbab66dd | 90 | } |
91 | ||
d504c864 | 92 | //_________________________________________________________________________________________________ |
9dfd64cf | 93 | const char* |
94 | AliHLTPHOSRawAnalyzerComponent::GetComponentID() | |
95 | { | |
96 | return "AliPhosTestRaw"; | |
97 | } | |
ee7849e6 | 98 | |
1c1b3412 | 99 | |
d504c864 | 100 | //_________________________________________________________________________________________________ |
cbab66dd | 101 | void |
ee7849e6 | 102 | AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
cbab66dd | 103 | { |
146c463a | 104 | const AliHLTComponentDataType* pType=fgkInputDataTypes; |
ee7849e6 | 105 | while (pType->fID!=0) { |
106 | list.push_back(*pType); | |
107 | pType++; | |
108 | } | |
cbab66dd | 109 | } |
110 | ||
d504c864 | 111 | //_________________________________________________________________________________________________ |
cbab66dd | 112 | AliHLTComponentDataType |
113 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataType() | |
114 | { | |
d504c864 | 115 | return AliHLTPHOSDefinitions::fgkCellEnergyDataType; |
cbab66dd | 116 | } |
117 | ||
d504c864 | 118 | |
119 | //_________________________________________________________________________________________________ | |
cbab66dd | 120 | void |
9dfd64cf | 121 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) |
122 | ||
cbab66dd | 123 | { |
ef408bb3 | 124 | constBase = 30; |
2b7cf4fb | 125 | inputMultiplier = 1; |
cbab66dd | 126 | } |
127 | ||
d504c864 | 128 | //_________________________________________________________________________________________________ |
129 | int | |
130 | AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) | |
cbab66dd | 131 | { |
857f8ed5 | 132 | AliHLTUInt8_t tmpMod = 0; |
133 | AliHLTUInt8_t tmpZ = 0; | |
134 | AliHLTUInt8_t tmpX = 0; | |
135 | AliHLTUInt8_t tmpGain = 0; | |
bde48b84 | 136 | Int_t sampleCnt = 0; |
2947a32c | 137 | Int_t processedChannels = 0; |
bde48b84 | 138 | UInt_t offset = 0; |
139 | UInt_t mysize = 0; | |
140 | UInt_t tSize = 0; | |
2bcb5a06 | 141 | Int_t tmpChannelCnt = 0; |
432edd34 | 142 | Int_t tmpStartIndex = 0; |
53740333 | 143 | AliHLTUInt8_t* outBPtr; |
2b7cf4fb | 144 | unsigned long first; |
145 | unsigned long last; | |
53740333 | 146 | outBPtr = outputPtr; |
0a211711 | 147 | const AliHLTComponentBlockData* iter = NULL; |
148 | unsigned long ndx; | |
cf434398 | 149 | |
0a211711 | 150 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
151 | { | |
0a211711 | 152 | iter = blocks+ndx; |
53740333 | 153 | mysize = 0; |
154 | offset = tSize; | |
155 | ||
d504c864 | 156 | if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType ) |
0a211711 | 157 | { |
0a211711 | 158 | continue; |
159 | } | |
ef408bb3 | 160 | |
bde48b84 | 161 | fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize ); |
146c463a | 162 | fAnalyzerPtr->SetData(fTmpChannelData); |
a00e1689 | 163 | fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr; |
bde48b84 | 164 | mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct); |
a00e1689 | 165 | fOutPtr->fRcuX = fRcuX; |
166 | fOutPtr->fRcuZ = fRcuZ; | |
167 | fOutPtr->fModuleID = fModuleID; | |
2bcb5a06 | 168 | tmpChannelCnt = 0; |
2b7cf4fb | 169 | |
2947a32c | 170 | while(fPHOSRawStream->Next()) |
171 | { | |
e56d0892 | 172 | // cout << "rawanalyze fPHOSRawStream->Next()" <<endl; |
2947a32c | 173 | if (fPHOSRawStream->IsNewHWAddress()) |
174 | { | |
175 | if(processedChannels > 0) | |
176 | { | |
e56d0892 | 177 | // cout << "rawanalyzer fPHOSRawStream->IsNewHWAddress()" <<endl; |
146c463a | 178 | fAnalyzerPtr->SetData(fTmpChannelData); |
179 | fAnalyzerPtr->Evaluate(0, sampleCnt); | |
a00e1689 | 180 | fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain; |
1c1b3412 | 181 | fOutPtr->fValidData[tmpChannelCnt].fZ = tmpZ; |
182 | fOutPtr->fValidData[tmpChannelCnt].fX = tmpX; | |
2b7cf4fb | 183 | fOutPtr->fValidData[tmpChannelCnt].fEnergy = (float)fAnalyzerPtr->GetEnergy(); |
184 | fOutPtr->fValidData[tmpChannelCnt].fTime = (float)fAnalyzerPtr->GetTiming(); | |
432edd34 | 185 | ResetDataPtr(tmpStartIndex, sampleCnt); |
2b7cf4fb | 186 | tmpChannelCnt ++; |
68d9caee | 187 | sampleCnt = 0; |
2947a32c | 188 | } |
189 | ||
1c1b3412 | 190 | tmpMod = (AliHLTUInt8_t)fPHOSRawStream->GetModule() ; |
1c1b3412 | 191 | tmpX =(AliHLTUInt8_t)fPHOSRawStream->GetRow() - fRcuXOffset; |
192 | tmpZ =(AliHLTUInt8_t)fPHOSRawStream->GetColumn() - fRcuZOffset; | |
2947a32c | 193 | tmpGain = fPHOSRawStream->IsLowGain(); |
194 | processedChannels ++; | |
195 | } | |
432edd34 | 196 | |
197 | if(sampleCnt == 0) | |
198 | { | |
199 | tmpStartIndex = fPHOSRawStream->GetTime(); | |
200 | } | |
201 | ||
2947a32c | 202 | fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal(); |
bde48b84 | 203 | sampleCnt ++; |
2947a32c | 204 | } |
2b7cf4fb | 205 | |
006ee9b2 | 206 | tmpChannelCnt ++; |
146c463a | 207 | fAnalyzerPtr->SetData(fTmpChannelData); |
208 | fAnalyzerPtr->Evaluate(0, sampleCnt); | |
006ee9b2 | 209 | fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain; |
210 | fOutPtr->fValidData[tmpChannelCnt].fZ = tmpZ; | |
211 | fOutPtr->fValidData[tmpChannelCnt].fX = tmpX; | |
146c463a | 212 | fOutPtr->fValidData[tmpChannelCnt].fEnergy = fAnalyzerPtr->GetEnergy(); |
213 | fOutPtr->fValidData[tmpChannelCnt].fTime = fAnalyzerPtr->GetTiming(); | |
857f8ed5 | 214 | ResetDataPtr(tmpStartIndex, sampleCnt); |
006ee9b2 | 215 | |
2b7cf4fb | 216 | sampleCnt = 0; |
006ee9b2 | 217 | |
a00e1689 | 218 | fOutPtr->fCnt = tmpChannelCnt; |
53740333 | 219 | AliHLTComponentBlockData bd; |
220 | FillBlockData( bd ); | |
53740333 | 221 | bd.fOffset = offset; |
222 | bd.fSize = mysize; | |
d504c864 | 223 | bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType; |
9ce19a20 | 224 | bd.fSpecification = 0xFFFFFFFF; |
53740333 | 225 | outputBlocks.push_back( bd ); |
53740333 | 226 | tSize += mysize; |
227 | outBPtr += mysize; | |
2b7cf4fb | 228 | |
cf434398 | 229 | if( tSize > size ) |
2b7cf4fb | 230 | { |
231 | cout <<"kHLTLogFatal, HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent Too much data Data written over allowed buffer. Amount written:" << tSize << " allowed" << size << endl; | |
232 | Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data", | |
233 | "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu." | |
234 | , tSize, size ); | |
235 | return EMSGSIZE; | |
236 | } | |
53740333 | 237 | |
2b7cf4fb | 238 | } |
239 | ||
d2a0b488 | 240 | fPhosEventCount++; |
2b7cf4fb | 241 | |
242 | if(fPrintInfo == kTRUE) | |
243 | { | |
d2a0b488 | 244 | if(fPhosEventCount%fPrintInfoFrequncy == 0) |
2b7cf4fb | 245 | { |
d2a0b488 | 246 | cout <<"Analyzing event " << fPhosEventCount << "for Equippment " << fkEquippmentID << endl; |
2b7cf4fb | 247 | } |
248 | } | |
53740333 | 249 | size = tSize; |
2947a32c | 250 | return 0; |
251 | }//end DoEvent | |
0a211711 | 252 | |
253 | ||
d504c864 | 254 | //_________________________________________________________________________________________________ |
0a211711 | 255 | int |
256 | AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) | |
257 | { | |
2b7cf4fb | 258 | fSendChannelData = kFALSE; |
259 | fPrintInfo = kFALSE; | |
2947a32c | 260 | Reset(); |
0a211711 | 261 | fRawMemoryReader = new AliRawReaderMemory(); |
262 | fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS"); | |
1c1b3412 | 263 | fPHOSRawStream->SetOldRCUFormat(kFALSE); |
2b7cf4fb | 264 | int iResult=0; |
265 | TString argument=""; | |
d2a0b488 | 266 | iResult = ScanArguments(argc, argv); |
2b7cf4fb | 267 | |
268 | ||
d2a0b488 | 269 | if(fIsSetEquippmentID == kFALSE) |
2b7cf4fb | 270 | { |
e56d0892 | 271 | cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>" << endl; |
2b7cf4fb | 272 | Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument", |
273 | "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>"); | |
274 | iResult = -2; | |
275 | } | |
d2a0b488 | 276 | else |
277 | { | |
278 | fRawMemoryReader->SetEquipmentID(fkEquippmentID); | |
279 | } | |
2b7cf4fb | 280 | |
d2a0b488 | 281 | return iResult; |
0a211711 | 282 | } |
9dfd64cf | 283 | |
d504c864 | 284 | //_________________________________________________________________________________________________ |
2ca5f55f | 285 | void |
286 | AliHLTPHOSRawAnalyzerComponent::DumpData(int gain) const | |
0a211711 | 287 | { |
432edd34 | 288 | for(int mod = 0; mod < N_MODULES; mod ++) |
2947a32c | 289 | { |
290 | printf("\n *********** MODULE %d ************\n", mod); | |
432edd34 | 291 | for(int row = 0; row < N_ROWS_MOD; row ++) |
2947a32c | 292 | { |
432edd34 | 293 | for(int col = 0; col < N_COLUMNS_MOD; col ++) |
2947a32c | 294 | { |
295 | if( fMaxValues[mod][row][col][0] != 0) | |
296 | { | |
432edd34 | 297 | cout << fMaxValues[mod][row][col][gain] << "\t"; |
2947a32c | 298 | } |
299 | } | |
300 | } | |
301 | } | |
302 | } | |
9dfd64cf | 303 | |
432edd34 | 304 | |
d504c864 | 305 | //_________________________________________________________________________________________________ |
2ca5f55f | 306 | void |
307 | AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data) const | |
68d9caee | 308 | { |
d2a0b488 | 309 | cout << endl; |
310 | for(int i=0; i< ALTRO_MAX_SAMPLES; i++) | |
311 | { | |
312 | if (data[i] != 0) | |
68d9caee | 313 | { |
d2a0b488 | 314 | cout <<i <<"\t"; |
68d9caee | 315 | } |
d2a0b488 | 316 | } |
317 | cout << endl; | |
318 | ||
319 | for(int i=0; i< ALTRO_MAX_SAMPLES; i++) | |
320 | { | |
321 | if (data[i] != 0) | |
68d9caee | 322 | { |
d2a0b488 | 323 | cout <<data[i] <<"\t"; |
68d9caee | 324 | } |
d2a0b488 | 325 | } |
326 | ||
327 | cout << endl; | |
68d9caee | 328 | } |
329 | ||
d504c864 | 330 | //_________________________________________________________________________________________________ |
2947a32c | 331 | void |
332 | AliHLTPHOSRawAnalyzerComponent::Reset() | |
333 | { | |
432edd34 | 334 | for(int mod = 0; mod < N_MODULES; mod ++) |
9dfd64cf | 335 | { |
432edd34 | 336 | for(int row = 0; row < N_ROWS_MOD; row ++) |
2947a32c | 337 | { |
432edd34 | 338 | for(int col = 0; col < N_COLUMNS_MOD; col ++) |
2947a32c | 339 | { |
432edd34 | 340 | for(int gain = 0; gain < N_GAINS; gain ++ ) |
2947a32c | 341 | { |
342 | fMaxValues[mod][row][col][gain] = 0; | |
343 | } | |
344 | } | |
345 | } | |
346 | } | |
9dfd64cf | 347 | |
2b7cf4fb | 348 | ResetDataPtr(0, ALTRO_MAX_SAMPLES); |
432edd34 | 349 | |
350 | } // end Reset | |
351 | ||
d504c864 | 352 | //_________________________________________________________________________________________________ |
2947a32c | 353 | void |
432edd34 | 354 | AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt) |
2947a32c | 355 | { |
432edd34 | 356 | for(int i = startindex ; i< sampleCnt; i++) |
2947a32c | 357 | { |
358 | fTmpChannelData[i] = 0; | |
359 | } | |
cbab66dd | 360 | } |
ef408bb3 | 361 |