]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSRawStreamSDDCompressed.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / ITS / AliITSRawStreamSDDCompressed.cxx
index d08f8f9343592d69800b0c30eb7f312e4d1fa24d..012742e7159cbe1957aa816b9d80e2f98d5dfd85 100644 (file)
@@ -24,7 +24,7 @@
 //   29  |                                                       //
 //   28  |-> 4 bits to identify the Carlos (0-11) inside the DDL //
 //   27 -                                                        //
-//   26 detecot side (0= left, =right)                           //
+//   26 detecor side (0= left, =right)                           //
 //   25 -                                                        //
 //   24  |                                                       //
 //   23  |                                                       //
 //    1  |                                                       //
 //    0 -                                                        //
 //                                                               //
-// Plus 2 types of control words:                                //
-// - DDL identifier with the 4 more significant bits     = 1000  //
-// - End of module data (needed by the Cluster Finder)   = 1111  //
+// Plus 3 types of control words                                 //
+// identified by the the 4 most significant bits (31-28)         //
+// 1) Jitter word     = 1000                                     //
+// 2) JTAG answer     = 1100                                     //
+// 3) End of module data (needed by the Cluster Finder)   = 1111 //
 //                                                               //
 // Origin: F.Prino, Torino, prino@to.infn.it                     //
 //                                                               //
@@ -73,12 +75,13 @@ ClassImp(AliITSRawStreamSDDCompressed)
 //______________________________________________________________________
 AliITSRawStreamSDDCompressed::AliITSRawStreamSDDCompressed(AliRawReader* rawReader) :
   AliITSRawStream(rawReader),
