First working implementation of the online cell energy/time evaluation. The
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzerComponent.cxx
CommitLineData
9dfd64cf 1
cbab66dd 2/**************************************************************************
3 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
4 * *
5 * Author: Per Thomas Hille for the ALICE HLT Project. *
6 * Contributors are mentioned in the code where appropriate. *
7 * *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
16
17#include "AliHLTPHOSRawAnalyzerComponent.h"
18#include <iostream>
9dfd64cf 19#include "stdio.h"
0a211711 20
9dfd64cf 21#include "AliRawReaderMemory.h"
0a211711 22#include "AliCaloRawStream.h"
2947a32c 23#include <cstdlib>
24//#include "TH2.h"
0a211711 25
26//#include "AliHLTTPCDefinitions.h"
cbab66dd 27
ee7849e6 28const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
29const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::outputDataType=kAliHLTVoidDataType;
30
31
9dfd64cf 32//AliHLTPHOSRawAnalyzerComponent gAliHLTPHOSRawAnalyzerComponent;
ee7849e6 33//ClassImp(AliHLTPHOSRawAnalyzerComponent)
0a211711 34AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), eventCount(0), fPHOSRawStream(), fRawMemoryReader(0)
cbab66dd 35{
9dfd64cf 36 // fRawMemoryReader = NULL;
cbab66dd 37}
38
39AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
40{
0a211711 41 if(fRawMemoryReader != 0)
42 {
43 delete fRawMemoryReader;
44 }
45 if(fPHOSRawStream != 0)
46 {
47 delete fPHOSRawStream;
48 }
49
cbab66dd 50}
51
52
0a211711 53
54AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), eventCount(0), fPHOSRawStream(),fRawMemoryReader(0)
cbab66dd 55{
9dfd64cf 56 // fRawMemoryReader = NULL;
cbab66dd 57}
58
9dfd64cf 59
cbab66dd 60int
61AliHLTPHOSRawAnalyzerComponent::Deinit()
62{
63 return 0;
64}
65
66int
67AliHLTPHOSRawAnalyzerComponent::DoDeinit()
68{
9dfd64cf 69 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
70
0a211711 71 if(fRawMemoryReader !=0)
72 {
73 delete fRawMemoryReader;
74 }
75
76 if(fPHOSRawStream != 0)
77 {
78 delete fPHOSRawStream;
79 }
cbab66dd 80 return 0;
cbab66dd 81
cbab66dd 82}
83
9dfd64cf 84const char*
85AliHLTPHOSRawAnalyzerComponent::GetComponentID()
86{
87 return "AliPhosTestRaw";
88}
ee7849e6 89
cbab66dd 90void
ee7849e6 91AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
cbab66dd 92{
ee7849e6 93 const AliHLTComponentDataType* pType=inputDataTypes;
94 while (pType->fID!=0) {
95 list.push_back(*pType);
96 pType++;
97 }
cbab66dd 98}
99
100AliHLTComponentDataType
101AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
102{
ee7849e6 103 return outputDataType;
cbab66dd 104}
105
106void
9dfd64cf 107AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
108
cbab66dd 109{
ee7849e6 110 constBase = 0;inputMultiplier = 0;
cbab66dd 111}
112
0a211711 113
114int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
115 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
116 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
cbab66dd 117{
2947a32c 118 Int_t tmpMod = 0;
119 Int_t tmpRow = 0;
120 Int_t tmpCol = 0;
121 Int_t tmpGain = 0;
122 Int_t processedChannels = 0;
123 // Int_t tmpMax = 0;
0a211711 124 const AliHLTComponentBlockData* iter = NULL;
125 unsigned long ndx;
2947a32c 126 Reset();
127
0a211711 128 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
129 {
0a211711 130 iter = blocks+ndx;
2947a32c 131 if (eventCount == 0)
132 {
133 continue;
134 }
0a211711 135
0a211711 136 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
137 {
138 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
139 continue;
140 }
0a211711 141 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
2947a32c 142 fRawMemoryReader->DumpData();
143 fRawMemoryReader->RewindEvents();
0a211711 144
2947a32c 145 analyzerPtr->SetData(fTmpChannelData);
146
147 while(fPHOSRawStream->Next())
148 {
149 if (fPHOSRawStream->IsNewHWAddress())
150 {
151 if(processedChannels > 0)
152 {
153 analyzerPtr->SetData(fTmpChannelData);
154 analyzerPtr->Evaluate(0, 1008);
155 fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
156 ResetDataPtr();
157 }
158
159 tmpMod = fPHOSRawStream->GetModule();
160 tmpRow = fPHOSRawStream->GetRow();
161 tmpCol = fPHOSRawStream->GetColumn();
162 tmpGain = fPHOSRawStream->IsLowGain();
163 processedChannels ++;
164 }
165
166 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
167 }
168 }
169 DumpData();
170 fEventCount++;
171 return 0;
172}//end DoEvent
0a211711 173
174
175
176int
177AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
178{
2947a32c 179 cout << "DOINIT argc =" << argc << endl;
180 cout << "DOINIT argv[0] =" << argv[0] << endl;
181 cout << "DOINIT argv[1] =" << argv[1] << endl;
182 cout << "DOINIT argv[2] =" << argv[2] << endl;
183 cout << "DOINIT argv[3] =" << argv[3] << endl;
184 cout << "DOINIT argv[4] =" << argv[4] << endl;
185 cout << "DOINIT argv[5] =" << argv[5] << endl;
186 cout << "DOINIT argv[6] =" << argv[6] << endl;
187
188 int equippmentId = atoi(argv[6]);
189 cout << "The equipment ID was set to " <<equippmentId << endl;
190
191 //fRawMemoryReader->SetEquipmentID(1806);
192
193 Reset();
0a211711 194 cout << "AliHLTPHOSRawAnalyzerComponent::DoInit Creating new AliRawReaderMemory()" << endl;
2947a32c 195 legoPlotPtr = new TH2S("Lego plot 1","Phi0 20Gev, High gain", 56*5, 0, 56*5, 64, 0, 64);
0a211711 196 fRawMemoryReader = new AliRawReaderMemory();
197 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
2947a32c 198 fRawMemoryReader->SetEquipmentID(equippmentId);
199
0a211711 200 cout <<"AliHLTPHOSRawAnalyzerComponent::DoIni DONE!" << endl;
201 if (argc==0 && argv==NULL) {
202 // this is currently just to get rid of the warning "unused parameter"
203 }
204 return 0;
205}
9dfd64cf 206
2947a32c 207void
208AliHLTPHOSRawAnalyzerComponent::DumpData()
0a211711 209{
2947a32c 210 for(int mod = 0; mod <5; mod ++)
211 {
212 printf("\n *********** MODULE %d ************\n", mod);
213 for(int row = 0; row < 64; row ++)
214 {
215 for(int col = 0; col < 56; col ++)
216 {
217 if( fMaxValues[mod][row][col][0] != 0)
218 {
219 cout << fMaxValues[mod][row][col][0] << "\t";
220 }
221 }
222 }
223 }
224}
9dfd64cf 225
0a211711 226
2947a32c 227void
228AliHLTPHOSRawAnalyzerComponent::Reset()
229{
230 for(int mod = 0; mod <5; mod ++)
9dfd64cf 231 {
2947a32c 232 for(int row = 0; row < 64; row ++)
233 {
234 for(int col = 0; col < 56; col ++)
235 {
236 for(int gain = 0; gain <2; gain ++ )
237 {
238 fMaxValues[mod][row][col][gain] = 0;
239 }
240 }
241 }
242 }
9dfd64cf 243
2947a32c 244 for(int i = 0 ; i< 1008; i++)
245 {
246 fTmpChannelData[i] = 0;
0a211711 247 }
2947a32c 248} // end Reset
9dfd64cf 249
2947a32c 250void
251AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
252{
253 for(int i = 0 ; i< 1008; i++)
254 {
255 fTmpChannelData[i] = 0;
256 }
cbab66dd 257}