FairRoot/PandaRoot
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
PndDipoleMap Class Reference

#include <PndDipoleMap.h>

Inheritance diagram for PndDipoleMap:
PndFieldMap

Public Member Functions

 PndDipoleMap ()
 
 PndDipoleMap (const char *mapName, const char *fileType="R", Double_t BeamMom=15.0)
 
 PndDipoleMap (PndMapPar *fieldPar)
 
virtual ~PndDipoleMap ()
 
virtual Bool_t IsInside (Double_t x, Double_t y, Double_t z, Int_t &ix, Int_t &iy, Int_t &iz, Double_t &dx, Double_t &dy, Double_t &dz)
 
Int_t GetRegionNo ()
 
void GetBxyz (const Double_t point[3], Double_t *bField)
 
void FillParContainer ()
 
virtual void Init ()
 
virtual Double_t GetBx (Double_t x, Double_t y, Double_t z)
 
TArrayF * GetBx () const
 
virtual Double_t GetBy (Double_t x, Double_t y, Double_t z)
 
TArrayF * GetBy () const
 
virtual Double_t GetBz (Double_t x, Double_t y, Double_t z)
 
TArrayF * GetBz () const
 
void WriteAsciiFile (const char *fileName)
 
void WriteRootFile (const char *fileName, const char *mapName)
 
void SetPosition (Double_t x, Double_t y, Double_t z)
 
void SetScale (Double_t factor)
 
Double_t GetXmin () const
 
Double_t GetYmin () const
 
Double_t GetZmin () const
 
Double_t GetXmax () const
 
Double_t GetYmax () const
 
Double_t GetZmax () const
 
Double_t GetXstep () const
 
Double_t GetYstep () const
 
Double_t GetZstep () const
 
Int_t GetNx () const
 
Int_t GetNy () const
 
Int_t GetNz () const
 
Double_t GetUnit () const
 
Double_t GetPositionX () const
 
Double_t GetPositionY () const
 
Double_t GetPositionZ () const
 
Double_t GetScale () const
 
const char * GetFileName ()
 
virtual void Print ()
 

Public Attributes

Int_t fRegionNo
 

Static Public Attributes

static Int_t fNumberOfRegions =0
 

Protected Member Functions

void Reset ()
 
void ReadAsciiFile (const char *fileName)
 
void ReadRootFile (const char *fileName, const char *mapName)
 
void SetField (const PndFieldMapData *data)
 
Double_t Interpolate (Double_t dx, Double_t dy, Double_t dz)
 

Protected Attributes

Double_t fHemiX
 
Double_t fHemiY
 
Double_t fBeamMom
 
TString fFileName
 
Double_t fScale
 
Double_t funit
 
Double_t fPosX
 
Double_t fPosY
 
Double_t fPosZ
 
Double_t fXmin
 
Double_t fXmax
 
Double_t fXstep
 
Double_t fYmin
 
Double_t fYmax
 
Double_t fYstep
 
Double_t fZmin
 
Double_t fZmax
 
Double_t fZstep
 
Int_t fNx
 
Int_t fNy
 
Int_t fNz
 
TArrayF * fBx
 
TArrayF * fBy
 
TArrayF * fBz
 
Double_t fHa [2][2][2]
 
Double_t fHb [2][2]
 Field at corners of a grid cell. More...
 
Double_t fHc [2]
 Interpolated field (2-dim) More...
 

Detailed Description

Definition at line 27 of file PndDipoleMap.h.

Constructor & Destructor Documentation

PndDipoleMap::PndDipoleMap ( )

Default constructor

Definition at line 14 of file PndDipoleMap.cxx.

15  :PndFieldMap(), fRegionNo(0), fHemiX(0), fHemiY(0), fBeamMom(0.)
16 {
17  fType = 3;
18 }
Double_t fHemiY
Definition: PndDipoleMap.h:75
Int_t fRegionNo
Definition: PndDipoleMap.h:63
Double_t fBeamMom
Definition: PndDipoleMap.h:76
Double_t fHemiX
Definition: PndDipoleMap.h:75
PndDipoleMap::PndDipoleMap ( const char *  mapName,
const char *  fileType = "R",
Double_t  BeamMom = 15.0 
)

Standard constructor

Parameters
nameName of field map
fileTypeR = ROOT file, A = ASCII

Definition at line 24 of file PndDipoleMap.cxx.

References fBeamMom, PndFieldMap::fFileName, fNumberOfRegions, fRegionNo, fRun, SetName, and TString.

26  : PndFieldMap(mapName, fileType), fRegionNo(0), fHemiX(0), fHemiY(0), fBeamMom(BeamMom)
27 {
28  fType = 3;
29  TString Suffix="";
30  FairRunSim *fRun= FairRunSim::Instance();
31  if(fRun) fBeamMom= fRun->GetBeamMom();
32 
33  if(fBeamMom< 3)Suffix=".0150" ;
34  else if (fBeamMom< 6.0 && fBeamMom >= 3.0)Suffix=".0406";
35  else if (fBeamMom< 10.0 && fBeamMom >= 6.0 )Suffix=".0890" ;
36  else if (fBeamMom< 13.0 && fBeamMom >= 10.0)Suffix=".1191";
37  else if (fBeamMom>= 13.0) Suffix=".1500";
38 
39 
40  TString NewName=mapName;
41  NewName=mapName+Suffix;
42  SetName(NewName.Data());
43  TString dir = getenv("VMCWORKDIR");
44  fFileName = dir + "/input/fieldmaps/" + NewName;
45  if ( fileType[0] == 'R' ) fFileName += ".root";
46  else fFileName += ".dat";
47 
48 
51 
52 }
cout<< "-----------------------------------------------> Quarter VOLUME<<endl;name="QuarterShape";QuarterShape=newTGeoArb8(name,dz,vertQuar);name="Quarter4Vol";TStringmedium="air";QuarterVol=newTGeoVolumeAssembly(name);name="SubunitShape";SubunitShape=newTGeoArb8(name,dz,vertSub);TStringmedium="air";name="SubunitVol";name1="SubunitVol1";name2="SubunitVol2";name3="SubunitVol3";name4="SubunitVol4";name5="SubunitVol5";name6="SubunitVol6";name7="SubunitVol7";name8="SubunitVol8";name9="SubunitVol9";SubunitVol=newTGeoVolumeAssembly(name);SubunitVol1=newTGeoVolumeAssembly(name1);SubunitVol2=newTGeoVolumeAssembly(name2);SubunitVol3=newTGeoVolumeAssembly(name3);SubunitVol4=newTGeoVolumeAssembly(name4);SubunitVol5=newTGeoVolumeAssembly(name5);SubunitVol6=newTGeoVolumeAssembly(name6);SubunitVol7=newTGeoVolumeAssembly(name7);SubunitVol8=newTGeoVolumeAssembly(name8);SubunitVol9=newTGeoVolumeAssembly(name9);name="BoxShape";BoxShape=newTGeoArb8(name,dz,vertBox);TStringmedium="air";name="BoxVol";BoxVol=newTGeoVolumeAssembly(name);name1="BoxVol1";name2="BoxVol2";name3="BoxVol3";name4="BoxVol4";BoxVol1=newTGeoVolumeAssembly(name1);BoxVol2=newTGeoVolumeAssembly(name2);BoxVol3=newTGeoVolumeAssembly(name3);BoxVol4=newTGeoVolumeAssembly(name4);for(Int_tb=0;b<kNumOfBoxes;b++){cout<<""<<endl;cout<<"---------------->BOXnumber:"<<b<<endl;if(b==0){trBox=newTGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(0.465518);rotBox.RotateY(-0.465518);}if(b==1){trBox=newTGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(-0.465518);rotBox.RotateY(0.465518);}if(b==2){trBox=newTGeoTranslation(tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(-0.465518);rotBox.RotateY(-0.465518);}if(b==3){trBox=newTGeoTranslation(-tr-kSpaceInSub-kAlveoleThickness-0.5*kSpaceInBox,tr+kSpaceInSub+kAlveoleThickness+0.5*kSpaceInBox,0.);rotBox=newTGeoRotation();rotBox.RotateX(0.465518);rotBox.RotateY(0.465518);}TGeoCombiTrans*trrotBox=newTGeoCombiTrans(trBox,rotBox);name="BoxVol";name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol->AddNode(BoxVol,b,trrotBox);if(b==1){name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol1->AddNode(BoxVol,b,trrotBox);}if(b==2){name+=b;trrotBox->SetName(name);trrotBox->RegisterYourself();SubunitVol2->AddNode(BoxVol1,b,trrotBox);}if(b==0){name+=b;trrotBox-> SetName(name)
static Int_t fNumberOfRegions
Definition: PndDipoleMap.h:62
TString fFileName
Definition: PndFieldMap.h:157
FairRunAna * fRun
Definition: hit_dirc.C:58
Double_t fHemiY
Definition: PndDipoleMap.h:75
Int_t fRegionNo
Definition: PndDipoleMap.h:63
Double_t fBeamMom
Definition: PndDipoleMap.h:76
Double_t fHemiX
Definition: PndDipoleMap.h:75
PndDipoleMap::PndDipoleMap ( PndMapPar fieldPar)

