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: AliMpBusPatch.cxx,v 1.3 2006/03/17 11:51:34 ivana Exp $
18 // Category: management
20 // Class AliMpBusPatch
22 // Class that manages the maps buspatch<>DDL<>DE
24 // Calculates also the maximum DSP and buspatch numbers for a given DE
26 // Author: Ch. Finck; Subatech Nantes
28 #include "AliMpBusPatch.h"
29 #include "AliMpFiles.h"
30 #include "AliMpHelper.h"
35 #include "Riostream.h"
37 ClassImp(AliMpBusPatch)
39 //////////////////////////////////////////////////////////
41 // This class contains the informations about buspatch vs (DE-DDL)
43 //////////////////////////////////////////////////////////
46 //_____________________________________________________________________________
47 AliMpBusPatch::AliMpBusPatch()
49 fDetElemIdToBusPatch(300),
50 fBusPatchToDetElem(300),
53 /// Default constructor
55 for (Int_t i = 0; i < 10; i++)
61 //_____________________________________________________________________________
62 AliMpBusPatch::AliMpBusPatch(const AliMpBusPatch& rhs)
70 //_____________________________________________________________________________
71 AliMpBusPatch::~AliMpBusPatch()
75 fDetElemIdToBusPatch.Delete();
76 fBusPatchToDetElem.Delete();
77 fBusPatchToDDL.Delete();
80 //_____________________________________________________________________________
81 AliMpBusPatch& AliMpBusPatch::operator = (const AliMpBusPatch& /*rhs*/)
83 /// Assignment operator
85 AliFatal("= operator not implemented");
90 //____________________________________________________________________
91 Int_t AliMpBusPatch::GetDEfromBus(Int_t busPatchId)
93 /// getting DE id from bus patch
94 Long_t it = fBusPatchToDetElem.GetValue(busPatchId);
102 //____________________________________________________________________
103 TArrayI* AliMpBusPatch::GetBusfromDE(Int_t idDE)
105 /// getting bus patch from DE id
107 return (TArrayI*)fDetElemIdToBusPatch.GetValue(idDE);
109 //____________________________________________________________________
110 Int_t AliMpBusPatch::GetDDLfromBus(Int_t busPatchId)
112 /// getting DE id from bus patch
113 Long_t it = fBusPatchToDDL.GetValue(busPatchId);
121 //____________________________________________________________________
122 void AliMpBusPatch::GetDspInfo(Int_t iCh, Int_t& iDspMax, Int_t* iBusPerDSP)
125 /// calculates the number of DSP & buspatch per block
127 Int_t iBusPerBlk = fMaxBusPerCh[iCh]/4; //per half chamber; per block
129 iDspMax = iBusPerBlk/5; //number max of DSP per block
130 if (iBusPerBlk % 5 != 0)
133 for (Int_t i = 0; i < iDspMax; i++) {
134 if ((iBusPerBlk -= 5) > 0)
137 iBusPerDSP[i] = iBusPerBlk + 5;
141 //____________________________________________________________________
142 void AliMpBusPatch::ReadBusPatchFile()
144 /// idDE <> buspatch <> iDDL map's
146 TString infile = AliMpFiles::BusPatchFilePath();
148 ifstream in(infile, ios::in);
149 if (!in) AliError("DetElemIdToBusPatch.dat not found.");
154 Int_t maxBusPatch = 0;
156 while ( in.getline(line,80) ) {
158 if ( line[0] == '#' ) continue;
160 TString tmp(AliMpHelper::Normalize(line));
162 Int_t blankPos = tmp.First(' ');
163 Int_t blankPos1 = tmp.Last(' ');
165 TString sDE(tmp(0, blankPos));
167 Int_t idDE = atoi(sDE.Data());
169 if (idDE/100 != iChprev) {
170 fMaxBusPerCh[iChprev-1] = maxBusPatch-iChprev*100+1;
174 TString sDDL(tmp(blankPos1 + 1, tmp.Length()-blankPos1));
176 Int_t iDDL = atoi(sDDL.Data());
178 TString busPatch(tmp(blankPos + 1,blankPos1-blankPos-1));
179 AliDebug(3,Form("idDE %d buspatch %s iDDL %d\n", idDE, busPatch.Data(), iDDL));
181 TArrayI busPatchList;
182 // decoding range of buspatch
183 AliMpHelper::DecodeName(busPatch,';',busPatchList);
185 // filling buspatch -> idDE
186 for (Int_t i = 0; i < busPatchList.GetSize(); i++) {
187 fBusPatchToDetElem.Add((Long_t)busPatchList[i],(Long_t)idDE);
188 fBusPatchToDDL.Add((Long_t)busPatchList[i],(Long_t)iDDL);
189 maxBusPatch = busPatchList[i];
192 // filling idDE -> buspatch list (vector)
193 fDetElemIdToBusPatch.Add((Long_t)idDE, (Long_t)(new TArrayI(busPatchList)));
197 fMaxBusPerCh[iChprev-1] = maxBusPatch-iChprev*100+1;