fixed code violation
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzerComponent.cxx
CommitLineData
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#include "AliHLTPHOSRawAnalyzer.h"
cbab66dd 20#include "AliHLTPHOSRawAnalyzerComponent.h"
bde48b84 21#include "AliHLTPHOSRcuCellEnergyDataStruct.h"
2b7cf4fb 22#include "AliHLTPHOSRcuChannelDataStruct.h"
e086ee30 23#include "AliHLTDDLDecoder.h"
24#include "AliHLTAltroData.h"
e086ee30 25#include "AliHLTPHOSMapper.h"
43dd7c5e 26#include "AliHLTAltroBunch.h"
ee7849e6 27
43dd7c5e 28//using namespace std;
2b7cf4fb 29
b60bd496 30AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTPHOSRcuProcessor(), fAnalyzerPtr(0),
43dd7c5e 31 fSendChannelData(kFALSE),fOutPtr(0), fMapperPtr(0), fDecoderPtr(0),
32 fAltroDataPtr(0), fAltroBunchPtr(0)
cbab66dd 33{
e086ee30 34 fMapperPtr = new AliHLTPHOSMapper();
43dd7c5e 35
d504c864 36}
2b7cf4fb 37
2ef3c547 38
cbab66dd 39AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
40{
b60bd496 41 delete fMapperPtr;
cbab66dd 42}
43
2ef3c547 44
cbab66dd 45int
d2a0b488 46AliHLTPHOSRawAnalyzerComponent::Deinit()
cbab66dd 47{
d2a0b488 48 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen Deinit");
d2a0b488 49 return 0;
cbab66dd 50}
51
2ef3c547 52
9dfd64cf 53const char*
54AliHLTPHOSRawAnalyzerComponent::GetComponentID()
55{
56 return "AliPhosTestRaw";
57}
ee7849e6 58
1c1b3412 59
cbab66dd 60void
ee7849e6 61AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
cbab66dd 62{
146c463a 63 const AliHLTComponentDataType* pType=fgkInputDataTypes;
ee7849e6 64 while (pType->fID!=0) {
65 list.push_back(*pType);
66 pType++;
67 }
cbab66dd 68}
69
2ef3c547 70
cbab66dd 71AliHLTComponentDataType
72AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
73{
d504c864 74 return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
cbab66dd 75}
76
d504c864 77
cbab66dd 78void
9dfd64cf 79AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
80
cbab66dd 81{
ef408bb3 82 constBase = 30;
2b7cf4fb 83 inputMultiplier = 1;
cbab66dd 84}
85
2ef3c547 86
d504c864 87int
88AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
cbab66dd 89{
bde48b84 90 UInt_t offset = 0;
91 UInt_t mysize = 0;
92 UInt_t tSize = 0;
03b3d247 93 // Int_t tmpChannelCnt = 0;
53740333 94 AliHLTUInt8_t* outBPtr;
43dd7c5e 95
96 AliHLTAltroBunch *bunchPtr;
53740333 97 outBPtr = outputPtr;
0a211711 98 const AliHLTComponentBlockData* iter = NULL;
99 unsigned long ndx;
0a211711 100 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
101 {
afc526a2 102
103
104 Int_t tmpChannelCnt = 0;
0a211711 105 iter = blocks+ndx;
53740333 106 mysize = 0;
107 offset = tSize;
afc526a2 108
d504c864 109 if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
0a211711 110 {
32764ee6 111 // cout <<"WARNING: not AliHLTPHOSDefinitions::fgkDDLPackedRawDataType " << endl;
afc526a2 112 continue; //!!!!! Commented out to read TPC data, remember to put back
0a211711 113 }
ef408bb3 114
afc526a2 115 fDecoderPtr->SetMemory(reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize);
03b3d247 116 // fDecoderPtr->SetMemory2(reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize);
e086ee30 117 fDecoderPtr->Decode();
e086ee30 118 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
0d7c9b63 119 fOutPtr->fRcuX = fRcuX;
120 fOutPtr->fRcuZ = fRcuZ;
d2b84453 121 fOutPtr->fModuleID =fModuleID;
e086ee30 122 while( fDecoderPtr->NextChannel(fAltroDataPtr) == true )
123 {
e086ee30 124 fAnalyzerPtr->SetData(fAltroDataPtr->fData);
6e709a0d 125 fAnalyzerPtr->Evaluate(0, fAltroDataPtr->fDataSize -2);
43dd7c5e 126
9c9d15d6 127 fOutPtr->fValidData[tmpChannelCnt].fZ = fMapperPtr->hw2geomapPtr[fAltroDataPtr->fHadd].zRow;
128 fOutPtr->fValidData[tmpChannelCnt].fX = fMapperPtr->hw2geomapPtr[fAltroDataPtr->fHadd].xCol;
43dd7c5e 129 fOutPtr->fValidData[tmpChannelCnt].fGain = fMapperPtr->hw2geomapPtr[fAltroDataPtr->fHadd].gain;
e086ee30 130 fOutPtr->fValidData[tmpChannelCnt].fEnergy = (float)fAnalyzerPtr->GetEnergy();
131 fOutPtr->fValidData[tmpChannelCnt].fTime = (float)fAnalyzerPtr->GetTiming();
132 tmpChannelCnt ++;
e086ee30 133 }
43dd7c5e 134
03b3d247 135
e086ee30 136 fOutPtr->fCnt = tmpChannelCnt;
03b3d247 137 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
138
e086ee30 139 AliHLTComponentBlockData bd;
140 FillBlockData( bd );
141 bd.fOffset = offset;
142 bd.fSize = mysize;
143
144 bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType;
145 bd.fSpecification = 0xFFFFFFFF;
146 outputBlocks.push_back( bd );
147
148 tSize += mysize;
149 outBPtr += mysize;
150
151 if( tSize > size )
152 {
6e709a0d 153 cout <<"kHLTLogFatal, HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent Too much dataData written over allowed buffer. Amount written:"
e086ee30 154 << tSize << " allowed" << size << endl;
155 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
156 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
157 , tSize, size );
158 return EMSGSIZE;
159 }
b60bd496 160 // fDecoderPtr->GetFailureRate();
161
e086ee30 162 }
e086ee30 163
d2a0b488 164 fPhosEventCount++;
2b7cf4fb 165
166 if(fPrintInfo == kTRUE)
167 {
d2a0b488 168 if(fPhosEventCount%fPrintInfoFrequncy == 0)
2b7cf4fb 169 {
d2a0b488 170 cout <<"Analyzing event " << fPhosEventCount << "for Equippment " << fkEquippmentID << endl;
2b7cf4fb 171 }
172 }
53740333 173 size = tSize;
e086ee30 174
2947a32c 175 return 0;
176}//end DoEvent
e086ee30 177
0a211711 178
0a211711 179int
180AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
181{
2ef3c547 182 cout <<"AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) "<< endl;
e086ee30 183 fAltroDataPtr = new AliHLTAltroData();
43dd7c5e 184 fAltroBunchPtr = new AliHLTAltroBunch();
e086ee30 185 fDecoderPtr = new AliHLTDDLDecoder();
2b7cf4fb 186 fSendChannelData = kFALSE;
187 fPrintInfo = kFALSE;
2947a32c 188 Reset();
2b7cf4fb 189 int iResult=0;
190 TString argument="";
d2a0b488 191 iResult = ScanArguments(argc, argv);
2b7cf4fb 192
d2a0b488 193 if(fIsSetEquippmentID == kFALSE)
2b7cf4fb 194 {
e56d0892 195 cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>" << endl;
2b7cf4fb 196 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
197 "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>");
e086ee30 198 iResult = -3;
2b7cf4fb 199 }
d2a0b488 200 else
201 {
2ef3c547 202 iResult = 0;
203 // fRawMemoryReader->SetEquipmentID(fkEquippmentID);
d2a0b488 204 }
2b7cf4fb 205
2ef3c547 206 // return iResult;
207 // return 0;
d2a0b488 208 return iResult;
0a211711 209}
9dfd64cf 210
9dfd64cf 211
2947a32c 212void
213AliHLTPHOSRawAnalyzerComponent::Reset()
214{
432edd34 215 for(int mod = 0; mod < N_MODULES; mod ++)
9dfd64cf 216 {
b60bd496 217 for(int row = 0; row < N_ZROWS_MOD; row ++)
2947a32c 218 {
b60bd496 219 for(int col = 0; col < N_XCOLUMNS_MOD; col ++)
2947a32c 220 {
432edd34 221 for(int gain = 0; gain < N_GAINS; gain ++ )
2947a32c 222 {
223 fMaxValues[mod][row][col][gain] = 0;
224 }
225 }
226 }
227 }
9dfd64cf 228
2b7cf4fb 229 ResetDataPtr(0, ALTRO_MAX_SAMPLES);
432edd34 230
231} // end Reset
232
e086ee30 233
2947a32c 234void
432edd34 235AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
2947a32c 236{
432edd34 237 for(int i = startindex ; i< sampleCnt; i++)
2947a32c 238 {
239 fTmpChannelData[i] = 0;
240 }
cbab66dd 241}
ef408bb3 242