]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFDigitMap.cxx
Minor changes
[u/mrichter/AliRoot.git] / TOF / AliTOFDigitMap.cxx
index 58d5bec99af5627beac456c1999f5413a976ff92..227d732115738b433c24cb125cd329db91de5bbe 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,42 @@ 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),
-  fMaxIndex(-1),
+AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & digitMap):
+  TObject(digitMap),
+  fNSector(digitMap.fNSector),
+  fNplate(digitMap.fNplate),
+  fNstrip(digitMap.fNstrip),
+  fNpx(digitMap.fNpx),
+  fNpz(digitMap.fNpz),
+  fMaxIndex(digitMap.fMaxIndex),
   fDigitMap(0x0)
 {
 //
-// Dummy copy constructor
+// dummy 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];
+}
+
+////////////////////////////////////////////////////////////////////////
+AliTOFDigitMap &
+AliTOFDigitMap::operator=(const AliTOFDigitMap & /*digitMap*/)
+{
+//
+// dummy copy const
+//
+    return *this;
 }
 
  
@@ -150,6 +158,12 @@ 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) {
+    AliWarning(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]));
+    AliWarning(Form("Then, the digit number %i will be not inserted in the digit map, i.e. it will be lost.", idigit));
+    return;
+  }
+
   for (Int_t slot=0; slot<kMaxDigitsPerPad; slot++) {
 
     if (fDigitMap[CheckedIndex(vol)][slot]==0) {
@@ -159,6 +173,7 @@ void AliTOFDigitMap::AddDigit(Int_t *vol, Int_t idigit)
     //else continue;
 
   }
+
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -217,12 +232,6 @@ FlagType AliTOFDigitMap::TestDigit(Int_t *vol) const
     }
 }
 
-////////////////////////////////////////////////////////////////////////
-AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/) 
-{
-// Dummy assignment operator
-    return *this;
-}
 ////////////////////////////////////////////////////////////////////////
 Int_t AliTOFDigitMap::GetFilledCellNumber() const
 {
@@ -233,6 +242,8 @@ Int_t AliTOFDigitMap::GetFilledCellNumber() const
   Int_t volume[5] = {-1, -1, -1, -1, -1};
   Int_t counter = 0;
 
+  Bool_t checkContent = kFALSE;
+
   for (Int_t iSector=0; iSector<fNSector; iSector++)
     for (Int_t iPlate=0; iPlate<fNplate; iPlate++)
       for (Int_t iStrip=0; iStrip<fNstrip; iStrip++)
@@ -246,8 +257,12 @@ Int_t AliTOFDigitMap::GetFilledCellNumber() const
              volume[3] = iPadX;
              volume[4] = iPadZ;
 
+             checkContent = kFALSE;
+             for (Int_t label=0; label<kMaxDigitsPerPad; label++)
+               checkContent = checkContent || (GetDigitIndex(volume, label)>=0);
+
              //if (CheckedIndex(volume)!=-1) counter++;
-             if (GetDigitIndex(volume, 0)>0) counter++;
+             if (checkContent) counter++;
            }
 
   return counter;
@@ -255,14 +270,113 @@ Int_t AliTOFDigitMap::GetFilledCellNumber() const
 }
 
 ////////////////////////////////////////////////////////////////////////
-void AliTOFDigitMap::ResetDigit(Int_t *vol)
+Bool_t AliTOFDigitMap::StripDigitCheck(Int_t iSector, Int_t iPlate, Int_t iStrip) const
+{
+  //
+  // Returns:
+  //           kFALSE if the strip doesn't contain digits
+  //           kTRUE  if the strip contains at least one digit
+  //
+
+  Int_t volume[5] = {iSector, iPlate, iStrip, -1, -1};
+  Bool_t counter = kFALSE;
+
+  for (Int_t iPadX=0; iPadX<fNpx; iPadX++)
+    for (Int_t iPadZ=0; iPadZ<fNpz; iPadZ++)
+      {
+       volume[3] = iPadX;
+       volume[4] = iPadZ;
+       for (Int_t label=0; label<kMaxDigitsPerPad; label++) {
+         if (GetDigitIndex(volume, label)>=0) {
+           counter = kTRUE;
+           break;
+         }
+       }
+      }
+
+  return counter;
+
+}
+
+////////////////////////////////////////////////////////////////////////
+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;
+
+}
+
+////////////////////////////////////////////////////////////////////////
+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)
 {
   //
   // Reset digit into pad vol
   //
   // 0 means empty pad, we need to shift indeces by 1
 
+  fDigitMap[CheckedIndex(vol)][dig] = 0;
+
+}
+
+////////////////////////////////////////////////////////////////////////
+void AliTOFDigitMap::ResetDigit(Int_t *vol)
+{
+  //
+  // Reset digit into pad vol
+  //
+  // 0 means empty pad, we need to shift indices by 1
+
   for (Int_t slot=0; slot<kMaxDigitsPerPad; 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;
+
+}