#include "Riostream.h"
#include "TClonesArray.h"
+#include "TStopwatch.h"
#include "AliDAQ.h"
#include "AliLog.h"
#include "AliTOFrawData.h"
#include "AliTOFRawMap.h"
#include "AliTOFRawStream.h"
+#include "AliTOFdigit.h"
+#include "AliTOFSDigit.h"
//#include "AliTOFCableLengthMap.h"
#include "AliTOFHitData.h"
//_____________________________________________________________________________
AliTOFRawStream::AliTOFRawStream(AliRawReader* rawReader):
fRawReader(rawReader),
- fTOFrawData(0x0),
+ fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
fDecoder(new AliTOFDecoder()),
fDDL(-1),
fTRM(-1),
fInsideLTM(kFALSE),
fInsideTRMchain0(kFALSE),
fInsideTRMchain1(kFALSE),
- fDataBuffer(),
- fPackedDataBuffer(),
+ //fDataBuffer(),
+ //fPackedDataBuffer(),
fLocalEventCounterDRM(-1),
fLocalEventCounterLTM(-1),
- fLocalEventCounterTRM(),
- fLocalEventCounterChain(),
- fChainBunchID(),
- fCableLengthMap(0x0),
- fEventID(0)
+ //fLocalEventCounterTRM(),
+ //fLocalEventCounterChain(),
+ //fChainBunchID(),
+ //fCableLengthMap(new AliTOFCableLengthMap()),
+ fEventID(0),
+ fNewDecoderVersion(0)
{
//
// create an object to read TOF raw digits
ResetPackedDataBuffer(i);
}
- fTOFrawData = new TClonesArray("AliTOFrawData",1000);
+ //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
fTOFrawData->SetOwner();
fRawReader->Reset();
}
}
- fCableLengthMap = new AliTOFCableLengthMap();
-
fEventID = (Int_t)fRawReader->GetBCID(); //bunch crossing
}
//_____________________________________________________________________________
AliTOFRawStream::AliTOFRawStream():
- fRawReader(0x0),
- fTOFrawData(0x0),
+ fRawReader(0x0),
+ fTOFrawData(new TClonesArray("AliTOFrawData",1000)),
fDecoder(new AliTOFDecoder()),
fDDL(-1),
fTRM(-1),
fInsideLTM(kFALSE),
fInsideTRMchain0(kFALSE),
fInsideTRMchain1(kFALSE),
- fDataBuffer(),
- fPackedDataBuffer(),
+ //fDataBuffer(),
+ //fPackedDataBuffer(),
fLocalEventCounterDRM(-1),
fLocalEventCounterLTM(-1),
- fLocalEventCounterTRM(),
- fLocalEventCounterChain(),
- fChainBunchID(),
- fCableLengthMap(0x0),
- fEventID(0)
+ //fLocalEventCounterTRM(),
+ //fLocalEventCounterChain(),
+ //fChainBunchID(),
+ //fCableLengthMap(new AliTOFCableLengthMap()),
+ fEventID(0),
+ fNewDecoderVersion(0)
{
//
// default ctr
ResetPackedDataBuffer(i);
}
- fTOFrawData = new TClonesArray("AliTOFrawData",1000);
+ //fTOFrawData = new TClonesArray("AliTOFrawData",1000);
fTOFrawData->SetOwner();
for (Int_t j=0;j<13;j++){
}
}
- fCableLengthMap = new AliTOFCableLengthMap();
-
}
//_____________________________________________________________________________
fInsideLTM(stream.fInsideLTM),
fInsideTRMchain0(stream.fInsideTRMchain0),
fInsideTRMchain1(stream.fInsideTRMchain1),
- fDataBuffer(),
- fPackedDataBuffer(),
+ //fDataBuffer(),
+ //fPackedDataBuffer(),
fLocalEventCounterDRM(stream.fLocalEventCounterDRM),
fLocalEventCounterLTM(stream.fLocalEventCounterLTM),
- fLocalEventCounterTRM(),
- fLocalEventCounterChain(),
- fChainBunchID(),
- fCableLengthMap(stream.fCableLengthMap),
- fEventID(stream.fEventID)
+ //fLocalEventCounterTRM(),
+ //fLocalEventCounterChain(),
+ //fChainBunchID(),
+ //fCableLengthMap(stream.fCableLengthMap),
+ fEventID(stream.fEventID),
+ fNewDecoderVersion(stream.fNewDecoderVersion)
{
//
// copy constructor
}
}
- fCableLengthMap = stream.fCableLengthMap;
+ //fCableLengthMap = stream.fCableLengthMap;
fEventID = stream.fEventID;
+ fNewDecoderVersion = stream.fNewDecoderVersion;
return *this;
fTOFrawData->Clear();
delete fTOFrawData;
- delete fCableLengthMap;
+ //delete fCableLengthMap;
}
for (Int_t ii=0; ii<13; ii++)
fLocalEventCounterTRM[ii] = -1;
for (Int_t ii=0; ii<13; ii++)
- for (Int_t jj=0; jj<2; jj++)
+ for (Int_t jj=0; jj<2; jj++) {
fLocalEventCounterChain[ii][jj] = -1;
+ fChainBunchID[ii][jj] = -1;
+ }
fRawReader->Reset();
fRawReader->Select("TOF", indexDDL, indexDDL);
if (((iDDL==1 || iDDL==2) && iPadAlongTheStrip< AliTOFGeometry::NpadX()) ||
((iDDL==0 || iDDL==3) && iPadAlongTheStrip>=AliTOFGeometry::NpadX())) {
- std::cerr << "Problems with the padX number!" << endl;
+ std::cerr << "Warning -> AliTOFRawStream::Equip2VolNpad: Problems with the padX number!" << endl;
//AliWarning("Problems with the padX number!");
}
return iPadAlongTheStrip;
//----------------------------------------------------------------------------
void AliTOFRawStream::EquipmentId2VolumeId(Int_t nDDL, Int_t nTRM, Int_t iChain,
Int_t nTDC, Int_t iCH,
- Int_t *volume) const
+ Int_t *volume)
{
//
// To convert:
// padZ number, i.e. volume[4] (variable in [0, 1])
//
+ for (Int_t ii=0; ii<5; ii++) volume[ii] = -1;
+
Int_t iDDL = GetDDLnumberPerSector(nDDL);
+ if (iDDL%2==1 && nTRM==3 && nTDC/3>0) { // Signal not coming from a TOF pad but -probably- from a TOF OR signal
+ //printf("Info -> AliTOFRawStream::EquipmentId2VolumeId: Signal not coming from a TOF pad but -probably- from a TOF OR signal (%2d %2d %2d)\n", nDDL, nTRM, nTDC);
+ return;
+ }
+
Int_t iSector = GetSectorNumber(nDDL);
Int_t iPlate = Equip2VolNplate(iDDL, nTRM, nTDC);
if (iPlate==-1) {
- if (fRawReader)
- fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");
- AliWarning("Problems with the plate number!");
+ /*if (fRawReader)
+ fRawReader->AddMajorErrorLog(kPlateError,"plate = -1");*/
+ printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the plate number (%2d %2d %2d)!\n",
+ nDDL, nTRM, nTDC);
}
Int_t iStrip = Equip2VolNstrip(iDDL, nTRM, nTDC);
if (iStrip==-1) {
- if (fRawReader)
- fRawReader->AddMajorErrorLog(kStripError,"strip = -1");
- AliWarning("Problems with the strip number!");
+ /*if (fRawReader)
+ fRawReader->AddMajorErrorLog(kStripError,"strip = -1");*/
+ printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the strip number (%2d %2d %2d)!\n",
+ nDDL, nTRM, nTDC);
}
Int_t iPadAlongTheStrip = Equip2VolNpad(iDDL, iChain, nTDC, iCH);
- if (iPadAlongTheStrip==-1){
- if (fRawReader)
- fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");
- AliWarning("Problems with the pad number along the strip!");
+ if (iPadAlongTheStrip==-1) {
+ /*if (fRawReader)
+ fRawReader->AddMajorErrorLog(kPadAlongStripError,"pad = -1");*/
+ printf("Warning -> AliTOFRawStream::EquipmentId2VolumeId: Problems with the pad number along the strip (%2d %1d %2d %1d)!\n",
+ nDDL, iChain, nTDC, iCH);
}
Int_t iPadX = (Int_t)(iPadAlongTheStrip/(Float_t(AliTOFGeometry::NpadZ())));
return nChannel;
}
+
+//____________________________________________________________________________
+void AliTOFRawStream::Raw2Digits(AliRawReader* rawReader, TClonesArray* digitsArray)
+{
+ //
+ // Converts raw data to digits for TOF
+ //
+
+ TStopwatch stopwatch;
+ stopwatch.Start();
+
+ //TClonesArray *fDigits = new TClonesArray("AliTOFdigit", 4000);
+ //digitsTree->Branch("TOF", &fDigits);
+ TClonesArray &aDigits = *digitsArray;
+
+ Int_t inholes = 0;
+
+ Clear();
+ SetRawReader(rawReader);
+
+ //ofstream ftxt;
+ //if (fVerbose==2) ftxt.open("TOFdigitsRead.txt",ios::app);
+
+ TClonesArray staticRawData("AliTOFrawData",10000);
+ staticRawData.Clear();
+ TClonesArray * clonesRawData = &staticRawData;
+
+ Int_t dummy = -1;
+ Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
+ Int_t digit[4];
+
+ const Int_t kMaxNumberOfTracksPerDigit = 3;
+ Int_t tracks[kMaxNumberOfTracksPerDigit];
+ for (Int_t ii=0; ii<kMaxNumberOfTracksPerDigit; ii++)
+ tracks[ii] = -1;
+ Int_t last = -1;
+
+ Int_t indexDDL = 0;
+ Int_t iRawData = 0;
+ AliTOFrawData *tofRawDatum = 0;
+ for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
+
+ rawReader->Reset();
+ if (fNewDecoderVersion) {
+ AliInfo("Using New Decoder \n");
+ LoadRawDataBuffers(indexDDL, 0);
+ }
+ else
+ LoadRawData(indexDDL);
+
+ clonesRawData = GetRawData();
+ if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
+ for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
+
+ tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
+
+ //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
+ if (tofRawDatum->GetTOF()==-1) continue;
+
+ EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+ tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+
+ dummy = detectorIndex[3];
+ detectorIndex[3] = detectorIndex[4];//padz
+ detectorIndex[4] = dummy;//padx
+
+ digit[0] = tofRawDatum->GetTOF();
+ digit[1] = tofRawDatum->GetTOT();
+ digit[2] = tofRawDatum->GetTOT();
+ digit[3] = -1;//tofRawDatum->GetTOF(); //tofND
+
+ dummy = detectorIndex[3];
+ detectorIndex[3] = detectorIndex[4];//padx
+ detectorIndex[4] = dummy;//padz
+
+ // Do not reconstruct anything in the holes
+ if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
+ if (detectorIndex[1]==2) { // plate with holes
+ inholes++;
+ continue;
+ }
+ }
+
+ last = digitsArray->GetEntriesFast();
+ new (aDigits[last]) AliTOFdigit(tracks, detectorIndex, digit);
+ /*
+ if (fVerbose==2) {
+ if (indexDDL<10) ftxt << " " << indexDDL;
+ else ftxt << " " << indexDDL;
+ if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
+ else ftxt << " " << tofRawDatum->GetTRM();
+ ftxt << " " << tofRawDatum->GetTRMchain();
+ if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
+ else ftxt << " " << tofRawDatum->GetTDC();
+ ftxt << " " << tofRawDatum->GetTDCchannel();
+
+ if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
+ else ftxt << " -> " << detectorIndex[0];
+ ftxt << " " << detectorIndex[1];
+ if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
+ else ftxt << " " << detectorIndex[2];
+ ftxt << " " << detectorIndex[4];
+ if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
+ else ftxt << " " << detectorIndex[3];
+
+ if (digit[1]<10)ftxt << " " << digit[1];
+ else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
+ else ftxt << " " << digit[1];
+ if (digit[0]<10) ftxt << " " << digit[0] << endl;
+ else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
+ else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
+ else ftxt << " " << digit[3] << endl;
+ }
+ */
+ AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
+ last,
+ detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
+ digit[0], digit[1], digit[3]));
+
+ tofRawDatum = 0;
+ } // loop on tofRawData array
+
+ clonesRawData->Clear();
+
+ } // DDL Loop
+
+ //if (fVerbose==2) ftxt.close();
+
+
+ if (inholes) AliWarning(Form("Raw data in the TOF holes: %d",inholes));
+
+ Int_t nDigits = digitsArray->GetEntries();
+ AliDebug(1, Form("Got %d TOF digits", nDigits));
+ AliDebug(1, Form("Execution time to read TOF raw data and fill TOF digit tree : R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
+
+}
+
+//____________________________________________________________________________
+void AliTOFRawStream::Raw2SDigits(AliRawReader* rawReader, TClonesArray* sdigitsArray)
+{
+ //
+ // Converts raw data to sdigits for TOF
+ //
+
+ TStopwatch stopwatch;
+ stopwatch.Start();
+
+ Int_t inholes = 0;
+
+ //if(!GetLoader()->TreeS()) {MakeTree("S"); MakeBranch("S");}
+ TClonesArray &aSDigits = *sdigitsArray;
+
+ Clear();
+ SetRawReader(rawReader);
+
+ //ofstream ftxt;
+ //if (fVerbose==2) ftxt.open("TOFsdigitsRead.txt",ios::app);
+
+ TClonesArray staticRawData("AliTOFrawData",10000);
+ staticRawData.Clear();
+ TClonesArray * clonesRawData = &staticRawData;
+
+ Int_t dummy = -1;
+ Int_t detectorIndex[5] = {-1, -1, -1, -1, -1};
+ Int_t digit[2];
+ Int_t track = -1;
+ Int_t last = -1;
+
+ Int_t indexDDL = 0;
+ Int_t iRawData = 0;
+ AliTOFrawData *tofRawDatum = 0;
+ for (indexDDL=0; indexDDL<AliDAQ::NumberOfDdls("TOF"); indexDDL++) {
+
+ rawReader->Reset();
+ if (fNewDecoderVersion) {
+ AliInfo("Using New Decoder \n");
+ LoadRawDataBuffers(indexDDL, 0);
+ }
+ else
+ LoadRawData(indexDDL);
+
+ clonesRawData = GetRawData();
+ if (clonesRawData->GetEntriesFast()!=0) AliInfo(Form(" TOF raw data number = %3d", clonesRawData->GetEntriesFast()));
+ for (iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
+
+ tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
+
+ //if (tofRawDatum->GetTOT()==-1 || tofRawDatum->GetTOF()==-1) continue;
+ if (tofRawDatum->GetTOF()==-1) continue;
+
+ EquipmentId2VolumeId(indexDDL, tofRawDatum->GetTRM(), tofRawDatum->GetTRMchain(),
+ tofRawDatum->GetTDC(), tofRawDatum->GetTDCchannel(), detectorIndex);
+
+ dummy = detectorIndex[3];
+ detectorIndex[3] = detectorIndex[4];//padz
+ detectorIndex[4] = dummy;//padx
+
+ digit[0] = tofRawDatum->GetTOF();
+ digit[1] = tofRawDatum->GetTOT();
+
+ dummy = detectorIndex[3];
+ detectorIndex[3] = detectorIndex[4];//padx
+ detectorIndex[4] = dummy;//padz
+
+ // Do not reconstruct anything in the holes
+ if (detectorIndex[0]==13 || detectorIndex[0]==14 || detectorIndex[0]==15 ) { // sectors with holes
+ if (detectorIndex[1]==2) { // plate with holes
+ inholes++;
+ continue;
+ }
+ }
+
+ last = sdigitsArray->GetEntriesFast();
+ new (aSDigits[last]) AliTOFSDigit(track, detectorIndex, digit);
+ /*
+ if (fVerbose==2) {
+ if (indexDDL<10) ftxt << " " << indexDDL;
+ else ftxt << " " << indexDDL;
+ if (tofRawDatum->GetTRM()<10) ftxt << " " << tofRawDatum->GetTRM();
+ else ftxt << " " << tofRawDatum->GetTRM();
+ ftxt << " " << tofRawDatum->GetTRMchain();
+ if (tofRawDatum->GetTDC()<10) ftxt << " " << tofRawDatum->GetTDC();
+ else ftxt << " " << tofRawDatum->GetTDC();
+ ftxt << " " << tofRawDatum->GetTDCchannel();
+
+ if (detectorIndex[0]<10) ftxt << " -> " << detectorIndex[0];
+ else ftxt << " -> " << detectorIndex[0];
+ ftxt << " " << detectorIndex[1];
+ if (detectorIndex[2]<10) ftxt << " " << detectorIndex[2];
+ else ftxt << " " << detectorIndex[2];
+ ftxt << " " << detectorIndex[4];
+ if (detectorIndex[4]<10) ftxt << " " << detectorIndex[3];
+ else ftxt << " " << detectorIndex[3];
+
+ if (digit[1]<10)ftxt << " " << digit[1];
+ else if (digit[1]>=10 && digit[1]<100) ftxt << " " << digit[1];
+ else ftxt << " " << digit[1];
+ if (digit[0]<10) ftxt << " " << digit[0] << endl;
+ else if (digit[0]>=10 && digit[0]<100) ftxt << " " << digit[0] << endl;
+ else if (digit[0]>=100 && digit[0]<1000) ftxt << " " << digit[0] << endl;
+ else ftxt << " " << digit[3] << endl;
+ }
+ */
+ AliDebug(2, Form(" Raw data reading %2d -> %2d %1d %2d %1d %2d (%d, %d, %d)",
+ last,
+ detectorIndex[0], detectorIndex[1], detectorIndex[2], detectorIndex[4], detectorIndex[3],
+ digit[0], digit[1], digit[3]));
+
+ tofRawDatum = 0;
+ } // while loop
+
+ clonesRawData->Clear();
+
+ } // DDL Loop
+
+ //if (fVerbose==2) ftxt.close();
+
+ if (inholes) AliWarning(Form("Clusters in the TOF holes: %d",inholes));
+
+ Int_t nSDigits = sdigitsArray->GetEntries();
+ AliDebug(1, Form("Got %d TOF sdigits", nSDigits));
+ AliDebug(1, Form("Execution time to read TOF raw data and fill TOF sdigit tree : R:%.2fs C:%.2fs",
+ stopwatch.RealTime(),stopwatch.CpuTime()));
+
+}