]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/AliHMPIDRawStream.cxx
re-activate contrib code
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDRawStream.cxx
index dbab61ae2e643b56ff95b5b0261e25844ab3a9ab..e9d761d56cb4ba2c96902474ffeff3cc9b291025 100644 (file)
@@ -45,7 +45,8 @@ AliHMPIDRawStream::AliHMPIDRawStream(AliRawReader* rawReader) :
   fZeroSup(kTRUE),
   fPos(0x0),
   fiPos(0),
-  fTurbo(kFALSE)
+  fTurbo(kFALSE),
+  fRawDataSize(0)
 {
   //
   // Constructor
@@ -85,7 +86,8 @@ AliHMPIDRawStream::AliHMPIDRawStream() :
   fZeroSup(kTRUE),
   fPos(0x0),
   fiPos(0),
-  fTurbo(kFALSE) 
+  fTurbo(kFALSE) ,
+  fRawDataSize(0)
 {
   //
   // Constructor
@@ -102,6 +104,7 @@ AliHMPIDRawStream::AliHMPIDRawStream() :
   for(Int_t iddl=0;iddl<kNDDL;iddl++) 
     for(Int_t ierr=0; ierr < kSumErr; ierr++) fNumOfErr[iddl][ierr]=0;               //reset errors  
 
+  
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 AliHMPIDRawStream::~AliHMPIDRawStream()
@@ -119,10 +122,12 @@ AliHMPIDRawStream::~AliHMPIDRawStream()
   fWord=0;
   fZeroSup=0;
   fTurbo=0;
-  for(Int_t i=0;i<kSumErr;i++) delete [] fNumOfErr[i]; 
+  fRawDataSize=0;
+  for(Int_t i=0;i<kNDDL;i++) delete [] fNumOfErr[i]; 
   delete [] fNumOfErr; 
 
-  if(fnDDLInStream) { delete [] fnDDLInStream; fnDDLInStream = 0x0; }
+  delete [] fnDDLInStream;
+  delete [] fnDDLOutStream;
 }
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 void AliHMPIDRawStream::Reset()
@@ -146,7 +151,7 @@ Bool_t AliHMPIDRawStream::Turbo()
   fNPads=0;
 //  Int_t gw=0;
   for(Int_t i=1;i<cntGlob;i++) {
-    GetWord(1);
+    if(!GetWord(1)) return kFALSE;
     if (((fWord >> kbit27) & 1)) continue;
     UInt_t statusControlRow = 0x32a8; 
     UInt_t rowControlWord = fWord >> kbit0 & 0xfbff;
@@ -176,7 +181,15 @@ Bool_t AliHMPIDRawStream::Next()
   do {
     if (!fRawReader->ReadNextData(fData)) return kFALSE;
   } while (fRawReader->GetDataSize() == 0);
+  Int_t runNumber = fRawReader->GetRunNumber();
+  
+  Int_t ddlArray[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13}; 
+
+  // next line: fix for link chamber2 cables inversion for period LHC11d, LHC11e, LHC11f and LHC11h. 
   
+  if(runNumber>=156620 && runNumber<=170593) {ddlArray[4] = 5; ddlArray[5] = 4;}  
+  else {ddlArray[4] = 4; ddlArray[5] = 5;}
      
   /*
   Event type is selected as in $ALICE_ROOT/RAW/event.h  
@@ -198,26 +211,34 @@ Bool_t AliHMPIDRawStream::Next()
   */
 
   fPosition = 0;
-  Bool_t status=kTRUE;
-  Int_t  rawDataSize=0;        
+  Bool_t status=kFALSE;
+  fRawDataSize=0;        
+  fDDLNumber = -1;
+  if (fRawReader->GetDDLID()>=0)
+    fDDLNumber = ddlArray[fRawReader->GetDDLID()];
+  
+  if(fDDLNumber<0) {
+    AliWarning(Form("fDDLNumber not a acceptable value %i",fDDLNumber));
+    return kFALSE;
+  }
+    
   if(fRawReader->GetType() == 7 || fRawReader->GetType() == 8 )  {           //New: Select Physics events, Old: Raw data size is not 0 and not 47148 (pedestal)
-    fDDLNumber = fRawReader->GetDDLID();
     fnDDLInStream[fDDLNumber]=1; fnDDLOutStream[fDDLNumber]=0;
     
     fLDCNumber = fRawReader->GetLDCId();
     fTimeStamp = fRawReader->GetTimestamp();
     
     AliDebug(1,Form("DDL %i started to be decoded!",fDDLNumber));
-    rawDataSize=fRawReader->GetDataSize()/4;
-    DelVars();                                        //We have to delete the variables initialized in the InitVars before recall IntiVars!!!
-    InitVars(rawDataSize);                            //To read the charge and pads we cannot delete before the status return
+    fRawDataSize=fRawReader->GetDataSize()/4;
+    DelVars();                                         //We have to delete the variables initialized in the InitVars before recall IntiVars!!!
+    InitVars(fRawDataSize);                            //To read the charge and pads we cannot delete before the status return
     
     if(fTurbo==kTRUE) status=Turbo();
     else status = ReadHMPIDRawData();
    
     if(status) AliDebug(1,Form("Event DDL %i successfully decoded!.",fDDLNumber));
     else AliDebug(1,Form("Event DDL %i ERROR in decoding!.",fDDLNumber));
-//      DumpData(fRawReader->GetDataSize());
+    //DumpData(fRawReader->GetDataSize());
   
    
     }
@@ -237,6 +258,7 @@ void AliHMPIDRawStream::InitVars(Int_t n)
   fPad = new Int_t[n];
   //for debug purpose
   fPos = new Int_t[4*n+4];                     //reset debug
+  for(Int_t ie = 0 ; ie < 4*n+4; ie++) fPos[ie] = 0; //initialize for 0, otherwise the position is considered filled and will not be updated for the dump
   fiPos = 0;
 }    
 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -273,8 +295,7 @@ Bool_t AliHMPIDRawStream::ReadHMPIDRawData()
   cnt--;
 
   
-  while (cnt>0) {
-    
+  while (cnt>20) { //counter limit is changed from 0 to 20 to take into account (skipp) the 5 extra words in the equipment header
     nwSeg = (fWord >> kbit8) & 0xfff;
     if(!CheckSegment()) return kFALSE;
     if(!ReadSegment(cntSegment)) return kFALSE;
@@ -377,6 +398,7 @@ Bool_t AliHMPIDRawStream::ReadDilogic(Int_t &cntDilogic)
     UInt_t pad = (fWord >> kbit12) & 0x3f;                                          //pad info in raw word is between bits: 12...17
     if(!CheckPad(pad)) continue;
     Int_t charge = fWord & 0xfff;
+    if(GetPad(fDDLNumber,row,dilogic,pad)<0) continue;
     fPad[fNPads] = GetPad(fDDLNumber,row,dilogic,pad);
     fCharge[fNPads] = charge; 
     fNPads++;
@@ -494,7 +516,7 @@ Bool_t AliHMPIDRawStream::CheckEoE(Int_t &nDil)
 //    fRawReader->AddMajorErrorLog(kEoEDILOGICErr,Form("eoe dil %d != %d",da,dilogic));
 //    AliDebug(1,Form("Wrong DILOGIC address found in end-of-event: %d, expected %d!",da,dilogic));
 //    fNumOfErr[kEoEDILOGICErr]++;
-//    return kFALSE;  AliQAChecker::Instance()->Run(AliQA::kHMPID, task, obj) ;  
+//    return kFALSE;  AliQAChecker::Instance()->Run(AliQAv1::kHMPID, task, obj) ;  
 
 //  }
 //  UInt_t ca = (eOfEvent >> 22) & 0x1f;
@@ -544,7 +566,11 @@ Bool_t AliHMPIDRawStream::GetWord(Int_t n,EDirection dir)
   // independent.
   
   fWord = 0;
-  if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
+  if (fPosition < 0) {
+    AliError("fPosition < 0 !!! Event skipped.");
+    fRawReader->AddMajorErrorLog(kRawDataSizeErr,"fPosition<0");
+    return kFALSE;
+  }
 
   if(dir==kBwd) n = -n; 
   fPosition+=4*n-4;
@@ -552,7 +578,7 @@ Bool_t AliHMPIDRawStream::GetWord(Int_t n,EDirection dir)
   if(fPosition==-4) return kTRUE;
   
   if(fPosition<0 || fPosition > fRawReader->GetDataSize()) {
-    AliDebug(1,Form("fPosition out of boundaries %i",fPosition));
+    AliWarning(Form("fPosition out of boundaries %i",fPosition));
     return kFALSE;
   }