]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpTriggerSegmentation.cxx
Modifications to the trigger classes to have I/O. I
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpTriggerSegmentation.cxx
CommitLineData
ff7d3d1a 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$
efb408b3 17// $MpId: AliMpTriggerSegmentation.cxx,v 1.5 2006/03/17 16:42:39 ivana Exp $
ff7d3d1a 18
19#include "AliMpTriggerSegmentation.h"
20
21#include "AliLog.h"
22#include "AliMpConnection.h"
23#include "AliMpMotif.h"
24#include "AliMpMotifPosition.h"
25#include "AliMpMotifType.h"
26#include "AliMpPCB.h"
27#include "AliMpSlat.h"
28#include "AliMpSlatSegmentation.h"
29#include "AliMpTrigger.h"
30
31ClassImp(AliMpTriggerSegmentation)
32
33//_____________________________________________________________________________
34AliMpTriggerSegmentation::AliMpTriggerSegmentation()
35: AliMpVSegmentation(),
efb408b3 36fkSlat(0),
37fNofStrips(0)
ff7d3d1a 38{
39 //
40 // Default ctor. Not to be used really.
41 //
42 AliDebug(1,Form("this=%p Empty ctor",this));
43}
44
45//_____________________________________________________________________________
46AliMpTriggerSegmentation::AliMpTriggerSegmentation(const AliMpTrigger* slat)
47: AliMpVSegmentation(),
48fkSlat(slat)
49{
50 //
51 // Normal ctor.
52 //
53 AliDebug(1,Form("this=%p Normal ctor slat=%p",this,slat));
efb408b3 54
55 // Compute the number of strips.
56 // We have to loop over all possible pads, in order to properly take
57 // into account the fact that a given strip might be part of several
58 // layer. Otherwise we would double count pads.
59
60 fNofStrips = 0;
61 for ( Int_t ix = 0; ix <= MaxPadIndexX(); ++ix )
62 {
63 for ( Int_t iy = 0; iy <= MaxPadIndexY(); ++iy )
64 {
65 if ( HasPad(AliMpIntPair(ix,iy)) )
66 {
67 ++fNofStrips;
68 }
69 }
70 }
ff7d3d1a 71}
72
884a73f1 73//______________________________________________________________________________
74AliMpTriggerSegmentation::AliMpTriggerSegmentation(const AliMpTriggerSegmentation& right)
75 : AliMpVSegmentation(right)
76{
77/// Protected copy constructor (not implemented)
78
79 AliFatal("Copy constructor not provided.");
80}
81
ff7d3d1a 82//_____________________________________________________________________________
83AliMpTriggerSegmentation::~AliMpTriggerSegmentation()
84{
85 //
86 // Dtor (empty).
87 //
88 AliDebug(1,Form("this=%p",this));
89}
90
884a73f1 91//______________________________________________________________________________
92AliMpTriggerSegmentation&
93AliMpTriggerSegmentation::operator=(const AliMpTriggerSegmentation& right)
94{
95/// Protected assignement operator (not implemented)
96
97 // check assignement to self
98 if (this == &right) return *this;
99
100 AliFatal("Assignement operator not provided.");
101
102 return *this;
103}
104
ff7d3d1a 105//_____________________________________________________________________________
106AliMpVPadIterator*
107AliMpTriggerSegmentation::CreateIterator(const AliMpArea&) const
108{
109 //
110 // Returns an iterator to loop over the pad contained within given area.
111 // Not implemented for trigger.
112
113 return 0;
114}
115
63bcb3c3 116//_____________________________________________________________________________
117TVector2
118AliMpTriggerSegmentation::Dimensions() const
119{
120 return Slat()->Dimensions();
121}
122
123//_____________________________________________________________________________
124void
125AliMpTriggerSegmentation::GetAllElectronicCardIDs(TArrayI& ecn) const
126{
127 Slat()->GetAllLocalBoardNumbers(ecn);
128}
129
ff7d3d1a 130//_____________________________________________________________________________
131const char*
132AliMpTriggerSegmentation::GetName() const
133{
134 TString name("TriggerSegmentation");
135 if ( fkSlat)
136 {
137 name += ".";
138 name += fkSlat->GetName();
139 }
140 return name.Data();
141}
142
143//_____________________________________________________________________________
144Bool_t
145AliMpTriggerSegmentation::HasPad(const AliMpIntPair& indices) const
146{
147 //
148 // Test if this slat has a pad located at the position referenced
149 // by the integer indices.
150 //
151
152 return PadByIndices(indices,kFALSE) != AliMpPad::Invalid();
153}
154
155//_____________________________________________________________________________
156Int_t
026b7442 157AliMpTriggerSegmentation::MaxPadIndexX() const
ff7d3d1a 158{
159 //
160 // Returns the value of the largest pad index in x-direction.
161 //
162
163 return fkSlat->GetNofPadsX()-1;
164}
165
166//_____________________________________________________________________________
167Int_t
026b7442 168AliMpTriggerSegmentation::MaxPadIndexY() const
ff7d3d1a 169{
170 //
171 // Returns the value of the largest pad index in y-direction.
172 //
173
174 return fkSlat->GetMaxNofPadsY()-1;
175}
176
177//_____________________________________________________________________________
178AliMpPad
179AliMpTriggerSegmentation::PadByLocation(const AliMpIntPair& location,
180 Bool_t warning) const
181{
182 //
183 // Returns the pad specified by its location, where location is the
184 // pair (ManuID,ManuChannel).
185 // If warning=kTRUE and the pad does not exist, a warning message is
186 // printed.
187 //
188 // AliMpPad::Invalid() is returned if there's no pad at the given location.
189 //
190 AliMpPad pad;
191 AliMpIntPair invloc;
192
193 for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
194 {
195 const AliMpSlat* slat = fkSlat->GetLayer(i);
196 AliMpSlatSegmentation seg(slat);
197 AliMpPad p_i = seg.PadByLocation(location,kFALSE);
198 if ( p_i.IsValid() )
199 {
200 if ( !pad.IsValid() )
201 {
202 pad = AliMpPad(invloc,p_i.GetIndices(),p_i.Position(),p_i.Dimensions());
203 pad.AddLocation(p_i.GetLocation());
204 }
205 else
206 {
207 pad.AddLocation(p_i.GetLocation());
208 }
209 }
210 }
211 if ( warning && !pad.IsValid() )
212 {
213 AliWarning(Form("No pad found at location (%d,%d)",location.GetFirst(),
214 location.GetSecond()));
215 }
216 return pad;
217}
218
219//_____________________________________________________________________________
220AliMpPad
221AliMpTriggerSegmentation::PadByIndices(const AliMpIntPair& indices,
222 Bool_t warning) const
223{
224 //
225 // Returns the pad specified by its integer indices.
226 // If warning=kTRUE and the pad does not exist, a warning message is
227 // printed.
228 //
229 // AliMpPad::Invalid() is returned if there's no pad at the given location.
230 //
231 //
232
233 AliMpPad pad;
234 AliMpIntPair invloc;
235
236 for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
237 {
238 const AliMpSlat* slat = fkSlat->GetLayer(i);
239 AliMpSlatSegmentation seg(slat);
240 AliMpPad p_i = seg.PadByIndices(indices,kFALSE);
241 if ( p_i.IsValid() )
242 {
243 if ( !pad.IsValid() )
244 {
245 pad = AliMpPad(invloc,p_i.GetIndices(),p_i.Position(),p_i.Dimensions());
246 pad.AddLocation(p_i.GetLocation());
247 }
248 else
249 {
250 pad.AddLocation(p_i.GetLocation());
251 }
252 }
253 }
254 if ( warning && !pad.IsValid() )
255 {
256 AliWarning(Form("No pad found at indices (%d,%d)",indices.GetFirst(),
257 indices.GetSecond()));
258 }
259
260 return pad;
261}
262
263//_____________________________________________________________________________
264AliMpPad
265AliMpTriggerSegmentation::PadByPosition(const TVector2& position,
266 Bool_t warning) const
267{
268 //
269 // Returns the pad specified by its (floating point) position.
270 // If warning=kTRUE and the pad does not exist, a warning message is
271 // printed.
272 //
273 // AliMpPad::Invalid() is returned if there's no pad at the given location.
274 //
275 AliMpPad pad;
276 AliMpIntPair invloc;
277
278 for ( Int_t i = 0; i < fkSlat->GetSize(); ++i )
279 {
280 const AliMpSlat* slat = fkSlat->GetLayer(i);
281 AliMpSlatSegmentation seg(slat);
282 AliMpPad p_i = seg.PadByPosition(position,kFALSE);
283 if ( p_i.IsValid() )
284 {
285 if ( !pad.IsValid() )
286 {
287 pad = AliMpPad(invloc,p_i.GetIndices(),p_i.Position(),p_i.Dimensions());
288 pad.AddLocation(p_i.GetLocation());
289 }
290 else
291 {
292 pad.AddLocation(p_i.GetLocation());
293 }
294 }
295 }
296 if ( warning && !pad.IsValid() )
297 {
298 AliWarning(Form("No pad found at position (%e,%e)",position.X(),
299 position.Y()));
300 }
301
302 return pad;
303}
304
63bcb3c3 305//_____________________________________________________________________________
306AliMpPlaneType
307AliMpTriggerSegmentation::PlaneType() const
308{
309 return Slat()->PlaneType();
310}
311
ff7d3d1a 312//_____________________________________________________________________________
313const AliMpTrigger*
314AliMpTriggerSegmentation::Slat() const
315{
316 //
317 // Returns the pointer to the referenced slat.
318 //
319
320 return fkSlat;
321}