Modifications by H. Tydesio:
authorprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Aug 2008 14:36:19 +0000 (14:36 +0000)
committerprino <prino@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 4 Aug 2008 14:36:19 +0000 (14:36 +0000)
* AliITSCalibrationSPD
Flag for fully bad chip added, significantly reducing the disk space needed for calibration files.

* AliITSOnlineCalibrationSPD
Added flags for dead equipments, half-staves, and chips.

* AliITSOnlineCalibrationSPDhandler
Functionality to treat dead equipments, half-staves, and chips. General code improvements.

* AliITSOnlineSPDphysAnalyzer
Significant speed-up of dead and noisy pixel search algorithm. Treatment of fully dead chips modified.

* AliITSPreprocessor
Changes to comply with new strategy of fully dead chips and modifications to AliITSCalibrationSPD.

* AliITSRawStreamSPD
Added event counter flags for all chips, which can be read after each event.

* AliITSRawStreamSPDErrorLog
Modifications for SPDmood. Removed the payload size information. The ConsErrPos histogram is replaced by a TGraph.

* ITSSPDPHYSda.cxx
Bug fix related to using TString instead of TObjString. General code improvements.

* ITSSPDSCANda.cxx
Bug fix related to using TString instead of TObjString.

14 files changed:
ITS/AliITSCalibrationSPD.cxx
ITS/AliITSCalibrationSPD.h
ITS/AliITSOnlineCalibrationSPD.cxx
ITS/AliITSOnlineCalibrationSPD.h
ITS/AliITSOnlineCalibrationSPDhandler.cxx
ITS/AliITSOnlineCalibrationSPDhandler.h
ITS/AliITSOnlineSPDphysAnalyzer.cxx
ITS/AliITSPreprocessorSPD.cxx
ITS/AliITSRawStreamSPD.cxx
ITS/AliITSRawStreamSPD.h
ITS/AliITSRawStreamSPDErrorLog.cxx
ITS/AliITSRawStreamSPDErrorLog.h
ITS/ITSSPDPHYSda.cxx
ITS/ITSSPDSCANda.cxx

index 1a269ff69a92733afbb28e2e0e310626ac4c4da7..d247fd72cddfdcbc2599c0877ff7877a86a84ea2 100644 (file)
@@ -21,7 +21,7 @@
 //
 //  Modified by D. Elia, G.E. Bruno, H. Tydesjo
 //  March-April 2006
-//  Last mod:  H. Tydesjo  Oct 2007
+//  Last mod:  H. Tydesjo  Aug 2008
 //  September   2007: CouplingRowDefault = 0.055 (was 0.047)
 //
 ///////////////////////////////////////////////////////////////////////////
@@ -31,7 +31,7 @@ const Double_t AliITSCalibrationSPD::fgkCouplColDefault = 0.;
 const Double_t AliITSCalibrationSPD::fgkCouplRowDefault = 0.055;
 const Double_t AliITSCalibrationSPD::fgkBiasVoltageDefault = 18.182;
 
-ClassImp(AliITSCalibrationSPD) 
+ClassImp(AliITSCalibrationSPD)
 
 //______________________________________________________________________
 AliITSCalibrationSPD::AliITSCalibrationSPD():
@@ -52,85 +52,188 @@ fBadChannels(0){
    SetBiasVoltage(fgkBiasVoltageDefault);
    SetNoiseParam(0.,0.);
    SetDataType("simulated");
+   ClearBad();
+}
+//____________________________________________________________________________
+void AliITSCalibrationSPD::ClearBad() {
+  // clear all bad pixels (single+chips)
+  fBadChannels.Reset();
+  fNrBad=0;
+  for (UInt_t chip=0; chip<5; chip++) {
+    fBadChip[chip]=kFALSE;
+  }
 }
 //____________________________________________________________________________
 void AliITSCalibrationSPD::AddBad(UInt_t col, UInt_t row) {
-  //
-  // add bad pixel 
-  //
+  // add single bad pixel 
   fBadChannels.Set(fNrBad*2+2);
   fBadChannels.AddAt(col,fNrBad*2);
   fBadChannels.AddAt(row,fNrBad*2+1);
   fNrBad++;
 }
 //____________________________________________________________________________
