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),
61 fManuToSerialNbs(1700),
62 fSerialNbToManus(1700),
64 fTrackerChannels(1700*AliMpConstants::ManuNofChannels()),
67 /// Standard constructor
70 //______________________________________________________________________________
71 AliMpDetElement::AliMpDetElement(TRootIOCtor* /*ioCtor*/)
82 fTrackerChannels(true),
85 /// Root IO constructor
88 //______________________________________________________________________________
89 AliMpDetElement::~AliMpDetElement()
99 //______________________________________________________________________________
100 Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId)
102 /// Add bus patch Id if a bus patch with the same Id is not yet present;
103 /// return false if bus patch was not added
105 if ( HasBusPatchId(busPatchId) ) {
107 << "Bus patch Id = " << busPatchId << " already present."
112 fBusPatchIds.Add(busPatchId);
116 //______________________________________________________________________________
117 void AliMpDetElement::AddManuSerial(Int_t manuId, Int_t serialNb)
119 /// Map the serial manu number
120 /// (Eventually add check if the given pair already present)
122 AliCodeTimerAuto("");
124 AliDebug(1,Form("DE %4d ManuId %4d SerialNB %d",
125 fId,manuId,serialNb));
127 fManuToSerialNbs.Add(Long_t(manuId), Long_t(serialNb));
128 fSerialNbToManus.Add(Long_t(serialNb), Long_t(manuId));
131 //______________________________________________________________________________
132 TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const
134 /// Return the segmentation name for the given catod type
136 return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType));
139 //______________________________________________________________________________
140 AliMp::PlaneType AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const
142 /// Return plane type \n
144 if ( cath == AliMp::kCath0 ) return fPlaneType;
145 else return AliMp::OtherPlaneType(fPlaneType);
148 //______________________________________________________________________________
149 AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const
151 /// Return cathod type for given planeType
153 if ( fPlaneType == planeType ) return AliMp::kCath0;
154 else return AliMp::kCath1;
157 //______________________________________________________________________________
158 AliMp::CathodType AliMpDetElement::GetCathodTypeFromManuId(Int_t manuId) const
160 /// Return cathod type for given manuId
162 AliMp::PlaneType planeType = AliMp::kBendingPlane;
163 if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) )
165 planeType = AliMp::kNonBendingPlane;
167 return GetCathodType(planeType);
170 //______________________________________________________________________________
171 AliMp::StationType AliMpDetElement::GetStationType() const
173 /// Return station type \n
174 /// Failure causes Fatal error - as AliMp::StationType has no possibility
175 /// to return undefined value
177 Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
178 if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
179 AliFatal("Cannot return AliMp::StationType value.");
180 return AliMp::kStation1;
183 if ( chamberId == 0 || chamberId == 1 ) return AliMp::kStation1;
184 if ( chamberId == 2 || chamberId == 3 ) return AliMp::kStation2;
185 if ( chamberId >= 4 && chamberId <= 9 ) return AliMp::kStation345;
186 if ( chamberId >= 10 && chamberId <= 13 ) return AliMp::kStationTrigger;
188 // Should never get to this line
189 AliFatal("Cannot return AliMp::StationType value.");
190 return AliMp::kStation1;
193 //______________________________________________________________________________
194 Int_t AliMpDetElement::GetNofBusPatches() const
196 /// Return the number of bus patches in this detection element
198 return fBusPatchIds.GetSize();
201 //______________________________________________________________________________
202 Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
204 /// Return the index-th bus patch
206 if ( index < 0 || index > GetNofBusPatches() ) {
208 << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
212 return fBusPatchIds.GetValue(index);
216 //______________________________________________________________________________
217 Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
219 /// Return true if the bus patch Id is present
221 return fBusPatchIds.HasValue(busPatchId);;
224 //______________________________________________________________________________
225 Int_t AliMpDetElement::GetManuSerialFromId(Int_t manuId) const
227 /// Return manu serial number from manuId
229 return (Int_t)fManuToSerialNbs.GetValue(Long_t(manuId));
232 //______________________________________________________________________________
233 Int_t AliMpDetElement::GetManuIdFromSerial(Int_t serialNb) const
235 /// Return manuId from manu serial number
237 return (Int_t)fSerialNbToManus.GetValue(Long_t(serialNb));
240 //______________________________________________________________________________
242 AliMpDetElement::NofChannelsInManu(Int_t manuId) const
244 /// Return the number of channels in a given manu
246 Long_t uid = AliMpManuUID::BuildUniqueID(fId,manuId);
248 return (Int_t)(fManuList.GetValue(uid));
251 //______________________________________________________________________________
253 AliMpDetElement::IsExistingChannel(Int_t manuId, Int_t manuChannel) const
255 /// Whether or not the channel is a valid one (does not tell if it is
258 if ( NofChannelsInManu(manuId) > 0 &&
260 manuChannel < AliMpConstants::ManuNofChannels() )
270 //______________________________________________________________________________
272 AliMpDetElement::IsConnectedChannel(Int_t manuId, Int_t manuChannel) const
274 /// Whether or not the channel is a *connected* one (i.e. it is valid plus
275 /// it corresponds to a real pad)
277 return ( fTrackerChannels.GetValue(AliMpPadUID::BuildUniqueID(fId,manuId,manuChannel)) > 0 );
280 //______________________________________________________________________________
282 AliMpDetElement::AddManu(Int_t manuId)
284 /// Fills the fManuList and fTrackerChannels
285 AliMp::StationType stationType = AliMpDEManager::GetStationType(fId);
287 if ( stationType == AliMp::kStationTrigger ) return;
291 AliDebug(1,Form("DE %4d Manu %4d",fId,manuId));
293 AliCodeTimerStart(Form("%s",AliMp::StationTypeName(stationType).Data()));
295 if ( fHVmanus.GetSize() == 0 )
297 fHVmanus.SetOwner(kTRUE); // to be 100% explicit
299 // get the size, to avoid resizing when adding later on
302 AliMp::CathodType cathodes[] = { AliMp::kCath0, AliMp::kCath1 };
304 for ( Int_t i = 0; i < 2; ++i )
306 const AliMpVSegmentation* seg =
307 AliMpSegmentation::Instance()->GetMpSegmentation(fId,cathodes[i]);
311 seg->GetAllElectronicCardIDs(manus);
313 nmanus += manus.GetSize();
316 fHVmanus.SetSize(nmanus);
319 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fId,manuId);
323 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
325 if ( seg->PadByLocation(AliMpIntPair(manuId,i),kFALSE).IsValid() )
328 fTrackerChannels.Add((Long_t)AliMpPadUID::BuildUniqueID(fId,manuId,i),
333 fManuList.Add(AliMpManuUID::BuildUniqueID(fId,manuId),(Long_t)n);
335 AliMpHVNamer hvNamer;
337 Int_t index = hvNamer.ManuId2Index(fId,manuId);
339 UInt_t hvuid = AliMpHVUID::BuildUniqueID(fId,index);
341 AliMpArrayI* hv = static_cast<AliMpArrayI*>(fHVmanus.GetValue(hvuid));
346 hv = new AliMpArrayI(sort);
347 fHVmanus.Add(hvuid,hv);
350 hv->Add(manuId,kFALSE);
352 AliCodeTimerStop(Form("%s",AliMp::StationTypeName(stationType).Data()));
355 //______________________________________________________________________________
357 AliMpDetElement::ManusForHV(Int_t hvIndex) const
359 /// Return the list of manus sharing a hv channel
360 return static_cast<AliMpArrayI*>(fHVmanus.GetValue(AliMpHVUID::BuildUniqueID(fId,hvIndex)));
363 //______________________________________________________________________________
365 AliMpDetElement::NofManusWithSerialNumber() const
367 /// Return the number of manus which have a serial number in this detection element
368 return fManuToSerialNbs.GetSize();
371 //______________________________________________________________________________
373 AliMpDetElement::NofManus() const
375 /// Return the number of manus in this detection element
376 return fManuList.GetSize();