AliRoot Core  ee782a0 (ee782a0)
AliMpDEManager.cxx
Go to the documentation of this file.
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 //-----------------------------------------------------------------------------
21 // Class AliMpDEManager
22 // --------------------
23 // The manager class for definition of detection element types
24 // Authors: Ivana Hrivnacova, IPN Orsay
25 // Laurent Aphecetche, SUBATECH Nantes
26 //-----------------------------------------------------------------------------
27 
28 #include "AliMpDEManager.h"
29 #include "AliMpDEStore.h"
30 #include "AliMpDetElement.h"
31 #include "AliMpConstants.h"
32 #include "AliMpCathodType.h"
33 #include "AliMpEncodePair.h"
34 
35 #include "AliLog.h"
36 
37 #include <Riostream.h>
38 #include <TClass.h>
39 
40 using std::endl;
42 ClassImp(AliMpDEManager)
44 
45 const Int_t AliMpDEManager::fgkCoefficient = 100;
46 
47 //
48 // static private methods
49 //
50 //______________________________________________________________________________
51 TArrayI& AliMpDEManager::GetNofDEPerChamber()
52 {
54  static TArrayI nofDEPerChamber;
55  return nofDEPerChamber;
56 }
57 
58 //
59 // static public methods
60 //
61 
62 //______________________________________________________________________________
63 AliMpDetElement* AliMpDEManager::GetDetElement(Int_t detElemId, Bool_t warn)
64 {
66 
67  return AliMpDEStore::Instance()->GetDetElement(detElemId, warn);
68 }
69 
70 //______________________________________________________________________________
71 AliMpDetElement* AliMpDEManager::GetDetElement(const TString& deName, Bool_t warn)
72 {
74 
75  return AliMpDEStore::Instance()->GetDetElement(deName, warn);
76 }
77 
78 //
79 // static public methods
80 //
81 
82 //______________________________________________________________________________
83 Bool_t AliMpDEManager::IsValidDetElemId(Int_t detElemId, Bool_t warn)
84 {
87 
88  if ( GetDetElement(detElemId, warn) ) return true;
89 
90  return false;
91 }
92 
93 //______________________________________________________________________________
94 Bool_t AliMpDEManager::IsValidChamberId(Int_t chamberId, Bool_t warn)
95 {
97 
98  if ( chamberId >= 0 && chamberId < AliMpConstants::NofChambers() )
99  return true;
100 
101  if (warn)
102  AliErrorClassStream() << "Wrong chamber Id " << chamberId << endl;
103 
104  return false;
105 }
106 
107 //______________________________________________________________________________
108 Bool_t AliMpDEManager::IsValidGeomModuleId(Int_t moduleId, Bool_t warn)
109 {
111 
112  if ( moduleId >= 0 && moduleId < AliMpConstants::NofGeomModules() )
113  return true;
114 
115  if (warn)
116  AliErrorClassStream() << "Wrong module Id " << moduleId << endl;
117 
118  return false;
119 }
120 
121 //______________________________________________________________________________
122 Int_t AliMpDEManager::GetChamberId(Int_t detElemId, Bool_t warn)
123 {
125 
126  if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
127 
128  return detElemId/fgkCoefficient - 1;
129 }
130 
131 //______________________________________________________________________________
132 Int_t AliMpDEManager::GetGeomModuleId(Int_t detElemId, Bool_t warn)
133 {
158 
159  if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
160 
161  return detElemId/fgkCoefficient
162  + ((detElemId >= 505 && detElemId <= 513) || detElemId >= 600 )
163  + ((detElemId >= 605 && detElemId <= 613) || detElemId >= 700 )
164  + ((detElemId >= 707 && detElemId <= 719) || detElemId >= 800 )
165  + ((detElemId >= 807 && detElemId <= 819) || detElemId >= 900 )
166  + ((detElemId >= 907 && detElemId <= 919) || detElemId >= 1000 )
167  + ((detElemId >= 1007 && detElemId <= 1019) || detElemId >= 1100 ) - 1;
168 }
169 
170 //______________________________________________________________________________
172 {
176 
177  if ( ! IsValidDetElemId(detElemId, true) ) {
178  AliFatalClass("Cannot return AliMp::PlaneType value.");
179  return AliMp::kBendingPlane;
180  }
181 
182  return GetDetElement(detElemId)->GetPlaneType(cath);
183 }
184 
185 //______________________________________________________________________________
187 {
191 
192  if ( ! IsValidDetElemId(detElemId, true) ) {
193  AliFatalClass("Cannot return AliMp::StationType value.");
194  return AliMp::kStation12;
195  }
196 
197  return GetDetElement(detElemId)->GetStationType();
198 }
199 
200 //______________________________________________________________________________
202 {
206 
207  if ( ! IsValidDetElemId(detElemId, true) ) {
208  AliFatalClass("Cannot return AliMp::Station12Type value.");
209  return AliMq::kNotSt12;
210  }
211 
212  return GetDetElement(detElemId)->GetStation12Type();
213 }
214 
215 //______________________________________________________________________________
217 AliMpDEManager::GetCathod(Int_t detElemId, AliMp::PlaneType planeType)
218 {
220 
221  if ( ! IsValidDetElemId(detElemId, true) ) {
222  AliFatalClass("Cannot return AliMp::CathodType value.");
223  return AliMp::kCath0;
224  }
225 
226  return GetDetElement(detElemId)->GetCathodType(planeType);
227 }
228 
229 //______________________________________________________________________________
230 Int_t AliMpDEManager::GetNofDEInChamber(Int_t chamberId, Bool_t warn)
231 {
234 
235  if ( ! IsValidChamberId(chamberId,warn) ) return 0;
236 
237  // Fill array if it is empty
238  if ( ! GetNofDEPerChamber().GetSize() ) {
240  AliMpDEIterator it;
241  for ( Int_t i=0; i<AliMpConstants::NofChambers(); i++ ) {
242  Int_t counter = 0;
243  for ( it.First(i); ! it.IsDone(); it.Next() ) ++counter;
244  GetNofDEPerChamber()[i] = counter;
245  }
246  }
247 
248  return GetNofDEPerChamber()[chamberId];
249 
250 }
251 
252 //______________________________________________________________________________
254 {
257 
258  if ( ! IsValidChamberId(chamberId) ) return 0;
259 
260  return AliMp::Pair(
261  (chamberId+1)*fgkCoefficient,
262  (chamberId+1)*fgkCoefficient + GetNofDEInChamber(chamberId) - 1);
263 
264 }
265 
266 //
267 // ctors, dtor
268 //
269 
270 //______________________________________________________________________________
272 {
274 }
275 
static AliMq::Station12Type GetStation12Type(Int_t detElemId)
static Int_t NofChambers()
Return number of chambers.
The iterator over detection elements.
static Bool_t IsValidGeomModuleId(Int_t moduleId, Bool_t warn=false)
station 1,2 (quadrants)
#define AliErrorClassStream()
Definition: AliLog.h:631
static AliMpDEStore * Instance(Bool_t warn=true)
static const Int_t fgkCoefficient
Coefficient used in DE Id <-> station.
static AliMp::CathodType GetCathod(Int_t detElemId, AliMp::PlaneType planeType)
AliMq::Station12Type GetStation12Type() const
Bool_t IsDone() const
AliMp::StationType GetStationType() const
static MpPair_t GetDetElemIdRange(Int_t chamberId)
MpPair_t Pair(Int_t first, Int_t second)
Encode the pair of integers to another integer.
static Int_t GetGeomModuleId(Int_t detElemId, Bool_t warn=true)
AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
The class defines the electronics properties of detection element.
#define AliFatalClass(message)
Definition: AliLog.h:645
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
static TArrayI & GetNofDEPerChamber()
static Int_t GetNofDEInChamber(Int_t chamberId, Bool_t warn=true)
static Int_t NofGeomModules()
Return number of geometry modules.
static AliMp::StationType GetStationType(Int_t detElemId)
AliMp::PlaneType GetPlaneType(AliMp::CathodType cath) const
static AliMp::PlaneType GetPlaneType(Int_t detElemId, AliMp::CathodType cath)
bending plane
value for all non sector stations
The manager class for definition of detection element types.
AliMp::CathodType GetCathodType(AliMp::PlaneType planeType) const
Int_t MpPair_t
static Bool_t IsValidChamberId(Int_t chamberId, Bool_t warn=false)
virtual ~AliMpDEManager()
static AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true)
static Bool_t IsValidDetElemId(Int_t detElemId, Bool_t warn=false)