StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_BW003_2014_b.cc
1 #include "DSM.hh"
2 //#include "sumTriggerPatchChannels.hh"
3 #include "DSMAlgo_BW003_2014_b.hh"
4 #include "TString.h"
5 
6 void DSMAlgo_BW003_2014_b::operator()(DSM& dsm)
7 {
8  // INPUT:
9 
10  // 10 x 12-bit BEMC channels
11  // (5-0) high-tower
12  // (11-6) trigger-patch
13 
14  // REGISTERS:
15 
16  // R0: BEMC-High-Tower-Th0 (6)
17  // R1: BEMC-High-Tower-Th1 (6)
18  // R2: BEMC-High-Tower-Th2 (6)
19  // R3: BEMC-High-Tower-Th3 (6)
20  // R4: BEMC-High-Tower-Th4 (6)
21  // R5: BEMC-High-Tower-UPC (6)
22  // R6: BEMC-Trig-Patch-UPC (6)
23  //Printf("BW003 register 5 and 6: %d and %d", dsm.registers[5], dsm.registers[6]);
24 
25  unsigned int highTowerBits[10][6];
26  unsigned int trigPatchBits[10];
27 
28  for(int ichn = 0; ichn < 10; ichn++){
29  unsigned int ht = dsm.channels[ichn] & 0x3f;
30  for(int ireg = 0; ireg < 6; ireg++){
31  highTowerBits[ichn][ireg] = ht > dsm.registers[ireg];
32  }
33  unsigned int tp = dsm.channels[ichn] >> 6 & 0x3f;
34  trigPatchBits[ichn] = tp > dsm.registers[5];
35  }
36 
37  unsigned int evenhtBits[6];
38  unsigned int oddhtBits[6];
39 
40  for(int ireg = 0; ireg < 6; ireg++){
41  evenhtBits[ireg] = 0;
42  oddhtBits[ireg] = 0;
43 
44  for(int iichn = 0; iichn < 5; iichn++){
45  evenhtBits[ireg] |= highTowerBits[2*iichn][ireg];
46  oddhtBits[ireg] |= highTowerBits[2*iichn+1][ireg];
47  }
48  }
49 
50  unsigned int eventpBits = 0;
51  unsigned int oddtpBits = 0;
52 
53  for(int iichn = 0; iichn < 5; iichn++){
54  eventpBits |= trigPatchBits[2*iichn];
55  oddtpBits |= trigPatchBits[2*iichn+1];
56  }
57 
58  unsigned int evenhttpBits = 0;
59  unsigned int oddhttpBits = 0;
60  for(int iichn = 0; iichn < 5; iichn++){
61  evenhttpBits |= (highTowerBits[2*iichn][5] & trigPatchBits[2*iichn]);
62  oddhttpBits |= (highTowerBits[2*iichn+1][5] & trigPatchBits[2*iichn+1]);
63  }
64 
65  // OUTPUT (16):
66 
67  // (0-8) Unused
68  // (9) TP threshold bit odd channels
69  // (10) HT.TP threshold bit odd channels
70  // (11-15) HT threshold bits odd channels
71  // (16-24) Unused
72  // (25) TP threshold bit even channels
73  // (26) HT.TP threshold bit even channels
74  // (27-31) HT threshold bit even channels
75  int out = 0;
76 
77  out |= oddtpBits << 8;
78  out |= oddhttpBits << 9;
79  out |= oddhtBits[0] << 10;
80  out |= oddhtBits[1] << 11;
81  out |= oddhtBits[2] << 12;
82  out |= oddhtBits[3] << 13;
83  out |= oddhtBits[4] << 14;
84  out |= oddhtBits[5] << 15;
85 
86  out |= eventpBits << 24;
87  out |= evenhttpBits << 25;
88  out |= evenhtBits[0] << 26;
89  out |= evenhtBits[1] << 27;
90  out |= evenhtBits[2] << 28;
91  out |= evenhtBits[3] << 29;
92  out |= evenhtBits[4] << 30;
93  out |= evenhtBits[5] << 31;
94 
95  dsm.output = out;
96 
97 }
Definition: DSM.hh:16