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