#include "AliFstream.h"
#include "AliITSFOSignalsSPD.h"
+using std::ofstream;
+using std::ios;
+using std::endl;
ClassImp(AliITSDDLRawData)
////////////////////////////////////////////////////////////////////////////////////////
fVerbose(0),
fIndex(-1),
fHalfStaveModule(-1),
-fUseCompressedSDDFormat(0){
+fSDDRawFormat(7){
//Default constructor
}
fVerbose(source.fVerbose),
fIndex(source.fIndex),
fHalfStaveModule(source.fHalfStaveModule),
-fUseCompressedSDDFormat(source.fUseCompressedSDDFormat){
+fSDDRawFormat(source.fSDDRawFormat){
//Copy Constructor
}
AliITSDDLRawData& AliITSDDLRawData::operator=(const AliITSDDLRawData &source){
//Assigment operator
- this->fIndex=source.fIndex;
- this->fHalfStaveModule=source.fHalfStaveModule;
- this->fVerbose=source.fVerbose;
- this->fUseCompressedSDDFormat=source.fUseCompressedSDDFormat;
+ if(this==&source) return *this;
+ fIndex=source.fIndex;
+ fHalfStaveModule=source.fHalfStaveModule;
+ fVerbose=source.fVerbose;
+ fSDDRawFormat=source.fSDDRawFormat;
return *this;
}
ix=digs->GetCoord2(); // Strip Number
is=digs->GetCompressedSignal(); // ADC Signal
// cout<<" Module:"<<mod-500<<" N/P side:"<<iz<<" Strip Number:"<<ix<<" Amplidute:"<<is-1<<endl;
- if(is<0) is = 4096 + is;
+ if(is<0) is = 0;
+ if(is>4095) is = 4095;
if (fVerbose==2)
ftxt<<"DDL:"<<ddl<<" Mod: "<<modR<<" N/P: "<<iz<<" Strip: "<<ix<<" Value: "<<is-1<<endl;
dataWord+=sid<<26;
dataWord+=iz<<18;
dataWord+=ix<<10;
- dataWord+=is;
+ UInt_t adcEncoded=0;
+ Int_t shift=0;
+ if(is < 8) shift=2;
+ else if(is<16) shift=3;
+ else if(is<32) shift=4;
+ else if(is<64) shift=5;
+ else if(is<128) shift=6;
+ else shift=7;
+ adcEncoded=shift+((is-(1<<shift))<<3);
+ dataWord+=adcEncoded;
fIndex++;
buf[fIndex]=dataWord;
}
}
- UInt_t finalWord=15<<28;
+ UInt_t finalWord=UInt_t(15)<<28;
finalWord+=mod;
fIndex++;
buf[fIndex]=finalWord;
fIndex=-1;
TClonesArray*& digits = * (TClonesArray**) branch->GetAddress();
- char fileName[15];
+ TString fileName;
AliFstream* outfile; // logical name of the output file
AliRawDataHeaderSim header;
//loop over DDLs
for(Int_t ddl=0;ddl<AliDAQ::NumberOfDdls("ITSSPD");ddl++){
- strcpy(fileName,AliDAQ::DdlFileName("ITSSPD",ddl)); //The name of the output file.
- outfile = new AliFstream(fileName);
+ fileName.Form("%s",AliDAQ::DdlFileName("ITSSPD",ddl)); //The name of the output file.
+ outfile = new AliFstream(fileName.Data());
//write Dummy DATA HEADER
UInt_t dataHeaderPosition=outfile->Tellp();
outfile->WriteBuffer((char*)(&header),sizeof(header));
fIndex=-1;
TClonesArray*& digits = * (TClonesArray**) branch->GetAddress();
- char fileName[15];
+ TString fileName;
AliFstream* outfile; // logical name of the output file
AliRawDataHeaderSim header;
//loop over DDLs
for(Int_t i=0;i<AliDAQ::NumberOfDdls("ITSSSD");i++){
- strcpy(fileName,AliDAQ::DdlFileName("ITSSSD",i)); //The name of the output file.
- outfile = new AliFstream(fileName);
+ fileName.Form("%s",AliDAQ::DdlFileName("ITSSSD",i)); //The name of the output file.
+ outfile = new AliFstream(fileName.Data());
//write Dummy DATA HEADER
UInt_t dataHeaderPosition=outfile->Tellp();
outfile->WriteBuffer((char*)(&header),sizeof(header));
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch, AliITSDDLModuleMapSDD* ddlsdd){
+Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch, const AliITSDDLModuleMapSDD* ddlsdd){
//This method creates the Raw data files for SDD detectors
const Int_t kSize=131072; //256*512
UInt_t buf[kSize];
fIndex=-1;
TClonesArray*& digits = * (TClonesArray**) branch->GetAddress();
- char fileName[15];
+ TString fileName;
AliFstream* outfile; // logical name of the output file
AliRawDataHeaderSim header;
- UInt_t skippedword, carlosFooterWord,fifoFooterWord,jitterWord;
+
+ if(fSDDRawFormat!=0){
+ for(Int_t ibit=0; ibit<8; ibit++) header.SetAttribute(ibit);
+ }else{
+ for(Int_t ibit=0; ibit<5; ibit++) header.SetAttribute(ibit);
+ for(Int_t ibit=5; ibit<8; ibit++) header.ResetAttribute(ibit);
+ }
+ UInt_t skippedword=0;
+ UInt_t carlosFooterWord=0;
+ UInt_t fifoFooterWord=0;
+ UInt_t jitterWord=0;
Bool_t retcode;
retcode = AliBitPacking::PackWord(0x3FFFFFFF,carlosFooterWord,0,31);
+ if(!retcode)AliError("AliBitPacking error\n");
retcode = AliBitPacking::PackWord(0x3F1F1F1F,fifoFooterWord,0,31);
- if(!fUseCompressedSDDFormat) retcode = AliBitPacking::PackWord(0x7F000000,jitterWord,0,31);
+ if(fSDDRawFormat!=0) retcode = AliBitPacking::PackWord(0x7F000000,jitterWord,0,31);
else retcode = AliBitPacking::PackWord(0x80000000,jitterWord,0,31);
//loop over DDLs
for(Int_t i=0;i<AliDAQ::NumberOfDdls("ITSSDD");i++){
- strcpy(fileName,AliDAQ::DdlFileName("ITSSDD",i)); //The name of the output file.
- outfile = new AliFstream(fileName);
+ fileName.Form("%s",AliDAQ::DdlFileName("ITSSDD",i)); //The name of the output file.
+ outfile = new AliFstream(fileName.Data());
//write Dummy DATA HEADER
UInt_t dataHeaderPosition=outfile->Tellp();
outfile->WriteBuffer((char*)(&header),sizeof(header));
//first 1 "dummy" word to be skipped
- if(!fUseCompressedSDDFormat){
+ if(fSDDRawFormat!=0){
retcode = AliBitPacking::PackWord(0xFFFFFFFF,skippedword,0,31);
outfile->WriteBuffer((char*)(&skippedword),sizeof(skippedword));
}
//For each Module, buf contains the array of data words in Binary format
//fIndex gives the number of 32 bits words in the buffer for each module
// cout<<"MODULE NUMBER:"<<mapSDD[i][mod]<<endl;
- if(fUseCompressedSDDFormat){
+ if(fSDDRawFormat==0){
GetDigitsSDDCompressed(digits,mod,buf);
outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
}else{
}//end if
}//end for
// 12 words with FIFO footers (=4 FIFO x 3 3F1F1F1F words per DDL)
- if(!fUseCompressedSDDFormat){
+ if(fSDDRawFormat!=0){
for(Int_t iw=0;iw<12;iw++) outfile->WriteBuffer((char*)(&fifoFooterWord),sizeof(fifoFooterWord));
}
outfile->WriteBuffer((char*)(&jitterWord),sizeof(jitterWord));
}//end else
return;
}//end WriteHit
+