]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFDigitMap.cxx
Optional scoring for background studies in HALL.
[u/mrichter/AliRoot.git] / TOF / AliTOFDigitMap.cxx
index 4275feec03d91683c9a9de0173f2f86a97d921b1..e0e318cc4c325560562590ef3789b18e3cb7b370 100644 (file)
@@ -49,11 +49,11 @@ Raw data update: to read the TOF raw data defined in UNPACKED mode
 ClassImp(AliTOFDigitMap)
 
 AliTOFDigitMap::AliTOFDigitMap():
-  fNSector(-1),
-  fNplate(-1),
-  fNstrip(-1),
-  fNpx(-1),
-  fNpz(-1),
+  fNSector(AliTOFGeometry::NSectors()),
+  fNplate(AliTOFGeometry::NPlates()),
+  fNstrip(AliTOFGeometry::NStripC()),
+  fNpx(AliTOFGeometry::NpadX()),
+  fNpz(AliTOFGeometry::NpadZ()),
   fMaxIndex(-1),
   fDigitMap(0x0)
 {
@@ -61,34 +61,61 @@ AliTOFDigitMap::AliTOFDigitMap():
 // Default ctor
 //
 
-  fNSector = AliTOFGeometry::NSectors();
-  fNplate = AliTOFGeometry::NPlates();
-  fNstrip = AliTOFGeometry::NStripC();
-  fNpx  = AliTOFGeometry::NpadX();
-  fNpz  = AliTOFGeometry::NpadZ();
   fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
-
   fDigitMap = new Int_t*[fMaxIndex];
+
   for (Int_t i=0; i<fMaxIndex; i++) fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
   Clear();
 }
 
 ////////////////////////////////////////////////////////////////////////
-AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/):
-  TObject(),
-  fNSector(-1),
-  fNplate(-1),
-  fNstrip(-1),
-  fNpx(-1),
-  fNpz(-1),
+AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & digitMap):
+  TObject(digitMap),
+  fNSector(digitMap.fNSector),
+  fNplate(digitMap.fNplate),
+  fNstrip(digitMap.fNstrip),
+  fNpx(digitMap.fNpx),
+  fNpz(digitMap.fNpz),
   fMaxIndex(-1),
   fDigitMap(0x0)
 {
-//
-// Dummy copy constructor
-//
-  ;
+  //
+  // Copy constructor
+  //
+  fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
+  fDigitMap = new Int_t*[fMaxIndex];
+  for (Int_t i=0; i<fMaxIndex; i++) {
+    fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
+    for (Int_t j=0; j<kMaxDigitsPerPad; j++)
+      fDigitMap[i][j]=digitMap.fDigitMap[i][j];
+  }
+}
 
+////////////////////////////////////////////////////////////////////////
+AliTOFDigitMap & AliTOFDigitMap::operator=(const AliTOFDigitMap & digitMap)
+{
+  //
+  // Assignment operator
+  //
+  
+  if (this != &digitMap) {
+    TObject::operator=(digitMap);
+    fNSector=digitMap.fNSector;
+    fNplate=digitMap.fNplate;
+    fNstrip=digitMap.fNstrip;
+    fNpx=digitMap.fNpx;
+    fNpz=digitMap.fNpz;
+    fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpz;
+    for (Int_t i=0; i<fMaxIndex; ++i) delete [] fDigitMap[i];
+    delete [] fDigitMap;
+    fDigitMap = new Int_t*[fMaxIndex];
+    for (Int_t i=0; i<fMaxIndex; i++) {
+      fDigitMap[i] = new Int_t[kMaxDigitsPerPad];
+      for (Int_t j=0; j<kMaxDigitsPerPad; j++)
+       fDigitMap[i][j]=digitMap.fDigitMap[i][j];
+    }
+  }
+  return *this;
 }
 
  
@@ -100,6 +127,7 @@ AliTOFDigitMap::~AliTOFDigitMap()
 //
   if (fDigitMap) {
     for (Int_t i=0; i<fMaxIndex; i++)  delete[] fDigitMap[i];
+    delete [] fDigitMap;
   }
 
 
@@ -121,7 +149,7 @@ void AliTOFDigitMap::Clear(const Option_t*)
 }
 
 ////////////////////////////////////////////////////////////////////////
-Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
+Int_t AliTOFDigitMap::CheckedIndex(Int_t * const vol) const
 {
   //
   // Return checked index for vol
@@ -150,6 +178,13 @@ void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
   //
   // 0 means empty pad, we need to shift indeces by 1
 
+  if (fDigitMap[CheckedIndex(vol)][kMaxDigitsPerPad-1]!=0) {
+    AliDebug(1,Form("In the volume (Se%i, Pl%i, St%i, PadR%i, Pad%i) there is not more possibility to add other digits.", vol[0], vol[1], vol[2], vol[4], vol[3]));
+    AliDebug(1,Form("Then, the digit number %i will be not inserted in the digit map, i.e. it will be lost.", idigit));
+    AliDebug(1,Form("Please, check the possibility to increase the digit map size (succently set to %i)", kMaxDigitsPerPad));
+    return;
+  }
+
   for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
 
     if (fDigitMap[CheckedIndex(vol)][slot]==0) {
@@ -159,6 +194,7 @@ void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
     //else continue;
 
   }
+
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -192,9 +228,10 @@ Int_t AliTOFDigitMap::GetDigitIndex(Int_t *vol, Int_t label) const
     return -1;
   }
 
-  if (CheckedIndex(vol)==-1) return -1;
+  Int_t ci = CheckedIndex(vol);
+  if (ci==-1) return -1;
   
