]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSegmentation.cxx
Adding comments only
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentation.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *      SigmaEffect_thetadegrees                                                                  *
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 purpeateose. It is      *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // $Id$
17 //
18 // ----------------------------
19 // Class AliMUONSegmentation
20 // ----------------------------
21 // Manager class for geometry construction via geometry builders.
22 // Author: Ivana Hrivnacova, IPN Orsay
23
24 #include <iostream>
25
26 #include <TObjArray.h>
27
28 #include "AliMUONSegmentation.h"
29 #include "AliMUONVGeometryDESegmentation.h"
30 #include "AliMUONGeometrySegmentation.h"
31 \
32 #include "AliMpVSegmentation.h"
33 #include "AliMpDEManager.h"
34
35 #include "AliLog.h"
36
37 /// \cond CLASSIMP
38 ClassImp(AliMUONSegmentation)
39 /// \endcond
40  
41 //______________________________________________________________________________
42 AliMUONSegmentation::AliMUONSegmentation(Int_t nofModules)
43   : TObject(),
44     fDESegmentations(0)
45 {
46 /// Standard constructor
47
48   // Create array for DE segmentations
49   fDESegmentations = new TObjArray();
50   fDESegmentations->SetOwner(kTRUE);
51
52   // Create array for modules segmentations
53   for (Int_t cathod = 0; cathod < 2; cathod++) {
54     fModuleSegmentations[cathod] = new TObjArray(nofModules);
55     fModuleSegmentations[cathod]->SetOwner(true);
56     
57     for (Int_t i=0; i<nofModules; i++)
58       fModuleSegmentations[cathod]->AddAt(0, i);
59   }  
60
61   AliDebug(1, Form("ctor this = %p", this) ); 
62 }
63
64 //______________________________________________________________________________
65 AliMUONSegmentation::AliMUONSegmentation() 
66   : TObject(),
67     fDESegmentations(0)
68 {
69 /// Default constructor
70
71   fModuleSegmentations[0] = 0;
72   fModuleSegmentations[1] = 0;
73
74   AliDebug(1, Form("default (empty) ctor this = %p", this));
75
76
77 //______________________________________________________________________________
78 AliMUONSegmentation::~AliMUONSegmentation()
79 {
80 /// Destructor
81
82   AliDebug(1, Form("dtor this = %p", this));
83
84   delete fDESegmentations;
85   delete fModuleSegmentations[0];
86   delete fModuleSegmentations[1];
87 }
88
89 //
90 // private functions
91 //
92
93 //_____________________________________________________________________________
94 AliMUONGeometrySegmentation* 
95 AliMUONSegmentation::GetModuleSegmentation(
96                         Int_t moduleId, Int_t cathod, Bool_t warn) const
97 {
98 /// Return the geometry module segmentation specified by moduleId
99
100   if (cathod < 0 || cathod >= 2) {
101     if (warn) {
102       AliWarningStream() 
103         << "Cathod: " << cathod << " outside limits" << std::endl;
104     }                    
105     return 0;  
106   }  
107
108   if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
109     if (warn) {
110       AliWarningStream() 
111         << "Index: " << moduleId << " outside limits" << std::endl;
112     }                    
113     return 0;  
114   }  
115
116   return (AliMUONGeometrySegmentation*) 
117             fModuleSegmentations[cathod]->At(moduleId);
118 }    
119
120 //
121 // public functions
122 //
123
124 //_____________________________________________________________________________
125 void AliMUONSegmentation::AddDESegmentation(
126                                 AliMUONVGeometryDESegmentation* segmentation)
127 {
128 /// Add the DE segmentation to the array
129
130   fDESegmentations->Add(segmentation);
131 }
132
133 //_____________________________________________________________________________
134 void AliMUONSegmentation::AddModuleSegmentation(Int_t moduleId, Int_t cathod,
135                              AliMUONGeometrySegmentation* segmentation)
136 {
137 /// Add the module segmentation to the array
138
139   if (cathod < 0 || cathod >= 2) {
140       AliErrorStream() 
141         << "Cathod: " << cathod << " outside limits" << std::endl;
142       return;   
143   }                      
144
145   if (moduleId < 0 || moduleId >= fModuleSegmentations[cathod]->GetEntriesFast()) {
146     AliErrorStream() 
147         << "Module Id: " << moduleId << " outside limits" << std::endl;
148     return;  
149   }  
150
151   fModuleSegmentations[cathod]->AddAt(segmentation, moduleId);
152 }
153
154 //_____________________________________________________________________________
155 void  AliMUONSegmentation::Init()
156 {
157 /// Initialize all segmentations
158  
159   for (Int_t cathod = 0; cathod < 2; cathod++) {
160     for (Int_t i = 0; i < fModuleSegmentations[cathod]->GetEntriesFast(); i++) {
161     
162       AliMUONGeometrySegmentation* moduleSegmentation
163         = (AliMUONGeometrySegmentation*)fModuleSegmentations[cathod]->At(i);
164     
165       if (moduleSegmentation) moduleSegmentation->Init(i); 
166     }  
167   }  
168 }
169                             
170 //_____________________________________________________________________________
171 AliMUONGeometrySegmentation* 
172 AliMUONSegmentation::GetModuleSegmentationByDEId(
173                         Int_t detElemId, Int_t cathod, Bool_t warn) const
174 {
175 /// Return the geometry module specified by detElemId/cathod
176
177   // Get moduleId 
178   Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
179
180   return GetModuleSegmentation(moduleId, cathod, warn);
181 }    
182
183 //_____________________________________________________________________________
184 const AliMUONVGeometryDESegmentation* 
185 AliMUONSegmentation::GetDESegmentation(
186                         Int_t detElemId, Int_t cathod, Bool_t warn) const
187 {
188 /// Return the DE segmentation specified by detElemId/cathod
189
190   // Get geometry segmentation 
191   AliMUONGeometrySegmentation* moduleSegmentation
192     = GetModuleSegmentationByDEId(detElemId, cathod, warn);
193     
194   if ( !moduleSegmentation ) return 0; 
195   
196   return moduleSegmentation->GetDESegmentation(detElemId, warn);
197 }    
198
199 //_____________________________________________________________________________
200 Bool_t 
201 AliMUONSegmentation::HasDE(Int_t detElemId, Int_t cathod) const
202 {
203 /// Return true if segmentation for detElemId and cathod is defined.
204
205   const AliMUONVGeometryDESegmentation* kdeSegmentation
206     = GetDESegmentation(detElemId, cathod, false);
207     
208   return ( kdeSegmentation != 0 ); 
209   
210 }
211
212 //_____________________________________________________________________________
213 TString 
214 AliMUONSegmentation::GetDEName(Int_t detElemId, Int_t cathod) const
215 {
216 /// Get detection element name 
217
218   AliMUONGeometrySegmentation* moduleSegmentation
219     = GetModuleSegmentationByDEId(detElemId, cathod, true);
220     
221   return  moduleSegmentation->GetDEName(detElemId); 
222 }
223
224