]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzerComponent.cxx
Included AliHLTPHOSConstnts.h where needed
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzerComponent.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 /// @class AliHLTPHOSRawAnalyzerComponent
21 /// Base class of PHOS HLT online raw analysis component.
22 /// The class provides a common interface for the implementation of PHOS 
23 /// HLT raw data
24 /// processors components. The class is intended for processing of 
25 /// arrays of raw data samples to evaluate energy and timing.
26 /// The Energy will be given in entities of ADC leves ranging from 0 to
27 /// 1023. Timing will be given in entities of samples periods.
28 /// Drived clases  must implement the fucntions
29 /// - @ref GetComponentID
30 /// - @ref Spawn
31
32 #include "AliHLTPHOSRawAnalyzer.h"
33 #include "AliHLTPHOSRawAnalyzerComponent.h"
34 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
35 #include "AliHLTPHOSRcuChannelDataStruct.h"
36 #include "AliHLTDDLDecoder.h"
37 #include "AliHLTAltroData.h"
38 #include "AliHLTPHOSMapper.h"
39
40
41 using namespace std;
42
43 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTPHOSProcessor(), fAnalyzerPtr(0), 
44 fSendChannelData(kFALSE),fOutPtr(0)
45 {
46   fMapperPtr = new AliHLTPHOSMapper();
47
48
49
50 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
51 {
52
53 }
54
55
56 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTPHOSProcessor(), fAnalyzerPtr(0), 
57 fSendChannelData(kFALSE),fOutPtr(0)
58 {
59
60 }
61
62
63 int 
64 AliHLTPHOSRawAnalyzerComponent::Deinit()
65 {
66   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen Deinit");
67   return 0;
68 }
69
70
71 const char* 
72 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
73 {
74   return "AliPhosTestRaw";
75 }
76
77
78 void
79 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
80 {
81   const AliHLTComponentDataType* pType=fgkInputDataTypes;
82   while (pType->fID!=0) {
83     list.push_back(*pType);
84     pType++;
85   }
86 }
87
88
89 AliHLTComponentDataType 
90 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
91 {
92   return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
93 }
94
95
96 void
97 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
98
99 {
100   constBase = 30;
101   inputMultiplier = 1;
102 }
103
104
105 int 
106 AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
107 {
108   UInt_t offset           = 0; 
109   UInt_t mysize           = 0;
110   UInt_t tSize            = 0;
111   Int_t tmpChannelCnt     = 0;
112   AliHLTUInt8_t* outBPtr;
113   outBPtr = outputPtr;
114   const AliHLTComponentBlockData* iter = NULL; 
115   unsigned long ndx;
116
117   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
118     {
119       iter = blocks+ndx;
120       mysize = 0;
121       offset = tSize;
122
123       if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
124         {
125           cout <<"WARNING: notAliHLTPHOSDefinitions::fgkDDLPackedRawDataTyp  "  << endl;
126           //      continue;
127         }
128
129       fDecoderPtr->SetMemory(reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize);
130       fDecoderPtr->Decode();
131       fOutPtr =  (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
132
133       while( fDecoderPtr->NextChannel(fAltroDataPtr) == true )
134         {
135
136           fAnalyzerPtr->SetData(fAltroDataPtr->fData);
137           fAnalyzerPtr->Evaluate(0, fAltroDataPtr->fDataSize -2);  
138
139           fOutPtr->fValidData[tmpChannelCnt].fGain = fMapperPtr->ALTRO_MAP[fAltroDataPtr->fHadd].gain;
140           fOutPtr->fValidData[tmpChannelCnt].fZ  = fMapperPtr->ALTRO_MAP[fAltroDataPtr->fHadd].row;
141           fOutPtr->fValidData[tmpChannelCnt].fX  = fMapperPtr->ALTRO_MAP[fAltroDataPtr->fHadd].col; 
142           fOutPtr->fValidData[tmpChannelCnt].fEnergy  = (float)fAnalyzerPtr->GetEnergy();
143           fOutPtr->fValidData[tmpChannelCnt].fTime    = (float)fAnalyzerPtr->GetTiming();
144           tmpChannelCnt ++;
145         }
146
147       mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
148
149       fOutPtr->fCnt =  tmpChannelCnt;
150       AliHLTComponentBlockData bd;
151       FillBlockData( bd );
152       bd.fOffset = offset;
153       bd.fSize = mysize;
154  
155       bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType;
156       bd.fSpecification = 0xFFFFFFFF;
157       outputBlocks.push_back( bd );
158  
159       tSize += mysize;
160       outBPtr += mysize;
161       
162       if( tSize > size )
163         {
164           cout <<"kHLTLogFatal, HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent Too much dataData written over allowed buffer. Amount written:"
165                << tSize << " allowed" << size << endl;
166           Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
167                    "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
168                    , tSize, size );
169           return EMSGSIZE;
170         }
171     }
172
173   fPhosEventCount++; 
174
175   if(fPrintInfo == kTRUE)
176     {
177       if(fPhosEventCount%fPrintInfoFrequncy == 0)
178         {
179           cout <<"Analyzing event " <<  fPhosEventCount  << "for Equippment " << fkEquippmentID << endl; 
180         }  
181     }
182   size = tSize;
183
184   return 0;
185 }//end DoEvent
186
187
188 int
189 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
190 {
191   cout <<"AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) "<< endl;
192   fAltroDataPtr = new AliHLTAltroData();
193   fDecoderPtr = new AliHLTDDLDecoder();
194   fSendChannelData = kFALSE;
195   fPrintInfo = kFALSE;
196   Reset();
197   int iResult=0;
198   TString argument="";
199   iResult = ScanArguments(argc, argv);
200
201   if(fIsSetEquippmentID == kFALSE)
202     {
203       cout << "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID  <number>" << endl;
204       Logging( kHLTLogFatal, "HLT::AliHLTPHOSRcuHistogramProducerComponent::DoInt( int argc, const char** argv )", "Missing argument",
205                "The argument equippmentID is not set: set it with a component argumet like this: -equippmentID  <number>");
206       iResult = -3; 
207     }
208   else
209     {
210       iResult = 0; 
211       //      fRawMemoryReader->SetEquipmentID(fkEquippmentID);
212     }
213
214   //  return iResult;
215   //  return 0;
216   return iResult;
217 }
218
219
220 void
221 AliHLTPHOSRawAnalyzerComponent::Reset()
222 {
223   for(int mod = 0; mod < N_MODULES; mod ++)
224     {
225       for(int row = 0; row < N_ROWS_MOD; row ++)
226         {
227           for(int col = 0; col < N_COLUMNS_MOD; col ++)
228             {
229               for(int gain = 0; gain < N_GAINS; gain ++ )
230                 {
231                   fMaxValues[mod][row][col][gain] = 0;
232                 }
233             }
234         }
235     }
236
237   ResetDataPtr(0, ALTRO_MAX_SAMPLES);
238
239 } // end Reset
240
241
242 void
243 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
244 {
245   for(int i = startindex ; i< sampleCnt; i++)
246     {
247       fTmpChannelData[i] = 0;
248     }
249 }
250