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