// @(#) $Id$
/** \class AliHLTTPCBeamTestMemHandler
//_____________________________________________________________
// AliHLTTPCBeamTestMemHandler
//
// Class for converting the test beam data of May 2004
// to the HLT file format using R. Bramms tables.
//
// Author: C. Loizides
// -- Copyright © ALICE HLT Group
*/
#include "AliHLTStandardIncludes.h"
#include "AliHLTRootTypes.h"
#include "AliHLTLogging.h"
#include "AliHLTTransform.h"
#include "AliHLTMemHandler.h"
#include "AliHLTDigitData.h"
#include "AliHLTTPCBeamTestMemHandler.h"
#if __GNUC__ >= 3
using namespace std;
#endif
ClassImp(AliHLTTPCBeamTestMemHandler)
AliHLTTPCBeamTestMemHandler::AliHLTTPCBeamTestMemHandler(Char_t *fPathToMappingFile) : AliHLTMemHandler()
{
//constructor
fMinTimeBin=1;
fNumOfChannels=7807+1; //must be big enough to contain all channels (per patch)
Char_t readcarry[255];
Int_t actPos=0;
Int_t oldPos=0;
ifstream *in = new ifstream();
in->open(fPathToMappingFile);
#if defined(__HP_aCC) || defined(__DECCXX)
if(!in->rdbuf()->is_open()){
#else
if(!in->is_open()){
#endif
LOG(AliHLTLog::kFatal,"AliHLTTPCBeamTestMemHandler","Mapping File")
<<"Can't open file " << fPathToMappingFile << " !!!" <> readcarry;
mappingRow[j] = atoi(readcarry);
}
actPos = mappingRow[0];
fMapping[actPos] = mappingRow;
if( (actPos - oldPos) > 1){
for(Int_t j = (oldPos+1); j < actPos; j++){
fMapping[j] = fMappingEmptyRow;
}
}
oldPos = actPos;
}
in->close();
delete in;
}
AliHLTTPCBeamTestMemHandler::~AliHLTTPCBeamTestMemHandler()
{
//destructor
for(Int_t i = 0; i < 5504 ; i++) {
if(fMapping[i] != fMappingEmptyRow && fMapping[i]) delete[] fMapping[i];
}
delete [] fMappingEmptyRow;
delete[] fMapping;
}
AliHLTDigitRowData* AliHLTTPCBeamTestMemHandler::RawData2Memory(UInt_t &nrow,Int_t /*event*/)
{
//convert the raw data
AliHLTDigitRowData *data = 0;
nrow=0;
Int_t nrowsdummy=AliHLTTransform::GetNRows(fPatch);
fRows = new AliRowStructure[nrowsdummy];
for(Int_t i=0;i=fNumOfChannels) continue;
Int_t pad=MappingGetPad(hw);
Int_t lrow=MappingGetPadRow(hw);
if((lrow<0) ||(pad<0)) continue;
if(lrow+fRowMin>fRowMax) continue;
fRows[lrow].fRow=lrow+fRowMin;
if(fRows[lrow].fPadPos[pad]!=-1){
continue;
}
Bool_t isThereDataOnThisPad=kFALSE;
Int_t digmean=0;
#if 1
for(Int_t timebin = fMinTimeBin ; timebin <= ntimebins ; timebin++){
Int_t dig=fInputPtr[pos+timebin];
digmean+=dig;
}
digmean/=(ntimebins-fMinTimeBin+1);
#else
digmean = 40;
#endif
for(Int_t timebin = fMinTimeBin ; timebin <= ntimebins ; timebin++){
Int_t dig=fInputPtr[pos+timebin]-digmean;
if(dig <= AliHLTTransform::GetZeroSup()) continue;
if(dig >= AliHLTTransform::GetADCSat())
dig = AliHLTTransform::GetADCSat();
fRows[lrow].fNDigits++; //for this row only
ndigitcount++;
isThereDataOnThisPad=kTRUE;
}
if(isThereDataOnThisPad) {
fRows[lrow].fPadPos[pad]=pos;
}
}
Int_t nrows=0;
for(Int_t i=0;ifRow = slrow;
tempPt->fNDigit = fRows[i].fNDigits;
Int_t localcount=0;
for(Int_t pad=0;pad= AliHLTTransform::GetADCSat())
dig = AliHLTTransform::GetADCSat();
//Exclude data outside cone:
//AliHLTTransform::Raw2Local(xyz,sector,row,pad,time);
//if(fParam->GetPadRowRadii(sector,row)<230./250.*fabs(xyz[2])) continue;
tempPt->fDigitData[localcount].fCharge=(UShort_t)dig;
tempPt->fDigitData[localcount].fPad=(UChar_t)pad;
tempPt->fDigitData[localcount].fTime=(UShort_t)timebin-1;
//cout << slrow << " " << pad << " " << timebin << " " << dig << endl;
#ifdef do_mc
tempPt->fDigitData[localcount].fTrackID[0] = 0;
tempPt->fDigitData[localcount].fTrackID[1] = 0;
tempPt->fDigitData[localcount].fTrackID[2] = 0;
#endif
localcount++;
ndigitcounttest++;
} //time
} //pad
if(localcount != fRows[i].fNDigits)
LOG(AliHLTLog::kFatal,"AliHLTTPCBeamTestMemHandler::RawData2Memory","Memory")
<