From Laurent:
[u/mrichter/AliRoot.git] / MUON / AliMUONLocalTrigger.cxx
CommitLineData
a9e2aefa 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
30178c30 16/* $Id$ */
a9e2aefa 17
18#include "AliMUONLocalTrigger.h"
2be06f1e 19#include <assert.h>
20#include "AliLog.h"
a9e2aefa 21
925e6570 22ClassImp(AliMUONLocalTrigger)
a9e2aefa 23//----------------------------------------------------------------------
24AliMUONLocalTrigger::AliMUONLocalTrigger()
2be06f1e 25 : TObject(), fDigits(0)
a9e2aefa 26{
27// constructor
28 fLoCircuit = 0;
29 fLoStripX = 0;
30 fLoDev = 0;
31 fLoStripY = 0;
32 fLoLpt = 0;
33 fLoHpt = 0;
34 fLoApt = 0;
6dc7fcdf 35
36 fX1Pattern = 0;
37 fX2Pattern = 0;
38 fX3Pattern = 0;
39 fX4Pattern = 0;
40
41 fY1Pattern = 0;
42 fY2Pattern = 0;
43 fY3Pattern = 0;
44 fY4Pattern = 0;
45
46 fLoDecision = 0;
a9e2aefa 47}
48//----------------------------------------------------------------------
30178c30 49AliMUONLocalTrigger::AliMUONLocalTrigger(const AliMUONLocalTrigger& theMUONLocalTrig)
50 : TObject(theMUONLocalTrig)
e9b63742 51{
52// copy constructor (useful for TClonesArray)
30178c30 53 fLoCircuit = theMUONLocalTrig.fLoCircuit;
54 fLoStripX = theMUONLocalTrig.fLoStripX;
55 fLoDev = theMUONLocalTrig.fLoDev;
56 fLoStripY = theMUONLocalTrig.fLoStripY;
57 fLoLpt = theMUONLocalTrig.fLoLpt;
58 fLoHpt = theMUONLocalTrig.fLoHpt;
59 fLoApt = theMUONLocalTrig.fLoApt;
6dc7fcdf 60
61 fX1Pattern = theMUONLocalTrig.fX1Pattern;
62 fX2Pattern = theMUONLocalTrig.fX2Pattern;
63 fX3Pattern = theMUONLocalTrig.fX3Pattern;
64 fX4Pattern = theMUONLocalTrig.fX4Pattern;
65
66 fY1Pattern = theMUONLocalTrig.fY1Pattern;
67 fY2Pattern = theMUONLocalTrig.fY2Pattern;
68 fY3Pattern = theMUONLocalTrig.fY3Pattern;
69 fY4Pattern = theMUONLocalTrig.fY4Pattern;
70
71 fLoDecision = theMUONLocalTrig.fLoDecision;
2be06f1e 72
73 fDigits = theMUONLocalTrig.fDigits;
e9b63742 74}
75//----------------------------------------------------------------------
30178c30 76AliMUONLocalTrigger& AliMUONLocalTrigger::operator=(const AliMUONLocalTrigger& theMUONLocalTrig)
e9b63742 77{
78// equal operator (useful for non-pointer member in TClonesArray)
30178c30 79 if (this == &theMUONLocalTrig)
e9b63742 80 return *this;
81
30178c30 82 // base class assignement
83 TObject::operator=(theMUONLocalTrig);
84
85 fLoCircuit = theMUONLocalTrig.fLoCircuit;
86 fLoStripX = theMUONLocalTrig.fLoStripX;
87 fLoDev = theMUONLocalTrig.fLoDev;
88 fLoStripY = theMUONLocalTrig.fLoStripY;
89 fLoLpt = theMUONLocalTrig.fLoLpt;
90 fLoHpt = theMUONLocalTrig.fLoHpt;
91 fLoApt = theMUONLocalTrig.fLoApt;
e9b63742 92
6dc7fcdf 93 fX1Pattern = theMUONLocalTrig.fX1Pattern;
94 fX2Pattern = theMUONLocalTrig.fX2Pattern;
95 fX3Pattern = theMUONLocalTrig.fX3Pattern;
96 fX4Pattern = theMUONLocalTrig.fX4Pattern;
97
98 fY1Pattern = theMUONLocalTrig.fY1Pattern;
99 fY2Pattern = theMUONLocalTrig.fY2Pattern;
100 fY3Pattern = theMUONLocalTrig.fY3Pattern;
101 fY4Pattern = theMUONLocalTrig.fY4Pattern;
102
103 fLoDecision = theMUONLocalTrig.fLoDecision;
104
2be06f1e 105 fDigits = theMUONLocalTrig.fDigits;
106
e9b63742 107 return *this;
108}
109
110//----------------------------------------------------------------------
2be06f1e 111AliMUONLocalTrigger::AliMUONLocalTrigger(const Int_t* localtr, const TArrayI& digits)
a9e2aefa 112{
113// add a local trigger object
114 fLoCircuit = localtr[0];
115 fLoStripX = localtr[1];
116 fLoDev = localtr[2];
117 fLoStripY = localtr[3];
118 fLoLpt = localtr[4];
119 fLoHpt = localtr[5];
120 fLoApt = localtr[6];
6dc7fcdf 121
122 // keep on with this way
123 fX1Pattern = (UShort_t)localtr[7];
124 fX2Pattern = (UShort_t)localtr[8];
125 fX3Pattern = (UShort_t)localtr[9];
126 fX4Pattern = (UShort_t)localtr[10];
127
128 fY1Pattern = (UShort_t)localtr[11];
129 fY2Pattern = (UShort_t)localtr[12];
130 fY3Pattern = (UShort_t)localtr[13];
131 fY4Pattern = (UShort_t)localtr[14];
2be06f1e 132
133 fDigits = digits;
a9e2aefa 134}
6dc7fcdf 135//----------------------------------------------------------------------
136Char_t AliMUONLocalTrigger::GetLoDecision()
137{
138 fLoDecision = (fLoLpt & 0x3);
139 fLoDecision |= (fLoHpt << 2) & 0xC;
402fb06e 140
6dc7fcdf 141 return fLoDecision;
142}
2be06f1e 143
144//----------------------------------------------------------------------
145void AliMUONLocalTrigger::GetDigit(
d8e8484f 146 Int_t i, Int_t& chamber, Int_t& cathode, Int_t& digit
2be06f1e 147 ) const
148{
149// Returns the i'th digit that fired this circuit.
150// The number of digits can be found with NumberOfDigits(), that is
151// i is valid in the range [ 0 , NumberOfDigits() - 1 ]
152
153 Int_t digitnumber = fDigits[i];
154 DecodeDigitNumber(digitnumber, chamber, cathode, digit);
b8fdc4dd 155}
2be06f1e 156
157//----------------------------------------------------------------------
158Int_t AliMUONLocalTrigger::EncodeDigitNumber(
d8e8484f 159 Int_t chamber, Int_t cathode, Int_t digit
2be06f1e 160 )
161{
162// Encodes a 32-bit digit number from digit information to be stored
163// in internal integer arrays. Note that the value of the digit parameter
164// can not be larger than 0x07FFFFFF.
165
166 assert( 0 <= cathode && cathode <= 1 );
167 assert( 0 <= chamber && chamber <= 13 );
168
169 if ((digit & 0xF8000000) != 0)
170 {
171 AliErrorGeneral("AliMUONLocalTrigger", Form(
172 "Digit index value is to large: 0x%8.8X. Maximum supported value is 0x07FFFFFF.",
173 cathode, chamber, digit
174 ));
175 return -1;
176 };
177
178 return ((cathode & 0x1) << 31) | ((chamber & 0xF) << 27) | digit;
b8fdc4dd 179}
2be06f1e 180
181//----------------------------------------------------------------------
182void AliMUONLocalTrigger::DecodeDigitNumber(
d8e8484f 183 Int_t digitnumber,
2be06f1e 184 Int_t& chamber, Int_t& cathode, Int_t& digit
185 )
186{
187// Decodes a digit number into information about the digit.
188// One can subsequently fetch the digit with
189// AliMUONDataInterface::Digit(chamber, cathode, digit)
190
191 cathode = (digitnumber >> 31) & 0x1;
192 chamber = (digitnumber >> 27) & 0xF;
193 digit = digitnumber & 0x7FFFFFF;
b8fdc4dd 194}
2be06f1e 195