StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_EM201_2014_b.cc
1 //
2 // Pibero Djawotho <pibero@comp.tamu.edu>
3 // Texas A&M University Cyclotron Institute
4 // 7 Jan 2014_b
5 //
6 #include "bits.hh"
7 #include "DSM.hh"
8 #include "DSMAlgo_EM201_2014_b.hh"
9 #include "TString.h"
10 
11 void DSMAlgo_EM201_2014_b::operator()(DSM& dsm)
12 {
13  // INPUT:
14 
15  // 6 channels from BEMC
16 
17  // BEMC BC101 10 o'clock
18  // BEMC BC102 12 o'clock
19  // BEMC BC103 2 o'clock
20  // BEMC BC104 4 o'clock
21  // BEMC BC105 6 o'clock
22  // BEMC BC106 8 o'clock
23 
24  // bits 0-7 unused
25  // bit 8 DAQ10k test bit
26  // bit 9 TP threshold bit
27  // bit 10 HT.TP threshold bit
28  // bits 11-15 HT threshold bits
29 
30  // 2 channels from EEMC
31 
32  // EEMC EE101 4, 6 and 8 o'clock
33  // EEMC EE102 10, 12 and 2 o'clock
34 
35  // bits 0-13 unused
36  // bits 14-15 HT threshold bits
37 
38  // REGISTERS:
39 
40  // R0: DAQ10k-Sector-Count(3)
41  // R1: EMC-UPC-Topo-Swith (3)
42  // ACTION:
43  const int R0 = dsm.registers[0];
44  const int R1 = dsm.registers[1];
45  //Printf("EM201 R1 = 0x%x", R1);
46  int bemcHT = 0;
47  int bemcTP = 0;
48  int bemcHTTP = 0;
49 
50  // Combine (OR) the HT bits from the six BEMC layer 1 DSM's
51  int bemcTPBit[6];
52  int bemcHTTPBit[6];
53  int bemcHTUPCBit[6];
54 
55  int counterDAQ10K = 0;
56 
57  for (int ichn = 0; ichn < 6; ++ichn) {
58  bemcHT |= dsm.channels[ichn] >> 10 & 0x3f;
59 
60  bemcTPBit[ichn] = dsm.channels[ichn] >> 8 & 0x1;
61  bemcTP |= bemcTPBit[ichn];
62 
63  bemcHTTPBit[ichn] = dsm.channels[ichn] >> 9 & 0x1;
64  bemcHTTP |= bemcHTTPBit[ichn];
65 
66  bemcHTUPCBit[ichn] = dsm.channels[ichn] >> 15 & 0x1;
67 
68  counterDAQ10K += dsm.channels[ichn] >> 7 & 0x1;
69  }
70  int bemcDAQ10K = counterDAQ10K >= R0;
71 
72  // Combine (OR) the HT bits from the two EEMC layer 1 DSM's
73 
74  int eemcHT = 0;
75 
76  for (int ichn = 6; ichn < 8; ++ichn) {
77  eemcHT |= dsm.channels[ichn] >> 14 & 0x3;
78  }
79 
80  int tpB2B = 0;
81  int tpNONADJ = 0;
82 
83  int httpB2B = 0;
84  int httpNONADJ = 0;
85 
86  int htUPCB2B = 0;
87  int htUPCNONADJ = 0;
88 
89  for(int ichn = 0; ichn < 3; ichn++){
90  int jchn = (ichn+3)%12;
91  tpB2B |= bemcTPBit[ichn] && bemcTPBit[jchn];
92  httpB2B |= bemcHTTPBit[ichn] && bemcHTTPBit[jchn];
93  htUPCB2B |= bemcHTUPCBit[ichn] && bemcHTUPCBit[jchn];
94  }
95 
96  tpNONADJ = (bemcTPBit[0] && (bemcTPBit[2] || bemcTPBit[3] || bemcTPBit[4]))
97  || (bemcTPBit[1] && (bemcTPBit[3] || bemcTPBit[4] || bemcTPBit[5]))
98  || (bemcTPBit[2] && (bemcTPBit[4] || bemcTPBit[5]))
99  || (bemcTPBit[3] && bemcTPBit[5]);
100 
101  httpNONADJ = (bemcHTTPBit[0] && (bemcHTTPBit[2] || bemcHTTPBit[3] || bemcHTTPBit[4]))
102  || (bemcHTTPBit[1] && (bemcHTTPBit[3] || bemcHTTPBit[4] || bemcHTTPBit[5]))
103  || (bemcHTTPBit[2] && (bemcHTTPBit[4] || bemcHTTPBit[5]))
104  || (bemcHTTPBit[3] && bemcHTTPBit[5]);
105 
106  htUPCNONADJ = (bemcHTUPCBit[0] && (bemcHTUPCBit[2] || bemcHTUPCBit[3] || bemcHTUPCBit[4]))
107  || (bemcHTUPCBit[1] && (bemcHTUPCBit[3] || bemcHTUPCBit[4] || bemcHTUPCBit[5]))
108  || (bemcHTUPCBit[2] && (bemcHTUPCBit[4] || bemcHTUPCBit[5]))
109  || (bemcHTUPCBit[3] && bemcHTUPCBit[5]);
110 
111  int tpTopo = 0;
112  if(btest(R1, 0)) tpTopo = tpB2B;
113  else tpTopo = tpNONADJ;
114 
115  int httpTopo = 0;
116  if(btest(R1, 1)) { //Printf("back to back");
117  httpTopo = httpB2B; }
118  else httpTopo = httpNONADJ;
119 
120  int htUPCTopo = 0;
121  if(btest(R1, 2)) htUPCTopo = htUPCB2B;
122  else htUPCTopo = htUPCNONADJ;
123  // OUTPUT (16):
124 
125  // (0:4) Barrel HT bits (5)
126  // (5) Barrel HT UPC
127  // (6) Barrel TP bit
128  // (7) Barrel HT.TP bit
129  // (8) Barrel TP-based topo bit
130  // (9) Barrel HTTP-based topo bit
131  // (10) Barrel UPC-based topo bit
132  // (11) Unused
133  // (12) Unused
134  // (13:14) Endcap HT bits (2)
135  // (15) DAQ10k
136 
137  int out = 0;
138 
139  out |= (bemcHT & 0x3f);
140  out |= bemcTP << 6;
141  out |= bemcHTTP << 7;
142  out |= tpTopo << 8;
143  out |= httpTopo << 9;
144  out |= htUPCTopo << 10;
145  out |= eemcHT << 13;
146  out |= bemcDAQ10K << 15;
147 
148  dsm.output = out;
149 
150 }
Definition: DSM.hh:16