]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpBusPatch.cxx
Updated for modifs in AliMpFiles
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpBusPatch.cxx
CommitLineData
1e738c3c 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16// $Id$
17// $MpId: $
18// Category: basic
19//
20// Class AliMpBusPatch
21// ---------------
22// Class that manages the maps buspatch<>DDL<>DE
23// for the mapping
24// Calculates also the maximum DSP and buspatch numbers for a given DE
25//
26// Author: Ch. Finck; Subatech Nantes
27
28#include "AliMpBusPatch.h"
29#include "AliMpFiles.h"
30#include "AliMpHelper.h"
31
32#include "AliLog.h"
33
34#include <Riostream.h>
35
36ClassImp(AliMpBusPatch)
37
38//////////////////////////////////////////////////////////
39//
40// This class contains the informations about buspatch vs (DE-DDL)
41//
42//////////////////////////////////////////////////////////
43
44
45//_____________________________________________________________________________
46AliMpBusPatch::AliMpBusPatch()
47 : TObject(),
48 fDetElemIdToBusPatch(300),
49 fBusPatchToDetElem(300),
50 fBusPatchToDDL(300)
51{
52/// Default constructor
53
54 for (Int_t i = 0; i < 10; i++)
55 fMaxBusPerCh[i] = 0;
56
57}
58
59
60//_____________________________________________________________________________
61AliMpBusPatch::AliMpBusPatch(const AliMpBusPatch& rhs)
62 : TObject(rhs)
63{
64/// Copy constructor
65
66 *this = rhs;
67}
68
69//_____________________________________________________________________________
70AliMpBusPatch::~AliMpBusPatch()
71{
72/// Destructor
73
74 fDetElemIdToBusPatch.Delete();
75 fBusPatchToDetElem.Delete();
76 fBusPatchToDDL.Delete();
77}
78
79//_____________________________________________________________________________
80AliMpBusPatch& AliMpBusPatch::operator = (const AliMpBusPatch& /*rhs*/)
81{
82/// Assignment operator
83
84 AliFatal("= operator not implemented");
85
86 return *this;
87}
88
89//____________________________________________________________________
90Int_t AliMpBusPatch::GetDEfromBus(Int_t busPatchId)
91{
92 /// getting DE id from bus patch
93 Long_t it = fBusPatchToDetElem.GetValue(busPatchId);
94
95 if ( it )
96 return (Int_t)it;
97 else
98 return -1;
99}
100
101//____________________________________________________________________
102TArrayI* AliMpBusPatch::GetBusfromDE(Int_t idDE)
103{
104/// getting bus patch from DE id
105
106 return (TArrayI*)fDetElemIdToBusPatch.GetValue(idDE);
107}
108//____________________________________________________________________
109Int_t AliMpBusPatch::GetDDLfromBus(Int_t busPatchId)
110{
111/// getting DE id from bus patch
112 Long_t it = fBusPatchToDDL.GetValue(busPatchId);
113
114 if ( it )
115 return (Int_t)it;
116 else
117 return -1;
118}
119
120//____________________________________________________________________
121void AliMpBusPatch::GetDspInfo(Int_t iCh, Int_t& iDspMax, Int_t* iBusPerDSP)
122{
123/// calculates the number of DSP & buspatch per block
124
125 Int_t iBusPerBlk = fMaxBusPerCh[iCh]/4; //per half chamber; per block
126
127 iDspMax = iBusPerBlk/5; //number max of DSP per block
128 if (iBusPerBlk % 5 != 0)
129 iDspMax += 1;
130
131 for (Int_t i = 0; i < iDspMax; i++) {
132 if ((iBusPerBlk -= 5) > 0)
133 iBusPerDSP[i] = 5;
134 else
135 iBusPerDSP[i] = iBusPerBlk + 5;
136 }
137
138}
139//____________________________________________________________________
140void AliMpBusPatch::ReadBusPatchFile()
141{
142/// idDE <> buspatch <> iDDL map's
143
144 TString infile = AliMpFiles::BusPatchFilePath();
145
146 ifstream in(infile, ios::in);
147 if (!in) AliError("DetElemIdToBusPatch.dat not found.");
148
149 char line[80];
150
151 Int_t iChprev = 1;
152 Int_t maxBusPatch = 0;
153
154 while ( in.getline(line,80) ) {
155
156 if ( line[0] == '#' ) continue;
157
158 TString tmp(AliMpHelper::Normalize(line));
159
160 Int_t blankPos = tmp.First(' ');
161 Int_t blankPos1 = tmp.Last(' ');
162
163 TString sDE(tmp(0, blankPos));
164
165 Int_t idDE = atoi(sDE.Data());
166
167 if (idDE/100 != iChprev) {
168 fMaxBusPerCh[iChprev-1] = maxBusPatch-iChprev*100+1;
169 iChprev = idDE/100;
170 }
171
172 TString sDDL(tmp(blankPos1 + 1, tmp.Length()-blankPos1));
173
174 Int_t iDDL = atoi(sDDL.Data());
175
176 TString busPatch(tmp(blankPos + 1,blankPos1-blankPos-1));
177 AliDebug(3,Form("idDE %d buspatch %s iDDL %d\n", idDE, busPatch.Data(), iDDL));
178
179 TArrayI busPatchList;
180 // decoding range of buspatch
181 AliMpHelper::DecodeName(busPatch,';',busPatchList);
182
183 // filling buspatch -> idDE
184 for (Int_t i = 0; i < busPatchList.GetSize(); i++) {
185 fBusPatchToDetElem.Add((Long_t)busPatchList[i],(Long_t)idDE);
186 fBusPatchToDDL.Add((Long_t)busPatchList[i],(Long_t)iDDL);
187 maxBusPatch = busPatchList[i];
188 }
189
190 // filling idDE -> buspatch list (vector)
191 fDetElemIdToBusPatch.Add((Long_t)idDE, (Long_t)(new TArrayI(busPatchList)));
192
193 }
194
195 fMaxBusPerCh[iChprev-1] = maxBusPatch-iChprev*100+1;
196
197 in.close();
198
199}