]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSRawAnalyzerComponent.cxx
Effective C++ & documentation, bug fix in Online display
[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;
2bcb5a06 93 Int_t tmpChannelCnt = 0;
53740333 94 AliHLTUInt8_t* outBPtr;
43dd7c5e 95
96 AliHLTAltroBunch *bunchPtr;
97
53740333 98 outBPtr = outputPtr;
0a211711 99 const AliHLTComponentBlockData* iter = NULL;
100 unsigned long ndx;
cf434398 101
0a211711 102 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
103 {
0a211711 104 iter = blocks+ndx;
53740333 105 mysize = 0;
106 offset = tSize;
107
d504c864 108 if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
0a211711 109 {
b60bd496 110 cout <<"WARNING: notAliHLTPHOSDefinitions::fgkDDLPackedRawDataType " << endl;
e086ee30 111 // continue;
0a211711 112 }
ef408bb3 113
e086ee30 114 fDecoderPtr->SetMemory(reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize);
e086ee30 115 fDecoderPtr->Decode();
e086ee30 116 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
0d7c9b63 117 fOutPtr->fRcuX = fRcuX;
118 fOutPtr->fRcuZ = fRcuZ;
e086ee30 119
d2b84453 120 fOutPtr->fModuleID =fModuleID;
121
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
e086ee30 135
136 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
e086ee30 137 fOutPtr->fCnt = tmpChannelCnt;
138 AliHLTComponentBlockData bd;
139 FillBlockData( bd );
140 bd.fOffset = offset;
141 bd.fSize = mysize;
142
143 bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType;
144 bd.fSpecification = 0xFFFFFFFF;
145 outputBlocks.push_back( bd );
146
147 tSize += mysize;
148 outBPtr += mysize;
149
150 if( tSize > size )
151 {
6e709a0d 152 cout <<"kHLTLogFatal, HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent Too much dataData written over allowed buffer. Amount written:"
e086ee30 153 << tSize << " allowed" << size << endl;
154 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
155 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
156 , tSize, size );
157 return EMSGSIZE;
158 }
b60bd496 159 // fDecoderPtr->GetFailureRate();
160
e086ee30 161 }
e086ee30 162
d2a0b488 163 fPhosEventCount++;
2b7cf4fb 164
165 if(fPrintInfo == kTRUE)
166 {
d2a0b488 167 if(fPhosEventCount%fPrintInfoFrequncy == 0)
2b7cf4fb 168 {
d2a0b488 169 cout <<"Analyzing event " << fPhosEventCount << "for Equippment " << fkEquippmentID << endl;
2b7cf4fb 170 }
171 }
53740333 172 size = tSize;
e086ee30 173
2947a32c 174 return 0;
175}//end DoEvent
e086ee30 176
0a211711 177
0a211711 178int
179AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
180{
2ef3c547 181 cout <<"AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) "<< endl;
e086ee30 182 fAltroDataPtr = new AliHLTAltroData();
43dd7c5e 183 fAltroBunchPtr = new AliHLTAltroBunch();
e086ee30 184 fDecoderPtr = new AliHLTDDLDecoder();
2b7cf4fb 185 fSendChannelData = kFALSE;
186 fPrintInfo = kFALSE;
2947a32c 187 Reset();
2b7cf4fb 188 int iResult=0;
189 TString argument="";
d2a0b488 190 iResult = ScanArguments(argc, argv);
2b7cf4fb 191
d2a0b488 192 if(fIsSetEquippmentID == kFALSE)
2b7cf4fb 193 {
e56d0892 194 cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>" << endl;
2b7cf4fb 195 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
196 "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>");
e086ee30 197 iResult = -3;
2b7cf4fb 198 }
d2a0b488 199 else
200 {
2ef3c547 201 iResult = 0;
202 // fRawMemoryReader->SetEquipmentID(fkEquippmentID);
d2a0b488 203 }
2b7cf4fb 204
2ef3c547 205 // return iResult;
206 // return 0;
d2a0b488 207 return iResult;
0a211711 208}
9dfd64cf 209
9dfd64cf 210
2947a32c 211void
212AliHLTPHOSRawAnalyzerComponent::Reset()
213{
432edd34 214 for(int mod = 0; mod < N_MODULES; mod ++)
9dfd64cf 215 {
b60bd496 216 for(int row = 0; row < N_ZROWS_MOD; row ++)
2947a32c 217 {
b60bd496 218 for(int col = 0; col < N_XCOLUMNS_MOD; col ++)
2947a32c 219 {
432edd34 220 for(int gain = 0; gain < N_GAINS; gain ++ )
2947a32c 221 {
222 fMaxValues[mod][row][col][gain] = 0;
223 }
224 }
225 }
226 }
9dfd64cf 227
2b7cf4fb 228 ResetDataPtr(0, ALTRO_MAX_SAMPLES);
432edd34 229
230} // end Reset
231
e086ee30 232
2947a32c 233void
432edd34 234AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
2947a32c 235{
432edd34 236 for(int i = startindex ; i< sampleCnt; i++)
2947a32c 237 {
238 fTmpChannelData[i] = 0;
239 }
cbab66dd 240}
ef408bb3 241