From 14dceddf425e481482770e8ee051d25b9ae0aeba Mon Sep 17 00:00:00 2001 From: masera Date: Mon, 26 Nov 2007 17:26:59 +0000 Subject: [PATCH] SDD cluster finding adapted to real raw data formata (one DDL at once) - F. Prino --- ITS/AliITSClusterFinderV2SDD.cxx | 41 +++++------ ITS/AliITSDDLRawData.cxx | 11 +-- ITS/AliITSRawStreamSDD.cxx | 122 +++++++++++-------------------- ITS/AliITSRawStreamSDD.h | 14 ++-- 4 files changed, 73 insertions(+), 115 deletions(-) diff --git a/ITS/AliITSClusterFinderV2SDD.cxx b/ITS/AliITSClusterFinderV2SDD.cxx index 24b53021602..9478b09767b 100644 --- a/ITS/AliITSClusterFinderV2SDD.cxx +++ b/ITS/AliITSClusterFinderV2SDD.cxx @@ -87,7 +87,6 @@ void AliITSClusterFinderV2SDD::FindClustersSDD(TClonesArray *digits) { if(gain>0) charge/=gain; if(chargeGetThresholdAnode(d->GetCoord1())) continue; Int_t q=(Int_t)(charge+0.5); - if (z <= nAnodes){ bins[0][y*nzBins+z].SetQ(q); bins[0][y*nzBins+z].SetMask(1); @@ -271,54 +270,54 @@ void AliITSClusterFinderV2SDD::FindClustersSDD(AliITSRawStream* input, Int_t nxBins = nTimeBins+2; const Int_t kMaxBin=nzBins*(nxBins+2); AliBin *bins[2]; - bins[0]=new AliBin[kMaxBin]; - bins[1]=new AliBin[kMaxBin]; - + AliBin *ddlbins[24]; // 12 modules (=24 hybrids) of 1 DDL read "in parallel" + for(Int_t iHyb=0;iHyb<24;iHyb++) ddlbins[iHyb]=new AliBin[kMaxBin]; // read raw data input stream - while (kTRUE) { - Bool_t next = input->Next(); - if (!next || input->IsCompletedModule()) { + while (input->Next()) { + Int_t iCarlos =((AliITSRawStreamSDD*)input)->GetCarlosId(); + Int_t iSide = ((AliITSRawStreamSDD*)input)->GetChannel(); + Int_t iHybrid=iCarlos*2+iSide; + if (input->IsCompletedModule()) { // when all data from a module was read, search for clusters Int_t iModule = input->GetModuleID(); if (iModule >= 0) { clusters[iModule] = new TClonesArray("AliITSRecPoint"); fModule = iModule; + bins[0]=ddlbins[iCarlos*2]; // first hybrid of the completed module + bins[1]=ddlbins[iCarlos*2+1]; // second hybrid of the completed module FindClustersSDD(bins, kMaxBin, nzBins, NULL, clusters[iModule]); Int_t nClusters = clusters[iModule]->GetEntriesFast(); nClustersSDD += nClusters; for(Int_t iBin=0;iBinGetModuleID()); AliITSresponseSDD* res = (AliITSresponseSDD*)cal->GetResponse(); const char *option=res->ZeroSuppOption(); Float_t charge=input->GetSignal(); - Float_t gain=cal->GetChannelGain(input->GetCoord1()); + Int_t chan=input->GetCoord1()+nAnodes*iSide; + Float_t gain=cal->GetChannelGain(chan); if(!((strstr(option,"1D")) || (strstr(option,"2D")))){ - Float_t baseline = cal->GetBaseline(input->GetCoord1()); + Float_t baseline = cal->GetBaseline(chan); if(charge>baseline) charge-=baseline; else charge=0; } if(gain>0) charge/=gain; - Int_t q=(Int_t)(charge+0.5); - if(q>=cal->GetThresholdAnode(input->GetCoord1())) { + if(charge>=cal->GetThresholdAnode(chan)) { + Int_t q=(Int_t)(charge+0.5); Int_t iz = input->GetCoord1()+1; - Int_t side = ((AliITSRawStreamSDD*)input)->GetChannel(); Int_t index = (input->GetCoord2()+1) * nzBins + iz; - bins[side][index].SetQ(q); - bins[side][index].SetMask(1); - bins[side][index].SetIndex(index); + ddlbins[iHybrid][index].SetQ(q); + ddlbins[iHybrid][index].SetMask(1); + ddlbins[iHybrid][index].SetIndex(index); } } } - delete [] bins[0]; - delete [] bins[1]; - + for(Int_t iHyb=0;iHyb<24;iHyb++) delete [] ddlbins[iHyb]; Info("FindClustersSDD", "found clusters in ITS SDD: %d", nClustersSDD); } diff --git a/ITS/AliITSDDLRawData.cxx b/ITS/AliITSDDLRawData.cxx index 700f9fefef1..dbc33469136 100644 --- a/ITS/AliITSDDLRawData.cxx +++ b/ITS/AliITSDDLRawData.cxx @@ -140,7 +140,7 @@ void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod,Int_t modR } } //word to select the 12 carlos for the 12 modules - UInt_t carlosid=805306368+mod; + UInt_t carlosid=0x30000000+mod; fIndex++; buf[fIndex]=carlosid; @@ -178,28 +178,25 @@ void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod,Int_t modR ix=digs->GetCoord2(); // Time is=digs->GetCompressedSignal(); // ADC Signal digarr[iz][ix]=is; - if (fVerbose==2) + if (fVerbose==2) ftxt<<"DDL:"<255){Error("GetDigitsSDD", "bits words is needed)!!!");} } for(Int_t anode=0;anode<512;anode++){ - if(flag){ + if(flag){ last = first+diff-1; AliBitPacking::PackWord(word2,baseWord,first,last); flag = kFALSE; first = last+1; diff=0; } - - if(anode == 256){ last = 0; first = 0; flag = kFALSE; diff = 0; word2=0; - } for(Int_t tb=0;tb<256;tb++){ @@ -589,7 +586,7 @@ Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch){ Bool_t retcode; retcode = AliBitPacking::PackWord(0x3FFFFFFF,carlosFooterWord,0,31); retcode = AliBitPacking::PackWord(0x3F1F1F1F,fifoFooterWord,0,31); - retcode = AliBitPacking::PackWord(0xFF00000E,jitterWord,0,31); + retcode = AliBitPacking::PackWord(0x7F00000E,jitterWord,0,31); //loop over DDLs for(Int_t i=0;iGetDDLID(); - //cout << "fDDL: " << fDDL; Int_t ddln = fRawReader->GetDDLID(); - //cout << ", ddln: " << ddln << endl; if(ddln <0) ddln=0; fCompletedModule=kFALSE; @@ -129,100 +126,69 @@ Bool_t AliITSRawStreamSDD::Next() } if ((fChannel < 0) || (fLastBit[fCarlosId][fChannel] < fReadBits[fCarlosId][fChannel])) { - if (!fRawReader->ReadNextInt(fData)) { - //cout << "read word in Next and skip, fData: "; - //printf("%x\n",fData); - return kFALSE; // read next word - } - //cout << "read word in Next, fData: "; - //printf("%x\n",fData); + + if (!fRawReader->ReadNextInt(fData)) return kFALSE; // read next word ddln = fRawReader->GetDDLID(); if(ddln!=fDDL) { Reset(); - fChannel=-1; fDDL=fRawReader->GetDDLID(); } if(ddln < 0 || ddln > (kDDLsNumber-1)) ddln = 0; - //cout << "in the while loop, fDDL: " << fDDL << ", ddln: " << ddln << endl; fChannel = -1; - if(fData>=fICarlosWord[0]&&fData<=fICarlosWord[11]) { // Carlos Word - if(fEndWords==12) continue; // out of event - else if(fEndWords<12){ - fCarlosId = fData-fICarlosWord[0]; - Int_t iFifoIdx = fCarlosId/3; - if(fNCarlos == 8) { - if(fCarlosId==2) iFifoIdx = 1; - if(fCarlosId==4 || fCarlosId==5) iFifoIdx = 2; - if(fCarlosId==6 || fCarlosId==7) iFifoIdx = 3 ; - } - fNfifo[iFifoIdx] = fCarlosId; - //cout << "set fCarlosId to " << fCarlosId << " and fNfifo[" << iFifoIdx << "] to " << fNfifo[iFifoIdx] << endl; - } - } else if (fData>=fIFifoWord[0]&&fData<=fIFifoWord[3]){ - if(fEndWords==12) continue; // out of event - else if(fEndWords<12){ - //cout << "fData-fIFifoWord[0]: " << fData-fIFifoWord[0] << endl; - fCarlosId = fNfifo[fData-fIFifoWord[0]]; - //cout << "fCarlosId set to " << fCarlosId << " from FIFO Word" << endl; - } - } - if((fData >> 4) == 0xFF00000){ // jitter word (to be improved !!!!) + if((fData >> 16) == 0x7F00){ // jitter word for data since october 2007 for(Int_t i=0;iGetDDLID() << " and fCarlosId: " << fCarlosId << endl; - fModuleID = fgkDDLModuleMap[fRawReader->GetDDLID()][fCarlosId]; - //cout<<"AliITSRawStreamSDD: fModuleID: "<> 28) == 0x02) { // header - fEventId = (fData >> 3) & 0x07FF; - //cout<<"AliITSRawStreamSDD:fEventID: "<> 28)== 0x03) { // footer - if(fData==0x3FFFFFFF){ + UInt_t nData28= fData >> 28; + UInt_t nData30= fData >> 30; + + + if (nData28== 0x02) { // header + fEventId = (fData >> 3) & 0x07FF; + } else if (nData28== 0x03) { // Carlos and FIFO words or Footers + if(fData>=fICarlosWord[0]&&fData<=fICarlosWord[11]) { // Carlos Word + if(fEndWords==12) continue; // out of event + fCarlosId = fData-fICarlosWord[0]; + Int_t iFifoIdx = fCarlosId/3; + if(fNCarlos == 8) iFifoIdx=fCarlosId/2; + fNfifo[iFifoIdx] = fCarlosId; + } else if (fData>=fIFifoWord[0]&&fData<=fIFifoWord[3]){ // FIFO word + if(fEndWords==12) continue; // out of event + fCarlosId = fNfifo[fData-fIFifoWord[0]]; + } else if(fData==0x3FFFFFFF){ // Carlos footer fICountFoot[fCarlosId]++; // stop before the last word (last word=jitter) if(fICountFoot[fCarlosId]==3){ fCompletedModule=kTRUE; return kTRUE; } - } - } else if ((fData >> 29) == 0x00) { // error - if ((fData & 0x00000163) != 0) { - fRawReader->AddMajorErrorLog(kDataError,Form("Error code = %8.8x",fData)); - AliWarning(Form("error codes = %8.8x",fData)); - return kFALSE; + } else if(fData==0x3F1F1F1F){ // CarlosRX footer + fEndWords++; + if(fEndWords<=12) continue; + }else{ + fRawReader->AddMajorErrorLog(kDataError,"Too many footers"); + AliWarning(Form("invalid data: too many footers\n", fData)); + return kFALSE; } - } else if ((fData >> 30) == 0x01) { // JTAG word - // ignored - } else if ((fData >> 30) == 0x02) { // channel 0 data - fChannel = 0; - //cout << "fChannel set to " << fChannel << endl; - } else if ((fData >> 30) == 0x03) { // channel 1 data - fChannel = 1; - //cout << "fChannel set to " << fChannel << endl; + } else if (nData30 == 0x02 || nData30 == 0x03) { + fChannel = nData30-2; + fChannelData[fCarlosId][fChannel] += + (ULong64_t(fData & 0x3FFFFFFF) << fLastBit[fCarlosId][fChannel]); + fLastBit[fCarlosId][fChannel] += 30; } else { // unknown data format fRawReader->AddMajorErrorLog(kDataFormatErr,Form("Invalid data %8.8x",fData)); AliWarning(Form("invalid data: %8.8x\n", fData)); return kFALSE; } - if (fChannel >= 0) { // add read word to the data - //cout << "add read word to the data" << endl; - fChannelData[fCarlosId][fChannel] += - (ULong64_t(fData & 0x3FFFFFFF) << fLastBit[fCarlosId][fChannel]); - fLastBit[fCarlosId][fChannel] += 30; - } + if (fNCarlos == 8 && fCarlosId >= 8) continue; // old data, fNCarlos = 8; + + fModuleID = fgkDDLModuleMap[fRawReader->GetDDLID()][fCarlosId]; + } else { // decode data if (fReadCode[fCarlosId][fChannel]) {// read the next code word fChannelCode[fCarlosId][fChannel] = ReadBits(); @@ -242,14 +208,13 @@ Bool_t AliITSRawStreamSDD::Next() fCoord1 = fAnode[fCarlosId][fChannel]; fCoord2 = fTimeBin[fCarlosId][fChannel]; fTimeBin[fCarlosId][fChannel]++; - //cout << "data read, Module, Anode, Time, Charge = " << fModuleID << "," << fCoord1 << "," << fCoord2 << "," << fSignal << endl; + //printf("Data read, Module=%d , Anode=%d , Time=%d , Charge=%d\n",fModuleID,fCoord1,fCoord2,fSignal); return kTRUE; } } } } - return kFALSE; - + return kFALSE; } void AliITSRawStreamSDD::Reset(){ @@ -260,8 +225,8 @@ void AliITSRawStreamSDD::Reset(){ fChannelData[ic][i]=0; fLastBit[ic][i]=0; fChannelCode[ic][i]=0; - fReadCode[ic][i]=kFALSE; - fReadBits[ic][i]=0; + fReadCode[ic][i]=kTRUE; + fReadBits[ic][i]=3; fTimeBin[ic][i]=0; fAnode[ic][i]=0; } @@ -271,16 +236,13 @@ void AliITSRawStreamSDD::Reset(){ } Bool_t AliITSRawStreamSDD::ResetSkip(Int_t ddln){ + // skip the 9 DDL header words Bool_t startCount=kFALSE; while (fSkip[ddln] < 9) { if (!fRawReader->ReadNextInt(fData)) { - //cout << "read word in ResetSkip, fData: "; - //printf("%x\n",fData); - //cout << "return kFALSE in resetskip" << endl; return kFALSE; } if(fData==0xFFFFFFFF) startCount=kTRUE; - //cout << "read word in ResetSkip, fData: "; //printf("%x\n",fData); if ((fData >> 30) == 0x01) continue; // JTAG word if(startCount) fSkip[ddln]++; diff --git a/ITS/AliITSRawStreamSDD.h b/ITS/AliITSRawStreamSDD.h index bd588879c55..c8748278ff0 100644 --- a/ITS/AliITSRawStreamSDD.h +++ b/ITS/AliITSRawStreamSDD.h @@ -55,8 +55,8 @@ class AliITSRawStreamSDD: public AliITSRawStream { UInt_t fData; // data read for file Int_t fSkip[kDDLsNumber];// number of skipped words - Int_t fCarlosId; // carlos ID Int_t fEventId; // event ID from header + Int_t fCarlosId; // carlos ID Int_t fChannel; // current channel Int_t fJitter; // jitter between L0 and pascal stop (x25ns) ULong64_t fChannelData[kModulesPerDDL][2];// packed data for the 2 channels @@ -66,15 +66,15 @@ class AliITSRawStreamSDD: public AliITSRawStream { UInt_t fReadBits[kModulesPerDDL][2]; // number of bits to read Int_t fLowThreshold[2]; // low Carlos threshold Int_t fNCarlos; // number of Carlos - Int_t fNfifo[kFifoWords]; + Int_t fNfifo[kFifoWords]; // FIFO number Int_t fTimeBin[kModulesPerDDL][2]; // current timebin [ncarlos][nchannels] Int_t fAnode[kModulesPerDDL][2]; // current anode [ncarlos][nchannels] Int_t fDDL; //current ddl number - UInt_t fICarlosWord[kCarlosWords]; - UInt_t fIFifoWord[kFifoWords]; - Int_t fICountFoot[kModulesPerDDL]; - Int_t fEndWords;//number of 3f1f1f1f - Int_t fResetSkip; //if it is 0, the ResetSkip Funcion is called + UInt_t fICarlosWord[kCarlosWords]; // Carlos words + UInt_t fIFifoWord[kFifoWords]; // FIFO words + Int_t fICountFoot[kModulesPerDDL]; // counter for carlos footer words + Int_t fEndWords; //number of 3f1f1f1f + Int_t fResetSkip; //if it is 0, the ResetSkip Funcion is called ClassDef(AliITSRawStreamSDD, 7) // class for reading ITS SDD raw digits }; -- 2.43.0