1 #ifndef St_trigDetSumsC_h
2 #define St_trigDetSumsC_h
6 #include "tables/St_trigDetSums_Table.h"
7 #include "StDetectorDbClock.h"
8 #include "St_richvoltagesC.h"
12 St_trigDetSumsC(St_trigDetSums *table=0) :
TChair(table) {SafeDelete(fgInstance); fgInstance =
this; fMargin = 0;}
16 trigDetSums_st *Struct(Int_t i = 0) {
return ((St_trigDetSums*) Table())->GetTable()+i;}
17 UInt_t getNumRows() {
return GetNRows();}
18 UInt_t runNumber(Int_t i = 0) {
return Struct(i)->runNumber;}
19 UInt_t timeOffset(Int_t i = 0) {
return Struct(i)->timeOffset;}
20 Double_t ctbWest(Int_t i = 0) {
return validity(Struct(i)->ctbWest);}
21 Double_t ctbEast(Int_t i = 0) {
return validity(Struct(i)->ctbEast);}
22 Double_t ctbTOFp(Int_t i = 0) {
return validity(Struct(i)->ctbTOFp);}
23 Double_t tofp(Int_t i = 0) {
return validity(Struct(i)->tofp);}
24 Double_t epdx(Int_t i = 0) {
return validity(Struct(i)->tofp);}
25 Double_t zdcWest(Int_t i = 0) {
return validity(Struct(i)->zdcWest);}
26 Double_t zdcEast(Int_t i = 0) {
return validity(Struct(i)->zdcEast);}
27 Double_t zdcX(Int_t i = 0) {
return validity(Struct(i)->zdcX);}
28 Double_t mult(Int_t i = 0) {
return validity(Struct(i)->mult);}
29 Double_t L0(Int_t i = 0) {
return validity(Struct(i)->L0);}
30 Double_t bbcX(Int_t i = 0) {
return validity(Struct(i)->bbcX);}
31 Double_t bbcXctbTOFp(Int_t i = 0) {
return validity(Struct(i)->bbcXctbTOFp);}
32 Double_t bbcWest(Int_t i = 0) {
return validity(Struct(i)->bbcWest);}
33 Double_t bbcEast(Int_t i = 0) {
return validity(Struct(i)->bbcEast);}
34 Double_t bbcYellowBkg(Int_t i = 0) {
return validity(Struct(i)->bbcYellowBkg);}
35 Double_t bbcBlueBkg(Int_t i = 0) {
return validity(Struct(i)->bbcBlueBkg);}
36 Double_t pvpdWest(Int_t i = 0) {
return validity(Struct(i)->pvpdWest);}
37 Double_t pvpdEast(Int_t i = 0) {
return validity(Struct(i)->pvpdEast);}
38 Double_t zdcCoin(Int_t i = 0) {
return Nc(zdcX(i),zdcEast(i),zdcWest(i));}
39 Double_t bbcCoin(Int_t i = 0) {
return Nc(bbcX(i),bbcEast(i),bbcWest(i));}
40 static St_trigDetSums* fgTableCopy;
41 void validityMargin(Double_t margin=0) {fMargin = margin;}
42 Double_t getCTBWest() {
return ctbWest();}
43 Double_t getCTBEast() {
return ctbEast();}
44 Double_t getCTBOrTOFp() {
return ctbTOFp();}
45 Double_t getTOFp() {
return tofp();}
46 Double_t getEPDX() {
return epdx();}
47 Double_t getZDCWest() {
return zdcWest();}
48 Double_t getZDCEast() {
return zdcEast();}
49 Double_t getZDCX() {
return zdcX();}
50 Double_t getZDCCoin() {
return zdcCoin();}
51 Double_t getMult() {
return mult();}
52 Double_t getL0() {
return L0();}
53 Double_t getBBCX() {
return bbcX();}
54 Double_t getBBCCoin() {
return bbcCoin();}
55 Double_t getBBCXCTB() {
return bbcXctbTOFp();}
56 Double_t getBBCWest() {
return bbcWest();}
57 Double_t getBBCEast() {
return bbcEast();}
58 Double_t getBBCYellowBkg() {
return bbcYellowBkg();}
59 Double_t getBBCBlueBkg() {
return bbcBlueBkg();}
60 Double_t getPVPDWest() {
return pvpdWest();}
61 Double_t getPVPDEast() {
return pvpdEast();}
62 UInt_t getRichHVStatus() {
return St_richvoltagesC::instance()->status();}
63 void setValidityMargin(Double_t margin=0) {validityMargin(margin);}
67 static Double_t Nc(Double_t New, Double_t Ne, Double_t Nw, Int_t n_bunches=111) {
70 Double_t Nbc = StDetectorDbClock::instance()->CurrentFrequency() * ((Double_t) n_bunches) / 120.;
71 return -Nbc * TMath::Log(1. - ((New - (Ne*Nw/Nbc)) / (Nbc+New-Ne-Nw)));
83 Double_t validity(
double& newval) {
86 fgTableCopy =
new St_trigDetSums(*((St_trigDetSums*) Table()));
89 double& oldval = *((
double*) (((
char*) (fgTableCopy->GetTable())) +
90 (((
char*) &newval) - ((
char*) Struct(0)))));
96 if (newval > CORRUPT || newval < 0)
97 return (oldval > CORRUPT || oldval < 0 ? -1 : oldval);
99 if (fMargin == 0)
return newval;
102 if ((oldval < 100) ||
103 ((newval/oldval) < (2.0-fMargin)) ||
104 (fabs(fmod((newval/oldval)+0.5,1.0)-0.5) > fMargin))
110 ClassDefChair(St_trigDetSums, trigDetSums_st )