StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StCtbTriggerDetector.cxx
1 /***************************************************************************
2  *
3  * $Id: StCtbTriggerDetector.cxx,v 2.11 2009/04/16 15:23:10 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Sep 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StCtbTriggerDetector.cxx,v $
13  * Revision 2.11 2009/04/16 15:23:10 ullrich
14  * Fix for bug #1516
15  *
16  * Revision 2.10 2007/07/11 23:06:45 perev
17  * Cleanup+fix StXXXTriggerDetector
18  *
19  * Revision 2.9 2004/07/20 18:02:26 jeromel
20  * Updates from Akio to fix CTB issues.
21  *
22  * Revision 2.8 2004/02/11 01:42:09 ullrich
23  * Added new constructor to load data from StTriggerData.
24  *
25  * Revision 2.7 2002/11/19 22:09:08 ullrich
26  * Corrected bug: loop in mips() was off by one.
27  *
28  * Revision 2.6 2002/11/19 20:21:00 ullrich
29  * Added method to sum all mips.
30  *
31  * Revision 2.5 2001/04/05 04:00:47 ullrich
32  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
33  *
34  * Revision 2.4 2000/05/09 10:22:17 ullrich
35  * Updated to cope with modified dst_TrgDet.idl
36  *
37  * Revision 2.3 1999/12/20 12:54:45 ullrich
38  * Adapted changed in trigger table dst_TrgDet
39  *
40  * Revision 2.2 1999/10/28 22:24:58 ullrich
41  * Adapted new StArray version. First version to compile on Linux and Sun.
42  *
43  * Revision 2.1 1999/10/13 19:44:28 ullrich
44  * Initial Revision
45  *
46  **************************************************************************/
47 #include "StCtbTriggerDetector.h"
48 #include "tables/St_dst_TrgDet_Table.h"
49 #include "StTriggerData.h"
50 
51 static const char rcsid[] = "$Id: StCtbTriggerDetector.cxx,v 2.11 2009/04/16 15:23:10 ullrich Exp $";
52 
53 ClassImp(StCtbTriggerDetector)
54 
56 {
57  memset(mBeg,0,mEnd-mBeg);
58 }
59 
60 StCtbTriggerDetector::StCtbTriggerDetector(const dst_TrgDet_st& t)
61 {
62  memset(mBeg,0,mEnd-mBeg);
63  int i, j, k;
64  for(i=0; i<mMaxTrays; i++) {
65  for(j=0; j<mMaxSlats; j++) {
66  for(k=0; k<mMaxEventSamples; k++) {
67  mMips[i][j][k] = t.nCtb[i][j][k];
68  mTime[i][j][k] = t.timeCtb[i][j][k];
69  }
70  }
71  }
72  for(i=0; i<mMaxAux; i++) {
73  for(j=0; j<mMaxEventSamples; j++) {
74  mAux[i][j] = t.ctbaux[i][j];
75  }
76  }
77  mNumberOfPreSamples = t.npre;
78  mNumberOfPostSamples = t.npost;
79 }
80 
81 StCtbTriggerDetector::StCtbTriggerDetector(const StTriggerData& t)
82 {
83  memset(mBeg,0,mEnd-mBeg);
84  int evtmap[mMaxEventSamples] = {0, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5};
85  int i, j, k, evt;
86 
87  for(i=0; i<mMaxTrays; i++) {
88  for(j=0; j<mMaxSlats; j++) {
89  //No prepost data in daq file ever
90  //for(k=0; k<mMaxEventSamples; k++) {
91  for(k=0; k<1; k++) {
92  evt = evtmap[k];
93  mMips[i][j][k] = t.ctbTraySlat(i,j,evt);
94 
95  //if(t.ctbTraySlat(i,j, evt)>0) {
96  // printf("AKIO! tray=%d slat=%d prepost=%d adc=%f\n",i,j,evt,mMips[i][j][k]);
97  //}
98  }
99  }
100  }
101  mNumberOfPreSamples = 5;
102  mNumberOfPostSamples = 5;
103 }
104 
105 StCtbTriggerDetector::~StCtbTriggerDetector() {/* noop */}
106 
107 unsigned int
108 StCtbTriggerDetector::numberOfTrays() const {return mMaxTrays;}
109 
110 unsigned int
111 StCtbTriggerDetector::numberOfSlats() const {return mMaxSlats;}
112 
113 unsigned int
114 StCtbTriggerDetector::numberOfAuxWords() const {return mMaxAux;}
115 
116 unsigned int
117 StCtbTriggerDetector::numberOfPreSamples() const {return mNumberOfPreSamples;}
118 
119 unsigned int
120 StCtbTriggerDetector::numberOfPostSamples() const {return mNumberOfPostSamples;}
121 
122 float
123 StCtbTriggerDetector::mips(unsigned int i, unsigned int j, unsigned int k) const
124 {
125  return mMips[i][j][k];
126 }
127 
128 double
129 StCtbTriggerDetector::mips(unsigned int evt) const
130 {
131  double sum = 0;
132  for (unsigned int i=0; i<mMaxTrays; i++)
133  for (unsigned int j=0; j<mMaxSlats; j++)
134  sum += mMips[i][j][evt];
135  return sum;
136 }
137 
138 char
139 StCtbTriggerDetector::time(unsigned int i, unsigned int j, unsigned int k) const
140 {
141  return mTime[i][j][k];
142 }
143 
144 float
145 StCtbTriggerDetector::aux(unsigned int i, unsigned int j) const
146 {
147  return mAux[i][j];
148 }
149 
150 void
151 StCtbTriggerDetector::setMips(unsigned int i, unsigned int j, unsigned int k, float val)
152 {
153  mMips[i][j][k] = val;
154 }
155 
156 void
157 StCtbTriggerDetector::setTime(unsigned int i, unsigned int j, unsigned int k, char val)
158 {
159  mTime[i][j][k] = val;
160 }
161 
162 void
163 StCtbTriggerDetector::setAux(unsigned int i, unsigned int j, float val)
164 {
165  mAux[i][j] = val;
166 }
167 
168 void
169 StCtbTriggerDetector::setNumberOfPreSamples(unsigned int val)
170 {
171  mNumberOfPreSamples = val;
172 }
173 
174 void
175 StCtbTriggerDetector::setNumberOfPostSamples(unsigned int val)
176 {
177  mNumberOfPostSamples = val;
178 }
179