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