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 "AliMpHVNamer.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),
68 /// Standard constructor
71 //______________________________________________________________________________
72 AliMpDetElement::AliMpDetElement(TRootIOCtor* ioCtor)
87 /// Root IO constructor
90 //______________________________________________________________________________
91 AliMpDetElement::~AliMpDetElement()
101 //______________________________________________________________________________
102 Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId)
104 /// Add bus patch Id if a bus patch with the same Id is not yet present;
105 /// return false if bus patch was not added
107 if ( HasBusPatchId(busPatchId) ) {
109 << "Bus patch Id = " << busPatchId << " already present."
114 fBusPatchIds.Add(busPatchId);
118 //______________________________________________________________________________
119 void AliMpDetElement::AddManuSerial(Int_t manuId, Int_t serialNb)
121 /// Map the serial manu number
122 /// (Eventually add check if the given pair already present)
124 AliCodeTimerAuto("");
126 AliDebug(1,Form("DE %4d ManuId %4d SerialNB %d",
127 fId,manuId,serialNb));
129 fManuToSerialNbs.Add(Long_t(manuId), Long_t(serialNb));
130 fSerialNbToManus.Add(Long_t(serialNb), Long_t(manuId));
133 //______________________________________________________________________________
134 TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const
136 /// Return the segmentation name for the given catod type
138 return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType));
141 //______________________________________________________________________________
142 AliMp::PlaneType AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const
144 /// Return plane type \n
146 if ( cath == AliMp::kCath0 ) return fPlaneType;
147 else return AliMp::OtherPlaneType(fPlaneType);
150 //______________________________________________________________________________
151 AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const
153 /// Return cathod type for given planeType
155 if ( fPlaneType == planeType ) return AliMp::kCath0;
156 else return AliMp::kCath1;
159 //______________________________________________________________________________
160 AliMp::CathodType AliMpDetElement::GetCathodTypeFromManuId(Int_t manuId) const
162 /// Return cathod type for given manuId
164 AliMp::PlaneType planeType = AliMp::kBendingPlane;
165 if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) )
167 planeType = AliMp::kNonBendingPlane;
169 return GetCathodType(planeType);
172 //______________________________________________________________________________
173 AliMp::StationType AliMpDetElement::GetStationType() const
175 /// Return station type \n
176 /// Failure causes Fatal error - as AliMp::StationType has no possibility
177 /// to return undefined value
179 Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
180 if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
181 AliFatal("Cannot return AliMp::StationType value.");
182 return AliMp::kStation1;
185 if ( chamberId == 0 || chamberId == 1 ) return AliMp::kStation1;
186 if ( chamberId == 2 || chamberId == 3 ) return AliMp::kStation2;
187 if ( chamberId >= 4 && chamberId <= 9 ) return AliMp::kStation345;
188 if ( chamberId >= 10 && chamberId <= 13 ) return AliMp::kStationTrigger;
190 // Should never get to this line
191 AliFatal("Cannot return AliMp::StationType value.");
192 return AliMp::kStation1;
195 //______________________________________________________________________________
196 Int_t AliMpDetElement::GetNofBusPatches() const
198 /// Return the number of bus patches in this detection element
200 return fBusPatchIds.GetSize();
203 //______________________________________________________________________________
204 Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
206 /// Return the index-th bus patch
208 if ( index < 0 || index > GetNofBusPatches() ) {
210 << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
214 return fBusPatchIds.GetValue(index);
218 //______________________________________________________________________________
219 Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
221 /// Return true if the bus patch Id is present
223 return fBusPatchIds.HasValue(busPatchId);;
226 //______________________________________________________________________________
227 Int_t AliMpDetElement::GetManuSerialFromId(Int_t manuId) const
229 /// Return manu serial number from manuId
231 return (Int_t)fManuToSerialNbs.GetValue(Long_t(manuId));
234 //______________________________________________________________________________
235 Int_t AliMpDetElement::GetManuIdFromSerial(Int_t serialNb) const
237 /// Return manuId from manu serial number
239 return (Int_t)fSerialNbToManus.GetValue(Long_t(serialNb));
242 //______________________________________________________________________________
244 AliMpDetElement::NofChannelsInManu(Int_t manuId) const
246 /// Return the number of channels in a given manu
248 Long_t uid = AliMpManuUID::BuildUniqueID(fId,manuId);
250 return (Int_t)(fManuList.GetValue(uid));
253 //______________________________________________________________________________
255 AliMpDetElement::IsExistingChannel(Int_t manuId, Int_t manuChannel) const
257 /// Whether or not the channel is a valid one (does not tell if it is
260 if ( NofChannelsInManu(manuId) > 0 &&
262 manuChannel < AliMpConstants::ManuNofChannels() )
272 //______________________________________________________________________________
274 AliMpDetElement::IsConnectedChannel(Int_t manuId, Int_t manuChannel) const
276 /// Whether or not the channel is a *connected* one (i.e. it is valid plus
277 /// it corresponds to a real pad)
279 return ( fTrackerChannels.GetValue(AliMpPadUID::BuildUniqueID(fId,manuId,manuChannel)) > 0 );
282 //______________________________________________________________________________
284 AliMpDetElement::AddManu(Int_t manuId)
286 /// Fills the fManuList and fTrackerChannels
287 AliMp::StationType stationType = AliMpDEManager::GetStationType(fId);
289 if ( stationType == AliMp::kStationTrigger ) return;
293 AliDebug(1,Form("DE %4d Manu %4d",fId,manuId));
295 AliCodeTimerStart(Form("%s",AliMp::StationTypeName(stationType).Data()));
297 if ( fHVmanus.GetSize() == 0 )
299 fHVmanus.SetOwner(kTRUE); // to be 100% explicit
301 // get the size, to avoid resizing when adding later on
304 AliMp::CathodType cathodes[] = { AliMp::kCath0, AliMp::kCath1 };
306 for ( Int_t i = 0; i < 2; ++i )
308 const AliMpVSegmentation* seg =
309 AliMpSegmentation::Instance()->GetMpSegmentation(fId,cathodes[i]);
313 seg->GetAllElectronicCardIDs(manus);
315 nmanus += manus.GetSize();
318 fHVmanus.SetSize(nmanus);
321 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fId,manuId);
325 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
327 if ( seg->PadByLocation(AliMpIntPair(manuId,i),kFALSE).IsValid() )
330 fTrackerChannels.Add((Long_t)AliMpPadUID::BuildUniqueID(fId,manuId,i),
335 fManuList.Add(AliMpManuUID::BuildUniqueID(fId,manuId),(Long_t)n);
339 AliMpHVNamer hvNamer;
341 Int_t index = hvNamer.ManuId2Index(fId,manuId);
343 UInt_t hvuid = AliMpHVUID::BuildUniqueID(fId,index);
345 AliMpArrayI* hv = static_cast<AliMpArrayI*>(fHVmanus.GetValue(hvuid));
350 hv = new AliMpArrayI(sort);
351 fHVmanus.Add(hvuid,hv);
354 hv->Add(manuId,kFALSE);
356 AliCodeTimerStop(Form("%s",AliMp::StationTypeName(stationType).Data()));
359 //______________________________________________________________________________
361 AliMpDetElement::ManusForHV(Int_t hvIndex) const
363 /// Return the list of manus sharing a hv channel
364 return static_cast<AliMpArrayI*>(fHVmanus.GetValue(AliMpHVUID::BuildUniqueID(fId,hvIndex)));
367 //______________________________________________________________________________
369 AliMpDetElement::NofManusWithSerialNumber() const
371 /// Return the number of manus which have a serial number in this detection element
372 return fManuToSerialNbs.GetSize();
375 //______________________________________________________________________________
377 AliMpDetElement::NofManus() const
379 /// Return the number of manus in this detection element
380 return fManuList.GetSize();