Constructor from PndFieldPar

Definition at line 58 of file PndDipoleMap.cxx.

References PndFieldMap::fBx, PndFieldMap::fBy, PndFieldMap::fBz, PndFieldMap::fFileName, PndFieldMap::fNx, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::fPosX, PndFieldMap::fPosY, PndFieldMap::fPosZ, PndFieldMap::fScale, PndFieldMap::funit, PndFieldMap::fXmax, PndFieldMap::fXmin, PndFieldMap::fXstep, PndFieldMap::fYmax, PndFieldMap::fYmin, PndFieldMap::fYstep, PndFieldMap::fZmax, PndFieldMap::fZmin, PndFieldMap::fZstep, PndMapPar::GetPositionX(), PndMapPar::GetPositionY(), PndMapPar::GetPositionZ(), PndMapPar::GetScale(), PndMapPar::GetType(), PndMapPar::MapName(), and TString.

59  : PndFieldMap(), fRegionNo(0), fHemiX(0), fHemiY(0), fBeamMom(0)
60 {
61 
62  fType = 3;
63  fPosX = fPosY = fPosZ = 0.;
64  fXmin = fYmin = fZmin = 0.;
65  fXmax = fYmax = fZmax = 0.;
66  fXstep = fYstep = fZstep = 0.;
67  fNx = fNy = fNz = 0;
68  fScale = 1.;
69  funit = 10.0;
70  fBx = fBy = fBz = NULL;
71  if ( ! fieldPar ) {
72  cerr << "-W- PndDipoleMap::PndDipoleMap: empty parameter container!"
73  << endl;
74  fName = "";
75  fFileName = "";
76  fType = 1;
77  }
78  else {
79  fieldPar->MapName(fName);
80  fPosX = fieldPar->GetPositionX();
81  fPosY = fieldPar->GetPositionY();
82  fPosZ = fieldPar->GetPositionZ();
83  fScale = fieldPar->GetScale();
84  TString dir = getenv("VMCWORKDIR");
85  fFileName = dir + "/input/fieldmaps/" + fName + ".root";
86  fType = fieldPar->GetType();
87  }
88 
89 }
Double_t funit
Definition: PndFieldMap.h:164
Double_t GetPositionX() const
Definition: PndMapPar.h:59
Double_t fYmin
Definition: PndFieldMap.h:173
Double_t GetScale() const
Definition: PndMapPar.h:62
Double_t fZstep
Definition: PndFieldMap.h:174
Double_t fZmin
Definition: PndFieldMap.h:174
Double_t fYmax
Definition: PndFieldMap.h:173
TArrayF * fBz
Definition: PndFieldMap.h:184
Double_t fXstep
Definition: PndFieldMap.h:172
Double_t fXmax
Definition: PndFieldMap.h:172
TString fFileName
Definition: PndFieldMap.h:157
void MapName(TString &name)
Definition: PndMapPar.h:58
Double_t fPosZ
Definition: PndFieldMap.h:168
Double_t fScale
Definition: PndFieldMap.h:161
Double_t fHemiY
Definition: PndDipoleMap.h:75
Double_t fPosY
Definition: PndFieldMap.h:168
TArrayF * fBy
Definition: PndFieldMap.h:183
TArrayF * fBx
Definition: PndFieldMap.h:182
Double_t fPosX
Definition: PndFieldMap.h:168
Double_t GetPositionZ() const
Definition: PndMapPar.h:61
Double_t fYstep
Definition: PndFieldMap.h:173
Double_t GetPositionY() const
Definition: PndMapPar.h:60
Double_t fZmax
Definition: PndFieldMap.h:174
Int_t fRegionNo
Definition: PndDipoleMap.h:63
Double_t fBeamMom
Definition: PndDipoleMap.h:76
Int_t GetType() const
Definition: PndMapPar.h:51
Double_t fXmin
Definition: PndFieldMap.h:172
Double_t fHemiX
Definition: PndDipoleMap.h:75
PndDipoleMap::~PndDipoleMap ( )
virtual

Destructor

Definition at line 95 of file PndDipoleMap.cxx.

95 { }

Member Function Documentation

void PndDipoleMap::FillParContainer ( )

Definition at line 209 of file PndDipoleMap.cxx.

References TString.

210 {
211  TString MapName=GetName();
212  cout << "PndDipoleMap::FillParContainer() " << endl;
213 
214 }
Double_t PndFieldMap::GetBx ( Double_t  x,
Double_t  y,
Double_t  z 
)
virtualinherited

Get the field components at a certain point

Parameters
x,y,zPoint coordinates (global) [cm] Bx,By,Bz Field components [kG]

Definition at line 157 of file PndFieldMap.cxx.

References Double_t, dx, dy, dz, PndFieldMap::fBx, PndFieldMap::fHa, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::Interpolate(), and PndFieldMap::IsInside().

Referenced by interpolate_fieldmap().

157  {
158 
159  Int_t ix = 0;
160  Int_t iy = 0;
161  Int_t iz = 0;
162  Double_t dx = 0.;
163  Double_t dy = 0.;
164  Double_t dz = 0.;
165 
166  if ( IsInside(x, y, z, ix, iy, iz, dx, dy, dz) ) {
167 
168  // Get Bx field values at grid cell corners
169  fHa[0][0][0] = fBx->At(ix *fNy*fNz + iy *fNz + iz);
170  fHa[1][0][0] = fBx->At((ix+1)*fNy*fNz + iy *fNz + iz);
171  fHa[0][1][0] = fBx->At(ix *fNy*fNz + (iy+1)*fNz + iz);
172  fHa[1][1][0] = fBx->At((ix+1)*fNy*fNz + (iy+1)*fNz + iz);
173  fHa[0][0][1] = fBx->At(ix *fNy*fNz + iy *fNz + (iz+1));
174  fHa[1][0][1] = fBx->At((ix+1)*fNy*fNz + iy *fNz + (iz+1));
175  fHa[0][1][1] = fBx->At(ix *fNy*fNz + (iy+1)*fNz + (iz+1));
176  fHa[1][1][1] = fBx->At((ix+1)*fNy*fNz + (iy+1)*fNz + (iz+1));
177 
178  // Return interpolated field value
179  return Interpolate(dx, dy, dz);
180 
181  }
182 
183  return 0.;
184 }
Double_t fHa[2][2][2]
Definition: PndFieldMap.h:189
double dy
virtual Bool_t IsInside(Double_t x, Double_t y, Double_t z, Int_t &ix, Int_t &iy, Int_t &iz, Double_t &dx, Double_t &dy, Double_t &dz)
Double_t Interpolate(Double_t dx, Double_t dy, Double_t dz)
Double_t
Double_t z
double dx
TArrayF * fBx
Definition: PndFieldMap.h:182
Double_t x
Double_t y
TArrayF* PndFieldMap::GetBx ( ) const
inlineinherited

Accessors to the field value arrays

Definition at line 114 of file PndFieldMap.h.

References PndFieldMap::fBx.

