00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "AliHLTPHOSRawAnalyzerComponent.h"
00020 #include <iostream>
00021 #include "stdio.h"
00022 #include "AliRawReaderMemory.h"
00023 #include "AliCaloRawStream.h"
00024 #include <cstdlib>
00025 #include "AliHLTPHOSRcuCellEnergyDataStruct.h"
00026
00027 const AliHLTComponentDataType AliHLTPHOSRawAnalyzerComponent::inputDataTypes[]={kAliHLTVoidDataType,{0,"",""}};
00028 int AliHLTPHOSRawAnalyzerComponent::fEventCount = 0;
00029
00030
00044 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent():AliHLTProcessor(),fEquippmentID(0), fRcuX(0),
00045 fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
00046 {
00047
00048 }
00049
00050 AliHLTPHOSRawAnalyzerComponent::~AliHLTPHOSRawAnalyzerComponent()
00051 {
00052 if(fRawMemoryReader != 0)
00053 {
00054 delete fRawMemoryReader;
00055 }
00056 if(fPHOSRawStream != 0)
00057 {
00058 delete fPHOSRawStream;
00059 }
00060
00061 }
00062
00063
00064
00065 AliHLTPHOSRawAnalyzerComponent::AliHLTPHOSRawAnalyzerComponent(const AliHLTPHOSRawAnalyzerComponent & ) : AliHLTProcessor(),
00066 fEquippmentID(0), fRcuX(0), fRcuZ(0),fRcuRowOffeset(0), fRcuColOffeset(0), fModuleID(0), fPHOSRawStream(0), fRawMemoryReader(0), fOutPtr(0)
00067 {
00068 }
00069
00070
00071
00072
00073
00074
00075 int
00076 AliHLTPHOSRawAnalyzerComponent::Deinit()
00077 {
00078 return 0;
00079 }
00080
00081
00082
00083
00084
00085
00086 int
00087 AliHLTPHOSRawAnalyzerComponent::DoDeinit()
00088 {
00089 Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerComponen DoDeinit");
00090
00091 if(fRawMemoryReader !=0)
00092 {
00093 delete fRawMemoryReader;
00094 }
00095
00096 if(fPHOSRawStream != 0)
00097 {
00098 delete fPHOSRawStream;
00099 }
00100 return 0;
00101
00102 }
00103
00104
00105
00106
00107
00108 const char*
00109 AliHLTPHOSRawAnalyzerComponent::GetComponentID()
00110 {
00111 return "AliPhosTestRaw";
00112 }
00113
00114
00115 void
00116 AliHLTPHOSRawAnalyzerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list)
00117 {
00118 const AliHLTComponentDataType* pType=inputDataTypes;
00119 while (pType->fID!=0) {
00120 list.push_back(*pType);
00121 pType++;
00122 }
00123 }
00124
00125 AliHLTComponentDataType
00126 AliHLTPHOSRawAnalyzerComponent::GetOutputDataType()
00127 {
00128 return AliHLTPHOSDefinitions::gkCellEnergyDataType;
00129 }
00130
00131 void
00132 AliHLTPHOSRawAnalyzerComponent::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier )
00133
00134 {
00135 constBase = 30;
00136 inputMultiplier = 0.1;
00137 }
00138
00139
00140 int AliHLTPHOSRawAnalyzerComponent::DoEvent( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks,
00141 AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr,
00142 AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
00143 {
00144 Int_t tmpMod = 0;
00145 Int_t tmpRow = 0;
00146 Int_t tmpCol = 0;
00147 Int_t tmpGain = 0;
00148 Int_t sampleCnt = 0;
00149 Int_t processedChannels = 0;
00150 UInt_t offset = 0;
00151 UInt_t mysize = 0;
00152 UInt_t tSize = 0;
00153 Int_t tmpChannelCnt = 0;
00154 Int_t tmpStartIndex = 0;
00155 AliHLTUInt8_t* outBPtr;
00156 outBPtr = outputPtr;
00157 const AliHLTComponentBlockData* iter = NULL;
00158 unsigned long ndx;
00159
00160 if((fEventCount % 100) == 0)
00161 {
00162
00163 }
00164
00165 for( ndx = 0; ndx < evtData.fBlockCnt; ndx++ )
00166 {
00167 iter = blocks+ndx;
00168 mysize = 0;
00169 offset = tSize;
00170
00171 if ( iter->fDataType != AliHLTPHOSDefinitions::gkDDLPackedRawDataType )
00172 {
00173
00174 continue;
00175 }
00176
00177 fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( iter->fPtr ), iter->fSize );
00178 analyzerPtr->SetData(fTmpChannelData);
00179 fOutPtr = (AliHLTPHOSRcuCellEnergyDataStruct*)outBPtr;
00180 mysize += sizeof(AliHLTPHOSRcuCellEnergyDataStruct);
00181 fOutPtr->fRcuX = fRcuX;
00182 fOutPtr->fRcuZ = fRcuZ;
00183 fOutPtr->fModuleID = fModuleID;
00184 tmpChannelCnt = 0;
00185
00186 if(fEventCount%100 ==0)
00187 {
00188
00189 }
00190
00191 while(fPHOSRawStream->Next())
00192 {
00193 if (fPHOSRawStream->IsNewHWAddress())
00194 {
00195 if(processedChannels > 0)
00196 {
00197 analyzerPtr->SetData(fTmpChannelData);
00198 analyzerPtr->Evaluate(0, sampleCnt);
00199 sampleCnt = 0;
00200
00201
00202 fOutPtr->fValidData[tmpChannelCnt].fGain = tmpGain;
00203 fOutPtr->fValidData[tmpChannelCnt].fRow = tmpRow;
00204 fOutPtr->fValidData[tmpChannelCnt].fCol = tmpCol;
00205 fOutPtr->fValidData[tmpChannelCnt].fEnergy = analyzerPtr->GetEnergy();
00206 fOutPtr->fValidData[tmpChannelCnt].fTime = analyzerPtr->GetTiming();
00207 tmpChannelCnt ++;
00208 ResetDataPtr(tmpStartIndex, sampleCnt);
00209 sampleCnt = 0;
00210 }
00211
00212 tmpMod = fPHOSRawStream->GetModule() ;
00213 tmpRow = fPHOSRawStream->GetRow() - fRcuRowOffeset;
00214 tmpCol = fPHOSRawStream->GetColumn() - fRcuColOffeset;
00215 tmpGain = fPHOSRawStream->IsLowGain();
00216 processedChannels ++;
00217
00218 cout << "EquitppmentId = " << fRawMemoryReader->GetEquipmentId() <<"\t" << "fPHOSRawStream->GetColumn()=\t" <<fPHOSRawStream->GetColumn() <<"\t(" << tmpCol <<")\t"<<\
00219 "fPHOSRawStream->GetRow()=\t" <<fPHOSRawStream->GetRow()<<"\t(" << tmpRow <<")" <<endl;
00220
00221
00222
00223 }
00224
00225 if(sampleCnt == 0)
00226 {
00227 tmpStartIndex = fPHOSRawStream->GetTime();
00228 }
00229
00230 fTmpChannelData[fPHOSRawStream->GetTime()] = fPHOSRawStream->GetSignal();
00231 sampleCnt ++;
00232
00233 }
00234
00235 fOutPtr->fCnt = tmpChannelCnt;
00236 AliHLTComponentBlockData bd;
00237 FillBlockData( bd );
00238 bd.fOffset = offset;
00239 bd.fSize = mysize;
00240 bd.fDataType = AliHLTPHOSDefinitions::gkCellEnergyDataType;
00241 bd.fSpecification = 0xFFFFFFFF;
00242 outputBlocks.push_back( bd );
00243 tSize += mysize;
00244 outBPtr += mysize;
00245
00246 if( tSize > size )
00247 {
00248 Logging( kHLTLogFatal, "HLT::AliHLTPHOSRawAnalyzerComponent::DoEvent", "Too much data",
00249 "Data written over allowed buffer. Amount written: %lu, allowed amount: %lu."
00250 , tSize, size );
00251 return EMSGSIZE;
00252 }
00253 }
00254
00255 fEventCount++;
00256 size = tSize;
00257 return 0;
00258 }
00259
00260
00261
00262 int
00263 AliHLTPHOSRawAnalyzerComponent::DoInit( int argc, const char** argv )
00264 {
00265 int equippmentID = atoi(argv[6]);
00266 cout << "AliHLTPHOSRawAnalyzerComponent::DoIni Setting EquipmentID to" << equippmentID << endl;
00267 Reset();
00268 fRawMemoryReader = new AliRawReaderMemory();
00269 fPHOSRawStream = new AliCaloRawStream(fRawMemoryReader,"PHOS");
00270 fPHOSRawStream->SetOldRCUFormat(kFALSE);
00271 fRawMemoryReader->SetEquipmentID(equippmentID);
00272 SetEquippmentID(equippmentID);
00273 SetCoordinates(equippmentID);
00274 if (argc==0 && argv==NULL) {
00275
00276 }
00277 return 0;
00278 }
00279
00280 void
00281 AliHLTPHOSRawAnalyzerComponent::DumpData(int gain)
00282 {
00283 for(int mod = 0; mod < N_MODULES; mod ++)
00284 {
00285 printf("\n *********** MODULE %d ************\n", mod);
00286 for(int row = 0; row < N_ROWS_MOD; row ++)
00287 {
00288 for(int col = 0; col < N_COLUMNS_MOD; col ++)
00289 {
00290 if( fMaxValues[mod][row][col][0] != 0)
00291 {
00292 cout << fMaxValues[mod][row][col][gain] << "\t";
00293 }
00294 }
00295 }
00296 }
00297 }
00298
00299
00300 void
00301 AliHLTPHOSRawAnalyzerComponent::DumpData()
00302 {
00303 DumpData(0);
00304 }
00305
00306 void
00307 AliHLTPHOSRawAnalyzerComponent::DumpChannelData(Double_t *data)
00308 {
00309 cout << endl;
00310
00311 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
00312 {
00313 if (data[i] != 0)
00314 {
00315 cout <<i <<"\t";
00316 }
00317 }
00318 cout << endl;
00319
00320 for(int i=0; i< ALTRO_MAX_SAMPLES; i++)
00321 {
00322 if (data[i] != 0)
00323 {
00324 cout <<data[i] <<"\t";
00325 }
00326 }
00327
00328 cout << endl;
00329 }
00330
00331
00332
00333 void
00334 AliHLTPHOSRawAnalyzerComponent::Reset()
00335 {
00336 for(int mod = 0; mod < N_MODULES; mod ++)
00337 {
00338 for(int row = 0; row < N_ROWS_MOD; row ++)
00339 {
00340 for(int col = 0; col < N_COLUMNS_MOD; col ++)
00341 {
00342 for(int gain = 0; gain < N_GAINS; gain ++ )
00343 {
00344 fMaxValues[mod][row][col][gain] = 0;
00345 }
00346 }
00347 }
00348 }
00349
00350 ResetDataPtr();
00351
00352 }
00353
00354
00355
00356 void
00357 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr()
00358 {
00359 for(int i = 0 ; i< ALTRO_MAX_SAMPLES; i++)
00360 {
00361 fTmpChannelData[i] = 0;
00362 }
00363 }
00364
00365 void
00366 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int sampleCnt)
00367 {
00368 for(int i = 0 ; i< sampleCnt; i++)
00369 {
00370 fTmpChannelData[i] = 0;
00371 }
00372 }
00373
00374 void
00375 AliHLTPHOSRawAnalyzerComponent::ResetDataPtr(int startindex, int sampleCnt)
00376 {
00377 for(int i = startindex ; i< sampleCnt; i++)
00378 {
00379 fTmpChannelData[i] = 0;
00380 }
00381 }
00382
00383
00384 void
00385 AliHLTPHOSRawAnalyzerComponent::SetEquippmentID(AliHLTUInt32_t id)
00386 {
00387 fEquippmentID = id;
00388 }
00389
00390 int
00391 AliHLTPHOSRawAnalyzerComponent::GetEquippmentID()
00392 {
00393 return fEquippmentID;
00394 }
00395
00396 void
00397 AliHLTPHOSRawAnalyzerComponent::SetCoordinates(AliHLTUInt32_t equippmentID)
00398 {
00399 int rcuIndex = (fEquippmentID - 1792)%4;
00400 fModuleID = (fEquippmentID -1792 -rcuIndex)/5;
00401
00402 if(rcuIndex == 0)
00403 {
00404 fRcuX = 0;
00405 fRcuZ = 0;
00406 }
00407
00408 if(rcuIndex == 1)
00409 {
00410 fRcuX = 0;
00411 fRcuZ = 1;
00412 }
00413
00414 if(rcuIndex == 2)
00415 {
00416 fRcuX = 1;
00417 fRcuZ = 0;
00418 }
00419
00420
00421 if(rcuIndex == 3)
00422 {
00423 fRcuX = 1;
00424 fRcuZ = 1;
00425 }
00426
00427 fRcuRowOffeset = 32*fRcuX;
00428 fRcuColOffeset = 28*fRcuZ;
00429
00430 }