StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMAlgo_BW001_2014_b.cc
1 #include "DSM.hh"
2 //#include "sumTriggerPatchChannels.hh"
3 #include "DSMAlgo_BW001_2014_b.hh"
4 #include "TString.h"
5 
6 void DSMAlgo_BW001_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 
24  // Args: dsm, chMin, chMax, step, targetPedestal, sum, highTowerBits
25 
26  // sumTriggerPatchChannels(dsm, 0, 5, 1, 1, lowEtaSum, highTowerBits);
27  // sumTriggerPatchChannels(dsm, 6, 9, 1, 1, highEtaSum, highTowerBits);
28 
29  //Printf("BW001 register 5 and 6: %d and %d", dsm.registers[5], dsm.registers[6]);
30  unsigned int highTowerBits[10][6];
31  unsigned int trigPatchBits[10];
32 
33  for(int ichn = 0; ichn < 10; ichn++){
34  unsigned int ht = dsm.channels[ichn] & 0x3f;
35  for(int ireg = 0; ireg < 6; ireg++){
36  highTowerBits[ichn][ireg] = ht > dsm.registers[ireg];
37  }
38  unsigned int tp = dsm.channels[ichn] >> 6 & 0x3f;
39  trigPatchBits[ichn] = tp > dsm.registers[6];
40  }
41 
42  unsigned int htBits[6];
43  for(int ireg = 0; ireg < 6; ireg++){
44  htBits[ireg] = 0;
45  for(int ichn = 0; ichn < 10; ichn++){
46  htBits[ireg] |= highTowerBits[ichn][ireg];
47  }
48  }
49  unsigned int tpBits = 0;
50  for(int ichn = 0; ichn < 10; ichn++){
51  tpBits |= trigPatchBits[ichn];
52  }
53  unsigned int httpBits = 0;
54  for(int ichn = 0; ichn < 10; ichn++){
55  httpBits |= (highTowerBits[ichn][5] & trigPatchBits[ichn]);
56  }
57 
58  // OUTPUT (16):
59 
60  // (0-8) Unused
61  // (9) TP threshold bit
62  // (10) HT.TP threshold bit
63  // (11-15) HT threshold bits
64 
65  int out = 0;
66 
67  out |= tpBits << 8;
68  out |= httpBits << 9;
69  out |= htBits[0] << 10;
70  out |= htBits[1] << 11;
71  out |= htBits[2] << 12;
72  out |= htBits[3] << 13;
73  out |= htBits[4] << 14;
74  out |= htBits[5] << 15;
75 
76  dsm.output = out;
77 
78 }
79 
Definition: DSM.hh:16