StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BEdsm2.cxx
1 #include <iostream>
2 #include <assert.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
6 
7 /*
8 >Jan:
9 >in 2005 pairs of bits 8+9, 10+11, 12+13 carried
10 >3 JP thresholds results. This is gone for 2006+, right?
11 >So I need to disable this part of the code for years>=2006.
12 
13 Steve:
14 Yes, these bits formerly used for adjacent jet patch use are now gone, so we do not have output bits that handle JP bits for individual jet patches.
15 
16 >Also bits 0-7 used to carry Etot - now are gone, right?
17 >
18 >
19 Etot out of each layer 1 DSM is now reduced to 5 bits, 0-4, in order to allow Eleanor to form the sum of 8 layer 1 DSM's in the layer 2 DSM. Bits 5-6 are now empty, and bit 7 has been reassigned to register-selected HT x TP threshold.
20 
21 */
22 
23 #include "BEdsm2.h"
24 
25 //--------------------------------------------------
26 //
27 //--------------------------------------------------
28 BEdsm2::BEdsm2(){
29  mYear=999; // to force initialization
30 }
31 
32 //--------------------------------------------------
33 //--------------------------------------------------
34 BEdsm2::~BEdsm2() { }
35 
36 //--------------------------------------------------
37 //--------------------------------------------------
38 void
39 BEdsm2::clear() {
40  memset(data,0,sizeof(data));
41 }
42 
43 //--------------------------------------------------
44 //--------------------------------------------------
45 void
46 BEdsm2::setWord(int ch, unsigned short val){
47  assert(ch>=0 && ch<nc);
48  data[ch]=val;
49 }
50 
51 
52 //--------------------------------------------------
53 //--------------------------------------------------
54 int
55 BEdsm2::getInpHT2bit(int i3p) const { // year 2006
56  int ch=i3p;
57  assert(ch>=0 && ch<nc);
58  unsigned short val=data[ch] >> 12;
59  val=val & 3;
60  return val;
61 }
62 
63 //--------------------------------------------------
64 //--------------------------------------------------
65 int
66 BEdsm2::getInpHT2bit_2(int i3p) const { // year 2006
67  int ch=i3p;
68  assert(ch>=0 && ch<nc);
69  unsigned short val=data[ch] >> 14;
70  val=val & 3;
71  return val;
72 }
73 
74 
75 //--------------------------------------------------
76 //--------------------------------------------------
77 int
78 BEdsm2::getInpJP2bit(int i3p) const { // year 2006
79  int ch=i3p;
80  assert(ch>=0 && ch<nc);
81  unsigned short val=data[ch] >> 10;
82  val=val & 3;
83  return val;
84 }
85 
86 //--------------------------------------------------
87 //--------------------------------------------------
88 int
89 BEdsm2::getInpHTTP1bit(int i3p) const { //selected HT x TP threshold passed?Y/N
90  int ch=i3p;
91  assert(ch>=0 && ch<nc);
92  assert(mYear>=2006);
93  unsigned short val=data[ch] >> 7;
94  val=val & 1;
95  return val;
96 }
97 
98 //--------------------------------------------------
99 //--------------------------------------------------
100 int
101 BEdsm2::getInpTP1bit(int i3p) const { //selected TP threshold passed?Y/N
102  int ch=i3p;
103  assert(ch>=0 && ch<nc);
104  assert(mYear>=2006);
105  unsigned short val=data[ch] >> 9;
106  val=val & 1;
107  return val;
108 }
109 
110 
111 //--------------------------------------------------
112 //--------------------------------------------------
113 unsigned short
114 BEdsm2::getJPthr(int jp) const { //used for adjacent jet patch
115  assert(jp>=0 && jp<6);
116  assert(mYear<2006);
117  int ch= jp/3;
118  int i=jp%3;
119  assert(ch>=0 && ch<nc);
120  unsigned short val=data[ch]>>8;
121  val=val>>(2*i);
122  val=val & 3;
123  return val;
124 }
125 
126 
127 //--------------------------------------------------
128 //--------------------------------------------------
129 int
130 BEdsm2::getInpEsum5bit(int i3p) const {// Etot out of each layer 1 DSM
131 
132  int ch= i3p;
133  assert(ch>=0 && ch<nc);
134  unsigned short val=data[ch] & 0xff;
135  if(mYear>=2006) val=val & 0x1f; //is now reduced to 5 bits, 0-4,
136  return val;
137 }
138 
139 
140 //--------------------------------------------------
141 //--------------------------------------------------
142 void
143 BEdsm2::print( int k) const {
144  printf("BEdsm2:: INPUTS, year=%d \n",mYear);
145  int i;
146 
147  printf("ch = ");
148  for(i=nc-1;i>=0;i--) printf(" %4d ",i);
149  printf("\nword = ");
150  for(i=nc-1;i>=0;i--) printf(" x%4.4x ", data[i] );
151  if(mYear>=2006) {
152  printf("\ninpTP 1bit = ");
153  for(i=nc-1;i>=0;i--) printf(" %4d ", getInpTP1bit(i) );
154  printf("\nHTTPthr = ");
155  for(i=nc-1;i>=0;i--) printf(" %4d ", getInpHTTP1bit(i) );
156  }
157 
158 #if 0
159  printf("\nJP_Falk =");
160  for(i=njp-1;i>=0;i--) printf(" %4d ",i);
161  printf("\nJP_Steve=");
162  for(i=njp-1;i>=0; i--) printf(" %4d ",(i+2)%6+1);
163 #endif
164 
165  if(mYear<2006) {
166  printf("\nJPthr =");
167  for(i=njp-1;i>=0;i--) printf(" %4d ", getJPthr(i));
168  }
169  printf("\n");
170 
171  const char *txt="5bit";
172  if(mYear<2006)txt="8bit";
173 
174  for(i=0;i<2;i++){
175  printf("3x.9 JP_Falk(%d+%d+%d) energy/dec: %s=%d HT2bit=%d (only for EEMC)\n",3*i,3*i+1,3*i+2,txt,getInpEsum5bit(i), getInpHT2bit(i));
176  }
177  printf("\n");
178 
179 }
180 
181 // $Log: BEdsm2.cxx,v $
182 // Revision 1.2 2010/04/18 06:05:25 pibero
183 // Address compiler warnings.
184 //
185 // Revision 1.1 2009/10/12 18:04:24 pibero
186 // Moved StEEmcUtil/EEdsm to StTriggerUtilities/Eemc
187 //
188 // Revision 1.2 2009/02/24 03:56:18 ogrebeny
189 // Corrected const-ness
190 //
191 // Revision 1.1 2007/08/17 01:15:34 balewski
192 // full blown Endcap trigger simu, by Xin
193 //
194 // Revision 1.3 2006/04/05 18:34:10 balewski
195 // new DSM bit assignment in 2006,
196 // possibly lost backward compatibility
197 // use tagged 2005 version if needed
198 //
199 // Revision 1.2 2005/02/01 22:13:40 perev
200 // Compatibility to redhat
201 //
202 // Revision 1.1 2004/11/29 20:12:59 balewski
203 // first
204 //
205 // Revision 1.1 2004/02/17 03:09:17 balewski
206 // *** empty log message ***
207 //
208