Modification for new development in raw data
authordibari <dibari@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 10 Jan 2008 11:22:39 +0000 (11:22 +0000)
committerdibari <dibari@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 10 Jan 2008 11:22:39 +0000 (11:22 +0000)
HMPID/AliHMPIDParam.h
HMPID/AliHMPIDPreprocessor.cxx
HMPID/AliHMPIDRawStream.cxx
HMPID/AliHMPIDRawStream.h
HMPID/AliHMPIDReconstructor.cxx
HMPID/AliHMPIDv1.cxx
HMPID/AliHMPIDv2.cxx

index d66b278..99613e0 100644 (file)
@@ -48,6 +48,7 @@ public:
   inline static void   Lors2Pad(Float_t x,Float_t y,Int_t &pc,Int_t &px,Int_t &py);                                     //(x,y)->(pc,px,py) 
 
   static Int_t   Abs         (Int_t ch,Int_t pc,Int_t x,Int_t y)   {return ch*100000000+pc*1000000+x*1000+y;         }  //(ch,pc,padx,pady)-> abs pad
+  static Int_t   DDL2C       (Int_t ddl                      )     {return ddl/2;                                    }  //ddl -> chamber
   static Int_t   A2C         (Int_t pad                      )     {return pad/100000000;                            }  //abs pad -> chamber
   static Int_t   A2P         (Int_t pad                      )     {return pad%100000000/1000000;                    }  //abs pad -> pc 
   static Int_t   A2X         (Int_t pad                      )     {return pad%1000000/1000;                         }  //abs pad -> pad X 
index 7783b93..920888b 100644 (file)
@@ -200,9 +200,7 @@ Bool_t AliHMPIDPreprocessor::ProcPed()
     infile>>nSigCut; pM->SetUniqueID(nSigCut); //n. of pedestal distribution sigmas used to create zero suppresion table
     while(!infile.eof()){
       infile>>dec>>r>>d>>a>>mean>>sigma>>hex>>hard;      
-      //dig.Raw(ddl,r,d,a);
-      rs.Raw(ddl,r,d,a);
-      AliHMPIDDigit dig(rs.GetPad(ddl,r,d,a),rs.GetCharge(ddl,r,d,a));
+      AliHMPIDDigit dig(rs.GetPad(ddl,r,d,a),(Int_t)mean);
       (*pM)(dig.PadChX(),dig.PadChY()) = sigma;
     }
     infile.close();
index 0dfe95e..5963d81 100644 (file)
@@ -27,7 +27,7 @@
 
 Int_t fPos[170000];
 Int_t iPos = 0;
-//static Bool_t stDeb = kTRUE;
+static Bool_t stDeb = kTRUE;
 
 ClassImp(AliHMPIDRawStream)
 
@@ -39,8 +39,12 @@ AliHMPIDRawStream::AliHMPIDRawStream(AliRawReader* rawReader) :
   fPosition(-1)
 {
   // Constructor
-  Init();
+  fNPads = 0;
+  fCharge = 0x0;
+  fPad =0x0;
 
+  for(Int_t l=1; l < kSumErr; l++) fNumOfErr[l]=0;               //reset errors
+    
   fRawReader->Reset();
   fRawReader->Select("HMPID");
 }
@@ -52,42 +56,19 @@ AliHMPIDRawStream::AliHMPIDRawStream() :
   fPosition(-1)
 {
   // Constructor
-  Init();
+  for(Int_t l=1; l < kSumErr; l++) fNumOfErr[l]=0;               //reset errors
 }
 //_____________________________________________________________________________
 AliHMPIDRawStream::~AliHMPIDRawStream()
 {
   // destructor
+    DelVars();
 }
