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 //-----------------------------------------------------------------------------
21 // Class AliMpDetElement
22 // --------------------
23 // The class defines the electronics properties of detection element
24 // Authors: Ivana Hrivnacova, IPN Orsay
25 // Laurent Aphecetche, Christian Finck, SUBATECH Nantes
26 //-----------------------------------------------------------------------------
28 #include "AliMpDetElement.h"
30 #include "AliMpArrayI.h"
31 #include "AliMpConstants.h"
32 #include "AliMpDEManager.h"
33 #include "AliMpDCSNamer.h"
34 #include "AliMpHVUID.h"
35 #include "AliMpManuUID.h"
36 #include "AliMpPadUID.h"
37 #include "AliMpSegmentation.h"
38 #include "AliMpVSegmentation.h"
40 #include "AliCodeTimer.h"
43 #include <Riostream.h>
46 ClassImp(AliMpDetElement)
49 const char AliMpDetElement::fgkNameSeparator = '_';
51 //______________________________________________________________________________
52 AliMpDetElement::AliMpDetElement(Int_t id, const TString& name,
53 const TString& segType, AliMp::PlaneType planeType)
59 fPlaneType(planeType),
66 /// Standard constructor
69 //______________________________________________________________________________
70 AliMpDetElement::AliMpDetElement(TRootIOCtor* ioCtor)
83 /// Root IO constructor
86 //______________________________________________________________________________
87 AliMpDetElement::~AliMpDetElement()
97 //______________________________________________________________________________
98 Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId)
100 /// Add bus patch Id if a bus patch with the same Id is not yet present;
101 /// return false if bus patch was not added
103 if ( HasBusPatchId(busPatchId) ) {
105 << "Bus patch Id = " << busPatchId << " already present."
110 fBusPatchIds.Add(busPatchId);
114 //______________________________________________________________________________
115 TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const
117 /// Return the segmentation name for the given catod type
119 return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType));
122 //______________________________________________________________________________
123 AliMp::PlaneType AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const
125 /// Return plane type \n
127 if ( cath == AliMp::kCath0 ) return fPlaneType;
128 else return AliMp::OtherPlaneType(fPlaneType);
131 //______________________________________________________________________________
132 AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const
134 /// Return cathod type for given planeType
136 if ( fPlaneType == planeType ) return AliMp::kCath0;
137 else return AliMp::kCath1;
140 //______________________________________________________________________________
141 AliMp::CathodType AliMpDetElement::GetCathodTypeFromManuId(Int_t manuId) const
143 /// Return cathod type for given manuId
145 AliMp::PlaneType planeType = AliMp::kBendingPlane;
146 if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) )
148 planeType = AliMp::kNonBendingPlane;
150 return GetCathodType(planeType);
153 //______________________________________________________________________________
154 AliMp::StationType AliMpDetElement::GetStationType() const
156 /// Return station type \n
157 /// Failure causes Fatal error - as AliMp::StationType has no possibility
158 /// to return undefined value
160 Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
161 if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
162 AliFatal("Cannot return AliMp::StationType value.");
163 return AliMp::kStation1;
166 if ( chamberId == 0 || chamberId == 1 ) return AliMp::kStation1;
167 if ( chamberId == 2 || chamberId == 3 ) return AliMp::kStation2;
168 if ( chamberId >= 4 && chamberId <= 9 ) return AliMp::kStation345;
169 if ( chamberId >= 10 && chamberId <= 13 ) return AliMp::kStationTrigger;
171 // Should never get to this line
172 AliFatal("Cannot return AliMp::StationType value.");
173 return AliMp::kStation1;
176 //______________________________________________________________________________
177 Int_t AliMpDetElement::GetNofBusPatches() const
179 /// Return the number of bus patches in this detection element
181 return fBusPatchIds.GetSize();
184 //______________________________________________________________________________
185 Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
187 /// Return the index-th bus patch
189 if ( index < 0 || index > GetNofBusPatches() ) {
191 << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
195 return fBusPatchIds.GetValue(index);
199 //______________________________________________________________________________
200 Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
202 /// Return true if the bus patch Id is present
204 return fBusPatchIds.HasValue(busPatchId);;
207 //______________________________________________________________________________
209 AliMpDetElement::NofChannelsInManu(Int_t manuId) const
211 /// Return the number of channels in a given manu
213 Long_t uid = AliMpManuUID::BuildUniqueID(fId,manuId);
215 return (Int_t)(fManuList.GetValue(uid));
218 //______________________________________________________________________________
220 AliMpDetElement::IsExistingChannel(Int_t manuId, Int_t manuChannel) const
222 /// Whether or not the channel is a valid one (does not tell if it is
225 if ( NofChannelsInManu(manuId) > 0 &&
227 manuChannel < AliMpConstants::ManuNofChannels() )
237 //______________________________________________________________________________
239 AliMpDetElement::IsConnectedChannel(Int_t manuId, Int_t manuChannel) const
241 /// Whether or not the channel is a *connected* one (i.e. it is valid plus
242 /// it corresponds to a real pad)
244 return ( fTrackerChannels.GetValue(AliMpPadUID::BuildUniqueID(fId,manuId,manuChannel)) > 0 );
247 //______________________________________________________________________________
249 AliMpDetElement::AddManu(Int_t manuId)
251 /// Fills the fManuList and fTrackerChannels
252 AliMp::StationType stationType = AliMpDEManager::GetStationType(fId);
254 if ( stationType == AliMp::kStationTrigger ) return;
258 AliDebug(1,Form("DE %4d Manu %4d",fId,manuId));
260 AliCodeTimerStart(Form("%s",AliMp::StationTypeName(stationType).Data()));
262 if ( fHVmanus.GetSize() == 0 )
264 fHVmanus.SetOwner(kTRUE); // to be 100% explicit
266 // get the size, to avoid resizing when adding later on
269 AliMp::CathodType cathodes[] = { AliMp::kCath0, AliMp::kCath1 };
271 for ( Int_t i = 0; i < 2; ++i )
273 const AliMpVSegmentation* seg =
274 AliMpSegmentation::Instance()->GetMpSegmentation(fId,cathodes[i]);
278 seg->GetAllElectronicCardIDs(manus);
280 nmanus += manus.GetSize();
283 fHVmanus.SetSize(nmanus);
286 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fId,manuId);
290 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
292 if ( seg->PadByLocation(AliMpIntPair(manuId,i),kFALSE).IsValid() )
295 fTrackerChannels.Add((Long_t)AliMpPadUID::BuildUniqueID(fId,manuId,i),
300 fManuList.Add(AliMpManuUID::BuildUniqueID(fId,manuId),(Long_t)n);
304 AliMpDCSNamer hvNamer("TRACKER");
306 Int_t index = hvNamer.ManuId2Index(fId,manuId);
308 UInt_t hvuid = AliMpHVUID::BuildUniqueID(fId,index);
310 AliMpArrayI* hv = static_cast<AliMpArrayI*>(fHVmanus.GetValue(hvuid));
315 hv = new AliMpArrayI(sort);
316 fHVmanus.Add(hvuid,hv);
319 hv->Add(manuId,kFALSE);
321 AliCodeTimerStop(Form("%s",AliMp::StationTypeName(stationType).Data()));
324 //______________________________________________________________________________
326 AliMpDetElement::ManusForHV(Int_t hvIndex) const
328 /// Return the list of manus sharing a hv channel
329 return static_cast<AliMpArrayI*>(fHVmanus.GetValue(AliMpHVUID::BuildUniqueID(fId,hvIndex)));
332 //______________________________________________________________________________
334 AliMpDetElement::NofManus() const
336 /// Return the number of manus in this detection element
337 return fManuList.GetSize();