-Int_t AliITSCalibrationSPD::GetBadColAt(UInt_t index) {
-  //
+void AliITSCalibrationSPD::SetChipBad(UInt_t chip) {
+  // set full chip bad
+  if (chip>=5) {AliError("Wrong chip number");}
+  fBadChip[chip]=kTRUE;
+}
+//____________________________________________________________________________
+void AliITSCalibrationSPD::UnSetChipBad(UInt_t chip) {
+  // unset full chip bad
+  if (chip>=5) {AliError("Wrong chip number");}
+  fBadChip[chip]=kFALSE;
+}
+//____________________________________________________________________________
+Int_t AliITSCalibrationSPD::GetBadColAt(UInt_t index) const {
   // Get column of index-th bad pixel
-  //
-  if (index<fNrBad) {
+  if ((Int_t)index<GetNrBadSingle()) {
     return fBadChannels.At(index*2);
   }
+  else {
+    Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
+    Int_t badChipsFound =0;
+    for (UInt_t chip=0; chip<5; chip++) {
+      if (fBadChip[chip]) badChipsFound++;
+      if (badChipIndex==badChipsFound-1) {
+       Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
+       return chip*32 + badPixelIndex/256;
+      }
+    }
+  }
+  AliError(Form("Index %d is out of bounds - returning -1",index));
   return -1;
 }
 //____________________________________________________________________________
-Int_t AliITSCalibrationSPD::GetBadRowAt(UInt_t index) {
-  //
+Int_t AliITSCalibrationSPD::GetBadRowAt(UInt_t index) const {
   // Get row of index-th bad pixel
-  //
-  if (index<fNrBad) {
+  if ((Int_t)index<GetNrBadSingle()) {
     return fBadChannels.At(index*2+1);
   }
-  return -1;
-}
-//____________________________________________________________________________
-Bool_t AliITSCalibrationSPD::IsPixelBad(Int_t col, Int_t row) const {
-  //
-  // Check if pixel (col,row) is bad
-  //
-  for (UInt_t i=0; i<fNrBad; i++) { 
-    if (fBadChannels.At(i*2)==col && fBadChannels.At(i*2+1)==row) {
-      return true;
+  else {
+    Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
+    Int_t badChipsFound =0;
+    for (UInt_t chip=0; chip<5; chip++) {
+      if (fBadChip[chip]) badChipsFound++;
+      if (badChipIndex==badChipsFound-1) {
+       Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
+       return badPixelIndex%256;
+      }
     }
   }
-  return false;
+  AliError(Form("Index %d is out of bounds - returning -1",index));
+  return -1;
 }
-
 //____________________________________________________________________________
-void AliITSCalibrationSPD::GetBadPixel(Int_t i, Int_t &row, Int_t &col) const {
-  //
-  // i: is the i-th bad pixel in fBadChannels
+void AliITSCalibrationSPD::GetBadPixel(Int_t index, Int_t &row, Int_t &col) const {
+  // i: is the i-th bad pixel in single bad pixel list
   // row: is the corresponding row (-1 if i is out of range)
   // col: is the corresponding column (-1 if i is out of range)
   row = -1;
   col = -1;
-  if(i<0 || i>=GetNrBad()){
-    AliWarning(Form("Index %d is out of bounds - nothing done",i));
+  if(index>=0 && index<GetNrBadSingle()){
+    col = GetBadColAt(index);
+    row = GetBadRowAt(index);
     return;
   }
-  col = fBadChannels.At(i*2);
-  row = fBadChannels.At(i*2+1);
+  else {
+    if (index>=0) {
+      Int_t badChipIndex=(index-GetNrBadSingle())/(32*256);
+      Int_t badChipsFound =0;
+      for (UInt_t chip=0; chip<5; chip++) {
+       if (fBadChip[chip]) badChipsFound++;
+       if (badChipIndex==badChipsFound-1) {
+         Int_t badPixelIndex=(index-GetNrBadSingle())%(32*256);
+         col = chip*32 + badPixelIndex/256;
+         row = badPixelIndex%256;
+         return;
+       }
+      }
+    }
+  }
+  AliError(Form("Index %d is out of bounds - nothing done",index));
 }
 //___________________________________________________________________________
-Int_t  AliITSCalibrationSPD::GetNrBadInColumn(Int_t col) const {
- //
- // Count n. of bad in a given column: col. range [0,159]
- //
- if(col<0 || col>159) {AliWarning("GetNrBadInColumn: wrong column number"); return -1;}
- Int_t bad=0;
- for (UInt_t i=0; i<fNrBad; i++) if (fBadChannels.At(i*2)==col) bad++;
- return bad;
+Int_t  AliITSCalibrationSPD::GetNrBad() const {
+  // Total number of bad pixels (including bad chips) in a given module
+  Int_t bad=0;
+  // single pixels:
+  bad+=fNrBad;
+  // whole chips:
+  for (UInt_t chip=0; chip<5; chip++) {
+    bad+=fBadChip[chip]*32*256;
+  }
+  return bad;
 }
 //___________________________________________________________________________
 Int_t  AliITSCalibrationSPD::GetNrBadInChip(Int_t chip) const {
- //
- // Count n. of bad in a given chip: chip range [0,4]
- //
- if(chip<0 || chip>4) {AliWarning("GetNrBadInChip: wrong chip number"); return -1;}
- Int_t bad=0;
- for (Int_t col=32*chip; col<32*(chip+1); col++) bad+=GetNrBadInColumn(col);
- return bad;
+  // Total number of bad pixels (including bad chips) in a given chip: chip range [0,4]
+  if(chip<0 || chip>4) {AliError("Wrong chip number"); return -1;}
+  if (fBadChip[chip]) return 32*256;
+  else {
+    Int_t bad=0;
+    for (UInt_t i=0; i<fNrBad; i++) {
+      Int_t col = GetBadColAt(i);
+      if (col!=-1) {
+       if (GetChipIndexFromCol(col)==chip) bad++;
+      }
+    }
+    return bad;
+  }
+}
+//___________________________________________________________________________
+Int_t  AliITSCalibrationSPD::GetNrBadInColumn(Int_t col) const {
+  // Total number of bad pixels (including bad chips) in a given column: col. range [0,159]
+  if(col<0 || col>159) {AliError("Wrong column number"); return -1;}
+  if (fBadChip[GetChipIndexFromCol(col)]) return 256;
+  else {
+    Int_t bad=0;
+    for (UInt_t i=0; i<fNrBad; i++) {
+      if (GetBadColAt(i)==col) bad++;
+    }
+    return bad;
+  }
+}
+//______________________________________________________________________
+Bool_t AliITSCalibrationSPD::IsBad() const {
+  // Are all chips of this module bad?
+  for (UInt_t chip=0; chip<5; chip++) {
+    if (!fBadChip[chip]) return kFALSE;
+  }
+  return kTRUE;
+}
+//______________________________________________________________________
+Bool_t AliITSCalibrationSPD::IsChipBad(Int_t chip) const {
+  // Is the full chip bad?
+  return (GetNrBadInChip(chip)==32*256);
+}
+//______________________________________________________________________
+Bool_t AliITSCalibrationSPD::IsColumnBad(Int_t col) const {
+  // Is the full column bad?
+  return (GetNrBadInColumn(col)==256);
+}
+//____________________________________________________________________________
+Bool_t AliITSCalibrationSPD::IsPixelBad(Int_t col, Int_t row) const {
+  // Is this pixel bad?
+  if(col<0 || col>159) {AliError("Wrong column number"); return kFALSE;}
+  Int_t chip = GetChipIndexFromCol(col);
+  if (fBadChip[chip]) return kTRUE;
+  for (UInt_t i=0; i<fNrBad; i++) { 
+    if (GetBadColAt(i)==col && GetBadRowAt(i)==row) {
+      return kTRUE;
+    }
+  }
+  return kFALSE;
+}
+//______________________________________________________________________
+Int_t AliITSCalibrationSPD::GetChipIndexFromCol(UInt_t col) const {
+  // returns chip index for specific column
+  if(col>=160) {AliWarning("Wrong column number"); return -1;}
+  return col/32;
+}
+//______________________________________________________________________
+void AliITSCalibrationSPD::SetNrBad(UInt_t /*nr*/) {
+  // should not be used anymore !!!
+  AliError("This method should not be used anymore. Use SetNrBadSingle instead!!!");
 }
 //______________________________________________________________________
 void AliITSCalibrationSPD::Streamer(TBuffer &R__b) {
@@ -147,15 +250,24 @@ void AliITSCalibrationSPD::Streamer(TBuffer &R__b) {
     R__b >> fCouplRow;
     R__b >> fBiasVoltage;
     R__b >> fNrBad;
-    if (R__v > 5) {
+    if (R__v >= 7) {
       fBadChannels.Streamer(R__b);
+      R__b.ReadStaticArray((bool*)fBadChip);
     }
     else {
-      TArrayI fBadChannelsV1;
-      fBadChannelsV1.Streamer(R__b);
-      fBadChannels.Set(fNrBad*2);
-      for (UInt_t i=0; i<fNrBad*2; i++) {
-       fBadChannels[i] = fBadChannelsV1[i];
+      if (R__v == 6) {
+       fBadChannels.Streamer(R__b);
+      }
+      else {
+       TArrayI fBadChannelsV1;
+       fBadChannelsV1.Streamer(R__b);
+       fBadChannels.Set(fNrBad*2);
+       for (UInt_t i=0; i<fNrBad*2; i++) {
+         fBadChannels[i] = fBadChannelsV1[i];
+       }
+      }
+      for (UInt_t i=0; i<5; i++) {
+       fBadChip[i]=kFALSE;
       }
     }
     R__b.CheckByteCount(R__s, R__c, AliITSCalibrationSPD::IsA());
@@ -172,6 +284,7 @@ void AliITSCalibrationSPD::Streamer(TBuffer &R__b) {
     R__b << fBiasVoltage;
     R__b << fNrBad;
     fBadChannels.Streamer(R__b);
+    R__b.WriteArray(fBadChip, 5);
     R__b.SetByteCount(R__c, kTRUE);
   }
 }
index b3de146bc7778f81981a8eab0ae8f9df0274f4cf..7645dc83bffb2fa0b8a221e742799019dbefb278 100644 (file)
@@ -19,6 +19,35 @@ class AliITSCalibrationSPD :  public AliITSCalibration {
     AliITSCalibrationSPD(); // default constructor
     virtual ~AliITSCalibrationSPD() {;} // destructror
 
+    virtual void   ClearBad();
+
+    virtual Int_t  GetNrBad() const;
+    virtual Int_t  GetNrBadInChip(Int_t chip) const;
+    virtual Int_t  GetNrBadInColumn(Int_t col) const;
+
+    virtual Int_t  GetBadColAt(UInt_t index) const;
+    virtual Int_t  GetBadRowAt(UInt_t index) const;
+    virtual void   GetBadPixel(Int_t index, Int_t &row, Int_t &col) const;
+
+    virtual Int_t  GetNrBadSingle() const {return fNrBad;}
+    virtual void   SetNrBadSingle(UInt_t nr) {fNrBad=nr;} // used to be called SetNrBad, but misleading
+    virtual void   SetBadList(TArrayS badlist) {fBadChannels=badlist;}
+    virtual void   SetNrBad(UInt_t /*nr*/); // Use SetNrBadSingle!!!
+
+    virtual Bool_t IsBad() const;
+    virtual Bool_t IsChipBad(Int_t chip) const;
+    virtual Bool_t IsColumnBad(Int_t col) const;
+    virtual Bool_t IsPixelBad(Int_t col, Int_t row) const;
+
+    virtual void   SetChipBad(UInt_t chip);
+    virtual void   UnSetChipBad(UInt_t chip);
+
+    virtual void   AddBad(UInt_t col, UInt_t row);
+
+    virtual Int_t  GetChipIndexFromCol(UInt_t col) const;
+    //    virtual Int_t  GetChipFromChipIndex(UInt_t index) const;
+
+
     // Set Threshold and noise + threshold fluctuations parameter values
     virtual  void   SetThresholds(Double_t thresh, Double_t sigma)
        {fThresh=thresh; fSigma=sigma;}
@@ -70,21 +99,7 @@ class AliITSCalibrationSPD :  public AliITSCalibration {
     virtual void SetSigmaDiffusionAsymmetry(Double_t ecc) {((AliITSresponseSPD*)fResponse)->SetSigmaDiffusionAsymmetry(ecc);}
     virtual void GetSigmaDiffusionAsymmetry(Double_t &ecc) const {((AliITSresponseSPD*)fResponse)->GetSigmaDiffusionAsymmetry(ecc);}
     
-    void   AddBad(UInt_t col, UInt_t row);
-    Int_t  GetNrBad() const {return fNrBad;}
-    Int_t  GetNrBadInChip(Int_t chip) const ;
-    Int_t  GetNrBadInColumn(Int_t col) const ;
-    Int_t  GetBadColAt(UInt_t index); //returns -1 if out of bounds
-    Int_t  GetBadRowAt(UInt_t index); //returns -1 if out of bounds
-    void   ClearBad() {fBadChannels.Reset(); fNrBad=0;}
-    Bool_t IsPixelBad(Int_t col, Int_t row) const ;
-    void GetBadPixel(Int_t i, Int_t &row, Int_t &col) const;
-
-    void   SetBadList(TArrayS badlist) {fBadChannels=badlist;}
-    void   SetNrBad(UInt_t nr) {fNrBad=nr;}
-    virtual Bool_t IsBad() const {return (GetNrBad()==256*160);};
-    virtual Bool_t IsChipBad(Int_t chip) const {return (GetNrBadInChip(chip)==256*32);};
-    Bool_t  IsColumnBad(Int_t col) const {return (GetNrBadInColumn(col)==256);};
+
 
  protected:
     // static const Double_t fgkDiffCoeffDefault; //default for fDiffCoeff
@@ -100,10 +115,11 @@ class AliITSCalibrationSPD :  public AliITSCalibration {
     Double_t fCouplCol;        // Coupling parameter along the cols
     Double_t fCouplRow;        // Coupling parameter along the rows
     Double_t fBiasVoltage;     // Bias Voltage for the SPD (used to compute DistanceOverVoltage)
-    UInt_t   fNrBad;           // Nr of bad pixels
+    UInt_t   fNrBad;           // Nr of SINGLE bad pixels
     TArrayS  fBadChannels;     // Array with bad channels info (col0,row0,col1...rowN) N = fNrBad
+    Bool_t   fBadChip[5];     // Is chip completely dead?
 
-    ClassDef(AliITSCalibrationSPD,6) // SPD response
+    ClassDef(AliITSCalibrationSPD,7) // SPD response
 };
 
 #endif
index a6364bd899f65717975b680d92a4dbf95522850b..2942cd438255a3a469fbe70ccd2aed0176df5574 100644 (file)
@@ -12,9 +12,11 @@ AliITSOnlineCalibrationSPD::AliITSOnlineCalibrationSPD():
 fEqNr(0),
 fNrBad(0),
 fBadChannels(0),
-fActiveEq(kTRUE)
+fActiveEq(kTRUE),
+fDeadEq(kFALSE)
 {
   ActivateALL();
+  UnSetDeadALL();
 }
 //____________________________________________________________________________
 Int_t AliITSOnlineCalibrationSPD::GetKeyAt(UInt_t index) const {
@@ -81,4 +83,60 @@ Bool_t AliITSOnlineCalibrationSPD::IsActiveChip(UInt_t hs, UInt_t chip) const {
   }
   return fActiveChip[hs*10+chip];
 }
-
+//____________________________________________________________________________
+void AliITSOnlineCalibrationSPD::UnSetDeadALL() {
+  // activate eq, all hs, all chips
+  SetDeadEq(kFALSE);
+  for (UInt_t hs=0; hs<6; hs++) {
+    SetDeadHS(hs,kFALSE);
+    for (UInt_t chip=0; chip<10; chip++) {
+      SetDeadChip(hs,chip,kFALSE);
+    }
+  }
+}
+//____________________________________________________________________________
+void AliITSOnlineCalibrationSPD::SetDeadEq(Bool_t setval) {
+  // set this eq dead
+  fDeadEq = setval;
+}
+//____________________________________________________________________________
+void AliITSOnlineCalibrationSPD::SetDeadHS(UInt_t hs, Bool_t setval) {
+  // set dead hs on this eq
+  if (hs>=6) {
+    Error("AliITSOnlineCalibrationSPD::SetDeadHS", "hs (%d) out of bounds.",hs);
+    return;
+  }
+  fDeadHS[hs] = setval;
+}
+//____________________________________________________________________________
+void AliITSOnlineCalibrationSPD::SetDeadChip(UInt_t hs, UInt_t chip, Bool_t setval) {
+  // set dead chip on this eq
+  if (hs>=6 || chip>=10) {
+    Error("AliITSOnlineCalibrationSPD::SetDeadChip", "hs,chip (%d,%d) out of bounds.",hs,chip);
+    return;
+  }
+  fDeadChip[hs*10+chip] = setval;
+}
+//____________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPD::IsDeadEq() const {
+  // is this eq dead?
+  return fDeadEq;
+}
+//____________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPD::IsDeadHS(UInt_t hs) const {
+  // is this hs dead?
+  if (hs>=6) {
+    Error("AliITSOnlineCalibrationSPD::IsDeadHS", "hs (%d) out of bounds.",hs);
+    return kFALSE;
+  }
+  return fDeadHS[hs];
+}
+//____________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPD::IsDeadChip(UInt_t hs, UInt_t chip) const {
+  // is this chip dead?
+  if (hs>=6 || chip>=10) {
+    Error("AliITSOnlineCalibrationSPD::IsDeadChip", "hs,chip (%d,%d) out of bounds.",hs,chip);
+    return kFALSE;
+  }
+  return fDeadChip[hs*10+chip];
+}
index dec4e741273b91c512430886ef2b7646d5d6ad38..01f9ec6c9ec6e9253eee87b220ed4102f7ce823d 100644 (file)
@@ -30,24 +30,36 @@ class AliITSOnlineCalibrationSPD : public TObject {
 
     void   ClearBad() {fBadChannels.Reset(); fNrBad=0;}
 
-    Bool_t IsActiveEq() const;
-    Bool_t IsActiveHS(UInt_t hs) const;
-    Bool_t IsActiveChip(UInt_t hs, UInt_t chip) const;
-
     void   ActivateALL();
     void   ActivateEq(Bool_t setval = kTRUE);
     void   ActivateHS(UInt_t hs, Bool_t setval = kTRUE);
     void   ActivateChip(UInt_t hs, UInt_t chip, Bool_t setval = kTRUE);
 
+    Bool_t IsActiveEq() const;
+    Bool_t IsActiveHS(UInt_t hs) const;
+    Bool_t IsActiveChip(UInt_t hs, UInt_t chip) const;
+
+    void   UnSetDeadALL();
+    void   SetDeadEq(Bool_t setval = kTRUE);
+    void   SetDeadHS(UInt_t hs, Bool_t setval = kTRUE);
+    void   SetDeadChip(UInt_t hs, UInt_t chip, Bool_t setval = kTRUE);
+    
+    Bool_t IsDeadEq() const;
+    Bool_t IsDeadHS(UInt_t hs) const;
+    Bool_t IsDeadChip(UInt_t hs, UInt_t chip) const;
+
  private:
-    UInt_t   fEqNr;            // eq nr
-    UInt_t   fNrBad;           // nr of bad pixels
-    TArrayI  fBadChannels;     // array of keys for the bad
-    Bool_t   fActiveEq;        // active bit for each equipment
-    Bool_t   fActiveHS[6];     // active bit for each half-stave
-    Bool_t   fActiveChip[60];  // active bit for each chip
-
-    ClassDef(AliITSOnlineCalibrationSPD,2)
+    UInt_t   fEqNr;                // eq nr
+    UInt_t   fNrBad;               // nr of bad (single) pixels
+    TArrayI  fBadChannels;         // array of keys for the bad (single) pixels
+    Bool_t   fActiveEq;            // active bit for each equipment
+    Bool_t   fActiveHS[6];         // active bit for each half-stave
+    Bool_t   fActiveChip[60];      // active bit for each chip
+    Bool_t   fDeadEq;              // dead bit for each equipment
+    Bool_t   fDeadHS[6];           // dead bit for each half-stave
+    Bool_t   fDeadChip[60];        // dead bit for each chip
+
+    ClassDef(AliITSOnlineCalibrationSPD,3)
 };
 
 #endif
index fdedb537d3d213f2f2f797edc0e54f093f7f5d74..c50f22190177044a45d5c8ad3affe799d44db55a 100644 (file)
@@ -40,6 +40,7 @@ AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler():
     fNoisyPixelMap[gloChip] = new AliITSIntMap();    
   }
   ActivateALL();
+  UnSetDeadALL();
 }
 //____________________________________________________________________________________________
 AliITSOnlineCalibrationSPDhandler::AliITSOnlineCalibrationSPDhandler(const AliITSOnlineCalibrationSPDhandler& handle): 
@@ -105,6 +106,7 @@ void AliITSOnlineCalibrationSPDhandler::ClearMaps() {
 //____________________________________________________________________________________________
 void AliITSOnlineCalibrationSPDhandler::ResetDead() {
   // reset the dead pixel map and inactive eq,hs,chip
+  UnSetDeadALL();
   for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
     fNrDead[gloChip]=0;
     fDeadPixelMap[gloChip]->Clear();
@@ -121,6 +123,7 @@ void AliITSOnlineCalibrationSPDhandler::ResetNoisy() {
 //____________________________________________________________________________________________
 void AliITSOnlineCalibrationSPDhandler::ResetDeadForChip(UInt_t eq, UInt_t hs, UInt_t chip) {
   // clear the dead pixels for this chip
+  SetDeadChip(eq,hs,chip,kFALSE);
   UInt_t gloChip = GetGloChip(eq,hs,chip);
   for (UInt_t col=0; col<32; col++) {
     for (UInt_t row=0; row<256; row++) {
@@ -245,6 +248,17 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromFileName(const char *fileN
          UInt_t row = GetRowFromKey(key);
          SetDeadPixel(eq,hs,chip,col,row);
        }
+       UInt_t eq = calib->GetEqNr();
+       if (calib->IsDeadEq()) SetDeadEq(eq);
+       else                   SetDeadEq(eq,kFALSE);
+       for (UInt_t hs=0; hs<6; hs++) {
+         if (calib->IsDeadHS(hs)) SetDeadHS(eq,hs);
+         else                     SetDeadHS(eq,hs,kFALSE);
+         for (UInt_t chip=0; chip<10; chip++) {
+           if (calib->IsDeadChip(hs,chip)) SetDeadChip(eq,hs,chip);
+           else                            SetDeadChip(eq,hs,chip,kFALSE);
+         }
+       }
        if (inactive) {
          UInt_t eq = calib->GetEqNr();
          if (calib->IsActiveEq()) ActivateEq(eq);
@@ -447,6 +461,16 @@ void AliITSOnlineCalibrationSPDhandler::WriteDeadToFile(UInt_t eq, Bool_t inacti
   calib->SetEqNr(eq);
   calib->SetBadList(GetDeadArrayOnline(eq));
   calib->SetNrBad(GetNrDeadEq(eq));
+  if (IsDeadEq(eq)) calib->SetDeadEq();
+  else              calib->SetDeadEq(kFALSE);
+  for (UInt_t hs=0; hs<6; hs++) {
+    if (IsDeadHS(eq,hs)) calib->SetDeadHS(hs);
+    else                 calib->SetDeadHS(hs,kFALSE);
+    for (UInt_t chip=0; chip<10; chip++) {
+      if (IsDeadChip(eq,hs,chip)) calib->SetDeadChip(hs,chip);
+      else                        calib->SetDeadChip(hs,chip,kFALSE);
+    }
+  }
   if (inactive) {
     if (IsActiveEq(eq)) calib->ActivateEq();
     else                calib->ActivateEq(kFALSE);
@@ -498,7 +522,8 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadModuleFromDB(UInt_t module, In
   }
   AliITSCalibrationSPD* calibSPD;
   calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
-  UInt_t nrDead = calibSPD->GetNrBad();
+
+  UInt_t nrDead = calibSPD->GetNrBadSingle();
   if (nrDead>0) {
     if (!treeSerial) RecursiveInsertDead(calibSPD,module,0,nrDead-1);
     else {
@@ -509,6 +534,17 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadModuleFromDB(UInt_t module, In
       }
     }
   }
+  for (UInt_t chipIndex=0; chipIndex<5; chipIndex++) {
+    UInt_t eq,hs,chip,col,row;
+    AliITSRawStreamSPD::OfflineToOnline(module, chipIndex*32, 0, eq, hs, chip, col, row);
+    if (calibSPD->IsChipBad(chipIndex)) {
+      SetDeadChip(eq,hs,chip);
+    }
+    else {
+      SetDeadChip(eq,hs,chip,kFALSE);
+    }
+  }
+
   spdEntry->SetOwner(kTRUE);
   spdEntry->Clear();
   return kTRUE;
@@ -532,7 +568,7 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyModuleFromDB(UInt_t module, I
   }
   AliITSCalibrationSPD* calibSPD;
   calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
-  UInt_t nrNoisy = calibSPD->GetNrBad();
+  UInt_t nrNoisy = calibSPD->GetNrBadSingle();
   if (nrNoisy>0) {
     if (!treeSerial) RecursiveInsertNoisy(calibSPD,module,0,nrNoisy-1);
     else {
@@ -573,9 +609,8 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromDB(Int_t runNr, Bool_t tre
   }
   AliITSCalibrationSPD* calibSPD;
   for (UInt_t module=0; module<240; module++) {
-    //    printf("Reading module %d\n",module);
     calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
-    UInt_t nrDead = calibSPD->GetNrBad();
+    UInt_t nrDead = calibSPD->GetNrBadSingle();
     if (nrDead>0) {    
       if (!treeSerial) RecursiveInsertDead(calibSPD,module,0,nrDead-1);
       else {
@@ -586,6 +621,16 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromDB(Int_t runNr, Bool_t tre
        }
       }
     }
+    for (UInt_t chipIndex=0; chipIndex<5; chipIndex++) {
+      UInt_t eq,hs,chip,col,row;
+      AliITSRawStreamSPD::OfflineToOnline(module, chipIndex*32, 0, eq, hs, chip, col, row);
+      if (calibSPD->IsChipBad(chipIndex)) {
+       SetDeadChip(eq,hs,chip);
+      }
+      else {
+       SetDeadChip(eq,hs,chip,kFALSE);
+      }
+    }
   }
   spdEntry->SetOwner(kTRUE);
   spdEntry->Clear();
@@ -613,10 +658,9 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromDB(Int_t runNr, Bool_t tr
   for (UInt_t module=0; module<240; module++) {
     //    printf("Reading module %d\n",module);
     calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
-    UInt_t nrNoisy = calibSPD->GetNrBad();
+    UInt_t nrNoisy = calibSPD->GetNrBadSingle();
     if (nrNoisy>0) {    
       if (!treeSerial) {
-       printf("*** mod %d nrnoisy=%d\n",module,nrNoisy);
        RecursiveInsertNoisy(calibSPD,module,0,nrNoisy-1);
       }
       else {
@@ -636,10 +680,19 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromDB(Int_t runNr, Bool_t tr
 Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromCalibObj(TObjArray* calObj) {
   // reads dead pixels from calib object
   for (UInt_t module=0; module<240; module++) {
-    for (Int_t i=0; i<((AliITSCalibrationSPD*)calObj->At(module))->GetNrBad(); i++) {
-      SetDeadPixelM(module,
-                   ((AliITSCalibrationSPD*)calObj->At(module))->GetBadColAt(i),
-                   ((AliITSCalibrationSPD*)calObj->At(module))->GetBadRowAt(i));
+    AliITSCalibrationSPD* calibSPD = (AliITSCalibrationSPD*)calObj->At(module);
+    for (Int_t i=0; i<calibSPD->GetNrBadSingle(); i++) {
+      SetDeadPixelM(module,calibSPD->GetBadColAt(i),calibSPD->GetBadRowAt(i));
+    }
+    for (UInt_t chipIndex=0; chipIndex<5; chipIndex++) {
+      UInt_t eq,hs,chip,col,row;
+      AliITSRawStreamSPD::OfflineToOnline(module, chipIndex*32, 0, eq, hs, chip, col, row);
+      if (calibSPD->IsChipBad(chipIndex)) {
+       SetDeadChip(eq,hs,chip);
+      }
+      else {
+       SetDeadChip(eq,hs,chip,kFALSE);
+      }
     }
   }
   return kTRUE;
@@ -648,10 +701,9 @@ Bool_t AliITSOnlineCalibrationSPDhandler::ReadDeadFromCalibObj(TObjArray* calObj
 Bool_t AliITSOnlineCalibrationSPDhandler::ReadNoisyFromCalibObj(TObjArray* calObj) {
   // reads noisy pixels from calib object
   for (UInt_t module=0; module<240; module++) {
-    for (Int_t i=0; i<((AliITSCalibrationSPD*)calObj->At(module))->GetNrBad(); i++) {
-      SetNoisyPixelM(module,
-                    ((AliITSCalibrationSPD*)calObj->At(module))->GetBadColAt(i),
-                    ((AliITSCalibrationSPD*)calObj->At(module))->GetBadRowAt(i));
+    AliITSCalibrationSPD* calibSPD = (AliITSCalibrationSPD*)calObj->At(module);
+    for (Int_t i=0; i<calibSPD->GetNrBadSingle(); i++) {
+      SetNoisyPixelM(module,calibSPD->GetBadColAt(i),calibSPD->GetBadRowAt(i));
     }
   }
   return kTRUE;
@@ -677,22 +729,33 @@ Bool_t AliITSOnlineCalibrationSPDhandler::WriteDeadToDB(Int_t runNrStart, Int_t
   TObjArray* spdEntry = new TObjArray(240);
   spdEntry->SetOwner(kTRUE);
   for(UInt_t module=0; module<240; module++){
-    AliITSCalibrationSPD* calObj = new AliITSCalibrationSPD();
+    AliITSCalibrationSPD* calibSPD = new AliITSCalibrationSPD();
 
     // *** this is temporarily hard coded here ********************
     // (later these parameters will be separated from the cal.obj.)
-    calObj->SetThresholds(3000, 250);
-    calObj->SetBiasVoltage(18.182);
-    calObj->SetNoiseParam(0,0);
-    calObj->SetCouplingParam(0.,0.055);
+    calibSPD->SetThresholds(3000, 250);
+    calibSPD->SetBiasVoltage(18.182);
+    calibSPD->SetNoiseParam(0,0);
+    calibSPD->SetCouplingParam(0.,0.055);
     // *** remove later...
     // ************************************************************
 
-    spdEntry->Add(calObj);
+    spdEntry->Add(calibSPD);
   }
   for(UInt_t module=0; module<240; module++){
-    ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrBad( GetNrSilent(module) );
-    ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetBadList( GetSilentArray(module) );
+    AliITSCalibrationSPD* calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
+    calibSPD->SetNrBadSingle( GetNrDead(module) );
+    calibSPD->SetBadList( GetDeadArray(module) );
+    for (UInt_t chipIndex=0; chipIndex<5; chipIndex++) {
+      UInt_t eq,hs,chip,col,row;
+      AliITSRawStreamSPD::OfflineToOnline(module, chipIndex*32, 0, eq, hs, chip, col, row);
+      if (IsSilentChip(eq,hs,chip)) {
+       calibSPD->SetChipBad(chipIndex);
+      }
+      else {
+       calibSPD->UnSetChipBad(chipIndex);
+      }
+    }
   }
   AliCDBEntry* cdbEntry = new AliCDBEntry((TObject*)spdEntry,idCalSPD,metaData);
   man->Put(cdbEntry);
@@ -716,22 +779,23 @@ Bool_t AliITSOnlineCalibrationSPDhandler::WriteNoisyToDB(Int_t runNrStart, Int_t
   TObjArray* spdEntry = new TObjArray(240);
   spdEntry->SetOwner(kTRUE);
   for(UInt_t module=0; module<240; module++){
-    AliITSCalibrationSPD* calObj = new AliITSCalibrationSPD();
+    AliITSCalibrationSPD* calibSPD = new AliITSCalibrationSPD();
 
     // *** this is temporarily hard coded here ********************
     // (later these parameters will be separated from the cal.obj.)
-    calObj->SetThresholds(3000, 250);
-    calObj->SetBiasVoltage(18.182);
-    calObj->SetNoiseParam(0,0);
-    calObj->SetCouplingParam(0.,0.055);
+    calibSPD->SetThresholds(3000, 250);
+    calibSPD->SetBiasVoltage(18.182);
+    calibSPD->SetNoiseParam(0,0);
+    calibSPD->SetCouplingParam(0.,0.055);
     // *** remove later...
     // ************************************************************
 
-    spdEntry->Add(calObj);
+    spdEntry->Add(calibSPD);
   }
   for(UInt_t module=0; module<240; module++){
-    ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetNrBad( GetNrNoisy(module) );
-    ((AliITSCalibrationSPD*) spdEntry->At(module)) -> SetBadList( GetNoisyArray(module) );
+    AliITSCalibrationSPD* calibSPD = (AliITSCalibrationSPD*) spdEntry->At(module);
+    calibSPD->SetNrBadSingle( GetNrNoisy(module) );
+    calibSPD->SetBadList( GetNoisyArray(module) );
   }
   AliCDBEntry* cdbEntry = new AliCDBEntry((TObject*)spdEntry,idCalSPD,metaData);
   man->Put(cdbEntry);
@@ -789,6 +853,7 @@ void AliITSOnlineCalibrationSPDhandler::GenerateDCSConfigFile(const Char_t* file
 //____________________________________________________________________________________________
 TArrayS AliITSOnlineCalibrationSPDhandler::GetSilentArray(UInt_t module, Bool_t treeSerial) {
   // get a TArrayS of the silent=dead+inactive pixels (format for the AliITSCalibrationSPD object)
+  // NB! with new implementation of AliITSCalibrationSPD this is not needed anymore
   TArrayS returnArray;
 
   UInt_t eq = GetEqIdFromOffline(module);
@@ -852,7 +917,7 @@ TArrayS AliITSOnlineCalibrationSPDhandler::GetSilentArray(UInt_t module, Bool_t
 }
 //____________________________________________________________________________________________
 TArrayS AliITSOnlineCalibrationSPDhandler::GetDeadArray(UInt_t module, Bool_t treeSerial) {
-  // get a TArrayS of the dead pixels (format for the AliITSCalibrationSPD object)
+  // get a TArrayS of the single dead pixels (format for the AliITSCalibrationSPD object)
   TArrayS returnArray;
 
   UInt_t eq = GetEqIdFromOffline(module);
@@ -865,23 +930,26 @@ TArrayS AliITSOnlineCalibrationSPDhandler::GetDeadArray(UInt_t module, Bool_t tr
   returnArray.Set(size*2);
   UInt_t gloIndex=0;
   for (UInt_t ch=0; ch<5; ch++) {
-    UInt_t gloChip = GetGloChip(eq,hs,GetChipFromOffline(module,ch*32));
+    UInt_t chip = GetChipFromOffline(module,ch*32);
+    UInt_t gloChip = GetGloChip(eq,hs,chip);
     if (treeSerial) fDeadPixelMap[gloChip]->PrepareSerialize(); // for tree ordered values
     else fDeadPixelMap[gloChip]->PrepareSerializeOrdered(); // for key ordered values
-    for (UInt_t index=0; index<fNrDead[gloChip]; index++) {
-      Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
-      Int_t colM = GetColMFromKey(key);
-      Int_t rowM = GetRowMFromKey(key);
-      returnArray.AddAt(colM,gloIndex*2);
-      returnArray.AddAt(rowM,gloIndex*2+1);
-      gloIndex++;
+    if (!IsSilentChip(eq,hs,chip)) {
+      for (UInt_t index=0; index<fNrDead[gloChip]; index++) {
+       Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
+       Int_t colM = GetColMFromKey(key);
+       Int_t rowM = GetRowMFromKey(key);
+       returnArray.AddAt(colM,gloIndex*2);
+       returnArray.AddAt(rowM,gloIndex*2+1);
+       gloIndex++;
+      }
     }
   }
   return returnArray;
 }
 //____________________________________________________________________________________________
 TArrayS AliITSOnlineCalibrationSPDhandler::GetNoisyArray(UInt_t module, Bool_t treeSerial) {
-  // get a TArrayS of the noisy pixels (format for the AliITSCalibrationSPD object)
+  // get a TArrayS of the single noisy pixels (format for the AliITSCalibrationSPD object)
   TArrayS returnArray;
 
   UInt_t eq = GetEqIdFromOffline(module);
@@ -910,7 +978,7 @@ TArrayS AliITSOnlineCalibrationSPDhandler::GetNoisyArray(UInt_t module, Bool_t t
 }
 //____________________________________________________________________________________________
 TArrayI AliITSOnlineCalibrationSPDhandler::GetDeadArrayOnline(UInt_t eq) {
-  // get a TArrayI of the dead pixels (format for the AliITSOnlineCalibrationSPD object)
+  // get a TArrayI of the single dead pixels (format for the AliITSOnlineCalibrationSPD object)
   TArrayI returnArray;
   // fix size of array
   UInt_t size=0;
@@ -938,7 +1006,7 @@ TArrayI AliITSOnlineCalibrationSPDhandler::GetDeadArrayOnline(UInt_t eq) {
 }
 //____________________________________________________________________________________________
 TArrayI AliITSOnlineCalibrationSPDhandler::GetNoisyArrayOnline(UInt_t eq) {
-  // get a TArrayI of the noisy pixels (format for the AliITSOnlineCalibrationSPD object)
+  // get a TArrayI of the single noisy pixels (format for the AliITSOnlineCalibrationSPD object)
   TArrayI returnArray;
   // fix size of array
   UInt_t size=0;
@@ -971,17 +1039,17 @@ void AliITSOnlineCalibrationSPDhandler::PrintEqSummary() {
   printf("Eq summary:\n");
   printf("-----------\n");
   for (UInt_t eq=0; eq<20; eq++) {
-    printf("Eq %*d: %*d silent(dead+inactive) , %*d dead , %*d noisy\n",2,eq,5,GetNrSilentEq(eq),5,GetNrDeadEq(eq),5,GetNrNoisyEq(eq));
+    printf("Eq %*d: %*d silent(dead+inactive) , %*d dead , %*d noisy\n",2,eq,6,GetNrSilentEq(eq),6,GetNrDeadEq(eq),6,GetNrNoisyEq(eq));
   }
 }
 //____________________________________________________________________________________________
 void AliITSOnlineCalibrationSPDhandler::PrintSilent() const {
   // print the inactive and dead pixels to screen
-  printf("------------------------------------------------------\n");
-  printf("Inactive Equipments: (eq  |  module1 .. module12)\n");
-  printf("------------------------------------------------------\n");
+  printf("-----------------------------------------------------------\n");
+  printf("Inactive or dead Equipments: (eq  |  module1 .. module12)\n");
+  printf("-----------------------------------------------------------\n");
   for (UInt_t eq=0; eq<20; eq++) {
-    if (!IsActiveEq(eq)) {
+    if (IsSilentEq(eq)) {
       printf("%*d  |  ",2,eq);
       for (UInt_t hs=0; hs<6; hs++) {
        for (UInt_t chip=0; chip<10; chip+=5) {
@@ -994,13 +1062,13 @@ void AliITSOnlineCalibrationSPDhandler::PrintSilent() const {
     }
   }
 
-  printf("------------------------------------------------------\n");
-  printf("Inactive Half-staves: (eq,hs  |  module1,module2)\n");
-  printf("------------------------------------------------------\n");
+  printf("-----------------------------------------------------------\n");
+  printf("Inactive or dead Half-staves: (eq,hs  |  module1,module2)\n");
+  printf("-----------------------------------------------------------\n");
   for (UInt_t eq=0; eq<20; eq++) {
-    if (IsActiveEq(eq)) {
+    if (!IsSilentEq(eq)) {
       for (UInt_t hs=0; hs<6; hs++) {
-       if (!IsActiveHS(eq,hs)) {
+       if (IsSilentHS(eq,hs)) {
          printf("%*d,%*d  |  ",2,eq,1,hs);
          for (UInt_t chip=0; chip<10; chip+=5) {
            UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
@@ -1013,15 +1081,15 @@ void AliITSOnlineCalibrationSPDhandler::PrintSilent() const {
     }
   }
 
-  printf("------------------------------------------------------\n");
-  printf("Inactive Chips: (eq,hs,chip  |  module,colM1-colM2)\n");
-  printf("------------------------------------------------------\n");
+  printf("-----------------------------------------------------------\n");
+  printf("Inactive or dead Chips: (eq,hs,chip  |  module,colM1-colM2)\n");
+  printf("-----------------------------------------------------------\n");
   for (UInt_t eq=0; eq<20; eq++) {
-    if (IsActiveEq(eq)) {
+    if (!IsSilentEq(eq)) {
       for (UInt_t hs=0; hs<6; hs++) {
-       if (IsActiveHS(eq,hs)) {
+       if (!IsSilentHS(eq,hs)) {
          for (UInt_t chip=0; chip<10; chip++) {
-           if (!IsActiveChip(eq,hs,chip)) {
+           if (IsSilentChip(eq,hs,chip)) {
              printf("%*d,%*d,%*d  |  ",2,eq,1,hs,1,chip);
              UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
              UInt_t colM1 = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,0);
@@ -1036,27 +1104,6 @@ void AliITSOnlineCalibrationSPDhandler::PrintSilent() const {
 
   PrintDead();
 
-//!!!  printf("------------------------------------------------------\n");
-//!!!  printf("Dead Pixels: (eq,hs,chip,col,row  |  module,colM,rowM)\n");
-//!!!  printf("------------------------------------------------------\n");
-//!!!  for (UInt_t gloChip=0; gloChip<1200; gloChip++) {
-//!!!    for (UInt_t index=0; index<fNrDead[gloChip]; index++) {
-//!!!      Int_t key = fDeadPixelMap[gloChip]->GetKeyIndex(index);
-//!!!      UInt_t eq = GetEqIdFromKey(key);
-//!!!      UInt_t hs = GetHSFromKey(key);
-//!!!      UInt_t chip = GetChipFromKey(key);
-//!!!      if (!( IsActiveEq(eq) && IsActiveHS(eq,hs) && IsActiveChip(eq,hs,chip) )) continue;
-//!!!      UInt_t col = GetColFromKey(key);
-//!!!      UInt_t row = GetRowFromKey(key);
-//!!!
-//!!!      UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
-//!!!      UInt_t colM = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,col);
-//!!!      UInt_t rowM = AliITSRawStreamSPD::GetOfflineRowFromOnline(eq,hs,chip,row);
-//!!!
-//!!!      printf("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d\n",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
-//!!!    }
-//!!!  }
-
 }
 //____________________________________________________________________________________________
 void AliITSOnlineCalibrationSPDhandler::PrintDead() const {
@@ -1219,58 +1266,9 @@ Bool_t AliITSOnlineCalibrationSPDhandler::UnSetNoisyPixelM(UInt_t module, UInt_t
   return UnSetNoisyPixel(eq,hs,chip,col,row);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::SetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip) {
-  // set a full chip dead, returns nr of new dead pixels
-  UInt_t nrNew = 0;
-  for (UInt_t col=0; col<32; col++) {
-    for (UInt_t row=0; row<256; row++) {
-      if (SetDeadPixel(eq,hs,chip,col,row)) {
-       nrNew++;
-      }
-    }
-  }
-  return nrNew;
-}
-//____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::SetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip) {
-  // set a full chip noisy, returns nr of new noisy pixels
-  UInt_t nrNew = 0;
-  for (UInt_t col=0; col<32; col++) {
-    for (UInt_t row=0; row<256; row++) {
-      if (SetNoisyPixel(eq,hs,chip,col,row)) {
-       nrNew++;
-      }
-    }
-  }
-  return nrNew;
-}
-//____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::UnSetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip) {
-  // unset a full dead chip, returns false if it was not all dead before
-  UInt_t nrUnset = 0;
-  for (UInt_t col=0; col<32; col++) {
-    for (UInt_t row=0; row<256; row++) {
-      if (UnSetDeadPixel(eq,hs,chip,col,row)) {
-       nrUnset++;
-      }
-    }
-  }
-  if (nrUnset+GetNrNoisyC(eq,hs,chip)<8192) return kFALSE;
-  else return kTRUE;
-}
-//____________________________________________________________________________________________
-Bool_t AliITSOnlineCalibrationSPDhandler::UnSetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip) {
-  // unset a full noisy chip, returns false if it was not all noisy before
-  UInt_t nrUnset = 0;
-  for (UInt_t col=0; col<32; col++) {
-    for (UInt_t row=0; row<256; row++) {
-      if (UnSetNoisyPixel(eq,hs,chip,col,row)) {
-       nrUnset++;
-      }
-    }
-  }
-  if (nrUnset<8192) return kFALSE;
-  else return kTRUE;
+Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelBad(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const {
+  // is the pixel bad (silent or noisy)
+  return (IsPixelSilent(eq,hs,chip,col,row) || IsPixelNoisy(eq,hs,chip,col,row));
 }
 //____________________________________________________________________________________________
 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelSilent(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const {
@@ -1280,20 +1278,23 @@ Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelSilent(UInt_t eq, UInt_t hs, UI
     Error("AliITSOnlineCalibrationSPDhandler::IsPixelSilent", "eq,hs,chip,col,row nrs (%d,%d,%d,%d,%d) out of bounds.",eq,hs,chip,col,row);
     return kFALSE;
   }
-  if (!(IsActiveEq(eq) && IsActiveHS(eq,hs) && IsActiveChip(eq,hs,chip))) return kTRUE;
+  if (IsSilentChip(eq,hs,chip)) return kTRUE;
   else return IsPixelDead(eq,hs,chip,col,row);
 }
 //____________________________________________________________________________________________
 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelDead(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const {
-  // is the pixel?
+  // is the pixel dead?
   UInt_t gloChip = GetGloChip(eq,hs,chip);
   if (gloChip>=1200 || col>=32 || row>=256) {
     Error("AliITSOnlineCalibrationSPDhandler::IsPixelDead", "eq,hs,chip,col,row nrs (%d,%d,%d,%d,%d) out of bounds.",eq,hs,chip,col,row);
     return kFALSE;
   }
   UInt_t key = GetKey(eq,hs,chip,col,row);
-  if ( fDeadPixelMap[gloChip]->Find(key) != NULL ) return kTRUE;
-  else return kFALSE;
+  if (IsDeadEq(eq) || IsDeadHS(eq,hs) || IsDeadChip(eq,hs,chip)) return kTRUE;
+  else {
+    if ( fDeadPixelMap[gloChip]->Find(key) != NULL ) return kTRUE;
+    else return kFALSE;
+  }
 }
 //____________________________________________________________________________________________
 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisy(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const {
@@ -1308,6 +1309,11 @@ Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisy(UInt_t eq, UInt_t hs, UIn
   else return kFALSE;
 }
 //____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelBadM(UInt_t module, UInt_t colM, UInt_t rowM) const {
+  // is the pixel bad (silent or noisy)?
+  return (IsPixelSilentM(module,colM,rowM) || IsPixelNoisyM(module,colM,rowM));
+}
+//____________________________________________________________________________________________
 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelSilentM(UInt_t module, UInt_t colM, UInt_t rowM) const {
   // is the pixel silent (dead or inactive)?
   UInt_t eq = GetEqIdFromOffline(module);
@@ -1338,6 +1344,16 @@ Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisyM(UInt_t module, UInt_t co
   return IsPixelNoisy(eq,hs,chip,col,row);
 }
 //____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelBadKey(Int_t key) const {
+  // is this pixel silent (dead or inactive)?
+  UInt_t eq = GetEqIdFromKey(key);
+  UInt_t hs = GetHSFromKey(key);
+  UInt_t chip = GetChipFromKey(key);
+  UInt_t col = GetColFromKey(key);
+  UInt_t row = GetRowFromKey(key);
+  return IsPixelBad(eq,hs,chip,col,row);
+}
+//____________________________________________________________________________________________
 Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelSilentKey(Int_t key) const {
   // is this pixel silent (dead or inactive)?
   UInt_t eq = GetEqIdFromKey(key);
@@ -1368,21 +1384,37 @@ Bool_t AliITSOnlineCalibrationSPDhandler::IsPixelNoisyKey(Int_t key) const {
   return IsPixelNoisy(eq,hs,chip,col,row);
 }
 //____________________________________________________________________________________________
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNrBad() const {
+  // returns the total nr of bad pixels (silent or noisy)
+  UInt_t nrBad=0;
+  nrBad+=GetNrSilent();
+  UInt_t nrNoisy = GetNrNoisy();
+  for (UInt_t i=0; i<nrNoisy; i++) {
+    UInt_t eq   = GetNoisyEqIdAt(i);
+    UInt_t hs   = GetNoisyHSAt(i);
+    UInt_t chip = GetNoisyChipAt(i);
+    UInt_t col  = GetNoisyColAt(i);
+    UInt_t row  = GetNoisyRowAt(i);
+    if (!IsPixelSilent(eq,hs,chip,col,row)) nrBad++;
+  }
+  return nrBad;
+}
+//____________________________________________________________________________________________
 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilent() const {
   // returns the total nr of silent pixels (dead or inactive)
   UInt_t nrDead = 0;
   for (UInt_t eq=0; eq<20; eq++) {
-    if (!IsActiveEq(eq)) {
+    if (IsSilentEq(eq)) {
       nrDead+=81920*6;
       continue;
     }
     for (UInt_t hs=0; hs<6; hs++) {
-      if (!IsActiveHS(eq,hs)) {
+      if (IsSilentHS(eq,hs)) {
        nrDead+=81920;
        continue;
       }
       for (UInt_t chip=0; chip<10; chip++) {
-       if (!IsActiveChip(eq,hs,chip)) {
+       if (IsSilentChip(eq,hs,chip)) {
          nrDead+=8192;
          continue;
        }
@@ -1414,7 +1446,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisy() const {
   return nrNoisy;
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt(UInt_t index) const {
   // get eq for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1422,7 +1454,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt(UInt_t index) {
   return GetDeadEqIdAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt(UInt_t index) const {
   // get eq for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1430,7 +1462,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt(UInt_t index) {
   return GetNoisyEqIdAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAt(UInt_t index) const {
   // get hs for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1438,7 +1470,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAt(UInt_t index) {
   return GetDeadHSAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt(UInt_t index) const {
   // get hs for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1446,7 +1478,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt(UInt_t index) {
   return GetNoisyHSAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAt(UInt_t index) const {
   // get chip for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1454,7 +1486,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAt(UInt_t index) {
   return GetDeadChipAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt(UInt_t index) const {
   // get chip for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1462,7 +1494,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt(UInt_t index) {
   return GetNoisyChipAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t index) const {
   // get hs for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1470,7 +1502,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t index) {
   return GetDeadColAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t index) const {
   // get hs for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1478,7 +1510,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t index) {
   return GetNoisyColAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t index) const {
   // get hs for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1486,7 +1518,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t index) {
   return GetDeadRowAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t index) const {
   // get hs for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1494,6 +1526,22 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t index) {
   return GetNoisyRowAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNrBad(UInt_t module) const {
+  // returns the number of bad pixels for a certain module (silent or noisy)
+  UInt_t nrBad = 0;
+  nrBad+=GetNrSilent(module);
+  UInt_t nrNoisy = GetNrNoisy(module);
+  for (UInt_t i=0; i<nrNoisy; i++) {
+    UInt_t eq   = GetNoisyEqIdAt(module,i);
+    UInt_t hs   = GetNoisyHSAt(module,i);
+    UInt_t chip = GetNoisyChipAt(module,i);
+    UInt_t col  = GetNoisyColAt(module,i);
+    UInt_t row  = GetNoisyRowAt(module,i);
+    if (!IsPixelSilent(eq,hs,chip,col,row)) nrBad++;
+  }
+  return nrBad;
+}
+//____________________________________________________________________________________________
 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilent(UInt_t module) const {
   // returns the number of silent pixels for a certain module (dead or inactive)
   if (module>=240) {
@@ -1502,12 +1550,12 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilent(UInt_t module) const {
   }
   UInt_t nrSilent = 0;
   UInt_t eq = GetEqIdFromOffline(module);
-  if (!IsActiveEq(eq)) return 160*256;
+  if (IsSilentEq(eq)) return 160*256;
   UInt_t hs = GetHSFromOffline(module);
-  if (!IsActiveHS(eq,hs)) return 160*256;
+  if (IsSilentHS(eq,hs)) return 160*256;
   for (UInt_t ch=0; ch<5; ch++) {
     UInt_t chip = GetChipFromOffline(module,ch*32);
-    if (!IsActiveChip(eq,hs,chip)) {
+    if (IsSilentChip(eq,hs,chip)) {
       nrSilent+=8192;
     }
     else {
@@ -1550,7 +1598,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNrNoisy(UInt_t module) const {
   return nrNoisy;
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt(UInt_t module, UInt_t index) const {
   // get eq for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1558,7 +1606,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadEqIdAt(UInt_t module, UInt_t in
   return GetDeadEqIdAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt(UInt_t module, UInt_t index) const {
   // get eq for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1566,7 +1614,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAt(UInt_t module, UInt_t i
   return GetNoisyEqIdAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAt(UInt_t module, UInt_t index) const {
   // get hs for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1574,7 +1622,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAt(UInt_t module, UInt_t inde
   return GetDeadHSAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt(UInt_t module, UInt_t index) const {
   // get hs for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1582,7 +1630,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAt(UInt_t module, UInt_t ind
   return GetNoisyHSAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAt(UInt_t module, UInt_t index) const {
   // get chip for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1590,7 +1638,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAt(UInt_t module, UInt_t in
   return GetDeadChipAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt(UInt_t module, UInt_t index) const {
   // get chip for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1598,7 +1646,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAt(UInt_t module, UInt_t i
   return GetNoisyChipAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t module, UInt_t index) const {
   // get hs for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1606,7 +1654,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAt(UInt_t module, UInt_t ind
   return GetDeadColAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t module, UInt_t index) const {
   // get hs for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1614,7 +1662,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAt(UInt_t module, UInt_t in
   return GetNoisyColAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t module, UInt_t index) const {
   // get hs for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1622,7 +1670,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAt(UInt_t module, UInt_t ind
   return GetDeadRowAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t module, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t module, UInt_t index) const {
   // get hs for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1630,17 +1678,32 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAt(UInt_t module, UInt_t in
   return GetNoisyRowAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNrBadEq(UInt_t eq) const {
+  // returns nr of bad for eq (silent or noisy)
+  UInt_t nrBad = 0;
+  nrBad+=GetNrSilentEq(eq);
+  UInt_t nrNoisy = GetNrNoisy(eq);
+  for (UInt_t i=0; i<nrNoisy; i++) {
+    UInt_t hs   = GetNoisyHSAtEq(eq,i);
+    UInt_t chip = GetNoisyChipAtEq(eq,i);
+    UInt_t col  = GetNoisyColAtEq(eq,i);
+    UInt_t row  = GetNoisyRowAtEq(eq,i);
+    if (!IsPixelSilent(eq,hs,chip,col,row)) nrBad++;
+  }
+  return nrBad;
+}
+//____________________________________________________________________________________________
 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilentEq(UInt_t eq) const {
   // returns nr of silent for eq (dead or inactive)
   UInt_t returnval=0;
-  if (!IsActiveEq(eq)) return 81920*6;
+  if (IsSilentEq(eq)) return 81920*6;
   for (UInt_t hs=0; hs<6; hs++) {
-    if (!IsActiveHS(eq,hs)) {
+    if (IsSilentHS(eq,hs)) {
       returnval+=81920;
       continue;
     }
     for (UInt_t chip=0; chip<10; chip++) {
-      if (!IsActiveChip(eq,hs,chip)) {
+      if (IsSilentChip(eq,hs,chip)) {
        returnval+=8192;
        continue;
       }
@@ -1694,7 +1757,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyEqIdAtEq(UInt_t eq, UInt_t ind
   }
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAtEq(UInt_t eq, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAtEq(UInt_t eq, UInt_t index) const {
   // get hs for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1702,7 +1765,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadHSAtEq(UInt_t eq, UInt_t index)
   return GetDeadHSAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAtEq(UInt_t eq, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAtEq(UInt_t eq, UInt_t index) const {
   // get hs for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1710,7 +1773,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyHSAtEq(UInt_t eq, UInt_t index
   return GetNoisyHSAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAtEq(UInt_t eq, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAtEq(UInt_t eq, UInt_t index) const {
   // get chip for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1718,7 +1781,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadChipAtEq(UInt_t eq, UInt_t inde
   return GetDeadChipAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAtEq(UInt_t eq, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAtEq(UInt_t eq, UInt_t index) const {
   // get chip for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1726,7 +1789,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyChipAtEq(UInt_t eq, UInt_t ind
   return GetNoisyChipAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAtEq(UInt_t eq, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAtEq(UInt_t eq, UInt_t index) const {
   // get hs for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1734,7 +1797,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadColAtEq(UInt_t eq, UInt_t index
   return GetDeadColAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAtEq(UInt_t eq, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAtEq(UInt_t eq, UInt_t index) const {
   // get hs for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1742,7 +1805,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyColAtEq(UInt_t eq, UInt_t inde
   return GetNoisyColAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAtEq(UInt_t eq, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAtEq(UInt_t eq, UInt_t index) const {
   // get hs for the dead pixel at position index in list of dead
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1750,7 +1813,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetDeadRowAtEq(UInt_t eq, UInt_t index
   return GetDeadRowAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
-UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAtEq(UInt_t eq, UInt_t index) {
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAtEq(UInt_t eq, UInt_t index) const {
   // get hs for the noisy pixel at position index in list of noisy
   UInt_t gloChip;
   UInt_t chipIndex;
@@ -1758,9 +1821,22 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAtEq(UInt_t eq, UInt_t inde
   return GetNoisyRowAtC2(gloChip,chipIndex);
 }
 //____________________________________________________________________________________________
+UInt_t AliITSOnlineCalibrationSPDhandler::GetNrBadC(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // returns nr of bad for chip (silent or noisy)
+  UInt_t nrBad = 0;
+  nrBad+=GetNrSilentC(eq,hs,chip);
+  UInt_t nrNoisy = GetNrNoisyC(eq,hs,chip);
+  for (UInt_t i=0; i<nrNoisy; i++) {
+    UInt_t col  = GetNoisyColAtC(eq,hs,chip,i);
+    UInt_t row  = GetNoisyRowAtC(eq,hs,chip,i);
+    if (!IsPixelSilent(eq,hs,chip,col,row)) nrBad++;
+  }
+  return nrBad;
+}
+//____________________________________________________________________________________________
 UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilentC(UInt_t eq, UInt_t hs, UInt_t chip) const {
   // returns nr of silent for chip (dead or inactive)
-  if (!(IsActiveEq(eq) && IsActiveHS(eq,hs) && IsActiveChip(eq,hs,chip))) return 8192;
+  if (IsSilentChip(eq,hs,chip)) return 8192;
   else return GetNrDeadC(eq,hs,chip);
 }
 //____________________________________________________________________________________________
@@ -1841,7 +1917,7 @@ const Char_t* AliITSOnlineCalibrationSPDhandler::GetDeadPixelAsTextC(UInt_t eq,
     UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
     UInt_t colM = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,col);
     UInt_t rowM = AliITSRawStreamSPD::GetOfflineRowFromOnline(eq,hs,chip,row);
-    returnMess = Form("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d\n",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
+    returnMess = Form("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
     return returnMess.Data();
   }
   else {
@@ -1865,7 +1941,7 @@ const Char_t* AliITSOnlineCalibrationSPDhandler::GetNoisyPixelAsTextC(UInt_t eq,
     UInt_t module = AliITSRawStreamSPD::GetOfflineModuleFromOnline(eq,hs,chip);
     UInt_t colM = AliITSRawStreamSPD::GetOfflineColFromOnline(eq,hs,chip,col);
     UInt_t rowM = AliITSRawStreamSPD::GetOfflineRowFromOnline(eq,hs,chip,row);
-    returnMess = Form("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d\n",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
+    returnMess = Form("%*d,%*d,%*d,%*d,%*d  |  %*d,%*d,%*d",2,eq,1,hs,1,chip,2,col,3,row,3,module,3,colM,3,rowM);
     return returnMess.Data();
   }
   else {
@@ -1880,10 +1956,13 @@ UInt_t AliITSOnlineCalibrationSPDhandler::AddSilentFrom(AliITSOnlineCalibrationS
 
   for (UInt_t eq=0; eq<20; eq++) {
     if (!(other->IsActiveEq(eq))) ActivateEq(eq,kFALSE);
+    if (other->IsDeadEq(eq))      SetDeadEq(eq,kTRUE);
     for (UInt_t hs=0; hs<6; hs++) {
       if (!(other->IsActiveHS(eq,hs))) ActivateHS(eq,hs,kFALSE);
+      if (other->IsDeadHS(eq,hs))      SetDeadHS(eq,hs,kTRUE);
       for (UInt_t chip=0; chip<10; chip++) {
        if (!(other->IsActiveChip(eq,hs,chip))) ActivateChip(eq,hs,chip,kFALSE);
+       if (other->IsDeadChip(eq,hs,chip))      SetDeadChip(eq,hs,chip,kTRUE);
       }
     }
   }
@@ -1940,8 +2019,8 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNrSilentDiff(AliITSOnlineCalibratio
   for (UInt_t eq=0; eq<20; eq++) {
     for (UInt_t hs=0; hs<6; hs++) {
       for (UInt_t chip=0; chip<10; chip++) {
-       if (!(IsActiveEq(eq) && IsActiveHS(eq,hs) && IsActiveChip(eq,hs,chip))) {
-         if (other->IsActiveEq(eq) && other->IsActiveHS(eq,hs) && other->IsActiveChip(eq,hs,chip)) {
+       if (!IsActiveEq(eq) || IsDeadEq(eq) || !IsActiveHS(eq,hs) || IsDeadHS(eq,hs) || !IsActiveChip(eq,hs,chip) || IsDeadChip(eq,hs,chip)) {
+         if (other->IsActiveEq(eq) && !other->IsDeadEq(eq) && other->IsActiveHS(eq,hs) && !other->IsDeadHS(eq,hs) && other->IsActiveChip(eq,hs,chip) && !other->IsDeadChip(eq,hs,chip)) {
            // if this is inactive and the other is active...
            returnval+= 8192 - other->GetNrDeadC(eq,hs,chip);
          }
@@ -2010,16 +2089,28 @@ AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetDiff(Al
       newHandler->ActivateEq(eq,kFALSE);
       if (!other->IsActiveEq(eq)) newHandler->ActivateEq(eq);
     }
+    if (IsDeadEq(eq)) {
+      newHandler->SetDeadEq(eq);
+      if (other->IsDeadEq(eq)) newHandler->SetDeadEq(eq,kFALSE);
+    }
     for (UInt_t hs=0; hs<6; hs++) {
       if (!(IsActiveHS(eq,hs))) {
        newHandler->ActivateHS(eq,hs,kFALSE);
        if (!other->IsActiveHS(eq,hs)) newHandler->ActivateHS(eq,hs);
       }
+      if (IsDeadHS(eq,hs)) {
+       newHandler->SetDeadHS(eq,hs);
+       if (other->IsDeadHS(eq,hs)) newHandler->SetDeadHS(eq,hs,kFALSE);
+      }
       for (UInt_t chip=0; chip<10; chip++) {
        if (!(IsActiveChip(eq,hs,chip))) {
          newHandler->ActivateChip(eq,hs,chip,kFALSE);
          if (!other->IsActiveChip(eq,hs,chip)) newHandler->ActivateHS(eq,hs,chip);
        }
+       if (IsDeadChip(eq,hs,chip)) {
+         newHandler->SetDeadChip(eq,hs,chip);
+         if (other->IsDeadChip(eq,hs,chip)) newHandler->SetDeadChip(eq,hs,chip,kFALSE);
+       }
       }
     }
   }
@@ -2064,16 +2155,28 @@ AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetSilentD
       newHandler->ActivateEq(eq,kFALSE);
       if (!other->IsActiveEq(eq)) newHandler->ActivateEq(eq);
     }
+    if (IsDeadEq(eq)) {
+      newHandler->SetDeadEq(eq);
+      if (other->IsDeadEq(eq)) newHandler->SetDeadEq(eq,kFALSE);
+    }
     for (UInt_t hs=0; hs<6; hs++) {
       if (!(IsActiveHS(eq,hs))) {
        newHandler->ActivateHS(eq,hs,kFALSE);
        if (!other->IsActiveHS(eq,hs)) newHandler->ActivateHS(eq,hs);
       }
+      if (IsDeadHS(eq,hs)) {
+       newHandler->SetDeadHS(eq,hs);
+       if (other->IsDeadHS(eq,hs)) newHandler->SetDeadHS(eq,hs,kFALSE);
+      }
       for (UInt_t chip=0; chip<10; chip++) {
        if (!(IsActiveChip(eq,hs,chip))) {
          newHandler->ActivateChip(eq,hs,chip,kFALSE);
          if (!other->IsActiveChip(eq,hs,chip)) newHandler->ActivateHS(eq,hs,chip);
        }
+       if (IsDeadChip(eq,hs,chip)) {
+         newHandler->SetDeadChip(eq,hs,chip);
+         if (other->IsDeadChip(eq,hs,chip)) newHandler->SetDeadChip(eq,hs,chip,kFALSE);
+       }
       }
     }
   }
@@ -2133,7 +2236,7 @@ AliITSOnlineCalibrationSPDhandler* AliITSOnlineCalibrationSPDhandler::GetNoisyDi
   return newHandler;
 }
 //____________________________________________________________________________________________
-void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexDead(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
+void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexDead(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const {
   // find gloChip and chipIndex from module and index
   if (index<GetNrDead(module)) {
     UInt_t eq = GetEqIdFromOffline(module);
@@ -2157,7 +2260,7 @@ void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexDead(UInt_t module, UInt_
   }
 }
 //____________________________________________________________________________________________
-void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexNoisy(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
+void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexNoisy(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const {
   // find gloChip and chipIndex from module and index
   if (index<GetNrNoisy(module)) {
     UInt_t eq = GetEqIdFromOffline(module);
@@ -2181,7 +2284,7 @@ void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexNoisy(UInt_t module, UInt
   }
 }
 //____________________________________________________________________________________________
-void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqDead(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
+void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqDead(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const {
   // find gloChip and chipIndex from module and index
   if (index<GetNrDeadEq(eq)) {
 
@@ -2205,7 +2308,7 @@ void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqDead(UInt_t eq, UInt_t
   }
 }
 //____________________________________________________________________________________________
-void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqNoisy(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
+void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqNoisy(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const {
   // find gloChip and chipIndex from module and index
   if (index<GetNrNoisyEq(eq)) {
 
@@ -2229,7 +2332,7 @@ void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexEqNoisy(UInt_t eq, UInt_t
   }
 }
 //____________________________________________________________________________________________
-void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexTotDead(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
+void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexTotDead(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const {
   // find gloChip and chipIndex from global index
   if (index<GetNrDead()) {
     
@@ -2250,7 +2353,7 @@ void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexTotDead(UInt_t index, UIn
   }
 }
 //____________________________________________________________________________________________
-void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexTotNoisy(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) {
+void AliITSOnlineCalibrationSPDhandler::GetChipAndIndexTotNoisy(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const {
   // find gloChip and chipIndex from global index
   if (index<GetNrNoisy()) {
     
@@ -2495,6 +2598,7 @@ UInt_t AliITSOnlineCalibrationSPDhandler::GetNoisyRowAtC2(UInt_t gloChip, UInt_t
 }
 //____________________________________________________________________________________________
 void AliITSOnlineCalibrationSPDhandler::ActivateALL() {
+  // activate all eq,hs,chips
   for (UInt_t eq=0; eq<20; eq++) {
     ActivateEq(eq);
     for (UInt_t hs=0; hs<6; hs++) {
@@ -2507,6 +2611,7 @@ void AliITSOnlineCalibrationSPDhandler::ActivateALL() {
 }
 //____________________________________________________________________________________________
 void AliITSOnlineCalibrationSPDhandler::ActivateEq(UInt_t eq, Bool_t setval) {
+  // activate eq
   if (eq>=20) {
     Error("AliITSOnlineCalibrationSPDhandler::ActivateEq", "eq (%d) out of bounds.",eq);
     return;
@@ -2515,6 +2620,7 @@ void AliITSOnlineCalibrationSPDhandler::ActivateEq(UInt_t eq, Bool_t setval) {
 }
 //____________________________________________________________________________________________
 void AliITSOnlineCalibrationSPDhandler::ActivateHS(UInt_t eq, UInt_t hs, Bool_t setval) {
+  // activate hs
   if (eq>=20 || hs>=6) {
     Error("AliITSOnlineCalibrationSPDhandler::ActivateHS", "eq,hs (%d,%d) out of bounds.",eq,hs);
     return;
@@ -2523,6 +2629,7 @@ void AliITSOnlineCalibrationSPDhandler::ActivateHS(UInt_t eq, UInt_t hs, Bool_t
 }
 //____________________________________________________________________________________________
 void AliITSOnlineCalibrationSPDhandler::ActivateChip(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setval) {
+  // activate chip
   if (eq>=20 || hs>=6 || chip>=10) {
     Error("AliITSOnlineCalibrationSPDhandler::ActivateChip", "eq,hs,chip (%d,%d,%d) out of bounds.",eq,hs,chip);
     return;
@@ -2531,6 +2638,7 @@ void AliITSOnlineCalibrationSPDhandler::ActivateChip(UInt_t eq, UInt_t hs, UInt_
 }
 //____________________________________________________________________________________________
 Bool_t AliITSOnlineCalibrationSPDhandler::IsActiveEq(UInt_t eq) const {
+  // Is eq active?
   if (eq>=20) {
     Error("AliITSOnlineCalibrationSPDhandler::IsActiveEq", "eq (%d) out of bounds.",eq);
     return kFALSE;
@@ -2539,6 +2647,7 @@ Bool_t AliITSOnlineCalibrationSPDhandler::IsActiveEq(UInt_t eq) const {
 }
 //____________________________________________________________________________________________
 Bool_t AliITSOnlineCalibrationSPDhandler::IsActiveHS(UInt_t eq, UInt_t hs) const {
+  // Is hs active?
   if (eq>=20 || hs>=6) {
     Error("AliITSOnlineCalibrationSPDhandler::IsActiveHS", "eq,hs (%d,%d) out of bounds.",eq,hs);
     return kFALSE;
@@ -2547,10 +2656,104 @@ Bool_t AliITSOnlineCalibrationSPDhandler::IsActiveHS(UInt_t eq, UInt_t hs) const
 }
 //____________________________________________________________________________________________
 Bool_t AliITSOnlineCalibrationSPDhandler::IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // Is chip active?
   if (eq>=20 || hs>=6 || chip>=10) {
     Error("AliITSOnlineCalibrationSPDhandler::IsActiveChip", "eq,hs,chip (%d,%d,%d) out of bounds.",eq,hs,chip);
     return kFALSE;
   }
   return fActiveChip[eq][hs][chip];
 }
-
+//____________________________________________________________________________________________
+void AliITSOnlineCalibrationSPDhandler::UnSetDeadALL() {
+  // Clear all dead eq,hs,chips
+  for (UInt_t eq=0; eq<20; eq++) {
+    SetDeadEq(eq,kFALSE);
+    for (UInt_t hs=0; hs<6; hs++) {
+      SetDeadHS(eq,hs,kFALSE);
+      for (UInt_t chip=0; chip<10; chip++) {
+       SetDeadChip(eq,hs,chip,kFALSE);
+      }
+    }
+  }
+}
+//____________________________________________________________________________________________
+void AliITSOnlineCalibrationSPDhandler::SetDeadEq(UInt_t eq, Bool_t setval) {
+  // set eq dead
+  if (eq>=20) {
+    Error("AliITSOnlineCalibrationSPDhandler::SetDeadEq", "eq (%d) out of bounds.",eq);
+    return;
+  }
+  fDeadEq[eq] = setval;
+}
+//____________________________________________________________________________________________
+void AliITSOnlineCalibrationSPDhandler::SetDeadHS(UInt_t eq, UInt_t hs, Bool_t setval) {
+  // set hs dead
+  if (eq>=20 || hs>=6) {
+    Error("AliITSOnlineCalibrationSPDhandler::SetDeadHS", "eq,hs (%d,%d) out of bounds.",eq,hs);
+    return;
+  }
+  fDeadHS[eq][hs] = setval;
+}
+//____________________________________________________________________________________________
+void AliITSOnlineCalibrationSPDhandler::SetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setval) {
+  // set chip dead
+  if (eq>=20 || hs>=6 || chip>=10) {
+    Error("AliITSOnlineCalibrationSPDhandler::SetDeadChip", "eq,hs,chip (%d,%d,%d) out of bounds.",eq,hs,chip);
+    return;
+  }
+  fDeadChip[eq][hs][chip] = setval;
+}
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::IsDeadEq(UInt_t eq) const {
+  // is eq dead?
+  if (eq>=20) {
+    Error("AliITSOnlineCalibrationSPDhandler::IsDeadEq", "eq (%d) out of bounds.",eq);
+    return kFALSE;
+  }
+  return fDeadEq[eq];
+}
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::IsDeadHS(UInt_t eq, UInt_t hs) const {
+  // is hs dead?
+  if (eq>=20 || hs>=6) {
+    Error("AliITSOnlineCalibrationSPDhandler::IsDeadHS", "eq,hs (%d,%d) out of bounds.",eq,hs);
+    return kFALSE;
+  }
+  return fDeadHS[eq][hs];
+}
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::IsDeadChip(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // is chip dead?
+  if (eq>=20 || hs>=6 || chip>=10) {
+    Error("AliITSOnlineCalibrationSPDhandler::IsDeadChip", "eq,hs,chip (%d,%d,%d) out of bounds.",eq,hs,chip);
+    return kFALSE;
+  }
+  return fDeadChip[eq][hs][chip];
+}
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::IsSilentEq(UInt_t eq) const {
+  // is eq silent?
+  if (eq>=20) {
+    Error("AliITSOnlineCalibrationSPDhandler::IsSilentEq", "eq (%d) out of bounds.",eq);
+    return kFALSE;
+  }
+  return (!IsActiveEq(eq) || IsDeadEq(eq));
+}
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::IsSilentHS(UInt_t eq, UInt_t hs) const {
+  // is hs silent?
+  if (eq>=20 || hs>=6) {
+    Error("AliITSOnlineCalibrationSPDhandler::IsSilentHS", "eq,hs (%d,%d) out of bounds.",eq,hs);
+    return kFALSE;
+  }
+  return (!IsActiveEq(eq) || IsDeadEq(eq) || !IsActiveHS(eq,hs) || IsDeadHS(eq,hs));
+}
+//____________________________________________________________________________________________
+Bool_t AliITSOnlineCalibrationSPDhandler::IsSilentChip(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // is chip silent?
+  if (eq>=20 || hs>=6 || chip>=10) {
+    Error("AliITSOnlineCalibrationSPDhandler::IsSilentChip", "eq,hs,chip (%d,%d,%d) out of bounds.",eq,hs,chip);
+    return kFALSE;
+  }
+  return (!IsActiveEq(eq) || IsDeadEq(eq) || !IsActiveHS(eq,hs) || IsDeadHS(eq,hs) || !IsActiveChip(eq,hs,chip) || IsDeadChip(eq,hs,chip));
+}
index 98116b911b876a002d76a8f1f7bf79180b6d36b2..2f4ff171445499da758e988e9a4d974024a0e1aa 100644 (file)
@@ -98,63 +98,67 @@ class AliITSOnlineCalibrationSPDhandler {
   Bool_t  UnSetNoisyPixel(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row);
   Bool_t  UnSetDeadPixelM(UInt_t module, UInt_t colM, UInt_t row);
   Bool_t  UnSetNoisyPixelM(UInt_t module, UInt_t colM, UInt_t row);
-  UInt_t  SetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip);
-  UInt_t  SetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip);
-  Bool_t  UnSetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip);
-  Bool_t  UnSetNoisyChip(UInt_t eq, UInt_t hs, UInt_t chip);
 
+  Bool_t  IsPixelBad(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
   Bool_t  IsPixelSilent(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const; // silent = dead or inactive
   Bool_t  IsPixelDead(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
   Bool_t  IsPixelNoisy(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const;
+  Bool_t  IsPixelBadM(UInt_t module, UInt_t colM, UInt_t row) const;
   Bool_t  IsPixelSilentM(UInt_t module, UInt_t colM, UInt_t row) const;
   Bool_t  IsPixelDeadM(UInt_t module, UInt_t colM, UInt_t row) const;
   Bool_t  IsPixelNoisyM(UInt_t module, UInt_t colM, UInt_t row) const;
+  Bool_t  IsPixelBadKey(Int_t key) const;
   Bool_t  IsPixelSilentKey(Int_t key) const;
   Bool_t  IsPixelDeadKey(Int_t key) const;
   Bool_t  IsPixelNoisyKey(Int_t key) const;
 
+  UInt_t  GetNrBad() const; // bad = silent or noisy
   UInt_t  GetNrSilent() const; // silent = dead or inactive
   UInt_t  GetNrDead() const;
-  UInt_t  GetDeadEqIdAt(UInt_t index);
-  UInt_t  GetDeadHSAt(UInt_t index);
-  UInt_t  GetDeadChipAt(UInt_t index);
-  UInt_t  GetDeadColAt(UInt_t index);
-  UInt_t  GetDeadRowAt(UInt_t index);
+  UInt_t  GetDeadEqIdAt(UInt_t index) const;
+  UInt_t  GetDeadHSAt(UInt_t index) const;
+  UInt_t  GetDeadChipAt(UInt_t index) const;
+  UInt_t  GetDeadColAt(UInt_t index) const;
+  UInt_t  GetDeadRowAt(UInt_t index) const;
   UInt_t  GetNrNoisy() const;
-  UInt_t  GetNoisyEqIdAt(UInt_t index);
-  UInt_t  GetNoisyHSAt(UInt_t index);
-  UInt_t  GetNoisyChipAt(UInt_t index);
-  UInt_t  GetNoisyColAt(UInt_t index);
-  UInt_t  GetNoisyRowAt(UInt_t index);
+  UInt_t  GetNoisyEqIdAt(UInt_t index) const;
+  UInt_t  GetNoisyHSAt(UInt_t index) const;
+  UInt_t  GetNoisyChipAt(UInt_t index) const;
+  UInt_t  GetNoisyColAt(UInt_t index) const;
+  UInt_t  GetNoisyRowAt(UInt_t index) const;
 
+
+  UInt_t  GetNrBad(UInt_t module) const; // bad = silent or noisy
   UInt_t  GetNrSilent(UInt_t module) const; // silent = dead or inactive
   UInt_t  GetNrDead(UInt_t module) const;
-  UInt_t  GetDeadEqIdAt(UInt_t module,UInt_t index);
-  UInt_t  GetDeadHSAt(UInt_t module,UInt_t index);
-  UInt_t  GetDeadChipAt(UInt_t module,UInt_t index);
-  UInt_t  GetDeadColAt(UInt_t module,UInt_t index);
-  UInt_t  GetDeadRowAt(UInt_t module,UInt_t index);
+  UInt_t  GetDeadEqIdAt(UInt_t module,UInt_t index) const;
+  UInt_t  GetDeadHSAt(UInt_t module,UInt_t index) const;
+  UInt_t  GetDeadChipAt(UInt_t module,UInt_t index) const;
+  UInt_t  GetDeadColAt(UInt_t module,UInt_t index) const;
+  UInt_t  GetDeadRowAt(UInt_t module,UInt_t index) const;
   UInt_t  GetNrNoisy(UInt_t module) const;
-  UInt_t  GetNoisyEqIdAt(UInt_t module, UInt_t index);
-  UInt_t  GetNoisyHSAt(UInt_t module, UInt_t index);
-  UInt_t  GetNoisyChipAt(UInt_t module, UInt_t index);
-  UInt_t  GetNoisyColAt(UInt_t module, UInt_t index);
-  UInt_t  GetNoisyRowAt(UInt_t module, UInt_t index);
+  UInt_t  GetNoisyEqIdAt(UInt_t module, UInt_t index) const;
+  UInt_t  GetNoisyHSAt(UInt_t module, UInt_t index) const;
+  UInt_t  GetNoisyChipAt(UInt_t module, UInt_t index) const;
+  UInt_t  GetNoisyColAt(UInt_t module, UInt_t index) const;
+  UInt_t  GetNoisyRowAt(UInt_t module, UInt_t index) const;
 
+  UInt_t  GetNrBadEq(UInt_t eq) const; // bad = silent or noisy
   UInt_t  GetNrSilentEq(UInt_t eq) const; // silent = dead or inactive
   UInt_t  GetNrDeadEq(UInt_t eq) const;
   UInt_t  GetDeadEqIdAtEq(UInt_t eq, UInt_t index) const;
-  UInt_t  GetDeadHSAtEq(UInt_t eq, UInt_t index);
-  UInt_t  GetDeadChipAtEq(UInt_t eq, UInt_t index);
-  UInt_t  GetDeadColAtEq(UInt_t eq, UInt_t index);
-  UInt_t  GetDeadRowAtEq(UInt_t eq, UInt_t index);
+  UInt_t  GetDeadHSAtEq(UInt_t eq, UInt_t index) const;
+  UInt_t  GetDeadChipAtEq(UInt_t eq, UInt_t index) const;
+  UInt_t  GetDeadColAtEq(UInt_t eq, UInt_t index) const;
+  UInt_t  GetDeadRowAtEq(UInt_t eq, UInt_t index) const;
   UInt_t  GetNrNoisyEq(UInt_t eq) const;
   UInt_t  GetNoisyEqIdAtEq(UInt_t eq, UInt_t index) const;
-  UInt_t  GetNoisyHSAtEq(UInt_t eq, UInt_t index);
-  UInt_t  GetNoisyChipAtEq(UInt_t eq, UInt_t index);
-  UInt_t  GetNoisyColAtEq(UInt_t eq, UInt_t index);
-  UInt_t  GetNoisyRowAtEq(UInt_t eq, UInt_t index);
+  UInt_t  GetNoisyHSAtEq(UInt_t eq, UInt_t index) const;
+  UInt_t  GetNoisyChipAtEq(UInt_t eq, UInt_t index) const;
+  UInt_t  GetNoisyColAtEq(UInt_t eq, UInt_t index) const;
+  UInt_t  GetNoisyRowAtEq(UInt_t eq, UInt_t index) const;
 
+  UInt_t  GetNrBadC(UInt_t eq, UInt_t hs, UInt_t chip) const; // bad = silent or noisy
   UInt_t  GetNrSilentC(UInt_t eq, UInt_t hs, UInt_t chip) const; // silent = dead or inactive
   UInt_t  GetNrDeadC(UInt_t eq, UInt_t hs, UInt_t chip) const;
   UInt_t  GetDeadEqIdAtC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
@@ -172,14 +176,27 @@ class AliITSOnlineCalibrationSPDhandler {
   const Char_t* GetDeadPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
   const Char_t* GetNoisyPixelAsTextC(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t index) const;
 
-  void   ActivateALL();
-  void   ActivateEq(UInt_t eq, Bool_t setval = kTRUE);
-  void   ActivateHS(UInt_t eq, UInt_t hs, Bool_t setval = kTRUE);
-  void   ActivateChip(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setval = kTRUE);
+  void    ActivateALL();
+  void    ActivateEq(UInt_t eq, Bool_t setval = kTRUE);
+  void    ActivateHS(UInt_t eq, UInt_t hs, Bool_t setval = kTRUE);
+  void    ActivateChip(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setval = kTRUE);
+
+  void    UnSetDeadALL();
+  void    SetDeadEq(UInt_t eq, Bool_t setval = kTRUE);
+  void    SetDeadHS(UInt_t eq, UInt_t hs, Bool_t setval = kTRUE);
+  void    SetDeadChip(UInt_t eq, UInt_t hs, UInt_t chip, Bool_t setval = kTRUE);
+
+  Bool_t  IsActiveEq(UInt_t eq) const;
+  Bool_t  IsActiveHS(UInt_t eq, UInt_t hs) const;
+  Bool_t  IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
+
+  Bool_t  IsDeadEq(UInt_t eq) const;
+  Bool_t  IsDeadHS(UInt_t eq, UInt_t hs) const;
+  Bool_t  IsDeadChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
 
-  Bool_t IsActiveEq(UInt_t eq) const;
-  Bool_t IsActiveHS(UInt_t eq, UInt_t hs) const;
-  Bool_t IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
+  Bool_t  IsSilentEq(UInt_t eq) const;
+  Bool_t  IsSilentHS(UInt_t eq, UInt_t hs) const;
+  Bool_t  IsSilentChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
 
 
   UInt_t  AddSilentFrom(AliITSOnlineCalibrationSPDhandler* other);
@@ -205,6 +222,9 @@ class AliITSOnlineCalibrationSPDhandler {
   Bool_t fActiveEq[20];               // active bit for each equipment
   Bool_t fActiveHS[20][6];            // active bit for each half-stave
   Bool_t fActiveChip[20][6][10];      // active bit for each chip
+  Bool_t fDeadEq[20];                 // dead bit for each equipment
+  Bool_t fDeadHS[20][6];              // dead bit for each half-stave
+  Bool_t fDeadChip[20][6][10];        // dead bit for each chip
 
   Int_t    GetKey(UInt_t eq, UInt_t hs, UInt_t chip, UInt_t col, UInt_t row) const 
     {return eq*6*10*32*256 + hs*10*32*256 + chip*32*256 + col*256 + row;}
@@ -230,12 +250,12 @@ class AliITSOnlineCalibrationSPDhandler {
   UInt_t   GetHSGlo(UInt_t gloChip) const {return (gloChip%60)/10;}
   UInt_t   GetChipGlo(UInt_t gloChip) const {return (gloChip%60)%10;}
 
-  void     GetChipAndIndexDead(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
-  void     GetChipAndIndexNoisy(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
-  void     GetChipAndIndexEqDead(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
-  void     GetChipAndIndexEqNoisy(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
-  void     GetChipAndIndexTotDead(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
-  void     GetChipAndIndexTotNoisy(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex);
+  void     GetChipAndIndexDead(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
+  void     GetChipAndIndexNoisy(UInt_t module, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
+  void     GetChipAndIndexEqDead(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
+  void     GetChipAndIndexEqNoisy(UInt_t eq, UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
+  void     GetChipAndIndexTotDead(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
+  void     GetChipAndIndexTotNoisy(UInt_t index, UInt_t& gloChip, UInt_t& chipIndex) const;
 
   UInt_t   GetEqIdFromOffline(UInt_t module) const;
   UInt_t   GetHSFromOffline(UInt_t module) const;
index a1dcd98df427c20aa6b8ec5124740b648f0ce478..c4ced31a45af8ff2861cd8aa9e1a16d32a35e191 100644 (file)
@@ -313,20 +313,17 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() {
   fNrEqHits = 0;
 
 
-  AliITSOnlineCalibrationSPDhandler *deadPixelHandler = new AliITSOnlineCalibrationSPDhandler();
-
   for (UInt_t hs=0; hs<6; hs++) {
-    if (!(fHandler->IsActiveHS(GetEqNr(),hs))) {
+    if (!fHandler->IsActiveHS(GetEqNr(),hs)) {
       fNrDeadChips+=10;
     }
     else {
       for (UInt_t chip=0; chip<10; chip++) {
-       if (!(fHandler->IsActiveChip(GetEqNr(),hs,chip))) {
+       if (!fHandler->IsActiveChip(GetEqNr(),hs,chip)) {
          fNrDeadChips++;
        }
        else {
          // perform search for individual dead pixels...
-         deadPixelHandler->ResetDead();
          Bool_t good=kFALSE;
 
          UInt_t nrPossiblyDeadPixels = 0;
@@ -341,7 +338,9 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() {
                nrPixels++;
                if (nrHits==0) {
                  nrPossiblyDeadPixels++;
-                 deadPixelHandler->SetDeadPixel(GetEqNr(),hs,chip,col,row);
+               }
+               else {
+                 fHandler->UnSetDeadPixel(GetEqNr(),hs,chip,col,row); // unset (no action unless dead before)
                }
              }
              else {
@@ -351,24 +350,10 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() {
          }
          fNrEqHits+=nrChipHits;
 
-         // check all pixels that were declared dead from before...
-         UInt_t nrDeadBefore = fHandler->GetNrDeadC(GetEqNr(),hs,chip);
-         AliITSOnlineCalibrationSPDhandler *tmpHand = new AliITSOnlineCalibrationSPDhandler();
-         for (UInt_t index=0; index<nrDeadBefore; index++) {
-           UInt_t col = fHandler->GetDeadColAtC(GetEqNr(),hs,chip,index);
-           UInt_t row = fHandler->GetDeadRowAtC(GetEqNr(),hs,chip,index);
-           if (fPhysObj->GetHits(hs,chip,col,row)>0) {
-             //            fHandler->UnSetDeadPixel(GetEqNr(),hs,chip,col,row); // This was a bug - cannot delete while moving through indices, use tmpHand instead
-             tmpHand->SetDeadPixel(GetEqNr(),hs,chip,col,row);
-           }
+         if (nrChipHits>0) {
+           // make sure the chip is not flagged as dead
+           fHandler->SetDeadChip(GetEqNr(),hs,chip,kFALSE);
          }
-         UInt_t nrToRemove = tmpHand->GetNrDead();
-         for (UInt_t index=0; index<nrToRemove; index++) {
-           fHandler->UnSetDeadPixel(GetEqNr(),hs,chip,tmpHand->GetDeadColAtC(GetEqNr(),hs,chip,index),tmpHand->GetDeadRowAtC(GetEqNr(),hs,chip,index));
-         }
-         delete tmpHand;
-
-
 
          if (nrPossiblyDeadPixels==0) {
            // no need to see if we have enough statistics...
@@ -381,7 +366,6 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() {
 
          if (nrChipHits==0) {
            nrPossiblyDeadChips++;
-           //!!!           deadChipHandler->SetDeadChip(GetEqNr(),hs,chip);
            possiblyDead->Insert(hs,chip);
            good=kFALSE;
            //  printf("%3d",good);
@@ -406,7 +390,18 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() {
                fNrEnoughStatChips++;
                good=kTRUE;
                // add dead pixels to handler
-               fHandler->AddDeadFrom(deadPixelHandler);
+               for (UInt_t col=0; col<32; col++) {
+                 for (UInt_t row=0; row<256; row++) {
+                   UInt_t nrHits = fPhysObj->GetHits(hs,chip,col,row);
+                   if (!fHandler->IsPixelNoisy(GetEqNr(),hs,chip,col,row)) {
+                     // don't include noisy pixels
+                     nrPixels++;
+                     if (nrHits==0) {
+                       fHandler->SetDeadPixel(GetEqNr(),hs,chip,col,row);
+                     }
+                   }
+                 }
+               }
                break;
              }
            }
@@ -432,13 +427,13 @@ UInt_t AliITSOnlineSPDphysAnalyzer::ProcessDeadPixels() {
     }
   } // for hs
  
-  delete deadPixelHandler;
 
   Int_t key,val;
+
   // dead chips?
   if (fNrEqHits>fMinNrEqHitsForDeadChips) {
     while (possiblyDead->Pop(key,val)) {
-      fHandler->ActivateChip(GetEqNr(),key,val,kFALSE);
+      fHandler->SetDeadChip(GetEqNr(),key,val,kFALSE);
     }
     fNrDeadChips+=nrPossiblyDeadChips;
   }
index 3f23fdaacb2355f912ce39fce0e1dda3666fd2a5..8067e0c0e0b0f60d07f32f8eea013b274ab7c419 100644 (file)
@@ -259,7 +259,7 @@ UInt_t AliITSPreprocessorSPD::Process(TMap* /*dcsAliasMap*/)
     handler->SetFileLocation(fileLoc.Data());
     handler->ReadNoisyFromFiles();
     for (Int_t module=0; module<240; module++) {
-      ((AliITSCalibrationSPD*) spdEntryNoisy->At(module)) -> SetNrBad( handler->GetNrNoisy(module) );
+      ((AliITSCalibrationSPD*) spdEntryNoisy->At(module)) -> SetNrBadSingle( handler->GetNrNoisy(module) );
       ((AliITSCalibrationSPD*) spdEntryNoisy->At(module)) -> SetBadList( handler->GetNoisyArray(module) );
     }
     delete handler;
@@ -378,9 +378,20 @@ UInt_t AliITSPreprocessorSPD::Process(TMap* /*dcsAliasMap*/)
     // Add dead from the copied FXS files
     handOld->SetFileLocation(".");
     handOld->ReadSilentFromFiles();
-    for (Int_t module=0; module<240; module++) {
-      ((AliITSCalibrationSPD*) spdEntryDead->At(module)) -> SetNrBad( handOld->GetNrSilent(module) );
-      ((AliITSCalibrationSPD*) spdEntryDead->At(module)) -> SetBadList( handOld->GetSilentArray(module) );
+    for (UInt_t module=0; module<240; module++) {
+      AliITSCalibrationSPD* calibSPD = (AliITSCalibrationSPD*) spdEntryDead->At(module);
+      calibSPD->SetNrBad( handOld->GetNrDead(module) );
+      calibSPD->SetBadList( handOld->GetDeadArray(module) );
+      for (UInt_t chipIndex=0; chipIndex<5; chipIndex++) {
+       UInt_t eq,hs,chip,col,row;
+       AliITSRawStreamSPD::OfflineToOnline(module, chipIndex*32, 0, eq, hs, chip, col, row);
+       if (handOld->IsSilentChip(eq,hs,chip)) {
+         calibSPD->SetChipBad(chipIndex);
+       }
+       else {
+         calibSPD->UnSetChipBad(chipIndex);
+       }
+      }
     }
     delete handOld;
     // Store the new calibration objects in OCDB
index c9067a01f62587eaf70e677f828119923a99e18e..549dda004a43505c5f1994236cd444a18f138979 100644 (file)
@@ -70,6 +70,13 @@ AliITSRawStreamSPD::AliITSRawStreamSPD(AliRawReader* rawReader) :
   }
   for (UInt_t eq=0; eq<20; eq++) {
     fActiveEq[eq]=kFALSE;
+    for (UInt_t hs=0; hs<6; hs++) {
+      fActiveHS[eq][hs]=kFALSE;
+      for (UInt_t chip=0; chip<10; chip++) {
+       fActiveChip[eq][hs][chip]=kFALSE;
+       fEventCounterFull[eq][hs][chip] = -1;
+      }
+    }
   }
   NewEvent();
 }
@@ -171,7 +178,7 @@ Int_t AliITSRawStreamSPD::ReadCalibHeader() {
   fFillOutOfSynch = kFALSE;
 
   // set eq active and the participating half-staves (for access from outside this class), 
-  // set what number of chip headers/trailers to expect
+  // set what number of chip headers/trailers to expect (for the moment not used)
   fActiveEq[ddlID]=kTRUE;
   fExpectedHeaderTrailerCount = 0;
   for (UInt_t hs=0; hs<6; hs++) {
@@ -290,6 +297,8 @@ Bool_t AliITSRawStreamSPD::Next() {
        if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHSNumberErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data());
        fHalfStaveNr=0;
       }
+      fActiveChip[fDDLID][fHalfStaveNr][fChipAddr]=kTRUE;
+      fEventCounterFull[fDDLID][fHalfStaveNr][fChipAddr] = eventCounter;
       // translate  ("online") ddl, hs, chip nr  to  ("offline") module id :
       fModuleID = GetOfflineModuleFromOnline(fDDLID,fHalfStaveNr,fChipAddr);
     } 
@@ -367,14 +376,14 @@ void AliITSRawStreamSPD::CheckHeaderAndTrailerCount(Int_t ddlID) {
                           fEqPLChipHeadersRead,fExpectedHeaderTrailerCount,ddlID);
     AliError(errMess.Data());
     fRawReader->AddMajorErrorLog(kHeaderCountErr,errMess.Data());
-    if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHeaderCountErr,ddlID,-1,-1,errMess.Data());
+    if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHeaderCountErr,ddlID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data());
   }
   if (fEqPLChipTrailersRead != fExpectedHeaderTrailerCount) {
     TString errMess = Form("Chip trailer count inconsistent %d != %d (expected) for ddl %d",
                           fEqPLChipTrailersRead,fExpectedHeaderTrailerCount,ddlID);
     AliError(errMess.Data());
     fRawReader->AddMajorErrorLog(kHeaderCountErr,errMess.Data());
-    if (fAdvancedErrorLog) fAdvLogger->ProcessError(kTrailerCountErr,ddlID,-1,-1,errMess.Data());
+    if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHeaderCountErr,ddlID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data());
   }
 }
 //__________________________________________________________________________
@@ -412,6 +421,36 @@ const Char_t* AliITSRawStreamSPD::GetErrorName(UInt_t errorCode) {
   else return "";
 }
 //__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::IsActiveEq(UInt_t eq) const {
+  // returns if the eq is active (seen in data)
+  if (eq>=20) {
+    TString errMess = Form("eq = %d out of bounds. Return kFALSE.",eq);
+    AliError(errMess.Data());
+    return kFALSE;
+  }
+  return fActiveEq[eq];
+}
+//__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::IsActiveHS(UInt_t eq, UInt_t hs) const {
+  // returns if the hs is active (info from block attr)
+  if (eq>=20 || hs>=6) {
+    TString errMess = Form("eq,hs = %d,%d out of bounds. Return kFALSE.",eq,hs);
+    AliError(errMess.Data());
+    return kFALSE;
+  }
+  return fActiveHS[eq][hs];
+}
+//__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // returns if the chip is active (seen in data)
+  if (eq>=20 || hs>=6 || chip>=10) {
+    TString errMess = Form("eq,hs,chip = %d,%d,%d out of bounds. Return kFALSE.",eq,hs,chip);
+    AliError(errMess.Data());
+    return kFALSE;
+  }
+  return fActiveChip[eq][hs][chip];
+}
+//__________________________________________________________________________
 Bool_t AliITSRawStreamSPD::GetHalfStavePresent(UInt_t hs) {
   // Reads the half stave present status from the block attributes
   // This is not really needed anymore (kept for now in case it is still used somewhere).
@@ -436,6 +475,83 @@ Bool_t AliITSRawStreamSPD::GetHalfStavePresent(UInt_t hs) {
   }
 }
 //__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::IsEventCounterFullConsistent() const {
+  // checks if the event counter values are consistent within the event
+  Short_t reference = -1;
+  for (UInt_t eq=0; eq<20; eq++) {
+    if (IsActiveEq(eq)) {
+      for (UInt_t hs=0; hs<6; hs++) {
+       if (IsActiveHS(eq,hs)) {
+         for (UInt_t chip=0; chip<10; chip++) {
+           if (fEventCounterFull[eq][hs][chip]!=-1) {
+             if (reference==-1) reference = fEventCounterFull[eq][hs][chip];
+             if (fEventCounterFull[eq][hs][chip] != reference) return kFALSE;
+           }
+         }
+       }
+      }
+    }
+  }
+  return kTRUE;
+}
+//__________________________________________________________________________
+Short_t AliITSRawStreamSPD::GetEventCounterFullEq(UInt_t eq) const {
+  // if the eq is active; returns the event counter value
+  if (eq>=20) {
+    TString errMess = Form("eq (%d) out of bounds",eq);
+    AliError(errMess.Data());
+    return -1;
+  }
+  if (IsActiveEq(eq)) {
+    for (UInt_t hs=0; hs<6; hs++) {
+      if (IsActiveHS(eq,hs)) {
+       for (UInt_t chip=0; chip<10; chip++) {
+         if (fEventCounterFull[eq][hs][chip]!=-1) {
+           return fEventCounterFull[eq][hs][chip];
+         }
+       }
+      }
+    }
+  }
+  return -1;
+}
+//__________________________________________________________________________
+Short_t AliITSRawStreamSPD::GetEventCounterFullHS(UInt_t eq, UInt_t hs) const {
+  // if the eq,hs is active; returns the event counter value
+  if (eq>=20 || hs>=6) {
+    TString errMess = Form("eq,hs (%d,%d) out of bounds",eq,hs);
+    AliError(errMess.Data());
+    return -1;
+  }
+  if (IsActiveEq(eq)) {
+    if (IsActiveHS(eq,hs)) {
+      for (UInt_t chip=0; chip<10; chip++) {
+       if (fEventCounterFull[eq][hs][chip]!=-1) {
+         return fEventCounterFull[eq][hs][chip];
+       }
+      }
+    }
+  }
+  return -1;
+}
+//__________________________________________________________________________
+Short_t AliITSRawStreamSPD::GetEventCounterFullChip(UInt_t eq, UInt_t hs, UInt_t chip) const {
+  // if the eq,hs,chip is active; returns the event counter value
+  if (eq>=20 || hs>=6 || chip>=10) {
+    TString errMess = Form("eq,hs,chip (%d,%d,%d) out of bounds",eq,hs,chip);
+    AliError(errMess.Data());
+    return -1;
+  }
+  if (IsActiveEq(eq)) {
+    if (IsActiveHS(eq,hs)) {
+      if (IsActiveChip(eq,hs,chip)) {
+       return fEventCounterFull[eq][hs][chip];
+      }
+    }
+  }
+  return -1;
+}
+//__________________________________________________________________________
 Bool_t AliITSRawStreamSPD::GetHhalfStaveScanned(UInt_t hs) const {
   if (hs<6) return (Bool_t)((fCalHeadWord[0]>>(6+hs)) & (0x00000001));
   else return kFALSE;
index 52b8f93a851b4f82d58094eb99ebe791a7a8c3e4..ac5165588dcd62d0d2e11e517a41e9efb54ad822 100644 (file)
@@ -54,10 +54,15 @@ class AliITSRawStreamSPD: public AliITSRawStream {
     static UInt_t GetOfflineColFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col);
     static UInt_t GetOfflineRowFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t row);
 
-    Int_t  GetEventCounter() {return fEventCounter;}
+    Int_t   GetEventCounter() const {return fEventCounter;}    // get last read event counter value
+    Short_t GetEventCounterFullEq(UInt_t eq) const;
+    Short_t GetEventCounterFullHS(UInt_t eq, UInt_t hs) const;
+    Short_t GetEventCounterFullChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
+    Bool_t  IsEventCounterFullConsistent() const;
 
-    Bool_t IsActiveEq(UInt_t eq) const {return fActiveEq[eq];}
-    Bool_t IsActiveHS(UInt_t eq, UInt_t hs) const {return fActiveHS[eq][hs];}
+    Bool_t IsActiveEq(UInt_t eq) const;
+    Bool_t IsActiveHS(UInt_t eq, UInt_t hs) const;
+    Bool_t IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const;
 
     Bool_t GetHalfStavePresent(UInt_t hs);
 
@@ -116,6 +121,8 @@ class AliITSRawStreamSPD: public AliITSRawStream {
     void       CheckHeaderAndTrailerCount(Int_t ddlID);
 
     Int_t       fEventCounter;                // chip event counter
+    Short_t     fEventCounterFull[20][6][10]; // chip event counter
+
     UShort_t    fChipAddr;                    // chip nr
     UShort_t    fHalfStaveNr;                 // half stave nr
     UInt_t      fCol;                         // chip column nr
@@ -144,6 +151,7 @@ class AliITSRawStreamSPD: public AliITSRawStream {
 
     Bool_t      fActiveEq[20];               // which equipments are active (found in data)
     Bool_t      fActiveHS[20][6];            // which half-staves are active (blockattribute bits)
+    Bool_t      fActiveChip[20][6][10];      // which chips are active (found in data)
 
     ClassDef(AliITSRawStreamSPD, 0) // class for reading ITS SPD raw digits
 };
index 773d2956292e5c46788d60b43b9e45aed26c5b3e..11c903e608edde3cd22eda7ec942079a6a839ac0 100644 (file)
@@ -22,7 +22,6 @@ AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog() :
   for (UInt_t eq=0; eq<20; eq++) {
     fTextTmp[eq] = new TGText();
     fNEvents[eq] = 0;
-    fPayloadSizeSet[eq] = kFALSE;
     fByteOffset[eq] = 0;
     fSuppressEq[eq] = kFALSE;
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
@@ -45,8 +44,6 @@ AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog(const AliITSRawStreamSPDE
       fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
     }
     fNEvents[eq] = logger.fNEvents[eq];
-    fPayloadSize[eq] = logger.fPayloadSize[eq];
-    fPayloadSizeSet[eq] = logger.fPayloadSizeSet[eq];
     fByteOffset[eq] = logger.fByteOffset[eq];
     fSuppressEq[eq] = logger.fSuppressEq[eq];
   }
@@ -63,7 +60,7 @@ AliITSRawStreamSPDErrorLog::AliITSRawStreamSPDErrorLog(const AliITSRawStreamSPDE
   for (UInt_t eq=0; eq<20; eq++) {
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]);
-      fConsErrPos[err][eq] = new TH1F(*logger.fConsErrPos[err][eq]);
+      fConsErrPos[err][eq] = new TGraph(*logger.fConsErrPos[err][eq]);
     }
     fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
     fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
@@ -85,8 +82,6 @@ AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRa
        fErrEventCounter[err][eq] = logger.fErrEventCounter[err][eq];
       }
       fNEvents[eq] = logger.fNEvents[eq];
-      fPayloadSize[eq] = logger.fPayloadSize[eq];
-      fPayloadSizeSet[eq] = logger.fPayloadSizeSet[eq];
       fByteOffset[eq] = logger.fByteOffset[eq];
       fSuppressEq[eq] = logger.fSuppressEq[eq];
     }
@@ -103,7 +98,7 @@ AliITSRawStreamSPDErrorLog& AliITSRawStreamSPDErrorLog::operator=(const AliITSRa
     for (UInt_t eq=0; eq<20; eq++) {
       for (UInt_t err=0; err<kNrErrorCodes; err++) {
        fConsErrEvent[err][eq] = new TGraph(*logger.fConsErrEvent[err][eq]);
-       fConsErrPos[err][eq] = new TH1F(*logger.fConsErrPos[err][eq]);
+       fConsErrPos[err][eq] = new TGraph(*logger.fConsErrPos[err][eq]);
       }
       fConsErrType[eq] = new TH1F(*logger.fConsErrType[eq]);
       fConsErrFraction[eq] = new TH1F(*logger.fConsErrFraction[eq]);
@@ -140,12 +135,11 @@ void AliITSRawStreamSPDErrorLog::InitHistograms() {
     
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       fConsErrEvent[err][eq]=new TGraph();
+      fConsErrPos[err][eq]=new TGraph();
+      fConsErrPosTMP[err][eq]=new TGraph();
       fErrEventCounter[err][eq] = 0;
-      histName = Form("ConsErrPos %d %d",err,eq);
-      histTitle = Form("Position in event, eq %d , error code %d",eq,err);
-      fConsErrPos[err][eq]=new TH1F(histName.Data(),histTitle.Data(),200,0,100);
-      fConsErrPos[err][eq]->SetXTitle("Position [%]");
-      fConsErrPos[err][eq]->SetYTitle("Nr Errors");
+      fErrPosCounter[err][eq] = 0;
+      fErrPosTMPCounter[err][eq] = 0;
     }
   }
 }
@@ -158,6 +152,7 @@ void AliITSRawStreamSPDErrorLog::DeleteHistograms() const {
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       delete fConsErrEvent[err][eq];
       delete fConsErrPos[err][eq];
+      delete fConsErrPosTMP[err][eq];
     }
   }
 }
@@ -170,13 +165,17 @@ void AliITSRawStreamSPDErrorLog::Reset() {
     fConsErrType[eq]->Reset();
     fConsErrFraction[eq]->Reset();
     fNEvents[eq] = 0;
-    fPayloadSizeSet[eq] = kFALSE;
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       fNErrors[err][eq] = 0;
       delete fConsErrEvent[err][eq];
+      delete fConsErrPos[err][eq];
+      delete fConsErrPosTMP[err][eq];
       fErrEventCounter[err][eq] = 0;
+      fErrPosCounter[err][eq] = 0;
+      fErrPosTMPCounter[err][eq] = 0;
       fConsErrEvent[err][eq] = new TGraph();
-      fConsErrPos[err][eq]->Reset();
+      fConsErrPos[err][eq] = new TGraph();
+      fConsErrPosTMP[err][eq] = new TGraph();
     }
   }
 }
@@ -192,9 +191,13 @@ void AliITSRawStreamSPDErrorLog::ProcessError(UInt_t errorCode, UInt_t eq, Int_t
     fNErrors[errorCode][eq]++;
     if (errorCode!=kTotal) fNErrors[kTotal][eq]++;
 
-    if (fPayloadSizeSet[eq]) {
-      fConsErrPos[errorCode][eq]->Fill(100.*bytesRead/fPayloadSize[eq]);
-      if (errorCode!=kTotal) fConsErrPos[kTotal][eq]->Fill(100.*bytesRead/fPayloadSize[eq]);
+    if (bytesRead>=0) {
+      fConsErrPosTMP[errorCode][eq]->SetPoint(fErrPosTMPCounter[errorCode][eq],0,bytesRead+fByteOffset[eq]);
+      fErrPosTMPCounter[errorCode][eq]++;
+      if (errorCode!=kTotal) {
+       fConsErrPosTMP[kTotal][eq]->SetPoint(fErrPosTMPCounter[kTotal][eq],0,bytesRead+fByteOffset[eq]);
+       fErrPosTMPCounter[kTotal][eq]++;
+      }
     }
 
     TString msg;
@@ -235,7 +238,14 @@ void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) {
        fErrEventCounter[err][eq]++;
        fConsErrFraction[eq]->Fill(err);
       }
+      for (UInt_t pind=0; pind<fErrPosTMPCounter[err][eq]; pind++) {
+       Double_t x,y;
+       fConsErrPosTMP[err][eq]->GetPoint(pind,x,y);
+       fConsErrPos[err][eq]->SetPoint(fErrPosCounter[err][eq],eventNum,y);
+       fErrPosCounter[err][eq]++;
+      }
     }
+
     fNEvents[eq]++;
     if (fNErrors[kTotal][eq]>0) {
       msg = Form("*** Event %d , Eq %d: ***",eventNum,eq);
@@ -243,23 +253,19 @@ void AliITSRawStreamSPDErrorLog::SummarizeEvent(UInt_t eventNum) {
       fText->AddText(fTextTmp[eq]);
       fText->InsLine(fText->RowCount()," ");
     }
-    fPayloadSizeSet[eq]=kFALSE;
     fByteOffset[eq]=0;
     fTextTmp[eq]->Clear();
     for (UInt_t err=0; err<kNrErrorCodes; err++) {
       fNErrors[err][eq]=0;
     }
   }
-}
-//________________________________________________________________________________________________
-void AliITSRawStreamSPDErrorLog::SetPayloadSize(UInt_t eq, UInt_t size) {
-  // set the payload size for this event
-  if (eq<20) {
-    fPayloadSize[eq]=size;
-    fPayloadSizeSet[eq]=kTRUE;
-  }
-  else {
-    AliWarning(Form("Equipment number (%d) out of range",eq));
+
+  for (UInt_t eq=0; eq<20; eq++) {
+    for (UInt_t err=0; err<kNrErrorCodes; err++) {
+      delete fConsErrPosTMP[err][eq];
+      fErrPosTMPCounter[err][eq] = 0;
+      fConsErrPosTMP[err][eq] = new TGraph();
+    }
   }
 }
 //________________________________________________________________________________________________
@@ -385,7 +391,7 @@ TH1F* AliITSRawStreamSPDErrorLog::GetConsErrFractionUnScaled(UInt_t eq) {
   }
 }
 //________________________________________________________________________________________________
-TH1F* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) {
+TGraph* AliITSRawStreamSPDErrorLog::GetConsErrPos(UInt_t errorCode, UInt_t eq) {
   // returns a pointer to the histogram
   if (errorCode<kNrErrorCodes && eq<20) return fConsErrPos[errorCode][eq];
   else {
index 55e17c37d00682d4dffe0942eb6bb0196e88d923..cb35480b5542a7d5dea2b52570a6c81099df4d89 100644 (file)
@@ -37,7 +37,6 @@ class AliITSRawStreamSPDErrorLog : public TObject {
   UInt_t  GetNrErrorsTotal(UInt_t errorCode, UInt_t eq);
   UInt_t  GetNrErrorsTotalAllEq(UInt_t errorCode);
 
-  void    SetPayloadSize(UInt_t eq, UInt_t size);
   void    SetByteOffset(UInt_t eq, Int_t size);
   void    SuppressErrorMessages(UInt_t errorCode, Bool_t suppr = kTRUE);
   void    SuppressErrorEq(UInt_t eq, Bool_t suppr = kTRUE);
@@ -45,27 +44,28 @@ class AliITSRawStreamSPDErrorLog : public TObject {
   static  UInt_t GetNrErrorCodes(){return kNrErrorCodes;}
 
   TGraph* GetConsErrEvent(UInt_t errorCode, UInt_t eq);
+  TGraph* GetConsErrPos(UInt_t errorCode, UInt_t eq);
   TH1F*   GetConsErrType(UInt_t eq);
   TH1F*   GetConsErrFraction(UInt_t eq);        // NB!!! Take care of deleting returned object later
   TH1F*   GetConsErrFractionUnScaled(UInt_t eq);
-  TH1F*   GetConsErrPos(UInt_t errorCode, UInt_t eq);
   TGText* GetText() {return fText;}
 
 
  private:
   Int_t   fNErrors[kNrErrorCodes][20];          // number of errors for this event, for each code and eq
   UInt_t  fNEvents[20];                         // number of events used, for each eq
-  UInt_t  fPayloadSize[20];                     // size of payload for this event, for each eq
-  Bool_t  fPayloadSizeSet[20];                  // was the payload size set for this eq?
   UInt_t  fErrEventCounter[kNrErrorCodes][20];  // event counter used when filling graph
+  UInt_t  fErrPosCounter[kNrErrorCodes][20];    // event counter used when filling graph
+  UInt_t  fErrPosTMPCounter[kNrErrorCodes][20]; // event counter used when filling graph
   Int_t   fByteOffset[20];                      // offset: how many bytes in the equipment header, for each eq
   Bool_t  fSuppressMess[kNrErrorCodes];         // do we suppress error messages for a specific error code?
   Bool_t  fSuppressEq[20];                      // do we suppress error messages for a specific eq?
 
   TGraph  *fConsErrEvent[kNrErrorCodes][20];    // graphs to display number of errors found in each event
+  TGraph  *fConsErrPos[kNrErrorCodes][20];      // graphs to display number of bytes read for each error and event
+  TGraph  *fConsErrPosTMP[kNrErrorCodes][20];   // temporary, to fill tgraph above for event
   TH1F    *fConsErrType[20];                    // histogram of how many errors for each error code
   TH1F    *fConsErrFraction[20];                // histogram of rate of events with errors for each error code
-  TH1F    *fConsErrPos[kNrErrorCodes][20];      // histogram of where in payload the errors occur
 
   TGText  *fText;                               // text buffer for all events analyzed so far
   TGText  *fTextTmp[20];                        // text buffer for this event (defined error codes)
@@ -74,7 +74,7 @@ class AliITSRawStreamSPDErrorLog : public TObject {
   void    InitHistograms();
   void    DeleteHistograms() const;
 
-  ClassDef(AliITSRawStreamSPDErrorLog, 1);
+  ClassDef(AliITSRawStreamSPDErrorLog, 2);
 };
 
 #endif
index b0689ff18a33aedf05271e7ece19a437b0801f0f..3d4b8bf53bb5a790d0b0ee1cae8cc763ddee669c 100644 (file)
@@ -35,11 +35,14 @@ extern "C" {
 #include "AliLog.h"
 #include <iostream>
 #include <fstream>
+//#include <time.h>
 #include <TROOT.h>
 #include <TPluginManager.h>
 #include <TObjArray.h>
+#include <TObjString.h>
 #include <TString.h>
 
+
 int main(int argc, char **argv) {
   if (argc<2) {
     printf("Wrong number of arguments\n");
@@ -108,10 +111,8 @@ int main(int argc, char **argv) {
        paramsFile >> paramN;
        if (paramsFile.eof()) break;
        paramsFile >> paramV;
-       TString* paramNS = new TString(paramN);
-       TString* paramVS = new TString(paramV);
-       paramNames.AddAtAndExpand((TObject*)paramNS,nrTuningParams);
-       paramVals.AddAtAndExpand((TObject*)paramVS,nrTuningParams);
+       paramNames.AddAtAndExpand(new TObjString(paramN),nrTuningParams);
+       paramVals.AddAtAndExpand(new TObjString(paramV),nrTuningParams);
        nrTuningParams++;
        if (paramsFile.eof()) break;
       }
@@ -119,7 +120,8 @@ int main(int argc, char **argv) {
     }
   }
   //  for (UInt_t i=0; i<nrTuningParams; i++) {
-  //    printf("Entry %d: N=%s , V=%s\n",i,((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+  //  //    printf("Entry %d: N=%s , V=%s\n",i,((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+  //    printf("Entry %d: N=%s , V=%s\n",i,((TObjString*)paramNames.At(i))->GetString().Data(),((TObjString*)paramVals.At(i))->GetString().Data());
   //  }
 
 
@@ -131,10 +133,7 @@ int main(int argc, char **argv) {
   // Read silent=dead+inactive info from previous calibrations
   handler->SetFileLocation(saveDirDead);
   handler->ReadSilentFromFiles();
-//!!!  // start by deactivating all eq - should then be activated when found in raw data
-//!!!  for (UInt_t eq=0; eq<20; eq++) {
-//!!!    handler->ActivateEq(eq,kFALSE);
-//!!!  }
+  printf("Nr dead pixels before: %d\n",handler->GetNrDead());
 
 
 
@@ -156,9 +155,9 @@ int main(int argc, char **argv) {
   // container objects
   AliITSOnlineSPDphys *physObj[20];
   Bool_t bPhysInit[20];
-  for (UInt_t eqId=0; eqId<20; eqId++) {
-    physObj[eqId]=NULL;
-    bPhysInit[eqId]=kFALSE;
+  for (UInt_t eq=0; eq<20; eq++) {
+    physObj[eq]=NULL;
+    bPhysInit[eq]=kFALSE;
   }
 
 
@@ -230,58 +229,71 @@ int main(int argc, char **argv) {
 
        while (str->Next()) {
 
-         Int_t eqId = reader->GetDDLID();
+         Int_t eq = reader->GetDDLID();
          // check that this hs is active in handler object
-         if (!(handler->IsActiveEq(eqId))) {
-           printf("Warning: Found Eq (%d) , previously inactive in this run!\n",eqId);
-           handler->ActivateEq(eqId);
+         if (!(handler->IsActiveEq(eq))) {
+           printf("Info: Found Eq (%d) , previously inactive\n",eq);
+           handler->ActivateEq(eq);
          }
-         if (eqId>=0 && eqId<20) {
-           if (!bPhysInit[eqId]) { // this code is duplicated for the moment... (see also below)
-             TString fileName = Form("%s/SPDphys_run_%d_eq_%d.root",saveDirNoisyRef,runNr,eqId);
-             physObj[eqId] = new AliITSOnlineSPDphys(fileName.Data());
-             physObj[eqId]->AddRunNr(runNr);
-             physObj[eqId]->SetEqNr(eqId);
-             bPhysInit[eqId]=kTRUE;
+         if (eq>=0 && eq<20) {
+           if (!bPhysInit[eq]) { // this code is duplicated for the moment... (see also below)
+             TString fileName = Form("%s/SPDphys_run_%d_eq_%d.root",saveDirNoisyRef,runNr,eq);
+             physObj[eq] = new AliITSOnlineSPDphys(fileName.Data());
+             physObj[eq]->AddRunNr(runNr);
+             physObj[eq]->SetEqNr(eq);
+             bPhysInit[eq]=kTRUE;
            }
 
            UInt_t hs = str->GetHalfStaveNr();
            // check that this hs is active in handler object
-           if (!(handler->IsActiveHS(eqId,hs))) {
-             printf("Warning: Found HS (%d,%d) , previously inactive in this run!\n",eqId,hs);
-             handler->ActivateHS(eqId,hs);
+           if (!(handler->IsActiveHS(eq,hs))) {
+             printf("Info: Found HS (%d,%d) , previously inactive\n",eq,hs);
+             handler->ActivateHS(eq,hs);
            }
            UInt_t chip = str->GetChipAddr();
            // check that this chip is active in handler object
-           if (!(handler->IsActiveChip(eqId,hs,chip))) {
-             printf("Info: Found Chip (%d,%d,%d) , inactive in previous run.\n",eqId,hs,chip);
-             handler->ActivateChip(eqId,hs,chip);
+           if (!(handler->IsActiveChip(eq,hs,chip))) {
+             printf("Info: Found Chip (%d,%d,%d) , previously inactive\n",eq,hs,chip);
+             handler->ActivateChip(eq,hs,chip);
            }
-           physObj[eqId]->IncrementHits(hs,chip,str->GetChipCol(),str->GetChipRow());
+           physObj[eq]->IncrementHits(hs,chip,str->GetChipCol(),str->GetChipRow());
            
          }
        }
 
 
-       // check which eq and hs are active for first event only
+       // check which eq and hs are active, for first event only
        if (eventNr==0) {
-         for (UInt_t eqId=0; eqId<20; eqId++) {
+         for (UInt_t eq=0; eq<20; eq++) {
            // activate Eq and HSs in handler object
-           if (str->IsActiveEq(eqId)) {
-             handler->ActivateEq(eqId);
+           if (str->IsActiveEq(eq)) {
+             handler->ActivateEq(eq);
              for (UInt_t hs=0; hs<6; hs++) {
-               handler->ActivateHS(eqId,hs,str->IsActiveHS(eqId,hs));
+               if (str->IsActiveHS(eq,hs)) {
+                 handler->ActivateHS(eq,hs);
+                 for (UInt_t chip=0; chip<10; chip++) {
+                   if (str->IsActiveChip(eq,hs,chip)) {
+                     handler->ActivateChip(eq,hs,chip);
+                   }
+                   else {
+                     handler->ActivateChip(eq,hs,chip,kFALSE);
+                   }
+                 }
+               }
+               else {
+                 handler->ActivateHS(eq,hs,kFALSE);
+               }
              }
-             if (!bPhysInit[eqId]) { // this code is duplicated for the moment... (see also above)
-               TString fileName = Form("%s/SPDphys_run_%d_eq_%d.root",saveDirNoisyRef,runNr,eqId);
-               physObj[eqId] = new AliITSOnlineSPDphys(fileName.Data());
-               physObj[eqId]->AddRunNr(runNr);
-               physObj[eqId]->SetEqNr(eqId);
-               bPhysInit[eqId]=kTRUE;
+             if (!bPhysInit[eq]) { // this code is duplicated for the moment... (see also above)
+               TString fileName = Form("%s/SPDphys_run_%d_eq_%d.root",saveDirNoisyRef,runNr,eq);
+               physObj[eq] = new AliITSOnlineSPDphys(fileName.Data());
+               physObj[eq]->AddRunNr(runNr);
+               physObj[eq]->SetEqNr(eq);
+               bPhysInit[eq]=kTRUE;
              }
            }
            else {
-             handler->ActivateEq(eqId,kFALSE);
+             handler->ActivateEq(eq,kFALSE);
            }
          }
        }
@@ -322,6 +334,9 @@ int main(int argc, char **argv) {
 
   // ********* STEP 2: Analyze phys container files. ************************************************
 
+  //  time_t timeStamp = time(NULL);
+  //  printf("*** Start step2 , %d\n",time(NULL) - timeStamp);
+
   // clear noisyToFXS dir:
   TString command;
   command = Form("cd %s; rm -f *",saveDirNoisyToFXS);
@@ -361,7 +376,7 @@ int main(int argc, char **argv) {
 
     // configure analyzer with tuning parameters etc:
     for (UInt_t i=0; i<nrTuningParams; i++) {
-      noisyAnalyzer->SetParam(((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+      noisyAnalyzer->SetParam(((TObjString*)paramNames.At(i))->GetString().Data(),((TObjString*)paramVals.At(i))->GetString().Data());
     }
 
     printf("SPD phys STEP 2: Noisy search for eq %d\n",eq);  
@@ -401,8 +416,8 @@ int main(int argc, char **argv) {
   }
   // *** *** *** end loop over equipments (eq_id)
 
-  printf("Noisy search finished. %d noisy pixels found. %d chips (%d) had enough statistics.\n",
-        handler->GetNrNoisy(),nrEnoughStatNoisy,nrEqActiveNoisy*60);
+  printf("Noisy search finished. %d noisy pixels found. %d chips had enough statistics.\n",
+        handler->GetNrNoisy(),nrEnoughStatNoisy);
   handler->SetFileLocation(saveDirNoisyToFXS);
   handler->WriteNoisyToFiles();
 
@@ -412,7 +427,6 @@ int main(int argc, char **argv) {
 
 
 
-
   UInt_t nrEnoughStatChips = 0;
   UInt_t nrDeadChips = 0;
   UInt_t nrInefficientChips = 0;
@@ -434,7 +448,7 @@ int main(int argc, char **argv) {
               deadAnalyzer->GetEqNr(),eq);
       }
       delete deadAnalyzer;
-      //!!!      nrDeadChips+=60; // since this eq is inactive...
+      nrDeadChips+=60; // since this eq is inactive...
       continue;
     }
 
@@ -443,7 +457,7 @@ int main(int argc, char **argv) {
 
     // configure analyzer with tuning parameters etc:
     for (UInt_t i=0; i<nrTuningParams; i++) {
-      deadAnalyzer->SetParam(((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+      deadAnalyzer->SetParam(((TObjString*)paramNames.At(i))->GetString().Data(),((TObjString*)paramVals.At(i))->GetString().Data());
     }
 
     printf("SPD phys STEP 2: Dead search for eq %d\n",eq);  
@@ -455,6 +469,7 @@ int main(int argc, char **argv) {
 
     delete deadAnalyzer;
 
+
 #ifndef SPD_DA_OFF
     daqDA_progressReport((unsigned int)(50+(eq+1)*2.5));
 #else
@@ -463,8 +478,12 @@ int main(int argc, char **argv) {
   }
   // *** *** *** end loop over equipments (eq_id)
 
+
+
   
-  printf("Dead search finished. %d dead pixels in total.\n%d chips (%d) had enough statistics. %d chips were dead. %d chips were inefficient.\n",handler->GetNrDead(),nrEnoughStatChips,nrEqActiveDead*60,nrDeadChips,nrInefficientChips);
+  printf("Dead search finished.\n");
+  printf("%d single dead pixels , %d dead or inactive pixels in total.\n",handler->GetNrDead(),handler->GetNrSilent());
+  printf("%d chips had enough statistics. %d chips are dead. %d chips are inefficient.\n",nrEnoughStatChips,nrDeadChips,nrInefficientChips);
   handler->SetFileLocation(saveDirDead);
   handler->WriteSilentToFilesAlways();
   handler->SetFileLocation(saveDirDeadToFXS);
@@ -478,7 +497,7 @@ int main(int argc, char **argv) {
 
 
   // send (dead) reference data for this run to FXS - only if there is no chip in category "needsMoreStat"
-  if (nrEnoughStatChips+nrDeadChips+nrInefficientChips == nrEqActiveDead*60) {
+  if (nrEnoughStatChips+nrDeadChips+nrInefficientChips == 1200) {
     printf("Dead calibration is complete.\n");    // calibration is complete
     printf("Preparing dead reference data\n");
     // send reference data for dead pixels to FXS
@@ -510,6 +529,7 @@ int main(int argc, char **argv) {
   }
 
 
+
   // send (noisy) reference data for this run to FXS
   printf("Preparing noisy reference data\n");
   TString tarFiles = "";
@@ -532,6 +552,8 @@ int main(int argc, char **argv) {
   idsFXSfile << Form("%s\n",id.Data());
 
 
+
+
   // send dead pixels to FXS
   printf("Preparing dead files\n");
   // send a tared file of all the dead files
@@ -550,6 +572,7 @@ int main(int argc, char **argv) {
   idsFXSfile << Form("%s\n",id.Data());
 
 
+
   // send noisy pixels to FXS
   if (handler->GetNrNoisy()>0) { // there must be at least one file created
     printf("Preparing noisy files\n");
@@ -570,6 +593,7 @@ int main(int argc, char **argv) {
   }
 
 
+
   // send ids file to FXS
   idsFXSfile.close();
   id = "SPD_id_list";
@@ -586,6 +610,8 @@ int main(int argc, char **argv) {
 
   delete handler;
 
+  //  printf("*** End step2 , %d\n",time(NULL) - timeStamp);
+
 
   return 0;
 }
index 711e8790bfd9049f8e114ccbd4584902dd371420..17d57bfa8073c53857eec6dbfb5d8ef6634e3156 100644 (file)
@@ -43,6 +43,7 @@ extern "C" {
 #include <TROOT.h>
 #include <TPluginManager.h>
 #include <TObjArray.h>
+#include <TObjString.h>
 #include <TString.h>
 #include <TFitter.h>
 
@@ -118,10 +119,8 @@ int main(int argc, char **argv) {
        paramsFile >> paramN;
        if (paramsFile.eof()) break;
        paramsFile >> paramV;
-       TString* paramNS = new TString(paramN);
-       TString* paramVS = new TString(paramV);
-       paramNames.AddAtAndExpand((TObject*)paramNS,nrTuningParams);
-       paramVals.AddAtAndExpand((TObject*)paramVS,nrTuningParams);
+       paramNames.AddAtAndExpand(new TObjString(paramN),nrTuningParams);
+       paramVals.AddAtAndExpand(new TObjString(paramV),nrTuningParams);
        nrTuningParams++;
        if (paramsFile.eof()) break;
       }
@@ -129,7 +128,8 @@ int main(int argc, char **argv) {
     }
   }
   //  for (UInt_t i=0; i<nrTuningParams; i++) {
-  //    printf("Entry %d: N=%s , V=%s\n",i,((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+  //  //    printf("Entry %d: N=%s , V=%s\n",i,((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+  //    printf("Entry %d: N=%s , V=%s\n",i,((TObjString*)paramNames.At(i))->GetString().Data(),((TObjString*)paramVals.At(i))->GetString().Data());
   //  }
 
   // perm noisy list:
@@ -496,7 +496,7 @@ int main(int argc, char **argv) {
 
     // configure analyzer with tuning parameters etc:
     for (UInt_t i=0; i<nrTuningParams; i++) {
-      analyzer->SetParam(((TString*)paramNames.At(i))->Data(),((TString*)paramVals.At(i))->Data());
+      analyzer->SetParam(((TObjString*)paramNames.At(i))->GetString().Data(),((TObjString*)paramVals.At(i))->GetString().Data());
     }
 
     UInt_t type  = analyzer->GetType();
@@ -726,4 +726,4 @@ int main(int argc, char **argv) {
   printf("DA finished.\n");
 
   return 0;
-}
\ No newline at end of file
+}