-
-//_____________________________________________________________________________
-void AliHMPIDRawStream::Init()
-{
-  // Initalize the container
-  // with the pad charges
-  Int_t n=0;
-  iPos = 0;
-  for(Int_t h = 0; h < kNDDL; h++) {  
-    for(Int_t i = 0; i < kNRows; i++){
-      for(Int_t j = 0; j < kNDILOGICAdd; j++){
-       for(Int_t k = 0; k < kNPadAdd; k++){
-         fCharge[h][i][j][k] = -1;
-         fPad[h][i][j][k]=-1;
-          fPos[++n] = 0;
-       }
-      }
-    }
-  }
-  fZeroSup=kTRUE;
-  
-  for(Int_t l=1; l < kSumErr; l++) fNumOfErr[l]=0;               //reset errors
-}//Init()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDRawStream::Reset()
 {
   // reset raw stream params
   // Reinitalize the containers
-  Init();
   fDDLNumber = -1;
   fPosition = -1;
   fData = NULL;
@@ -127,46 +108,55 @@ Bool_t AliHMPIDRawStream::Next()
   Bool_t status;
   
   if(fRawReader->GetType() == 7)  {                             //New: Select Physics events, Old: Raw data size is not 0 and not 47148 (pedestal)
-  
     fDDLNumber = fRawReader->GetDDLID();
-    
-    Init();
-    
+    Printf("DDL %i started to be decoded!.",fDDLNumber);
+    InitVars(fRawReader->GetDataSize()/4);
     status = ReadHMPIDRawData();
-//    if(status) Printf("Event DDL %i successfully decoded!.",fDDLNumber);
-// Just for test...
-//    for(Int_t i=0;i<fRawReader->GetDataSize()/4;i++) {
-//      GetWord();
-//    }
-//...
-    
-//    if(stDeb) DumpData(fRawReader->GetDataSize());
+    if(status) Printf("Event DDL %i successfully decoded!.",fDDLNumber);
+    else Printf("Event DDL %i ERROR in decoding!.",fDDLNumber);
+    if(stDeb) DumpData(fRawReader->GetDataSize());
 //    stDeb=kFALSE;
   }
-  return status;
+//  return status;
+  return kTRUE;
 }
