StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_BC101_2015.cc
1 #include "DSMAlgo_BC101_2015.hh"
2 
3 void DSMAlgo_BC101_2015::operator()(DSM& dsm)
4 {
5  // INPUT:
6 
7  // ----------------------------------------------------------------------
8  // BC101 - ch0 - BE001 | B101 - ch1 - BW001 |
9  // ch2 - BE002 | ch3 - BW002 |
10  // ch4 - BE003 - JP1 (0-15) | ch5 - BW003 - JP1 (0-15) |
11  // ----------------------------------------------------------------------
12  // BC102 - ch0 - BE003 - JP6 (16-31) | B102 - ch1 - BW003 - JP6 (16-31) |
13  // ch2 - BE004 | ch3 - BW004 |
14  // ch4 - BE005 | ch5 - BW005 |
15  // ----------------------------------------------------------------------
16 
17  // From each channel:
18 
19  // (0-5) TP sum for low-eta group (6)
20  // (6-11) TP sum for high-eta group (6)
21  // (12-15) HT bits (4)
22 
23  // REGISTERS:
24 
25  // R0: BEMC-Jet-Patch-Th0 (9)
26  // R1: BEMC-Jet-Patch-Th1 (9)
27  // R2: BEMC-Jet-Patch-Th2 (9)
28 
29  // ACTION:
30 
31  int jpx; // East (-1 < eta < 0)
32  int jpy; // Middle (-0.6 < eta < 0.4)
33  int jpz; // West (0 < eta < 1)
34  int jpPartial; // Partial (0.4 < eta < 1)
35 
36  int highTowerBits;
37 
38  getBemcJetPatchSums2015A(dsm,jpx,jpy,jpz,jpPartial,highTowerBits);
39 
40  // Compare each jet patch sum to three thresholds
41  // and then pack results for each jet patch into
42  // 2-bit integer.
43 
44  int jpxBits = 0;
45  int jpyBits = 0;
46  int jpzBits = 0;
47  //register counts
48  int rcounts = 0;
49  for(int ir = 0; ir < 6; ir++){
50  if(dsm.registers[ir] > 0) rcounts++;
51  }
52  //BEMC-JP-th2-East BEMC-JP-th2-Mid BEMC-JP-th2-West weren't properly set up in the offlince database therefore still using the th2-East for th2-Mid and th2-West
53  //printf("counts=%d r2=%d r3=%d r4=%d\n", rcounts, dsm.registers[2], dsm.registers[3], dsm.registers[4]);
54  for (int reg = 0; reg < 2; ++reg) {
55  if (jpx > dsm.registers[reg]) ++jpxBits;
56  if (jpy > dsm.registers[reg]) ++jpyBits;
57  if (jpz > dsm.registers[reg]) ++jpzBits;
58  }
59  if(rcounts >= 5){
60  //2015 pAu 3 registers
61  if (jpx > dsm.registers[2]) ++jpxBits;
62  if (jpy > dsm.registers[3]) ++jpyBits;
63  if (jpz > dsm.registers[4]) ++jpzBits;
64  }else{
65  //2015 pp 3 registers
66  if (jpx > dsm.registers[2]) ++jpxBits;
67  if (jpy > dsm.registers[2]) ++jpyBits;
68  if (jpz > dsm.registers[2]) ++jpzBits;
69  }
70 
71  int daq10kBits = 0;
72 
73  for (int ch = 0; ch < 6; ++ch) {
74  int htBits = dsm.channels[ch] >> 12 & 0xf;
75  daq10kBits |= (htBits >> dsm.registers[5] & 0x1) << ch;
76  }
77 
78  // OUTPUT (16+6):
79 
80  // (0-1) JPX threshold bits (2)
81  // (2-3) JPY threshold bits (2)
82  // (4-5) JPZ threshold bits (2)
83  // (6-11) JPpartial sum (6)
84  // (12-15) HT bits (4)
85 
86  // (16-21) DAQ10k HT bits (6)
87 
88  int out = 0;
89 
90  out |= jpxBits;
91  out |= jpyBits << 2;
92  out |= jpzBits << 4;
93  out |= jpPartial << 6;
94  out |= highTowerBits << 12;
95 
96  out |= daq10kBits << 16;
97 
98  dsm.output = out;
99  // INFO:
100 
101  dsm.info[0] = jpx;
102  dsm.info[1] = jpy;
103  dsm.info[2] = jpz;
104  //partial sum
105  dsm.info[3] = jpPartial;
106 }
107 void getBemcJetPatchSums2015A(const DSM& bc101, int& jpx, int& jpy, int& jpz, int& jpPartial, int& highTowerBits)
108 {
109  jpx = 0;
110  jpy = 0;
111  jpz = 0;
112  jpPartial = 0;
113  highTowerBits = 0;
114 
115  // East (ch0/2/4 - even channels)
116 
117  for (int ch = 0; ch <= 4; ch += 2) {
118  int lowEtaSum = bc101.channels[ch] & 0x3f;
119  int highEtaSum = bc101.channels[ch] >> 6 & 0x3f;
120  jpx += lowEtaSum + highEtaSum;
121  jpy += lowEtaSum;
122  highTowerBits |= bc101.channels[ch] >> 12 & 0xf;
123  }
124 
125  // West (ch1/3/5 - odd channels)
126 
127  for (int ch = 1; ch <= 5; ch += 2) {
128  int lowEtaSum = bc101.channels[ch] & 0x3f;
129  int highEtaSum = bc101.channels[ch] >> 6 & 0x3f;
130  jpy += lowEtaSum;
131  jpz += lowEtaSum + highEtaSum;
132  jpPartial += highEtaSum;
133  highTowerBits |= bc101.channels[ch] >> 12 & 0xf;
134  }
135 
136  // If overflow, set JPpartial sum to max
137  if (jpPartial > 63) jpPartial = 63;
138 }
Definition: DSM.hh:16