Transition to NewIO
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1ElectronicElement.cxx
CommitLineData
ba030c0e 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
88cb7938 16/* $Id$ */
ba030c0e 17
18// Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
19//
20// Class AliMUONSt1ElectronicElement
21// ---------------------------------
22// Describes a set of pads either by defining
23// a range of indices, or
24// a range of (centimeters) positions or
25// a range of electronic channel numbers or
26// a range of MANU numbers or, finally,
27// a range of gassiplex/MANAS numbers, in a given range of MANU addresses
28
29#include "AliMUONSt1ElectronicElement.h"
30
31ClassImp(AliMUONSt1ElectronicElement);
32
33//______________________________________________________________________________
34AliMUONSt1ElectronicElement::AliMUONSt1ElectronicElement()
35 :TObject(),fDescription(kNone)
36{
37// default constructor
38}
39
40//______________________________________________________________________________
41AliMUONSt1ElectronicElement::AliMUONSt1ElectronicElement(TDescription descr)
42 :TObject(),fDescription(descr)
43{
44// normal constructor
45 switch (descr){
46 case kXY : SetRange(0,0.,0.); SetRange(1,0.,0.); break;
47 default: SetRange(0,0,0); SetRange(1,0,0); break;
48 }
49}
50
51//______________________________________________________________________________
52AliMUONSt1ElectronicElement::~AliMUONSt1ElectronicElement()
53{
54// destructor
55}
56
57//______________________________________________________________________________
58void AliMUONSt1ElectronicElement::SetRange(Int_t numVar,Int_t i1,Int_t i2)
59{
60// set the range of the <numVar>th variables, in all cases but kXY
61// ---
62
63 if (fDescription==kXY) {
64 fRanges[numVar][0].x = (Double_t)i1;
65 fRanges[numVar][1].x = (Double_t)i2;
66 } else {
67 fRanges[numVar][0].i = i1;
68 fRanges[numVar][1].i = i2;
69 }
70}
71
72//______________________________________________________________________________
73void AliMUONSt1ElectronicElement::SetRange(Int_t numVar,Double_t x1,Double_t x2)
74{
75// set the range of the <numVar>th variable, in cases kXY
76// ---
77
78 if (fDescription==kXY) {
79 fRanges[numVar][0].x = x1;
80 fRanges[numVar][1].x = x2;
81 } else {
82 fRanges[numVar][0].i = (Int_t)x1;
83 fRanges[numVar][1].i = (Int_t)x2;
84 }
85}
86
87//______________________________________________________________________________
88Bool_t AliMUONSt1ElectronicElement::IsInRange(Int_t numVar,Int_t i) const
89{
90// is the given value in the <numVar>th variable
91// ---
92
93 return (fRanges[numVar][0].i<=i) && (fRanges[numVar][1].i>=i);
94}
95
96//______________________________________________________________________________
97Bool_t AliMUONSt1ElectronicElement::IsInRange(Int_t numVar,Double_t x) const
98{
99// is the given value in the <numVar>th variable
100// ---
101
102 return (fRanges[numVar][0].x<=x) && (fRanges[numVar][1].x>=x);
103}
104
105//______________________________________________________________________________
5f91c9e8 106Bool_t AliMUONSt1ElectronicElement::Contains(const AliMpPad& pad) const
ba030c0e 107{
108// is the pad <pad> contained in this range
109// ---
110
111 switch(fDescription){
112 case kNone:
113 return kFALSE;
114 case kIJ :
115 return ( IsInRange(0,pad.GetIndices().GetFirst())
116 && IsInRange(1,pad.GetIndices().GetSecond())
117 );
118 case kXY :
119 return ( IsInRange(0,pad.Position().X())
120 && IsInRange(1,pad.Position().Y())
121 );
122 case kMGC :
123 return ( IsInRange(0,pad.GetLocation().GetFirst())
124 && IsInRange(1,pad.GetLocation().GetSecond())
125 );
126 case kMG :
127 return ( IsInRange(0,pad.GetLocation().GetFirst())
128 && IsInRange(1,pad.GetLocation().GetSecond() >> 4)
129 );
130 case kM :
131 return ( IsInRange(0,pad.GetLocation().GetFirst()));
132
133 default: return kFALSE;
134 }
135}