]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpDEManager.cxx
In SetNofManusPerModule(): return false if no action
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpDEManager.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
16 // $Id$
17 // $MpId: AliMpDEManager.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
18 // Category: management
19 //
20 // Class AliMpDEManager
21 // --------------------
22 // The manager class for definition of detection element types
23 // Authors: Ivana Hrivnacova, IPN Orsay
24 //          Laurent Aphecetche, SUBATECH Nantes
25
26 #include "AliMpDEManager.h"
27 #include "AliMpDEStore.h"
28 #include "AliMpDetElement.h"
29 #include "AliMpConstants.h"
30 #include "AliMpCathodType.h"
31
32 #include "AliLog.h"
33
34 #include <Riostream.h>
35 #include <TClass.h>
36 //#include <TSystem.h>
37 //#include <TObjString.h>
38 //#include <TMap.h>
39
40 /// \cond CLASSIMP
41 ClassImp(AliMpDEManager)
42 /// \endcond
43
44 const Int_t AliMpDEManager::fgkCoefficient = 100;
45 TArrayI     AliMpDEManager::fgNofDEPerChamber;
46
47 //______________________________________________________________________________
48
49 AliMpDEManager::~AliMpDEManager()
50 {
51 /// Destructor
52 }
53
54 //
55 // static private methods
56 //
57
58 //______________________________________________________________________________
59 AliMpDetElement* AliMpDEManager::GetDetElement(Int_t detElemId, Bool_t warn)
60 {
61 /// Return det element for given detElemId
62
63   return AliMpDEStore::Instance()->GetDetElement(detElemId, warn);
64 }    
65
66 //______________________________________________________________________________
67 AliMpDetElement* AliMpDEManager::GetDetElement(const TString& deName, Bool_t warn)
68 {
69 /// Return det element for given deName
70
71   return AliMpDEStore::Instance()->GetDetElement(deName, warn);
72 }    
73
74 //
75 // static public methods
76 //
77
78 //______________________________________________________________________________
79 Bool_t AliMpDEManager::IsValidDetElemId(Int_t detElemId, Bool_t warn)
80 {
81 /// Return true if detElemId is valid
82 /// (is present in the DE map)
83
84   if ( GetDetElement(detElemId, warn) ) return true;
85
86   return false;
87 }    
88
89 //______________________________________________________________________________
90 Bool_t AliMpDEManager::IsValidChamberId(Int_t chamberId, Bool_t warn)
91 {
92 /// Return true if chamberId is valid
93
94   if ( chamberId >= 0 && chamberId < AliMpConstants::NofChambers() ) 
95     return true;
96  
97   if (warn) 
98     AliErrorClassStream() << "Wrong chamber Id " << chamberId << endl;
99   
100   return false;
101 }    
102
103 //______________________________________________________________________________
104 Bool_t AliMpDEManager::IsValidGeomModuleId(Int_t moduleId, Bool_t warn)
105 {
106 /// Return true if moduleId is valid
107
108   if ( moduleId >= 0 && moduleId < AliMpConstants::NofGeomModules() ) 
109     return true;
110  
111   if (warn) 
112     AliErrorClassStream() << "Wrong module Id " << moduleId << endl;
113   
114   return false;
115 }    
116
117 //______________________________________________________________________________
118 Int_t  AliMpDEManager::GetChamberId(Int_t detElemId, Bool_t warn)
119 {
120 /// Return chamber Id for given detElemId
121
122   if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
123   
124   return detElemId/fgkCoefficient - 1;
125 }  
126
127 //______________________________________________________________________________
128 Int_t AliMpDEManager::GetGeomModuleId(Int_t detElemId, Bool_t warn)
129 {
130 /// <pre>
131 /// Get module Id from detection element Id                 
132 /// !!! moduleId != chamberId
133 /// Station 1:   Chamber:  1   Module:  0   Det elements:  100-103
134 ///              Chamber:  2   Module:  1   Det elements:  200-203
135 /// Station 2:   Chamber:  3   Module:  2   Det elements:  300-303
136 ///              Chamber:  4   Module:  3   Det elements:  400-403
137 /// Station 3:   Chamber:  5   Module:  4   Det elements:  500-504, 514-517
138 ///                            Module:  5   Det elements:  505-513,
139 ///              Chamber:  6   Module:  6   Det elements:  600-604, 614-617
140 ///                            Module:  7   Det elements:  605-613
141 /// Station 4:   Chamber:  7   Module:  8   Det elements:  700-706, 720-725
142 ///                            Module:  9   Det elements:  707-719
143 ///              Chamber:  8   Module: 10   Det elements:  800-806, 820-825
144 ///                            Module: 11   Det elements:  807-819
145 /// Station 5:   Chamber:  9   Module: 12   Det elements:  900-906, 920-925
146 ///                            Module: 13   Det elements:  907-919        
147 ///              Chamber: 10   Module: 14   Det elements: 1000-1006,1020-1025
148 ///                            Module: 15   Det elements: 1007-1019
149 /// Station 6:   Chamber: 11   Module: 16   Det elements: 1100-1117
150 ///              Chamber: 12   Module: 17   Det elements: 1200-1217
151 /// Station 7:   Chamber: 13   Module: 18   Det elements: 1300-1317
152 ///              Chamber: 14   Module: 19   Det elements: 1400-1417
153 /// </pre>
154
155   if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
156   
157   return detElemId/fgkCoefficient 
158            + (detElemId >=  505 && detElemId <=  513 || detElemId >= 600 )
159            + (detElemId >=  605 && detElemId <=  613 || detElemId >= 700 )
160            + (detElemId >=  707 && detElemId <=  719 || detElemId >= 800 )
161            + (detElemId >=  807 && detElemId <=  819 || detElemId >= 900 )
162            + (detElemId >=  907 && detElemId <=  919 || detElemId >= 1000 )
163            + (detElemId >= 1007 && detElemId <= 1019 || detElemId >= 1100 ) - 1;
164 }  
165
166 //______________________________________________________________________________
167 AliMp::PlaneType  AliMpDEManager::GetPlaneType(Int_t detElemId, AliMp::CathodType cath)
168 {
169 /// Return plane type                                                      \n
170 /// Failure causes Fatal error - as AliMp::PlaneType has no possibility
171 /// to return undefined value
172
173   if ( ! IsValidDetElemId(detElemId, true) ) {
174     AliFatalClass("Cannot return AliMp::PlaneType value.");
175     return AliMp::kBendingPlane;
176   }  
177
178   return GetDetElement(detElemId)->GetPlaneType(cath);
179 }    
180
181 //______________________________________________________________________________
182 AliMp::StationType AliMpDEManager::GetStationType(Int_t detElemId)
183 {
184 /// Return station type                                                      \n
185 /// Failure causes Fatal error - as AliMp::StationType has no possibility
186 /// to return undefined value
187
188   if ( ! IsValidDetElemId(detElemId, true) ) {
189     AliFatalClass("Cannot return AliMp::StationType value.");
190     return AliMp::kStation1;
191   }  
192   
193   return GetDetElement(detElemId)->GetStationType();
194 }
195
196 //______________________________________________________________________________
197 AliMp::CathodType 
198 AliMpDEManager::GetCathod(Int_t detElemId, AliMp::PlaneType planeType)
199 {
200 /// Return cathod number for given detElemId and planeType
201
202   if ( ! IsValidDetElemId(detElemId, true) ) {
203     AliFatalClass("Cannot return AliMp::CathodType value.");
204     return AliMp::kCath0;
205   }  
206   
207   return GetDetElement(detElemId)->GetCathodType(planeType);
208 }
209
210 //______________________________________________________________________________
211 Int_t AliMpDEManager::GetNofDEInChamber(Int_t chamberId, Bool_t warn)
212 {
213 /// Return the number of detection elements in the chamber with the given 
214 /// chamberId
215
216   if ( ! IsValidChamberId(chamberId,warn) ) return 0;
217
218   // Fill array if it is empty
219   if ( ! fgNofDEPerChamber.GetSize() ) {
220     fgNofDEPerChamber.Set(AliMpConstants::NofChambers());
221     AliMpDEIterator it;
222     for ( Int_t i=0; i<AliMpConstants::NofChambers(); i++ ) {
223       Int_t counter = 0;
224       for ( it.First(i); ! it.IsDone(); it.Next() ) ++counter;
225       fgNofDEPerChamber[i] = counter;
226     }  
227   }
228   
229   return fgNofDEPerChamber[chamberId];    
230
231 }
232