StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEdsm2.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 "EEdsm2.h"
24 
25 //--------------------------------------------------
26 //
27 //--------------------------------------------------
28 EEdsm2::EEdsm2(){
29  mYear=999; // to force initialization
30 }
31 
32 //--------------------------------------------------
33 //--------------------------------------------------
34 EEdsm2::~EEdsm2() { }
35 
36 //--------------------------------------------------
37 //--------------------------------------------------
38 void
39 EEdsm2::clear() {
40  assert(mYear>2000);// to assure it was initialized
41  memset(data,0,sizeof(data));
42 }
43 
44 //--------------------------------------------------
45 //--------------------------------------------------
46 void
47 EEdsm2::setWord(int ch, unsigned short val){
48  assert(ch>=0 && ch<nc);
49  data[ch]=val;
50 }
51 
52 //--------------------------------------------------
53 //--------------------------------------------------
54 unsigned short
55 EEdsm2::getJPthr(int jp) const { //used for adjacent jet patch
56  assert(jp>=0 && jp<6);
57  assert(mYear<2006);
58  int ch= jp/3;
59  int i=jp%3;
60  assert(ch>=0 && ch<nc);
61  unsigned short val=data[ch]>>8;
62  val=val>>(2*i);
63  val=val & 3;
64  return val;
65 }
66 
67 //--------------------------------------------------
68 //--------------------------------------------------
69 unsigned short
70 EEdsm2::get3JPHTthr(int i3p) const { // ??2006
71  int ch=i3p;
72  assert(ch>=0 && ch<nc);
73  unsigned short val=data[ch]>>14;
74  val=val & 3;
75  return val;
76 }
77 
78 //--------------------------------------------------
79 //--------------------------------------------------
80 unsigned short
81 EEdsm2::getHTTPthr(int i3p) const { //selected HT x TP threshold passed?Y/N
82  int ch=i3p;
83  assert(ch>=0 && ch<nc);
84  assert(mYear>=2006);
85  unsigned short val=data[ch] >>7;
86  return val&1;
87 }
88 
89 //--------------------------------------------------
90 //--------------------------------------------------
91 unsigned short
92 EEdsm2::getTPthr(int i3p) const { //selected TP threshold passed?Y/N
93  int ch=i3p;
94  assert(ch>=0 && ch<nc);
95  assert(mYear>=2006);
96  unsigned short val=data[ch] >>9;
97  return val&1;
98 }
99 
100 //--------------------------------------------------
101 //--------------------------------------------------
102 unsigned short
103 EEdsm2::get3JPsum(int i3p) const {// Etot out of each layer 1 DSM
104 
105  int ch= i3p;
106  assert(ch>=0 && ch<nc);
107  unsigned short val=data[ch]&0xff;
108  if(mYear>=2006) val=val &0x1f; //is now reduced to 5 bits, 0-4,
109  return val;
110 }
111 
112 
113 //--------------------------------------------------
114 //--------------------------------------------------
115 void
116 EEdsm2::print( int k) const {
117  printf("EEdsm2:: INPUTS, year=%d \n",mYear);
118  int i;
119 
120  printf("\nch = ");
121  for(i=nc-1;i>=0;i--) printf(" %4d ",i);
122  printf("\nword = ");
123  for(i=nc-1;i>=0;i--) printf(" x%4.4x ", data[i] );
124  if(mYear>=2006) {
125  printf("\nTPthr = ");
126  for(i=nc-1;i>=0;i--) printf(" %4d ", getTPthr(i) );
127  printf("\nHTTPthr = ");
128  for(i=nc-1;i>=0;i--) printf(" %4d ", getHTTPthr(i) );
129  }
130  printf("\nJP_Falk =");
131  for(i=njp-1;i>=0;i--) printf(" %4d ",i);
132  printf("\nJP_Steve=");
133  for(i=njp-1;i>=0; i--) printf(" %4d ",(i+2)%6+1);
134 
135  if(mYear<2006) {
136  printf("\nJPthr =");
137  for(i=njp-1;i>=0;i--) printf(" %4d ", getJPthr(i));
138  }
139  printf("\n");
140 
141  const char *txt="5bit";
142  if(mYear<2006)txt="8bit";
143 
144  for(i=0;i<2;i++){
145  printf("3x.9 JP_Falk(%d+%d+%d) energy/dec: %s=%d HTthr=%d\n",3*i,3*i+1,3*i+2,txt,get3JPsum(i), get3JPHTthr(i));
146  }
147 }
148 
149 // $Log: EEdsm2.cxx,v $
150 // Revision 1.2 2010/04/18 06:05:25 pibero
151 // Address compiler warnings.
152 //
153 // Revision 1.1 2009/10/12 18:04:26 pibero
154 // Moved StEEmcUtil/EEdsm to StTriggerUtilities/Eemc
155 //
156 // Revision 1.4 2009/02/24 03:56:19 ogrebeny
157 // Corrected const-ness
158 //
159 // Revision 1.3 2006/04/05 18:34:10 balewski
160 // new DSM bit assignment in 2006,
161 // possibly lost backward compatibility
162 // use tagged 2005 version if needed
163 //
164 // Revision 1.2 2005/02/01 22:13:40 perev
165 // Compatibility to redhat
166 //
167 // Revision 1.1 2004/11/29 20:12:59 balewski
168 // first
169 //
170 // Revision 1.1 2004/02/17 03:09:17 balewski
171 // *** empty log message ***
172 //
173