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