]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONGlobalTriggerBoard.cxx
Add Config/HighVoltage directory and entry
[u/mrichter/AliRoot.git] / MUON / AliMUONGlobalTriggerBoard.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 //-----------------------------------------------------------------------------
19 /// \class AliMUONGlobalTriggerBoard
20 /// Global trigger implementation:
21 /// - inputs are regional responses
22 /// - output is a 12-bit word
23 /// - 4 bits per trigger level
24 ///
25 /// \author Rachid Guernane (LPCCFd), 
26 /// Corrected by Christian Finck (Subatech)
27 //-----------------------------------------------------------------------------
28
29 #include "AliMUONGlobalTriggerBoard.h"
30 #include "AliLog.h"
31 #include "TBits.h"
32
33 #include <Riostream.h>
34
35 /// \cond CLASSIMP
36 ClassImp(AliMUONGlobalTriggerBoard)
37 /// \endcond
38
39 //___________________________________________
40 AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard(): AliMUONTriggerBoard()
41 {
42 /// Default constructor
43
44    for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
45 }
46
47 //___________________________________________
48 AliMUONGlobalTriggerBoard::AliMUONGlobalTriggerBoard(const char *name, Int_t a) : AliMUONTriggerBoard(name, a)
49 {
50 /// Standard constructor
51
52    for (Int_t i=0;i<16;i++) fRegionalResponse[i] = 0;
53 }
54
55 //___________________________________________
56 AliMUONGlobalTriggerBoard::~AliMUONGlobalTriggerBoard()
57 {
58 /// Destructor
59 }
60
61 //___________________________________________
62 void AliMUONGlobalTriggerBoard::Mask(Int_t index, UShort_t mask)
63 {
64   /// mask global trigger board input index with value mask
65   if ( index>=0 && index < 2 ) 
66   {
67     fMask[index]=mask;
68   }
69   else
70   {
71     AliError(Form("Index %d out of bounds (max %d)",index,2));
72   }  
73 }
74
75 //___________________________________________
76 void AliMUONGlobalTriggerBoard::Response()
77 {
78    /// compute the global trigger board
79    /// response according to the algo() method
80 // output from global trigger algorithm
81 // [+, -, LS, US] * [Hpt, Lpt]
82 // transformed to [usHpt, usLpt, lsHpt, lsLpt, sHpt, sLpt] according
83 // to Global Trigger Unit user manual
84
85    Int_t t[16];
86
87    for (Int_t i = 0; i < 16; ++i) 
88    {
89      Int_t index = i/8;
90      Int_t shift = i % 8;
91      UShort_t enable = !((fMask[index] >> shift) & 0x1);
92      if (enable)
93       t[i] = fRegionalResponse[i];
94      else
95        t[i] = 0;
96    }
97    
98    Int_t rank = 8;
99
100    for (Int_t i=0;i<4;i++)
101    {
102       Int_t ip = 0;
103       
104       for (Int_t j=0;j<rank;j++)
105       {
106          UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT");
107
108          UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT"); hthres <<= 4;
109
110          t[ip] = lthres | hthres;
111
112          ip++;
113       }
114       
115       rank /= 2; 
116    }
117    UChar_t sLpt, sHpt, lsLpt, lsHpt, usLpt, usHpt;
118    sLpt  = ((t[0] & 0xC)  != 0);
119    sHpt  = ((t[0] & 0xC0) != 0);
120    lsLpt = ((t[0] & 0x2)  != 0);
121    lsHpt = ((t[0] & 0x20) != 0);
122    usLpt = ((t[0] & 0x1 ) != 0);
123    usHpt = ((t[0] & 0x10) != 0);
124
125    sHpt  <<= 1;
126    lsLpt <<= 2;
127    lsHpt <<= 3;
128    usLpt <<= 4;
129    usHpt <<= 5;
130
131    fResponse = sLpt | sHpt | lsLpt | lsHpt | usLpt |usHpt;
132 }
133
134 //___________________________________________
135 UShort_t AliMUONGlobalTriggerBoard::Algo(UShort_t i, UShort_t j, char *thres)
136 {
137    /// global trigger algorithm
138    TBits a(8), b(8); a.Set(8,&i); b.Set(8,&j);
139
140    TBits trg1(2), trg2(2), trg(2);
141
142    if (!strcmp(thres,"LPT"))
143    {
144       trg1[0] = a[2]; trg1[1] = a[3]; 
145       trg2[0] = b[2]; trg2[1] = b[3];
146    }
147    else
148    {
149       trg1[0] = a[6]; trg1[1] = a[7]; 
150       trg2[0] = b[6]; trg2[1] = b[7];         
151    }
152        
153    TBits trgLS1(1), trgUS1(1), trgLS2(1), trgUS2(1), trgLS(1), trgUS(1);
154
155    if (!strcmp(thres,"LPT"))
156    {
157       trgLS1[0] = a[1]; trgUS1[0] = a[0]; 
158       trgLS2[0] = b[1]; trgUS2[0] = b[0];
159    }
160    else
161    {
162       trgLS1[0] = a[5]; trgUS1[0] = a[4]; 
163       trgLS2[0] = b[5]; trgUS2[0] = b[4];         
164    }
165
166    trgLS[0] = ( trg1[0] & trg2[0] ) | ( trg1[1] & trg2[1] ) | trgLS1[0] | trgLS2[0];
167    trgUS[0] = ( trg1[0] & trg2[1] ) | ( trg1[1] & trg2[0] ) | trgUS1[0] | trgUS2[0];
168    
169    trg[0] = trg1[0] | trg2[0];
170    trg[1] = trg1[1] | trg2[1];
171    
172    TBits v(4);
173    
174    v[0] = trgUS[0];
175    v[1] = trgLS[0];
176    v[2] = trg[0];
177    v[3] = trg[1];
178
179    UShort_t rv = 0;
180    v.Get(&rv);
181    
182    return rv;
183 }
184
185 //___________________________________________
186 void AliMUONGlobalTriggerBoard::Scan(Option_t*) const
187 {
188   /// print global trigger output 
189   TBits w(8); w.Set(8,&fResponse);
190
191 // TRG[1:0]
192 // 00 noth
193 // 01 negative track
194 // 10 positive track
195 // 11 undef
196
197    Int_t iSP[2] = {0,0}, iSM[2] = {0,0}, iSU[2] = {0,0};
198
199    TBits a(2), n(2), p(2), u(2);
200    
201    UShort_t val;
202
203    val = 1; n.Set(2,&val);
204    val = 2; p.Set(2,&val);
205    val = 3; u.Set(2,&val);
206    
207    a[0] = w[2];
208    a[1] = w[3];
209    
210    if      (a==p) iSP[0] = 1;
211    else if (a==n) iSM[0] = 1;
212    else if (a==u) iSU[0] = 1;   
213
214    a[0] = w[6];
215    a[1] = w[7];
216
217    if      (a==p) iSP[1] = 1;
218    else if (a==n) iSM[1] = 1;
219    else if (a==u) iSU[1] = 1;
220    
221    Int_t iPU[2] = {w[0],w[4]};
222    Int_t iPL[2] = {w[1],w[5]};
223
224    printf("============================================\n");
225    printf(" Global Trigger output       Low pt  High pt\n");
226    printf(" number of Single Plus      :\t");
227    for (Int_t i=0; i<2; i++) printf("%i\t",iSP[i]);
228    printf("\n");
229    printf(" number of Single Minus     :\t");
230    for (Int_t i=0; i<2; i++) printf("%i\t",iSM[i]);
231    printf("\n");
232    printf(" number of Single Undefined :\t"); 
233    for (Int_t i=0; i<2; i++) printf("%i\t",iSU[i]);
234    printf("\n");
235    printf(" number of UnlikeSign pair  :\t"); 
236    for (Int_t i=0; i<2; i++) printf("%i\t",iPU[i]);
237    printf("\n");
238    printf(" number of LikeSign pair    :\t");  
239    for (Int_t i=0; i<2; i++) printf("%i\t",iPL[i]);
240    printf("\n");
241    printf("===================================================\n");
242    printf("\n");
243 }
244