X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSDDLRawData.cxx;h=a0ba53ead55bc81492bb327d6cc75945f643d178;hb=f41a58ba1b306e1e3f100ae58e4a05557ff58e65;hp=7a04db20ff774d0d1f2faf57e81207a753d1cc2d;hpb=979b5a5f346aa4764ee6d0d0f4719832e10250d5;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSDDLRawData.cxx b/ITS/AliITSDDLRawData.cxx index 7a04db20ff7..a0ba53ead55 100644 --- a/ITS/AliITSDDLRawData.cxx +++ b/ITS/AliITSDDLRawData.cxx @@ -37,14 +37,19 @@ #include "AliBitPacking.h" #include "AliDAQ.h" #include "AliFstream.h" +#include "AliITSFOSignalsSPD.h" +using std::ofstream; +using std::ios; +using std::endl; ClassImp(AliITSDDLRawData) //////////////////////////////////////////////////////////////////////////////////////// AliITSDDLRawData::AliITSDDLRawData(): fVerbose(0), fIndex(-1), -fHalfStaveModule(-1){ +fHalfStaveModule(-1), +fSDDRawFormat(7){ //Default constructor } @@ -55,7 +60,8 @@ AliITSDDLRawData::AliITSDDLRawData(const AliITSDDLRawData &source) : TObject(source), fVerbose(source.fVerbose), fIndex(source.fIndex), -fHalfStaveModule(source.fHalfStaveModule){ +fHalfStaveModule(source.fHalfStaveModule), +fSDDRawFormat(source.fSDDRawFormat){ //Copy Constructor } @@ -63,9 +69,11 @@ fHalfStaveModule(source.fHalfStaveModule){ AliITSDDLRawData& AliITSDDLRawData::operator=(const AliITSDDLRawData &source){ //Assigment operator - this->fIndex=source.fIndex; - this->fHalfStaveModule=source.fHalfStaveModule; - this->fVerbose=source.fVerbose; + if(this==&source) return *this; + fIndex=source.fIndex; + fHalfStaveModule=source.fHalfStaveModule; + fVerbose=source.fVerbose; + fSDDRawFormat=source.fSDDRawFormat; return *this; } @@ -94,7 +102,8 @@ void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod,Int_t modR ix=digs->GetCoord2(); // Strip Number is=digs->GetCompressedSignal(); // ADC Signal // cout<<" Module:"<4095) is = 4095; if (fVerbose==2) ftxt<<"DDL:"<GetEntries(); + AliITSdigit *digs; + if(ndigits){ + for (Int_t digit=0;digitUncheckedAt(digit); + Int_t iz=digs->GetCoord1(); // Anode + Int_t ix=digs->GetCoord2(); // Time + Int_t is=digs->GetCompressedSignal(); // ADC Signal - 8 bit + dataWord=mod<<27; + Int_t sid=0; + if(iz>=256){ + sid=1; + iz-=256; + } + dataWord+=sid<<26; + dataWord+=iz<<18; + dataWord+=ix<<10; + 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<=128value = value - (1 << 7) (word is 7 bit long) */ + //if(digarr[anode][tb]<4) continue; // not write <4 cnts above tL if(digarr[anode][tb]<8){ bitinfo1[3] = 2; wordinfo1[2] = 2; @@ -375,7 +429,7 @@ void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod,Int_t modR //PIXEL // -void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, UInt_t *buf){ +void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, UInt_t *buf, AliITSFOSignalsSPD* foSignals){ //This method packs the SPD digits in a proper 32 structure //Since data is zero suppressed,the coordinates for the chip having zero digits //doesn't get listed in the galice.root file. However the SPD format requires @@ -383,26 +437,29 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, Int_t chipLow = AliITSRawStreamSPD::GetOnlineChipFromOffline(mod,0); Int_t chipHigh = AliITSRawStreamSPD::GetOnlineChipFromOffline(mod,159); + if (chipLow>chipHigh) {chipLow -= 4; chipHigh += 4;} + UInt_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(mod); UInt_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(mod); // create int map to later hold all digits sorted AliITSIntMap* digMap = new AliITSIntMap(); UInt_t baseWord=0; - Int_t chipHitCount=0; //Number of Hit in the current chip - Int_t previousChip=-1; //Previuos chip respect to the actual aone + Int_t ndigits = ITSdigits->GetEntries(); //number of digits in the current module //cout<<" Number of digits in the current module:"<UncheckedAt(digit); + if (fVerbose==2) ftxt.open("SPDdigits.txt",ios::app); + for (Int_t digit=0; digitUncheckedAt(digit); /*--------------------------------------------------------------------------- * Each module contains 5 read out chips of 256 rows and 32 columns. * So, the cell number in Z direction varies from 0 to 159. @@ -410,71 +467,70 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, Int_t iz=digs->GetCoord1(); // Cell number in Z direction Int_t ix=digs->GetCoord2(); // Cell number in X direction - if(fVerbose==2) - ftxt<<"DDL:"<Insert(chip*256*32+(32-col)*256+(256-row),row); + digMap->Insert(chip*256*32+(31-col)*256+(255-row),row); } } + // _______________________________________________________________________ + // Procedure for writing raw data (Henrik Tydesjo) + // Reimplemented because of unreadability (5 Mar 2009) + // Now also with fast-or signals + Int_t previousChip = chipLow-1; + Int_t chip = chipLow-1; + UInt_t chipHitCount = 0; + + UInt_t nrHits = digMap->GetNrEntries(); - if (nrHits>0) { - Int_t chip = 0; - for (UInt_t nHit=0; nHitGetKeyIndex(nHit); - chip = key/(256*32); - Int_t col = 32 - (key%(256*32))/256; - Int_t row = digMap->GetValIndex(nHit); - - if(previousChip==-1) { // first hit - //loop over chip without digits - //Even if there aren't digits for a given chip - //the chip header and the chip trailer are stored - for (Int_t i=chipLow; iGetKeyIndex(nHit); + chip = key/(256*32); + Int_t col = 31 - (key%(256*32))/256; + Int_t row = digMap->GetValIndex(nHit); + + // add trailer for previous chip (if there was one...) + if (chip>previousChip && previousChip>chipLow-1) { + WriteChipTrailer(buf, chipHitCount, foSignals->GetSignal(eq,hs,previousChip), baseWord); + } + + // add headers/trailers for chips without hits (if any) + for (Int_t ch=previousChip+1; chGetSignal(eq,hs,ch), baseWord); + } + + // if new chip, add header + if (chip>previousChip) { + WriteChipHeader(chip, hs, baseWord); + chipHitCount = 0; + previousChip = chip; + } + + chipHitCount++; + + // add pixel hit + WriteHit(buf,row,col,baseWord); + + } + + // add trailer for last chip (if there was one...) + if (chip>chipLow-1) { + WriteChipTrailer(buf, chipHitCount, foSignals->GetSignal(eq,hs,chip), baseWord); + } + + // add REMAINING headers/trailers for chips without hits (if any) + for (Int_t ch=chip+1; ch<=chipHigh; ch++) { + WriteChipHeader(ch, hs, baseWord); + WriteChipTrailer(buf, 0, foSignals->GetSignal(eq,hs,ch), baseWord); + } + // _______________________________________________________________________ + delete digMap; @@ -485,32 +541,32 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch){ +Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch, AliITSFOSignalsSPD* foSignals){ //This method creates the Raw data files for SPD detectors const Int_t kSize=21000; //256*32*5=40960 max number of digits per module UInt_t buf[kSize]; //One buffer cell can contain 2 digits 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;iTellp(); outfile->WriteBuffer((char*)(&header),sizeof(header)); //Loops over Modules of a particular DDL for (Int_t mod=0; modClear(); branch->GetEvent(moduleNumber); //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 - GetDigitsSPD(digits,mod,i,buf); + GetDigitsSPD(digits, moduleNumber, ddl, buf, foSignals); outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t))); for(Int_t i=0;i<(fIndex+1);i++){ buf[i]=0; @@ -539,14 +595,14 @@ Int_t AliITSDDLRawData::RawDataSSD(TBranch* branch){ 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;iTellp(); outfile->WriteBuffer((char*)(&header),sizeof(header)); @@ -579,34 +635,48 @@ Int_t AliITSDDLRawData::RawDataSSD(TBranch* branch){ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -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); - retcode = AliBitPacking::PackWord(0x7F00000E,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;iTellp(); outfile->WriteBuffer((char*)(&header),sizeof(header)); //first 1 "dummy" word to be skipped - retcode = AliBitPacking::PackWord(0xFFFFFFFF,skippedword,0,31); - outfile->WriteBuffer((char*)(&skippedword),sizeof(skippedword)); + if(fSDDRawFormat!=0){ + retcode = AliBitPacking::PackWord(0xFFFFFFFF,skippedword,0,31); + outfile->WriteBuffer((char*)(&skippedword),sizeof(skippedword)); + } //Loops over Modules of a particular DDL for (Int_t mod=0; modWriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t))); - for(Int_t iw=0;iw<3;iw++) outfile->WriteBuffer((char*)(&carlosFooterWord),sizeof(carlosFooterWord)); + if(fSDDRawFormat==0){ + GetDigitsSDDCompressed(digits,mod,buf); + outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t))); + }else{ + GetDigitsSDD(digits,mod,moduleNumber,i,buf); + outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t))); + for(Int_t iw=0;iw<3;iw++) outfile->WriteBuffer((char*)(&carlosFooterWord),sizeof(carlosFooterWord)); + } fIndex=-1; }//end if }//end for // 12 words with FIFO footers (=4 FIFO x 3 3F1F1F1F words per DDL) - for(Int_t iw=0;iw<12;iw++) outfile->WriteBuffer((char*)(&fifoFooterWord),sizeof(fifoFooterWord)); - + if(fSDDRawFormat!=0){ + for(Int_t iw=0;iw<12;iw++) outfile->WriteBuffer((char*)(&fifoFooterWord),sizeof(fifoFooterWord)); + } outfile->WriteBuffer((char*)(&jitterWord),sizeof(jitterWord)); - //Write REAL DATA HEADER UInt_t currentFilePosition=outfile->Tellp(); outfile->Seekp(dataHeaderPosition); @@ -657,13 +732,15 @@ void AliITSDDLRawData::WriteChipHeader(Int_t ChipAddr,Int_t halfStave,UInt_t &Ba ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void AliITSDDLRawData::WriteChipTrailer(UInt_t *buf,Int_t ChipHitCount,UInt_t &BaseWord){ +void AliITSDDLRawData::WriteChipTrailer(UInt_t *buf, Int_t ChipHitCount, Bool_t foBit, UInt_t &BaseWord){ //This method writes a chip trailer //pixel fill word if((ChipHitCount%2)!=0){ AliBitPacking::PackWord(0xC000,BaseWord,16,31); } - AliBitPacking::PackWord(ChipHitCount,BaseWord,0,13); + AliBitPacking::PackWord(ChipHitCount,BaseWord,0,11); + AliBitPacking::PackWord(0x0,BaseWord,12,12); + AliBitPacking::PackWord(foBit,BaseWord,13,13); AliBitPacking::PackWord(0x0,BaseWord,14,15); fIndex++; buf[fIndex]=BaseWord;