fOperatingMode(kDigits),
fParam(0x0)
{
+ //
// ctor
+ //
+
AliError("default ctor - usage not recommended");
+
}
//______________________________________________________________________________
fOperatingMode(operatingMode),
fParam(param)
{
+ //
// ctor
+ //
+
this->LoadParams(); // load parameters
// T0
//______________________________________________________________________________
Bool_t AliTRDptrgCBAC::LoadParams()
{
- // load configuration parameters
+ //
+ // Load configuration parameters
+ //
if (this->fParam != 0x0) {
// read AliTRDptrgParam
// get LUTs
- AliTRDptrgLUT* LUT = new AliTRDptrgLUT();
+ AliTRDptrgLUT* lut = 0x0;
// 0
- LUT = new AliTRDptrgLUT();
- LUT->InitTable(10, 10, this->fParam->GetCBLUT(this->fPosition, 0), kFALSE);
+ lut = new AliTRDptrgLUT();
+ lut->InitTable(10, 10, this->fParam->GetCBLUT(this->fPosition, 0), kFALSE);
// do not copy table data
- this->fLUTArray.AddLast(LUT);
+ this->fLUTArray.AddLast(lut);
// 1
- LUT = new AliTRDptrgLUT();
- LUT->InitTable(10, 10, this->fParam->GetCBLUT(this->fPosition, 1), kFALSE);
+ lut = new AliTRDptrgLUT();
+ lut->InitTable(10, 10, this->fParam->GetCBLUT(this->fPosition, 1), kFALSE);
// do not copy table data
- this->fLUTArray.AddLast(LUT);
+ this->fLUTArray.AddLast(lut);
}
else {
// load default parameters
- AliTRDptrgLUT* LUT = new AliTRDptrgLUT();
- this->fLUTArray.AddLast(LUT);
- LUT = new AliTRDptrgLUT();
- this->fLUTArray.AddLast(LUT);
+ AliTRDptrgLUT* lut = new AliTRDptrgLUT();
+ this->fLUTArray.AddLast(lut);
+ lut = new AliTRDptrgLUT();
+ this->fLUTArray.AddLast(lut);
// the following lines are only needed for test reasons
- LUT = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0));
- Int_t* initData = new Int_t[1024]; // 2^10
- for (Int_t i = 0; i < 1024; i++ ) {
- initData[i] = i;
- }
- LUT->InitTable(10, 10, initData, kTRUE); // copy initData
- LUT = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(1));
- for (Int_t i = 1023; i >= 0; i--) {
- initData[31 - i] = i; // inverse ramp
+ lut = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(0));
+ if (lut) {
+ Int_t* initData = new Int_t[1024]; // 2^10
+ for (Int_t i = 0; i < 1024; i++ ) {
+ initData[i] = i;
+ }
+ lut->InitTable(10, 10, initData, kTRUE); // copy initData
+ lut = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray.At(1));
+ if (lut) {
+ for (Int_t i = 1023; i >= 0; i--) {
+ initData[31 - i] = i; // inverse ramp
+ }
+ lut->InitTable(10, 10, initData, kTRUE); // copy initData
+ }
}
- LUT->InitTable(10, 10, initData, kTRUE); // copy initData
}
+
return false;
+
}
//______________________________________________________________________________
AliTRDptrgCBAC::~AliTRDptrgCBAC()
{
- // destructor
+ //
+ // Destructor
+ //
this->fLUTArray.Delete();
this->fFEBArray.Delete();
+
}
//______________________________________________________________________________
Int_t* AliTRDptrgCBAC::Simulate()
{
+ //
// Simulate the CBAC behavior of event
+ //
+
Int_t nFEBs = this->fFEBArray.GetEntries();
Int_t nLUTs = this->fLUTArray.GetEntries();
Int_t** partResults = 0x0;
partResults = new Int_t* [nFEBs];
-
for (Int_t iFEB = 0; iFEB < nFEBs; iFEB++) {
- partResults[iFEB] =
- dynamic_cast<AliTRDptrgFEB*>(this->fFEBArray.At(iFEB))->Simulate();
+ AliTRDptrgFEB *feb = 0x0;
+ if ((feb = dynamic_cast<AliTRDptrgFEB*>(this->fFEBArray.At(iFEB)))) {
+ partResults[iFEB] = feb->Simulate();
+ }
}
// combine partResults and create inputVector
Int_t mask = 0x1;
for (Int_t iFEB = 0; iFEB < nFEBs ; iFEB++) {
for (Int_t j = 1; j <= partResults[iFEB][0]; j++) {
- if ((iBit >
- dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[0])->GetInputWidth())
- || (iBit >
- dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[0])->GetInputWidth())) {
- AliError("FEB result width does not match CB-A/C input with!");
+ AliTRDptrgLUT *lut0 = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[0]);
+ AliTRDptrgLUT *lut1 = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[1]);
+ if (lut0 && lut1) {
+ if ((iBit > lut0->GetInputWidth())
+ || (iBit > lut1->GetInputWidth())) {
+ AliError("FEB result width does not match CB-A/C input with!");
+ }
}
iBit++;
if (partResults[iFEB][j] > 0) {
result[0] = nLUTs; // storage array length in the first array value
for (Int_t iLUT = 0; iLUT < nLUTs; iLUT++) {
// process the return value for each LUT and store the result in the array
- result[iLUT + 1] =
- dynamic_cast<AliTRDptrgLUT*>(
- this->fLUTArray[iLUT])->LookUp(inputVector);
+ AliTRDptrgLUT *lutTmp = 0x0;
+ if ((lutTmp = dynamic_cast<AliTRDptrgLUT*>(this->fLUTArray[iLUT]))) {
+ result[iLUT + 1] = lutTmp->LookUp(inputVector);
+ }
AliDebug(4, Form("CBAC result[%d] = 0x%x",(iLUT + 1),result[iLUT + 1]));
}
+ // Clean up
+ delete [] partResults;
+
return result;
+
}