-  Int_t dummy = fDigitMap[CheckedIndex(vol)][label];
+  Int_t dummy = fDigitMap[ci][label];
   
   if (dummy>0) return dummy-1;
   else return -1;
@@ -217,13 +254,6 @@ FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
     }
 }
 
-////////////////////////////////////////////////////////////////////////
-AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/) 
-{
-// Dummy assignment operator
-    return *this;
-}
-
 ////////////////////////////////////////////////////////////////////////
 Int_t AliTOFDigitMap::GetFilledCellNumber() const
 {
@@ -231,28 +261,21 @@ Int_t AliTOFDigitMap::GetFilledCellNumber() const
   // Returns the number of filled cells of the TOF digit map
   //
 
-  Int_t volume[5] = {-1, -1, -1, -1, -1};
   Int_t counter = 0;
 
-  for (Int_t iSector=0; iSector<fNSector; iSector++)
-    for (Int_t iPlate=0; iPlate<fNplate; iPlate++)
-      for (Int_t iStrip=0; iStrip<fNstrip; iStrip++)
-       for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
-         for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
-           {
-
-             volume[0] = iSector;
-             volume[1] = iPlate;
-             volume[2] = iStrip;
-             volume[3] = iPadX;
-             volume[4] = iPadZ;
-
-             //if (CheckedIndex(volume)!=-1) counter++;
-             if (GetDigitIndex(volume, 0)>0) counter++;
-           }
+  for (Int_t index = 0; index < fMaxIndex; ++index)
+  {
+    for (Int_t label = 0; label < kMaxDigitsPerPad; ++label)
+    {
+      if (fDigitMap[index][label] > 0)
+      {
+       ++counter;
+       break;
+      }
+    }
+  }
 
   return counter;
-
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -272,9 +295,11 @@ Bool_t AliTOFDigitMap::StripDigitCheck(Int_t iSector, Int_t iPlate, Int_t iStrip
       {
        volume[3] = iPadX;
        volume[4] = iPadZ;
-       if (GetDigitIndex(volume, 0)>=0) {
-         counter = kTRUE;
-         break;          
+       for (Int_t label=0; label<kMaxDigitsPerPad; label++) {
+         if (GetDigitIndex(volume, label)>=0) {
+           counter = kTRUE;
+           break;
+         }
        }
       }
 
@@ -282,6 +307,68 @@ Bool_t AliTOFDigitMap::StripDigitCheck(Int_t iSector, Int_t iPlate, Int_t iStrip
 
 }
 
+////////////////////////////////////////////////////////////////////////
+Int_t AliTOFDigitMap::DigitInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const
+{
+  //
+  // Returns number of digits in the strip iStrip,
+  //         in the plate iPlate of the sector iSector
+  //
+
+  Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
+  Int_t counter = 0;
+
+  for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
+    for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
+      for (Int_t label=0; label<kMaxDigitsPerPad; label++) {
+       volume[3] = iPadX;
+       volume[4] = iPadZ;
+       if (GetDigitIndex(volume, label)>=0)
+         counter++;
+      }
+
+  return counter;
+
+}
+
+////////////////////////////////////////////////////////////////////////
+Int_t AliTOFDigitMap::FilledCellsInStrip(Int_t iSector, Int_t iPlate, Int_t iStrip) const
+{
+  //
+  // Returns number of digits in the strip iStrip,
+  //         in the plate iPlate of the sector iSector
+  //
+
+  Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
+  Int_t counter = 0;
+
+  for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
+    for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++) {
+      volume[3] = iPadX;
+      volume[4] = iPadZ;
+      if (GetDigitIndex(volume, 0)>=0)
+       counter++;
+    }
+
+  return counter;
+
+}
+
+////////////////////////////////////////////////////////////////////////
+void AliTOFDigitMap::ResetDigitNumber(Int_t *vol, Int_t dig)
+{
+  //
+  // Reset digit into pad vol
+  //
+
+  for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
+    if (fDigitMap[CheckedIndex(vol)][slot]-1==dig) {
+      fDigitMap[CheckedIndex(vol)][slot] = 0;
+    }
+  }
+
+}
+
 ////////////////////////////////////////////////////////////////////////
 void AliTOFDigitMap::ResetDigit(Int_t *vol, Int_t dig)
 {
@@ -290,14 +377,11 @@ void AliTOFDigitMap::ResetDigit(Int_t *vol, Int_t dig)
   //
   // 0 means empty pad, we need to shift indeces by 1
 
-  //for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
-  //if (fDigitMap[CheckedIndex(vol)][slot]==dig)
-  //fDigitMap[CheckedIndex(vol)][slot] = 0;
-  //}
   fDigitMap[CheckedIndex(vol)][dig] = 0;
 
 }
 
+////////////////////////////////////////////////////////////////////////
 void AliTOFDigitMap::ResetDigit(Int_t *vol)
 {
   //
@@ -306,6 +390,25 @@ void AliTOFDigitMap::ResetDigit(Int_t *vol)
   // 0 means empty pad, we need to shift indices by 1
 
   for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
-    ResetDigit(vol,slot);
+    fDigitMap[CheckedIndex(vol)][slot] = 0;
+
+}
+
+////////////////////////////////////////////////////////////////////////
+Int_t AliTOFDigitMap::GetNumberOfDigits(Int_t *vol)
+{
+  //
+  // Returns the number of digit
+  //   into pad volume vol
+  //
+  // 0 means empty pad
+  //
+
+  Int_t counter = 0;
+
+  for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++)
+    if (GetDigitIndex(vol, slot)>=0) counter++;
+
+  return counter;
 
 }