]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUSensMap.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[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 :  fDimCol(0)
42   ,fDimRow(0)
43   ,fDimCycle(0)
44   ,fItems(0)
45   ,fBTree(0)
46 {
47   // Default constructor
48 }
49
50 //______________________________________________________________________
51 AliITSUSensMap::AliITSUSensMap(const char* className, UInt_t dimCol,UInt_t dimRow,UInt_t dimCycle)
52   :fDimCol(dimCol)
53   ,fDimRow(dimRow)
54   ,fDimCycle(dimCycle)
55   ,fItems(new TClonesArray(className,100))
56   ,fBTree(new TBtree())
57 {
58   // Standard constructor
59 }
60
61 //______________________________________________________________________
62 AliITSUSensMap::~AliITSUSensMap() 
63 {
64   // Default destructor
65   delete fItems;
66   delete fBTree;
67 }
68
69
70 //______________________________________________________________________
71 AliITSUSensMap::AliITSUSensMap(const AliITSUSensMap &source)
72   :TObject(source)
73   ,fDimCol(source.fDimCol)
74   ,fDimRow(source.fDimRow)
75   ,fDimCycle(source.fDimCycle)
76   ,fItems( source.fItems ? new TClonesArray(*source.fItems) : 0)
77   ,fBTree( 0 )
78 {
79   if (source.fBTree) {
80     fBTree = new TBtree();
81     if (fItems) {
82       for (int i=fItems->GetEntriesFast();i--;) {
83         TObject* obj = fItems->At(i);
84         if (obj && ! IsDisabled(obj)) continue;
85         RegisterItem(obj);
86       }
87     }
88   }
89 }
90
91 //______________________________________________________________________
92 AliITSUSensMap& AliITSUSensMap::operator=(const AliITSUSensMap &source)
93 {
94   // = operator
95   if (this!=&source) {
96     this->~AliITSUSensMap();
97     new(this) AliITSUSensMap(source);
98   }
99   return *this;
100 }
101
102 //______________________________________________________________________
103 void AliITSUSensMap::Clear(Option_t*) 
104 {
105   // clean everything
106   if (fItems) fItems->Clear();
107   if (fBTree) fBTree->Clear();
108 }
109
110 //______________________________________________________________________
111 void AliITSUSensMap::DeleteItem(UInt_t col,UInt_t row,Int_t cycle)
112 {
113   // Delete a particular AliITSUSensMapItems.
114   SetUniqueID( GetIndex(col,row,cycle) );
115   TObject* fnd = fBTree->FindObject(this);
116   if (!fnd) return;
117   Disable(fnd);
118   fBTree->Remove(fnd);
119 }
120
121 //______________________________________________________________________
122 void AliITSUSensMap::DeleteItem(TObject* obj)
123 {
124   // Delete a particular AliITSUSensMapItems.
125   TObject* fnd = fBTree->FindObject(obj);
126   if (!fnd) return;
127   Disable(fnd);
128   fBTree->Remove(fnd);
129 }
130
131 //______________________________________________________________________
132 void  AliITSUSensMap::SetDimensions(UInt_t dimCol,UInt_t dimRow,UInt_t dimCycle) 
133 {
134   // set dimensions for current sensor
135   const UInt_t kMaxPackDim = 0xffffffff;
136   fDimCol = dimCol; 
137   fDimRow = dimRow; 
138   fDimCycle=dimCycle;
139   if ((fDimCol*fDimRow*fDimCycle)>kMaxPackDim/2) AliFatal(Form("Dimension %dx%dx%d*2 cannot be packed to UInt_t",fDimCol,fDimRow,fDimCycle));
140 }
141