]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUSensMap.cxx
Use the MCchain flag in GetChainForTestMode
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUSensMap.cxx
CommitLineData
451f5018 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/* $Id: AliITSUSensMap.cxx 39464 2010-03-09 14:59:19Z masera $ */
16
17//***********************************************************************
18//
19// It consist of a TClonesArray of
20// AliITSUSensMapItem objects
21// This array can be accessed via 2 indexed
22// it is used at digitization level by
23// all the 3 ITS subdetectors
24//
25//
26// The items should be added to the map like this:
27// map->RegisterItem( new(map->GetFree()) ItemConstructor(...) );
28//
29// The items must be sortable with the same sorting algorithm like
30// for the dummy class AliITSUSensMap::TObjSortable
31//
32// ***********************************************************************
33
34#include "AliITSUSensMap.h"
35#include "AliLog.h"
36//______________________________________________________________________
37
38ClassImp(AliITSUSensMap)
39//______________________________________________________________________
40AliITSUSensMap::AliITSUSensMap()
41: fDim0(0)
42 ,fDim1(0)
43 ,fItems(0)
44 ,fBTree(0)
45 ,fProbe()
46{
47 // Default constructor
48}
49
50//______________________________________________________________________
51AliITSUSensMap::AliITSUSensMap(const char* className, UInt_t dim0,UInt_t dim1)
52 :fDim0(dim0)
53 ,fDim1(dim1)
54 ,fItems(new TClonesArray(className,100))
55 ,fBTree(new TBtree())
56 ,fProbe()
57{
58 // Standard constructor
59}
60
61//______________________________________________________________________
62AliITSUSensMap::~AliITSUSensMap()
63{
64 // Default destructor
65 delete fItems;
66 delete fBTree;
67}
68
69
70//______________________________________________________________________
71AliITSUSensMap::AliITSUSensMap(const AliITSUSensMap &source)
72 :TObject(source)
73 ,fDim0(source.fDim0)
74 ,fDim1(source.fDim1)
75 ,fItems( source.fItems ? new TClonesArray(*source.fItems) : 0)
76 ,fBTree( 0 )
77 ,fProbe( source.fProbe)
78{
79 if (source.fBTree) {
80 fBTree = new TBtree();
81 for (int i=fItems->GetEntriesFast();i--;) {
82 TObject* obj = fItems->At(i);
83 if (obj && ! IsDisabled(obj)) continue;
84 RegisterItem(obj);
85 }
86 }
87}
88
89//______________________________________________________________________
90AliITSUSensMap& AliITSUSensMap::operator=(const AliITSUSensMap &source)
91{
92 // = operator
93 if (this!=&source) {
94 this->~AliITSUSensMap();
95 new(this) AliITSUSensMap(source);
96 }
97 return *this;
98}
99
100//______________________________________________________________________
101void AliITSUSensMap::Clear(Option_t*)
102{
103 // clean everything
104 if (fItems) fItems->Clear();
105 if (fBTree) fBTree->Clear();
106 fProbe.Clear();
107}
108
109//______________________________________________________________________
110void AliITSUSensMap::DeleteItem(UInt_t i,UInt_t j)
111{
112 // Delete a particular AliITSUSensMapItems.
113 fProbe.SetUniqueID( GetIndex(i,j) );
114 TObject* fnd = fBTree->FindObject(&fProbe);
115 if (!fnd) return;
116 Disable(fnd);
117 fBTree->Remove(fnd);
118}
119
120//______________________________________________________________________
121void AliITSUSensMap::DeleteItem(TObject* obj)
122{
123 // Delete a particular AliITSUSensMapItems.
124 TObject* fnd = fBTree->FindObject(obj);
125 if (!fnd) return;
126 Disable(fnd);
127 fBTree->Remove(fnd);
128}
129
130//______________________________________________________________________
131void AliITSUSensMap::GetCell(UInt_t index,UInt_t &i,UInt_t &j) const
132{
133 // returns the i,j index numbers from the linearized index computed
134 // with GetIndex
135 if(index>=fDim0*fDim1){
136 Warning("GetCell","Index out of range 0<=index=%d<%d",index,fDim0*fDim1);
137 i=-1;j=-1;
138 return;
139 } // end if
140 i = index/fDim1;
141 j = index%fDim1;
142 return;
143}