-    
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDRawStream::InitVars(Int_t n)
+{
+  fNPads = 0;
+  fCharge = new Int_t[n];
+  fPad = new Int_t[n];
+  //for debug purpose
+  for(Int_t i=0; i < 170000; i++) fPos[i]=0;                     //reset debug
+  iPos = 0;
+}    
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+void AliHMPIDRawStream::DelVars()
+{
+  fNPads = 0;
+  delete fCharge;
+  delete fPad;
+}    
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Bool_t AliHMPIDRawStream::ReadHMPIDRawData()
 {
   Int_t cntGlob = fRawReader->GetDataSize()/4;
   Int_t cnt = cntGlob;
-  UInt_t word32;
   Int_t nwSeg;
   Int_t cntSegment;
 
-  word32 = GetWord(cnt);cnt--;
+  fWord = GetWord(cnt);cnt--;
 
   
   while (cnt>0) {
     
-    nwSeg = (word32 >> kbit8) & 0xfff;
-    if(!CheckSegment(word32)) return kFALSE;
-    if(!ReadSegment(word32,cntSegment)) return kFALSE;
+    nwSeg = (fWord >> kbit8) & 0xfff;
+    if(!CheckSegment()) return kFALSE;
+    if(!ReadSegment(cntSegment)) return kFALSE;
 
     if(nwSeg != cntSegment) {Printf("Error in Segment counters: %i different wrt %i",nwSeg,cntSegment);return kFALSE;}
-    Printf(" cnt %i cntSegment %i",cnt,cntSegment);
-    word32 = GetWord(cntSegment+1,kBwd);
+//    Printf(" cnt %i cntSegment %i",cnt,cntSegment);
+    fWord = GetWord(cntSegment+1,kBwd);
     cnt-=cntSegment+1;
   }
   
@@ -174,23 +164,23 @@ Bool_t AliHMPIDRawStream::ReadHMPIDRawData()
   
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDRawStream::ReadSegment(UInt_t word32,Int_t &cntSegment)
+Bool_t AliHMPIDRawStream::ReadSegment(Int_t &cntSegment)
 {
-  cntSegment = (word32 >> kbit8) & 0xfff;
+  cntSegment = (fWord >> kbit8) & 0xfff;
   Int_t cnt = cntSegment;
   Int_t cntRow;
   Int_t nwRow;
 
-  word32 = GetWord(cnt,kBwd);
+  fWord = GetWord(cnt,kBwd);
   
   while (cnt>0) {
 
-    cntRow  = (word32 >> kbit16) & 0xfff;
-    if(!CheckRowMarker(word32)) return kFALSE;
-    if(!ReadRow(word32,nwRow)) return kFALSE;
+    cntRow  = (fWord >> kbit16) & 0xfff;
+    if(!CheckRowMarker()) return kFALSE;
+    if(!ReadRow(nwRow)) return kFALSE;
 
     if(nwRow != cntRow) {Printf("Error in Row counters: %i different wrt %i",nwRow,cntRow);return kFALSE;}
-    word32 = GetWord(cntRow+1);
+    fWord = GetWord(cntRow+1);
     cnt -= cntRow+1;
     
   }
@@ -201,25 +191,25 @@ Bool_t AliHMPIDRawStream::ReadSegment(UInt_t word32,Int_t &cntSegment)
     
 }    
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDRawStream::ReadRow(UInt_t word32,Int_t &cntRow)
+Bool_t AliHMPIDRawStream::ReadRow(Int_t &cntRow)
 {
   Int_t cnt;
   Int_t cntDilogic;
   Int_t nwDil;
   
-  cntRow  = (word32 >> kbit16) & 0xfff;
+  cntRow  = (fWord >> kbit16) & 0xfff;
   cnt = cntRow;  
   
-  word32 = GetWord(cntRow);
+  fWord = GetWord(cntRow);
   
   while (cnt>0) {
     
-    if(!CheckEoE(word32,nwDil)) return kFALSE;
-    if(!ReadDilogic(word32,cntDilogic)) return kFALSE;
+    if(!CheckEoE(nwDil)) return kFALSE;
+    if(!ReadDilogic(cntDilogic)) return kFALSE;
     
     if(nwDil != cntDilogic) {Printf("Error in Dilogic counters: %i different wrt %i",nwDil,cntDilogic);return kFALSE;}
     cnt -= cntDilogic;
-    word32 = GetWord(1,kBwd); // go to next Dilogic bank...
+    fWord = GetWord(1,kBwd); // go to next Dilogic bank...
     cnt--;
 //    Printf(" cnt %i cntDilogic %i ",cnt,cntDilogic);
   }
@@ -230,34 +220,38 @@ Bool_t AliHMPIDRawStream::ReadRow(UInt_t word32,Int_t &cntRow)
   
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDRawStream::ReadDilogic(UInt_t word32,Int_t &cntDilogic)
+Bool_t AliHMPIDRawStream::ReadDilogic(Int_t &cntDilogic)
 {
-  cntDilogic = word32 & 0x7f;
+  cntDilogic = fWord & 0x7f;
   
   Int_t cnt = cntDilogic;
+  
+//  Printf(" cnt DILOGIC %i at %i word %08X",cnt,fPosition,fWord);
 
   for(Int_t iDil=0;iDil<cntDilogic;iDil++) {
     UInt_t dilogic = 0, row = 0;
-    word32 = GetWord(1,kBwd);
+    fWord = GetWord(1,kBwd);
 //check on row number      
     cnt--;
-    row = (word32 >> kbit22) & 0xf;
+    row = (fWord >> kbit22) & 0x1f;
     if(!CheckRow(row)) continue;
 //check dilogic number     
-    dilogic = (word32 >> kbit18) & 0xf;                                              //dilogic info in raw word is between bits: 18...21
+    dilogic = (fWord >> kbit18) & 0xf;                                              //dilogic info in raw word is between bits: 18...21
     if(!CheckDilogic(dilogic)) continue;
 //check pad number
-    UInt_t pad = (word32 >> kbit12) & 0x3f;                                          //pad info in raw word is between bits: 12...17
+    UInt_t pad = (fWord >> kbit12) & 0x3f;                                          //pad info in raw word is between bits: 12...17
     if(!CheckPad(pad)) continue;
-    fCharge[fDDLNumber][row][dilogic][pad] = word32 & 0xfff;
-//            Printf(" (word %08X) DDL %i row %i dil %i pad %i ",word32,fDDLNumber,row,dilogic,pad);
+    Int_t charge = fWord & 0xfff;
+    fPad[fNPads] = GetPad(fDDLNumber,row,dilogic,pad);
+    fCharge[fNPads] = charge;
+    fNPads++;
   }
 
   cntDilogic -= cnt;  
   return kTRUE;  
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDRawStream::CheckSegment(UInt_t word)
+Bool_t AliHMPIDRawStream::CheckSegment()
 {
   UInt_t markSegment = 0xAB0;
   /*
@@ -270,32 +264,33 @@ Bool_t AliHMPIDRawStream::CheckSegment(UInt_t word)
       return kTRUE;
     }
 */
-  UInt_t segMarker = (word >> kbit20) & 0xfff;
+  UInt_t segMarker = (fWord >> kbit20) & 0xfff;
   if (segMarker != markSegment ) {
-    fRawReader->AddMajorErrorLog(kWrongSegErr,Form("Segment marker %0X wrong (expected %0X) at address %i in word %0X!",segMarker,markSegment,fPosition/4,word));
-    AliWarning(Form("Segment marker %X wrong (expected %0X)! at address %i in word %0X!",segMarker,markSegment,fPosition/4,word));
+    fRawReader->AddMajorErrorLog(kWrongSegErr,Form("Segment marker %0X wrong (expected %0X) at %i in word %0X!",segMarker,markSegment,fPosition,fWord));
+    AliWarning(Form("Segment marker %X wrong (expected %0X)! at %i in word %0X!",segMarker,markSegment,fPosition,fWord));
     fNumOfErr[kWrongSegErr]++;
     return kFALSE;
   }
   
-  UInt_t segAddress = word & 0xff;
+  UInt_t segAddress = fWord & 0xff;
   if (segAddress<1 ||segAddress>3) {
-    fRawReader->AddMajorErrorLog(kWrongSegErr,Form("Segment address %d not in the valid range [1-3] at address %i in word %0X",segAddress,fPosition/4,word));
+    fRawReader->AddMajorErrorLog(kWrongSegErr,Form("Segment address %d not in the valid range [1-3] at %i in word %0X",segAddress,fPosition,fWord));
     AliWarning(Form("Segment address %d not in the valid range [1-3]",segAddress));
     fNumOfErr[kWrongSegErr]++;
     return kFALSE;
   }
-  Printf("Segment Marker found! Number of segment is %i",segAddress);
+//  Printf("Segment Marker found at %i! Number of segment is %i",fPosition,segAddress);
   return kTRUE;
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Bool_t AliHMPIDRawStream::CheckRow(UInt_t row)
 {
 //check on row number      
+//  Printf("ROW %i word %0X",row,fWord);
   if(row>=1 && row <=kNRows) return kTRUE;
   
   fRawReader->AddMajorErrorLog(kWrongRowErr,Form("row %d",row));
-  AliWarning(Form("Wrong row index: %d, expected (1 -> %d)!",row,kNRows));
+  AliWarning(Form("Wrong row index: %d, expected (1 -> %d) word %0X at %i...",row,kNRows,fWord,fPosition));
   fNumOfErr[kWrongRowErr]++;
   return kFALSE;
 }
@@ -323,18 +318,18 @@ Bool_t AliHMPIDRawStream::CheckPad(UInt_t pad)
   return kFALSE;
 }    
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDRawStream::CheckEoE(UInt_t word,Int_t &nDil)
+Bool_t AliHMPIDRawStream::CheckEoE(Int_t &nDil)
 {
-  if (!((word >> kbit27) & 0x1)) {                                                //check 27th bit in EoE. It must be 1!
+  if (!((fWord >> kbit27) & 0x1)) {                                                //check 27th bit in EoE. It must be 1!
     fRawReader->AddMajorErrorLog(kEoEFlagErr);
-    AliWarning(Form("Missing end-of-event flag! (%08X)",word));
+    AliWarning(Form("Missing end-of-event flag! (%08X) at %i",fWord,fPosition));
     fNumOfErr[kEoEFlagErr]++;
     return kFALSE;
   }
-  nDil = word & 0x7f;
-  if(nDil < 1 || nDil > 48 ) {
+  nDil = fWord & 0x7f;
+  if(nDil < 0 || nDil > 48 ) {
     fRawReader->AddMajorErrorLog(kEoESizeErr,Form("EoE size=%d",nDil));
-    AliWarning(Form("Wrong end-of-event word-count: %08X",word));
+    AliWarning(Form("Wrong end-of-event word-count: %08X",fWord));
     fNumOfErr[kEoESizeErr]++;
     return kFALSE;
   }
@@ -356,12 +351,12 @@ Bool_t AliHMPIDRawStream::CheckEoE(UInt_t word,Int_t &nDil)
   return kTRUE;
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Bool_t AliHMPIDRawStream::CheckRowMarker(UInt_t word)
+Bool_t AliHMPIDRawStream::CheckRowMarker()
 {
   UInt_t nMAXwordsInRow = 0x1EA;
   UInt_t statusControlRow = 0x32a8; // 0x36a8 for zero suppression
 //First check on row marker    
-  UInt_t rowControlWord = word >> kbit0 & 0xfbff;
+  UInt_t rowControlWord = fWord >> kbit0 & 0xfbff;
   
   if(rowControlWord != statusControlRow) {
     fRawReader->AddMajorErrorLog(kRowMarkerErr);
@@ -370,7 +365,7 @@ Bool_t AliHMPIDRawStream::CheckRowMarker(UInt_t word)
     return kFALSE;
   }
 //Second check on row marker    
-   UInt_t wordsInRow = word >> kbit16 & 0x0fff;                // Number of words after the row marker
+   UInt_t wordsInRow = fWord >> kbit16 & 0x0fff;                // Number of words after the row marker
   
   if (wordsInRow > nMAXwordsInRow) {
     fRawReader->AddMajorErrorLog(kRowMarkerSizeErr);
@@ -416,7 +411,10 @@ void AliHMPIDRawStream::DumpData(Int_t nw)
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDRawStream::StorePosition()
 {
-//  if(fPos[fPosition]!=0) {Printf("Position already stored!!! Value %i at address %i",fPos[fPosition],fPosition); return;}
+  if(fPos[fPosition]!=0) {
+//    Printf("Position already stored!!! Value %i at address %i",fPos[fPosition],fPosition); 
+    return;
+  }
   iPos++;
   fPos[fPosition] = iPos;
 //  if(stDeb)Printf("%i - Actual position %i",iPos,fPosition); 
index 9c53fd4..5fc798c 100644 (file)
@@ -31,40 +31,39 @@ class AliHMPIDRawStream: public TObject {
 
     virtual void     Reset();
     virtual Bool_t   Next();
-            void     Init();
+            void     InitVars(Int_t n);
+            void     DelVars();
     
-           Int_t    Ch( Int_t ddl,Int_t row,Int_t dil,Int_t pad    ) {return AliHMPIDParam::A2C(fPad[ddl][row][dil][pad]); }            //chamber number
-           
            Int_t GetDDLNumber()  const { return fDDLNumber; }                                                                            // Provide current DDL number
-    inline  Int_t GetCharge(Int_t ddl,Int_t row, Int_t dilogic, Int_t pad);                                                                         // Provide the charge observed in certain row,dilogic,pad channel
-           inline Int_t GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad);                                                                        //
-           
-           Int_t   Pc          ( Int_t ddl,Int_t row,Int_t dil,Int_t pad                            ) {return AliHMPIDParam::A2P(fPad[ddl][row][dil][pad]);}                                                 //PC position number
-           Int_t   PadPcX      ( Int_t ddl,Int_t row,Int_t dil,Int_t pad                            ) {return AliHMPIDParam::A2X(fPad[ddl][row][dil][pad]);}                                                 //pad pc x # 0..79
-           Int_t   PadPcY      ( Int_t ddl,Int_t row,Int_t dil,Int_t pad                            ) {return AliHMPIDParam::A2Y(fPad[ddl][row][dil][pad]);}                                                 //pad pc y # 0..47
+           inline Int_t GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad);                                                                 //
+           Int_t   GetNPads()       const { return fNPads;}
+            Int_t*  GetPadArray()    const { return fPad;}
+            Int_t*  GetChargeArray() const { return fCharge;}
+           Int_t   Pc          ( Int_t ddl,Int_t row,Int_t dil,Int_t pad                            ) {return AliHMPIDParam::A2P(GetPad(ddl,row,dil,pad));}                                                 //PC position number
+           Int_t   PadPcX      ( Int_t ddl,Int_t row,Int_t dil,Int_t pad                            ) {return AliHMPIDParam::A2X(GetPad(ddl,row,dil,pad));}                                                 //pad pc x # 0..79
+           Int_t   PadPcY      ( Int_t ddl,Int_t row,Int_t dil,Int_t pad                            ) {return AliHMPIDParam::A2Y(GetPad(ddl,row,dil,pad));}                                                 //pad pc y # 0..47
    
            inline  Bool_t SetZeroSup (Bool_t isSup);
     inline  Bool_t GetZeroSup(); 
     inline  Int_t GetErrors(Int_t eType);                                                                                          //Get errors and occurance
     
     Bool_t ReadHMPIDRawData();                           // Read HMPID Raw data
-    Bool_t ReadSegment(UInt_t word32,Int_t &cntSegment); // Read Segment
-    Bool_t ReadRow(UInt_t word32,Int_t &cntRow);         // Read Row
-    Bool_t ReadDilogic(UInt_t word32,Int_t &cntDilogic); // Read Dilogic
+    Bool_t ReadSegment(Int_t &cntSegment);               // Read Segment
+    Bool_t ReadRow(Int_t &cntRow);                       // Read Row
+    Bool_t ReadDilogic(Int_t &cntDilogic);               // Read Dilogic
 
-    Bool_t CheckRow(UInt_t row);                   // Check Row
-    Bool_t CheckDilogic(UInt_t dilogic);           // Check Dilogic
-    Bool_t CheckPad(UInt_t pad);                   // Check pad
-    Bool_t CheckEoE(UInt_t word,Int_t &nDil);       // Check EoE
-    Bool_t CheckRowMarker(UInt_t word);            // Check RowMarker
-    Bool_t CheckSegment(UInt_t word);              // Check Segment
-    void   DumpData(Int_t nw);                     // Dump Data
-    void   StorePosition();                        //
+    Bool_t CheckRow(UInt_t row);                         // Check Row
+    Bool_t CheckDilogic(UInt_t dilogic);                 // Check Dilogic
+    Bool_t CheckPad(UInt_t pad);                         // Check pad
+    Bool_t CheckEoE(Int_t &nDil);                        // Check EoE
+    Bool_t CheckRowMarker();                             // Check RowMarker
+    Bool_t CheckSegment();                               // Check Segment
+    void   DumpData(Int_t nw);                           // Dump Data
+    void   StorePosition();                              //Debug purpose
     
-    inline void    Raw            (UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a);                                              //digit->(w32,ddl,r,d,a)
-    inline void    Raw            (Int_t ddl,Int_t r,Int_t d,Int_t a);                                                              //raw->abs pad number
-    inline Bool_t  Raw            (UInt_t  w32,Int_t  ddl,AliRawReader *pRR);                                                       //(w32,ddl)->digit
-    inline void   SetCharge      (Int_t ddl,Int_t row,Int_t dil,Int_t pad,Int_t q);
+//    inline void    Raw            (UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a);                                              //digit->(w32,ddl,r,d,a)
+//    inline void    Raw            (Int_t ddl,Int_t r,Int_t d,Int_t a);                                                              //raw->abs pad number
+//    inline Bool_t  Raw            (UInt_t  w32,Int_t  ddl,AliRawReader *pRR);                                                       //(w32,ddl)->digit
     inline void    WriteRaw       (TObjArray *pDigLst                             );                                                      //write as raw stream     
     inline void   WriteRowMarker  (AliFstream *ddl,UInt_t size);
     inline void   WriteEoE        (AliFstream *ddl,UInt_t row,UInt_t dil,UInt_t wordCnt);  
@@ -113,19 +112,21 @@ enum Ebits {kbit0,kbit1 , kbit2, kbit3, kbit4, kbit5, kbit6, kbit7, kbit8,
 
     UInt_t           GetWord(Int_t n=1,EDirection dir=kFwd);             // Get n-th word
     UInt_t           GetNextWord();                                      // Get next word
-    Int_t            fCharge[kNDDL][kNRows+1][kNDILOGICAdd+1][kNPadAdd]; // Array for charge values for all channels in one DDL
-    Int_t            fPad[kNDDL][kNRows+1][kNDILOGICAdd+1][kNPadAdd];    // Array for abs pad values for all channels in one DDL
-    UInt_t           fRawWord[kNDDL][kNRows+1][kNDILOGICAdd+1][kNPadAdd];// Array of raw words
+    Int_t            fNPads;                                             // counter of pads in one DDL
+    Int_t            *fCharge;                                           // Array for charge values for all channels in one DDL
+    Int_t            *fPad;                                              // Array for abs pad values for all channels in one DDL
     Int_t            fNumOfErr[kSumErr];                                 // Store the numner of errors for a given error type
     Int_t            fDDLNumber;                                         // index of current DDL number
     AliRawReader*    fRawReader;                                         // object for reading the raw data
     UChar_t*         fData;                                              // raw data
-    Int_t            fPosition;                                          // current position in fData
+    Int_t            fPosition;                                          // current word
+    UInt_t           fWord;                                              // current position in fData
     Bool_t           fZeroSup;
 
     ClassDef(AliHMPIDRawStream, 1)                                       // base class for reading HMPID raw digits
 };
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+    /*
 void AliHMPIDRawStream::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)
 {
 // Convert raw stream word to raw word format
@@ -139,14 +140,16 @@ void AliHMPIDRawStream::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)
   a=y2a[PadPcY(ddl,r,d,a)%6]+6*(PadPcX(ddl,r,d,a)%8);                                           //ADDRESS 0..47        
   
   w32=0;    
-  AliBitPacking::PackWord((fCharge[ddl][r][d][a]>4095)?4095:(UInt_t)fCharge[ddl][r][d][a],w32, 0,11);       // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq        Qdc               bits (00..11) counts (0..4095)
+  AliBitPacking::PackWord((fCharge[fNPads]>4095)?4095:(UInt_t)fCharge[fNPads],w32, 0,11);       // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq        Qdc               bits (00..11) counts (0..4095)
   //molnarl: Since in simulation the the charge can be > than 4095 but not in real life we need to protect. If fQ>4095 after packing we will get 0 for the charge! 
   assert(0<=a&&a<=47);AliBitPacking::PackWord(        a ,w32,12,17);  // 3322 2222 2222 1111 1111 1000 0000 0000        DILOGIC address   bits (12..17) counts (0..47)
   assert(1<=d&&d<=10);AliBitPacking::PackWord(        d ,w32,18,21);  // 1098 7654 3210 9876 5432 1098 7654 3210        DILOGIC number    bits (18..21) counts (1..10)
   assert(1<=r&&r<=24);AliBitPacking::PackWord(        r ,w32,22,26);  //                                                Row number        bits (22..26) counts (1..24)  
 }
+*/
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDRawStream::Raw(Int_t ddl,Int_t r,Int_t d,Int_t a)
+    /*
+Int_t AliHMPIDRawStream::Raw(Int_t ddl,Int_t r,Int_t d,Int_t a)
 {
   //Assign absolute pad ID based on ddl,row,dil,pad
   //Arguments: DDL, row number, dilogic number, dilogic address(pad)
@@ -158,7 +161,7 @@ void AliHMPIDRawStream::Raw(Int_t ddl,Int_t r,Int_t d,Int_t a)
   Int_t tmp=(r-1)/8;              Int_t pc=(ddl%2)? 5-2*tmp:2*tmp; 
                                   Int_t px=(d-1)*8+a/6;
         tmp=(ddl%2)?(24-r):r-1;   Int_t py=6*(tmp%8)+a2y[a%6];
-  fPad[ddl][r][d][a]=AliHMPIDParam::Abs(ch,pc,px,py);
+  return AliHMPIDParam::Abs(ch,pc,px,py);
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Bool_t AliHMPIDRawStream::Raw(UInt_t w32,Int_t ddl, AliRawReader *pRR)
@@ -180,16 +183,7 @@ Bool_t AliHMPIDRawStream::Raw(UInt_t w32,Int_t ddl, AliRawReader *pRR)
   fCharge[ddl][r][d][a]=q;
   return kTRUE;
 }
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-void AliHMPIDRawStream::SetCharge(Int_t ddl,Int_t row,Int_t dil,Int_t pad,Int_t q)
-{ 
-  //Setter for the charger in the raw stream
-  //Arguments: DDL, row number, dilogic number, dilogic address(pad), charge
-  //Returns:   Charge from the raw stream
-     fCharge[ddl][row][dil][pad]=q;
-     //  return fCharge[ddl][row][dil][pad];
-      
-}
+*/
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Int_t AliHMPIDRawStream::GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad)
 {
@@ -209,38 +203,9 @@ Int_t AliHMPIDRawStream::GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad)
         tmp=(ddl%2)?(24-row):row-1;   
                                   Int_t py=6*(tmp%8)+a2y[pad%6];
                                   
-  return fPad[ddl][row][dil][pad]=AliHMPIDParam::Abs(ch,pc,px,py);
+  return AliHMPIDParam::Abs(ch,pc,px,py);
 }//GetPad()
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-Int_t AliHMPIDRawStream::GetCharge(Int_t ddl,Int_t row, Int_t dilogic, Int_t pad)
-{
-  // The method returns the charge collected
-  // in a particular channel
-  // Return -1 in case the charge from the channels
-  // has not been read or invalid arguments
-  if (ddl < 0 || ddl > kNDDL) {
-    AliError(Form("Wrong DDL index %d!",ddl));
-    return 0;
-  }  
-  if (row < 1 || row > kNRows) {
-    AliError(Form("Wrong row index %d!",row));
-    return 0;
-  }
-
-  if (dilogic < 1 || dilogic > kNDILOGICAdd) {
-    AliError(Form("Wrong DILOGIC address %d!",dilogic));
-    return 0;
-  }
-  
-  if (pad >= kNPadAdd) {
-    AliError(Form("Wrong pad index %d!",pad));
-    return 0;
-  }
-
-  return fCharge[ddl][row][dilogic][pad];
-  
-}
-//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDRawStream::WriteRowMarker(AliFstream *ddl,UInt_t size)
 {
   //Writes the row marker for real data and pedestal into the ddl stream
index 4264ec9..a7288a6 100644 (file)
@@ -43,8 +43,8 @@ AliHMPIDReconstructor::AliHMPIDReconstructor():AliReconstructor(),fUserCut(0),fD
   fDig=new TObjArray(AliHMPIDParam::kMaxCh+1); fDig->SetOwner(kTRUE);
   
   for(int i=AliHMPIDParam::kMinCh;i<=AliHMPIDParam::kMaxCh;i++){ 
-    fDig->AddAt(new TClonesArray("AliHMPIDDigit"),i);
-    TClonesArray *pClus = new TClonesArray("AliHMPIDCluster");
+    fDig->AddAt(new TClonesArray("AliHMPIDDigit",24000),i);
+    TClonesArray *pClus = new TClonesArray("AliHMPIDCluster",24000);
     pClus->SetUniqueID(i);
     fClu->AddAt(pClus,i);
   }
@@ -136,7 +136,7 @@ void AliHMPIDReconstructor::Reconstruct(TTree *pDigTree,TTree *pCluTree)const
 //  Returns: none    
   AliDebug(1,"Start.");
   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
-    pCluTree->Branch(Form("HMPID%d",iCh),&((*fClu)[iCh]),4000,0);
+    pCluTree->Branch(Form("HMPID%d",iCh),&((*fClu)[iCh]),7);
     pDigTree->SetBranchAddress(Form("HMPID%d",iCh),&((*fDig)[iCh]));
   }   
   pDigTree->GetEntry(0);
@@ -160,31 +160,25 @@ void AliHMPIDReconstructor::ConvertDigits(AliRawReader *pRR,TTree *pDigTree)cons
   AliDebug(1,"Start.");
 //  Int_t digcnt=0;
   
+  Int_t iDigCnt[7]={0,0,0,0,0,0,0};
 
-  for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) {
-    pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh]),4000,0); 
+  for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){
+    pDigTree->Branch(Form("HMPID%d",iCh),&((*fDig)[iCh]));
+  }
     
-    Int_t iDigCnt=0;
-    AliHMPIDRawStream stream(pRR);    
-    while(stream.Next())
-    {
-      
-      UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13
-      if((UInt_t)(2*iCh)==ddl || (UInt_t)(2*iCh+1)==ddl) {
-       for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows; row++){
-        for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){
-          for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
-            if(stream.GetCharge(ddl,row,dil,pad) < 1) continue; 
-              AliHMPIDDigit dig(stream.GetPad(ddl,row,dil,pad),stream.GetCharge(ddl,row,dil,pad));
-              if(!IsDigSurvive(&dig)) continue; 
-              new((*((TClonesArray*)fDig->At(iCh)))[iDigCnt++]) AliHMPIDDigit(dig); //add this digit to the tmp list 
-            }//pad
-          }//dil
-        }//row
-      }//while
+  AliHMPIDRawStream stream(pRR);    
+  
+  while(stream.Next())
+  {
+    Int_t ch = AliHMPIDParam::DDL2C(stream.GetDDLNumber());
+    for(Int_t iPad=0;iPad<stream.GetNPads();iPad++) {
+      AliHMPIDDigit dig(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]);
+      if(!IsDigSurvive(&dig)) continue; 
+      new((*((TClonesArray*)fDig->At(ch)))[iDigCnt[ch]++]) AliHMPIDDigit(dig); //add this digit to the tmp list 
     }
