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