]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONHitMapA1.cxx
Addes script to compare Naiive, Poisson to Hits, Primaries
[u/mrichter/AliRoot.git] / MUON / AliMUONHitMapA1.cxx
index 21800fb8f6a23de26ec46be942e39e5cd242815d..7684987617b413e6ce517fc6435d51cb83a6be4f 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.8  2001/01/26 21:47:21  morsch
-Use access functions to AliMUONDigit member data.
+/* $Id$ */
 
-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.
-
-Revision 1.2  2000/06/15 07:58:48  morsch
-Code from MUON-dev joined
-
-Revision 1.1.2.2  2000/06/12 07:58:06  morsch
-include TMath.h
-
-Revision 1.1.2.1  2000/06/09 22:01:09  morsch
-Code from AliMUONHitMap.h
-Most coding rule violations corrected.
-
-*/
+#include <TObjArray.h>
+#include <TMath.h>
 
 #include "AliMUONHitMapA1.h"
-#include "AliSegmentation.h"
-#include "AliMUONResponse.h"
+#include "AliMUONGeometrySegmentation.h"
 #include "AliMUONDigit.h"
-
-#include <TObjArray.h>
-#include <TMath.h>
+#include "AliLog.h"
 
 ClassImp(AliMUONHitMapA1)
 
-    AliMUONHitMapA1::AliMUONHitMapA1()
+AliMUONHitMapA1::AliMUONHitMapA1()
+  : AliHitMap()
 {
     // Default constructor
-    fSegmentation = 0;
     fNpx          = 0;
     fNpy          = 0;
     fMaxIndex     = 0;
     
     fHitMap       = 0;
     fDigits       = 0;
-    fNdigits      = 0;
 }
 
-AliMUONHitMapA1::AliMUONHitMapA1(AliSegmentation *seg, TObjArray *dig)
+//________________________________________________________________________________
+AliMUONHitMapA1::AliMUONHitMapA1(Int_t idDE, AliMUONGeometrySegmentation* seg, TObjArray* dig)
+  : AliHitMap()
 {
-// Constructor
-    fSegmentation = seg;
-    fNpx  = fSegmentation->Npx()+1;
-    fNpy  = fSegmentation->Npy()+1;
+// Constructor with new segmentation
+    fNpx  = seg->Npx(idDE)+1;
+    fNpy  = seg->Npy(idDE)+1;
     fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
     
     fHitMap = new Int_t[fMaxIndex];
     fDigits =  dig;
-    fNdigits = fDigits->GetEntriesFast();
     Clear();
 }
-
+//______________________________________________________________
 AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap)
+  : AliHitMap(hitMap)
 {
-// Dummy copy constructor
-    ;
-}
+// Protected copy constructor
 
+  AliFatal("Not implemented.");
+}
+//_________________________________
 AliMUONHitMapA1::~AliMUONHitMapA1()
 {
 // Destructor
-//    if (fDigits) delete   fDigits;
     if (fHitMap) delete[] fHitMap;
 }
-
+//______________________________________
 void AliMUONHitMapA1::Clear(const char *)
 {
 // Clear hitmap
     memset(fHitMap,0,sizeof(int)*fMaxIndex);
 }
-
+//___________________________________________________
+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);
+//     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;
     }
 }
-
-       
+//_____________________________
 void  AliMUONHitMapA1::FillHits()
 {
 // Fill hits from digits list  
@@ -125,40 +102,39 @@ 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->PadX(),dig->PadY(),ndig);
     }
 }
-
-
+//___________________________________________________________
 void  AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
 {
 // Assign digit to hit cell ix,iy
 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
     fHitMap[CheckedIndex(ix, iy)]=idigit+1;
 }
-
+//_______________________________________________
 void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy)
 {
 // Delete hit at cell ix,iy
 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
     fHitMap[CheckedIndex(ix, iy)]=0;
 }
-
+//_____________________________________________
 void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy)
 {
 // Flag hit as used
     fHitMap[CheckedIndex(ix, iy)]=
        -TMath::Abs(fHitMap[CheckedIndex(ix, 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) const
 {
     // Get pointer to object at hit cell ix, iy
@@ -166,12 +142,15 @@ TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const
     Int_t index=GetHitIndex(ix,iy);
     return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
 }
-
+//_________________________________________________
 FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy)
 {
 // Check if hit cell is empty, used or unused
 //
-    Int_t inf=fHitMap[CheckedIndex(ix, iy)];
+    Int_t index = CheckedIndex(ix, iy);
+    if (index<0 || index >= fMaxIndex) return kEmpty;
+
+    Int_t inf=fHitMap[index];
     if (inf < 0) {
        return kUsed;
     } else if (inf == 0) {
@@ -180,11 +159,16 @@ FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy)
        return kUnused;
     }
 }
-
+//________________________________________________________________________
 AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs) 
 {
-// Dummy assignment operator
-    return *this;
+// Protected assignement operator
+
+  if (this == &rhs) return *this;
+
+  AliFatal( "Not implemented.");
+    
+  return *this;  
 }