StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EMCdsm2Tree.cxx
1 /**************************************************************
2  * $Id: EMCdsm2Tree.cxx,v 1.3 2009/11/18 15:50:59 pibero Exp $
3  **************************************************************/
4 
5 #include <iostream>
6 #include <assert.h>
7 
8 
9 #include "EMCdsm2Tree.h"
10 #include "BEdsm2.h"
11 
12 
13 //--------------------------------------------------
14 //--------------------------------------------------
15 EMCdsm2Tree::EMCdsm2Tree(const char *nameX) {
16  mYear=-999;
17  BEsumthr8bit=1000;
18  EEsumthr6bit=1000;
19  JPSIthrSelc2bit=1000;
20  BarreSide2bit=1000;
21  EtotThr8bit=1000;
22 
23  be2=new BEdsm2[Nbe2];
24  int i=0;
25  for(i=0; i<Nbe2; i++) be2[i].setYear(-999); // must be defined before use
26  clear();
27  strncpy(name,nameX,mxTxt);
28 }
29 
30 //--------------------------------------------------
31 //--------------------------------------------------
32 EMCdsm2Tree::~EMCdsm2Tree() {
33  //fix it: delete
34  }
35 
36 //--------------------------------------------------
37 //--------------------------------------------------
38 void
39 EMCdsm2Tree::setYear(int x, int BEsumthr, int EEsumthr, int JPSIthrSelc, int BarreSide, int EtotThr) {
40  mYear=x;
41  BEsumthr8bit = BEsumthr;
42  EEsumthr6bit = EEsumthr;
43  JPSIthrSelc2bit = JPSIthrSelc;
44  BarreSide2bit = BarreSide;
45  EtotThr8bit = EtotThr;
46  int i;
47  for (i=0;i<Nbe2;i++) be2[i].setYear(mYear);
48 }
49 
50 //--------------------------------------------------
51 //--------------------------------------------------
52 void
53 EMCdsm2Tree::clear() {
54  int i;
55  for (i=0;i<Nbe2;i++) be2[i].clear();
56  OutEndcapJP2bit=0;
57  OutEndcapHT2bit=0;
58  OutEndcapSum1bit=0;
59  OutEndcapHTTP1bit=0;
60  OutEndcapTP1bit=0;
61  OutBarreJP2bit=0;
62  OutBarreHT2bit=0;
63  OutBarreSum1bit=0;
64  OutBarreJPSi1bit=0;
65  OutBarreHTTP1bit=0;
66  OutBarreTP1bit=0;
67  OutEtot1bit=0;
68 
69  intBarreSum=0;
70  intEndcapSum=0;
71  intEtot=0;
72  // memset(,0,sizeof());
73 
74 }
75 
76 
77 //--------------------------------------------------
78 //--------------------------------------------------
79 void
80 EMCdsm2Tree::setInput16bit(int ibrd, int ch, unsigned short val){
81  // printf("addY %d %d %d\n",brd,ch,val);
82  assert(ibrd>=0 && ibrd<Nbe2);
83  be2[ibrd].setWord(ch,val);
84 
85 }
86 
87 
88 
89 //--------------------------------------------------
90 //--------------------------------------------------
91 void
92 EMCdsm2Tree::compute() {
93  //printf("EMCdsm2Tree(%s) , year=%d compute-EMPTY \n",name,mYear);
94  //printf("\n\n----------- level-2 -----------------\n ");
95 
96 
97  intEndcapSum = getInpEsum5bit(0,0) + getInpEsum5bit(0,1);
98  if ( intEndcapSum > EEsumthr6bit ) OutEndcapSum1bit = 1;
99  else OutEndcapSum1bit = 0;
100 
101  int i;
102  for (i=1; i<Nbe2; i++){
103  intBarreSum = intBarreSum + getInpEsum5bit(i,0) + getInpEsum5bit(i,1);
104  }
105  if ( intBarreSum > BEsumthr8bit ) OutBarreSum1bit = 1;
106  else OutBarreSum1bit = 0;
107 
108  intEtot = intEndcapSum + intBarreSum;
109  if ( intEtot > EtotThr8bit ) OutEtot1bit = 1;
110  else OutEtot1bit = 0;
111 
112  int j,k;
113  for ( j=0; j<Nbe2; j++){
114  for( k=0; k<Nbe2Cha; k++){
115  if ( j==0 ){
116  if ( OutEndcapJP2bit <= getInpJP2bit(j,k) ) OutEndcapJP2bit = getInpJP2bit(j,k) ;
117  if ( OutEndcapHT2bit <= getInpHT2bit(j,k) ) OutEndcapHT2bit = getInpHT2bit(j,k);
118  if ( OutEndcapHTTP1bit <= getInpHTTP1bit(j,k) ) OutEndcapHTTP1bit = getInpHTTP1bit(j,k);
119  if ( OutEndcapTP1bit <= getInpTP1bit(j,k) ) OutEndcapTP1bit = getInpTP1bit(j,k);
120  }
121  if( j>0 ){
122 
123  if ( OutBarreJP2bit <= getInpJP2bit(j,k) ) OutBarreJP2bit = getInpJP2bit(j,k) ;
124  if ( OutBarreHT2bit <= getInpHT2bit(j,k) ) OutBarreHT2bit = getInpHT2bit(j,k);
125  if ( OutBarreHT2bit <= getInpHT2bit_2(j,k) ) OutBarreHT2bit = getInpHT2bit_2(j,k);
126  if ( OutBarreHTTP1bit <= getInpHTTP1bit(j,k) ) OutBarreHTTP1bit = getInpHTTP1bit(j,k);
127  if ( OutBarreTP1bit <= getInpTP1bit(j,k) ) OutBarreTP1bit = getInpTP1bit(j,k);
128 
129  }
130  }
131  }
132 
133  int BarreEast_HT_JPSI[6]={0,0,0,0,0,0};
134  int BarreWest_HT_JPSI[6]={0,0,0,0,0,0};
135 
136  BarreEast_HT_JPSI[0]=getInpHT2bit(1,1);
137  BarreEast_HT_JPSI[1]=getInpHT2bit_2(1,1);
138  BarreEast_HT_JPSI[2]=getInpHT2bit(2,0);
139  BarreEast_HT_JPSI[3]=getInpHT2bit_2(2,0);
140  BarreEast_HT_JPSI[4]=getInpHT2bit(1,0);
141  BarreEast_HT_JPSI[5]=getInpHT2bit_2(1,0);
142 
143  BarreWest_HT_JPSI[0]=getInpHT2bit(3,1);
144  BarreWest_HT_JPSI[1]=getInpHT2bit_2(3,1);
145  BarreWest_HT_JPSI[2]=getInpHT2bit(2,1);
146  BarreWest_HT_JPSI[3]=getInpHT2bit_2(2,1);
147  BarreWest_HT_JPSI[4]=getInpHT2bit(3,0);
148  BarreWest_HT_JPSI[5]=getInpHT2bit_2(3,0);
149 
150  int l;
151  for ( l=0; l<6; l++){
152  if ( BarreEast_HT_JPSI[l] > JPSIthrSelc2bit ) BarreEast_HT_JPSI[l]=1;
153  else BarreEast_HT_JPSI[l]=0;
154 
155  if ( BarreWest_HT_JPSI[l] > JPSIthrSelc2bit ) BarreWest_HT_JPSI[l]=1;
156  else BarreWest_HT_JPSI[l]=0;
157  }
158 
159  if ( BarreEast_HT_JPSI[0] && ( BarreEast_HT_JPSI[2] || BarreEast_HT_JPSI[3] ||BarreEast_HT_JPSI[4] )) OutBarreJPSi1bit=1;
160 
161  if ( BarreEast_HT_JPSI[1] && ( BarreEast_HT_JPSI[3] || BarreEast_HT_JPSI[4] ||BarreEast_HT_JPSI[5] )) OutBarreJPSi1bit=1;
162 
163  if ( BarreEast_HT_JPSI[2] && ( BarreEast_HT_JPSI[4] || BarreEast_HT_JPSI[5] )) OutBarreJPSi1bit=1;
164 
165  if ( BarreEast_HT_JPSI[3] && BarreEast_HT_JPSI[5] ) OutBarreJPSi1bit=1;
166 
167  if ( BarreWest_HT_JPSI[0] && ( BarreWest_HT_JPSI[2] || BarreWest_HT_JPSI[3] ||BarreWest_HT_JPSI[4] )) OutBarreJPSi1bit=1;
168 
169  if ( BarreWest_HT_JPSI[1] && ( BarreWest_HT_JPSI[3] || BarreWest_HT_JPSI[4] ||BarreWest_HT_JPSI[5] )) OutBarreJPSi1bit=1;
170 
171  if ( BarreWest_HT_JPSI[2] && ( BarreWest_HT_JPSI[4] || BarreWest_HT_JPSI[5] )) OutBarreJPSi1bit=1;
172 
173  if ( BarreWest_HT_JPSI[3] && BarreWest_HT_JPSI[5] ) OutBarreJPSi1bit=1;
174 }
175 
176 //--------------------------------------------------
177 //--------------------------------------------------
178 int
179 EMCdsm2Tree::getInpHT2bit(int ibr, int ch) const {
180  assert(ibr>=0 && ibr<Nbe2);
181  return be2[ibr].getInpHT2bit(ch);
182 }
183 
184 //--------------------------------------------------
185 //--------------------------------------------------
186 int
187 EMCdsm2Tree::getInpHT2bit_2(int ibr, int ch) const {
188  assert(ibr>=0 && ibr<Nbe2);
189  return be2[ibr].getInpHT2bit_2(ch);
190 }
191 
192 //--------------------------------------------------
193 //--------------------------------------------------
194 int
195 EMCdsm2Tree::getInpJP2bit(int ibr, int ch) const {
196  assert(ibr>=0 && ibr<Nbe2);
197  return be2[ibr].getInpJP2bit(ch);
198 }
199 
200 
201 //--------------------------------------------------
202 //--------------------------------------------------
203 int
204 EMCdsm2Tree::getInpTP1bit(int ibr, int ch) const {
205  assert(ibr>=0 && ibr<Nbe2);
206  return be2[ibr].getInpTP1bit(ch);
207 }
208 
209 //--------------------------------------------------
210 //--------------------------------------------------
211 int
212 EMCdsm2Tree::getInpHTTP1bit(int ibr, int ch) const {
213  assert(ibr>=0 && ibr<Nbe2);
214  return be2[ibr].getInpHTTP1bit(ch);
215 }
216 
217 //--------------------------------------------------
218 //--------------------------------------------------
219 int
220 EMCdsm2Tree::getInpEsum5bit(int ibr, int ch) const {
221  assert(ibr>=0 && ibr<Nbe2);
222  return be2[ibr].getInpEsum5bit(ch);
223 }
224 
225 
226 
227 //--------------------------------------------------
228 //--------------------------------------------------
229 void
230 EMCdsm2Tree::print( int k) const {
231  printf("EMCdsm2Tree(%s) , year=%d \n",name,mYear);
232 
233  printf("\n\n----------- level-2 -----------------\n ");
234  int i;
235  for (i=0;i<Nbe2;i++) {
236  if(i==0) printf("\nEndcap board=1 ");
237  else printf("\nBarrel board=%d ",i);
238  be2[i].print();
239  if(k==0) break;// reduce printing (k=0 :endcap only)
240  }
241 }
242 
243 
244 
245 
246 /*
247  * $Log: EMCdsm2Tree.cxx,v $
248  * Revision 1.3 2009/11/18 15:50:59 pibero
249  * Address several compiler warnings of the type:
250  *
251  * warning: deprecated conversion from string constant 'char*'
252  *
253  * Revision 1.2 2009/10/13 17:04:03 pibero
254  * Changed location of #include file
255  *
256  * Revision 1.1 2009/10/12 18:04:27 pibero
257  * Moved StEEmcUtil/EEdsm to StTriggerUtilities/Eemc
258  *
259  * Revision 1.2 2009/02/24 03:56:19 ogrebeny
260  * Corrected const-ness
261  *
262  * Revision 1.1 2007/08/17 01:15:38 balewski
263  * full blown Endcap trigger simu, by Xin
264  *
265  */
266 
Definition: BEdsm2.h:7