Referenced by PndFieldMap::Print().

114 { return fBx; }
TArrayF * fBx
Definition: PndFieldMap.h:182
void PndDipoleMap::GetBxyz ( const Double_t  point[3],
Double_t bField 
)

Definition at line 98 of file PndDipoleMap.cxx.

References Double_t, dx, dy, dz, PndFieldMap::fBx, PndFieldMap::fBy, PndFieldMap::fBz, PndFieldMap::fHa, fHemiX, fHemiY, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::Interpolate(), IsInside(), x, y, and z.

99 {
100  // cout << " PndDipoleMap::GetBxyz " << point[0] << " " << point[1] <<" " << point[2] << endl;
101 
102  Double_t x =point[0];
103  Double_t y =point[1];
104  Double_t z =point[2];
105  Int_t ix = 0;
106  Int_t iy = 0;
107  Int_t iz = 0;
108  Double_t dx = 0.;
109  Double_t dy = 0.;
110  Double_t dz = 0.;
111 
112  if ( IsInside(x, y, z, ix, iy, iz, dx, dy, dz) ){
113 
114  // Get Bx field values at grid cell corners
115  fHa[0][0][0] = fBx->At(ix *fNy*fNz + iy *fNz + iz);
116  fHa[1][0][0] = fBx->At((ix+1)*fNy*fNz + iy *fNz + iz);
117  fHa[0][1][0] = fBx->At(ix *fNy*fNz + (iy+1)*fNz + iz);
118  fHa[1][1][0] = fBx->At((ix+1)*fNy*fNz + (iy+1)*fNz + iz);
119  fHa[0][0][1] = fBx->At(ix *fNy*fNz + iy *fNz + (iz+1));
120  fHa[1][0][1] = fBx->At((ix+1)*fNy*fNz + iy *fNz + (iz+1));
121  fHa[0][1][1] = fBx->At(ix *fNy*fNz + (iy+1)*fNz + (iz+1));
122  fHa[1][1][1] = fBx->At((ix+1)*fNy*fNz + (iy+1)*fNz + (iz+1));
123 
124  bField[0]=Interpolate(dx, dy, dz) * fHemiX *fHemiY ;
125 
126  // Get By field values at grid cell corners
127  fHa[0][0][0] = fBy->At(ix *fNy*fNz + iy *fNz + iz);
128  fHa[1][0][0] = fBy->At((ix+1)*fNy*fNz + iy *fNz + iz);
129  fHa[0][1][0] = fBy->At(ix *fNy*fNz + (iy+1)*fNz + iz);
130  fHa[1][1][0] = fBy->At((ix+1)*fNy*fNz + (iy+1)*fNz + iz);
131  fHa[0][0][1] = fBy->At(ix *fNy*fNz + iy *fNz + (iz+1));
132  fHa[1][0][1] = fBy->At((ix+1)*fNy*fNz + iy *fNz + (iz+1));
133  fHa[0][1][1] = fBy->At(ix *fNy*fNz + (iy+1)*fNz + (iz+1));
134  fHa[1][1][1] = fBy->At((ix+1)*fNy*fNz + (iy+1)*fNz + (iz+1));
135 
136 
137  //By is symtric in X and Y
138  bField[1]=Interpolate(dx, dy, dz);
139 
140  // Get Bz field values at grid cell corners
141  fHa[0][0][0] = fBz->At(ix *fNy*fNz + iy *fNz + iz);
142  fHa[1][0][0] = fBz->At((ix+1)*fNy*fNz + iy *fNz + iz);
143  fHa[0][1][0] = fBz->At(ix *fNy*fNz + (iy+1)*fNz + iz);
144  fHa[1][1][0] = fBz->At((ix+1)*fNy*fNz + (iy+1)*fNz + iz);
145  fHa[0][0][1] = fBz->At(ix *fNy*fNz + iy *fNz + (iz+1));
146  fHa[1][0][1] = fBz->At((ix+1)*fNy*fNz + iy *fNz + (iz+1));
147  fHa[0][1][1] = fBz->At(ix *fNy*fNz + (iy+1)*fNz + (iz+1));
148  fHa[1][1][1] = fBz->At((ix+1)*fNy*fNz + (iy+1)*fNz + (iz+1));
149 
150  // Return interpolated field value
151  //Bz is symtric in X and antisymtric Y
152  bField[2]=Interpolate(dx, dy, dz)* fHemiY ;
153 
154 
155  }else{
156  bField[0]=0;
157  bField[1]=0;
158  bField[2]=0;
159  }
160 
161 }
Double_t fHa[2][2][2]
Definition: PndFieldMap.h:189
double dy
TArrayF * fBz
Definition: PndFieldMap.h:184
Double_t Interpolate(Double_t dx, Double_t dy, Double_t dz)
Double_t
Double_t fHemiY
Definition: PndDipoleMap.h:75
TClonesArray * point
Definition: anaLmdDigi.C:29
Double_t z
virtual Bool_t IsInside(Double_t x, Double_t y, Double_t z, Int_t &ix, Int_t &iy, Int_t &iz, Double_t &dx, Double_t &dy, Double_t &dz)
TArrayF * fBy
Definition: PndFieldMap.h:183
double dx
TArrayF * fBx
Definition: PndFieldMap.h:182
Double_t x
Double_t y
Double_t fHemiX
Definition: PndDipoleMap.h:75
Double_t PndFieldMap::GetBy ( Double_t  x,
Double_t  y,
Double_t  z 
)
virtualinherited

Definition at line 190 of file PndFieldMap.cxx.

References Double_t, dx, dy, dz, PndFieldMap::fBy, PndFieldMap::fHa, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::Interpolate(), and PndFieldMap::IsInside().

Referenced by interpolate_fieldmap().

190  {
191 
192  Int_t ix = 0;
193  Int_t iy = 0;
194  Int_t iz = 0;
195  Double_t dx = 0.;
196  Double_t dy = 0.;
197  Double_t dz = 0.;
198 
199  if ( IsInside(x, y, z, ix, iy, iz, dx, dy, dz) ) {
200 
201  // Get By field values at grid cell corners
202  fHa[0][0][0] = fBy->At(ix *fNy*fNz + iy *fNz + iz);
203  fHa[1][0][0] = fBy->At((ix+1)*fNy*fNz + iy *fNz + iz);
204  fHa[0][1][0] = fBy->At(ix *fNy*fNz + (iy+1)*fNz + iz);
205  fHa[1][1][0] = fBy->At((ix+1)*fNy*fNz + (iy+1)*fNz + iz);
206  fHa[0][0][1] = fBy->At(ix *fNy*fNz + iy *fNz + (iz+1));
207  fHa[1][0][1] = fBy->At((ix+1)*fNy*fNz + iy *fNz + (iz+1));
208  fHa[0][1][1] = fBy->At(ix *fNy*fNz + (iy+1)*fNz + (iz+1));
209  fHa[1][1][1] = fBy->At((ix+1)*fNy*fNz + (iy+1)*fNz + (iz+1));
210 
211  // Return interpolated field value
212  return Interpolate(dx, dy, dz);
213 
214  }
215 
216  return 0.;
217 }
Double_t fHa[2][2][2]
Definition: PndFieldMap.h:189
double dy
virtual Bool_t IsInside(Double_t x, Double_t y, Double_t z, Int_t &ix, Int_t &iy, Int_t &iz, Double_t &dx, Double_t &dy, Double_t &dz)
Double_t Interpolate(Double_t dx, Double_t dy, Double_t dz)
Double_t
Double_t z
TArrayF * fBy
Definition: PndFieldMap.h:183
double dx
Double_t x
Double_t y
TArrayF* PndFieldMap::GetBy ( ) const
inlineinherited

Definition at line 115 of file PndFieldMap.h.

References PndFieldMap::fBy.

Referenced by PndFieldMap::Print().

115 { return fBy; }
TArrayF * fBy
Definition: PndFieldMap.h:183
Double_t PndFieldMap::GetBz ( Double_t  x,
Double_t  y,
Double_t  z 
)
virtualinherited

Definition at line 223 of file PndFieldMap.cxx.

