]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
SDD cluster finding adapted to real raw data formata (one DDL at once) - F. Prino
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Nov 2007 17:26:59 +0000 (17:26 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Nov 2007 17:26:59 +0000 (17:26 +0000)
ITS/AliITSClusterFinderV2SDD.cxx
ITS/AliITSDDLRawData.cxx
ITS/AliITSRawStreamSDD.cxx
ITS/AliITSRawStreamSDD.h

index 24b53021602e6251768a37a2700dab6c115fefb6..9478b09767b20ecc2d8814fe8498022686ed6e09 100644 (file)
@@ -87,7 +87,6 @@ void AliITSClusterFinderV2SDD::FindClustersSDD(TClonesArray *digits) {
      if(gain>0) charge/=gain;
      if(charge<cal->GetThresholdAnode(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;iBin<kMaxBin; iBin++){
-         bins[0][iBin].Reset();
-         bins[1][iBin].Reset();
+         ddlbins[iCarlos*2][iBin].Reset();
+         ddlbins[iCarlos*2+1][iBin].Reset();
        }
       }
-      if (!next) break;
     }else{
     // fill the current digit into the bins array
       AliITSCalibrationSDD* cal = (AliITSCalibrationSDD*)GetResp(input->GetModuleID());    
       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);
 }
 
index 700f9fefef12b14d689e006cbf3f93b9c48ab515..dbc334691363d7207956291c9a4bb0a6bc1a218e 100644 (file)
@@ -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:"<<ddl<<" MID:"<<modR<<" An:"<<iz<<" T:"<<ix<<" A:"<<is<<endl;
       if (is>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;i<AliDAQ::NumberOfDdls("ITSSDD");i++){
index 522361d14a7400d24d5b6dabbac8d6089989fd76..4a7107138cf71133994870ff59c22e3ec11af7de 100644 (file)
@@ -24,7 +24,6 @@
 #include "AliITSRawStreamSDD.h"
 #include "AliRawReader.h"
 #include "AliLog.h"
-#include "Riostream.h"
 
 ClassImp(AliITSRawStreamSDD)
 
@@ -60,8 +59,8 @@ const UInt_t AliITSRawStreamSDD::fgkCodeLength[8] =  {8, 18, 2, 3, 4, 5, 6, 7};
 AliITSRawStreamSDD::AliITSRawStreamSDD(AliRawReader* rawReader) :
   AliITSRawStream(rawReader),
 fData(0),
-fCarlosId(-1),
 fEventId(0),
+fCarlosId(-1),
 fChannel(0),
 fJitter(0),
 fNCarlos(kModulesPerDDL),
@@ -115,9 +114,7 @@ Bool_t AliITSRawStreamSDD::Next()
 
   fPrevModuleID = fModuleID;
   fDDL=fRawReader->GetDDLID();
-  //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;i<kDDLsNumber;i++){fSkip[i]=0;}
        fResetSkip=0;
        fEndWords=0;
        continue;
       }
 
-      if(fData==0x3F1F1F1F){
-       fEndWords++;
-       if(fEndWords<=12) continue;
-      }
-      if (fNCarlos == 8 && (fCarlosId == 8 || fCarlosId == 9 || 
-                           fCarlosId ==10 || fCarlosId == 11)) continue;  // old data, fNCarlos = 8;
-            
-      //cout << "set module from DDLID " << fRawReader->GetDDLID() << " and fCarlosId: " << fCarlosId << endl;
-      fModuleID = fgkDDLModuleMap[fRawReader->GetDDLID()][fCarlosId];    
-      //cout<<"AliITSRawStreamSDD: fModuleID: "<<fModuleID<<endl;
-      
-      if ((fData >> 28) == 0x02) {           // header
-       fEventId = (fData >> 3) & 0x07FF;
-       //cout<<"AliITSRawStreamSDD:fEventID: "<<fEventId<<endl;
-      } else if ((fData >> 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]++;
index bd588879c55b0ab85c95b1b91b92b0488b1b0031..c8748278ff06f237eb277d43b9e5800cc17999a1 100644 (file)
@@ -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
 };