]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRegionalTriggerBoard.cxx
Trigger scalers added to ESD header.
[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 //-----------------------------------------------------------------------------
19 /// \class AliMUONRegionalTriggerBoard
20 /// Dimuon regional trigger implementation:
21 /// - entry are local board responses
22 /// - output is 12-bit word
23 /// - algorithm is similar to the global one
24 ///
25 /// \author Rachid Guernane (LPCCFd)
26 /// Corrected by Christian Finck (Subatech)
27 //-----------------------------------------------------------------------------
28
29 #include "AliMUONRegionalTriggerBoard.h"
30
31 #include "AliLog.h"
32
33 #include "TBits.h"
34
35 #include <Riostream.h>
36
37 /// \cond CLASSIMP
38 ClassImp(AliMUONRegionalTriggerBoard)
39 /// \endcond
40
41 //___________________________________________
42 AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard()
43   : AliMUONTriggerBoard(),
44     fMask(0x0)   
45 {
46 /// Default constructor
47    for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
48 }
49
50 //___________________________________________
51 AliMUONRegionalTriggerBoard::AliMUONRegionalTriggerBoard(const char *name, Int_t a) 
52   : AliMUONTriggerBoard(name, a),
53     fMask(0x0)   
54 {
55 /// Standard constructor
56    for (Int_t i=0; i<16; i++) fLocalResponse[i] = 0;
57 }
58
59 //___________________________________________
60 AliMUONRegionalTriggerBoard::~AliMUONRegionalTriggerBoard()
61 {
62 /// Destructor
63 }
64
65 //___________________________________________
66 void AliMUONRegionalTriggerBoard::Response()
67 {
68 /// response is given following the regional algorithm
69 // output from local trigger algorithm
70 // [+, -] * [Hpt, Lpt]
71 // transformed to [+, -, US, LS] * [Hpt, Lpt]
72
73   Int_t t[16];
74
75    for (Int_t i = 0; i < 16; ++i)
76    {
77      if ((fMask >> i) & 0x1)
78       t[i] = fLocalResponse[i];
79      else
80        t[i] = 0;
81    }
82    
83    Int_t rank = 8;
84
85    for (Int_t i = 0; i < 4; ++i)
86    {
87       Int_t ip = 0;
88       
89       for (Int_t j = 0; j < rank; ++j)
90       {
91          UShort_t lthres = Algo(t[2*j],t[2*j+1],"LPT",i);
92                  
93          UShort_t hthres = Algo(t[2*j],t[2*j+1],"HPT",i); hthres <<= 4;
94
95          t[ip] = lthres | hthres;
96
97          ip++;
98       }
99       
100       rank /= 2; 
101    }
102    fResponse = t[0]; // 8-bit [H4:L4]
103 }
104
105 //___________________________________________
106 UShort_t AliMUONRegionalTriggerBoard::Algo(UShort_t i, UShort_t j, const char *thres, Int_t level)
107 {
108 /// implementation of the regional algorithm
109 /// similar to the global algorithm except for the
110 /// input layer
111
112 /// level = 0  a ,b = local response = Hpt (+|-) | Lpt (+|-)    
113 /// level > 0  a ,b = reg  response  =  Hpt (+|-|us|ls) |  Lpt (+|-|us|ls)    
114    
115   TBits a(8), b(8); a.Set(8,&i); b.Set(8,&j);
116
117    TBits trg1(2), trg2(2), trg(2);
118
119    if (!strcmp(thres,"LPT"))
120    {
121   
122       if (!level) 
123       {         
124          trg1[0] = a[0]; trg1[1] = a[1]; 
125          trg2[0] = b[0]; trg2[1] = b[1];
126       }
127       else
128       {
129          trg1[0] = a[2]; trg1[1] = a[3]; 
130          trg2[0] = b[2]; trg2[1] = b[3];
131       }
132    }
133    else
134    {
135       if (!level)
136       {         
137          trg1[0] = a[2]; trg1[1] = a[3]; 
138          trg2[0] = b[2]; trg2[1] = b[3];
139       }
140       else
141       {
142          trg1[0] = a[6]; trg1[1] = a[7]; 
143          trg2[0] = b[6]; trg2[1] = b[7];         
144       }
145    }
146        
147    TBits trgLS1(1), trgUS1(1), trgLS2(1), trgUS2(1), trgLS(1), trgUS(1);
148
149    if (!level) 
150    {
151       trgLS1[0] = trgUS1[0] = trgLS2[0] = trgUS2[0] = 0;
152    }
153    else
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          trgLS1[0] = a[0]; trgUS1[0] = a[1]; 
160          trgLS2[0] = b[0]; trgUS2[0] = b[1];
161       }
162       else
163       {
164          //trgLS1[0] = a[5]; trgUS1[0] = a[4]; 
165          //trgLS2[0] = b[5]; trgUS2[0] = b[4];         
166          trgLS1[0] = a[4]; trgUS1[0] = a[5]; 
167          trgLS2[0] = b[4]; trgUS2[0] = b[5];         
168       }
169    }
170
171    trgLS[0] = ( trg1[0] & trg2[0] ) | ( trg1[1] & trg2[1] ) | trgLS1[0] | trgLS2[0];
172    trgUS[0] = ( trg1[0] & trg2[1] ) | ( trg1[1] & trg2[0] ) | trgUS1[0] | trgUS2[0];
173    
174    trg[0] = trg1[0] | trg2[0];
175    trg[1] = trg1[1] | trg2[1];
176    
177    TBits v(4);
178    
179    //v[0] = trgUS[0]; 
180    //v[1] = trgLS[0];
181    v[0] = trgLS[0]; 
182    v[1] = trgUS[0];
183    v[2] = trg[0];
184    v[3] = trg[1];
185    UShort_t rv = 0;
186    v.Get(&rv);
187    return rv;
188 }
189
190 //___________________________________________
191 void AliMUONRegionalTriggerBoard::Scan(Option_t*) const
192 {
193 /// scan local board entries 
194
195   for (Int_t i=0; i<16; i++) 
196    {
197       TBits b;
198       b.Set(6,&fLocalResponse[i]);
199       
200       cout << "Entry " << i << " is " << b << endl;
201       
202    }
203    
204 }
205 //___________________________________________
206 void AliMUONRegionalTriggerBoard::Mask(UShort_t mask)
207 {
208 /// mask entry index
209
210     fMask = mask;
211 }
212
213
214