1 #ifndef St_starMagOnlC_h
2 #define St_starMagOnlC_h
6 #include "tables/St_starMagOnl_Table.h"
8 enum StMagnetPolarity {eUnknownMField, eFullMFieldPolB, eHalfMFieldPolB,
9 eZeroMField, eHalfMFieldPolA, eFullMFieldPolA};
14 starMagOnl_st*Struct(Int_t i = 0) {
return ((St_starMagOnl*) Table())->GetTable()+i;}
15 UInt_t getNumRows() {
return GetNRows();}
16 UInt_t runNumber(Int_t i = 0) {
return Struct(i)->runNumber;}
17 UInt_t time(Int_t i = 0) {
return Struct(i)->time;}
18 Double_t current(Int_t i = 0) {
return Struct(i)->current;}
20 Double_t ScaleFactor(Int_t i = 0){
return current()/4500.;};
21 Double_t getScaleFactor(UInt_t time=0) {
return currentToScaleFactor(getMagnetCurrent(time));}
22 Double_t getMagnetCurrent(UInt_t time=0) {
23 if (! instance())
return 0;
24 if (getNumRows() == 1 || time == 0)
return current();
25 Double_t tempCurrent = -9999;
26 for (UInt_t i = 0; i < getNumRows()-1; i++)
27 if( time >= getTimeEntry(i) && time <= getTimeEntry(i+1) )
28 if( TMath::Abs(getMagnetCurrentEntry(i) - getMagnetCurrentEntry(i+1)) < 50 )
29 tempCurrent = getMagnetCurrentEntry(i);
32 StMagnetPolarity getMagneticField(UInt_t time=0) {
33 StMagnetPolarity value = eUnknownMField;
34 if (! instance())
return value;
35 Double_t scaleFactor = getScaleFactor(time);
36 if(scaleFactor == 1.0) value = eFullMFieldPolA;
37 if(scaleFactor == 0.5) value = eHalfMFieldPolA;
38 if(scaleFactor == 0.0) value = eZeroMField;
39 if(scaleFactor == -0.5) value = eHalfMFieldPolB;
40 if(scaleFactor == -1.0) value = eFullMFieldPolB;
43 UInt_t getRunNumber() {
return runNumber();}
44 UInt_t getTimeEntry(UInt_t i=0) {
return time(i);}
45 Double_t getMagnetCurrentEntry(UInt_t i=0) {
return current(i);}
46 static Double_t currentToScaleFactor(Double_t current) {
47 Double_t value = -9999;
48 if (! instance())
return value;
49 if (current < -4450 && current > -4550) value = -1.0;
50 else if(current < -2200 && current > -2300) value = -0.5;
51 else if(current > -50 && current < 50) value = 0.0;
52 else if(current > 2200 && current < 2300) value = 0.5;
53 else if(current > 4450 && current < 4550) value = 1.0;
61 ClassDefChair(St_starMagOnl, starMagOnl_st )