StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StVpdTriggerDetector.cxx
1 /***************************************************************************
2  *
3  * $Id: StVpdTriggerDetector.cxx,v 2.7 2013/10/30 15:47:16 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Sep 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StVpdTriggerDetector.cxx,v $
13  * Revision 2.7 2013/10/30 15:47:16 ullrich
14  * Added ADCmxq(), TDCmxq() and referring data member (WJL).
15  *
16  * Revision 2.6 2007/04/10 20:13:41 ullrich
17  * Fixed bug in array subscript (Akio).
18  *
19  * Revision 2.5 2007/04/03 20:11:41 ullrich
20  * Modified for actual VPD used in 2007.
21  *
22  * Revision 2.4 2001/04/05 04:00:59 ullrich
23  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
24  *
25  * Revision 2.3 1999/12/21 15:09:25 ullrich
26  * Modified to cope with new compiler version on Sun (CC5.0).
27  *
28  * Revision 2.2 1999/10/28 22:28:12 ullrich
29  * Adapted new StArray version. First version to compile on Linux and Sun.
30  *
31  * Revision 2.1 1999/10/13 19:45:48 ullrich
32  * Initial Revision
33  *
34  **************************************************************************/
35 #include <algorithm>
36 #include "StVpdTriggerDetector.h"
37 #include "tables/St_dst_TrgDet_Table.h"
38 #include "StTriggerData.h"
39 #if !defined(ST_NO_NAMESPACES)
40 using std::fill_n;
41 using std::copy;
42 #endif
43 
44 static const char rcsid[] = "$Id: StVpdTriggerDetector.cxx,v 2.7 2013/10/30 15:47:16 ullrich Exp $";
45 
46 ClassImp(StVpdTriggerDetector)
47 
49 {
50  memset(*mADC,0,mMaxVpdCounter*sizeof(unsigned short));
51  memset(*mTDC,0,mMaxVpdCounter*sizeof(unsigned short));
52  memset(*mADCmxq,0,mMaxVpdCounter*sizeof(unsigned short)); //WJL
53  memset(*mTDCmxq,0,mMaxVpdCounter*sizeof(unsigned short)); //WJL
54  //fill_n(mADC, static_cast<short>(mMaxVpdCounter), 0);
55  //fill_n(mTDC, static_cast<short>(mMaxVpdCounter), 0);
56  //fill_n(mEarliestTDC, 2, 0);
57  mEarliestTDC[0]=0;
58  mEarliestTDC[1]=0;
59  mTimeDifference = 0;
60  mYear = 0;
61 }
62 
63 StVpdTriggerDetector::StVpdTriggerDetector(const dst_TrgDet_st&)
64 {
65  // old legacy code removed - was wrong in the
66  // first place (tu, April 3, 2007)
67 }
68 
69 StVpdTriggerDetector::StVpdTriggerDetector(const StTriggerData& t)
70 {
71  int i;
72  mYear = t.year();
73  if (mYear<2007) return;
74  for (i=0; i<mMaxVpdCounter; i++){
75  mADC[east][i] = t.vpdADC(east, i+1);
76  mTDC[east][i] = t.vpdTDC(east, i+1);
77  mADC[west][i] = t.vpdADC(west, i+1);
78  mTDC[west][i] = t.vpdTDC(west, i+1);
79  mADCmxq[east][i] = t.vpdADCHighThr(east, i+1); //WJL
80  mTDCmxq[east][i] = t.vpdTDCHighThr(east, i+1); //WJL
81  mADCmxq[west][i] = t.vpdADCHighThr(west, i+1); //WJL
82  mTDCmxq[west][i] = t.vpdTDCHighThr(west, i+1); //WJL
83  //
84  //LOG_INFO<<"WJL... "<<i
85  // <<" ADCe "<<mADC[east][i]<<" "<<mADCmxq[east][i]
86  // <<" TDCe "<<mTDC[east][i]<<" "<<mTDCmxq[east][i]
87  // <<" ADCw "<<mADC[west][i]<<" "<<mADCmxq[west][i]
88  // <<" TDCw "<<mTDC[west][i]<<" "<<mTDCmxq[west][i]
89  // <<endm;
90  //
91  }
92  mEarliestTDC[east] = t.vpdEarliestTDC(east);
93  mEarliestTDC[west] = t.vpdEarliestTDC(west);
94  mTimeDifference = t.vpdTimeDifference();
95 }
96 
97 
98 StVpdTriggerDetector::~StVpdTriggerDetector() {/* noop */}
99 
100 unsigned int
101 StVpdTriggerDetector::numberOfVpdCounters() const {return mMaxVpdCounter;}
102 
103 unsigned short
104 StVpdTriggerDetector::ADC(StBeamDirection eastwest, unsigned int i) const
105 {
106  if (i <= mMaxVpdCounter && i!=0)
107  return mADC[eastwest][i-1];
108  else
109  return 0;
110 }
111 
112 unsigned short
113 StVpdTriggerDetector::TDC(StBeamDirection eastwest, unsigned int i) const
114 {
115  if (i <= mMaxVpdCounter && i!=0)
116  return mTDC[eastwest][i-1];
117  else
118  return 0;
119 }
120 
121 unsigned short
122 StVpdTriggerDetector::EarliestTDC(StBeamDirection eastwest) const
123 {
124  return mEarliestTDC[eastwest];
125 }
126 
127 void
128 StVpdTriggerDetector::setADC(StBeamDirection eastwest, unsigned int i, unsigned short v)
129 {
130  if (i <= mMaxVpdCounter && i!=0)
131  mADC[eastwest][i-1] = v;
132 }
133 
134 void
135 StVpdTriggerDetector::setTDC(StBeamDirection eastwest, unsigned int i, unsigned short v)
136 {
137  if (i <= mMaxVpdCounter && i!=0)
138  mTDC[eastwest][i-1] = v;
139 }
140 
141 unsigned short StVpdTriggerDetector::ADCmxq(StBeamDirection eastwest, unsigned int i) const //WJL
142 {
143  if (i <= mMaxVpdCounter && i!=0)
144  return mADCmxq[eastwest][i-1];
145  else
146  return 0;
147 }
148 unsigned short StVpdTriggerDetector::TDCmxq(StBeamDirection eastwest, unsigned int i) const //WJL
149 {
150  if (i <= mMaxVpdCounter && i!=0)
151  return mTDCmxq[eastwest][i-1];
152  else
153  return 0;
154 }
155 void StVpdTriggerDetector::setADCmxq(StBeamDirection eastwest, unsigned int i, unsigned short v) //WJL
156 {
157  if (i <= mMaxVpdCounter && i!=0)
158  mADCmxq[eastwest][i-1] = v;
159 }
160 
161 void StVpdTriggerDetector::setTDCmxq(StBeamDirection eastwest, unsigned int i, unsigned short v) //WJL
162 {
163  if (i <= mMaxVpdCounter && i!=0)
164  mTDCmxq[eastwest][i-1] = v;
165 }
166