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>
47 ClassImp(AliMpDetElement)
50 const char AliMpDetElement::fgkNameSeparator = '_';
52 //______________________________________________________________________________
53 AliMpDetElement::AliMpDetElement(Int_t id, const TString& name,
54 const TString& segType, AliMp::PlaneType planeType)
60 fPlaneType(planeType),
67 /// Standard constructor
70 //______________________________________________________________________________
71 AliMpDetElement::AliMpDetElement(TRootIOCtor* ioCtor)
84 /// Root IO constructor
87 //______________________________________________________________________________
88 AliMpDetElement::~AliMpDetElement()
98 //______________________________________________________________________________
99 Bool_t AliMpDetElement::AddBusPatch(Int_t busPatchId)
101 /// Add bus patch Id if a bus patch with the same Id is not yet present;
102 /// return false if bus patch was not added
104 if ( HasBusPatchId(busPatchId) ) {
106 << "Bus patch Id = " << busPatchId << " already present."
111 fBusPatchIds.Add(busPatchId);
115 //______________________________________________________________________________
116 TString AliMpDetElement::GetSegName(AliMp::CathodType cathType) const
118 /// Return the segmentation name for the given catod type
120 return fSegType + fgkNameSeparator + PlaneTypeName(GetPlaneType(cathType));
123 //______________________________________________________________________________
124 AliMp::PlaneType AliMpDetElement::GetPlaneType(AliMp::CathodType cath) const
126 /// Return plane type \n
128 if ( cath == AliMp::kCath0 ) return fPlaneType;
129 else return AliMp::OtherPlaneType(fPlaneType);
132 //______________________________________________________________________________
133 AliMp::CathodType AliMpDetElement::GetCathodType(AliMp::PlaneType planeType) const
135 /// Return cathod type for given planeType
137 if ( fPlaneType == planeType ) return AliMp::kCath0;
138 else return AliMp::kCath1;
141 //______________________________________________________________________________
142 AliMp::CathodType AliMpDetElement::GetCathodTypeFromManuId(Int_t manuId) const
144 /// Return cathod type for given manuId
146 AliMp::PlaneType planeType = AliMp::kBendingPlane;
147 if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) )
149 planeType = AliMp::kNonBendingPlane;
151 return GetCathodType(planeType);
154 //______________________________________________________________________________
155 AliMp::StationType AliMpDetElement::GetStationType() const
157 /// Return station type \n
158 /// Failure causes Fatal error - as AliMp::StationType has no possibility
159 /// to return undefined value
161 Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
162 if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
163 AliFatal("Cannot return AliMp::StationType value.");
164 return AliMp::kStation12;
167 if ( chamberId >= 0 && chamberId <= 3 ) return AliMp::kStation12;
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::kStation12;
176 //______________________________________________________________________________
177 AliMq::Station12Type AliMpDetElement::GetStation12Type() const
179 /// Return station12 type \n
180 /// Failure causes Fatal error - as AliMp::Station12Type has no possibility
181 /// to return undefined value
183 Int_t chamberId = AliMpDEManager::GetChamberId(fId, false);
184 if ( ! AliMpDEManager::IsValidChamberId(chamberId, true) ) {
185 AliFatal("Cannot return AliMp::StationType value.");
186 return AliMq::kNotSt12;
189 if ( chamberId == 0 || chamberId == 1 ) return AliMq::kStation1;
190 if ( chamberId == 2 || chamberId == 3 ) return AliMq::kStation2;
191 if ( chamberId >= 4 || chamberId <= 13 ) return AliMq::kNotSt12;
193 // Should never get to this line
194 AliFatal("Cannot return AliMp::StationType value.");
195 return AliMq::kNotSt12;
198 //______________________________________________________________________________
199 Int_t AliMpDetElement::GetNofBusPatches() const
201 /// Return the number of bus patches in this detection element
203 return fBusPatchIds.GetSize();
206 //______________________________________________________________________________
207 Int_t AliMpDetElement::GetBusPatchId(Int_t index) const
209 /// Return the index-th bus patch
211 if ( index < 0 || index >= GetNofBusPatches() ) {
213 << "In DE = " << fId << ": Index " << index << " outside limits." << endl;
217 return fBusPatchIds.GetValue(index);
221 //______________________________________________________________________________
222 Bool_t AliMpDetElement::HasBusPatchId(Int_t busPatchId) const
224 /// Return true if the bus patch Id is present
226 return fBusPatchIds.HasValue(busPatchId);;
229 //______________________________________________________________________________
231 AliMpDetElement::NofChannelsInManu(Int_t manuId) const
233 /// Return the number of channels in a given manu
235 Long_t uid = AliMpManuUID::BuildUniqueID(fId,manuId);
237 return (Int_t)(fManuList.GetValue(uid));
240 //______________________________________________________________________________
242 AliMpDetElement::IsExistingChannel(Int_t manuId, Int_t manuChannel) const
244 /// Whether or not the channel is a valid one (does not tell if it is
247 if ( NofChannelsInManu(manuId) > 0 &&
249 manuChannel < AliMpConstants::ManuNofChannels() )
259 //______________________________________________________________________________
261 AliMpDetElement::IsConnectedChannel(Int_t manuId, Int_t manuChannel) const
263 /// Whether or not the channel is a *connected* one (i.e. it is valid plus
264 /// it corresponds to a real pad)
266 return ( fTrackerChannels.GetValue(AliMpPadUID::BuildUniqueID(fId,manuId,manuChannel)) > 0 );
269 //______________________________________________________________________________
271 AliMpDetElement::AddManu(Int_t manuId)
273 /// Fills the fManuList and fTrackerChannels
274 AliMp::StationType stationType = AliMpDEManager::GetStationType(fId);
276 if ( stationType == AliMp::kStationTrigger ) return;
278 AliCodeTimerAuto("",0)
280 AliDebug(1,Form("DE %4d Manu %4d",fId,manuId));
282 AliCodeTimerStart(Form("%s",AliMp::StationTypeName(stationType).Data()));
284 if ( fHVmanus.GetSize() == 0 )
286 fHVmanus.SetOwner(kTRUE); // to be 100% explicit
288 // get the size, to avoid resizing when adding later on
291 AliMp::CathodType cathodes[] = { AliMp::kCath0, AliMp::kCath1 };
293 for ( Int_t i = 0; i < 2; ++i )
295 const AliMpVSegmentation* seg =
296 AliMpSegmentation::Instance()->GetMpSegmentation(fId,cathodes[i]);
300 seg->GetAllElectronicCardIDs(manus);
302 nmanus += manus.GetSize();
305 fHVmanus.SetSize(nmanus);
308 const AliMpVSegmentation* seg = AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(fId,manuId);
312 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
314 if ( seg->PadByLocation(manuId,i,kFALSE).IsValid() )
317 fTrackerChannels.Add((Long_t)AliMpPadUID::BuildUniqueID(fId,manuId,i),
322 fManuList.Add(AliMpManuUID::BuildUniqueID(fId,manuId),(Long_t)n);
326 AliMpDCSNamer hvNamer("TRACKER");
328 Int_t index = hvNamer.ManuId2Index(fId,manuId);
330 UInt_t hvuid = AliMpHVUID::BuildUniqueID(fId,index);
332 AliMpArrayI* hv = static_cast<AliMpArrayI*>(fHVmanus.GetValue(hvuid));
337 hv = new AliMpArrayI(sort);
338 fHVmanus.Add(hvuid,hv);
341 hv->Add(manuId,kFALSE);
343 AliCodeTimerStop(Form("%s",AliMp::StationTypeName(stationType).Data()));
346 //______________________________________________________________________________
348 AliMpDetElement::ManusForHV(Int_t hvIndex) const
350 /// Return the list of manus sharing a hv channel
351 return static_cast<AliMpArrayI*>(fHVmanus.GetValue(AliMpHVUID::BuildUniqueID(fId,hvIndex)));
354 //______________________________________________________________________________
356 AliMpDetElement::NofManus() const
358 /// Return the number of manus in this detection element
359 return fManuList.GetSize();