]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHitMap.cxx
Adding new classe AliPHOSv0hits (no cout)
[u/mrichter/AliRoot.git] / MUON / AliMUONHitMap.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 */
19
20 #include "AliMUONHitMap.h"
21 ClassImp(AliMUONHitMap)
22 ClassImp(AliMUONHitMapA1)
23
24 AliMUONHitMapA1::AliMUONHitMapA1(AliMUONsegmentation *seg, TObjArray *dig)
25 {
26     fSegmentation = seg;
27     fNpx  = fSegmentation->Npx();
28     fNpy  = fSegmentation->Npy();
29     fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
30     
31     fHitMap = new Int_t[fMaxIndex];
32     fDigits =  dig;
33     fNdigits = fDigits->GetEntriesFast();
34     ClearMap();
35 }
36
37
38 AliMUONHitMapA1::~AliMUONHitMapA1()
39 {
40 //    if (fDigits) delete   fDigits;
41     if (fHitMap) delete[] fHitMap;
42 }
43
44 void AliMUONHitMapA1::ClearMap()
45 {
46     memset(fHitMap,0,sizeof(int)*fMaxIndex);
47 }
48
49 Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy)
50 {
51     Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
52     if (index > fMaxIndex) {
53         printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy);
54         return  fMaxIndex-1;
55     } else {
56         return index;
57     }
58 }
59
60         
61 void  AliMUONHitMapA1::FillHits()
62 {
63     Int_t ndigits = fDigits->GetEntriesFast();
64     //printf("\n Filling hits into HitMap\n");
65     //printf("FindRawClusters -- ndigits %d \n",ndigits);
66     if (!ndigits) return;
67     AliMUONdigit *dig;
68     for (Int_t ndig=0; ndig<fNdigits; ndig++) {
69         dig = (AliMUONdigit*)fDigits->UncheckedAt(ndig);
70         SetHit(dig->fPadX,dig->fPadY,ndig);
71     }
72 }
73
74
75 void  AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
76 {
77 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
78     fHitMap[CheckedIndex(ix, iy)]=idigit+1;
79 }
80
81 void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy)
82 {
83 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
84     fHitMap[CheckedIndex(ix, iy)]=0;
85 }
86
87 void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy)
88 {
89     fHitMap[CheckedIndex(ix, iy)]=
90         -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
91 }
92
93 Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy)
94 {
95     return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
96 }
97
98 TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy)
99 {
100     Int_t index=GetHitIndex(ix,iy);
101     // Force crash if index does not exist ! (Manu)
102     return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
103 }
104
105 Flag_t AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy)
106 {
107     Int_t inf=fHitMap[CheckedIndex(ix, iy)];
108     if (inf < 0) {
109         return used;
110     } else if (inf == 0) {
111         return empty;
112     } else {
113         return unused;
114     }
115 }
116
117