00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <string.h>
00016 #include <stdio.h>
00017 #include <errno.h>
00018 #include <assert.h>
00019 #include "StSCReader.h"
00020 #include "RTS/src/DAQ_SC/sc.h"
00021 #include "tables/St_trigDetSums_Table.h"
00022
00023 #ifdef sc
00024 # error "sc_t redefinition"
00025 #endif
00026 #define sc (*(fSC))
00027
00028
00029
00030
00031
00032 void StSCReader::FillTime( unsigned int utime)
00033 {
00034
00035
00036
00037 unsigned int UTime = utime;
00038 struct tm *time=gmtime((time_t*) &UTime);
00039 flipBBCBkg = (time->tm_year > 95 && time->tm_year < 109 ? 1 : 0) ;
00040 }
00041
00042 double StSCReader::getCTBWest() {
00043 return 0;
00044 }
00045
00046 double StSCReader::getCTBEast() {
00047 return 0;
00048 }
00049
00050 double StSCReader::getCTBOrTOFp() {
00051 return 0;
00052 }
00053
00054 double StSCReader::getTOFp() {
00055 return 0;
00056 }
00057
00058 double StSCReader::getZDCWest() {
00059 return sc.rich_scalers[6];
00060 }
00061
00062 double StSCReader::getZDCEast() {
00063 return sc.rich_scalers[5];
00064 }
00065
00066 double StSCReader::getZDCX() {
00067 return sc.rich_scalers[7];
00068 }
00069
00070 double StSCReader::getMult() {
00071 return sc.rich_scalers[10];
00072 }
00073
00074 double StSCReader::getL0() {
00075 return 0;
00076 }
00077
00078 double StSCReader::getBBCX() {
00079 return sc.rich_scalers[2];
00080 }
00081
00082 double StSCReader::getBBCXCTB() {
00083 return 0;
00084 }
00085
00086 double StSCReader::getBBCWest() {
00087 return sc.rich_scalers[1];
00088 }
00089
00090 double StSCReader::getBBCEast() {
00091 return sc.rich_scalers[0];
00092 }
00093
00094 double StSCReader::getBBCYellowBkg() {
00095 return sc.rich_scalers[3 + flipBBCBkg];
00096 }
00097
00098 double StSCReader::getBBCBlueBkg() {
00099 return sc.rich_scalers[4 - flipBBCBkg];
00100 }
00101
00102 double StSCReader::getPVPDWest() {
00103 return sc.rich_scalers[9];
00104 }
00105
00106 double StSCReader::getPVPDEast() {
00107 return sc.rich_scalers[8];
00108 }
00109 StSCReader::StSCReader(sc_t *daqsc,unsigned int utime) : fSC(daqsc)
00110 { FillTime(utime); }
00111
00112 StSCReader::~StSCReader() { }
00113
00114 int StSCReader::close() {
00115
00116 return 1;
00117 }
00118
00119 int StSCReader::Update() {
00120 return 1;
00121 }
00122
00123 char StSCReader::thereIsSCData() {
00124
00125
00126 if (getZDCWest() || getZDCEast() ||
00127 getBBCWest() || getBBCEast()) return 7;
00128 return 0;
00129 }
00130
00131 TDataSet* StSCReader::getSCTable(unsigned long runno) {
00132 St_trigDetSums* table = new St_trigDetSums("trigDetSums",1);
00133 trigDetSums_st* tb = table->GetTable();
00134 tb->ctbWest = getCTBWest();
00135 tb->ctbEast = getCTBEast();
00136 tb->ctbTOFp = getCTBOrTOFp();
00137 tb->tofp = getTOFp();
00138 tb->zdcWest = getZDCWest();
00139 tb->zdcEast = getZDCEast();
00140 tb->zdcX = getZDCX();
00141 tb->mult = getMult();
00142 tb->L0 = getL0();
00143 tb->bbcX = getBBCX();
00144 tb->bbcXctbTOFp = getBBCXCTB();
00145 tb->bbcWest = getBBCWest();
00146 tb->bbcEast = getBBCEast();
00147 tb->bbcYellowBkg = getBBCYellowBkg();
00148 tb->bbcBlueBkg = getBBCBlueBkg();
00149 tb->pvpdWest = getPVPDWest();
00150 tb->pvpdEast = getPVPDEast();
00151 tb->runNumber = runno;
00152 tb->timeOffset = 0;
00153 table->SetNRows(1);
00154 return table;
00155 }