StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
sumTriggerPatchChannels.hh
1 //
2 // Pibero Djawotho <pibero@comp.tamu.edu>
3 // Texas A&M University Cyclotron Institute
4 // 7 Jan 2009
5 //
6 
7 #ifndef SUM_TRIGGER_PATCH_CHANNELS_HH
8 #define SUM_TRIGGER_PATCH_CHANNELS_HH
9 
10 #include "DSM.hh"
11 
12 inline void sumTriggerPatchChannels(const DSM& dsm, int chMin, int chMax, int step, int targetPedestal, int& sum, int& highTowerBits)
13 {
14  // Loop over channels, make ADC sum and compare high towers to thresholds
15 
16  int nChannels = 0;
17 
18  for (int ch = chMin; ch <= chMax; ch += step) {
19  int highTower = dsm.channels[ch] & 0x3f;
20 
21  for (int reg = 0; reg < 4; ++reg)
22  highTowerBits |= (highTower > dsm.registers[reg]) << reg;
23 
24  int triggerPatch = dsm.channels[ch] >> 6 & 0x3f;
25 
26  sum += triggerPatch;
27 
28  ++nChannels;
29  }
30 
31  // Reset pedestal to 1
32 
33  if (sum < nChannels)
34  sum = 0;
35  else
36  sum -= (nChannels - targetPedestal);
37 
38  // If overflow, set to max
39 
40  if (sum > 63) sum = 63;
41 }
42 
43 inline void sumTriggerPatchChannels2015(const DSM& dsm, int chMin, int chMax, int step, int targetPedestal, int& sum, int& highTowerBits)
44 {
45  // Loop over channels, make ADC sum and compare high towers to thresholds
46 
47  int nChannels = 0;
48 
49  for (int ch = chMin; ch <= chMax; ch += step) {
50  int highTower = dsm.channels[ch] & 0x3f;
51  //run15 only compare to ht-th2 instead of ht-th3 from previous years
52  for (int reg = 0; reg < 3; ++reg)
53  highTowerBits |= (highTower > dsm.registers[reg]) << reg;
54 
55  int triggerPatch = dsm.channels[ch] >> 6 & 0x3f;
56  //ht_tp bit for run15
57  int ht_tp = (highTower > dsm.registers[3]) && (triggerPatch > dsm.registers[4]);
58  highTowerBits |= ht_tp << 3;
59 
60  sum += triggerPatch;
61 
62  ++nChannels;
63  }
64 
65  // Reset pedestal to 1
66 
67  if (sum < nChannels)
68  sum = 0;
69  else
70  sum -= (nChannels - targetPedestal);
71 
72  // If overflow, set to max
73 
74  if (sum > 63) sum = 63;
75 }
76 #endif // SUM_TRIGGER_PATCH_CHANNELS_HH
Definition: DSM.hh:16