]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONHitMapA1.cxx
Added class iostreamer funcionality and Print and Read functions. cleaned
[u/mrichter/AliRoot.git] / MUON / AliMUONHitMapA1.cxx
index b1007ac4d6c9705cc64ac177896fdf71f062eced..bda8df51b17ea1e5d66fd4e1795be99ee13e217e 100644 (file)
 
 /*
 $Log$
+Revision 1.10  2001/11/02 12:43:21  jchudoba
+remove fNdigits data member, it could have wrong value if fDigits is updated. Make this class non-persistent
+
+Revision 1.9  2001/03/20 13:34:05  egangler
+Obvious small bug
+
+Revision 1.8  2001/01/26 21:47:21  morsch
+Use access functions to AliMUONDigit member data.
+
+Revision 1.7  2001/01/25 11:43:48  morsch
+Add a "real" default constructor.
+
+Revision 1.6  2000/10/06 09:05:42  morsch
+Correction on upper limits for x- and y- coordinates to make code work with slat chambers.
+
+Revision 1.5  2000/10/02 21:28:09  fca
+Removal of useless dependecies via forward declarations
+
+Revision 1.4  2000/07/13 16:19:44  fca
+Mainly coding conventions + some small bug fixes
+
 Revision 1.3  2000/07/03 11:54:57  morsch
 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
@@ -41,18 +62,26 @@ Most coding rule violations corrected.
 
 ClassImp(AliMUONHitMapA1)
 
+    AliMUONHitMapA1::AliMUONHitMapA1()
+{
+    // Default constructor
+    fNpx          = 0;
+    fNpy          = 0;
+    fMaxIndex     = 0;
+    
+    fHitMap       = 0;
+    fDigits       = 0;
+}
 
 AliMUONHitMapA1::AliMUONHitMapA1(AliSegmentation *seg, TObjArray *dig)
 {
 // Constructor
-    fSegmentation = seg;
-    fNpx  = fSegmentation->Npx();
-    fNpy  = fSegmentation->Npy();
+    fNpx  = seg->Npx()+1;
+    fNpy  = seg->Npy()+1;
     fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
     
     fHitMap = new Int_t[fMaxIndex];
     fDigits =  dig;
-    fNdigits = fDigits->GetEntriesFast();
     Clear();
 }
 
@@ -66,7 +95,6 @@ AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap)
 AliMUONHitMapA1::~AliMUONHitMapA1()
 {
 // Destructor
-//    if (fDigits) delete   fDigits;
     if (fHitMap) delete[] fHitMap;
 }
 
@@ -76,12 +104,23 @@ void AliMUONHitMapA1::Clear(const char *)
     memset(fHitMap,0,sizeof(int)*fMaxIndex);
 }
 
-Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy)
+Bool_t AliMUONHitMapA1::ValidateHit(Int_t ix, Int_t iy)
+{
+    //
+    // Check if pad coordinates are within boundaries
+    //
+//    printf("\n Validate %d %d %d %d", ix, iy, fNpx, fNpy);
+    
+    return (TMath::Abs(ix) <= fNpx && TMath::Abs(iy) <= fNpy); 
+}
+
+Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
 {
 // Return checked indices ix, iy
     Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
-    if (index > fMaxIndex) {
-       printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy);
+    if (index >= fMaxIndex) {
+       printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",
+              ix,iy, fMaxIndex, index, fNpx, fNpy);
        return  fMaxIndex-1;
     } else {
        return index;
@@ -97,9 +136,9 @@ void  AliMUONHitMapA1::FillHits()
     //printf("FindRawClusters -- ndigits %d \n",ndigits);
     if (!ndigits) return;
     AliMUONDigit *dig;
-    for (Int_t ndig=0; ndig<fNdigits; ndig++) {
+    for (Int_t ndig=0; ndig<ndigits; ndig++) {
        dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
-       SetHit(dig->fPadX,dig->fPadY,ndig);
+       SetHit(dig->PadX(),dig->PadY(),ndig);
     }
 }
 
@@ -125,13 +164,13 @@ void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy)
        -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
 }
 
-Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy)
+Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
 {
 // Get absolute value of contents of hit cell ix,iy
     return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
 }
 
-TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy)
+TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const
 {
     // Get pointer to object at hit cell ix, iy
     // Force crash if index does not exist ! (Manu)
@@ -160,3 +199,6 @@ AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs)
 }
 
 
+
+
+