]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUSensMap.cxx
Fix in ladder width assingment (Stefan)
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUSensMap.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 /* $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 AliITSUSensMap::IsSortable,IsEqual,Compare
31 //
32 // ***********************************************************************
33
34 #include "AliITSUSensMap.h"
35 #include "AliLog.h"
36 //______________________________________________________________________
37
38 ClassImp(AliITSUSensMap)
39 //______________________________________________________________________
40 AliITSUSensMap::AliITSUSensMap() 
41 :  fDim0(0)
42   ,fDim1(0)
43   ,fItems(0)
44   ,fBTree(0)
45 {
46   // Default constructor
47 }
48
49 //______________________________________________________________________
50 AliITSUSensMap::AliITSUSensMap(const char* className, UInt_t dim0,UInt_t dim1)
51   :fDim0(dim0)
52   ,fDim1(dim1)
53   ,fItems(new TClonesArray(className,100))
54   ,fBTree(new TBtree())
55 {
56   // Standard constructor
57 }
58
59 //______________________________________________________________________
60 AliITSUSensMap::~AliITSUSensMap() 
61 {
62   // Default destructor
63   delete fItems;
64   delete fBTree;
65 }
66
67
68 //______________________________________________________________________
69 AliITSUSensMap::AliITSUSensMap(const AliITSUSensMap &source)
70   :TObject(source)
71   ,fDim0(source.fDim0)
72   ,fDim1(source.fDim1)
73   ,fItems( source.fItems ? new TClonesArray(*source.fItems) : 0)
74   ,fBTree( 0 )
75 {
76   if (source.fBTree) {
77     fBTree = new TBtree();
78     for (int i=fItems->GetEntriesFast();i--;) {
79       TObject* obj = fItems->At(i);
80       if (obj && ! IsDisabled(obj)) continue;
81       RegisterItem(obj);
82     }
83   }
84 }
85
86 //______________________________________________________________________
87 AliITSUSensMap& AliITSUSensMap::operator=(const AliITSUSensMap &source)
88 {
89   // = operator
90   if (this!=&source) {
91     this->~AliITSUSensMap();
92     new(this) AliITSUSensMap(source);
93   }
94   return *this;
95 }
96
97 //______________________________________________________________________
98 void AliITSUSensMap::Clear(Option_t*) 
99 {
100   // clean everything
101   if (fItems) fItems->Clear();
102   if (fBTree) fBTree->Clear();
103 }
104
105 //______________________________________________________________________
106 void AliITSUSensMap::DeleteItem(UInt_t i,UInt_t j)
107 {
108   // Delete a particular AliITSUSensMapItems.
109   SetUniqueID( GetIndex(i,j) );
110   TObject* fnd = fBTree->FindObject(this);
111   if (!fnd) return;
112   Disable(fnd);
113   fBTree->Remove(fnd);
114 }
115
116 //______________________________________________________________________
117 void AliITSUSensMap::DeleteItem(TObject* obj)
118 {
119   // Delete a particular AliITSUSensMapItems.
120   TObject* fnd = fBTree->FindObject(obj);
121   if (!fnd) return;
122   Disable(fnd);
123   fBTree->Remove(fnd);
124 }
125
126 //______________________________________________________________________
127 void AliITSUSensMap::GetCell(UInt_t index,UInt_t &i,UInt_t &j) const 
128 {
129   // returns the i,j index numbers from the linearized index computed
130   // with GetIndex
131   if(index>=fDim0*fDim1){
132     Warning("GetCell","Index out of range 0<=index=%d<%d",index,fDim0*fDim1);
133     i=-1;j=-1;
134     return;
135   } // end if
136   i = index/fDim1;
137   j = index%fDim1;
138   return;
139 }