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