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 ? 1 : 0);;
41 }
42 
43 double StSCReader::getCTBWest() {
44  return 0;
45 }
46 
47 double StSCReader::getCTBEast() {
48  return 0;
49 }
50 
51 double StSCReader::getCTBOrTOFp() {
52  return 0;
53 }
54 
55 double StSCReader::getTOFp() {
56  return 0;
57 }
58 
59 double StSCReader::getZDCWest() {
60  return sc.rich_scalers[6];
61 }
62 
63 double StSCReader::getZDCEast() {
64  return sc.rich_scalers[5];
65 }
66 
67 double StSCReader::getZDCX() {
68  return sc.rich_scalers[7];
69 }
70 
71 double StSCReader::getZDCWestNoKiller() {
72  return sc.rich_scalers[11];
73 }
74 
75 double StSCReader::getZDCEastNoKiller() {
76  return sc.rich_scalers[12];
77 }
78 
79 double StSCReader::getZDCXNoKiller() {
80  return sc.rich_scalers[14];
81 }
82 
83 double StSCReader::getMult() {
84  return sc.rich_scalers[10];
85 }
86 
87 double StSCReader::getL0() {
88  return 0;
89 }
90 
91 double StSCReader::getBBCX() {
92  return sc.rich_scalers[2];
93 }
94 
95 double StSCReader::getBBCXCTB() {
96  return 0;
97 }
98 
99 double StSCReader::getBBCWest() {
100  return sc.rich_scalers[1];
101 }
102 
103 double StSCReader::getBBCEast() {
104  return sc.rich_scalers[0];
105 }
106 
107 double StSCReader::getBBCYellowBkg() {
108  return sc.rich_scalers[3 + flipBBCBkg];
109 }
110 
111 double StSCReader::getBBCBlueBkg() {
112  return sc.rich_scalers[4 - flipBBCBkg];
113 }
114 
115 double StSCReader::getPVPDWest() {
116  return sc.rich_scalers[9];
117 }
118 
119 double StSCReader::getPVPDEast() {
120  return sc.rich_scalers[8];
121 }
122 
123 unsigned int StSCReader::getValid() {
124  return sc.valid;
125 }
126 
127 unsigned int StSCReader::getTime() {
128  return sc.time;
129 }
130 
131 int StSCReader::getTimelag() {
132  return sc.timelag;
133 }
134 
135 float StSCReader::getMagField() {
136  return sc.mag_field;
137 }
138 
139 StSCReader::StSCReader(sc_t *daqsc,unsigned int utime) : fSC(daqsc)
140 { FillTime(utime); }
141 
142 StSCReader::~StSCReader() { }
143 
144 int StSCReader::close() {
145  // delete fSCImpReader; fSCImpReader=0;
146  return 1;
147 }
148 
149 int StSCReader::Update() {
150  return 1;
151 }
152 
153 char StSCReader::thereIsSCData() {
154  // Make sure at least one non-zero ZDC or BBC scaler
155  // because of missing SCPresent value in 2005-2006
156  if (getZDCWest() || getZDCEast() ||
157  getBBCWest() || getBBCEast()) return 7; // TRUE
158  return 0; //FALSE
159 }
160 
161 TDataSet* StSCReader::getSCTable(unsigned long runno) {
162  St_trigDetSums* table = new St_trigDetSums("trigDetSums",1);
163  trigDetSums_st* tb = table->GetTable();
164  if (useNoKillers) { // use otherwise empty space
165  tb->ctbWest = getZDCWestNoKiller();
166  tb->ctbEast = getZDCEastNoKiller();
167  tb->ctbTOFp = getZDCXNoKiller();
168  } else {
169  tb->ctbWest = getCTBWest();
170  tb->ctbEast = getCTBEast();
171  tb->ctbTOFp = getCTBOrTOFp();
172  }
173  tb->tofp = getTOFp();
174  tb->zdcWest = getZDCWest();
175  tb->zdcEast = getZDCEast();
176  tb->zdcX = getZDCX();
177  tb->mult = getMult();
178  tb->L0 = getL0();
179  tb->bbcX = getBBCX();
180  tb->bbcXctbTOFp = getBBCXCTB();
181  tb->bbcWest = getBBCWest();
182  tb->bbcEast = getBBCEast();
183  tb->bbcYellowBkg = getBBCYellowBkg();
184  tb->bbcBlueBkg = getBBCBlueBkg();
185  tb->pvpdWest = getPVPDWest();
186  tb->pvpdEast = getPVPDEast();
187  tb->runNumber = runno;
188  tb->timeOffset = getTime();
189  table->SetNRows(1);
190  return table;
191 }
Definition: daq_sc.h:6