]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSDDLDecoderComponent.cxx
Added new files to build system
[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 <iostream>
22 #include "AliRawReaderMemory.h"
23 #include "AliCaloRawStream.h"
24 #include "AliHLTPHOSRcuChannelDataStruct.h"
25 #include "AliHLTPHOSPulseGenerator.h"
26 #include "AliHLTPHOSDataCorruptor.h"
27
28
29 using namespace std;
30
31
32 AliHLTPHOSDDLDecoderComponent  gAliHLTPHOSDDLDecoderComponent;
33
34
35 AliHLTPHOSDDLDecoderComponent::AliHLTPHOSDDLDecoderComponent():AliHLTPHOSProcessor(), fPHOSRawStream(0), fRawMemoryReader(0), 
36 fOutPtr(0), fDataCorruptorPtr(0)
37 {
38   //Default constructor
39   fDataCorruptorPtr = new AliHLTPHOSDataCorruptor();
40
41
42 AliHLTPHOSDDLDecoderComponent::~AliHLTPHOSDDLDecoderComponent()
43 {
44   //Destructor
45   delete  fRawMemoryReader;
46   delete  fPHOSRawStream;
47   delete  fDataCorruptorPtr;
48 }
49
50
51 AliHLTPHOSDDLDecoderComponent::AliHLTPHOSDDLDecoderComponent(const AliHLTPHOSDDLDecoderComponent & ) : AliHLTPHOSProcessor(), 
52 fPHOSRawStream(0),fRawMemoryReader(0), fOutPtr(0), fDataCorruptorPtr(0)
53 {
54
55 }
56
57
58 int 
59 AliHLTPHOSDDLDecoderComponent::Deinit()
60 {
61   //Se html documentation of base class
62   cout <<  "Deinit" << endl;
63   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
64
65   if(fRawMemoryReader !=0)
66     {
67       delete fRawMemoryReader;
68     }
69     
70   if(fPHOSRawStream != 0)
71     {
72       delete fPHOSRawStream;
73     }
74   return 0;
75
76   return 0;
77 }
78
79
80 const char* 
81 AliHLTPHOSDDLDecoderComponent::GetComponentID()
82 {
83   //Se html documentation of base class
84   return "PhosDDLDecoder";
85 }
86
87
88
89 void
90 AliHLTPHOSDDLDecoderComponent::GetInputDataTypes(vector<AliHLTComponentDataType>& list)
91 {
92   //Se html documentation of base class
93   const AliHLTComponentDataType* pType=fgkInputDataTypes;
94   while (pType->fID!=0) {
95     list.push_back(*pType);
96     pType++;
97   }
98 }
99
100 AliHLTComponentDataType 
101 AliHLTPHOSDDLDecoderComponent::GetOutputDataType()
102 {
103   //See html documentation of base class
104   return AliHLTPHOSDefinitions::fgkCellChannelDataDataType;
105 }
106
107 void
108 AliHLTPHOSDDLDecoderComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
109
110 {
111   //Se html documentation of base class
112   constBase = 30;
113   inputMultiplier = 1;
114 }
115
116
117 int
118 AliHLTPHOSDDLDecoderComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, 
119                                               AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, 
120                                               AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
121 {
122   Int_t sampleCnt         = 0;
123   Int_t processedChannels = 0;
124   UInt_t offset           = 0; 
125   UInt_t mysize           = 0;
126   UInt_t tSize            = 0;
127
128   Int_t tmpChannelCnt     = 0;
129  
130   AliHLTUInt8_t* outBPtr;
131  
132   outBPtr = outputPtr;
133   const AliHLTComponentBlockData* iter = NULL; 
134   unsigned long ndx;
135
136   //  cout << "evtData.fBlockCnt = " <<   evtData.fBlockCnt  << endl;
137
138   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
139     {
140       //     cout << "AliHLTPHOSDDLDecoderComponent::DoEven ndx = " <<  ndx   <<endl;
141       iter = blocks+ndx;
142       mysize = 0;
143       tmpChannelCnt = 0;
144       offset = tSize;
145
146       
147       if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
148         {
149           //      cout << "iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType" << endl;
150           continue;
151         }
152
153       fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
154       fOutPtr =  (AliHLTPHOSRcuChannelDataStruct*)outBPtr;
155       mysize += sizeof(AliHLTPHOSRcuChannelDataStruct);
156       fOutPtr->fRcuX = fRcuX;
157       fOutPtr->fRcuZ = fRcuZ;
158       fOutPtr->fModuleID = fModuleID;
159
160       tmpChannelCnt = 0;
161
162       while(fPHOSRawStream->Next())
163         {
164           if (fPHOSRawStream->IsNewHWAddress())
165             {
166               sampleCnt = 0;
167               fOutPtr->fValidData[tmpChannelCnt].fZ = (AliHLTUInt8_t)fPHOSRawStream->GetColumn() - fRcuZOffset;
168               fOutPtr->fValidData[tmpChannelCnt].fX = (AliHLTUInt8_t)fPHOSRawStream->GetRow() - fRcuXOffset;
169               fOutPtr->fValidData[tmpChannelCnt].fGain = fPHOSRawStream->IsLowGain();
170               fOutPtr->fValidData[tmpChannelCnt].fNSamples = 0;
171               tmpChannelCnt++;
172             }
173           fOutPtr->fValidData[tmpChannelCnt-1].fNSamples ++;
174           fOutPtr->fValidData[tmpChannelCnt-1].fChannelData[sampleCnt] = fPHOSRawStream->GetSignal();
175           sampleCnt ++; 
176         }
177
178       fOutPtr->fNValidChannels = tmpChannelCnt-1;
179       //      cout <<  "AliHLTPHOSDDLDecoderComponent::DoEven: setting  fOutPtr->fNValidChannels ="  << tmpChannelCnt-1<<endl;
180
181       int tmpSampleCnt=0;
182       AliHLTComponentBlockData bd;
183       FillBlockData( bd );
184       bd.fOffset = offset;
185       bd.fSize = mysize;
186       bd.fDataType = AliHLTPHOSDefinitions::fgkCellChannelDataDataType;
187       bd.fSpecification = 0xeFFFFFFF;
188       outputBlocks.push_back( bd);
189       tSize += mysize;
190       outBPtr += mysize;
191     }
192   
193   if( tSize > size )
194     {
195       cout <<"kHLTLogFatal, HLT::AliHLTPHOSDDLDecoderComponent::DoEvent Too much data Data written over allowed buffer. Amount written:" << tSize << " allowed" << size << endl;
196       Logging( kHLTLogFatal, "HLT::AliHLTPHOSDDLDecoderComponent::DoEvent", "Too much data", "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu.",  tSize, size );
197       return EMSGSIZE;
198     }
199
200   fPhosEventCount++; 
201   
202   if(fPrintInfo == kTRUE)
203     {
204       if(fPhosEventCount%fPrintInfoFrequncy == 0)
205         {
206           cout <<"Analyzing event " <<  fPhosEventCount  << "for Equippment " << fkEquippmentID << endl; 
207         }  
208     }
209   size = tSize;
210   return 0;
211 }//end DoEvent
212
213
214 int
215 AliHLTPHOSDDLDecoderComponent::DoInit( int argc, const char** argv )
216 {
217   //See html documentation of base class 
218   fPrintInfo = kFALSE;
219   fRawMemoryReader = new AliRawReaderMemory();
220   fPHOSRawStream = new  AliCaloRawStream(fRawMemoryReader,"PHOS");
221   fPHOSRawStream->SetOldRCUFormat(kFALSE);
222   int iResult=0;
223   TString argument="";
224   ScanArguments(argc, argv);
225
226   if(fIsSetEquippmentID == kFALSE)
227
228     {
229       cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID  <number>" << endl;
230       Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
231                "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID  <number>");
232       iResult = -2; 
233     }
234   else
235     {
236       fRawMemoryReader->SetEquipmentID(fkEquippmentID);
237     }
238
239   return iResult;
240 }
241
242 AliHLTComponent*
243 AliHLTPHOSDDLDecoderComponent::Spawn()
244 {
245   //See html documentation of base class 
246   return new AliHLTPHOSDDLDecoderComponent;
247 }