1 /**************************************************************************
2 * This file is property of and copyright by the Experimental Nuclear *
3 * Physics Group, Dep. of Physics *
4 * University of Oslo, Norway, 2007 *
6 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
7 * Contributors are mentioned in the code where appropriate. *
8 * Please report bugs to perthi@fys.uio.no *
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 **************************************************************************/
19 #include "AliHLTPHOSRawAnalyzer.h"
20 #include "AliHLTPHOSRawAnalyzerComponent.h"
21 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
22 #include "AliHLTPHOSRcuChannelDataStruct.h"
23 #include "AliHLTDDLDecoder.h"
24 #include "AliHLTAltroData.h"
25 #include "AliHLTPHOSMapper.h"
26 #include "AliHLTAltroBunch.h"
28 //using namespace std;
30 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTPHOSRcuProcessor(), fAnalyzerPtr(0),
31 fSendChannelData(kFALSE),fOutPtr(0), fMapperPtr(0), fDecoderPtr(0),
32 fAltroDataPtr(0), fAltroBunchPtr(0)
34 fMapperPtr = new AliHLTPHOSMapper();
39 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
46 AliHLTPHOSRawAnalyzerComponent::Deinit()
48 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen Deinit");
54 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
56 return "AliPhosTestRaw";
61 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
63 const AliHLTComponentDataType* pType=fgkInputDataTypes;
64 while (pType->fID!=0) {
65 list.push_back(*pType);
71 AliHLTComponentDataType
72 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
74 return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
79 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
88 AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
93 // Int_t tmpChannelCnt = 0;
94 AliHLTUInt8_t* outBPtr;
96 AliHLTAltroBunch *bunchPtr;
98 const AliHLTComponentBlockData* iter = NULL;
100 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
104 Int_t tmpChannelCnt = 0;
109 if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
111 // cout <<"WARNING: not AliHLTPHOSDefinitions::fgkDDLPackedRawDataType " << endl;
112 continue; //!!!!! Commented out to read TPC data, remember to put back
115 fDecoderPtr->SetMemory(reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize);
116 // fDecoderPtr->SetMemory2(reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize);
117 fDecoderPtr->Decode();
118 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
119 fOutPtr->fRcuX = fRcuX;
120 fOutPtr->fRcuZ = fRcuZ;
121 fOutPtr->fModuleID =fModuleID;
122 while( fDecoderPtr->NextChannel(fAltroDataPtr) == true )
124 fAnalyzerPtr->SetData(fAltroDataPtr->fData);
125 fAnalyzerPtr->Evaluate(0, fAltroDataPtr->fDataSize -2);
127 fOutPtr->fValidData[tmpChannelCnt].fZ = fMapperPtr->hw2geomapPtr[fAltroDataPtr->fHadd].zRow;
128 fOutPtr->fValidData[tmpChannelCnt].fX = fMapperPtr->hw2geomapPtr[fAltroDataPtr->fHadd].xCol;
129 fOutPtr->fValidData[tmpChannelCnt].fGain = fMapperPtr->hw2geomapPtr[fAltroDataPtr->fHadd].gain;
130 fOutPtr->fValidData[tmpChannelCnt].fEnergy = (float)fAnalyzerPtr->GetEnergy();
131 fOutPtr->fValidData[tmpChannelCnt].fTime = (float)fAnalyzerPtr->GetTiming();
136 fOutPtr->fCnt = tmpChannelCnt;
137 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
139 AliHLTComponentBlockData bd;
144 bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType;
145 bd.fSpecification = 0xFFFFFFFF;
146 outputBlocks.push_back( bd );
153 cout <<"kHLTLogFatal, HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent Too much dataData written over allowed buffer. Amount written:"
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."
160 // fDecoderPtr->GetFailureRate();
166 if(fPrintInfo == kTRUE)
168 if(fPhosEventCount%fPrintInfoFrequncy == 0)
170 cout <<"Analyzing event " << fPhosEventCount << "for Equippment " << fkEquippmentID << endl;
180 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
182 cout <<"AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) "<< endl;
183 fAltroDataPtr = new AliHLTAltroData();
184 fAltroBunchPtr = new AliHLTAltroBunch();
185 fDecoderPtr = new AliHLTDDLDecoder();
186 fSendChannelData = kFALSE;
191 iResult = ScanArguments(argc, argv);
193 if(fIsSetEquippmentID == kFALSE)
195 cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>" << endl;
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>");
203 // fRawMemoryReader->SetEquipmentID(fkEquippmentID);
213 AliHLTPHOSRawAnalyzerComponent::Reset()
215 for(int mod = 0; mod < N_MODULES; mod ++)
217 for(int row = 0; row < N_ZROWS_MOD; row ++)
219 for(int col = 0; col < N_XCOLUMNS_MOD; col ++)
221 for(int gain = 0; gain < N_GAINS; gain ++ )
223 fMaxValues[mod][row][col][gain] = 0;
229 ResetDataPtr(0, ALTRO_MAX_SAMPLES);
235 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
237 for(int i = startindex ; i< sampleCnt; i++)
239 fTmpChannelData[i] = 0;