References Double_t, dx, dy, dz, PndFieldMap::fBz, PndFieldMap::fHa, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::Interpolate(), and PndFieldMap::IsInside().

Referenced by interpolate_fieldmap().

223  {
224 
225  Int_t ix = 0;
226  Int_t iy = 0;
227  Int_t iz = 0;
228  Double_t dx = 0.;
229  Double_t dy = 0.;
230  Double_t dz = 0.;
231 
232  if ( IsInside(x, y, z, ix, iy, iz, dx, dy, dz) ) {
233 
234  // Get Bz field values at grid cell corners
235  fHa[0][0][0] = fBz->At(ix *fNy*fNz + iy *fNz + iz);
236  fHa[1][0][0] = fBz->At((ix+1)*fNy*fNz + iy *fNz + iz);
237  fHa[0][1][0] = fBz->At(ix *fNy*fNz + (iy+1)*fNz + iz);
238  fHa[1][1][0] = fBz->At((ix+1)*fNy*fNz + (iy+1)*fNz + iz);
239  fHa[0][0][1] = fBz->At(ix *fNy*fNz + iy *fNz + (iz+1));
240  fHa[1][0][1] = fBz->At((ix+1)*fNy*fNz + iy *fNz + (iz+1));
241  fHa[0][1][1] = fBz->At(ix *fNy*fNz + (iy+1)*fNz + (iz+1));
242  fHa[1][1][1] = fBz->At((ix+1)*fNy*fNz + (iy+1)*fNz + (iz+1));
243 
244  // Return interpolated field value
245  return Interpolate(dx, dy, dz);
246 
247  }
248 
249  return 0.;
250 }
Double_t fHa[2][2][2]
Definition: PndFieldMap.h:189
double dy
virtual Bool_t IsInside(Double_t x, Double_t y, Double_t z, Int_t &ix, Int_t &iy, Int_t &iz, Double_t &dx, Double_t &dy, Double_t &dz)
TArrayF * fBz
Definition: PndFieldMap.h:184
Double_t Interpolate(Double_t dx, Double_t dy, Double_t dz)
Double_t
Double_t z
double dx
Double_t x
Double_t y
TArrayF* PndFieldMap::GetBz ( ) const
inlineinherited

Definition at line 116 of file PndFieldMap.h.

References PndFieldMap::fBz.

Referenced by PndFieldMap::Print().

116 { return fBz; }
TArrayF * fBz
Definition: PndFieldMap.h:184
const char* PndFieldMap::GetFileName ( )
inlineinherited

Accessor to field map file

Definition at line 120 of file PndFieldMap.h.

References PndFieldMap::fFileName.

120 { return fFileName.Data(); }
TString fFileName
Definition: PndFieldMap.h:157
Int_t PndFieldMap::GetNx ( ) const
inlineinherited

Definition at line 97 of file PndFieldMap.h.

References PndFieldMap::fNx.

Referenced by interpolate_fieldmap(), and transform_jost_fieldmap().

97 { return fNx; }
Int_t PndFieldMap::GetNy ( ) const
inlineinherited

Definition at line 98 of file PndFieldMap.h.

References PndFieldMap::fNy.

Referenced by interpolate_fieldmap(), and transform_jost_fieldmap().

98 { return fNy; }
Int_t PndFieldMap::GetNz ( ) const
inlineinherited

Definition at line 99 of file PndFieldMap.h.

References PndFieldMap::fNz.

Referenced by interpolate_fieldmap(), and transform_jost_fieldmap().

99 { return fNz; }
Double_t PndFieldMap::GetPositionX ( ) const
inlineinherited

Accessor to field centre position in global system

Definition at line 104 of file PndFieldMap.h.

References PndFieldMap::fPosX.

Referenced by PndFieldPar::SetParameters(), and PndMapPar::SetParameters().

104 { return fPosX; }
Double_t fPosX
Definition: PndFieldMap.h:168
Double_t PndFieldMap::GetPositionY ( ) const
inlineinherited

Definition at line 105 of file PndFieldMap.h.

References PndFieldMap::fPosY.

Referenced by PndFieldPar::SetParameters(), and PndMapPar::SetParameters().

105 { return fPosY; }
Double_t fPosY
Definition: PndFieldMap.h:168
Double_t PndFieldMap::GetPositionZ ( ) const
inlineinherited

Definition at line 106 of file PndFieldMap.h.

References PndFieldMap::fPosZ.

Referenced by PndFieldPar::SetParameters(), and PndMapPar::SetParameters().

106 { return fPosZ; }
Double_t fPosZ
Definition: PndFieldMap.h:168
Int_t PndDipoleMap::GetRegionNo ( )
inline

Definition at line 65 of file PndDipoleMap.h.

References fRegionNo.

Referenced by PndMultiFieldPar::SetParameters().

65 {return fRegionNo;}
Int_t fRegionNo
Definition: PndDipoleMap.h:63
Double_t PndFieldMap::GetScale ( ) const
inlineinherited

Accessor to global scaling factor

Definition at line 110 of file PndFieldMap.h.

References PndFieldMap::fScale.

Referenced by interpolate_fieldmap(), PndFieldMapData::PndFieldMapData(), PndFieldPar::SetParameters(), and PndMapPar::SetParameters().

110 { return fScale; }
Double_t fScale
Definition: PndFieldMap.h:161
Double_t PndFieldMap::GetUnit ( ) const
inlineinherited

Definition at line 101 of file PndFieldMap.h.

References PndFieldMap::funit.

Referenced by interpolate_fieldmap().

101 {return funit; }
Double_t funit
Definition: PndFieldMap.h:164
Double_t PndFieldMap::GetXmax ( ) const
inlineinherited

Definition at line 91 of file PndFieldMap.h.

References PndFieldMap::fXmax.

Referenced by interpolate_fieldmap().

91 { return fXmax; }
Double_t fXmax
Definition: PndFieldMap.h:172
Double_t PndFieldMap::GetXmin ( ) const
inlineinherited

Accessors to field parameters in local coordinate system

Definition at line 88 of file PndFieldMap.h.

References PndFieldMap::fXmin.

Referenced by interpolate_fieldmap().

88 { return fXmin; }
Double_t fXmin
Definition: PndFieldMap.h:172
Double_t PndFieldMap::GetXstep ( ) const
inlineinherited

Definition at line 94 of file PndFieldMap.h.

References PndFieldMap::fXstep.

94 { return fXstep; }
Double_t fXstep
Definition: PndFieldMap.h:172
Double_t PndFieldMap::GetYmax ( ) const
inlineinherited

Definition at line 92 of file PndFieldMap.h.

References PndFieldMap::fYmax.

Referenced by interpolate_fieldmap().

92 { return fYmax; }
Double_t fYmax
Definition: PndFieldMap.h:173
Double_t PndFieldMap::GetYmin ( ) const
inlineinherited

Definition at line 89 of file PndFieldMap.h.

References PndFieldMap::fYmin.

Referenced by interpolate_fieldmap().

89 { return fYmin; }
Double_t fYmin
Definition: PndFieldMap.h:173
Double_t PndFieldMap::GetYstep ( ) const
inlineinherited

Definition at line 95 of file PndFieldMap.h.

References PndFieldMap::fYstep.

95 { return fYstep; }
Double_t fYstep
Definition: PndFieldMap.h:173
Double_t PndFieldMap::GetZmax ( ) const
inlineinherited

Definition at line 93 of file PndFieldMap.h.

References PndFieldMap::fZmax.

Referenced by PndMultiField::Init(), and interpolate_fieldmap().

93 { return fZmax; }
Double_t fZmax
Definition: PndFieldMap.h:174
Double_t PndFieldMap::GetZmin ( ) const
inlineinherited

Definition at line 90 of file PndFieldMap.h.

References PndFieldMap::fZmin.

Referenced by PndMultiField::Init(), and interpolate_fieldmap().

90 { return fZmin; }
Double_t fZmin
Definition: PndFieldMap.h:174
Double_t PndFieldMap::GetZstep ( ) const
inlineinherited

Definition at line 96 of file PndFieldMap.h.

References PndFieldMap::fZstep.

