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 **************************************************************************/
20 #include "AliHLTPHOSDDLDecoderComponent.h"
21 #include "AliRawReaderMemory.h"
22 #include "AliCaloRawStream.h"
23 #include "AliHLTPHOSRcuChannelDataStruct.h"
24 #include "AliHLTPHOSPulseGenerator.h"
25 #include "AliHLTPHOSDataCorruptor.h"
26 #include "AliHLTDDLDecoder.h"
27 #include "AliHLTPHOSMapper.h"
28 #include "AliHLTAltroData.h"
29 //#include "AliHLTPHOSBase.h"
34 AliHLTPHOSDDLDecoderComponent gAliHLTPHOSDDLDecoderComponent;
37 AliHLTPHOSDDLDecoderComponent::AliHLTPHOSDDLDecoderComponent():AliHLTPHOSRcuProcessor(),
38 fDataCorruptorPtr(0), fOutPtr(0), fDecoderPtr(0), fAltroDataPtr(0), fMapperPtr(0)
41 fDataCorruptorPtr = new AliHLTPHOSDataCorruptor();
42 fAltroDataPtr = new AliHLTAltroData();
43 fDecoderPtr = new AliHLTDDLDecoder();
44 fMapperPtr = new AliHLTPHOSMapper();
47 AliHLTPHOSDDLDecoderComponent::~AliHLTPHOSDDLDecoderComponent()
53 AliHLTPHOSDDLDecoderComponent::Deinit()
55 //Se html documentation of base class
56 cout << "Deinit" << endl;
57 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
63 AliHLTPHOSDDLDecoderComponent::GetComponentID()
65 //Se html documentation of base class
66 return "PhosDDLDecoder";
72 AliHLTPHOSDDLDecoderComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
74 //Se html documentation of base class
75 const AliHLTComponentDataType* pType=fgkInputDataTypes;
76 while (pType->fID!=0) {
77 list.push_back(*pType);
82 AliHLTComponentDataType
83 AliHLTPHOSDDLDecoderComponent::GetOutputDataType()
85 //See html documentation of base class
86 return AliHLTPHOSDefinitions::fgkCellChannelDataDataType;
90 AliHLTPHOSDDLDecoderComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
93 //Se html documentation of base class
100 AliHLTPHOSDDLDecoderComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
101 AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr,
102 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
105 cout <<"AliHLTPHOSDDLDecoderComponent::DoEvent()" << endl;
107 //Int_t sampleCnt = 0;
108 //Int_t processedChannels = 0;
112 Int_t tmpChannelCnt = 0;
113 AliHLTUInt8_t* outBPtr;
116 const AliHLTComponentBlockData* iter = NULL;
119 // cout << "evtData.fBlockCnt = " << evtData.fBlockCnt << endl;
121 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
123 // cout << "AliHLTPHOSDDLDecoderComponent::DoEven ndx = " << ndx <<endl;
129 if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
131 // cout << "iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType" << endl;
135 // fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
137 fDecoderPtr->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
138 fDecoderPtr->Decode();
140 fOutPtr = (AliHLTPHOSRcuChannelDataStruct*)outBPtr;
141 mysize += sizeof(AliHLTPHOSRcuChannelDataStruct);
143 fOutPtr->fRcuX = fRcuX;
144 fOutPtr->fRcuZ = fRcuZ;
145 fOutPtr->fModuleID = fModuleID;
148 while(fDecoderPtr->NextChannel(fAltroDataPtr) == true)
150 for(int i= 0; i<fAltroDataPtr->fDataSize;i ++ )
152 fOutPtr->fValidData[tmpChannelCnt].fChannelData[i] = fAltroDataPtr->fData[i];
156 fOutPtr->fValidData[tmpChannelCnt].fDataSize = fAltroDataPtr->fDataSize;
157 fOutPtr->fValidData[tmpChannelCnt].fX = fMapperPtr->hw2geomapPtr[fAltroDataPtr->fHadd].xCol;
158 fOutPtr->fValidData[tmpChannelCnt].fZ = fMapperPtr->hw2geomapPtr[fAltroDataPtr->fHadd].zRow;
159 fOutPtr->fRcuX = fRcuX;
160 fOutPtr->fRcuZ = fRcuZ;
161 fOutPtr->fModuleID = fModuleID;
166 // DumpData(fOutPtr->fValidData[tmpChannelCnt].fChannelData, fOutPtr->fValidData[tmpChannelCnt].fDataSize, 16);
172 for(int i=0; i<tmpChannelCnt; i++)
174 printf("\nDumping data for \n")
181 while(fPHOSRawStream->Next())
183 if (fPHOSRawStream->IsNewHWAddress())
186 fOutPtr->fValidData[tmpChannelCnt].fZ = (AliHLTUInt8_t)fPHOSRawStream->GetColumn() - fRcuZOffset;
187 fOutPtr->fValidData[tmpChannelCnt].fX = (AliHLTUInt8_t)fPHOSRawStream->GetRow() - fRcuXOffset;
188 fOutPtr->fValidData[tmpChannelCnt].fGain = fPHOSRawStream->IsLowGain();
189 fOutPtr->fValidData[tmpChannelCnt].fNSamples = 0;
192 fOutPtr->fValidData[tmpChannelCnt-1].fNSamples ++;
193 fOutPtr->fValidData[tmpChannelCnt-1].fChannelData[sampleCnt] = fPHOSRawStream->GetSignal();
199 fOutPtr->fNValidChannels = tmpChannelCnt-1;
200 // cout << "AliHLTPHOSDDLDecoderComponent::DoEven: setting fOutPtr->fNValidChannels =" << tmpChannelCnt-1<<endl;
202 //int tmpSampleCnt=0;
203 AliHLTComponentBlockData bd;
207 bd.fDataType = AliHLTPHOSDefinitions::fgkCellChannelDataDataType;
208 bd.fSpecification = 0xeFFFFFFF;
209 outputBlocks.push_back( bd);
216 cout <<"kHLTLogFatal, HLT::AliHLTPHOSDDLDecoderComponent::DoEvent Too much data Data written over allowed buffer. Amount written:" << tSize << " allowed" << size << endl;
217 Logging( kHLTLogFatal, "HLT::AliHLTPHOSDDLDecoderComponent::DoEvent", "Too much data", "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.", tSize, size );
223 if(fPrintInfo == kTRUE)
225 if(fPhosEventCount%fPrintInfoFrequncy == 0)
227 cout <<"Analyzing event " << fPhosEventCount << "for Equippment " << fkEquippmentID << endl;
236 AliHLTPHOSDDLDecoderComponent::DoInit( int argc, const char** argv )
238 //See html documentation of base class
240 // fRawMemoryReader = new AliRawReaderMemory();
241 // fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
242 // fPHOSRawStream->SetOldRCUFormat(kFALSE);
246 ScanArguments(argc, argv);
248 if(fIsSetEquippmentID == kFALSE)
251 cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>" << endl;
252 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
253 "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID <number>");
258 // fRawMemoryReader->SetEquipmentID(fkEquippmentID);
265 AliHLTPHOSDDLDecoderComponent::Spawn()
267 //See html documentation of base class
268 return new AliHLTPHOSDDLDecoderComponent;