FairRoot/PandaRoot
PndDipoleMap.cxx
Go to the documentation of this file.
1 
2 #include <iostream>
3 #include "TArrayF.h"
4 #include "stdlib.h"
5 #include "PndDipoleMap.h"
6 #include "PndDipolePar.h"
7 #include "PndMapPar.h"
8 #include "FairRunSim.h"
9 
11 
12 using namespace std;
13 // ------------- Default constructor ----------------------------------
15  :PndFieldMap(), fRegionNo(0), fHemiX(0), fHemiY(0), fBeamMom(0.)
16 {
17  fType = 3;
18 }
19 // ------------------------------------------------------------------------
20 
21 
22 
23 // ------------- Standard constructor ---------------------------------
24 PndDipoleMap::PndDipoleMap(const char* mapName,
25  const char* fileType, Double_t BeamMom)
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 }
53 // ------------------------------------------------------------------------
54 
55 
56 
57 // ------------ Constructor from PndFieldPar --------------------------
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 }
90 // ------------------------------------------------------------------------
91 
92 
93 
94 // ------------ Destructor --------------------------------------------
96 // ------------------------------------------------------------------------
97 
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 }
162 
163 
164 // ----------- Check whether a point is inside the map ----------------
166  Int_t& ix, Int_t& iy, Int_t& iz,
167  Double_t& dx, Double_t& dy,
168  Double_t& dz) {
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 }
208 // ------------------------------------------------------------------------
210 {
211  TString MapName=GetName();
212  cout << "PndDipoleMap::FillParContainer() " << endl;
213 
214 }
215 
216 
217 
Double_t fHa[2][2][2]
Definition: PndFieldMap.h:189
Double_t funit
Definition: PndFieldMap.h:164
double dy
Double_t GetPositionX() const
Definition: PndMapPar.h:59
Double_t fYmin
Definition: PndFieldMap.h:173
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)
Double_t GetScale() const
Definition: PndMapPar.h:62
static Int_t fNumberOfRegions
Definition: PndDipoleMap.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
virtual ~PndDipoleMap()
FairRunAna * fRun
Definition: hit_dirc.C:58
Double_t fPosZ
Definition: PndFieldMap.h:168
Double_t fScale
Definition: PndFieldMap.h:161
Double_t Interpolate(Double_t dx, Double_t dy, Double_t dz)
Double_t
Double_t fHemiY
Definition: PndDipoleMap.h:75
PndMultiFieldPar * fieldPar
Definition: sim_ftof.C:102
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)
Double_t fPosY
Definition: PndFieldMap.h:168
TArrayF * fBy
Definition: PndFieldMap.h:183
double dx
TArrayF * fBx
Definition: PndFieldMap.h:182
Double_t fPosX
Definition: PndFieldMap.h:168
Double_t x
Double_t GetPositionZ() const
Definition: PndMapPar.h:61
Double_t fYstep
Definition: PndFieldMap.h:173
void FillParContainer()
void GetBxyz(const Double_t point[3], Double_t *bField)
Double_t GetPositionY() const
Definition: PndMapPar.h:60
ClassImp(PndAnaContFact)
Double_t fZmax
Definition: PndFieldMap.h:174
Int_t fRegionNo
Definition: PndDipoleMap.h:63
Double_t y
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