96 { return fZstep; }
Double_t fZstep
Definition: PndFieldMap.h:174
void PndFieldMap::Init ( )
virtualinherited

Initialisation (read map from file)

Definition at line 144 of file PndFieldMap.cxx.

References PndFieldMap::fFileName, PndFieldMap::ReadAsciiFile(), and PndFieldMap::ReadRootFile().

Referenced by PndMultiField::Init(), interpolate_fieldmap(), and transform_jost_fieldmap().

144  {
145  if (fFileName.EndsWith(".root")) ReadRootFile(fFileName, fName);
146  else if (fFileName.EndsWith(".dat")) ReadAsciiFile(fFileName);
147  else {
148  LOG(ERROR) << "-E- PndFieldMap::Init: No proper file name defined! "<<fFileName.Data() ;
149  Fatal("Init", "No proper file name");
150  }
151 }
TString fFileName
Definition: PndFieldMap.h:157
void ReadAsciiFile(const char *fileName)
void ReadRootFile(const char *fileName, const char *mapName)
Double_t PndFieldMap::Interpolate ( Double_t  dx,
Double_t  dy,
Double_t  dz 
)
protectedinherited

Get field values by interpolation of the grid.

Parameters
dx,dy,dzRelative distance from grid point [cell units]

Definition at line 621 of file PndFieldMap.cxx.

References PndFieldMap::fHa, PndFieldMap::fHb, and PndFieldMap::fHc.

Referenced by PndFieldMap::GetBx(), PndTransMap::GetBxyz(), PndSolenoidMap::GetBxyz(), GetBxyz(), PndFieldMap::GetBy(), and PndFieldMap::GetBz().

621  {
622 
623  // Interpolate in x coordinate
624  fHb[0][0] = fHa[0][0][0] + ( fHa[1][0][0]-fHa[0][0][0] ) * dx;
625  fHb[1][0] = fHa[0][1][0] + ( fHa[1][1][0]-fHa[0][1][0] ) * dx;
626  fHb[0][1] = fHa[0][0][1] + ( fHa[1][0][1]-fHa[0][0][1] ) * dx;
627  fHb[1][1] = fHa[0][1][1] + ( fHa[1][1][1]-fHa[0][1][1] ) * dx;
628 
629  // Interpolate in y coordinate
630  fHc[0] = fHb[0][0] + ( fHb[1][0] - fHb[0][0] ) * dy;
631  fHc[1] = fHb[0][1] + ( fHb[1][1] - fHb[0][1] ) * dy;
632 
633  // Interpolate in z coordinate
634  return fHc[0] + ( fHc[1] - fHc[0] ) * dz;
635 
636 }
Double_t fHa[2][2][2]
Definition: PndFieldMap.h:189
double dy
Double_t fHb[2][2]
Field at corners of a grid cell.
Definition: PndFieldMap.h:190
Double_t fHc[2]
Interpolated field (2-dim)
Definition: PndFieldMap.h:191
double dx
Bool_t PndDipoleMap::IsInside ( Double_t  x,
Double_t  y,
Double_t  z,
Int_t &  ix,
Int_t &  iy,
Int_t &  iz,
Double_t dx,
Double_t dy,
Double_t dz 
)
virtual

Determine whether a point is inside the field map

Parameters
x,y,zPoint coordinates (global) [cm]
ix,iy,iz(return) Grid cell
dx,dy,dz(return) Distance from grid point [cm] if inside kTRUE if inside map, else kFALSE

Reimplemented from PndFieldMap.

Definition at line 165 of file PndDipoleMap.cxx.

References Double_t, fHemiX, fHemiY, PndFieldMap::fPosX, PndFieldMap::fPosY, PndFieldMap::fPosZ, PndFieldMap::fXmin, PndFieldMap::fXstep, PndFieldMap::fYmax, PndFieldMap::fYmin, PndFieldMap::fYstep, PndFieldMap::fZmax, PndFieldMap::fZmin, and PndFieldMap::fZstep.

Referenced by GetBxyz().

168  {
169 
170  // --- Transform into local coordinate system
171  Double_t xl = x - fPosX;
172  Double_t yl = y - fPosY;
173  Double_t zl = z - fPosZ;
174 
175  // --- Reflect w.r.t. symmetry axes
176  fHemiX = fHemiY = 1.;
177  if ( xl < 0. ) {
178  fHemiX = -1.;
179  xl = -1. * xl;
180  }
181  if ( yl < 0. ) {
182  fHemiY = -1.;
183  yl = -1. * yl;
184  }
185 
186  // --- Check for being outside the map range
187  if ( ! ( xl >= fXmin && xl <= fXmax && yl >= fYmin && yl <= fYmax &&
188  zl >= fZmin && zl <= fZmax ) ) {
189  ix = iy = iz = 0;
190  dx = dy = dz = 0.;
191  return kFALSE;
192  }
193 
194  // --- Determine grid cell
195  ix = Int_t( (xl-fXmin) / fXstep );
196  iy = Int_t( (yl-fYmin) / fYstep );
197  iz = Int_t( (zl-fZmin) / fZstep );
198 
199 
200  // Relative distance from grid point (in units of cell size)
201  dx = (xl-fXmin) / fXstep - Double_t(ix);
202  dy = (yl-fYmin) / fYstep - Double_t(iy);
203  dz = (zl-fZmin) / fZstep - Double_t(iz);
204 
205  return kTRUE;
206 
207 }
double dy
Double_t fYmin
Definition: PndFieldMap.h:173
Double_t fZstep
Definition: PndFieldMap.h:174
Double_t fZmin
Definition: PndFieldMap.h:174
Double_t fYmax
Definition: PndFieldMap.h:173
Double_t fXstep
Definition: PndFieldMap.h:172
Double_t fPosZ
Definition: PndFieldMap.h:168
Double_t
Double_t fHemiY
Definition: PndDipoleMap.h:75
Double_t z
Double_t fPosY
Definition: PndFieldMap.h:168
double dx
Double_t fPosX
Definition: PndFieldMap.h:168
Double_t x
Double_t fYstep
Definition: PndFieldMap.h:173
Double_t fZmax
Definition: PndFieldMap.h:174
Double_t y
Double_t fXmin
Definition: PndFieldMap.h:172
Double_t fHemiX
Definition: PndDipoleMap.h:75
void PndFieldMap::Print ( )
virtualinherited

Screen output

Definition at line 378 of file PndFieldMap.cxx.

References Double_t, PndFieldMap::fNx, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::fPosX, PndFieldMap::fPosY, PndFieldMap::fPosZ, PndFieldMap::fScale, PndFieldMap::fXmax, PndFieldMap::fXmin, PndFieldMap::fXstep, PndFieldMap::fYmax, PndFieldMap::fYmin, PndFieldMap::fYstep, PndFieldMap::fZmax, PndFieldMap::fZmin, PndFieldMap::fZstep, PndFieldMap::GetBx(), PndFieldMap::GetBy(), PndFieldMap::GetBz(), and TString.

