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::kStation12;
166 if ( chamberId >= 0 && chamberId <= 3 ) return AliMp::kStation12;
167 if ( chamberId >= 4 && chamberId <= 9 ) return AliMp::kStation345;
168 if ( chamberId >= 10 && chamberId <= 13 ) return AliMp::kStationTrigger;
170 // Should never get to this line
171 AliFatal("Cannot return AliMp::StationType value.");
172 return AliMp::kStation12;
175 //______________________________________________________________________________
176 AliMq::Station12Type AliMpDetElement::GetStation12Type() const
178 /// Return station12 type \n
179 /// Failure causes Fatal error - as AliMp::Station12Type has no possibility
180 /// to return undefined value
182 Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
183 if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
184 AliFatal("Cannot return AliMp::StationType value.");
185 return AliMq::kNotSt12;
188 if ( chamberId == 0 || chamberId == 1 ) return AliMq::kStation1;
189 if ( chamberId == 2 || chamberId == 3 ) return AliMq::kStation2;
190 if ( chamberId >= 4 || chamberId <= 13 ) return AliMq::kNotSt12;
192 // Should never get to this line
193 AliFatal("Cannot return AliMp::StationType value.");
194 return AliMq::kNotSt12;
197 //______________________________________________________________________________
198 Int_t AliMpDetElement::GetNofBusPatches() const
200 /// Return the number of bus patches in this detection element
202 return fBusPatchIds.GetSize();
205 //______________________________________________________________________________
206 Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
208 /// Return the index-th bus patch
210 if ( index < 0 || index >= GetNofBusPatches() ) {
212 << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
216 return fBusPatchIds.GetValue(index);
220 //______________________________________________________________________________
221 Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
223 /// Return true if the bus patch Id is present
225 return fBusPatchIds.HasValue(busPatchId);;
228 //______________________________________________________________________________
230 AliMpDetElement::NofChannelsInManu(Int_t manuId) const
232 /// Return the number of channels in a given manu
234 Long_t uid = AliMpManuUID::BuildUniqueID(fId,manuId);
236 return (Int_t)(fManuList.GetValue(uid));
239 //______________________________________________________________________________
241 AliMpDetElement::IsExistingChannel(Int_t manuId, Int_t manuChannel) const
243 /// Whether or not the channel is a valid one (does not tell if it is
246 if ( NofChannelsInManu(manuId) > 0 &&
248 manuChannel < AliMpConstants::ManuNofChannels() )
258 //______________________________________________________________________________
260 AliMpDetElement::IsConnectedChannel(Int_t manuId, Int_t manuChannel) const
262 /// Whether or not the channel is a *connected* one (i.e. it is valid plus
263 /// it corresponds to a real pad)
265 return ( fTrackerChannels.GetValue(AliMpPadUID::BuildUniqueID(fId,manuId,manuChannel)) > 0 );
268 //______________________________________________________________________________
270 AliMpDetElement::AddManu(Int_t manuId)
272 /// Fills the fManuList and fTrackerChannels
273 AliMp::StationType stationType = AliMpDEManager::GetStationType(fId);
275 if ( stationType == AliMp::kStationTrigger ) return;
277 AliCodeTimerAuto("",0)
279 AliDebug(1,Form("DE %4d Manu %4d",fId,manuId));
281 AliCodeTimerStart(Form("%s",AliMp::StationTypeName(stationType).Data()));
283 if ( fHVmanus.GetSize() == 0 )
285 fHVmanus.SetOwner(kTRUE); // to be 100% explicit
287 // get the size, to avoid resizing when adding later on
290 AliMp::CathodType cathodes[] = { AliMp::kCath0, AliMp::kCath1 };
292 for ( Int_t i = 0; i < 2; ++i )
294 const AliMpVSegmentation* seg =
295 AliMpSegmentation::Instance()->GetMpSegmentation(fId,cathodes[i]);
299 seg->GetAllElectronicCardIDs(manus);
301 nmanus += manus.GetSize();
304 fHVmanus.SetSize(nmanus);
307 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fId,manuId);
311 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
313 if ( seg->PadByLocation(manuId,i,kFALSE).IsValid() )
316 fTrackerChannels.Add((Long_t)AliMpPadUID::BuildUniqueID(fId,manuId,i),
321 fManuList.Add(AliMpManuUID::BuildUniqueID(fId,manuId),(Long_t)n);
325 AliMpDCSNamer hvNamer("TRACKER");
327 Int_t index = hvNamer.ManuId2Index(fId,manuId);
329 UInt_t hvuid = AliMpHVUID::BuildUniqueID(fId,index);
331 AliMpArrayI* hv = static_cast<AliMpArrayI*>(fHVmanus.GetValue(hvuid));
336 hv = new AliMpArrayI(sort);
337 fHVmanus.Add(hvuid,hv);
340 hv->Add(manuId,kFALSE);
342 AliCodeTimerStop(Form("%s",AliMp::StationTypeName(stationType).Data()));
345 //______________________________________________________________________________
347 AliMpDetElement::ManusForHV(Int_t hvIndex) const
349 /// Return the list of manus sharing a hv channel
350 return static_cast<AliMpArrayI*>(fHVmanus.GetValue(AliMpHVUID::BuildUniqueID(fId,hvIndex)));
353 //______________________________________________________________________________
355 AliMpDetElement::NofManus() const
357 /// Return the number of manus in this detection element
358 return fManuList.GetSize();