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 |
28 | const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array |
29 | const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::outputDataType=kAliHLTVoidDataType; |
30 | |
31 | |
9dfd64cf |
32 | //AliHLTPHOSRawAnalyzerComponent gAliHLTPHOSRawAnalyzerComponent; |
ee7849e6 |
33 | //ClassImp(AliHLTPHOSRawAnalyzerComponent) |
ef408bb3 |
34 | AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), fEventCount(0), fEquippmentId(0), fPHOSRawStream(), fRawMemoryReader(0) |
cbab66dd |
35 | { |
9dfd64cf |
36 | // fRawMemoryReader = NULL; |
cbab66dd |
37 | } |
38 | |
39 | AliHLTPHOSRawAnalyzerComponent::~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 | |
ef408bb3 |
54 | AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), fEventCount(0), fEquippmentId(0), fPHOSRawStream(),fRawMemoryReader(0) |
cbab66dd |
55 | { |
9dfd64cf |
56 | // fRawMemoryReader = NULL; |
cbab66dd |
57 | } |
58 | |
9dfd64cf |
59 | |
cbab66dd |
60 | int |
61 | AliHLTPHOSRawAnalyzerComponent::Deinit() |
62 | { |
63 | return 0; |
64 | } |
65 | |
66 | int |
67 | AliHLTPHOSRawAnalyzerComponent::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 |
84 | const char* |
85 | AliHLTPHOSRawAnalyzerComponent::GetComponentID() |
86 | { |
87 | return "AliPhosTestRaw"; |
88 | } |
ee7849e6 |
89 | |
cbab66dd |
90 | void |
ee7849e6 |
91 | AliHLTPHOSRawAnalyzerComponent::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 | |
100 | AliHLTComponentDataType |
101 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataType() |
102 | { |
ee7849e6 |
103 | return outputDataType; |
cbab66dd |
104 | } |
105 | |
106 | void |
9dfd64cf |
107 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) |
108 | |
cbab66dd |
109 | { |
ef408bb3 |
110 | constBase = 30; |
111 | inputMultiplier = 0.1; |
cbab66dd |
112 | } |
113 | |
0a211711 |
114 | |
115 | int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
116 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, |
117 | AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) |
cbab66dd |
118 | { |
ef408bb3 |
119 | |
2947a32c |
120 | Int_t tmpMod = 0; |
121 | Int_t tmpRow = 0; |
122 | Int_t tmpCol = 0; |
123 | Int_t tmpGain = 0; |
124 | Int_t processedChannels = 0; |
ef408bb3 |
125 | |
126 | // AliHLTUInt8_t *tmpOut = &((AliHLTUInt8_t)(GetEquippmentId())); |
127 | |
128 | AliHLTUInt8_t *tmpOut =( AliHLTUInt8_t*)&fEquippmentId; |
129 | |
130 | outputPtr[0] = tmpOut[0]; |
131 | outputPtr[1] = tmpOut[1]; |
132 | |
133 | AliHLTUInt16_t tmpID = *((AliHLTUInt16_t*)(outputPtr)); |
134 | |
135 | cout << "OutputBuffer setting equippment ID to " << tmpID << endl; |
136 | |
2947a32c |
137 | // Int_t tmpMax = 0; |
0a211711 |
138 | const AliHLTComponentBlockData* iter = NULL; |
139 | unsigned long ndx; |
2947a32c |
140 | Reset(); |
141 | |
0a211711 |
142 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
143 | { |
0a211711 |
144 | iter = blocks+ndx; |
ef408bb3 |
145 | |
0a211711 |
146 | if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType ) |
147 | { |
148 | cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl; |
149 | continue; |
150 | } |
ef408bb3 |
151 | |
0a211711 |
152 | fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize ); |
2947a32c |
153 | fRawMemoryReader->DumpData(); |
154 | fRawMemoryReader->RewindEvents(); |
2947a32c |
155 | analyzerPtr->SetData(fTmpChannelData); |
156 | |
157 | while(fPHOSRawStream->Next()) |
158 | { |
159 | if (fPHOSRawStream->IsNewHWAddress()) |
160 | { |
161 | if(processedChannels > 0) |
162 | { |
163 | analyzerPtr->SetData(fTmpChannelData); |
164 | analyzerPtr->Evaluate(0, 1008); |
165 | fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy(); |
166 | ResetDataPtr(); |
167 | } |
168 | |
169 | tmpMod = fPHOSRawStream->GetModule(); |
170 | tmpRow = fPHOSRawStream->GetRow(); |
171 | tmpCol = fPHOSRawStream->GetColumn(); |
172 | tmpGain = fPHOSRawStream->IsLowGain(); |
173 | processedChannels ++; |
174 | } |
175 | |
176 | fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal(); |
177 | } |
178 | } |
179 | DumpData(); |
180 | fEventCount++; |
181 | return 0; |
182 | }//end DoEvent |
0a211711 |
183 | |
184 | |
185 | |
186 | int |
187 | AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) |
188 | { |
2947a32c |
189 | cout << "DOINIT argc =" << argc << endl; |
190 | cout << "DOINIT argv[0] =" << argv[0] << endl; |
191 | cout << "DOINIT argv[1] =" << argv[1] << endl; |
192 | cout << "DOINIT argv[2] =" << argv[2] << endl; |
193 | cout << "DOINIT argv[3] =" << argv[3] << endl; |
194 | cout << "DOINIT argv[4] =" << argv[4] << endl; |
195 | cout << "DOINIT argv[5] =" << argv[5] << endl; |
196 | cout << "DOINIT argv[6] =" << argv[6] << endl; |
197 | |
198 | int equippmentId = atoi(argv[6]); |
199 | cout << "The equipment ID was set to " <<equippmentId << endl; |
200 | |
201 | //fRawMemoryReader->SetEquipmentID(1806); |
202 | |
203 | Reset(); |
0a211711 |
204 | cout << "AliHLTPHOSRawAnalyzerComponent::DoInit Creating new AliRawReaderMemory()" << endl; |
ef408bb3 |
205 | //legoPlotPtr = new TH2S("Lego plot 1","Phi0 20Gev, High gain", 56*5, 0, 56*5, 64, 0, 64); |
0a211711 |
206 | fRawMemoryReader = new AliRawReaderMemory(); |
207 | fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS"); |
2947a32c |
208 | fRawMemoryReader->SetEquipmentID(equippmentId); |
209 | |
ef408bb3 |
210 | SetEquippmentId(equippmentId); |
211 | |
0a211711 |
212 | cout <<"AliHLTPHOSRawAnalyzerComponent::DoIni DONE!" << endl; |
213 | if (argc==0 && argv==NULL) { |
214 | // this is currently just to get rid of the warning "unused parameter" |
215 | } |
216 | return 0; |
217 | } |
9dfd64cf |
218 | |
2947a32c |
219 | void |
220 | AliHLTPHOSRawAnalyzerComponent::DumpData() |
0a211711 |
221 | { |
2947a32c |
222 | for(int mod = 0; mod <5; mod ++) |
223 | { |
224 | printf("\n *********** MODULE %d ************\n", mod); |
225 | for(int row = 0; row < 64; row ++) |
226 | { |
227 | for(int col = 0; col < 56; col ++) |
228 | { |
229 | if( fMaxValues[mod][row][col][0] != 0) |
230 | { |
231 | cout << fMaxValues[mod][row][col][0] << "\t"; |
232 | } |
233 | } |
234 | } |
235 | } |
236 | } |
9dfd64cf |
237 | |
0a211711 |
238 | |
2947a32c |
239 | void |
240 | AliHLTPHOSRawAnalyzerComponent::Reset() |
241 | { |
242 | for(int mod = 0; mod <5; mod ++) |
9dfd64cf |
243 | { |
2947a32c |
244 | for(int row = 0; row < 64; row ++) |
245 | { |
246 | for(int col = 0; col < 56; col ++) |
247 | { |
248 | for(int gain = 0; gain <2; gain ++ ) |
249 | { |
250 | fMaxValues[mod][row][col][gain] = 0; |
251 | } |
252 | } |
253 | } |
254 | } |
9dfd64cf |
255 | |
2947a32c |
256 | for(int i = 0 ; i< 1008; i++) |
257 | { |
258 | fTmpChannelData[i] = 0; |
0a211711 |
259 | } |
2947a32c |
260 | } // end Reset |
9dfd64cf |
261 | |
2947a32c |
262 | void |
263 | AliHLTPHOSRawAnalyzerComponent::ResetDataPtr() |
264 | { |
265 | for(int i = 0 ; i< 1008; i++) |
266 | { |
267 | fTmpChannelData[i] = 0; |
268 | } |
cbab66dd |
269 | } |
ef408bb3 |
270 | |
271 | |
272 | void |
273 | AliHLTPHOSRawAnalyzerComponent::SetEquippmentId(int id) |
274 | { |
275 | fEquippmentId = id; |
276 | } |
277 | |
278 | int |
279 | AliHLTPHOSRawAnalyzerComponent::GetEquippmentId() |
280 | { |
281 | return fEquippmentId; |
282 | } |