StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMagFMaker.cxx
1 // $Id: StMagFMaker.cxx,v 1.19 2020/01/15 02:01:26 perev Exp $
2 // $Log: StMagFMaker.cxx,v $
3 // Revision 1.19 2020/01/15 02:01:26 perev
4 // Option to change mag factor added
5 //
6 // Revision 1.18 2018/06/29 21:46:21 smirnovd
7 // Revert iTPC-related changes committed on 2018-06-20 through 2018-06-28
8 //
9 // Revert "NoDead option added"
10 // Revert "Fill mag field more carefully"
11 // Revert "Assert commented out"
12 // Revert "Merging with TPC group code"
13 // Revert "Remove too strong assert"
14 // Revert "Restore removed by mistake line"
15 // Revert "Remove not used anymore file"
16 // Revert "iTPCheckIn"
17 //
18 // Revision 1.16 2010/09/01 20:21:21 fisyak
19 // remove dependence on St_geant_Maker
20 //
21 // Revision 1.15 2009/11/10 20:50:46 fisyak
22 // Switch to TChair
23 //
24 // Revision 1.14 2007/03/21 17:12:58 fisyak
25 // Zero Field is 1G
26 //
27 // Revision 1.13 2005/08/29 22:54:26 fisyak
28 // switch to StarMagField
29 //
30 // Revision 1.12 2003/09/02 17:58:40 perev
31 // gcc 3.2 updates + WarnOff
32 //
33 // Revision 1.11 2001/08/08 23:28:39 fisyak
34 // Fit Reverse Field option
35 //
36 // Revision 1.10 2001/07/14 21:18:18 fisyak
37 // Set scale=2.e-5 for FieldOff
38 //
39 // Revision 1.9 2001/05/29 21:59:41 fisyak
40 // Add StMagF class for back compartibility
41 //
42 // Revision 1.8 2001/05/23 22:52:08 fisyak
43 // Fix bug with scale factor
44 //
45 // Revision 1.7 2001/05/21 21:40:36 fisyak
46 // Merge geant and production mag. fields
47 //
48 // Revision 1.6 2001/05/17 20:38:26 fisyak
49 // Move check for mag. scale factor into InitRun
50 //
51 // Revision 1.5 2000/06/26 22:11:52 fisyak
52 // remove params
53 //
54 // Revision 1.4 2000/06/19 12:49:36 fisyak
55 // Resolve ambiguity between geometry/agufld and StMagF agufld by renaming agufld => lovefield
56 //
57 // Revision 1.3 2000/03/15 21:49:59 fisyak
58 // Change to RunLog
59 //
60 // Revision 1.2 2000/01/07 00:42:33 fisyak
61 // merge Make with Init
62 //
63 // Revision 1.1 2000/01/04 20:44:40 fisyak
64 // Add StMagFMaker
65 //
67 // //
68 // StMagFMaker class for Makers //
69 // //
70 // This commented block at the top of the source file is considered as //
71 // this class description to be present on the this class Web page. //
72 // see: begin_html <A HREF="http://root.cern.ch/root/Documentation.html"> ROOT HTML documentation </A> end_html //
73 // //
74 // Submit any problem with this code via begin_html <A HREF="http://www.star.bnl.gov/STARAFS/comp/sofi/bugs/send-pr.html"><B><I>"STAR Problem Report Form"</I></B></A> end_html //
75 // //
77 #include <assert.h>
78 #include "TError.h"
79 #include <Stiostream.h>
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"
85 #include "StMagF.h"
86 #include "StarMagField.h"
87 #include "StarCallf77.h"
88 #include "tables/St_Survey_Table.h"
89 #include "TMath.h"
90 #if 0
91 #define agdetpnew F77_NAME(agdetpnew,AGDETPNEW)
92 #define agdetpadd F77_NAME(agdetpadd,AGDETPADD)
93 #define mfldgeo F77_NAME(mfldgeo,MFLDGEO)
94 R__EXTERN "C" {
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();
98 }
99 #endif
100 ClassImp(StMagFMaker)
101 ClassImp(StMagF)
102 
103 //_____________________________________________________________________________
105 //_____________________________________________________________________________
106 Int_t StMagFMaker::InitRun(Int_t RunNo)
107 {
108  if (StarMagField::Instance() && StarMagField::Instance()->IsLocked()) {
109  // Passive mode, do not change scale factor
110  gMessMgr->Info() << "StMagFMaker::InitRun passive mode. Don't update Mag.Field from DB" << endm;
111  } else {
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();
118  if (GetRunNumber() > 1000000) {// real data
119  if (GetRunNumber() != (Int_t) St_starMagAvgC::instance()->runNumber()) {
120  gMessMgr->Error() << ", which does not matched with the current RunNo " << GetRunNumber();
121  }
122  }
123  gMessMgr->Info() << endm;
124  }
125 #if 0
126  assert(TMath::Abs(fScale)>0.005);
127 #else
128  if (TMath::Abs(fScale)<=0.005) {
129  gMessMgr->Info() << "StMagFMaker::InitRun reset scale factor from " << fScale;
130  fScale = 0.006;
131  gMessMgr->Info() << " to " << fScale << endm;
132  }
133 #endif
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;
138  }
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;
145  fScale = myScale;
146  }
147  }
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;
153  } else {
154  new StarMagField(StarMagField::kMapped, fScale);
155  gMessMgr->Info() << "Initialize STAR magnetic field with scale factor " << fScale << endm;
156  }
157 #ifdef __RotateMagField__
158  St_Survey *tableSet = (St_Survey *) GetDataBase("StMagF/MagFieldRotation");
159  if (tableSet) {
160  Survey_st *row = tableSet->GetTable();
161  StarMagField::Instance()->SetStarMagFieldRotation(&row->r00);
162  }
163 #endif
164  }
165  double myX[3]={0},myB[3];
166  StarMagField::Instance()->BField(myX,myB);
167  gMessMgr->Info() << "StMagFMaker::InitRun Bz(0) = " << myB[2] << endm;
168 
169  return kStOK;
170 }
171 //_____________________________________________________________________________
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
Definition: Stypes.h:40
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Definition: StMaker.cxx:1054
Definition: StMagF.h:9