]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRegionalTriggerBoard.cxx
Adding mask handling
[u/mrichter/AliRoot.git] / MUON / AliMUONRegionalTriggerBoard.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 //*-- Author: Rachid Guernane (LPCCFd)
19
20 #include "AliMUONRegionalTriggerBoard.h"
21
22 #include "AliLog.h"
23
24 #include "TBits.h"
25
26 #include <Riostream.h>
27
28 ClassImp(AliMUONRegionalTriggerBoard)
29
30 //___________________________________________
31 AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard()
32 {
33    for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
34 }
35
36 //___________________________________________
37 AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard(const char *name, Int_t a) : AliMUONTriggerBoard(name, a)
38 {
39    for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
40 }
41
42 //___________________________________________
43 void AliMUONRegionalTriggerBoard::Response()
44 {
45    Int_t t[16];
46
47    for (Int_t i=0;i<16;i++) t[i] = fLocalResponse[i] & fMask[i];
48
49    Int_t rank = 8;
50
51    for (Int_t i=0;i<4;i++)
52    {
53       Int_t ip = 0;
54       
55       for (Int_t j=0;j<rank;j++)
56       {
57          UShort_t athres = Algo(t[2*j],t[2*j+1],"APT",i);
58
59          UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT",i); lthres <<= 4;
60
61          UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT",i); hthres <<= 8;
62
63          t[ip] = athres | lthres | hthres;
64
65          ip++;
66       }
67       
68       rank /= 2; 
69    }
70
71    fResponse = t[0]; // 12-bit [H4:L4:A4]
72 }
73
74 //___________________________________________
75 UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres, Int_t level)
76 {
77    TBits a(12), b(12); a.Set(12,&i); b.Set(12,&j);
78
79    TBits trg1(2), trg2(2), trg(2);
80
81    if (!strcmp(thres,"APT"))
82    {
83       if (!level)
84       {         
85          trg1[0] = a[0]; trg1[1] = a[1]; 
86          trg2[0] = b[0]; trg2[1] = b[1];
87       }
88       else
89       {
90          trg1[0] = a[2]; trg1[1] = a[3]; 
91          trg2[0] = b[2]; trg2[1] = b[3];
92       }
93    }
94    else if (!strcmp(thres,"LPT"))
95    {
96       if (!level)
97       {         
98          trg1[0] = a[2]; trg1[1] = a[3]; 
99          trg2[0] = b[2]; trg2[1] = b[3];
100       }
101       else
102       {
103          trg1[0] = a[6]; trg1[1] = a[7]; 
104          trg2[0] = b[6]; trg2[1] = b[7];
105       }
106    }
107    else
108    {
109       if (!level)
110       {         
111          trg1[0] = a[4]; trg1[1] = a[5]; 
112          trg2[0] = b[4]; trg2[1] = b[5];
113       }
114       else
115       {
116          trg1[0] = a[10]; trg1[1] = a[11]; 
117          trg2[0] = b[10]; trg2[1] = b[11];         
118       }
119    }
120        
121    TBits trgLS1(1), trgUS1(1), trgLS2(1), trgUS2(1), trgLS(1), trgUS(1);
122
123    if (!level) 
124    {
125       trgLS1[0] = trgUS1[0] = trgLS2[0] = trgUS2[0] = 0;
126    }
127    else
128    {
129       if (!strcmp(thres,"APT"))
130       {
131          trgLS1[0] = a[1]; trgUS1[0] = a[0]; 
132          trgLS2[0] = b[1]; trgUS2[0] = b[0];
133       }
134       else if (!strcmp(thres,"LPT"))
135       {
136          trgLS1[0] = a[5]; trgUS1[0] = a[4]; 
137          trgLS2[0] = b[5]; trgUS2[0] = b[4];
138       }
139       else
140       {
141          trgLS1[0] = a[9]; trgUS1[0] = a[8]; 
142          trgLS2[0] = b[9]; trgUS2[0] = b[8];         
143       }
144    }
145
146    trgLS[0] = ( trg1[0] & trg2[0] ) | ( trg1[1] & trg2[1] ) | trgLS1[0] | trgLS2[0];
147    trgUS[0] = ( trg1[0] & trg2[1] ) | ( trg1[1] & trg2[0] ) | trgUS1[0] | trgUS2[0];
148    
149    trg[0] = trg1[0] | trg2[0];
150    trg[1] = trg1[1] | trg2[1];
151    
152    TBits v(4);
153    
154    v[0] = trgUS[0];
155    v[1] = trgLS[0];
156    v[2] = trg[0];
157    v[3] = trg[1];
158    
159    UShort_t rv = 0;
160    v.Get(&rv);
161
162    return rv;
163 }
164 //___________________________________________
165 void AliMUONRegionalTriggerBoard::Scan(Option_t*)
166 {
167    for (Int_t i=0; i<16; i++) 
168    {
169       TBits b;
170       b.Set(6,&fLocalResponse[i]);
171       
172       cout << "Entry " << i << " is " << b << endl;
173       
174    }
175    
176 }
177
178 //___________________________________________
179 void AliMUONRegionalTriggerBoard::Mask(Int_t index, UShort_t mask)
180 {
181   if ( index>=0 && index < 16 ) 
182   {
183     fMask[index]=mask;
184   }
185   else
186   {
187     AliError(Form("Index %d out of bounds (max %d)",index,16));
188   }
189 }
190
191 ClassImp(AliMUONRegionalTriggerBoard)