StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_LD301_2009.cc
1 //
2 // Pibero Djawotho <pibero@comp.tamu.edu>
3 // Texas A&M University Cyclotron Institute
4 // 14 Mar 2009
5 //
6 
7 #include "DSM.hh"
8 #include "DSMAlgo_LD301_2009.hh"
9 
10 void DSMAlgo_LD301_2009::operator()(DSM& dsm)
11 {
12  // INPUT:
13 
14  // ch0 - MTD information
15  // Bit 0 - MTD trigger (MTD)
16  // Bits 1:15 - Unused
17 
18  // ch1 - VTX information
19  // Bit 0 - BBC TAC difference in window (BBC-TAC)
20  // Bit 1 - BBC East ADC sum > threshold (BBCE)
21  // Bit 2 - BBC West ADC sum > threshold (BBCW)
22  // Bits 3:5 - Unused
23  // Bit 6 - ZDC TAC difference in window (ZDC-TAC)
24  // Bit 7 - ZDC East ADC sum > threshold (ZDCE)
25  // Bit 8 - ZDC West ADC sum > threshold (ZDCW)
26  // Bit 9 - ZDC East Front ADC > threshold (ZDCE-Front)
27  // Bit 10 - ZDC East Back ADC > threshold (ZDCE-Back)
28  // Bit 11 - ZDC West Front ADC > threshold (ZDCW-Front)
29  // Bit 12 - ZDC West Back ADC > threshold (ZDCW-Back)
30  // Bit 13 - VPD TAC difference in window (VPD-TAC)
31  // Bit 14 - VPD East ADC sum > threshold (VPDE)
32  // Bit 15 - VPD West ADC sum > threshold (VPDW)
33 
34  // ch2 - Unused
35 
36  // ch3 - EMC information
37  // Bits 0:3 - Barrel HT bits (BHT(0:3))
38  // Bits 4:5 - Endcap HT bits (EHT2 and EHT4)
39  // Bit 6 - Barrel+Endcap jet patch 1 (JP1)
40  // Bit 7 - Barrel+Endcap jet patch 2 (JP2)
41  // Bit 8 - Barrel-only jet patch 1 (BJP1)
42  // Bit 9 - Unused
43  // Bit 10 - Endcap-only jet patch 1 (EJP1)
44  // Bit 11 - Unused
45  // Bit 12 - Barrel+Endcap adjacent jet patch (AJP)
46  // Bits 13:15 - Unused
47 
48  // ch4 - RAT board
49  // Bit 0 - FMS led (FMS-led)
50  // Bits 1:7 - Unused
51  // Bits 8:15 - Detector status [1=Live, 0=Busy] (status(0:7))
52 
53  // ch5 - FMS/FPD information
54  // Bits 0:2 - FMS small-cell cluster threshold bits (FMS-small(0:2))
55  // Bits 3:6 - Unused
56  // Bits 7:9 - FMS large-cell cluster threshold bits (FMS-large(0:2))
57  // Bits 10:13 - Unused
58  // Bit 14 - FPE trigger (FPE)
59  // Bit 15 - Unused
60 
61  // ch6 - Special Trigger Requests
62  // Bits 0:13 - Unused
63  // Bit 14 - Zero-bias bit (Zerobias)
64  // Bit 15 - Unused
65 
66  // ch7 - Unused
67 
68  // REGISTERS:
69 
70  // R0 - BBCMBLive-PS-lo (12)
71  // R1 - BBCMBLive-PS-hi (12)
72  // R2 - VPDMBLive-PS-lo (12)
73  // R3 - VPDMBLive-PS-hi (12)
74  // R4 - ZDCMB-PS-lo (12)
75  // R5 - ZDCMB-PS-hi (12)
76  // R6 - BBC-Live-Det-Select (8)
77  // R7 - VPD-Live-Det-select (8)
78  // R8 - Output-Bit1-Select (3)
79  // R9 - Output-Bit2-Select (4)
80  // R10 - JP1-Select (4)
81 
82  // INTERNAL LOGIC:
83 
84  int bbctac = dsm.channels[1] & 0x1;
85  int bbce = dsm.channels[1] >> 1 & 0x1;
86  int bbcw = dsm.channels[1] >> 2 & 0x1;
87  int bbcmb = bbctac && bbce && bbcw;
88 
89  int bht3 = dsm.channels[3] >> 3 & 0x1;
90  int bht2 = dsm.channels[3] >> 2 & 0x1;
91  int bjp1 = dsm.channels[3] >> 8 & 0x1;
92  int bit1 = ((bht3 && (dsm.registers[8] & 0x1)) ||
93  (bht2 && bjp1 && (dsm.registers[8] & 0x2)) ||
94  (bht2 && bbcmb && (dsm.registers[8] & 0x4)));
95 
96  int jp2 = dsm.channels[3] >> 7 & 0x1;
97  int ajp = dsm.channels[3] >> 12 & 0x1;
98  int eht4 = dsm.channels[3] >> 5 & 0x1;
99  int eht2 = dsm.channels[3] >> 4 & 0x1;
100  int ejp1 = dsm.channels[3] >> 10 & 0x1;
101  int bit2 = ((jp2 && (dsm.registers[9] & 0x1)) ||
102  (ajp && (dsm.registers[9] & 0x2)) ||
103  (eht4 && (dsm.registers[9] & 0x4)) ||
104  (eht2 && ejp1 && (dsm.registers[9] & 0x8)));
105 
106  int bht = 0;
107  switch (dsm.channels[3] & 0x7) {
108  case 1: bht = 1; break;
109  case 3: bht = 2; break;
110  case 7: bht = 3; break;
111  }
112 
113  int jp1 = dsm.channels[3] >> 6 & 0x1;
114  int overlap_jp1 = jp1 && !(bjp1 || ejp1);
115  int jp1_selected = ((jp1 && (dsm.registers[10] & 0x1)) ||
116  (bjp1 && (dsm.registers[10] & 0x2)) ||
117  (ejp1 && (dsm.registers[10] & 0x4)) ||
118  (overlap_jp1 && (dsm.registers[10] & 0x8)));
119 
120  int status = dsm.channels[4] >> 8 & 0xff;
121  int bbcdetlive = (((status & dsm.registers[6]) | ~dsm.registers[6]) & 0xff) == 0xff;
122  int bbcmblive = bbcmb && bbcdetlive;
123  int bbcpre = dsm.registers[0] | dsm.registers[1] << 12;
124  if (bbcmblive) --bbcpre;
125  int bbcmblivepre = bbcpre == 1;
126 
127  int vpdtac = dsm.channels[1] >> 13 & 0x1;
128  int vpde = dsm.channels[1] >> 14 & 0x1;
129  int vpdw = dsm.channels[1] >> 15 & 0x1;
130  int vpdmb = vpdtac && vpde && vpdw;
131  int vpddetlive = (((status & dsm.registers[7]) | ~dsm.registers[7]) & 0xff) == 0xff;
132  int vpdmblive = vpdmb && vpddetlive;
133  int vpdpre = dsm.registers[2] | dsm.registers[3] << 12;
134  if (vpdmblive) --vpdpre;
135  int vpdmblivepre = vpdpre == 1;
136 
137  int zdctac = dsm.channels[1] >> 6 & 0x1;
138  int zdce = dsm.channels[1] >> 7 & 0x1;
139  int zdcw = dsm.channels[1] >> 8 & 0x1;
140  int zdcmb = zdctac && zdce && zdcw;
141 
142  int zdcefront = dsm.channels[1] >> 9 & 0x1;
143  int zdceback = dsm.channels[1] >> 10 & 0x1;
144  int zdcwfront = dsm.channels[1] >> 11 & 0x1;
145  int zdcwback = dsm.channels[1] >> 12 & 0x1;
146  int zdcpole = bbce && bbcw && zdcefront && zdceback;
147  int zdcpolw = bbce && bbcw && zdcwfront && zdcwback;
148  int zdcpol = zdcpole || zdcpolw;
149 
150  int mtd = dsm.channels[0] & 0x1;
151 
152  int fmssmall1 = dsm.channels[5] >> 1 & 0x1;
153  int fmslarge1 = dsm.channels[5] >> 8 & 0x1;
154  int fmssmall2 = dsm.channels[5] >> 2 & 0x1;
155  int fmslarge2 = dsm.channels[5] >> 9 & 0x1;
156  int fmsfast = fmssmall1 && fmslarge1;
157  int fmsslow = fmssmall2 && fmslarge2;
158  int fmsled = dsm.channels[4] & 0x1;
159  int fpe = dsm.channels[5] >> 14 & 0x1;
160  int fmsledfpe = fmsled || fpe;
161 
162  int zerobias = dsm.channels[6] >> 14 & 0x1;
163 
164  // OUTPUT:
165 
166  // Bit 0 - BIT1
167  // Bit 1 - BIT2
168  // Bit 2 - BHT-0
169  // Bit 3 - BHT-1
170  // Bit 4 - VPDMB
171  // Bit 5 - EHT2
172  // Bit 6 - JP1-selected
173  // Bit 7 - BBCMBLive-pre
174  // Bit 8 - VPDMBLive-pre
175  // Bit 9 - ZDCMB-pre
176  // Bit 10 - ZDCpol
177  // Bit 11 - MTD
178  // Bit 12 - FMSfast
179  // Bit 13 - FMSslow
180  // Bit 14 - FMSled-FPE
181  // Bit 15 - Zerobias
182  // Bits 16:31 - Same definitions as bits 0:15
183 
184  int out = 0;
185 
186  out |= bit1;
187  out |= bit2 << 1;
188  out |= bht << 2;
189  out |= vpdmb << 4;
190  out |= eht2 << 5;
191  out |= jp1_selected << 6;
192  out |= bbcmblivepre << 7;
193  out |= vpdmblivepre << 8;
194  out |= zdcmb << 9;
195  out |= zdcpol << 10;
196  out |= mtd << 11;
197  out |= fmsfast << 12;
198  out |= fmsslow << 13;
199  out |= fmsledfpe << 14;
200  out |= zerobias << 15;
201 
202  // Copy bits 0:15 to bits 16:31
203 
204  out |= out << 16;
205 
206  dsm.output = out;
207 }
Definition: DSM.hh:16