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"
27 #include "AliMpDEManager.h"
31 #include <TObjString.h>
32 #include <Riostream.h>
35 ClassImp(AliMpDetElement)
38 const char AliMpDetElement::fgkNameSeparator = '_';
40 //______________________________________________________________________________
41 AliMpDetElement::AliMpDetElement(Int_t id, const TString& name,
42 const TString& segType, AliMp::PlaneType planeType)
48 fPlaneType(planeType),
50 fManuToSerialNbs(1700),
51 fSerialNbToManus(1700)
53 /// Standard constructor
57 //______________________________________________________________________________
58 AliMpDetElement::AliMpDetElement(TRootIOCtor* /*ioCtor*/)
69 /// Root IO constructor
72 //______________________________________________________________________________
73 AliMpDetElement::~AliMpDetElement()
83 //______________________________________________________________________________
84 Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId)
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
89 if ( HasBusPatchId(busPatchId) ) {
91 << "Bus patch Id = " << busPatchId << " already present."
96 fBusPatchIds.Add(busPatchId);
100 //______________________________________________________________________________
101 void AliMpDetElement::AddManuSerial(Int_t manuId, Int_t serialNb)
103 /// Map the serial manu number
104 /// (Eventually add check if the given pair already present)
106 fManuToSerialNbs.Add(Long_t(manuId), Long_t(serialNb));
107 fSerialNbToManus.Add(Long_t(serialNb), Long_t(manuId));
110 //______________________________________________________________________________
111 TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const
113 /// Return the segmentation name for the given catod type
115 return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType));
118 //______________________________________________________________________________
119 AliMp::PlaneType AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const
121 /// Return plane type \n
123 if ( cath == AliMp::kCath0 ) return fPlaneType;
124 else return AliMp::OtherPlaneType(fPlaneType);
127 //______________________________________________________________________________
128 AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const
130 /// Return cathod type for given planeType
132 if ( fPlaneType == planeType ) return AliMp::kCath0;
133 else return AliMp::kCath1;
136 //______________________________________________________________________________
137 AliMp::StationType AliMpDetElement::GetStationType() const
139 /// Return station type \n
140 /// Failure causes Fatal error - as AliMp::StationType has no possibility
141 /// to return undefined value
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;
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;
154 // Should never get to this line
155 AliFatal("Cannot return AliMp::StationType value.");
156 return AliMp::kStation1;
159 //______________________________________________________________________________
160 Int_t AliMpDetElement::GetNofBusPatches() const
162 /// Return the number of bus patches in this detection element
164 return fBusPatchIds.GetSize();
167 //______________________________________________________________________________
168 Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
170 /// Return the index-th bus patch
172 if ( index < 0 || index > GetNofBusPatches() ) {
174 << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
178 return fBusPatchIds.GetValue(index);
182 //______________________________________________________________________________
183 Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
185 /// Return true if the bus patch Id is present
187 return fBusPatchIds.HasValue(busPatchId);;
190 //______________________________________________________________________________
191 Int_t AliMpDetElement::GetNofManus() const
193 /// Return the number of manus in this detection element
195 return fManuToSerialNbs.GetSize();
198 //______________________________________________________________________________
199 Int_t AliMpDetElement::GetManuSerialFromId(Int_t manuId) const
201 /// Return manu serial number from manuId
203 return (Int_t)fManuToSerialNbs.GetValue(Long_t(manuId));
206 //______________________________________________________________________________
207 Int_t AliMpDetElement::GetManuIdFromSerial(Int_t serialNb) const
209 /// Return manuId from manu serial number
211 return (Int_t)fSerialNbToManus.GetValue(Long_t(serialNb));