/*
$Log$
+Revision 1.19 2007/05/18 13:07:53 decaro
+Error messages stored in the global raw-reader error log (Cvetan, Chiara)
+
+Revision 1.18 2007/05/08 11:53:29 arcelli
+Improved class flexibility for further use (R.Preghenella)
+
+Revision 1.17 2007/05/03 08:53:50 decaro
+Coding convention: RS3 violation -> suppression
+
+Revision 1.16 2007/05/03 08:22:22 decaro
+Coding convention: RN17 violation -> suppression
+
+Revision 1.15 2007/04/30 15:22:06 arcelli
+Change TOF digit Time, Tot etc to int type
+
+Revision 1.14 2007/04/27 11:11:53 arcelli
+updates for the new decoder
+
+Revision 1.13 2007/03/16 11:46:35 decaro
+Coding convention: RN17 rule violation -> suppression
+
Revision 1.12 2007/02/22 09:43:45 decaro
Added AliTOFRawStream::GetIndex method for online calibration (C.Zampolli)
////////////////////////////////////////////////////////////////////////
+#include "Riostream.h"
+
#include "TClonesArray.h"
#include "AliDAQ.h"
#include "AliRawReader.h"
#include "AliTOFGeometry.h"
-#include "AliTOFGeometryV5.h"
#include "AliTOFrawData.h"
#include "AliTOFRawMap.h"
#include "AliTOFRawStream.h"
+#include "AliTOFHitData.h"
ClassImp(AliTOFRawStream)
//_____________________________________________________________________________
AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
fRawReader(rawReader),
- // fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
fTOFrawData(0x0),
fDecoder(new AliTOFDecoder()),
fDDL(-1),
fStrip(-1),
fPadX(-1),
fPadZ(-1),
- fTOFGeometry(new AliTOFGeometryV5()),
fPackedDigits(0),
fWordType(-1),
fSlotID(-1),
//
for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
- fDataBuffer[i]=new AliTOFHitDataBuffer(DATA_BUFFER_SIZE);
- fPackedDataBuffer[i]=new AliTOFHitDataBuffer(DATA_BUFFER_SIZE);
+ fDataBuffer[i]=new AliTOFHitDataBuffer();
+ fPackedDataBuffer[i]=new AliTOFHitDataBuffer();
}
fTOFrawData = new TClonesArray("AliTOFrawData",1000);
//_____________________________________________________________________________
AliTOFRawStream::AliTOFRawStream():
fRawReader(0x0),
- // fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
fTOFrawData(0x0),
fDecoder(new AliTOFDecoder()),
fDDL(-1),
fStrip(-1),
fPadX(-1),
fPadZ(-1),
- fTOFGeometry(new AliTOFGeometryV5()),
fPackedDigits(0),
fWordType(-1),
fSlotID(-1),
// default ctr
//
for (Int_t i=0;i<AliDAQ::NumberOfDdls("TOF");i++){
- fDataBuffer[i]=new AliTOFHitDataBuffer(DATA_BUFFER_SIZE);
- fPackedDataBuffer[i]=new AliTOFHitDataBuffer(DATA_BUFFER_SIZE);
+ fDataBuffer[i]=new AliTOFHitDataBuffer();
+ fPackedDataBuffer[i]=new AliTOFHitDataBuffer();
}
fTOFrawData = new TClonesArray("AliTOFrawData",1000);
AliTOFRawStream::AliTOFRawStream(const AliTOFRawStream& stream) :
TObject(stream),
fRawReader(0x0),
- // fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
fTOFrawData(0x0),
fDecoder(new AliTOFDecoder()),
fDDL(-1),
fStrip(-1),
fPadX(-1),
fPadZ(-1),
- fTOFGeometry(new AliTOFGeometryV5()),
fPackedDigits(0),
fWordType(-1),
fSlotID(-1),
fPadX = stream.fPadX;
fPadZ = stream.fPadZ;
- fTOFGeometry = stream.fTOFGeometry;
-
fPackedDigits = stream.fPackedDigits;
fWordType = stream.fWordType;
fPadX = stream.fPadX;
fPadZ = stream.fPadZ;
- fTOFGeometry = stream.fTOFGeometry;
-
fPackedDigits = stream.fPackedDigits;
fWordType = stream.fWordType;
fPackedDigits = 0;
- delete fTOFGeometry;
-
for (Int_t i=0;i<72;i++){
delete fDataBuffer[i];
delete fPackedDataBuffer[i];
void AliTOFRawStream::LoadRawData(Int_t indexDDL)
{
+ //
+ // To load raw data
+ //
- /*
- for (Int_t indexDDL = 0;
- indexDDL < AliDAQ::NumberOfDdls("TOF");
- indexDDL++) {
- */
+ fTOFrawData->Clear();
+
+ TClonesArray &arrayTofRawData = *fTOFrawData;
- fTOFrawData = new TClonesArray("AliTOFrawData",1000); //potential memory leak
- //fTOFrawData->Clear();
fPackedDigits = 0;
// create raw data map
Bool_t signal = kFALSE;
-
+ AliTOFrawData *rawDigit = NULL;
while(Next()) {
signal = (fSector!=-1 && fPlate!=-1 && fStrip!=-1 && fPadZ!=-1 && fPadX!=-1);
if (signal) {
- //printf(" %2i %1i %2i %1i %2i \n", fSector, fPlate, fStrip, fPadZ, fPadX);
+ AliDebug(2,Form(" %2i %1i %2i %1i %2i \n", fSector, fPlate, fStrip, fPadZ, fPadX));
slot[0] = fTRM;
slot[1] = fTRMchain;
if (rawMap->TestHit(slot) != kEmpty) {
- AliTOFrawData *rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
+ rawDigit = static_cast<AliTOFrawData*>(rawMap->GetHit(slot));
if (rawDigit->GetLeading()!=-1 && rawDigit->GetTrailing()==-1 &&
fLeadingEdge==-1 && fTrailingEdge!=-1) {
else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
(fLeadingEdge!=-1 || fTrailingEdge!=-1 || fTime!=-1) )
-/* else if ( ((rawDigit->GetTOF()!=-1 || rawDigit->GetLeading()!=-1 || rawDigit->GetTrailing()!=-1) &&
- (fTime!=-1 || fLeadingEdge!=-1 || fTrailingEdge!=-1))*/ /*||
- (rawDigit->GetLeading()==-1 && rawDigit->GetTrailing()!=-1 &&
- fLeadingEdge!=-1 && fTrailingEdge==-1) */)
+ )
{
- TClonesArray &arrayTofRawData = *fTOFrawData;
- new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
+ new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
- rawMap->SetHit(slot);
+ rawMap->SetHit(slot);
- }
+ }
}
else {
- TClonesArray &arrayTofRawData = *fTOFrawData;
new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(fTRM, fTRMchain, fTDC, fTDCchannel, fTime, fToT, fLeadingEdge, fTrailingEdge, fPSbit, fACQ, fErrorFlag);
rawMap->SetHit(slot);
} // closed -> while (Next())
- /*
- fDDL = fRawReader->GetDDLID();
-
- for (Int_t ii=0; ii<fTOFrawData->GetEntriesFast(); ii++) {
-
- AliTOFrawData *dummy = (AliTOFrawData*)fTOFrawData->UncheckedAt(ii);
-
- fTRM = dummy->GetTRM();
- fTRMchain = dummy->GetTRMchain();
- fTDC = dummy->GetTDC();
- fTDCchannel = dummy->GetTDCchannel();
-
- SetSector();
- SetPlate();
- SetStrip();
- SetPadZ();
- SetPadX();
-
- printf(" %2i, %2i %1i, %2i, %1i --> %2i, %1i, %2i, %1i, %2i \n",
- fDDL, fTRM, fTRMchain, fTDC, fTDCchannel,
- fSector, fPlate, fStrip, fPadZ, fPadX);
-
- } // closed loop on TOF raw data TClonesArray
- */
-
- //} // closed loop on indexDDL
-
-
+ rawMap->Delete();
}
}
//----------------------------------------------------------------------------
-Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
+Int_t AliTOFRawStream::Equip2VolNplate(Int_t iDDL, Int_t nTRM, Int_t nTDC)
{
//
// Returns the TOF plate number [0;4]
}
//----------------------------------------------------------------------------
-Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC) const
+Int_t AliTOFRawStream::Equip2VolNstrip(Int_t iDDL, Int_t nTRM, Int_t nTDC)
{
//
// Returns the TOF strip number per module:
//----------------------------------------------------------------------------
Int_t AliTOFRawStream::Equip2VolNpad(Int_t iDDL, Int_t iChain, Int_t nTDC,
- Int_t iCH) const
+ Int_t iCH)
{
//
// Returns the TOF pad number per strip [0;95]
iPadAlongTheStrip = iTDClocal*AliTOFGeometry::NCh() + iCHlocal;
if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
- ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX()))
- AliError("Problems with the padX number!");
-
+ ((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
+ std::cerr << "Problems with the padX number!" << endl;
+ //AliWarning("Problems with the padX number!");
+ }
return iPadAlongTheStrip;
}
Int_t iSector = GetSectorNumber(nDDL);
Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
- if (iPlate==-1) AliError("Problems with the plate number!");
+ if (iPlate==-1) {
+ if (fRawReader)
+ fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");
+ AliWarning("Problems with the plate number!");
+ }
Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
- if (iStrip==-1) AliError("Problems with the strip number!");
+ if (iStrip==-1) {
+ if (fRawReader)
+ fRawReader->AddMajorErrorLog(kStripError,"strip = -1");
+ AliWarning("Problems with the strip number!");
+ }
Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
- if (iPadAlongTheStrip==-1)
- AliError("Problems with the pad number along the strip!");
-
+ if (iPadAlongTheStrip==-1){
+ if (fRawReader)
+ fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");
+ AliWarning("Problems with the pad number along the strip!");
+ }
+
Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
Int_t iPadZ = iPadAlongTheStrip%AliTOFGeometry::NpadZ();
-
+
volume[0] = iSector;
volume[1] = iPlate;
volume[2] = iStrip;
volume[4] = iPadZ;
}
-//_____________________________________________________________________________
-
-Int_t AliTOFRawStream::GetIndex(Int_t *detId)
-{
- //Retrieve calibration channel index
- const Int_t nSectors = fTOFGeometry->NSectors();
- const Int_t nPlates = fTOFGeometry->NPlates();
- const Int_t nStripA = fTOFGeometry->NStripA();
- const Int_t nStripB = fTOFGeometry->NStripB();
- const Int_t nStripC = fTOFGeometry->NStripC();
- const Int_t nPadX = fTOFGeometry->NpadX();
- const Int_t nPadZ = fTOFGeometry->NpadZ();
-
-
- Int_t isector = detId[0];
- if (isector >= nSectors)
- AliError(Form("Wrong sector number in TOF (%d) !",isector));
- Int_t iplate = detId[1];
- if (iplate >= nPlates)
- AliError(Form("Wrong plate number in TOF (%d) !",iplate));
- Int_t istrip = detId[2];
- Int_t ipadz = detId[3];
- Int_t ipadx = detId[4];
- Int_t stripOffset = 0;
- switch (iplate) {
- case 0:
- stripOffset = 0;
- break;
- case 1:
- stripOffset = nStripC;
- break;
- case 2:
- stripOffset = nStripC+nStripB;
- break;
- case 3:
- stripOffset = nStripC+nStripB+nStripA;
- break;
- case 4:
- stripOffset = nStripC+nStripB+nStripA+nStripB;
- break;
- default:
- AliError(Form("Wrong plate number in TOF (%d) !",iplate));
- break;
- };
-
- Int_t idet = ((2*(nStripC+nStripB)+nStripA)*nPadZ*nPadX)*isector +
- (stripOffset*nPadZ*nPadX)+
- (nPadZ*nPadX)*istrip+
- (nPadX)*ipadz+
- ipadx;
- return idet;
-}
//-----------------------------------------------------------------------------
-Bool_t AliTOFRawStream::DecodeDDL(Int_t DDLMin, Int_t DDLMax, Int_t verbose = 0){
- Int_t currentEquipment;
- Int_t currentDDL;
+Bool_t AliTOFRawStream::DecodeDDL(Int_t nDDLMin, Int_t nDDLMax, Int_t verbose = 0) {
+ //
+ // To decode raw data for DDL number in [nDDLmin; nDDLmax]
+ //
- //pointers
- UChar_t *data = 0x0;
-
//check and fix valid DDL range
- if (DDLMin < 0){
- DDLMin = 0;
- AliError("Wrong DDL range: setting first DDL ID to 0");
+ if (nDDLMin < 0){
+ nDDLMin = 0;
+ fRawReader->AddMinorErrorLog(kDDLMinError);
+ AliWarning("Wrong DDL range: setting first DDL ID to 0");
}
- if (DDLMax > 71){
- DDLMax = 71;
- AliError("Wrong DDL range: setting last DDL ID to 71");
+ if (nDDLMax > 71){
+ nDDLMax = 71;
+ fRawReader->AddMinorErrorLog(kDDLMaxError);
+ AliWarning("Wrong DDL range: setting last DDL ID to 71");
}
//select required DDLs
- fRawReader->Select("TOF", DDLMin, DDLMax);
+ fRawReader->Select("TOF", nDDLMin, nDDLMax);
if (verbose)
- AliInfo(Form("Selected TOF DDL range: %d-%d", DDLMin, DDLMax));
+ AliInfo(Form("Selected TOF DDL range: %d-%d", nDDLMin, nDDLMax));
+ return(Decode(verbose));
+}
+//-----------------------------------------------------------------------------
+Bool_t AliTOFRawStream::Decode(Int_t verbose = 0) {
+ //
+ // New decoder method
+ //
+
+ Int_t currentEquipment;
+ Int_t currentDDL;
+
+ //pointers
+ UChar_t *data = 0x0;
+
//loop and read DDL headers
while(fRawReader->ReadHeader()){
//read equipment payload
if (!fRawReader->ReadNext(data, kDataSize))
{
+ fRawReader->AddMajorErrorLog(kDDLdataReading);
if (verbose)
- AliError("Error while reading DDL data. Go to next equipment");
+ AliWarning("Error while reading DDL data. Go to next equipment");
delete [] data;
data = 0x0;
continue;
fDecoder->SetPackedDataBuffer(fPackedDataBuffer[currentDDL]);
//start decoding
- if (fDecoder->Decode((UInt_t *)data, kDataWords) == kTRUE)
- AliError(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
+ if (fDecoder->Decode((UInt_t *)data, kDataWords) == kTRUE) {
+ fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",currentDDL));
+ AliWarning(Form("Error while decoding DDL # %d: decoder returned with errors", currentDDL));
+ }
delete [] data;
data = 0x0;
void
AliTOFRawStream::ResetBuffers()
{
+ //
+ // To reset the buffers
+ //
+
for (Int_t iDDL = 0; iDDL < AliDAQ::NumberOfDdls("TOF"); iDDL++){
ResetDataBuffer(iDDL);
ResetPackedDataBuffer(iDDL);
Bool_t
AliTOFRawStream::LoadRawDataBuffers(Int_t indexDDL, Int_t verbose)
{
+ //
+ // To load the buffers
+ //
+
fTOFrawData->Clear();
fPackedDigits = 0;
AliInfo(Form("Decoding raw data for DDL # %d ...", indexDDL));
if (DecodeDDL(indexDDL, indexDDL, verbose) != 0){ //decode DDL
- AliError(Form("Error while decoding DDL # %d", indexDDL));
+ fRawReader->AddMajorErrorLog(kDDLDecoder,Form("DDL # = %d",indexDDL));
+ AliWarning(Form("Error while decoding DDL # %d", indexDDL));
return kTRUE;
}
Int_t hitChain = hitData->GetChain();
Int_t hitTDC = hitData->GetTDC();
Int_t hitChan = hitData->GetChan();
- // Float_t hitTime = hitData->GetTime();
Int_t hitTimeBin = hitData->GetTimeBin();
- // Float_t hitTOT = hitData->GetTOT();
Int_t hitTOTBin = hitData->GetTOTBin();
- Float_t hitLeading = -1.;
- Float_t hitTrailing = -1.;
- Int_t hitError = -1;
+ Int_t hitLeading = hitData->GetTimeBin();//-1; // adc
+ Int_t hitTrailing = -1;
+ Int_t hitError = -1;
TClonesArray &arrayTofRawData = *fTOFrawData;
- new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, (Float_t)hitTimeBin, (Float_t)hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
+ new (arrayTofRawData[fPackedDigits++]) AliTOFrawData(hitSlotID, hitChain, hitTDC, hitChan, hitTimeBin, hitTOTBin, hitLeading, hitTrailing, hitPS, hitACQ, hitError);
}
if (verbose > 0)