]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSDDLDecoderComponent.cxx
Getting rid of trivial warnings.
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSDDLDecoderComponent.cxx
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                                       *
5  *                                                                        * 
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                                * 
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
19
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"
30
31 using namespace std;
32
33
34 AliHLTPHOSDDLDecoderComponent  gAliHLTPHOSDDLDecoderComponent;
35
36
37 AliHLTPHOSDDLDecoderComponent::AliHLTPHOSDDLDecoderComponent():AliHLTPHOSRcuProcessor(), 
38                                                                fDataCorruptorPtr(0), fOutPtr(0), fDecoderPtr(0), fAltroDataPtr(0), fMapperPtr(0)
39 {
40   //Default constructor
41   fDataCorruptorPtr = new AliHLTPHOSDataCorruptor();
42   fAltroDataPtr = new AliHLTAltroData();
43   fDecoderPtr = new AliHLTDDLDecoder();
44   fMapperPtr = new AliHLTPHOSMapper();
45
46
47 AliHLTPHOSDDLDecoderComponent::~AliHLTPHOSDDLDecoderComponent()
48 {
49   //comment
50 }
51
52 int 
53 AliHLTPHOSDDLDecoderComponent::Deinit()
54 {
55   //Se html documentation of base class
56   cout <<  "Deinit" << endl;
57   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
58   return 0;
59 }
60
61
62 const char* 
63 AliHLTPHOSDDLDecoderComponent::GetComponentID()
64 {
65   //Se html documentation of base class
66   return "PhosDDLDecoder";
67 }
68
69
70
71 void
72 AliHLTPHOSDDLDecoderComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
73 {
74   //Se html documentation of base class
75   const AliHLTComponentDataType* pType=fgkInputDataTypes;
76   while (pType->fID!=0) {
77     list.push_back(*pType);
78     pType++;
79   }
80 }
81
82 AliHLTComponentDataType 
83 AliHLTPHOSDDLDecoderComponent::GetOutputDataType()
84 {
85   //See html documentation of base class
86   return AliHLTPHOSDefinitions::fgkCellChannelDataDataType;
87 }
88
89 void
90 AliHLTPHOSDDLDecoderComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
91
92 {
93   //Se html documentation of base class
94   constBase = 30;
95   inputMultiplier = 1;
96 }
97
98
99 int
100 AliHLTPHOSDDLDecoderComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
101                                               AliHLTComponentTriggerData& /*trigData*/, AliHLTUInt8_t* outputPtr, 
102                                               AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
103 {
104   //comment
105   cout <<"AliHLTPHOSDDLDecoderComponent::DoEvent()" << endl;
106
107   //Int_t sampleCnt         = 0;
108   //Int_t processedChannels = 0;
109   UInt_t offset           = 0; 
110   UInt_t mysize           = 0;
111   UInt_t tSize            = 0;
112   Int_t tmpChannelCnt     = 0;
113   AliHLTUInt8_t* outBPtr;
114  
115   outBPtr = outputPtr;
116   const AliHLTComponentBlockData* iter = NULL; 
117   unsigned long ndx;
118
119   //  cout << "evtData.fBlockCnt = " <<   evtData.fBlockCnt  << endl;
120
121   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
122     {
123       //     cout << "AliHLTPHOSDDLDecoderComponent::DoEven ndx = " <<  ndx   <<endl;
124       iter = blocks+ndx;
125       mysize = 0;
126       tmpChannelCnt = 0;
127       offset = tSize;
128
129       if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
130         {
131           //      cout << "iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType" << endl;
132           continue;
133         }
134
135      //  fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
136
137       fDecoderPtr->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
138       fDecoderPtr->Decode();
139
140       fOutPtr =  (AliHLTPHOSRcuChannelDataStruct*)outBPtr;
141       mysize += sizeof(AliHLTPHOSRcuChannelDataStruct);
142       
143       fOutPtr->fRcuX = fRcuX;
144       fOutPtr->fRcuZ = fRcuZ;
145       fOutPtr->fModuleID = fModuleID;
146       tmpChannelCnt = 0;
147
148       while(fDecoderPtr->NextChannel(fAltroDataPtr) == true)
149         {
150           for(int i= 0; i<fAltroDataPtr->fDataSize;i ++ )
151             {
152               fOutPtr->fValidData[tmpChannelCnt].fChannelData[i] = fAltroDataPtr->fData[i];
153             }
154
155
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;
162           tmpChannelCnt++;
163
164           //      DumpData();
165           //      printf("\n");
166           //      DumpData(fOutPtr->fValidData[tmpChannelCnt].fChannelData, fOutPtr->fValidData[tmpChannelCnt].fDataSize, 16);
167           //      printf("\n");
168           
169         }
170
171       /*      
172       for(int i=0; i<tmpChannelCnt; i++)
173         {
174           printf("\nDumping data for   \n")
175  
176         }
177       */
178
179
180      /*
181       while(fPHOSRawStream->Next())
182         {
183           if (fPHOSRawStream->IsNewHWAddress())
184             {
185               sampleCnt = 0;
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;
190               tmpChannelCnt++;
191             }
192           fOutPtr->fValidData[tmpChannelCnt-1].fNSamples ++;
193           fOutPtr->fValidData[tmpChannelCnt-1].fChannelData[sampleCnt] = fPHOSRawStream->GetSignal();
194           sampleCnt ++; 
195         }
196      */
197
198
199       fOutPtr->fNValidChannels = tmpChannelCnt-1;
200       //      cout <<  "AliHLTPHOSDDLDecoderComponent::DoEven: setting  fOutPtr->fNValidChannels ="  << tmpChannelCnt-1<<endl;
201
202       //int tmpSampleCnt=0;
203       AliHLTComponentBlockData bd;
204       FillBlockData( bd );
205       bd.fOffset = offset;
206       bd.fSize = mysize;
207       bd.fDataType = AliHLTPHOSDefinitions::fgkCellChannelDataDataType;
208       bd.fSpecification = 0xeFFFFFFF;
209       outputBlocks.push_back( bd);
210       tSize += mysize;
211       outBPtr += mysize;
212     }
213   
214   if( tSize > size )
215     {
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 );
218       return EMSGSIZE;
219     }
220
221   fPhosEventCount++; 
222   
223   if(fPrintInfo == kTRUE)
224     {
225       if(fPhosEventCount%fPrintInfoFrequncy == 0)
226         {
227           cout <<"Analyzing event " <<  fPhosEventCount  << "for Equippment " << fkEquippmentID << endl; 
228         }  
229     }
230   size = tSize;
231   return 0;
232 }//end DoEvent
233
234
235 int
236 AliHLTPHOSDDLDecoderComponent::DoInit( int argc, const char** argv )
237 {
238   //See html documentation of base class 
239   fPrintInfo = kFALSE;
240   // fRawMemoryReader = new AliRawReaderMemory();
241   // fPHOSRawStream = new  AliCaloRawStream(fRawMemoryReader,"PHOS");
242   // fPHOSRawStream->SetOldRCUFormat(kFALSE);
243
244   int iResult=0;
245   TString argument="";
246   ScanArguments(argc, argv);
247
248   if(fIsSetEquippmentID == kFALSE)
249
250     {
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>");
254       iResult = -2; 
255     }
256   else
257     {
258       //     fRawMemoryReader->SetEquipmentID(fkEquippmentID);
259     }
260
261   return iResult;
262 }
263
264 AliHLTComponent*
265 AliHLTPHOSDDLDecoderComponent::Spawn()
266 {
267   //See html documentation of base class 
268   return new AliHLTPHOSDDLDecoderComponent;
269 }