-    stream.Delete();
   }
+  
+  stream.Delete();
   pDigTree->Fill();
   
   for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++)fDig->At(iCh)->Clear();
index 9fffa92..7e6823d 100644 (file)
@@ -474,16 +474,10 @@ Bool_t AliHMPIDv1::Raw2SDigits(AliRawReader *pRR)
   AliHMPIDRawStream stream(pRR);
   while(stream.Next())
   {
-    UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13  
-    for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
-     for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){
-      for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
-          if(stream.GetCharge(ddl,row,dil,pad)<1) continue;
-          AliHMPIDDigit sdi(stream.GetPad(ddl,row,dil,pad),stream.GetCharge(ddl,row,dil,pad));
-          new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
-          }//pad
-      }//dil
-    }//row
+    for(Int_t iPad=0;iPad<stream.GetNPads();iPad++) {
+      AliHMPIDDigit sdi(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]);
+      new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
+    }
   }
   
   GetLoader()->TreeS()->Fill(); GetLoader()->WriteSDigits("OVERWRITE");//write out sdigits
index 8062339..113c7fa 100644 (file)
@@ -719,25 +719,19 @@ Bool_t AliHMPIDv2::Raw2SDigits(AliRawReader *pRR)
 // Interface methode ivoked from AliSimulation to create a list of sdigits from raw digits. Events loop is done in AliSimulation
 // Arguments: pRR- raw reader 
 //   Returns: kTRUE on success (currently ignored in AliSimulation::ConvertRaw2SDigits())      
