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: AliMpDetElement.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
18 // Category: management
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
26 #include "AliMpDetElement.h"
28 #include "AliMpConstants.h"
29 #include "AliMpDEManager.h"
31 #include <Riostream.h>
34 ClassImp(AliMpDetElement)
37 const char AliMpDetElement::fgkNameSeparator = '_';
39 //______________________________________________________________________________
40 AliMpDetElement::AliMpDetElement(Int_t id, const TString& name,
41 const TString& segType, AliMp::PlaneType planeType)
47 fPlaneType(planeType),
49 fManuToSerialNbs(1700),
50 fSerialNbToManus(1700)
52 /// Standard constructor
56 //______________________________________________________________________________
57 AliMpDetElement::AliMpDetElement(TRootIOCtor* /*ioCtor*/)
68 /// Root IO constructor
71 //______________________________________________________________________________
72 AliMpDetElement::~AliMpDetElement()
82 //______________________________________________________________________________
83 Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId)
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
88 if ( HasBusPatchId(busPatchId) ) {
90 << "Bus patch Id = " << busPatchId << " already present."
95 fBusPatchIds.Add(busPatchId);
99 //______________________________________________________________________________
100 void AliMpDetElement::AddManuSerial(Int_t manuId, Int_t serialNb)
102 /// Map the serial manu number
103 /// (Eventually add check if the given pair already present)
105 fManuToSerialNbs.Add(Long_t(manuId), Long_t(serialNb));
106 fSerialNbToManus.Add(Long_t(serialNb), Long_t(manuId));
109 //______________________________________________________________________________
110 TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const
112 /// Return the segmentation name for the given catod type
114 return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType));
117 //______________________________________________________________________________
118 AliMp::PlaneType AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const
120 /// Return plane type \n
122 if ( cath == AliMp::kCath0 ) return fPlaneType;
123 else return AliMp::OtherPlaneType(fPlaneType);
126 //______________________________________________________________________________
127 AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const
129 /// Return cathod type for given planeType
131 if ( fPlaneType == planeType ) return AliMp::kCath0;
132 else return AliMp::kCath1;
135 //______________________________________________________________________________
136 AliMp::CathodType AliMpDetElement::GetCathodTypeFromManuId(Int_t manuId) const
138 /// Return cathod type for given manuId
140 AliMp::PlaneType planeType = AliMp::kBendingPlane;
141 if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) )
143 planeType = AliMp::kNonBendingPlane;
145 return GetCathodType(planeType);
148 //______________________________________________________________________________
149 AliMp::StationType AliMpDetElement::GetStationType() const
151 /// Return station type \n
152 /// Failure causes Fatal error - as AliMp::StationType has no possibility
153 /// to return undefined value
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;
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;
166 // Should never get to this line
167 AliFatal("Cannot return AliMp::StationType value.");
168 return AliMp::kStation1;
171 //______________________________________________________________________________
172 Int_t AliMpDetElement::GetNofBusPatches() const
174 /// Return the number of bus patches in this detection element
176 return fBusPatchIds.GetSize();
179 //______________________________________________________________________________
180 Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
182 /// Return the index-th bus patch
184 if ( index < 0 || index > GetNofBusPatches() ) {
186 << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
190 return fBusPatchIds.GetValue(index);
194 //______________________________________________________________________________
195 Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
197 /// Return true if the bus patch Id is present
199 return fBusPatchIds.HasValue(busPatchId);;
202 //______________________________________________________________________________
203 Int_t AliMpDetElement::GetNofManus() const
205 /// Return the number of manus in this detection element
207 return fManuToSerialNbs.GetSize();
210 //______________________________________________________________________________
211 Int_t AliMpDetElement::GetManuSerialFromId(Int_t manuId) const
213 /// Return manu serial number from manuId
215 return (Int_t)fManuToSerialNbs.GetValue(Long_t(manuId));
218 //______________________________________________________________________________
219 Int_t AliMpDetElement::GetManuIdFromSerial(Int_t serialNb) const
221 /// Return manuId from manu serial number
223 return (Int_t)fSerialNbToManus.GetValue(Long_t(serialNb));