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