]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpLocalBoard.cxx
GetPosition corrected (Philippe C.)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpLocalBoard.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
17 //
18 // --------------------
19 // Class AliMpLocalBoard
20 // --------------------
21 // The class defines the properties of local board
22 // Author: Ch. Finck, Subatech Nantes
23
24 #include "AliMpLocalBoard.h"
25 #include "AliMpConstants.h"
26 #include "AliMpIntPair.h"
27
28 #include "AliLog.h"
29
30 #include <TString.h>
31 #include <Riostream.h>
32
33 /// \cond CLASSIMP
34 ClassImp(AliMpLocalBoard)
35 /// \endcond
36
37
38 //_____________________________________________________________________________
39 AliMpLocalBoard::AliMpLocalBoard(Int_t id, const Char_t* name, Int_t slot)
40     : TNamed(name, "mapping trigger local board"),
41       fId(id),
42       fSlot(slot),
43       fTC(true),
44       fCrate(),
45       fSwitches(false),
46       fNotified(true),
47       fDEId(false)
48
49 {
50 /// Default constructor
51 }
52
53 //______________________________________________________________________________
54 AliMpLocalBoard::AliMpLocalBoard(TRootIOCtor* /*ioCtor*/)
55     : TNamed(),
56       fId(),
57       fSlot(),
58       fTC(),
59       fCrate(),
60       fSwitches(),
61       fNotified(),
62       fDEId()
63 {
64 /// Root IO constructor
65 }
66
67
68 //_____________________________________________________________________________
69 AliMpLocalBoard::~AliMpLocalBoard() 
70 {
71 /// Destructor
72
73 }
74
75 //_____________________________________________________________________________
76 Int_t AliMpLocalBoard::GetIndex(Int_t chamberId) const
77 {
78 /// Return the index from chamver Id.
79 /// chamberId could range from 10-13 in absolute value
80 /// chamberId could also range from 0-3 in relative value
81
82    Int_t index = chamberId;
83    
84    if ( chamberId >= AliMpConstants::NofTrackingChambers() && 
85         chamberId <  AliMpConstants::NofChambers() )
86    {
87        index -= AliMpConstants::NofTrackingChambers();
88    } 
89
90    if (index < 0 || index >=  AliMpConstants::NofTriggerChambers() ) 
91    {
92      AliError(Form("chamber# %d not a valid trigger chamber Id, [0-3] or [10-13]", chamberId));
93      return -1;
94    }
95
96    return index;
97 }
98
99
100 //______________________________________________________________________________
101 Bool_t AliMpLocalBoard::AddDE(Int_t detElemId)
102 {
103 /// Add detection element with given detElemId.
104 /// Return true if the detection element was added
105
106  if ( HasDEId(detElemId) ) {
107     AliWarningStream() 
108       << "Detection element Id = " << detElemId << " already present."
109       << endl;
110     return false;
111  }
112
113   fDEId.Add(detElemId);
114   return true;
115 }   
116
117
118 //______________________________________________________________________________
119 Int_t AliMpLocalBoard::GetNofDEs() const
120 {  
121 /// Return the number of detection elements connected to this crate
122
123   return fDEId.GetSize(); 
124 }
125
126 //______________________________________________________________________________
127 Int_t  AliMpLocalBoard::GetDEId(Int_t index) const
128 {  
129 /// Return the detection element by index (in loop)
130
131   return fDEId.GetValue(index); 
132 }
133
134 //______________________________________________________________________________
135 Int_t  AliMpLocalBoard::GetDEIdByChamber(Int_t chamberId) const
136 {  
137 /// Return the detection element by index (in loop)
138
139   return fDEId.GetValue(GetIndex(chamberId)); 
140 }
141
142 //______________________________________________________________________________
143 Bool_t  AliMpLocalBoard::HasDEId(Int_t detElemId) const
144 {  
145 /// Return true if the detection element Id is present
146
147   return fDEId.HasValue(detElemId); 
148 }
149
150 //______________________________________________________________________________
151 Bool_t AliMpLocalBoard::AddSwitch(Int_t swit)
152 {
153 /// Add a swicth for the given local board
154 /// Return true if switch was added
155
156     if ( swit > 1 ) {
157       AliWarningStream() 
158           << "Invalid value for switch = " << swit 
159           << endl;
160       return false;
161     }
162
163     fSwitches.Add(swit);
164     return true;
165 }   
166
167
168 //______________________________________________________________________________
169 Int_t AliMpLocalBoard::GetNofSwitches() const
170 {  
171 /// Return the number switches in this local board
172
173   return fSwitches.GetSize(); 
174 }
175
176 //______________________________________________________________________________
177 Int_t  AliMpLocalBoard::GetSwitch(Int_t index) const
178 {
179 /// Return switch by index (in loop)
180
181     if (index < fSwitches.GetSize())
182         return fSwitches.GetValue(index);
183     else 
184         AliWarning("Switch index too large");
185
186     return -1;
187 }
188
189 //______________________________________________________________________________
190 AliMpIntPair AliMpLocalBoard::GetPosition() const
191 {
192 /// gives position of the local board in (line, col)
193
194     const Char_t* boardName = GetName();
195     Int_t iLine = boardName[4] - '0';
196     Int_t iCol = boardName[2] - '0';
197
198     return (AliMpIntPair(iLine, iCol));
199 }
200