]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONDigitMapA1.cxx
Separating writing and reading of raw data (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitMapA1.cxx
CommitLineData
5289cf2f 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/* $Id$ */
17
5289cf2f 18#include "AliMUONDigitMapA1.h"
19#include "AliMUONDigit.h"
d3ea2ca8 20
5289cf2f 21#include "AliLog.h"
22
d3ea2ca8 23#include <TObjArray.h>
24#include <TMath.h>
25
5289cf2f 26ClassImp(AliMUONDigitMapA1)
27
28AliMUONDigitMapA1::AliMUONDigitMapA1()
29 : fIdDE(0),
30 fNpx(0),
31 fNpy(0),
32 fDigits(0),
33 fMaxIndex(0),
34 fHitMap(0)
35{
36 // Default constructor
37
38}
39//________________________________________________________________________________
d3ea2ca8 40AliMUONDigitMapA1::AliMUONDigitMapA1(Int_t idDE, Int_t npx, Int_t npy )
5289cf2f 41{
42// Constructor with new segmentation
43
5289cf2f 44 fIdDE = idDE;
d3ea2ca8 45 fNpx = npx;
46 fNpy = npy;
5289cf2f 47 fMaxIndex = fNpx * fNpy + fNpx ;
48
49 fHitMap = new Int_t[fMaxIndex];
50 Clear();
51
52}
53//______________________________________________________________
54AliMUONDigitMapA1::AliMUONDigitMapA1(const AliMUONDigitMapA1& hitMap)
55 : TObject(hitMap)
56{
57// Protected copy constructor
58
59 AliFatal("Not implemented.");
60}
61//_________________________________
62AliMUONDigitMapA1::~AliMUONDigitMapA1()
63{
64// Destructor
65 if (fHitMap) delete[] fHitMap;
66}
67//______________________________________
68void AliMUONDigitMapA1::Clear(const char *)
69{
70// Clear hitmap
71 memset(fHitMap,0,sizeof(int)*fMaxIndex);
72}
73
74//_________________________________________________________
75Int_t AliMUONDigitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
76{
77// Return checked indices ix, iy
78 Int_t index = iy * fNpx + ix;
b133692e 79 if ( index < 0 || index >= fMaxIndex ) {
5289cf2f 80 AliWarning(Form("index outside array idDE %d ix %d iy %d MaxIndex %d index %d Npx %d Npy %d",
81 fIdDE, ix,iy, fMaxIndex, index, fNpx, fNpy));
82 return fMaxIndex-1;
83 } else {
84 return index;
85 }
86}
87//_____________________________
88void AliMUONDigitMapA1::FillHits(TObjArray* digits)
89{
90// Fill hits from digits list
91 fDigits = digits;
92 Int_t ndigits = fDigits->GetEntriesFast();
93 if (!ndigits) return;
94 AliMUONDigit *dig;
95 for (Int_t ndig = 0; ndig < ndigits; ndig++) {
96 dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
97 SetHit(dig->PadX(),dig->PadY(),ndig);
98 }
99}
100//___________________________________________________________
101void AliMUONDigitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
102{
103// Assign digit to hit cell ix,iy
104
105 fHitMap[CheckedIndex(ix, iy)] = idigit + 1;
106}
107//_______________________________________________
108void AliMUONDigitMapA1::DeleteHit(Int_t ix, Int_t iy)
109{
110// Delete hit at cell ix,iy
111
112 fHitMap[CheckedIndex(ix, iy)]=0;
113}
114//_____________________________________________
115void AliMUONDigitMapA1::FlagHit(Int_t ix, Int_t iy)
116{
117// Flag hit as used
118 fHitMap[CheckedIndex(ix, iy)]=
119 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
120}
121//________________________________________________________
122Int_t AliMUONDigitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
123{
124// Get absolute value of contents of hit cell ix,iy
125 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
126}
127//_______________________________________________________
128TObject* AliMUONDigitMapA1::GetHit(Int_t ix, Int_t iy) const
129{
130 // Get pointer to object at hit cell ix, iy
131 // Force crash if index does not exist ! (Manu)
132 Int_t index = GetHitIndex(ix,iy);
133 return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
134}
135//_________________________________________________
136FlagType AliMUONDigitMapA1::TestHit(Int_t ix, Int_t iy)
137{
138// Check if hit cell is empty, used or unused
139//
140 Int_t index = CheckedIndex(ix, iy);
141 if (index<0 || index >= fMaxIndex) return kEmpty;
142
143 Int_t inf = fHitMap[index];
144 if (inf < 0) {
145 return kUsed;
146 } else if (inf == 0) {
147 return kEmpty;
148 } else {
149 return kUnused;
150 }
151}
152//________________________________________________________________________
153AliMUONDigitMapA1 & AliMUONDigitMapA1::operator = (const AliMUONDigitMapA1 & rhs)
154{
155// Protected assignement operator
156
157 if (this == &rhs) return *this;
158
159 AliFatal( "Not implemented.");
160
161 return *this;
162}
163
164
165
166
167