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" |
23 | |
24 | //#include "AliHLTTPCDefinitions.h" |
cbab66dd |
25 | |
ee7849e6 |
26 | const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array |
27 | const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::outputDataType=kAliHLTVoidDataType; |
28 | |
29 | |
9dfd64cf |
30 | //AliHLTPHOSRawAnalyzerComponent gAliHLTPHOSRawAnalyzerComponent; |
ee7849e6 |
31 | //ClassImp(AliHLTPHOSRawAnalyzerComponent) |
0a211711 |
32 | AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), eventCount(0), fPHOSRawStream(), fRawMemoryReader(0) |
cbab66dd |
33 | { |
9dfd64cf |
34 | // fRawMemoryReader = NULL; |
cbab66dd |
35 | } |
36 | |
37 | AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent() |
38 | { |
0a211711 |
39 | if(fRawMemoryReader != 0) |
40 | { |
41 | delete fRawMemoryReader; |
42 | } |
43 | if(fPHOSRawStream != 0) |
44 | { |
45 | delete fPHOSRawStream; |
46 | } |
47 | |
cbab66dd |
48 | } |
49 | |
50 | |
0a211711 |
51 | |
52 | AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), eventCount(0), fPHOSRawStream(),fRawMemoryReader(0) |
cbab66dd |
53 | { |
9dfd64cf |
54 | // fRawMemoryReader = NULL; |
cbab66dd |
55 | } |
56 | |
9dfd64cf |
57 | |
cbab66dd |
58 | int |
59 | AliHLTPHOSRawAnalyzerComponent::Deinit() |
60 | { |
61 | return 0; |
62 | } |
63 | |
64 | int |
65 | AliHLTPHOSRawAnalyzerComponent::DoDeinit() |
66 | { |
9dfd64cf |
67 | Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit"); |
68 | |
0a211711 |
69 | if(fRawMemoryReader !=0) |
70 | { |
71 | delete fRawMemoryReader; |
72 | } |
73 | |
74 | if(fPHOSRawStream != 0) |
75 | { |
76 | delete fPHOSRawStream; |
77 | } |
cbab66dd |
78 | return 0; |
cbab66dd |
79 | |
cbab66dd |
80 | } |
81 | |
9dfd64cf |
82 | const char* |
83 | AliHLTPHOSRawAnalyzerComponent::GetComponentID() |
84 | { |
85 | return "AliPhosTestRaw"; |
86 | } |
ee7849e6 |
87 | |
cbab66dd |
88 | void |
ee7849e6 |
89 | AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) |
cbab66dd |
90 | { |
ee7849e6 |
91 | const AliHLTComponentDataType* pType=inputDataTypes; |
92 | while (pType->fID!=0) { |
93 | list.push_back(*pType); |
94 | pType++; |
95 | } |
cbab66dd |
96 | } |
97 | |
98 | AliHLTComponentDataType |
99 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataType() |
100 | { |
ee7849e6 |
101 | return outputDataType; |
cbab66dd |
102 | } |
103 | |
104 | void |
9dfd64cf |
105 | AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier ) |
106 | |
cbab66dd |
107 | { |
ee7849e6 |
108 | constBase = 0;inputMultiplier = 0; |
cbab66dd |
109 | } |
110 | |
0a211711 |
111 | |
112 | int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, |
113 | AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, |
114 | AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks ) |
cbab66dd |
115 | { |
0a211711 |
116 | // int tmpCnt = 0; |
117 | cout << "processing Event" << endl; |
118 | const AliHLTComponentBlockData* iter = NULL; |
119 | unsigned long ndx; |
120 | |
121 | for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ ) |
122 | { |
123 | cout <<"Inside for loop ndx =" << ndx << endl; |
124 | iter = blocks+ndx; |
125 | |
126 | if (eventCount == 0) |
127 | { |
128 | continue; |
129 | } |
130 | |
131 | |
132 | if ( iter->fDataType == AliHLTPHOSDefinitions::gkDDLPackedRawDataType ) cout << "data type is :gkDDLPackedRawDataType " <<endl; |
133 | if ( iter->fDataType == AliHLTPHOSDefinitions::gkPackedRawDataType ) cout << "data type is : gkPackedRawDataType" <<endl; |
134 | if ( iter->fDataType == AliHLTPHOSDefinitions::gkUnpackedRawDataType) cout << "data type is gkUnpackedRawDataType" <<endl; |
135 | if ( iter->fDataType == AliHLTPHOSDefinitions::gkClustersDataType) cout << "data type is ::gkClustersDataType" <<endl; |
136 | if ( iter->fDataType == AliHLTPHOSDefinitions::gkVertexDataType ) cout << "data type is ::gkVertexDataType " <<endl; |
137 | if ( iter->fDataType == AliHLTPHOSDefinitions::gkTrackSegmentsDataType) cout << "data type is :::gkTrackSegmentsDataType" <<endl; |
138 | |
139 | if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType ) |
140 | { |
141 | cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl; |
142 | continue; |
143 | } |
144 | |
145 | cout <<"PHOSHLT DoEvent: processing event:"<< eventCount << endl; |
146 | cout <<"Struct size = " << evtData.fStructSize << endl; |
147 | cout <<"Event ID = " <<evtData.fEventID << endl; |
148 | cout <<"Block count = " <<evtData.fBlockCnt << endl; |
149 | cout <<"Block size = " << blocks->fSize << endl; |
150 | cout <<"printing out start od data block" << endl; |
151 | // cout << "content of data pointer =" << tmpDtaPtr << endl; |
152 | |
153 | // UChar_t *tmpDtaPtr = (UChar_t *)blocks->fPtr; |
154 | UInt_t *tmpDtaPtr = (UInt_t *)blocks->fPtr; |
155 | |
156 | |
157 | for(unsigned int i = 0; i < 15; i++) |
158 | { |
159 | // getc(); |
160 | // sleep(10); |
161 | // printf("\ntype return to continue; "); |
162 | // getc(stdin); |
163 | // printf("\nThanks; read in \n"); |
164 | cout << "entry:" <<i <<" = " << *tmpDtaPtr << endl; |
165 | tmpDtaPtr ++; |
166 | // cout << "entry:" <<i <<" = " << *blocks << endl; |
167 | // blocks ++; |
168 | } |
169 | |
170 | |
171 | fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize ); |
172 | bool readValue = true; |
173 | |
9dfd64cf |
174 | |
0a211711 |
175 | cout << endl << "eventCount =" << eventCount << endl; |
176 | fRawMemoryReader->DumpData(); |
177 | |
178 | readValue = fPHOSRawStream->Next(); |
179 | // fPHOSRawStream->Next(); |
180 | |
181 | while( readValue ) |
182 | { |
183 | cout <<"reading value" << endl; |
184 | readValue = fPHOSRawStream->Next(); |
185 | } |
186 | cout << "end of for lop" << endl; |
187 | } |
9dfd64cf |
188 | |
0a211711 |
189 | eventCount++; |
9dfd64cf |
190 | |
0a211711 |
191 | return 0; |
192 | } |
193 | |
194 | |
195 | |
196 | int |
197 | AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv ) |
198 | { |
199 | cout << "AliHLTPHOSRawAnalyzerComponent::DoInit Creating new AliRawReaderMemory()" << endl; |
200 | fRawMemoryReader = new AliRawReaderMemory(); |
201 | fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS"); |
202 | cout <<"AliHLTPHOSRawAnalyzerComponent::DoIni DONE!" << endl; |
203 | if (argc==0 && argv==NULL) { |
204 | // this is currently just to get rid of the warning "unused parameter" |
205 | } |
206 | return 0; |
207 | } |
9dfd64cf |
208 | |
9dfd64cf |
209 | |
9dfd64cf |
210 | |
0a211711 |
211 | /* |
212 | int |
213 | AliHLTPHOSRawAnalyzerComponent::DoEvent(const AliHLTComponentEventData& evtDtaPtr, const AliHLTComponentBlockData* dtaPtr, AliHLTComponentTriggerData&, AliHLTUInt8_t*, AliHLTUInt32_t&, std::vector<AliHLTComponentBlockData, std::allocator<AliHLTComponentBlockData> >&) |
214 | { |
215 | const Bool_t skipBadEvent=kFALSE; |
216 | const AliHLTComponentBlockData* iter = NULL; |
217 | |
218 | fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( dtaPtr->fPtr ), dtaPtr->fSize ); |
9dfd64cf |
219 | |
0a211711 |
220 | // fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS"); |
9dfd64cf |
221 | |
0a211711 |
222 | fRawMemoryReader->DumpData(); |
9dfd64cf |
223 | |
0a211711 |
224 | Logging(kHLTLogInfo, "HLT", "Sample", "PhosHLTRawAnalyzerComonent, DoEvent"); |
9dfd64cf |
225 | |
0a211711 |
226 | // UChar_t *tmpDtaPtr = (UChar_t *)dtaPtr->fPtr; |
227 | // UInt32_t *tmpDtaPtr = (UInt32_t *)dtaPtr->fPtr; |
228 | // unsigned long *tmpDtaPtr = (unsigned long *)dtaPtr->fPtr; |
9dfd64cf |
229 | |
0a211711 |
230 | |
9dfd64cf |
231 | cout <<"PHOSHLT DoEvent: processing event:"<< eventCount << endl; |
232 | cout <<"Struct size = " <<evtDtaPtr.fStructSize << endl; |
233 | cout <<"Event ID = " <<evtDtaPtr.fEventID << endl; |
234 | cout <<"Block count = " <<evtDtaPtr.fBlockCnt << endl; |
235 | cout <<"Block size = " << dtaPtr->fSize << endl; |
236 | cout <<"printing out start od data block" << endl; |
9dfd64cf |
237 | cout << "content of data pointer =" << tmpDtaPtr << endl; |
238 | |
239 | |
0a211711 |
240 | // UChar_t *tmpDtaPtr = (UChar_t *)blokcs->fPtr; |
241 | |
242 | // AliCaloRawStream in(fRawMemoryReader,"PHOS"); |
9dfd64cf |
243 | // for(unsigned int i = 0; i < tmpSize; i++) |
0a211711 |
244 | for(unsigned int i = 0; i < 15; i++) |
9dfd64cf |
245 | { |
246 | // getc(); |
247 | // sleep(10); |
0a211711 |
248 | // printf("\ntype return to continue; "); |
249 | // getc(stdin); |
250 | // printf("\nThanks; read in \n"); |
251 | // cout << "entry:" <<i <<" = " << *tmpDtaPtr << endl; |
252 | // tmpDtaPtr ++; |
9dfd64cf |
253 | } |
9dfd64cf |
254 | |
9dfd64cf |
255 | |
0a211711 |
256 | |
257 | cout << "Entering while loop" << endl; |
258 | while ( fPHOSRawStream->Next() ) |
259 | { |
260 | cout << "Inside while loop" << endl; |
261 | if (fPHOSRawStream->IsNewHWAddress()) cout << endl << " New HW address: " << endl; |
262 | cout << "time bin=" << fPHOSRawStream->GetTime() << " of "<< fPHOSRawStream->GetTimeLength() |
263 | << ", amp=" << fPHOSRawStream->GetSignal() <<" gain="<< fPHOSRawStream->IsLowGain() |
264 | << " HW address="<<fPHOSRawStream->GetHWAddress() |
265 | << " channel=("<<fPHOSRawStream->GetModule() <<","<<fPHOSRawStream->GetColumn()<<","<<fPHOSRawStream->GetRow()<<")"<< endl; |
266 | |
267 | |
268 | if (skipBadEvent && (fPHOSRawStream->GetTime() < 0 || fPHOSRawStream->GetTimeLength() <=0) ) { |
269 | cout << "Wrong time bin or time length. Skip this event" << endl; |
270 | break; |
271 | } |
272 | } |
273 | cout << "Finnsihed while loop" << endl << endl; |
9dfd64cf |
274 | |
0a211711 |
275 | eventCount++; |
cbab66dd |
276 | return 0; |
277 | } |
0a211711 |
278 | */ |