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