80 #include "StMagFMaker.h"
81 #include "StDetectorDbMaker/St_MagFactorC.h"
82 #include "StDetectorDbMaker/St_starMagOnlC.h"
83 #include "StDetectorDbMaker/St_starMagAvgC.h"
84 #include "StMessMgr.h"
86 #include "StarMagField.h"
87 #include "StarCallf77.h"
88 #include "tables/St_Survey_Table.h"
91 #define agdetpnew F77_NAME(agdetpnew,AGDETPNEW)
92 #define agdetpadd F77_NAME(agdetpadd,AGDETPADD)
93 #define mfldgeo F77_NAME(mfldgeo,MFLDGEO)
95 void type_of_call agdetpnew (DEFCHARD DEFCHARL);
96 void type_of_call agdetpadd (DEFCHARD, Float_t*, Int_t* DEFCHARL);
97 void type_of_call mfldgeo();
106 Int_t StMagFMaker::InitRun(Int_t RunNo)
108 if (StarMagField::Instance() && StarMagField::Instance()->IsLocked()) {
110 gMessMgr->Info() <<
"StMagFMaker::InitRun passive mode. Don't update Mag.Field from DB" << endm;
112 gMessMgr->Info() <<
"StMagFMaker::InitRun active mode " << endm;
113 Float_t fScale = St_MagFactorC::instance()->ScaleFactor();
114 if (! St_starMagAvgC::instance()->Table()->IsMarked()) {
115 fScale = St_starMagAvgC::instance()->ScaleFactor();
116 gMessMgr->Info() <<
"StMagFMaker::InitRun use Scale Factor = " << fScale
117 <<
" average for run " << St_starMagAvgC::instance()->runNumber();
119 if (
GetRunNumber() != (Int_t) St_starMagAvgC::instance()->runNumber()) {
120 gMessMgr->Error() <<
", which does not matched with the current RunNo " <<
GetRunNumber();
123 gMessMgr->Info() << endm;
126 assert(TMath::Abs(fScale)>0.005);
128 if (TMath::Abs(fScale)<=0.005) {
129 gMessMgr->Info() <<
"StMagFMaker::InitRun reset scale factor from " << fScale;
131 gMessMgr->Info() <<
" to " << fScale << endm;
134 gMessMgr->Info() <<
"StMagFMaker::InitRun from DB fScale = " << fScale << endm;
135 if (*SAttr(
"magFactor")) {
136 fScale = DAttr(
"magFactor");
137 gMessMgr->Info() <<
"StMagFMaker::InitRun from Attr \"magFactor\" fScale = " << fScale << endm;
139 if (*SAttr(
"ScaleFactor")) {
140 float myScale = DAttr(
"ScaleFactor");
141 if(myScale != fScale) {
142 gMessMgr->Info() << Form(
"StMagFMaker::InitRun Attr \"ScaleFactor\" %g is different from default %g",
143 myScale,fScale) << endm;
144 gMessMgr->Info() <<
"StMagFMaker::InitRun Attr \"ScaleFactor\" is assumed" << endm;
148 if (TMath::Abs(fScale) < 1e-3) fScale = 1e-3;
149 if (fabs(fScale) < 1e-3) fScale = 1e-3;
150 if (StarMagField::Instance()) {
151 StarMagField::Instance()->SetFactor(fScale);
152 gMessMgr->Info() <<
"Reset STAR magnetic field with scale factor " << fScale << endm;
155 gMessMgr->Info() <<
"Initialize STAR magnetic field with scale factor " << fScale << endm;
157 #ifdef __RotateMagField__
158 St_Survey *tableSet = (St_Survey *) GetDataBase(
"StMagF/MagFieldRotation");
160 Survey_st *row = tableSet->GetTable();
161 StarMagField::Instance()->SetStarMagFieldRotation(&row->r00);
165 double myX[3]={0},myB[3];
166 StarMagField::Instance()->BField(myX,myB);
167 gMessMgr->Info() <<
"StMagFMaker::InitRun Bz(0) = " << myB[2] << endm;
virtual Int_t GetRunNumber() const
Returns the current RunNumber.