/*
$Log$
+Revision 1.19 2007/06/22 11:37:47 cvetan
+Fixes in order to write correct raw-data on big-endian platforms (Marco)
+
+Revision 1.18 2007/05/21 13:26:19 decaro
+Correction on matching_window control and bug fixing (R.Preghenella)
+
+Revision 1.17 2007/05/10 09:29:34 hristov
+Last moment fixes and changes from v4-05-Release (Silvia)
+
+Revision 1.16 2007/05/03 09:07:22 decaro
+Double digit in the same TDC channel. Wrong sequence during the raw data writing in unpacked mode: solved
+
+Revision 1.15 2007/04/23 16:51:39 decaro
+Digits-to-raw_data conversion: correction for a more real description (A.De Caro, R.Preghenella)
+
+Revision 1.14 2007/03/28 10:50:33 decaro
+Rounding off problem in rawData coding/decoding: solved
+
+Revision 1.13 2007/02/20 15:57:00 decaro
+Raw data update: to read the TOF raw data defined in UNPACKED mode
+
+Revision 1.12 2006/08/22 13:29:42 arcelli
+removal of effective c++ warnings (C.Zampolli)
+
Revision 1.11 2006/08/10 14:46:54 decaro
TOF raw data format: updated version
#include "AliLog.h"
//#include "AliRawDataHeader.h"
#include "AliRawDataHeaderSim.h"
+#include "AliFstream.h"
#include "AliTOFDDLRawData.h"
#include "AliTOFDigitMap.h"
#include "AliTOFdigit.h"
#include "AliTOFGeometry.h"
#include "AliTOFRawStream.h"
+//#include "AliTOFCableLengthMap.h"
extern TRandom *gRandom;
+using std::ofstream;
+using std::endl;
+using std::cout;
+using std::ios;
ClassImp(AliTOFDDLRawData)
//---------------------------------------------------------------------------
AliTOFDDLRawData::AliTOFDDLRawData():
+ TObject(),
fVerbose(0),
fIndex(-1),
- fTOFgeometry(0),
+ fPackedAcquisition(kFALSE),
+ fFakeOrphaneProduction(kFALSE),
+ fMatchingWindow(8192),
fTOFdigitMap(new AliTOFDigitMap()),
fTOFdigitArray(0x0),
- fTOFrawStream(new AliTOFRawStream())
+ fWordsPerDRM(0),
+ fWordsPerTRM(0),
+ fWordsPerChain(0)
{
//Default constructor
}
-
-//----------------------------------------------------------------------------
-AliTOFDDLRawData::AliTOFDDLRawData(AliTOFGeometry *tofGeom):
- fVerbose(0),
- fIndex(-1),
- fTOFgeometry(tofGeom),
- fTOFdigitMap(new AliTOFDigitMap()),
- fTOFdigitArray(0x0),
- fTOFrawStream(new AliTOFRawStream())
-{
- //Constructor
-
-}
-
//----------------------------------------------------------------------------
AliTOFDDLRawData::AliTOFDDLRawData(const AliTOFDDLRawData &source) :
TObject(source),
- fVerbose(0),
- fIndex(-1),
- fTOFgeometry(0),
- fTOFdigitMap(new AliTOFDigitMap()),
- fTOFdigitArray(0x0),
- fTOFrawStream(new AliTOFRawStream())
+ fVerbose(source.fVerbose),
+ fIndex(source.fIndex),
+ fPackedAcquisition(source.fPackedAcquisition),
+ fFakeOrphaneProduction(source.fFakeOrphaneProduction),
+ fMatchingWindow(source.fMatchingWindow),
+ fTOFdigitMap(source.fTOFdigitMap),
+ fTOFdigitArray(source.fTOFdigitArray),
+ fWordsPerDRM(source.fWordsPerDRM),
+ fWordsPerTRM(source.fWordsPerTRM),
+ fWordsPerChain(source.fWordsPerChain)
{
//Copy Constructor
- this->fIndex=source.fIndex;
- this->fVerbose=source.fVerbose;
- this->fTOFgeometry=source.fTOFgeometry;
- this->fTOFdigitMap=source.fTOFdigitMap;
- this->fTOFdigitArray=source.fTOFdigitArray;
- this->fTOFrawStream=source.fTOFrawStream;
return;
}
//----------------------------------------------------------------------------
AliTOFDDLRawData& AliTOFDDLRawData::operator=(const AliTOFDDLRawData &source) {
//Assigment operator
- this->fIndex=source.fIndex;
- this->fVerbose=source.fVerbose;
- this->fTOFgeometry=source.fTOFgeometry;
- this->fTOFdigitMap=source.fTOFdigitMap;
- this->fTOFdigitArray=source.fTOFdigitArray;
- this->fTOFrawStream=source.fTOFrawStream;
+
+ if (this == &source)
+ return *this;
+
+ TObject::operator=(source);
+ fIndex=source.fIndex;
+ fVerbose=source.fVerbose;
+ fPackedAcquisition=source.fPackedAcquisition;
+ fFakeOrphaneProduction=source.fFakeOrphaneProduction;
+ fMatchingWindow=source.fMatchingWindow;
+ fTOFdigitMap=source.fTOFdigitMap;
+ fTOFdigitArray=source.fTOFdigitArray;
+ fWordsPerDRM=source.fWordsPerDRM;
+ fWordsPerTRM=source.fWordsPerTRM;
+ fWordsPerChain=source.fWordsPerChain;
return *this;
}
+//----------------------------------------------------------------------------
+AliTOFDDLRawData::~AliTOFDDLRawData()
+{
+ // dtr
+
+ delete fTOFdigitMap;
+}
//----------------------------------------------------------------------------
Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch)
{
// This method creates the Raw data files for TOF detector
//
- const Int_t kSize = 5000; //max number of digits per DDL file times 2
+ const Int_t kSize = 5000; // max number of digits per DDL file times 2
UInt_t buf[kSize];
+ // To clear the digit indices map for each event
+ fTOFdigitMap->Clear();
+
fIndex = -1;
fTOFdigitArray = * (TClonesArray**) branch->GetAddress();
- char fileName[15];
- ofstream outfile; // logical name of the output file
+ AliFstream* outfile; // logical name of the output file
- //AliRawDataHeader header;
AliRawDataHeaderSim header;
UInt_t sizeRawData = 0;
GetDigits();
+ //if (!fPackedAcquisition) fMatchingWindow = 2097152;//AdC
+
Int_t jj = -1;
Int_t iDDL = -1;
Int_t nDDL = -1;
Int_t nTRM = 0;
Int_t iChain = -1;
- UInt_t nWordsPerTRM = 0;
-
//loop over TOF DDL files
for (nDDL=0; nDDL<AliDAQ::NumberOfDdls("TOF"); nDDL++) {
- strcpy(fileName,AliDAQ::DdlFileName("TOF",nDDL)); //The name of the output file
-#ifndef __DECCXX
- outfile.open(fileName,ios::binary);
-#else
- outfile.open(fileName);
-#endif
+ char fileName[256]="";
+ strncpy(fileName,AliDAQ::DdlFileName("TOF",nDDL),255); //The name of the output file
- iDDL = fTOFrawStream->GetDDLnumberPerSector(nDDL);
+ outfile = new AliFstream(fileName);
+ iDDL = AliTOFRawStream::GetDDLnumberPerSector(nDDL);
// write Dummy DATA HEADER
- UInt_t dataHeaderPosition = outfile.tellp();
- outfile.write((char*)(&header),sizeof(header));
+ UInt_t dataHeaderPosition = outfile->Tellp();
+ outfile->WriteBuffer((char*)(&header),sizeof(header));
// DRM section: trailer
MakeDRMtrailer(buf);
- // LTM section
- fIndex++;
- buf[fIndex] = MakeFiller();
- MakeLTMtrailer(buf);
- MakeLTMdata(buf);
- MakeLTMheader(buf);
-
// loop on TRM number per DRM
for (nTRM=AliTOFGeometry::NTRM(); nTRM>=3; nTRM--) {
- nWordsPerTRM = 0;
+ fWordsPerTRM = 0;
// the slot number 3 of the even DRM (i.e. right) doesn't contain TDC digit data
if (iDDL%2==0 && nTRM==3) continue;
- // TRM global trailer
- MakeTRMtrailer(buf);
-
// loop on TRM chain number per TRM
for (iChain=AliTOFGeometry::NChain()-1; iChain>=0; iChain--) {
// TRM chain trailer
- MakeTRMchainTrailer(iChain, buf);
- nWordsPerTRM++;
+ MakeTRMchainTrailer(iChain, buf); fWordsPerTRM++;
// TRM TDC digits
- MakeTDCdigits(nDDL, nTRM, iChain, buf, nWordsPerTRM);
+ MakeTDCdigits(nDDL, nTRM, iChain, buf);
// TRM chain header
- MakeTRMchainHeader(nTRM, iChain, buf);
- nWordsPerTRM++;
+ MakeTRMchainHeader(nTRM, iChain, buf); fWordsPerTRM++;
} // end loop on iChain
// TRM global header
- MakeTRMheader(nTRM, buf);
+ MakeTRMheader(nTRM, buf); fWordsPerTRM++;
// TRM filler in case where TRM data number is odd
- if (nWordsPerTRM%2!=0) MakeTRMfiller(buf, nWordsPerTRM);
+ if ((fWordsPerTRM+1)%2!=0) {
+ MakeTRMfiller(buf); fWordsPerTRM++;
+ }
+
+ MakeTRMtrailer(buf); fWordsPerDRM++;
+
+ fWordsPerDRM += fWordsPerTRM;
} // end loop on nTRM
-
+
+
+ // LTM section
+ //fIndex++;
+ //buf[fIndex] = MakeFiller(); fWordsPerDRM++; // valid till when LTM word number was 33
+ MakeLTMtrailer(buf); fWordsPerDRM++;
+ MakeLTMdata(buf); fWordsPerDRM+=48;
+ MakeLTMheader(buf); fWordsPerDRM++;
+
// DRM section: in
MakeDRMheader(nDDL, buf);
ReverseArray(buf, fIndex+1);
- outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t)));
+ outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
for (jj=0; jj<(fIndex+1); jj++) buf[jj]=0;
fIndex = -1;
//Write REAL DATA HEADER
- UInt_t currentFilePosition = outfile.tellp();
+ UInt_t currentFilePosition = outfile->Tellp();
sizeRawData = currentFilePosition - dataHeaderPosition - sizeof(header);
header.fSize = currentFilePosition - dataHeaderPosition;
header.SetAttribute(0); // valid data
- outfile.seekp(dataHeaderPosition);
- outfile.write((char*)(&header),sizeof(header));
- outfile.seekp(currentFilePosition);
+ outfile->Seekp(dataHeaderPosition);
+ outfile->WriteBuffer((char*)(&header),sizeof(header));
+ outfile->Seekp(currentFilePosition);
- outfile.close();
+ delete outfile;
} //end loop on DDL file number
Int_t digit = -1;
Int_t ndigits = fTOFdigitArray->GetEntries();
-
+ AliDebug(2, Form(" Number of read digits = %d",ndigits));
AliTOFdigit *digs;
// loop on TOF digits
fTOFdigitMap->AddDigit(vol, digit);
} // close loop on digit del TOF
-
+ AliDebug(2,Form(" Number of mapped digits = %d",fTOFdigitMap->GetFilledCellNumber()));
}
//----------------------------------------------------------------------------
// DRM global header
//
- Int_t iDDL = fTOFrawStream->GetDDLnumberPerSector(nDDL);
+ //Int_t iDDL = fTOFrawStream->GetDDLnumberPerSector(nDDL);
+ Int_t iDDL = AliTOFRawStream::GetDDLnumberPerSector(nDDL);
- Int_t iSector = fTOFrawStream->GetSectorNumber(nDDL);
+ //Int_t iSector = fTOFrawStream->GetSectorNumber(nDDL);
+ Int_t iSector = AliTOFRawStream::GetSectorNumber(nDDL);
UInt_t baseWord=0;
UInt_t word;
baseWord=0;
word = 1; // 0001 -> DRM data are coming from the VME slot number 1
AliBitPacking::PackWord(word,baseWord, 0, 3);
- word = 0; // event CRC
+ word = 0; // event CRC --> CHANGED
AliBitPacking::PackWord(word,baseWord, 4,19);
word = 0; // reserved for future use
AliBitPacking::PackWord(word,baseWord,20,27);
fIndex++;
buf[fIndex]=baseWord;
+ // DRM status header 4
+ baseWord=0;
+ word = 1; // 0001 -> DRM data are coming from the VME slot number 1
+ AliBitPacking::PackWord(word,baseWord, 0, 3);
+ word = 0; // temperature
+ AliBitPacking::PackWord(word,baseWord, 4,13);
+ word = 0; // zero
+ AliBitPacking::PackWord(word,baseWord, 14,14);
+ word = 0; // ACK
+ AliBitPacking::PackWord(word,baseWord, 15,15);
+ word = 0; // Sens AD
+ AliBitPacking::PackWord(word,baseWord, 16,18);
+ word = 0; // zero
+ AliBitPacking::PackWord(word,baseWord, 19,19);
+ word = 0; // reserved for future use
+ AliBitPacking::PackWord(word,baseWord, 20,27);
+ word = 4; // 0100 -> DRM header ID
+ AliBitPacking::PackWord(word,baseWord,28,31);
+ fIndex++;
+ buf[fIndex]=baseWord;
+
// DRM status header 3
baseWord=0;
word = 1; // 0001 -> DRM data are coming from the VME slot number 1
AliBitPacking::PackWord(word,baseWord, 0, 3);
- word = 0; // TTC event counter
- AliBitPacking::PackWord(word,baseWord, 4,27);
+ word = 0; // L0 BCID
+ AliBitPacking::PackWord(word,baseWord, 4,15);
+ word = 0; // Run Time info
+ AliBitPacking::PackWord(word,baseWord, 16,27);
word = 4; // 0100 -> DRM header ID
AliBitPacking::PackWord(word,baseWord,28,31);
fIndex++;
word = 0; //
AliBitPacking::PackWord(word,baseWord,15,15);
word = 0; // fault ID
- AliBitPacking::PackWord(word,baseWord,16,27);
+ AliBitPacking::PackWord(word,baseWord,16,26);
+ word = 0; // RTO
+ AliBitPacking::PackWord(word,baseWord,27,27);
word = 4; // 0100 -> DRM header ID
AliBitPacking::PackWord(word,baseWord,28,31);
fIndex++;
word = 1; // LHC clock status: 1/0
AliBitPacking::PackWord(word,baseWord,15,15);
+ word = 0; // Vers ID
+ AliBitPacking::PackWord(word,baseWord,16,20);
+ word = 0; // DRMH size
+ AliBitPacking::PackWord(word,baseWord,21,24);
word = 0; // reserved for future use
- AliBitPacking::PackWord(word,baseWord,16,27);
+ AliBitPacking::PackWord(word,baseWord,25,27);
word = 4; // 0100 -> DRM header ID
AliBitPacking::PackWord(word,baseWord,28,31);
fIndex++;
baseWord=0;
word = 1; // 0001 -> DRM data are coming from the VME slot number 1
AliBitPacking::PackWord(word,baseWord, 0, 3);
- word = 0; // local event counter
+ word = 0; // local event counter --> TO BE CHANGED IN fWordsPerDRM+5
AliBitPacking::PackWord(word,baseWord, 4,15);
word = 0; // reserved for future use
AliBitPacking::PackWord(word,baseWord,16,27);
UInt_t baseWord;
UInt_t word;
-
+
baseWord=0;
- word = 100; // Local temperature in LTM5 -> 4 X 25 degree (environment temperature)
- AliBitPacking::PackWord(word,baseWord, 0, 9);
- word = 100; // Local temperature in LTM6 -> 4 X 25 degree (environment temperature)
+ word = 0;
+ AliBitPacking::PackWord(word,baseWord,0,9);
+ word = 0;
AliBitPacking::PackWord(word,baseWord,10,19);
- word = 100; // Local temperature in LTM7 -> 4 X 25 degree (environment temperature)
+ word = 0;
AliBitPacking::PackWord(word,baseWord,20,29);
word = 0;
- AliBitPacking::PackWord(word,baseWord,30,31);
+ AliBitPacking::PackWord(word,baseWord,30,30);
+ word = 0;
+ AliBitPacking::PackWord(word,baseWord,31,31);
+
+
+ // OR45, OR46, OR47
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR42, OR43, OR44
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR39, OR40, OR41
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR36, OR37, OR38
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR33, OR34, OR35
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR30, OR31, OR32
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR27, OR28, OR29
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR24, OR25, OR26
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR21, OR22, OR23
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR18, OR19, OR20
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // OR15, OR16, OR17
+ fIndex++;
+ buf[fIndex]=baseWord;
+ // OR12, OR12, OR24
fIndex++;
buf[fIndex]=baseWord;
- // Local temperature in LTM2, LMT3, LTM4 -> 4 X 25 degree (environment temperature)
+ // OR9, OR10, OR11
fIndex++;
buf[fIndex]=baseWord;
- // Local temperature in FEAC7, FEAC8, LTM1 -> 4 X 25 degree (environment temperature)
+ // OR6, OR7, OR8
fIndex++;
buf[fIndex]=baseWord;
- // Local temperature in FEAC4, FEAC5, FEAC6 -> 4 X 25 degree (environment temperature)
+ // OR3, OR4, OR5
fIndex++;
buf[fIndex]=baseWord;
- // Local temperature in FEAC1, FEAC2, FEAC3 -> 4 X 25 degree (environment temperature)
+ // OR0, OR1, OR2
fIndex++;
buf[fIndex]=baseWord;
+
+
baseWord=0;
- word = 0; // GND-FEAC15 -> Voltage drop between GND and FEAC15
+ word = 100; // Local temperature in LTM11 -> 4 X 25 degree (environment temperature)
AliBitPacking::PackWord(word,baseWord, 0, 9);
- word = 0; // VTH16 -> Thereshould voltage for FEAC16
+ word = 100; // Local temperature in LTM10 -> 4 X 25 degree (environment temperature)
AliBitPacking::PackWord(word,baseWord,10,19);
- word = 0; // GND-FEAC16 -> Voltage drop between GND and FEAC16
+ word = 100; // Local temperature in LTM9 -> 4 X 25 degree (environment temperature)
AliBitPacking::PackWord(word,baseWord,20,29);
word = 0;
- AliBitPacking::PackWord(word,baseWord,30,31);
+ AliBitPacking::PackWord(word,baseWord,30,30);
+ word = 0;
+ AliBitPacking::PackWord(word,baseWord,31,31);
+
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // Local temperature in LTM8, LMT7, LTM6 -> 4 X 25 degree (environment temperature)
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // Local temperature in LTM5, LMT4, LTM3 -> 4 X 25 degree (environment temperature)
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // Local temperature in LTM2, LMT1, LTM0 -> 4 X 25 degree (environment temperature)
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+
+ // Local temperature in T7, T6, T5 -> 4 X 25 degree (environment temperature)
+ fIndex++;
+ buf[fIndex]=baseWord;
+
+ // Local temperature in T4, T3, T2 -> 4 X 25 degree (environment temperature)
fIndex++;
buf[fIndex]=baseWord;
- // VTH14 -> Thereshould voltage for FEAC14
- // GND-FEAC14 -> Voltage drop between GND and FEAC14
- // VTH15 -> Thereshould voltage for FEAC15
+ // Local temperature in T1, T0 -> 4 X 25 degree (environment temperature)
+ // Local temperature in VTH15 -> Thereshould voltage for FEAC15
fIndex++;
buf[fIndex]=baseWord;
- // GND-FEAC12 -> Voltage drop between GND and FEAC12
- // VTH13 -> Thereshould voltage for FEAC13
- // GND-FEAC13 -> Voltage drop between GND and FEAC13
+ baseWord=0;
+ word = 0; // VTH13 -> Thereshould voltage for FEAC16
+ AliBitPacking::PackWord(word,baseWord, 0, 9);
+ word = 0; // VTH14 -> Thereshould voltage for FEAC14
+ AliBitPacking::PackWord(word,baseWord,10,19);
+ word = 0; // GND-FEAC7 -> Voltage drop between GND and FEAC7
+ AliBitPacking::PackWord(word,baseWord,20,29);
+ word = 0;
+ AliBitPacking::PackWord(word,baseWord,30,30);
+ word = 0;
+ AliBitPacking::PackWord(word,baseWord,31,31);
+
fIndex++;
buf[fIndex]=baseWord;
// VTH11 -> Thereshould voltage for FEAC11
- // GND-FEAC11 -> Voltage drop between GND and FEAC11
// VTH12 -> Thereshould voltage for FEAC12
+ // GND-FEAC6 -> Voltage drop between GND and FEAC6
fIndex++;
buf[fIndex]=baseWord;
- // GND-FEAC9 -> Voltage drop between GND and FEAC9
- // VTH10 -> Thereshould voltage for FEAC10
- // GND-FEAC10 -> Voltage drop between GND and FEAC10
+ // VTH9 -> Thereshould voltage for FEAC11
+ // VTH10 -> Thereshould voltage for FEAC12
+ // GND-FEAC5 -> Voltage drop between GND and FEAC6
fIndex++;
buf[fIndex]=baseWord;
- // VTH8 -> Thereshould voltage for FEAC8
- // GND-FEAC8 -> Voltage drop between GND and FEAC8
- // VTH9 -> Thereshould voltage for FEAC9
+ // VTH7 -> Thereshould voltage for FEAC11
+ // VTH8 -> Thereshould voltage for FEAC12
+ // GND-FEAC4 -> Voltage drop between GND and FEAC6
fIndex++;
buf[fIndex]=baseWord;
- // GND-FEAC6 -> Voltage drop between GND and FEAC6
- // VTH7 -> Thereshould voltage for FEAC7
- // GND-FEAC7 -> Voltage drop between GND and FEAC7
+ // VTH5 -> Thereshould voltage for FEAC11
+ // VTH6 -> Thereshould voltage for FEAC12
+ // GND-FEAC3 -> Voltage drop between GND and FEAC6
fIndex++;
buf[fIndex]=baseWord;
- // VTH5 -> Thereshould voltage for FEAC5
- // GND-FEAC5 -> Voltage drop between GND and FEAC5
- // VTH6 -> Thereshould voltage for FEAC6
+ // VTH3 -> Thereshould voltage for FEAC11
+ // VTH4 -> Thereshould voltage for FEAC12
+ // GND-FEAC2 -> Voltage drop between GND and FEAC6
fIndex++;
buf[fIndex]=baseWord;
- // GND-FEAC3 -> Voltage drop between GND and FEAC3
- // VTH4 -> Thereshould voltage for FEAC4
- // GND-FEAC4 -> Voltage drop between GND and FEAC4
+ // VTH1 -> Thereshould voltage for FEAC11
+ // VTH2 -> Thereshould voltage for FEAC12
+ // GND-FEAC1 -> Voltage drop between GND and FEAC6
fIndex++;
buf[fIndex]=baseWord;
- // VTH2 -> Thereshould voltage for FEAC2
- // GND-FEAC2 -> Voltage drop between GND and FEAC2
- // VTH3 -> Thereshould voltage for FEAC3
+ // LV15
+ // VTH0 -> Thereshould voltage for FEAC12
+ // GND-FEAC0 -> Voltage drop between GND and FEAC6
fIndex++;
buf[fIndex]=baseWord;
- // LV16 -> Low Voltage measured by FEAC16
- // GND-FEAC1 -> Voltage drop between GND and FEAC1
- // VTH1 -> Thereshould voltage for FEAC1
+ // LV15
+ // VTH0 -> Thereshould voltage for FEAC12
+ // GND-FEAC0 -> Voltage drop between GND and FEAC6
fIndex++;
buf[fIndex]=baseWord;
- // Low Voltage measured by FEAC13, FEAC14, FEAC15
+ // LV12
+ // LV13
+ // LV14
fIndex++;
buf[fIndex]=baseWord;
- // Low Voltage measured by FEAC10, FEAC11, FEAC12
+ // LV9
+ // LV10
+ // LV11
fIndex++;
buf[fIndex]=baseWord;
- // Low Voltage measured by FEAC7, FEAC8, FEAC9
+ // LV6
+ // LV7
+ // LV8
fIndex++;
buf[fIndex]=baseWord;
- // Low Voltage measured by FEAC4, FEAC5, FEAC6
+ // LV3
+ // LV4
+ // LV5
fIndex++;
buf[fIndex]=baseWord;
- // Low Voltage measured by FEAC1, FEAC2, FEAC3
+ // LV0
+ // LV1
+ // LV2
fIndex++;
buf[fIndex]=baseWord;
+
baseWord=0;
- word = 0; // PDL45 -> Delay Line setting for PDL45
+ word = 0; // PDL45 -> Delay Line setting for PDL41
AliBitPacking::PackWord(word,baseWord, 0, 7);
- word = 0; // PDL46 -> Delay Line setting for PDL46
+ word = 0; // PDL46 -> Delay Line setting for PDL42
AliBitPacking::PackWord(word,baseWord, 8,15);
- word = 0; // PDL47 -> Delay Line setting for PDL47
+ word = 0; // PDL47 -> Delay Line setting for PDL43
AliBitPacking::PackWord(word,baseWord,16,23);
- word = 0; // PDL48 -> Delay Line setting for PDL48
+ word = 0; // PDL48 -> Delay Line setting for PDL44
AliBitPacking::PackWord(word,baseWord,24,31);
fIndex++;
buf[fIndex]=baseWord;
- // Delay Line setting for PDL41, PDL42, PDL43, PDL44
- fIndex++;
- buf[fIndex]=baseWord;
-
// Delay Line setting for PDL37, PDL38, PDL39, PDL40
fIndex++;
buf[fIndex]=baseWord;
AliBitPacking::PackWord(word,baseWord, 0, 3);
word = 0; // event words
AliBitPacking::PackWord(word,baseWord, 4,16);
- word = 0; // ACQuisition mode: [0;3] see document
+
+ if (fPackedAcquisition)
+ word = 0; // ACQuisition mode: [0;3] see document
+ else
+ word = 3; // ACQuisition mode: [0;3] see document
AliBitPacking::PackWord(word,baseWord,17,18);
word = 0; // description of a SEU inside LUT tables for INL compensation;
// the data are unaffected
void AliTOFDDLRawData::MakeTRMtrailer(UInt_t *buf)
{
//
- // TRM trailer
+ // Set TRM Global Trailer
+ // with the calculated CRC
//
UInt_t baseWord;
baseWord=0;
word = 15; // 1111 -> TRM trailer ID 1
AliBitPacking::PackWord(word,baseWord, 0, 3);
- word = 0; // event CRC
- AliBitPacking::PackWord(word,baseWord, 4,15);
- word = 0; // local event counter == DRM local event counter
+
+ UInt_t trmCRC=0x0;
+ for (Int_t ii=fIndex-(fWordsPerTRM-1); ii<fIndex; ii++)
+ trmCRC ^= buf[ii];
+ //PH printf(" A trmCRC=%d\n",trmCRC);
+
+ word = 0x0;
+ word ^= ( (trmCRC & 0x00000fff) >> 0);
+ word ^= ( (trmCRC & 0x00fff000) >> 12);
+ word ^= ( (trmCRC & 0xff000000) >> 24);
+
+ //PH printf(" B trmCRC=%d\n",word);
+
+ AliBitPacking::PackWord(word,baseWord, 4,15); // event CRC --> CHANGED
+
+ word = 0; // local event counter == DRM local event counter --> TO BE CHANGED
AliBitPacking::PackWord(word,baseWord,16,27);
word = 5; // 0101 -> TRM trailer ID 2
AliBitPacking::PackWord(word,baseWord,28,31);
+
fIndex++;
- buf[fIndex]=baseWord;
+ for (Int_t ii=fIndex; ii>fIndex-fWordsPerTRM; ii--)
+ buf[ii]=buf[ii-1];
-}
+ buf[fIndex-fWordsPerTRM] = baseWord;
+}
+
//----------------------------------------------------------------------------
void AliTOFDDLRawData::MakeTRMchainHeader(Int_t nTRM, Int_t iChain,
UInt_t *buf)
AliBitPacking::PackWord(word,baseWord, 0, 3);
word = 0; // bunch ID
AliBitPacking::PackWord(word,baseWord, 4,15);
- word = 100; // PB24 temperature -> 4 X 25 degree (environment temperature)
+ word = 0;//100; // PB24 temperature -> 4 X 25 degree (environment temperature)
AliBitPacking::PackWord(word,baseWord,16,23);
- word = (Int_t)(5 * gRandom->Rndm()); // PB24 ID [0;4]
+ word = 0;//(Int_t)(5 * gRandom->Rndm()); // PB24 ID [0;4]
AliBitPacking::PackWord(word,baseWord,24,26);
word = 0; // TS
AliBitPacking::PackWord(word,baseWord,27,27);
}
//----------------------------------------------------------------------------
-void AliTOFDDLRawData::MakeTRMfiller(UInt_t *buf, UInt_t nWordsPerTRM)
+void AliTOFDDLRawData::MakeTRMfiller(UInt_t *buf)
{
//
// TRM filler
Int_t jj = -1;
fIndex++;
- for (jj=fIndex; jj>fIndex-(Int_t)nWordsPerTRM; jj--) {
+ for (jj=fIndex; jj>fIndex-fWordsPerTRM; jj--)
buf[jj] = buf[jj-1];
- }
- buf[fIndex-nWordsPerTRM] = MakeFiller();
+ buf[fIndex-fWordsPerTRM] = MakeFiller();
}
//----------------------------------------------------------------------------
-UInt_t AliTOFDDLRawData::MakeFiller()
+UInt_t AliTOFDDLRawData::MakeFiller() const
{
//
// Filler word definition: to make even the number of words per TRM/LTM
AliBitPacking::PackWord(word,baseWord, 0, 3);
word = 0; // MBZ
AliBitPacking::PackWord(word,baseWord, 4,15);
- word = 0; // event counter
+ word = 0; // event counter --> TO BE CHANGED
AliBitPacking::PackWord(word,baseWord,16,27);
switch (iChain) {
case 0:
}
//----------------------------------------------------------------------------
-void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain,
- UInt_t *buf, UInt_t &nWordsPerTRM)
+void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain, UInt_t *buf)
{
//
// TRM TDC digit
//
+ const Double_t kOneMoreFilledCell = 1./(AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors());
+ Double_t percentFilledCells = Double_t(fTOFdigitMap->GetFilledCellNumber())/(AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors());
+
if (nDDL<0 || nDDL>71) {
AliWarning(Form(" DDL number is out of the right range [0;71] (nDDL = %3i", nDDL));
return;
return;
}
+ Int_t psArray[1000];
+ UInt_t localBuffer[1000];
+ Int_t localIndex = -1;
+
Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
Int_t volume[5] = {-1, -1, -1, -1, -1};
Int_t totCharge = -1;
Int_t timeOfFlight = -1;
+ Int_t trailingSpurious = -1;
+ Int_t leadingSpurious = -1;
+
AliTOFdigit *digs;
UInt_t baseWord=0;
Int_t nTDC = -1;
Int_t iCH = -1;
+ //Int_t numberOfMeasuresPerChannel = 0;
+ //Int_t maxMeasuresPerChannelInTDC = 0;
+
+ Bool_t outOut = HeadOrTail();
+
ofstream ftxt;
if (fVerbose==2) ftxt.open("TOFdigits.txt",ios::app);
// the DRM odd (i.e. left) slot number 3 doesn't contain TDC digit data
// for TDC numbers 3-14
- if (iDDL%2==1 && nTRM==3 && (Int_t)(nTDC/3.)!=0) continue;
+ if (iDDL%2==1 && nTRM==3 && (Int_t)(nTDC/3)!=0) continue;
// loop on TDC channel number
for (iCH=AliTOFGeometry::NCh()-1; iCH>=0; iCH--) {
- fTOFrawStream->EquipmentId2VolumeId(nDDL, nTRM, iChain, nTDC, iCH, volume);
+ //numberOfMeasuresPerChannel = 0;
+
+ for (Int_t aa=0; aa<5; aa++) volume[aa]=-1;
+ AliTOFRawStream::EquipmentId2VolumeId(nDDL, nTRM, iChain, nTDC, iCH, volume);
+ AliDebug(3,Form(" volume -> %2d %1d %2d %2d %1d",volume[0],volume[1],volume[2],volume[3],volume[4]));
+
if (volume[0]==-1 || volume[1]==-1 || volume[2]==-1 ||
volume[3]==-1 || volume[4]==-1) continue;
- //AliInfo(Form(" sector = %2i plate = %1i strip = %2i
- //padX = %2i padZ = %1i", volume[0], volume[1], volume[2],
- //volume[3], volume[4]));
+
+ AliDebug(3,Form(" ====== %2d %1d %2d %2d %1d",volume[0],volume[1],volume[2],volume[3],volume[4]));
for (jj=0; jj<3; jj++) indexDigit[jj] = -1;
fTOFdigitMap->GetDigitIndex(volume, indexDigit);
+ if (indexDigit[0]<0) {
+
+ trailingSpurious = Int_t(2097152*gRandom->Rndm());
+ leadingSpurious = Int_t(2097152*gRandom->Rndm());
+
+ if ( fFakeOrphaneProduction &&
+ ( ( fPackedAcquisition && percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells) ) ||
+ (!fPackedAcquisition && percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) ) ) ) {
+
+ percentFilledCells+=kOneMoreFilledCell;
+
+ Int_t dummyPS = 0;
+
+ if (outOut) {
+ word = trailingSpurious; // trailing edge measurement
+ dummyPS = 2;
+ }
+ else {
+ word = leadingSpurious; // leading edge measurement
+ dummyPS = 1;
+ }
+
+ if (fVerbose==2) {
+ if (nDDL<10) ftxt << " " << nDDL;
+ else ftxt << " " << nDDL;
+ if (nTRM<10) ftxt << " " << nTRM;
+ else ftxt << " " << nTRM;
+ ftxt << " " << iChain;
+ if (nTDC<10) ftxt << " " << nTDC;
+ else ftxt << " " << nTDC;
+ ftxt << " " << iCH;
+ if (volume[0]<10) ftxt << " -> " << volume[0];
+ else ftxt << " -> " << volume[0];
+ ftxt << " " << volume[1];
+ if (volume[2]<10) ftxt << " " << volume[2];
+ else ftxt << " " << volume[2];
+ ftxt << " " << volume[4];
+ if (volume[3]<10) ftxt << " " << volume[3];
+ else ftxt << " " << volume[3];
+ ftxt << " " << -1;
+ if (word<10) ftxt << " " << word;
+ else if (word>=10 && word<100) ftxt << " " << word;
+ else if (word>=100 && word<1000) ftxt << " " << word;
+ else if (word>=1000 && word<10000) ftxt << " " << word;
+ else if (word>=10000 && word<100000) ftxt << " " << word;
+ else if (word>=100000 && word<1000000) ftxt << " " << word;
+ else ftxt << " " << word;
+ ftxt << " " << dummyPS << endl;
+ }
+
+ AliBitPacking::PackWord(word,baseWord, 0,20);
+ word = iCH; // TDC channel ID [0;7]
+ AliBitPacking::PackWord(word,baseWord,21,23);
+ word = nTDC; // TDC ID [0;14]
+ AliBitPacking::PackWord(word,baseWord,24,27);
+ word = 0; // error flag
+ AliBitPacking::PackWord(word,baseWord,28,28);
+ word = dummyPS; // Packing Status [0;3]
+ AliBitPacking::PackWord(word,baseWord,29,30);
+ word = 1; // TRM TDC digit ID
+ AliBitPacking::PackWord(word,baseWord,31,31);
+
+ localIndex++; fWordsPerTRM++;
+ localBuffer[localIndex]=baseWord;
+ psArray[localIndex]=dummyPS;
+
+ baseWord=0;
+
+ } // if ( fFakeOrphaneProduction && ( ( fPackedAcquisition && percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells) ) or ... ) )
+ } // if (indexDigit[0]<0)
+
for (jj=0; jj<3;jj++) {
if (indexDigit[jj]<0) continue;
+
+ AliDebug(3,Form(" ====== %2d %1d %2d %2d %1d -> %1d %d",volume[0],volume[1],volume[2],volume[3],volume[4],jj,indexDigit[jj]));
+
digs = (AliTOFdigit*)fTOFdigitArray->UncheckedAt(indexDigit[jj]);
if (digs->GetSector()!=volume[0] ||
digs->GetPlate() !=volume[1] ||
digs->GetStrip() !=volume[2] ||
digs->GetPadx() !=volume[3] ||
- digs->GetPadz() !=volume[4]) AliWarning(" --- ERROR --- ");
+ digs->GetPadz() !=volume[4]) AliWarning(Form(" --- ERROR --- %2i (%2i) %1i (%1i) %2i (%2i) %2i (%2i) %1i (%1i)",
+ digs->GetSector(), volume[0],
+ digs->GetPlate(), volume[1],
+ digs->GetStrip(), volume[2],
+ digs->GetPadx(), volume[3],
+ digs->GetPadz(), volume[4])
+ );
+
+ timeOfFlight = (Int_t)(digs->GetTdc());
+ /*+
+ fTOFCableLengthMap->GetCableTimeShiftBin(nDDL, nTRM, iChain, nTDC)*/;
+
+ //if (timeOfFlight>=fMatchingWindow+1000) continue; // adc
+ //if (timeOfFlight>=fMatchingWindow) continue; // adc
+ if (digs->GetTdcND()>=fMatchingWindow) {
+ AliDebug(2,"Out of matching window.");
+ continue; // adc
+ }
+ else AliDebug(2,"In matching window");
- timeOfFlight = (Int_t)(digs->GetTdc())%8192;
- totCharge = (Int_t)(digs->GetToT());//digs->GetAdc();
+ //numberOfMeasuresPerChannel++;
+
+ // totCharge = (Int_t)digs->GetAdc(); //Use realistic ToT, for Standard production with no miscalibration/Slewing it == fAdC in digit (see AliTOFDigitizer)
+ totCharge = (Int_t)(digs->GetToT());
// temporary control
- if (totCharge<0) totCharge = TMath::Abs(totCharge);
- if (totCharge>=256) totCharge = 255;
+ if (totCharge<0) totCharge = 0;//TMath::Abs(totCharge);
+
+ if (fPackedAcquisition) {
if (fVerbose==2) {
if (nDDL<10) ftxt << " " << nDDL;
ftxt << " " << volume[4];
if (volume[3]<10) ftxt << " " << volume[3];
else ftxt << " " << volume[3];
- if (totCharge<10) ftxt << " " << totCharge;
- else if (totCharge>=10 && totCharge<100) ftxt << " " << totCharge;
- else ftxt << " " << totCharge;
- if (timeOfFlight<10) ftxt << " " << timeOfFlight << endl;
- else if (timeOfFlight>=10 && timeOfFlight<100) ftxt << " " << timeOfFlight << endl;
- else if (timeOfFlight>=100 && timeOfFlight<1000) ftxt << " " << timeOfFlight << endl;
- else ftxt << " " << timeOfFlight << endl;
+ if (totCharge<10) ftxt << " " << totCharge;
+ else if (totCharge>=10 && totCharge<100) ftxt << " " << totCharge;
+ else ftxt << " " << totCharge;
+ if (timeOfFlight<10) ftxt << " " << timeOfFlight << endl;
+ else if (timeOfFlight>=10 && timeOfFlight<100) ftxt << " " << timeOfFlight << endl;
+ else if (timeOfFlight>=100 && timeOfFlight<1000) ftxt << " " << timeOfFlight << endl;
+ else ftxt << " " << timeOfFlight << endl;
}
- word = timeOfFlight; // time-of-fligth measurement
+ word = timeOfFlight%8192; // time-of-fligth measurement
AliBitPacking::PackWord(word,baseWord, 0,12);
+ if (totCharge>=256) totCharge = 255;
word = totCharge; // time-over-threshould measurement
AliBitPacking::PackWord(word,baseWord,13,20);
AliBitPacking::PackWord(word,baseWord,24,27);
word = 0; // error flag
AliBitPacking::PackWord(word,baseWord,28,28);
- word = 0; // Packing Status [0;5]
+ word = 0; // Packing Status [0;3]
AliBitPacking::PackWord(word,baseWord,29,30);
word = 1; // TRM TDC digit ID
AliBitPacking::PackWord(word,baseWord,31,31);
- fIndex++;
- buf[fIndex]=baseWord;
- nWordsPerTRM++;
+ localIndex++; fWordsPerTRM++;
+ localBuffer[localIndex]=baseWord;
+
baseWord=0;
+ if ( fFakeOrphaneProduction &&
+ percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells) ) {
+
+ percentFilledCells+=kOneMoreFilledCell;
+
+ trailingSpurious = Int_t(2097152*gRandom->Rndm());
+ leadingSpurious = Int_t(2097152*gRandom->Rndm());
+
+ Int_t dummyPS = 0;
+
+ if (outOut) {
+ word = trailingSpurious; // trailing edge measurement
+ dummyPS = 2;
+ }
+ else {
+ word = leadingSpurious; // leading edge measurement
+ dummyPS = 1;
+ }
+
+ if (fVerbose==2) {
+ if (nDDL<10) ftxt << " " << nDDL;
+ else ftxt << " " << nDDL;
+ if (nTRM<10) ftxt << " " << nTRM;
+ else ftxt << " " << nTRM;
+ ftxt << " " << iChain;
+ if (nTDC<10) ftxt << " " << nTDC;
+ else ftxt << " " << nTDC;
+ ftxt << " " << iCH;
+ if (volume[0]<10) ftxt << " -> " << volume[0];
+ else ftxt << " -> " << volume[0];
+ ftxt << " " << volume[1];
+ if (volume[2]<10) ftxt << " " << volume[2];
+ else ftxt << " " << volume[2];
+ ftxt << " " << volume[4];
+ if (volume[3]<10) ftxt << " " << volume[3];
+ else ftxt << " " << volume[3];
+ ftxt << " " << -1;
+ if (word<10) ftxt << " " << word;
+ else if (word>=10 && word<100) ftxt << " " << word;
+ else if (word>=100 && word<1000) ftxt << " " << word;
+ else if (word>=1000 && word<10000) ftxt << " " << word;
+ else if (word>=10000 && word<100000) ftxt << " " << word;
+ else if (word>=100000 && word<1000000) ftxt << " " << word;
+ else ftxt << " " << word;
+ ftxt << " " << dummyPS << endl;
+ }
+
+ AliBitPacking::PackWord(word,baseWord, 0,20);
+ word = iCH; // TDC channel ID [0;7]
+ AliBitPacking::PackWord(word,baseWord,21,23);
+ word = nTDC; // TDC ID [0;14]
+ AliBitPacking::PackWord(word,baseWord,24,27);
+ word = 0; // error flag
+ AliBitPacking::PackWord(word,baseWord,28,28);
+ word = dummyPS; // Packing Status [0;3]
+ AliBitPacking::PackWord(word,baseWord,29,30);
+ word = 1; // TRM TDC digit ID
+ AliBitPacking::PackWord(word,baseWord,31,31);
+
+ localIndex++; fWordsPerTRM++;
+ localBuffer[localIndex]=baseWord;
+ psArray[localIndex]=dummyPS;
+
+ baseWord=0;
+
+ } // if ( fFakeOrphaneProduction && percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells) )
+
+
+ } // if (fPackedAcquisition)
+ else { // if (!fPackedAcquisition)
+
+ if ( fFakeOrphaneProduction &&
+ percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && outOut ) {
+
+ percentFilledCells+=kOneMoreFilledCell;
+
+ trailingSpurious = Int_t(2097152*gRandom->Rndm());
+ word = trailingSpurious;
+ Int_t dummyPS = 2;
+
+ if (fVerbose==2) {
+ if (nDDL<10) ftxt << " " << nDDL;
+ else ftxt << " " << nDDL;
+ if (nTRM<10) ftxt << " " << nTRM;
+ else ftxt << " " << nTRM;
+ ftxt << " " << iChain;
+ if (nTDC<10) ftxt << " " << nTDC;
+ else ftxt << " " << nTDC;
+ ftxt << " " << iCH;
+ if (volume[0]<10) ftxt << " -> " << volume[0];
+ else ftxt << " -> " << volume[0];
+ ftxt << " " << volume[1];
+ if (volume[2]<10) ftxt << " " << volume[2];
+ else ftxt << " " << volume[2];
+ ftxt << " " << volume[4];
+ if (volume[3]<10) ftxt << " " << volume[3];
+ else ftxt << " " << volume[3];
+ ftxt << " " << -1;
+ if (word<10) ftxt << " " << word;
+ else if (word>=10 && word<100) ftxt << " " << word;
+ else if (word>=100 && word<1000) ftxt << " " << word;
+ else if (word>=1000 && word<10000) ftxt << " " << word;
+ else if (word>=10000 && word<100000) ftxt << " " << word;
+ else if (word>=100000 && word<1000000) ftxt << " " << word;
+ else ftxt << " " << word;
+ ftxt << " " << dummyPS << endl;
+ }
+
+ AliBitPacking::PackWord(word,baseWord, 0,20);
+ word = iCH; // TDC channel ID [0;7]
+ AliBitPacking::PackWord(word,baseWord,21,23);
+ word = nTDC; // TDC ID [0;14]
+ AliBitPacking::PackWord(word,baseWord,24,27);
+ word = 0; // error flag
+ AliBitPacking::PackWord(word,baseWord,28,28);
+ word = dummyPS; // Packing Status [0;3]
+ AliBitPacking::PackWord(word,baseWord,29,30);
+ word = 1; // TRM TDC digit ID
+ AliBitPacking::PackWord(word,baseWord,31,31);
+
+ localIndex++; fWordsPerTRM++;
+ localBuffer[localIndex]=baseWord;
+ psArray[localIndex]=dummyPS;
+
+ baseWord=0;
+
+ } // if ( fFakeOrphaneProduction && percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && outOut )
+
+
+ word = (timeOfFlight + Int_t(totCharge*AliTOFGeometry::ToTBinWidth()/AliTOFGeometry::TdcBinWidth()))%2097152; // trailing edge measurement
+
+ if (fVerbose==2) {
+ if (nDDL<10) ftxt << " " << nDDL;
+ else ftxt << " " << nDDL;
+ if (nTRM<10) ftxt << " " << nTRM;
+ else ftxt << " " << nTRM;
+ ftxt << " " << iChain;
+ if (nTDC<10) ftxt << " " << nTDC;
+ else ftxt << " " << nTDC;
+ ftxt << " " << iCH;
+ if (volume[0]<10) ftxt << " -> " << volume[0];
+ else ftxt << " -> " << volume[0];
+ ftxt << " " << volume[1];
+ if (volume[2]<10) ftxt << " " << volume[2];
+ else ftxt << " " << volume[2];
+ ftxt << " " << volume[4];
+ if (volume[3]<10) ftxt << " " << volume[3];
+ else ftxt << " " << volume[3];
+ ftxt << " " << -1;
+ if (word<10) ftxt << " " << word;
+ else if (word>=10 && word<100) ftxt << " " << word;
+ else if (word>=100 && word<1000) ftxt << " " << word;
+ else if (word>=1000 && word<10000) ftxt << " " << word;
+ else if (word>=10000 && word<100000) ftxt << " " << word;
+ else if (word>=100000 && word<1000000) ftxt << " " << word;
+ else ftxt << " " << word;
+ ftxt << " " << 2 << endl;
+ }
+
+ AliBitPacking::PackWord(word,baseWord, 0,20);
+
+ word = iCH; // TDC channel ID [0;7]
+ AliBitPacking::PackWord(word,baseWord,21,23);
+ word = nTDC; // TDC ID [0;14]
+ AliBitPacking::PackWord(word,baseWord,24,27);
+ word = 0; // error flag
+ AliBitPacking::PackWord(word,baseWord,28,28);
+ word = 2; // Packing Status [0;3]
+ AliBitPacking::PackWord(word,baseWord,29,30);
+ word = 1; // TRM TDC digit ID
+ AliBitPacking::PackWord(word,baseWord,31,31);
+
+ localIndex++; fWordsPerTRM++;
+ localBuffer[localIndex]=baseWord;
+ psArray[localIndex]=2;
+
+ baseWord=0;
+
+ word = timeOfFlight%2097152; // leading edge measurement
+
+ if (fVerbose==2) {
+ if (nDDL<10) ftxt << " " << nDDL;
+ else ftxt << " " << nDDL;
+ if (nTRM<10) ftxt << " " << nTRM;
+ else ftxt << " " << nTRM;
+ ftxt << " " << iChain;
+ if (nTDC<10) ftxt << " " << nTDC;
+ else ftxt << " " << nTDC;
+ ftxt << " " << iCH;
+ if (volume[0]<10) ftxt << " -> " << volume[0];
+ else ftxt << " -> " << volume[0];
+ ftxt << " " << volume[1];
+ if (volume[2]<10) ftxt << " " << volume[2];
+ else ftxt << " " << volume[2];
+ ftxt << " " << volume[4];
+ if (volume[3]<10) ftxt << " " << volume[3];
+ else ftxt << " " << volume[3];
+ ftxt << " " << -1;
+ if (word<10) ftxt << " " << word;
+ else if (word>=10 && word<100) ftxt << " " << word;
+ else if (word>=100 && word<1000) ftxt << " " << word;
+ else if (word>=1000 && word<10000) ftxt << " " << word;
+ else if (word>=10000 && word<100000) ftxt << " " << word;
+ else if (word>=100000 && word<1000000) ftxt << " " << word;
+ else ftxt << " " << word;
+ ftxt << " " << 1 << endl;
+ }
+
+ AliBitPacking::PackWord(word,baseWord, 0,20);
+
+ word = iCH; // TDC channel ID [0;7]
+ AliBitPacking::PackWord(word,baseWord,21,23);
+ word = nTDC; // TDC ID [0;14]
+ AliBitPacking::PackWord(word,baseWord,24,27);
+ word = 0; // error flag
+ AliBitPacking::PackWord(word,baseWord,28,28);
+ word = 1; // Packing Status [0;3]
+ AliBitPacking::PackWord(word,baseWord,29,30);
+ word = 1; // TRM TDC digit ID
+ AliBitPacking::PackWord(word,baseWord,31,31);
+
+ localIndex++; fWordsPerTRM++;
+ localBuffer[localIndex]=baseWord;
+ psArray[localIndex]=1;
+
+ baseWord=0;
+
+
+ if ( fFakeOrphaneProduction &&
+ percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && !outOut ) {
+
+ percentFilledCells+=kOneMoreFilledCell;
+
+ leadingSpurious = Int_t(2097152*gRandom->Rndm());
+ word = leadingSpurious;
+ Int_t dummyPS = 1;
+
+ if (fVerbose==2) {
+ if (nDDL<10) ftxt << " " << nDDL;
+ else ftxt << " " << nDDL;
+ if (nTRM<10) ftxt << " " << nTRM;
+ else ftxt << " " << nTRM;
+ ftxt << " " << iChain;
+ if (nTDC<10) ftxt << " " << nTDC;
+ else ftxt << " " << nTDC;
+ ftxt << " " << iCH;
+ if (volume[0]<10) ftxt << " -> " << volume[0];
+ else ftxt << " -> " << volume[0];
+ ftxt << " " << volume[1];
+ if (volume[2]<10) ftxt << " " << volume[2];
+ else ftxt << " " << volume[2];
+ ftxt << " " << volume[4];
+ if (volume[3]<10) ftxt << " " << volume[3];
+ else ftxt << " " << volume[3];
+ ftxt << " " << -1;
+ if (word<10) ftxt << " " << word;
+ else if (word>=10 && word<100) ftxt << " " << word;
+ else if (word>=100 && word<1000) ftxt << " " << word;
+ else if (word>=1000 && word<10000) ftxt << " " << word;
+ else if (word>=10000 && word<100000) ftxt << " " << word;
+ else if (word>=100000 && word<1000000) ftxt << " " << word;
+ else ftxt << " " << word;
+ ftxt << " " << dummyPS << endl;
+ }
+
+ AliBitPacking::PackWord(word,baseWord, 0,20);
+ word = iCH; // TDC channel ID [0;7]
+ AliBitPacking::PackWord(word,baseWord,21,23);
+ word = nTDC; // TDC ID [0;14]
+ AliBitPacking::PackWord(word,baseWord,24,27);
+ word = 0; // error flag
+ AliBitPacking::PackWord(word,baseWord,28,28);
+ word = dummyPS; // Packing Status [0;3]
+ AliBitPacking::PackWord(word,baseWord,29,30);
+ word = 1; // TRM TDC digit ID
+ AliBitPacking::PackWord(word,baseWord,31,31);
+
+ localIndex++; fWordsPerTRM++;
+ localBuffer[localIndex]=baseWord;
+ psArray[localIndex]=dummyPS;
+
+ baseWord=0;
+
+ } // if ( fFakeOrphaneProduction && percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && !outOut )
+
+
+ } // if (!fPackedAcquisition)
+
} //end loop on digits in the same volume
+ //if (numberOfMeasuresPerChannel>maxMeasuresPerChannelInTDC)
+ //maxMeasuresPerChannelInTDC = numberOfMeasuresPerChannel;
+
} // end loop on TDC channel number
+ //AliDebug(3,Form(" TDC number %2i: numberOfMeasuresPerChannel = %2i --- maxMeasuresPerChannelInTDC = %2i ", nTDC, numberOfMeasuresPerChannel, maxMeasuresPerChannelInTDC));
+
+ if (localIndex==-1) continue;
+
+ if (fPackedAcquisition) {
+
+ for (jj=0; jj<=localIndex; jj++) {
+ fIndex++;
+ buf[fIndex] = localBuffer[jj];
+ localBuffer[jj] = 0;
+ psArray[jj] = -1;
+ }
+
+ }
+ else {
+ /*
+ if (maxMeasuresPerChannelInTDC = 1) {
+
+ for (Int_t jj=0; jj<=localIndex; jj++) {
+ if (psArray[jj]==2) {
+ fIndex++;
+ buf[fIndex] = localBuffer[jj];
+ localBuffer[jj] = 0;
+ psArray[jj] = -1;
+ }
+ }
+ for (Int_t jj=0; jj<=localIndex; jj++) {
+ if (psArray[jj]==1) {
+ fIndex++;
+ buf[fIndex] = localBuffer[jj];
+ localBuffer[jj] = 0;
+ psArray[jj] = -1;
+ }
+ }
+
+ } // if (maxMeasuresPerChannelInTDC = 1)
+ else if (maxMeasuresPerChannelInTDC>1) {
+
+ AliDebug(3,Form(" In the TOF DDL %2i, TRM %2i, TDC %2i, chain %1i, the maximum number of t.o.f. good measurements per channel is %2i",
+ nDDL, nTRM, iChain, nTDC, iCH, maxMeasuresPerChannelInTDC));
+ */
+ for (jj=0; jj<=localIndex; jj++) {
+ fIndex++;
+ buf[fIndex] = localBuffer[jj];
+ localBuffer[jj] = 0;
+ psArray[jj] = -1;
+ }
+
+ //} // else if (maxMeasuresPerChannelInTDC>1)
+
+ } // else (!fPackedAcquisition)
+
+ localIndex = -1;
+
+ //maxMeasuresPerChannelInTDC = 0;
+
} // end loop on TDC number
return;
}
+
+//----------------------------------------------------------------------------
+Bool_t AliTOFDDLRawData::HeadOrTail() const
+{
+ //
+ // Returns the result of a 'pitch and toss'
+ //
+
+ Double_t dummy = gRandom->Rndm();
+
+ if (dummy<0.5) return kFALSE;
+ else return kTRUE;
+
+}