378  {
379  TString type = "Map";
380  if ( fType == 2 ) type = "Soleniod Map ";
381  if ( fType == 3 ) type = "Dipole Map ";
382  if ( fType == 4 ) type = "Trans Map ";
383  cout << "======================================================" << endl;
384  cout.precision(4);
385  cout << showpoint;
386  cout << "---- " << fTitle << " : " << fName << endl;
387  cout << "----" << endl;
388  cout << "---- Field type : " << type << endl;
389  cout << "----" << endl;
390  cout << "---- Field map grid : " << endl;
391  cout << "---- x = " << setw(4) << fXmin << " to " << setw(4) << fXmax
392  << " cm, " << fNx << " grid points, dx = " << fXstep << " cm" << endl;
393  cout << "---- y = " << setw(4) << fYmin << " to " << setw(4) << fYmax
394  << " cm, " << fNy << " grid points, dy = " << fYstep << " cm" << endl;
395  cout << "---- z = " << setw(4) << fZmin << " to " << setw(4) << fZmax
396  << " cm, " << fNz << " grid points, dz = " << fZstep << " cm" << endl;
397  cout << endl;
398  cout << "---- Field centre position: ( " << setw(6) << fPosX << ", "
399  << setw(6) << fPosY << ", " << setw(6) << fPosZ << ") cm" << endl;
400  cout << "---- Field scaling factor: " << fScale << endl;
401  Double_t bx = GetBx(0.,0.,0.);
402  Double_t by = GetBy(0.,0.,0.);
403  Double_t bz = GetBz(0.,0.,0.);
404  cout << "----" << endl;
405  cout << "---- Field at origin is ( " << setw(6) << bx << ", " << setw(6)
406  << by << ", " << setw(6) << bz << ") kG" << endl;
407  cout << "======================================================" << endl;
408 }
Double_t fYmin
Definition: PndFieldMap.h:173
Double_t fZstep
Definition: PndFieldMap.h:174
Double_t fZmin
Definition: PndFieldMap.h:174
Double_t fYmax
Definition: PndFieldMap.h:173
Double_t fXstep
Definition: PndFieldMap.h:172
Double_t fXmax
Definition: PndFieldMap.h:172
Double_t fPosZ
Definition: PndFieldMap.h:168
Double_t fScale
Definition: PndFieldMap.h:161
Double_t
TArrayF * GetBz() const
Definition: PndFieldMap.h:116
TArrayF * GetBy() const
Definition: PndFieldMap.h:115
Double_t fPosY
Definition: PndFieldMap.h:168
Double_t fPosX
Definition: PndFieldMap.h:168
Double_t fYstep
Definition: PndFieldMap.h:173
Double_t fZmax
Definition: PndFieldMap.h:174
TArrayF * GetBx() const
Definition: PndFieldMap.h:114
Double_t fXmin
Definition: PndFieldMap.h:172
void PndFieldMap::ReadAsciiFile ( const char *  fileName)
protectedinherited

Read the field map from an ASCII file

Definition at line 431 of file PndFieldMap.cxx.

References Double_t, PndFieldMap::fBx, PndFieldMap::fBy, PndFieldMap::fBz, PndFieldMap::fNx, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::fScale, PndFieldMap::funit, PndFieldMap::fXmax, PndFieldMap::fXmin, PndFieldMap::fXstep, PndFieldMap::fYmax, PndFieldMap::fYmin, PndFieldMap::fYstep, PndFieldMap::fZmax, PndFieldMap::fZmin, PndFieldMap::fZstep, CAMath::Nint(), and TString.

Referenced by PndFieldMap::Init().

431  {
432 
433  Double_t bx=0., by=0., bz=0.;
434  // Open file
435  cout << "-I- PndFieldMap: Reading field map from ASCII file "
436  << fileName << endl;
437  ifstream mapFile(fileName);
438  if ( ! mapFile.is_open() ) {
439  cerr << "-E- PndFieldMap:ReadAsciiFile: Could not open file! " << endl;
440  Fatal("ReadAsciiFile","Could not open file");
441  }
442 
443  // Read map type
444  TString type;
445  mapFile >> type;
446 
447  Int_t iType = 0;
448  if ( type == "nosym" ) iType = 1;
449  if ( type == "Solenoid") iType = 2;
450  if ( type == "Dipole" ) iType = 3;
451  if ( type == "Trans" ) iType = 4;
452  if ( fType != iType ) {
453  cout << "-E- PndFieldMap::ReadAsciiFile: Incompatible map types!"
454  << endl;
455  cout << " Field map is of type " << fType
456  << " but map on file is of type " << iType << endl;
457  Fatal("ReadAsciiFile","Incompatible map types");
458  }
459  // Read Units
460  TString unit;
461  mapFile >> unit;
462  if ( unit == "G" ) funit = 0.001;
463  else if ( unit == "T" ) funit = 10.0;
464  else if ( unit == "kG" ) funit=1.0;
465  else {
466  cout << "-E- FieldMap::ReadAsciiFile: No units!"
467  << endl;
468  Fatal("ReadAsciiFile","No units defined");
469  }
470 
471 
472  // Read grid parameters
473 
474  mapFile >>fXmin >> fXmax >> fNx;
475  mapFile >>fYmin >> fYmax >> fNy;
476  mapFile >>fZmin >> fZmax >> fNz;
477  fXstep = ( fXmax - fXmin ) / Double_t( fNx - 1 );
478  fYstep = ( fYmax - fYmin ) / Double_t( fNy - 1 );
479  fZstep = ( fZmax - fZmin ) / Double_t( fNz - 1 );
480 
481  // Create field arrays
482  fBx = new TArrayF(fNx * fNy * fNz);
483  fBy = new TArrayF(fNx * fNy * fNz);
484  fBz = new TArrayF(fNx * fNy * fNz);
485 
486  // Read the field values
487  Double_t factor = fScale * funit; // Factor 1/1000 for G -> kG
488  cout << right;
489  Int_t nTot = fNx * fNy * fNz;
490  cout << "-I- PndFieldMap: " << nTot << " entries to read... "
491  << setw(3) << 0 << " % ";
492  Int_t index = 0;
493  div_t modul;
494  Int_t iDiv = TMath::Nint(nTot/100.);
495  for (Int_t ix=0; ix<fNx; ix++) {
496  for (Int_t iy = 0; iy<fNy; iy++) {
497  for (Int_t iz = 0; iz<fNz; iz++) {
498  if (! mapFile.good()) cerr << "-E- PndFieldMap::ReadAsciiFile: "
499  << "I/O Error at " << ix << " "
500  << iy << " " << iz << endl;
501  index = ix*fNy*fNz + iy*fNz + iz;
502  if (iDiv!=0)
503  {
504  modul = div(index,iDiv);
505  if ( modul.rem == 0 ) {
506  Double_t perc = TMath::Nint(100.*index/nTot);
507  cout << "\b\b\b\b\b\b" << setw(3) << perc << " % " << flush;
508  }
509  }
510  //mapFile >> xx>>yy>>zz>> bx >> by >> bz ;
511  mapFile >> bx >> by >> bz ;
512  //cout << " x= " <<xx <<" y= " << yy<<" z= " << zz<<" bx= " << bx <<" by= " <<by <<" bz= " << bz<< endl;
513  fBx->AddAt(factor*bx, index);
514  fBy->AddAt(factor*by, index);
515  fBz->AddAt(factor*bz, index);
516  if ( mapFile.eof() ) {
517  cerr << endl << "-E- PndFieldMap::ReadAsciiFile: EOF"
518  << " reached at " << ix << " " << iy << " " << iz << endl;
519  mapFile.close();
520  break;
521  }
522  } // z-Loop
523  } // y-Loop0)
524  } // x-Loop
525 
526  cout << " " << index+1 << " read" << endl;
527 
528  mapFile.close();
529 
530 }
Double_t funit
Definition: PndFieldMap.h:164
Double_t fYmin
Definition: PndFieldMap.h:173
Double_t fZstep
Definition: PndFieldMap.h:174
Double_t fZmin
Definition: PndFieldMap.h:174
Double_t fYmax
Definition: PndFieldMap.h:173
TArrayF * fBz
Definition: PndFieldMap.h:184
Double_t fXstep
Definition: PndFieldMap.h:172
Double_t fXmax
Definition: PndFieldMap.h:172
Double_t fScale
Definition: PndFieldMap.h:161
Double_t
TArrayF * fBy
Definition: PndFieldMap.h:183
TArrayF * fBx
Definition: PndFieldMap.h:182
Double_t fYstep
Definition: PndFieldMap.h:173
Double_t fZmax
Definition: PndFieldMap.h:174
int Nint(float x)
Definition: PndCAMath.h:117
Double_t fXmin
Definition: PndFieldMap.h:172
void PndFieldMap::ReadRootFile ( const char *  fileName,
const char *  mapName 
)
protectedinherited

Read field map from a ROOT file

Definition at line 536 of file PndFieldMap.cxx.

References exit(), file, and PndFieldMap::SetField().

Referenced by PndFieldMap::Init().

