FairRoot/PandaRoot
PndTransMap.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndTransMap source file -----
3 // ----- Created 29/01/07 by M. Al/Turany -----
4 // -------------------------------------------------------------------------
5 
6 #include "FairRun.h"
7 #include "FairRuntimeDb.h"
8 
9 
10 
11 #include "PndTransMap.h"
12 #include "PndTransPar.h"
13 #include "FairRunSim.h"
14 #include "TArrayF.h"
15 
16 
17 #include <iostream>
18 #include "stdlib.h"
19 
20 
21 
22 using namespace std;
23 // ------------- Default constructor ----------------------------------
25  :PndFieldMap(), fHemiX(0), fHemiY(0), fBeamMom(0.)
26 {
27  fType = 4;
28 }
29 // ------------------------------------------------------------------------
30 
31 
32 
33 // ------------- Standard constructor ---------------------------------
34 PndTransMap::PndTransMap(const char* mapName,
35  const char* fileType, Double_t BeamMom)
36  : PndFieldMap(mapName, fileType), fHemiX(0), fHemiY(0),fBeamMom(BeamMom)
37 {
38  fType = 4;
39  TString Suffix="";
40  FairRunSim *fRun= FairRunSim::Instance();
41  if(fRun) fBeamMom= fRun->GetBeamMom();
42 
43  if(fBeamMom< 3)Suffix=".0150" ;
44  else if (fBeamMom< 6.0 && fBeamMom >= 3.0)Suffix=".0406";
45  else if (fBeamMom< 10.0 && fBeamMom >= 6.0 )Suffix=".0890" ;
46  else if (fBeamMom< 13.0 && fBeamMom >= 10.0)Suffix=".1191";
47  else if (fBeamMom> 13.0) Suffix=".1500";
48 
49 
50  TString NewName=mapName;
51  NewName=mapName+Suffix;
52  SetName(NewName.Data());
53  TString dir = getenv("VMCWORKDIR");
54  fFileName = dir + "/input/fieldmaps/" + NewName;
55  if ( fileType[0] == 'R' ) fFileName += ".root";
56  else fFileName += ".dat";
57 
58 
59 
60 }
61 // ------------------------------------------------------------------------
62 
63 
64 
65 // ------------ Constructor from PndFieldPar --------------------------
67  : PndFieldMap(), fHemiX(0), fHemiY(0),fBeamMom(0)
68 {
69  fType = 4;
70  fPosX = fPosY = fPosZ = 0.;
71  fXmin = fYmin = fZmin = 0.;
72  fXmax = fYmax = fZmax = 0.;
73  fXstep = fYstep = fZstep = 0.;
74  fNx = fNy = fNz = 0;
75  fScale = 1.;
76  funit = 10.0;
77  fBx = fBy = fBz = NULL;
78  if ( ! fieldPar ) {
79  cerr << "-W- PndTransMap::PndTransMap: empty parameter container!"
80  << endl;
81  fName = "";
82  fFileName = "";
83  fType = 1;
84  }
85  else {
86  fieldPar->MapName(fName);
87  fPosX = fieldPar->GetPositionX();
88  fPosY = fieldPar->GetPositionY();
89  fPosZ = fieldPar->GetPositionZ();
90  fScale = fieldPar->GetScale();
91  TString dir = getenv("VMCWORKDIR");
92  fFileName = dir + "/input/fieldmaps/" + fName + ".root";
93  fType = fieldPar->GetType();
94  }
95 }
96 // ------------------------------------------------------------------------
97 
98 
99 
100 // ------------ Destructor --------------------------------------------
102 {
103  //printf("PndTransMap::~PndTransMap() \n ");
104 }
105 // ------------------------------------------------------------------------
107 {
108  Double_t x =point[0];
109  Double_t y =point[1];
110  Double_t z =point[2];
111  Int_t ix = 0;
112  Int_t iy = 0;
113  Int_t iz = 0;
114  Double_t dx = 0.;
115  Double_t dy = 0.;
116  Double_t dz = 0.;
117 
118  if ( IsInside(x, y, z, ix, iy, iz, dx, dy, dz) ){
119  // Get Bx field values at grid cell corners
120  fHa[0][0][0] = fBx->At(ix *fNy*fNz + iy *fNz + iz);
121  fHa[1][0][0] = fBx->At((ix+1)*fNy*fNz + iy *fNz + iz);
122  fHa[0][1][0] = fBx->At(ix *fNy*fNz + (iy+1)*fNz + iz);
123  fHa[1][1][0] = fBx->At((ix+1)*fNy*fNz + (iy+1)*fNz + iz);
124  fHa[0][0][1] = fBx->At(ix *fNy*fNz + iy *fNz + (iz+1));
125  fHa[1][0][1] = fBx->At((ix+1)*fNy*fNz + iy *fNz + (iz+1));
126  fHa[0][1][1] = fBx->At(ix *fNy*fNz + (iy+1)*fNz + (iz+1));
127  fHa[1][1][1] = fBx->At((ix+1)*fNy*fNz + (iy+1)*fNz + (iz+1));
128 
129  //Bx is antisymtric in X
130  bField[0] =Interpolate(dx, dy, dz) * fHemiX ;
131 
132  // Get By field values at grid cell corners
133  fHa[0][0][0] = fBy->At(ix *fNy*fNz + iy *fNz + iz);
134  fHa[1][0][0] = fBy->At((ix+1)*fNy*fNz + iy *fNz + iz);
135  fHa[0][1][0] = fBy->At(ix *fNy*fNz + (iy+1)*fNz + iz);
136  fHa[1][1][0] = fBy->At((ix+1)*fNy*fNz + (iy+1)*fNz + iz);
137  fHa[0][0][1] = fBy->At(ix *fNy*fNz + iy *fNz + (iz+1));
138  fHa[1][0][1] = fBy->At((ix+1)*fNy*fNz + iy *fNz + (iz+1));
139  fHa[0][1][1] = fBy->At(ix *fNy*fNz + (iy+1)*fNz + (iz+1));
140  fHa[1][1][1] = fBy->At((ix+1)*fNy*fNz + (iy+1)*fNz + (iz+1));
141 
142  //By is symtric in X
143  bField[1] =Interpolate(dx, dy, dz);
144 
145  // Get Bz field values at grid cell corners
146  fHa[0][0][0] = fBz->At(ix *fNy*fNz + iy *fNz + iz);
147  fHa[1][0][0] = fBz->At((ix+1)*fNy*fNz + iy *fNz + iz);
148  fHa[0][1][0] = fBz->At(ix *fNy*fNz + (iy+1)*fNz + iz);
149  fHa[1][1][0] = fBz->At((ix+1)*fNy*fNz + (iy+1)*fNz + iz);
150  fHa[0][0][1] = fBz->At(ix *fNy*fNz + iy *fNz + (iz+1));
151  fHa[1][0][1] = fBz->At((ix+1)*fNy*fNz + iy *fNz + (iz+1));
152  fHa[0][1][1] = fBz->At(ix *fNy*fNz + (iy+1)*fNz + (iz+1));
153  fHa[1][1][1] = fBz->At((ix+1)*fNy*fNz + (iy+1)*fNz + (iz+1));
154 
155  // Return interpolated field value
156  //Bz is symtric in X
157  bField[2]=Interpolate(dx, dy, dz);
158 
159  }else{
160  bField[0]=0;
161  bField[1]=0;
162  bField[2]=0;
163  }
164 
165 }
166 
167 
168 
169 // ----------- Check whether a point is inside the map ----------------
171  Int_t& ix, Int_t& iy, Int_t& iz,
172  Double_t& dx, Double_t& dy,
173  Double_t& dz) {
174 
175  // --- Transform into local coordinate system
176  Double_t xl = x - fPosX;
177  Double_t yl = y - fPosY;
178  Double_t zl = z - fPosZ;
179 
180  // --- Reflect w.r.t. symmetry axes
181  fHemiX = fHemiY = 1.;
182  if ( xl < 0. ) {
183  fHemiX = -1.;
184  xl = -1. * xl;
185  }
186 
187  // --- Check for being outside the map range
188  if ( ! ( xl >= fXmin && xl <= fXmax && yl >= fYmin && yl <= fYmax &&
189  zl >= fZmin && zl <= fZmax ) ) {
190  ix = iy = iz = 0;
191  dx = dy = dz = 0.;
192  return kFALSE;
193  }
194 
195  // --- Determine grid cell
196  ix = Int_t( (xl-fXmin) / fXstep );
197  iy = Int_t( (yl-fYmin) / fYstep );
198  iz = Int_t( (zl-fZmin) / fZstep );
199 
200 
201  // Relative distance from grid point (in units of cell size)
202  dx = (xl-fXmin) / fXstep - Double_t(ix);
203  dy = (yl-fYmin) / fYstep - Double_t(iy);
204  dz = (zl-fZmin) / fZstep - Double_t(iz);
205 
206  return kTRUE;
207 
208 }
209 // ------------------------------------------------------------------------
211 {
212  TString MapName=GetName();
213  // cout << "PndConstField::FillParContainer() " << endl;
214  FairRun *fRun=FairRun::Instance();
215  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
216  //Bool_t kParameterMerged=kTRUE;
217  PndTransPar* Par = (PndTransPar*) rtdb->getContainer("PndTransPar");
218  Par->SetParameters(this);
219  Par->setInputVersion(fRun->GetRunId(),1);
220  Par->setChanged();
221 
222 }
223 
224 
225 
226 
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
Double_t fHemiX
Definition: PndTransMap.h:70
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 fZstep
Definition: PndFieldMap.h:174
Double_t fBeamMom
Definition: PndTransMap.h:71
Double_t fZmin
Definition: PndFieldMap.h:174
Double_t fHemiY
Definition: PndTransMap.h:70
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
void FillParContainer()
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
PndMultiFieldPar * fieldPar
Definition: sim_ftof.C:102
virtual ~PndTransMap()
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
Double_t z
Double_t fPosY
Definition: PndFieldMap.h:168
TArrayF * fBy
Definition: PndFieldMap.h:183
double dx
TArrayF * fBx
Definition: PndFieldMap.h:182
void GetBxyz(const Double_t point[3], Double_t *bField)
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
PndMultiFieldPar * Par
Definition: sim_emc_apd.C:115
Double_t GetPositionY() const
Definition: PndMapPar.h:60
ClassImp(PndAnaContFact)
Double_t fZmax
Definition: PndFieldMap.h:174
Double_t y
void SetParameters(FairField *field)
Definition: PndMapPar.cxx:91
Int_t GetType() const
Definition: PndMapPar.h:51
Double_t fXmin
Definition: PndFieldMap.h:172
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72