SND@LHC Software
Loading...
Searching...
No Matches
GoliathField.cc
Go to the documentation of this file.
1/* Copyright 2008-2010, Technische Universitaet Muenchen,
2 Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
3
4 This file is part of GENFIT.
5
6 GENFIT is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 GENFIT is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18
19 This file should stay in sync with charmdet/MuonfluxSpectrometer.cxx and charmdet/Spectrometer.cxx.
20 It is used for fitting reconstructed tracks. After instantiating in shipDigiReco.py call setup():
21
22 self.bfield = ROOT.genfit.GoliathField(0 ,1.*u.tesla,0)
23 self.bfield.setup()
24
25 Contact EvH for help if necessary.
26*/
27#include "GoliathField.h"
28#include "TGeoNavigator.h"
29#include "TGeoNode.h"
30#include "TGeoManager.h"
31#include "TGeoBBox.h"
32#include "TVector3.h"
33
34#include <stddef.h> // for NULL
35#include <iostream> // for operator<<, basic_ostream, etc
36
37using std::cout;
38using std::endl;
39using std::vector;
40
41namespace genfit {
42
43TVector3 GoliathField::get(const TVector3&) const {
44 return field_;
45}
46
47void GoliathField::get(const double& posX, const double& posY, const double& posZ, double& Bx, double& By, double& Bz) const {
48 Bx=0.;By=0.;Bz=0.;
49 if ((posX < coords[0][0]) && (posX > coords[0][3]) && (posY < coords[0][1]) && (posY > coords[0][4]) && (posZ < coords[0][2]+5.) && (posZ>coords[0][5]+5.) ) {
50 Bx = field_.X();
51 By = field_.Y();
52 Bz = field_.Z();
53 }
54 else {
55 for (Int_t i=1;i<13;i++){
56 if ((posX < coords[i][0]) && (posX > coords[i][3]) && (posY < coords[i][1]) && (posY > coords[i][4]) && (posZ < coords[i][2]) && (posZ>coords[i][5])) {
57 Bx = 0.;
58 By = -10.;
59 Bz = 0.;
60 break;
61 }
62 }
63 }
64}
65
66
67void GoliathField::getpos(TString volname, TVector3 &vbot, TVector3 &vtop) const {
68 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
69 Bool_t rc = nav->cd(volname);
70 if (not rc){
71 cout << "Goliathfield::getpos, TGeoNavigator failed "<<volname<<endl;
72 return;
73 }
74 TGeoNode* W = nav->GetCurrentNode();
75 TGeoBBox* S = dynamic_cast<TGeoBBox*>(W->GetVolume()->GetShape());
76 Double_t top[3] = {S->GetDX(),S->GetDY(),S->GetDZ()};
77 Double_t bot[3] = {-S->GetDX(),-S->GetDY(),-S->GetDZ()};
78 Double_t Gtop[3],Gbot[3];
79 nav->LocalToMaster(top, Gtop);
80 nav->LocalToMaster(bot, Gbot);
81 vtop.SetXYZ(Gtop[0],Gtop[1],Gtop[2]);
82 vbot.SetXYZ(Gbot[0],Gbot[1],Gbot[2]);
83}
84
86 TVector3 bot,top;
87 std::vector<TString> volume={"/volGoliath_1/VolVacuum_1","/volGoliath_1/volLateralS1_1","/volGoliath_1/volLateralS2_1","/volGoliath_1/volLateralSurface1low_1",
88 "/volGoliath_1/volLateralSurface2low_1","/volGoliath_1/volLateralS1_b_1","/volGoliath_1/volLateralS2_b_1","/volGoliath_1/volLateralSurface1blow_1",
89 "/volGoliath_1/volLateralSurface2blow_1","/volGoliath_1/volLateralS1_d_1","/volGoliath_1/volLateralS2_d_1","/volGoliath_1/volLateralS1_c_1",
90 "/volGoliath_1/volLateralS2_c_1"};
91 for (Int_t i=0;i<13;i++){
92 getpos(volume[i],bot,top);
93 for (Int_t j=0;j<3;j++) {
94 coords[i][j]=top[j];
95 coords[i][j+3]=bot[j];
96 }
97 //std::cout<<volume[i]<<" "<<coords[i][3] << " posX " << posX <<" "<< coords[i][0] << ";" << coords[i][4] << " posY "<< posY <<" "<< coords[i][1] << ";" << coords[i][5] << " posZ " << posZ<<" "<< coords[i][2]<<std::endl;
98 }
99}
100
101
102} /* End of namespace genfit */
103
void getpos(TString vol, TVector3 &bot, TVector3 &top) const
Float_t coords[13][6]
TVector3 get(const TVector3 &pos) const
return value at position
Matrix inversion tools.
Definition AbsBField.h:29