-fDDLModuleMap(0),
-fData(0),
-fCarlosId(-1),
-fChannel(0),
-fJitter(0),
-fDDL(0)
+  fDDLModuleMap(0),
+  fData(0),
+  fCarlosId(-1),
+  fChannel(0),
+  fJitter(0),
+  fDDL(0),
+  fADCEncoded(0)
 {
 // create an object to read ITS SDD raw digits
   for(Int_t im=0;im<kSDDModules;im++){
@@ -93,13 +96,14 @@ fDDL(0)
 
 //______________________________________________________________________
 AliITSRawStreamSDDCompressed::AliITSRawStreamSDDCompressed(const AliITSRawStreamSDDCompressed& rs) :
-AliITSRawStream(rs.fRawReader),
-fDDLModuleMap(rs.fDDLModuleMap),
-fData(0),
-fCarlosId(-1),
-fChannel(0),
-fJitter(0),
-fDDL(0)
+  AliITSRawStream(rs.fRawReader),
+  fDDLModuleMap(rs.fDDLModuleMap),
+  fData(0),
+  fCarlosId(-1),
+  fChannel(0),
+  fJitter(0),
+  fDDL(0),
+  fADCEncoded(0)
 {
   // copy constructor
   AliError("Copy constructor should not be used.");
@@ -126,10 +130,13 @@ Int_t AliITSRawStreamSDDCompressed::DecompAmbra(Int_t value) const
   if ((value & 0x80) == 0) {
     return value & 0x7f;
   } else if ((value & 0x40) == 0) {
+    if(value&1) return 0x080 + ((value & 0x3f) << 1);
     return 0x081 + ((value & 0x3f) << 1);
   } else if ((value & 0x20) == 0) {
+    if(value&1) return 0x103 + ((value & 0x1f) << 3);
     return 0x104 + ((value & 0x1f) << 3);
   } else {
+    if(value&1) return 0x207 + ((value & 0x1f) << 4);
     return 0x208 + ((value & 0x1f) << 4);
   }
   
@@ -139,41 +146,71 @@ Bool_t AliITSRawStreamSDDCompressed::Next()
 {
 // read the next raw digit
 // returns kFALSE if there is no digit left
-// returns kTRUE and fCompletedModule=kFALSE when a digit is found
-// returns kTRUE and fCompletedModule=kTRUE  when a module is completed 
+// returns kTRUE and fCompletedModule=kFALSE and fCompletedDDL=kFALSE when a digit is found
+// returns kTRUE and fCompletedModule=kTRUE  and fCompletedDDL=kFALSE when a module is completed (=3x3FFFFFFF footer words)
+// returns kTRUE and fCompletedModule=kFALSE and fCompletedDDL=kTRUE  when a DDL is completed (=jitter word)
 
 
-//  UInt_t masksod=8;    // start of DDL has the 4 most significant bits = 1000
-  UInt_t maskeom=15;   // end of module has the 4 most significant bits = 1111
+  UInt_t idJit=8;    // Jitter word has the 4 most significant bits = 1000
+  UInt_t idEom=15;   // end of module has the 4 most significant bits = 1111
+  UInt_t idJtag=12;  // end of module has the 4 most significant bits = 1100
+
   UInt_t maskmod=15;   // last 4 bits for module number in end of module word
-  //  UInt_t maskDDL=0xFF; // last 8 bits for DDL number in start of DDL word
-    
   UInt_t maskCarlos=15<<27; // 4 bits  (27-30) for CarlosId in data word
   UInt_t maskSide=1<<26;    // 1 bit   (26)    for side     in data word
   UInt_t maskAnode=255<<18; // 8 bits  (18-25) for Nanode   in data word
   UInt_t maskTb=255<<10;    // 8 bits  (10-27) for Ntimebin in data word
   UInt_t maskADC=1023;      // 10 bits (0-9)   for ADC      in data word
+  UInt_t maskCode=7;        // 3 bits (0-2)    for ADC range in encoded-ADC case
     
   while(kTRUE){
     if (!fRawReader->ReadNextInt(fData)) return kFALSE;  // read next word
     UInt_t mostsigbits=fData>>28; 
-    if(mostsigbits==maskeom){
+    if(fData==0xFFFFFFFF){ 
+      // CarlosRX header do nothing
+    } else if(mostsigbits==idEom){
+      // end of module word
       fCarlosId=fData&maskmod;
       fDDL=fRawReader->GetDDLID();
+      if(fDDL<0) return kFALSE;
       fModuleID = GetModuleNumber(fDDL,fCarlosId);
+      fCompletedDDL=kFALSE;
       fCompletedModule=kTRUE;
       return kTRUE;
-    }else{
+    } else if(mostsigbits==idJit){
+      // jitter word
+      fJitter = fData&0x000000ff;      
+      fCompletedModule=kFALSE;
+      fCompletedDDL=kTRUE;
+      return kTRUE;
+    } else if(mostsigbits==idJtag){
+      // jtag word -> skipped
+      continue;
+    }else if(mostsigbits<8){
+      // data word
       fCarlosId=(fData&maskCarlos)>>27;
       fDDL=fRawReader->GetDDLID();
+      if(fDDL<0) return kFALSE;
       fModuleID = GetModuleNumber(fDDL,fCarlosId);
       fChannel=(fData&maskSide)>>26;
       fCoord1=(fData&maskAnode)>>18;
       fCoord2=(fData&maskTb)>>10;
-      Int_t sig8bit=fData&maskADC;
+      Int_t sig8bit;
+      if(fADCEncoded){
+       UInt_t code=fData&maskCode;
+       if (code < 2 || code > 7){ 
+         AliError(Form("Wrong ADC code value %d",code));
+         continue;
+       }
+       UInt_t adcmask=(1<<code)-1;
+       sig8bit=((fData&(adcmask<<3))>>3) + (1<<code);
+      }else{      
+       sig8bit=fData&maskADC;
+      }
       sig8bit+=fLowThresholdArray[fModuleID-kSPDModules][fChannel];
       fSignal=DecompAmbra(sig8bit);
       fCompletedModule=kFALSE;
+      fCompletedDDL=kFALSE;
       return kTRUE;
     }
   }