]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpDetElement.cxx
Addung a method GetCathodTypeFromManuId (Laurent)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpDetElement.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: AliMpDetElement.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
18 // Category: management
19 //
20 // Class AliMpDetElement
21 // --------------------
22 // The class defines the electronics properties of detection element
23 // Authors: Ivana Hrivnacova, IPN Orsay
24 //          Laurent Aphecetche, Christian Finck, SUBATECH Nantes
25
26 #include "AliMpDetElement.h"
27
28 #include "AliMpConstants.h"
29 #include "AliMpDEManager.h"
30 #include "AliLog.h"
31 #include <Riostream.h>
32
33 /// \cond CLASSIMP
34 ClassImp(AliMpDetElement)
35 /// \endcond
36
37 const char  AliMpDetElement::fgkNameSeparator = '_'; 
38
39 //______________________________________________________________________________
40 AliMpDetElement::AliMpDetElement(Int_t id, const TString& name,
41                     const TString& segType, AliMp::PlaneType planeType)
42   : TObject(),
43     fId(id),
44     fDdlId(-1),
45     fName(name),
46     fSegType(segType),
47     fPlaneType(planeType),
48     fBusPatchIds(false),
49     fManuToSerialNbs(1700),
50     fSerialNbToManus(1700)
51 {
52 /// Standard constructor
53
54 }
55
56 //______________________________________________________________________________
57 AliMpDetElement::AliMpDetElement(TRootIOCtor* /*ioCtor*/)
58   : TObject(),
59     fId(0),
60     fDdlId(-1),
61     fName(),
62     fSegType(),
63     fPlaneType(),
64     fBusPatchIds(),
65     fManuToSerialNbs(),
66     fSerialNbToManus()
67 {
68 /// Root IO constructor
69 }
70
71 //______________________________________________________________________________
72 AliMpDetElement::~AliMpDetElement()
73 {
74 /// Destructor
75 }
76
77
78 //
79 // public methods
80 //
81
82 //______________________________________________________________________________
83 Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId)
84 {
85 /// Add bus patch Id if a bus patch with the same Id is not yet present;
86 /// return false if bus patch was not added
87
88   if ( HasBusPatchId(busPatchId) ) {
89     AliWarningStream() 
90       << "Bus patch Id = " << busPatchId << " already present."
91       << endl;
92     return false;
93   } 
94
95   fBusPatchIds.Add(busPatchId); 
96   return true;
97 }  
98  
99 //______________________________________________________________________________
100 void AliMpDetElement::AddManuSerial(Int_t manuId, Int_t serialNb)
101 {
102 /// Map the serial manu number 
103 /// (Eventually add check if the given pair already present)
104
105   fManuToSerialNbs.Add(Long_t(manuId), Long_t(serialNb)); 
106   fSerialNbToManus.Add(Long_t(serialNb), Long_t(manuId));
107 }      
108
109 //______________________________________________________________________________
110 TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const
111 {
112 /// Return the segmentation name for the given catod type
113
114   return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType));
115 }         
116
117 //______________________________________________________________________________
118 AliMp::PlaneType  AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const 
119 {
120 /// Return plane type                                                      \n
121
122   if ( cath == AliMp::kCath0 ) return fPlaneType;
123   else                         return AliMp::OtherPlaneType(fPlaneType); 
124 }    
125
126 //______________________________________________________________________________
127 AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const
128 {
129 /// Return cathod type for given planeType
130
131   if ( fPlaneType == planeType ) return AliMp::kCath0;
132   else                           return AliMp::kCath1;
133 }
134
135 //______________________________________________________________________________
136 AliMp::CathodType AliMpDetElement::GetCathodTypeFromManuId(Int_t manuId) const
137 {
138 /// Return cathod type for given manuId
139
140   AliMp::PlaneType planeType = AliMp::kBendingPlane;
141   if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) 
142   {
143     planeType = AliMp::kNonBendingPlane;
144   }
145   return GetCathodType(planeType);
146 }
147
148 //______________________________________________________________________________
149 AliMp::StationType AliMpDetElement::GetStationType() const
150 {
151 /// Return station type                                                      \n
152 /// Failure causes Fatal error - as AliMp::StationType has no possibility
153 /// to return undefined value
154
155   Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
156   if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
157     AliFatal("Cannot return AliMp::StationType value.");
158     return AliMp::kStation1;
159   }  
160   
161   if ( chamberId ==  0 || chamberId ==  1 )  return AliMp::kStation1;
162   if ( chamberId ==  2 || chamberId ==  3 )  return AliMp::kStation2;
163   if ( chamberId >=  4 && chamberId <=  9 )  return AliMp::kStation345;
164   if ( chamberId >= 10 && chamberId <= 13 )  return AliMp::kStationTrigger;
165
166   // Should never get to this line
167   AliFatal("Cannot return AliMp::StationType value.");
168   return AliMp::kStation1;
169 }
170
171 //______________________________________________________________________________
172 Int_t AliMpDetElement::GetNofBusPatches() const
173 {
174 /// Return the number of bus patches in this detection element
175
176   return fBusPatchIds.GetSize();
177 }  
178
179 //______________________________________________________________________________
180 Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
181 {
182 /// Return the index-th bus patch
183
184   if ( index < 0 || index > GetNofBusPatches() ) {
185     AliErrorStream()
186       << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
187     return 0;
188   }     
189
190   return  fBusPatchIds.GetValue(index);
191 }   
192
193
194 //______________________________________________________________________________
195 Bool_t  AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
196 {  
197 /// Return true if the bus patch Id is present
198
199   return fBusPatchIds.HasValue(busPatchId);; 
200 }
201
202 //______________________________________________________________________________
203 Int_t  AliMpDetElement::GetNofManus() const
204 {
205 /// Return the number of manus in this detection element  
206
207   return fManuToSerialNbs.GetSize();
208 }   
209
210 //______________________________________________________________________________
211 Int_t  AliMpDetElement::GetManuSerialFromId(Int_t manuId) const
212 {
213 /// Return manu serial number from manuId
214
215   return (Int_t)fManuToSerialNbs.GetValue(Long_t(manuId));
216 }
217
218 //______________________________________________________________________________
219 Int_t  AliMpDetElement::GetManuIdFromSerial(Int_t serialNb) const
220 {
221 /// Return manuId from manu serial number
222   
223   return (Int_t)fSerialNbToManus.GetValue(Long_t(serialNb));
224 }
225