StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSCReader.cxx
1 /***************************************************************************
2  *
3  *
4  *
5  * Author: Herbert Ward
6  ***************************************************************************
7  *
8  * Description: Offline Wrapper for DAQ SC reader classes
9  *
10  ***************************************************************************
11  *
12  *
13  *
14  **************************************************************************/
15 #include <string.h>
16 #include <stdio.h>
17 #include <errno.h>
18 #include <assert.h>
19 #include "StSCReader.h"
20 #include "RTS/src/DAQ_SC/sc.h"
21 #include "tables/St_trigDetSums_Table.h"
22 
23 #ifdef sc
24 # error "sc_t redefinition"
25 #endif
26 #define sc (*(fSC))
27 
28 // Copy of the sc_t from DAQ_SC/daq_sc.h
29 //#include "DAQ_SC/daq-sc.h"
30 
31 //____________________________________________________________
32 void StSCReader::FillTime( unsigned int utime)
33 {
34  //Keep BBCBkg scalers flipped as they were historically before 2009
35  //Note that new DAQ reader leads to UTime = 0, or tm_year=70 (1970)
36  //but new DAQ reader only gets used for 2009+ anyhow
37  time_t UTime = utime; //er->getEventInfo().UnixTime;
38  struct tm *time=gmtime(&UTime);
39  flipBBCBkg = (time->tm_year > 95 && time->tm_year < 109 ? 1 : 0);
40  useNoKillers = (time->tm_year > 110);
41  useEPD = (time->tm_year > 118 || (time->tm_year == 118 && time->tm_mon > 2));
42 }
43 
44 double StSCReader::getCTBWest() {
45  return 0;
46 }
47 
48 double StSCReader::getCTBEast() {
49  return 0;
50 }
51 
52 double StSCReader::getCTBOrTOFp() {
53  return 0;
54 }
55 
56 double StSCReader::getTOFp() {
57  return 0;
58 }
59 
60 double StSCReader::getZDCWest() {
61  return sc.rich_scalers[6];
62 }
63 
64 double StSCReader::getZDCEast() {
65  return sc.rich_scalers[5];
66 }
67 
68 double StSCReader::getZDCX() {
69  return sc.rich_scalers[7];
70 }
71 
72 double StSCReader::getZDCWestNoKiller() {
73  return sc.rich_scalers[11];
74 }
75 
76 double StSCReader::getZDCEastNoKiller() {
77  return sc.rich_scalers[12];
78 }
79 
80 double StSCReader::getZDCXNoKiller() {
81  return sc.rich_scalers[14];
82 }
83 
84 double StSCReader::getEPDX() {
85  return sc.rich_scalers[13];
86 }
87 
88 double StSCReader::getMult() {
89  return sc.rich_scalers[10];
90 }
91 
92 double StSCReader::getL0() {
93  return 0;
94 }
95 
96 double StSCReader::getBBCX() {
97  return sc.rich_scalers[2];
98 }
99 
100 double StSCReader::getBBCXCTB() {
101  return 0;
102 }
103 
104 double StSCReader::getBBCWest() {
105  return sc.rich_scalers[1];
106 }
107 
108 double StSCReader::getBBCEast() {
109  return sc.rich_scalers[0];
110 }
111 
112 double StSCReader::getBBCYellowBkg() {
113  return sc.rich_scalers[3 + flipBBCBkg];
114 }
115 
116 double StSCReader::getBBCBlueBkg() {
117  return sc.rich_scalers[4 - flipBBCBkg];
118 }
119 
120 double StSCReader::getPVPDWest() {
121  return sc.rich_scalers[9];
122 }
123 
124 double StSCReader::getPVPDEast() {
125  return sc.rich_scalers[8];
126 }
127 
128 unsigned int StSCReader::getValid() {
129  return sc.valid;
130 }
131 
132 unsigned int StSCReader::getTime() {
133  return sc.time;
134 }
135 
136 int StSCReader::getTimelag() {
137  return sc.timelag;
138 }
139 
140 float StSCReader::getMagField() {
141  return sc.mag_field;
142 }
143 
144 StSCReader::StSCReader(sc_t *daqsc,unsigned int utime) : fSC(daqsc)
145 { FillTime(utime); }
146 
147 StSCReader::~StSCReader() { }
148 
149 int StSCReader::close() {
150  // delete fSCImpReader; fSCImpReader=0;
151  return 1;
152 }
153 
154 int StSCReader::Update() {
155  return 1;
156 }
157 
158 char StSCReader::thereIsSCData() {
159  // Make sure at least one non-zero ZDC or BBC scaler
160  // because of missing SCPresent value in 2005-2006
161  if (getZDCWest() || getZDCEast() ||
162  getBBCWest() || getBBCEast()) return 7; // TRUE
163  return 0; //FALSE
164 }
165 
166 TDataSet* StSCReader::getSCTable(unsigned long runno) {
167  St_trigDetSums* table = new St_trigDetSums("trigDetSums",1);
168  trigDetSums_st* tb = table->GetTable();
169  if (useNoKillers) { // use otherwise empty space
170  tb->ctbWest = getZDCWestNoKiller();
171  tb->ctbEast = getZDCEastNoKiller();
172  tb->ctbTOFp = getZDCXNoKiller();
173  } else {
174  tb->ctbWest = getCTBWest();
175  tb->ctbEast = getCTBEast();
176  tb->ctbTOFp = getCTBOrTOFp();
177  }
178  if (useEPD) { // use otherwise empty space
179  tb->tofp = getEPDX();
180  } else {
181  tb->tofp = getTOFp();
182  }
183  tb->zdcWest = getZDCWest();
184  tb->zdcEast = getZDCEast();
185  tb->zdcX = getZDCX();
186  tb->mult = getMult();
187  tb->L0 = getL0();
188  tb->bbcX = getBBCX();
189  tb->bbcXctbTOFp = getBBCXCTB();
190  tb->bbcWest = getBBCWest();
191  tb->bbcEast = getBBCEast();
192  tb->bbcYellowBkg = getBBCYellowBkg();
193  tb->bbcBlueBkg = getBBCBlueBkg();
194  tb->pvpdWest = getPVPDWest();
195  tb->pvpdEast = getPVPDEast();
196  tb->runNumber = runno;
197  tb->timeOffset = getTime();
198  table->SetNRows(1);
199  return table;
200 }
Definition: daq_sc.h:6