-  AliHMPIDDigit sdi; //tmp sdigit, raw digit will be converted to it
+  //AliHMPIDDigit sdi; //tmp sdigit, raw digit will be converted to it
+  
   if(!GetLoader()->TreeS()) {MakeTree("S");  MakeBranch("S");}
     
   TClonesArray *pSdiLst=SdiLst(); Int_t iSdiCnt=0; //tmp list of sdigits for all chambers
   AliHMPIDRawStream stream(pRR);
   while(stream.Next())
   {
-   UInt_t ddl=stream.GetDDLNumber(); //returns 0,1,2 ... 13 
-    for(Int_t row = 1; row <=AliHMPIDRawStream::kNRows; row++){
-     for(Int_t dil = 1; dil <=AliHMPIDRawStream::kNDILOGICAdd; dil++){
-      for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){
-          if(stream.GetCharge(ddl,row,dil,pad)<1) continue;
-          AliHMPIDDigit sdi(stream.GetPad(ddl,row,dil,pad),stream.GetCharge(ddl,row,dil,pad));
-          new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
-        }//pad
-      }//dil
-    }//row
-  }    
+    for(Int_t iPad=0;iPad<stream.GetNPads();iPad++) {
+      AliHMPIDDigit sdi(stream.GetPadArray()[iPad],stream.GetChargeArray()[iPad]);
+      new((*pSdiLst)[iSdiCnt++]) AliHMPIDDigit(sdi); //add this digit to the tmp list
+    }
+  }
   
   GetLoader()->TreeS()->Fill(); GetLoader()->WriteSDigits("OVERWRITE");//write out sdigits
   SdiReset();