1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpDEManager.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
18 // Category: management
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 //-----------------------------------------------------------------------------
28 #include "AliMpDEManager.h"
29 #include "AliMpDEStore.h"
30 #include "AliMpDetElement.h"
31 #include "AliMpConstants.h"
32 #include "AliMpCathodType.h"
36 #include <Riostream.h>
40 ClassImp(AliMpDEManager)
43 const Int_t AliMpDEManager::fgkCoefficient = 100;
44 TArrayI AliMpDEManager::fgNofDEPerChamber;
46 //______________________________________________________________________________
48 AliMpDEManager::~AliMpDEManager()
54 // static private methods
57 //______________________________________________________________________________
58 AliMpDetElement* AliMpDEManager::GetDetElement(Int_t detElemId, Bool_t warn)
60 /// Return det element for given detElemId
62 return AliMpDEStore::Instance()->GetDetElement(detElemId, warn);
65 //______________________________________________________________________________
66 AliMpDetElement* AliMpDEManager::GetDetElement(const TString& deName, Bool_t warn)
68 /// Return det element for given deName
70 return AliMpDEStore::Instance()->GetDetElement(deName, warn);
74 // static public methods
77 //______________________________________________________________________________
78 Bool_t AliMpDEManager::IsValidDetElemId(Int_t detElemId, Bool_t warn)
80 /// Return true if detElemId is valid
81 /// (is present in the DE map)
83 if ( GetDetElement(detElemId, warn) ) return true;
88 //______________________________________________________________________________
89 Bool_t AliMpDEManager::IsValidChamberId(Int_t chamberId, Bool_t warn)
91 /// Return true if chamberId is valid
93 if ( chamberId >= 0 && chamberId < AliMpConstants::NofChambers() )
97 AliErrorClassStream() << "Wrong chamber Id " << chamberId << endl;
102 //______________________________________________________________________________
103 Bool_t AliMpDEManager::IsValidGeomModuleId(Int_t moduleId, Bool_t warn)
105 /// Return true if moduleId is valid
107 if ( moduleId >= 0 && moduleId < AliMpConstants::NofGeomModules() )
111 AliErrorClassStream() << "Wrong module Id " << moduleId << endl;
116 //______________________________________________________________________________
117 Int_t AliMpDEManager::GetChamberId(Int_t detElemId, Bool_t warn)
119 /// Return chamber Id for given detElemId
121 if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
123 return detElemId/fgkCoefficient - 1;
126 //______________________________________________________________________________
127 Int_t AliMpDEManager::GetGeomModuleId(Int_t detElemId, Bool_t warn)
130 /// Get module Id from detection element Id
131 /// !!! moduleId != chamberId
132 /// Station 1: Chamber: 1 Module: 0 Det elements: 100-103
133 /// Chamber: 2 Module: 1 Det elements: 200-203
134 /// Station 2: Chamber: 3 Module: 2 Det elements: 300-303
135 /// Chamber: 4 Module: 3 Det elements: 400-403
136 /// Station 3: Chamber: 5 Module: 4 Det elements: 500-504, 514-517
137 /// Module: 5 Det elements: 505-513,
138 /// Chamber: 6 Module: 6 Det elements: 600-604, 614-617
139 /// Module: 7 Det elements: 605-613
140 /// Station 4: Chamber: 7 Module: 8 Det elements: 700-706, 720-725
141 /// Module: 9 Det elements: 707-719
142 /// Chamber: 8 Module: 10 Det elements: 800-806, 820-825
143 /// Module: 11 Det elements: 807-819
144 /// Station 5: Chamber: 9 Module: 12 Det elements: 900-906, 920-925
145 /// Module: 13 Det elements: 907-919
146 /// Chamber: 10 Module: 14 Det elements: 1000-1006,1020-1025
147 /// Module: 15 Det elements: 1007-1019
148 /// Station 6: Chamber: 11 Module: 16 Det elements: 1100-1117
149 /// Chamber: 12 Module: 17 Det elements: 1200-1217
150 /// Station 7: Chamber: 13 Module: 18 Det elements: 1300-1317
151 /// Chamber: 14 Module: 19 Det elements: 1400-1417
154 if ( ! IsValidDetElemId(detElemId, warn) ) return -1;
156 return detElemId/fgkCoefficient
157 + (detElemId >= 505 && detElemId <= 513 || detElemId >= 600 )
158 + (detElemId >= 605 && detElemId <= 613 || detElemId >= 700 )
159 + (detElemId >= 707 && detElemId <= 719 || detElemId >= 800 )
160 + (detElemId >= 807 && detElemId <= 819 || detElemId >= 900 )
161 + (detElemId >= 907 && detElemId <= 919 || detElemId >= 1000 )
162 + (detElemId >= 1007 && detElemId <= 1019 || detElemId >= 1100 ) - 1;
165 //______________________________________________________________________________
166 AliMp::PlaneType AliMpDEManager::GetPlaneType(Int_t detElemId, AliMp::CathodType cath)
168 /// Return plane type \n
169 /// Failure causes Fatal error - as AliMp::PlaneType has no possibility
170 /// to return undefined value
172 if ( ! IsValidDetElemId(detElemId, true) ) {
173 AliFatalClass("Cannot return AliMp::PlaneType value.");
174 return AliMp::kBendingPlane;
177 return GetDetElement(detElemId)->GetPlaneType(cath);
180 //______________________________________________________________________________
181 AliMp::StationType AliMpDEManager::GetStationType(Int_t detElemId)
183 /// Return station type \n
184 /// Failure causes Fatal error - as AliMp::StationType has no possibility
185 /// to return undefined value
187 if ( ! IsValidDetElemId(detElemId, true) ) {
188 AliFatalClass("Cannot return AliMp::StationType value.");
189 return AliMp::kStation1;
192 return GetDetElement(detElemId)->GetStationType();
195 //______________________________________________________________________________
197 AliMpDEManager::GetCathod(Int_t detElemId, AliMp::PlaneType planeType)
199 /// Return cathod number for given detElemId and planeType
201 if ( ! IsValidDetElemId(detElemId, true) ) {
202 AliFatalClass("Cannot return AliMp::CathodType value.");
203 return AliMp::kCath0;
206 return GetDetElement(detElemId)->GetCathodType(planeType);
209 //______________________________________________________________________________
210 Int_t AliMpDEManager::GetNofDEInChamber(Int_t chamberId, Bool_t warn)
212 /// Return the number of detection elements in the chamber with the given
215 if ( ! IsValidChamberId(chamberId,warn) ) return 0;
217 // Fill array if it is empty
218 if ( ! fgNofDEPerChamber.GetSize() ) {
219 fgNofDEPerChamber.Set(AliMpConstants::NofChambers());
221 for ( Int_t i=0; i<AliMpConstants::NofChambers(); i++ ) {
223 for ( it.First(i); ! it.IsDone(); it.Next() ) ++counter;
224 fgNofDEPerChamber[i] = counter;
228 return fgNofDEPerChamber[chamberId];
232 //______________________________________________________________________________
233 AliMpIntPair AliMpDEManager::GetDetElemIdRange(Int_t chamberId)
235 /// Return the detection element Id range for given chamberId
237 if ( ! IsValidChamberId(chamberId) ) return AliMpIntPair::Invalid();
240 (chamberId+1)*fgkCoefficient,
241 (chamberId+1)*fgkCoefficient + GetNofDEInChamber(chamberId) - 1);