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"
26 //#include "AliHLTTPCDefinitions.h"
28 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}}; //'zero' terminated array
29 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::outputDataType=kAliHLTVoidDataType;
32 //AliHLTPHOSRawAnalyzerComponent gAliHLTPHOSRawAnalyzerComponent;
33 //ClassImp(AliHLTPHOSRawAnalyzerComponent)
34 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(), eventCount(0), fPHOSRawStream(), fRawMemoryReader(0)
36 // fRawMemoryReader = NULL;
39 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
41 if(fRawMemoryReader != 0)
43 delete fRawMemoryReader;
45 if(fPHOSRawStream != 0)
47 delete fPHOSRawStream;
54 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(), eventCount(0), fPHOSRawStream(),fRawMemoryReader(0)
56 // fRawMemoryReader = NULL;
61 AliHLTPHOSRawAnalyzerComponent::Deinit()
67 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
69 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
71 if(fRawMemoryReader !=0)
73 delete fRawMemoryReader;
76 if(fPHOSRawStream != 0)
78 delete fPHOSRawStream;
85 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
87 return "AliPhosTestRaw";
91 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
93 const AliHLTComponentDataType* pType=inputDataTypes;
94 while (pType->fID!=0) {
95 list.push_back(*pType);
100 AliHLTComponentDataType
101 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
103 return outputDataType;
107 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
110 constBase = 0;inputMultiplier = 0;
114 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
115 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
116 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
122 Int_t processedChannels = 0;
124 const AliHLTComponentBlockData* iter = NULL;
128 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
136 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
138 cout << "Warning: data type = is nOT gkDDLPackedRawDataType " << endl;
141 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
142 fRawMemoryReader->DumpData();
143 fRawMemoryReader->RewindEvents();
145 analyzerPtr->SetData(fTmpChannelData);
147 while(fPHOSRawStream->Next())
149 if (fPHOSRawStream->IsNewHWAddress())
151 if(processedChannels > 0)
153 analyzerPtr->SetData(fTmpChannelData);
154 analyzerPtr->Evaluate(0, 1008);
155 fMaxValues[tmpMod][tmpRow][tmpCol][tmpGain] = analyzerPtr->GetEnergy();
159 tmpMod = fPHOSRawStream->GetModule();
160 tmpRow = fPHOSRawStream->GetRow();
161 tmpCol = fPHOSRawStream->GetColumn();
162 tmpGain = fPHOSRawStream->IsLowGain();
163 processedChannels ++;
166 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
177 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
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;
188 int equippmentId = atoi(argv[6]);
189 cout << "The equipment ID was set to " <<equippmentId << endl;
191 //fRawMemoryReader->SetEquipmentID(1806);
194 cout << "AliHLTPHOSRawAnalyzerComponent::DoInit Creating new AliRawReaderMemory()" << endl;
195 legoPlotPtr = new TH2S("Lego plot 1","Phi0 20Gev, High gain", 56*5, 0, 56*5, 64, 0, 64);
196 fRawMemoryReader = new AliRawReaderMemory();
197 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
198 fRawMemoryReader->SetEquipmentID(equippmentId);
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"
208 AliHLTPHOSRawAnalyzerComponent::DumpData()
210 for(int mod = 0; mod <5; mod ++)
212 printf("\n *********** MODULE %d ************\n", mod);
213 for(int row = 0; row < 64; row ++)
215 for(int col = 0; col < 56; col ++)
217 if( fMaxValues[mod][row][col][0] != 0)
219 cout << fMaxValues[mod][row][col][0] << "\t";
228 AliHLTPHOSRawAnalyzerComponent::Reset()
230 for(int mod = 0; mod <5; mod ++)
232 for(int row = 0; row < 64; row ++)
234 for(int col = 0; col < 56; col ++)
236 for(int gain = 0; gain <2; gain ++ )
238 fMaxValues[mod][row][col][gain] = 0;
244 for(int i = 0 ; i< 1008; i++)
246 fTmpChannelData[i] = 0;
251 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
253 for(int i = 0 ; i< 1008; i++)
255 fTmpChannelData[i] = 0;