]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSRawAnalyzerComponent.cxx
Removing this file that was added to CVS by accident
[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 #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"
27
28 //using namespace std;
29
30 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTPHOSRcuProcessor(), fAnalyzerPtr(0), 
31                                                                  fSendChannelData(kFALSE),fOutPtr(0), fMapperPtr(0), fDecoderPtr(0), 
32                                                                  fAltroDataPtr(0), fAltroBunchPtr(0) 
33 {
34   fMapperPtr = new AliHLTPHOSMapper();
35   
36
37
38
39 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
40 {
41   delete  fMapperPtr;
42 }
43
44
45 int 
46 AliHLTPHOSRawAnalyzerComponent::Deinit()
47 {
48   Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen Deinit");
49   return 0;
50 }
51
52
53 const char* 
54 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
55 {
56   return "AliPhosTestRaw";
57 }
58
59
60 void
61 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
62 {
63   const AliHLTComponentDataType* pType=fgkInputDataTypes;
64   while (pType->fID!=0) {
65     list.push_back(*pType);
66     pType++;
67   }
68 }
69
70
71 AliHLTComponentDataType 
72 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
73 {
74   return AliHLTPHOSDefinitions::fgkCellEnergyDataType;
75 }
76
77
78 void
79 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
80
81 {
82   constBase = 30;
83   inputMultiplier = 1;
84 }
85
86
87 int 
88 AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
89 {
90   UInt_t offset           = 0; 
91   UInt_t mysize           = 0;
92   UInt_t tSize            = 0;
93   Int_t tmpChannelCnt     = 0;
94   AliHLTUInt8_t* outBPtr;
95
96   AliHLTAltroBunch *bunchPtr;
97
98   outBPtr = outputPtr;
99   const AliHLTComponentBlockData* iter = NULL; 
100   unsigned long ndx;
101
102   for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
103     {
104       iter = blocks+ndx;
105       mysize = 0;
106       offset = tSize;
107
108       if ( iter->fDataType != AliHLTPHOSDefinitions::fgkDDLPackedRawDataType )
109         {
110           cout <<"WARNING: notAliHLTPHOSDefinitions::fgkDDLPackedRawDataType  "  << endl;
111           //      continue;
112         }
113
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;
119
120       fOutPtr->fModuleID =fModuleID;
121
122       while( fDecoderPtr->NextChannel(fAltroDataPtr) == true )
123         {
124           fAnalyzerPtr->SetData(fAltroDataPtr->fData);
125           fAnalyzerPtr->Evaluate(0, fAltroDataPtr->fDataSize -2);  
126
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();
132           tmpChannelCnt ++;
133         }
134     
135
136       mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
137       fOutPtr->fCnt =  tmpChannelCnt;
138       AliHLTComponentBlockData bd;
139       FillBlockData( bd );
140       bd.fOffset = offset;
141       bd.fSize = mysize;
142  
143       bd.fDataType = AliHLTPHOSDefinitions::fgkCellEnergyDataType;
144       bd.fSpecification = 0xFFFFFFFF;
145       outputBlocks.push_back( bd );
146  
147       tSize += mysize;
148       outBPtr += mysize;
149       
150       if( tSize > size )
151         {
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."
156                    , tSize, size );
157           return EMSGSIZE;
158         }
159       //   fDecoderPtr->GetFailureRate();
160
161     }
162
163   fPhosEventCount++; 
164
165   if(fPrintInfo == kTRUE)
166     {
167       if(fPhosEventCount%fPrintInfoFrequncy == 0)
168         {
169           cout <<"Analyzing event " <<  fPhosEventCount  << "for Equippment " << fkEquippmentID << endl; 
170         }  
171     }
172   size = tSize;
173
174   return 0;
175 }//end DoEvent
176
177
178 int
179 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
180 {
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;
186   fPrintInfo = kFALSE;
187   Reset();
188   int iResult=0;
189   TString argument="";
190   iResult = ScanArguments(argc, argv);
191
192   if(fIsSetEquippmentID == kFALSE)
193     {
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>");
197       iResult = -3; 
198     }
199   else
200     {
201       iResult = 0; 
202       //      fRawMemoryReader->SetEquipmentID(fkEquippmentID);
203     }
204
205   //  return iResult;
206   //  return 0;
207   return iResult;
208 }
209
210
211 void
212 AliHLTPHOSRawAnalyzerComponent::Reset()
213 {
214   for(int mod = 0; mod < N_MODULES; mod ++)
215     {
216       for(int row = 0; row < N_ZROWS_MOD; row ++)
217         {
218           for(int col = 0; col < N_XCOLUMNS_MOD; col ++)
219             {
220               for(int gain = 0; gain < N_GAINS; gain ++ )
221                 {
222                   fMaxValues[mod][row][col][gain] = 0;
223                 }
224             }
225         }
226     }
227
228   ResetDataPtr(0, ALTRO_MAX_SAMPLES);
229
230 } // end Reset
231
232
233 void
234 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
235 {
236   for(int i = startindex ; i< sampleCnt; i++)
237     {
238       fTmpChannelData[i] = 0;
239     }
240 }
241