16#include "GaudiKernel/Bootstrap.h"
17#include "GaudiKernel/ISvcLocator.h"
21static const char* matNames[9] = {
"MDCGas",
22 "LogicalMdcInnerFilm1",
24 "LogicalMdcInnerFilm1",
39VertexExtrapolate::VertexExtrapolate()
41 m_BesKalmanExtMaterials.clear();
42 m_BesKalmanExtWalls.clear();
44 constructWallsFromGdml();
46 m_helixVector = CLHEP::Hep3Vector(5, 0);
47 m_errorMatrix = CLHEP::HepSymMatrix(5, 0);
49 ISvcLocator* svcLocator = Gaudi::svcLocator();
53 StatusCode sc = svcLocator->service(
"MagneticFieldSvc", IMFSvc);
55 std::cerr << MSG::ERROR <<
"Unable to open Magnetic field service"
65void VertexExtrapolate::G4MtovKalFitM(G4Material* g4m,
const std::string& name)
69 for (
unsigned i = 0; i != g4m->GetElementVector()->size(); ++i) {
70 Z += (g4m->GetElement(i)->GetZ()) * (g4m->GetFractionVector()[i]);
71 A += (g4m->GetElement(i)->GetA()) * (g4m->GetFractionVector()[i]);
73 double Ionization = g4m->GetIonisation()->GetMeanExcitationEnergy();
74 double Density = g4m->GetDensity() / (g / cm3);
75 double Radlen = g4m->GetRadlen();
76 std::cout <<
" " << name <<
": Z: " << Z <<
" A: " << (
A / (g / mole))
77 <<
" Ionization: " << (Ionization / eV) <<
" Density: " << Density
78 <<
" Radlen: " << Radlen << std::endl;
79 KalFitMaterial FitMdcMaterial(Z, A / g / mole, Ionization / eV, Density,
81 m_BesKalmanExtMaterials.push_back(FitMdcMaterial);
84void VertexExtrapolate::AddWalls(
int index,
double radius,
double thick,
85 double length,
double z0)
87 std::cout <<
" " << matNames[index] <<
": radius: " << radius
88 <<
", thick: " << thick <<
", length: " << length << std::endl;
92 m_BesKalmanExtWalls.push_back(innerwallCylinder);
95void VertexExtrapolate::AddWalls(
int index)
97 G4Tubs* g4t = getTubs(matNames[index]);
98 double radius = g4t->GetInnerRadius() / (cm);
99 double thick = g4t->GetOuterRadius() / (cm)-g4t->GetInnerRadius() / (cm);
100 double length = 2.0 * g4t->GetZHalfLength() / (cm);
103 AddWalls(index, radius, thick, length, z0);
106void VertexExtrapolate::testMW(
int index)
110 std::cout << index <<
" ==========================" << std::endl;
111 std::cout <<
"TEST==Radlen: " << m.
X0() << std::endl;
112 std::cout <<
"TEST==Radlen: " <<
w.material().X0()
113 <<
" radius: " <<
w.radius() << std::endl;
116void VertexExtrapolate::constructWallsFromGdml(
void)
119 G4LogicalVolume* logicalMdc = 0;
122 G4Material* mat = logicalMdc->GetMaterial();
124 G4MtovKalFitM(mat,
"MDCGas");
129 for (
int i = 1; i != 9; ++i) {
130 G4LogicalVolume* logicalAirVolume =
const_cast<G4LogicalVolume*
>(
131 GDMLProcessor::GetInstance()->GetLogicalVolume(matNames[i]));
132 mat = logicalAirVolume->GetMaterial();
133 G4MtovKalFitM(mat, matNames[i]);
137 for (
int i = 1; i != 4; ++i)
141 G4Tubs* innerwallTub = getTubs(
"LogicalMdcInnerFilm0");
142 G4Tubs* outerBeTub = getTubs(
"logicalouterBe");
143 double radius = outerBeTub->GetOuterRadius() / (cm);
144 double thick = innerwallTub->GetInnerRadius() /
145 (cm)-outerBeTub->GetOuterRadius() / (cm);
146 double length = 2.0 * innerwallTub->GetZHalfLength() / (cm);
148 AddWalls(4, radius, thick, length, z0);
150 for (
int i = 5; i != 9; ++i)
154 G4Tubs* goldLayerTub = getTubs(
"logicalgoldLayer");
156 thick = goldLayerTub->GetInnerRadius() / (cm);
157 length = 2.0 * goldLayerTub->GetZHalfLength() / (cm);
159 AddWalls(4, radius, thick, length, z0);
165int VertexExtrapolate::getWallMdcNumber(
const HepPoint3D& point)
const
167 int i = m_BesKalmanExtWalls.size() - 1;
169 if (m_BesKalmanExtWalls[i].isInside2(point))
break;
174void VertexExtrapolate::extToAnyPoint(
KalFitTrack& track,
177 const int index = getWallMdcNumber(point);
180 if (index == -1)
return;
183 for (
int j = 0; j < index; j++)
184 m_BesKalmanExtWalls[j].updateTrack(track, 1);
186 int size = m_BesKalmanExtWalls.size() - 1;
188 const KalFitMaterial& material = m_BesKalmanExtWalls[index].material();
191 double path = m_BesKalmanExtWalls[index].intersect(track, x, point);
197 int index_element(index);
198 if (index_element == 0) index_element = 1;
199 track.
ms(path, material, index_element);
200 track.
eloss(path, material, index_element);
208 HepVector tdsHelix = kalTrack->
getFHelix(pid);
209 HepSymMatrix tdsMatrix = kalTrack->
getFError(pid);
213 KalFitTrack fitTrack(IP, tdsHelix, tdsMatrix, pid, 0, 0);
216 const double rp = point.perp();
219 const double radius = m_BesKalmanExtWalls[0].radius();
222 fitTrack.
pivot(lastPivot);
223 if (rp <= radius) extToAnyPoint(fitTrack, point);
228 setHelixVector(fitTrack.
a());
229 setErrorMatrix(fitTrack.
Ea());
const HepSymMatrix & getFError(const int pid) const
const HepVector & getFHelix(const int pid) const
Cylinder is an Element whose shape is a cylinder.
double X0(void) const
Extractor.
Description of a track class (<- Helix.cc)
const HepPoint3D & pivot_numf(const HepPoint3D &newPivot)
Sets pivot position in a given mag field.
void ms(double path, const KalFitMaterial &m, int index)
double intersect_cylinder(double r) const
Intersection with different geometry.
static int numf_
Flag for treatment of non-uniform mag field.
static double mdcGasRadlen_
void eloss(double path, const KalFitMaterial &m, int index)
Calculate total energy lost in material.
static void setMagneticFieldSvc(IMagneticFieldSvc *)
const HepSymMatrix & Ea(void) const
returns error matrix.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
const HepVector & a(void) const
returns helix parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
G4LogicalVolume * GetTopVolume()
Get the top(world) volume;.