2 /**************************************************************************
3 * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved. *
5 * Author: Per Thomas Hille for the ALICE HLT Project. *
6 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include "AliHLTPHOSRawAnalyzerComponent.h"
21 #include "AliRawReaderMemory.h"
22 #include "AliCaloRawStream.h"
24 //#include "AliHLTTPCDefinitions.h"
26 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
27 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::outputDataType=kAliHLTVoidDataType;
30 //AliHLTPHOSRawAnalyzerComponent gAliHLTPHOSRawAnalyzerComponent;
31 //ClassImp(AliHLTPHOSRawAnalyzerComponent)
32 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), eventCount(0), fPHOSRawStream(), fRawMemoryReader(0)
34 // fRawMemoryReader = NULL;
37 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
39 if(fRawMemoryReader != 0)
41 delete fRawMemoryReader;
43 if(fPHOSRawStream != 0)
45 delete fPHOSRawStream;
52 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), eventCount(0), fPHOSRawStream(),fRawMemoryReader(0)
54 // fRawMemoryReader = NULL;
59 AliHLTPHOSRawAnalyzerComponent::Deinit()
65 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
67 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
69 if(fRawMemoryReader !=0)
71 delete fRawMemoryReader;
74 if(fPHOSRawStream != 0)
76 delete fPHOSRawStream;
83 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
85 return "AliPhosTestRaw";
89 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
91 const AliHLTComponentDataType* pType=inputDataTypes;
92 while (pType->fID!=0) {
93 list.push_back(*pType);
98 AliHLTComponentDataType
99 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
101 return outputDataType;
105 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
108 constBase = 0;inputMultiplier = 0;
112 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
113 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
114 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
117 cout << "processing Event" << endl;
118 const AliHLTComponentBlockData* iter = NULL;
121 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
123 cout <<"Inside for loop ndx =" << ndx << endl;
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;
139 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
141 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
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;
153 // UChar_t *tmpDtaPtr = (UChar_t *)blocks->fPtr;
154 UInt_t *tmpDtaPtr = (UInt_t *)blocks->fPtr;
157 for(unsigned int i = 0; i < 15; i++)
161 // printf("\ntype return to continue; ");
163 // printf("\nThanks; read in \n");
164 cout << "entry:" <<i <<" = " << *tmpDtaPtr << endl;
166 // cout << "entry:" <<i <<" = " << *blocks << endl;
171 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
172 bool readValue = true;
175 cout << endl << "eventCount =" << eventCount << endl;
176 fRawMemoryReader->DumpData();
178 readValue = fPHOSRawStream->Next();
179 // fPHOSRawStream->Next();
183 cout <<"reading value" << endl;
184 readValue = fPHOSRawStream->Next();
186 cout << "end of for lop" << endl;
197 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
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"
213 AliHLTPHOSRawAnalyzerComponent::DoEvent(const AliHLTComponentEventData& evtDtaPtr, const AliHLTComponentBlockData* dtaPtr, AliHLTComponentTriggerData&, AliHLTUInt8_t*, AliHLTUInt32_t&, std::vector<AliHLTComponentBlockData, std::allocator<AliHLTComponentBlockData> >&)
215 const Bool_t skipBadEvent=kFALSE;
216 const AliHLTComponentBlockData* iter = NULL;
218 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( dtaPtr->fPtr ), dtaPtr->fSize );
220 // fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
222 fRawMemoryReader->DumpData();
224 Logging(kHLTLogInfo, "HLT", "Sample", "PhosHLTRawAnalyzerComonent, DoEvent");
226 // UChar_t *tmpDtaPtr = (UChar_t *)dtaPtr->fPtr;
227 // UInt32_t *tmpDtaPtr = (UInt32_t *)dtaPtr->fPtr;
228 // unsigned long *tmpDtaPtr = (unsigned long *)dtaPtr->fPtr;
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;
237 cout << "content of data pointer =" << tmpDtaPtr << endl;
240 // UChar_t *tmpDtaPtr = (UChar_t *)blokcs->fPtr;
242 // AliCaloRawStream in(fRawMemoryReader,"PHOS");
243 // for(unsigned int i = 0; i < tmpSize; i++)
244 for(unsigned int i = 0; i < 15; i++)
248 // printf("\ntype return to continue; ");
250 // printf("\nThanks; read in \n");
251 // cout << "entry:" <<i <<" = " << *tmpDtaPtr << endl;
257 cout << "Entering while loop" << endl;
258 while ( fPHOSRawStream->Next() )
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;
268 if (skipBadEvent && (fPHOSRawStream->GetTime() < 0 || fPHOSRawStream->GetTimeLength() <=0) ) {
269 cout << "Wrong time bin or time length. Skip this event" << endl;
273 cout << "Finnsihed while loop" << endl << endl;