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;
99 const AliHLTComponentBlockData* iter = NULL;
102 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
108 if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
110 cout <<"WARNING: notAliHLTPHOSDefinitions::fgkDDLPackedRawDataType " << endl;
114 fDecoderPtr->SetMemory(reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize);
115 fDecoderPtr->Decode();
116 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
117 fOutPtr->fRcuX = fRcuX;
118 fOutPtr->fRcuZ = fRcuZ;
120 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].row;
128 fOutPtr->fValidData[tmpChannelCnt].fX = fMapperPtr->hw2geomapPtr[fAltroDataPtr->fHadd].col;
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 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
137 fOutPtr->fCnt = tmpChannelCnt;
138 AliHLTComponentBlockData bd;
143 bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType;
144 bd.fSpecification = 0xFFFFFFFF;
145 outputBlocks.push_back( bd );
152 cout <<"kHLTLogFatal, HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent Too much dataData written over allowed buffer. Amount written:"
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."
159 // fDecoderPtr->GetFailureRate();
165 if(fPrintInfo == kTRUE)
167 if(fPhosEventCount%fPrintInfoFrequncy == 0)
169 cout <<"Analyzing event " << fPhosEventCount << "for Equippment " << fkEquippmentID << endl;
179 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
181 cout <<"AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) "<< endl;
182 fAltroDataPtr = new AliHLTAltroData();
183 fAltroBunchPtr = new AliHLTAltroBunch();
184 fDecoderPtr = new AliHLTDDLDecoder();
185 fSendChannelData = kFALSE;
190 iResult = ScanArguments(argc, argv);
192 if(fIsSetEquippmentID == kFALSE)
194 cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>" << endl;
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>");
202 // fRawMemoryReader->SetEquipmentID(fkEquippmentID);
212 AliHLTPHOSRawAnalyzerComponent::Reset()
214 for(int mod = 0; mod < N_MODULES; mod ++)
216 for(int row = 0; row < N_ZROWS_MOD; row ++)
218 for(int col = 0; col < N_XCOLUMNS_MOD; col ++)
220 for(int gain = 0; gain < N_GAINS; gain ++ )
222 fMaxValues[mod][row][col][gain] = 0;
228 ResetDataPtr(0, ALTRO_MAX_SAMPLES);
234 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
236 for(int i = startindex ; i< sampleCnt; i++)
238 fTmpChannelData[i] = 0;