537  {
538 
539  // Store gFile pointer
540  TFile* oldFile = gFile;
541 
542  // Open root file
543  LOG(INFO) <<"PndFieldMap: Reading field map from ROOT file "<<fileName ;
544  TFile* file = new TFile(fileName, "READ");
545  if (file->IsZombie()) {
546  LOG(ERROR) << "-E- PndFieldMap::ReadRootfile: Cannot read from file! " ;
547  Fatal("ReadRootFile","Cannot read from file");
548  }
549 
550  // Get the field data object
551  PndFieldMapData* data = NULL;
552  file->GetObject(mapName, data);
553  if ( ! data ) {
554  LOG(ERROR)<<"PndFieldMap::ReadRootFile: data object %s not found in file! "<< fileName ;
555  exit(-1);
556  }
557 
558  // Get the field parameters
559  SetField(data);
560 
561  // Close the root file and delete the data object
562  file->Close();
563  delete data;
564  delete file;
565  if ( oldFile ) oldFile->cd();
566 
567 }
TFile * file
exit(0)
void SetField(const PndFieldMapData *data)
void PndFieldMap::Reset ( )
protectedinherited

Reset the field parameters and data

Definition at line 414 of file PndFieldMap.cxx.

References PndFieldMap::fBx, PndFieldMap::fBy, PndFieldMap::fBz, PndFieldMap::fNx, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::fPosX, PndFieldMap::fPosY, PndFieldMap::fPosZ, PndFieldMap::fScale, PndFieldMap::funit, PndFieldMap::fXmax, PndFieldMap::fXmin, PndFieldMap::fXstep, PndFieldMap::fYmax, PndFieldMap::fYmin, PndFieldMap::fYstep, PndFieldMap::fZmax, PndFieldMap::fZmin, and PndFieldMap::fZstep.

414  {
415  fPosX = fPosY = fPosZ = 0.;
416  fXmin = fYmin = fZmin = 0.;
417  fXmax = fYmax = fZmax = 0.;
418  fXstep = fYstep = fZstep = 0.;
419  fNx = fNy = fNz = 0;
420  fScale = 1.;
421  funit = 10.0;
422  if ( fBx ) { delete fBx; fBx = NULL; }
423  if ( fBy ) { delete fBy; fBy = NULL; }
424  if ( fBz ) { delete fBz; fBz = NULL; }
425 }
Double_t funit
Definition: PndFieldMap.h:164
Double_t fYmin
Definition: PndFieldMap.h:173
Double_t fZstep
Definition: PndFieldMap.h:174
Double_t fZmin
Definition: PndFieldMap.h:174
Double_t fYmax
Definition: PndFieldMap.h:173
TArrayF * fBz
Definition: PndFieldMap.h:184
Double_t fXstep
Definition: PndFieldMap.h:172
Double_t fXmax
Definition: PndFieldMap.h:172
Double_t fPosZ
Definition: PndFieldMap.h:168
Double_t fScale
Definition: PndFieldMap.h:161
Double_t fPosY
Definition: PndFieldMap.h:168
TArrayF * fBy
Definition: PndFieldMap.h:183
TArrayF * fBx
Definition: PndFieldMap.h:182
Double_t fPosX
Definition: PndFieldMap.h:168
Double_t fYstep
Definition: PndFieldMap.h:173
Double_t fZmax
Definition: PndFieldMap.h:174
Double_t fXmin
Definition: PndFieldMap.h:172
void PndFieldMap::SetField ( const PndFieldMapData data)
protectedinherited

Set field parameters and data

Definition at line 573 of file PndFieldMap.cxx.

References Double_t, PndFieldMap::fBx, PndFieldMap::fBy, PndFieldMap::fBz, PndFieldMap::fNx, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::fScale, PndFieldMap::funit, PndFieldMap::fXmax, PndFieldMap::fXmin, PndFieldMap::fXstep, PndFieldMap::fYmax, PndFieldMap::fYmin, PndFieldMap::fYstep, PndFieldMap::fZmax, PndFieldMap::fZmin, PndFieldMap::fZstep, PndFieldMapData::GetBx(), PndFieldMapData::GetBy(), PndFieldMapData::GetBz(), PndFieldMapData::GetNx(), PndFieldMapData::GetNy(), PndFieldMapData::GetNz(), PndFieldMapData::GetType(), PndFieldMapData::GetXmax(), PndFieldMapData::GetXmin(), PndFieldMapData::GetYmax(), PndFieldMapData::GetYmin(), PndFieldMapData::GetZmax(), and PndFieldMapData::GetZmin().

Referenced by PndFieldMap::ReadRootFile().

573  {
574 
575  // Check compatibility
576  if ( data->GetType() != fType ) {
577  LOG(ERROR)<<"PndFieldMap::SetField: Incompatible map types Field map is of type "<<fType<<" \n but map on file is of type "<<data->GetType() ;
578  Fatal("SetField","Incompatible map types");
579  }
580 
581 
582  fXmin = data->GetXmin();
583  fYmin = data->GetYmin();
584  fZmin = data->GetZmin();
585  fXmax = data->GetXmax();
586  fYmax = data->GetYmax();
587  fZmax = data->GetZmax();
588  fNx = data->GetNx();
589  fNy = data->GetNy();
590  fNz = data->GetNz();
591  fXstep = ( fXmax - fXmin ) / Double_t( fNx - 1 );
592  fYstep = ( fYmax - fYmin ) / Double_t( fNy - 1 );
593  fZstep = ( fZmax - fZmin ) / Double_t( fNz - 1 );
594  if ( fBx ) delete fBx;
595  if ( fBy ) delete fBy;
596  if ( fBz ) delete fBz;
597  fBx = new TArrayF(*(data->GetBx()));
598  fBy = new TArrayF(*(data->GetBy()));
599  fBz = new TArrayF(*(data->GetBz()));
600 
601  // Scale and convert from G(or T) to kG
602  Double_t factor = fScale * funit;
603  Int_t index = 0;
604  for (Int_t ix=0; ix<fNx; ix++) {
605  for (Int_t iy=0; iy<fNy; iy++) {
606  for (Int_t iz=0; iz<fNz; iz++) {
607  index = ix*fNy*fNz + iy*fNz + iz;
608  if ( fBx ) (*fBx)[index] = (*fBx)[index] * factor;
609  if ( fBy ) (*fBy)[index] = (*fBy)[index] * factor;
610  if ( fBz ) (*fBz)[index] = (*fBz)[index] * factor;
611  }
612  }
613  }
614 
615 }
Double_t funit
Definition: PndFieldMap.h:164
Double_t fYmin
Definition: PndFieldMap.h:173
Double_t GetYmin() const
Double_t GetZmin() const
Double_t GetXmax() const
Double_t fZstep
Definition: PndFieldMap.h:174
Int_t GetNy() const
Double_t fZmin
Definition: PndFieldMap.h:174
Double_t GetZmax() const
Double_t fYmax
Definition: PndFieldMap.h:173
TArrayF * fBz
Definition: PndFieldMap.h:184
Double_t fXstep
Definition: PndFieldMap.h:172
Double_t fXmax
Definition: PndFieldMap.h:172
TArrayF * GetBz() const
Double_t fScale
Definition: PndFieldMap.h:161
Double_t
Double_t GetXmin() const
TArrayF * fBy
Definition: PndFieldMap.h:183
Int_t GetNx() const
TArrayF * fBx
Definition: PndFieldMap.h:182
Double_t GetYmax() const
Double_t fYstep
Definition: PndFieldMap.h:173
Int_t GetNz() const
TArrayF * GetBy() const
TArrayF * GetBx() const
Double_t fZmax
Definition: PndFieldMap.h:174
Int_t GetType() const
Double_t fXmin
Definition: PndFieldMap.h:172
void PndFieldMap::SetPosition ( Double_t  x,
Double_t  y,
Double_t  z 
)
inherited

Set the position of the field centre

Definition at line 368 of file PndFieldMap.cxx.

References PndFieldMap::fPosX, PndFieldMap::fPosY, PndFieldMap::fPosZ, x, y, and z.

368  {
369  fPosX = x;
370  fPosY = y;
371  fPosZ = z;
372 }
Double_t fPosZ
Definition: PndFieldMap.h:168
Double_t z
Double_t fPosY
Definition: PndFieldMap.h:168
Double_t fPosX
Definition: PndFieldMap.h:168
Double_t x
Double_t y
void PndFieldMap::SetScale ( Double_t  factor)
inlineinherited

Set a global field scaling factor

Definition at line 84 of file PndFieldMap.h.

References PndFieldMap::fScale.

84 { fScale = factor; }
Double_t fScale
Definition: PndFieldMap.h:161
void PndFieldMap::WriteAsciiFile ( const char *  fileName)
inherited

Write the field map to an ASCII file

Definition at line 292 of file PndFieldMap.cxx.

References Double_t, PndFieldMap::fBx, PndFieldMap::fBy, PndFieldMap::fBz, PndFieldMap::fNx, PndFieldMap::fNy, PndFieldMap::fNz, PndFieldMap::fScale, PndFieldMap::funit, PndFieldMap::fXmax, PndFieldMap::fXmin, PndFieldMap::fYmax, PndFieldMap::fYmin, PndFieldMap::fZmax, PndFieldMap::fZmin, and CAMath::Nint().

292  {
293 
294  // Open file
295  LOG(INFO) <<"PndFieldMap: Writing field map to ASCII file " <<fileName ;
296  ofstream mapFile(fileName);
297  if ( ! mapFile.is_open() ) {
298  LOG(ERROR) << "PndFieldMap:ReadAsciiFile: Could not open file! " ;
299  return;
300  }
301 
302  // Write field map grid parameters
303  mapFile.precision(4);
304  mapFile << showpoint;
305  if ( fType == 1 ) mapFile << "nosym" << endl;
306  if ( fType == 2 ) mapFile << "Solenoid" << endl;
307  if ( fType == 3 ) mapFile << "Dipole" << endl;
308  if ( fType == 4 ) mapFile << "Trans" << endl;
309  if ( funit == 10.0 ) mapFile << "T" << endl;
310  if ( funit == 0.001 ) mapFile << "G" << endl;
311  if ( funit == 1.0 ) mapFile << "kG" << endl;
312 
313  mapFile << fXmin << " " << fXmax << " " << fNx << endl;
314  mapFile << fYmin << " " << fYmax << " " << fNy << endl;
315  mapFile << fZmin << " " << fZmax << " " << fNz << endl;
316 
317  // Write field values
318  Double_t factor = funit * fScale; // Takes out scaling
319  cout << right;
320  Int_t nTot = fNx * fNy * fNz;
321  cout << "-I- PndFieldMap: " << fNx*fNy*fNz << " entries to write... "
322  << setw(3) << 0 << " % ";
323  Int_t index=0;
324  div_t modul;
325  Int_t iDiv = TMath::Nint(nTot/100.);
326  for(Int_t ix=0; ix<fNx; ix++) {
327  for(Int_t iy=0; iy<fNy; iy++) {
328  for(Int_t iz=0; iz<fNz; iz++) {
329  index =ix*fNy*fNz + iy*fNz + iz;
330  if (iDiv!=0)
331  {
332  modul = div(index,iDiv);
333  if ( modul.rem == 0 ) {
334  Double_t perc = TMath::Nint(100.*index/nTot);
335  cout << "\b\b\b\b\b\b" << setw(3) << perc << " % " << flush;
336  }
337  }
338  mapFile << fBx->At(index)/factor << " " << fBy->At(index)/factor
339  << " " << fBz->At(index)/factor << endl;
340  } // z-Loop
341  } // y-Loop
342  } // x-Loop
343  cout << " " << index+1 << " written" << endl;
344  mapFile.close();
345 
346 }
Double_t funit
Definition: PndFieldMap.h:164
Double_t fYmin
Definition: PndFieldMap.h:173
Double_t fZmin
Definition: PndFieldMap.h:174
Double_t fYmax
Definition: PndFieldMap.h:173
TArrayF * fBz
Definition: PndFieldMap.h:184
Double_t fXmax
Definition: PndFieldMap.h:172
Double_t fScale
Definition: PndFieldMap.h:161
Double_t
TArrayF * fBy
Definition: PndFieldMap.h:183
TArrayF * fBx
Definition: PndFieldMap.h:182
Double_t fZmax
Definition: PndFieldMap.h:174
int Nint(float x)
Definition: PndCAMath.h:117
Double_t fXmin
Definition: PndFieldMap.h:172
void PndFieldMap::WriteRootFile ( const char *  fileName,
const char *  mapName 
)
inherited

Write field map data to a ROOT file

Definition at line 352 of file PndFieldMap.cxx.

References file.

Referenced by interpolate_fieldmap(), and transform_jost_fieldmap().

353  {
354 
355  PndFieldMapData* data = new PndFieldMapData(mapName, *this);
356  TFile* oldFile = gFile;
357  TFile* file = new TFile(fileName, "RECREATE");
358  data->Write();
359  file->Close();
360  if(oldFile) oldFile->cd();
361 
362 }
TFile * file

Member Data Documentation

Double_t PndDipoleMap::fBeamMom
protected

Definition at line 76 of file PndDipoleMap.h.

Referenced by PndDipoleMap().

TArrayF* PndFieldMap::fBx
protectedinherited
TArrayF* PndFieldMap::fBy
protectedinherited
TArrayF* PndFieldMap::fBz
protectedinherited
TString PndFieldMap::fFileName
protectedinherited
Double_t PndFieldMap::fHa[2][2][2]
protectedinherited

Variables for temporary storage Used in the very frequently called method GetFieldValue

Definition at line 189 of file PndFieldMap.h.

Referenced by PndFieldMap::GetBx(), PndTransMap::GetBxyz(), PndSolenoidMap::GetBxyz(), GetBxyz(), PndFieldMap::GetBy(), PndFieldMap::GetBz(), PndFieldMap::Interpolate(), and PndFieldMap::PndFieldMap().

Double_t PndFieldMap::fHb[2][2]
protectedinherited

Field at corners of a grid cell.

Definition at line 190 of file PndFieldMap.h.

Referenced by PndFieldMap::Interpolate(), and PndFieldMap::PndFieldMap().

Double_t PndFieldMap::fHc[2]
protectedinherited

Interpolated field (2-dim)

Definition at line 191 of file PndFieldMap.h.

Referenced by PndFieldMap::Interpolate(), and PndFieldMap::PndFieldMap().

Double_t PndDipoleMap::fHemiX
protected

Definition at line 75 of file PndDipoleMap.h.

Referenced by GetBxyz(), and IsInside().

Double_t PndDipoleMap::fHemiY
protected

Definition at line 75 of file PndDipoleMap.h.

Referenced by GetBxyz(), and IsInside().

Int_t PndDipoleMap::fNumberOfRegions =0
static

Definition at line 62 of file PndDipoleMap.h.

Referenced by PndDipoleMap(), and PndMultiFieldPar::SetParameters().

Int_t PndFieldMap::fNx
protectedinherited
Int_t PndFieldMap::fNy
protectedinherited
Int_t PndFieldMap::fNz
protectedinherited
Double_t PndFieldMap::fPosX
protectedinherited
Double_t PndFieldMap::fPosY
protectedinherited
Double_t PndFieldMap::fPosZ
protectedinherited
Int_t PndDipoleMap::fRegionNo

Definition at line 63 of file PndDipoleMap.h.

Referenced by GetRegionNo(), and PndDipoleMap().

Double_t PndFieldMap::fScale
protectedinherited
Double_t PndFieldMap::funit
protectedinherited
Double_t PndFieldMap::fXmax
protectedinherited
Double_t PndFieldMap::fXmin
protectedinherited
Double_t PndFieldMap::fXstep
protectedinherited
Double_t PndFieldMap::fYmax
protectedinherited
Double_t PndFieldMap::fYmin
protectedinherited
Double_t PndFieldMap::fYstep
protectedinherited
Double_t PndFieldMap::fZmax
protectedinherited
Double_t PndFieldMap::fZmin
protectedinherited
Double_t PndFieldMap::fZstep
protectedinherited

The documentation for this class was generated from the following files: