7#ifndef PORTABLE_LAR_SHAPE
10#include "CLHEP/Units/PhysicalConstants.h"
17 LWSDBG(1, std::cout <<
TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP) << std::endl);
22 LWSDBG(2, std::cout <<
"Outside BS" << std::endl);
25 G4ThreeVector p(inputP);
34 const G4double d = fabs(
GetCalculator()->DistanceToTheNearestFan(p, p_fan));
37 LWSDBG(2, std::cout <<
"dti result = " <<
result << std::endl);
40 LWSDBG(2, std::cout <<
"already inside, return 0" << MSG_VECTOR(p) << std::endl);
45 const G4ThreeVector &inputV)
const
47 LWSDBG(1, std::cout <<
TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP)
48 << MSG_VECTOR(inputV) << std::endl);
50 G4double distance = 0.;
52 G4ThreeVector p(inputP);
53 if(inside_BS == kOutside) {
55 if(distance == kInfinity) {
56 LWSDBG(2, std::cout <<
"Infinity distance to m_BoundingShape"
57 << MSG_VECTOR(inputP) << MSG_VECTOR(inputV)
61 p += inputV * distance;
63 LWSDBG(2, std::cout <<
"shift" << MSG_VECTOR(inputP) << std::endl);
66 const G4double phi0 = p.phi();
70 LWSDBG(2, std::cout <<
"already inside fan" << MSG_VECTOR(p) << std::endl);
72 if(inside_BS == kSurface) {
73 LWSDBG(2, std::cout <<
"On BS surface" << std::endl);
78 G4ThreeVector v(inputV);
79 v.rotateZ(p.phi() - phi0);
84#ifdef DEBUG_LARWHEELSLICESOLID
87 std::cout << MSG_VECTOR(inputP)
88 <<
" " << MSG_VECTOR(inputV) << std::endl;
90 std::cout <<
"dti: " << d0 <<
", DTI: " << distance << std::endl;
94 G4ThreeVector p2 = inputP + inputV*distance;
96 std::cout <<
"DTI hit at dist. " << distance <<
", point "
97 << MSG_VECTOR(p2) <<
", "
98 << inside(i) << std::endl;
100 std::cout <<
"got infinity from dti" << std::endl;
103#ifdef LWS_HARD_TEST_DTI
104 if(test_dti(inputP, inputV, distance)){
106 std::cout <<
TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP)
107 << MSG_VECTOR(inputV) << std::endl;
111 std::cout <<
TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP)
112 << MSG_VECTOR(inputV) <<
" " << distance << std::endl;
123 LWSDBG(4, std::cout <<
"dti: " << MSG_VECTOR(p) <<
" "
124 << MSG_VECTOR(v) << std::endl);
126 G4double distance = 0.;
129 if(v.x() >= 0.)
return kInfinity;
130 const G4double b = (
m_Xmax - p.x()) / v.x();
131 const G4double y2 = p.y() + v.y() * b;
132 const G4double z2 = p.z() + v.z() * b;
135 }
else if(p.x() <
m_Xmin) {
136 if(v.x() <= 0.)
return kInfinity;
137 const G4double b = (
m_Xmin - p.x()) / v.x();
138 const G4double y2 = p.y() + v.y() * b;
139 const G4double z2 = p.z() + v.z() * b;
146 LWSDBG(5, std::cout <<
"dti corrected: " << MSG_VECTOR(p) << std::endl);
150 LWSDBG(5, std::cout <<
"hit fan dist_p=" << dist_p <<
", m_FHTminusT=" <<
m_FHTminusT << std::endl);
157 LWSDBG(5, std::cout <<
"dti exit point: " << MSG_VECTOR(q) <<
" "
158 << dist_q << std::endl);
159 G4double dd = kInfinity;
160 if(dist_p * dist_q < 0.){
165 return distance + d2;
166 }
else if(dd < kInfinity){
167 return distance + dd;
178 const G4ThreeVector &p, G4double dist_p, G4ThreeVector &B,
int p_fan
181 LWSDBG(6, std::cout <<
"iip from " << p <<
" to " << B
182 <<
" dir " << (B - p).
unit()
188 unsigned int niter = 0;
195 if(dist_c * dist_p < 0. || fabs(dist_c) <
m_FHTminusT){
206 LWSDBG(7, std::cout <<
"iip result in " << niter <<
" = " << B
207 <<
" " <<
diff.mag() << std::endl);
214 const G4ThreeVector &p_in,
const G4double dist_p_in,
215 const G4ThreeVector &p_out,
int p_fan
218 LWSDBG(6, std::cout <<
"sfnp " << MSG_VECTOR(p_in) <<
" "
219 << MSG_VECTOR(p_out) << std::endl);
221 G4ThreeVector
A, B,
C, l,
diff;
227 G4double
sign = dist_p_in < 0.? -1. : 1.;
230 unsigned long niter = 0;
235 if(dist_c *
sign <= 0.){
236 LWSDBG(7, std::cout <<
"sfnp0 " << dist_c << std::endl);
243 if(d_prime < 0.)
A =
C;
250 LWSDBG(7, std::cout <<
"sfnp1 " << dist_c << std::endl);
254 if(dist_p_in *
sign < dist_c *
sign){
259 if(dist_p_out *
sign < dist_c *
sign)
C = p_out;
261 LWSDBG(7, std::cout <<
"sfnp2 " << dist_p_out << std::endl);
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
double DistanceToTheNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
Calculates aproximate, probably underestimate, distance to the neutral fibre of the vertical fan.
double DistanceToTheNearestFan(CLHEP::Hep3Vector &p, int &out_fan_number) const
Determines the nearest to the input point fan.
static const G4double s_IterationPrecision
static const unsigned int s_IterationsLimit
const LArWheelCalculator * GetCalculator(void) const
virtual G4double distance_to_in(G4ThreeVector &, const G4ThreeVector &, int) const
G4double m_FanHalfThickness
G4double search_for_nearest_point(const G4ThreeVector &, const G4double, const G4ThreeVector &, int) const
G4double DistanceToIn(const G4ThreeVector &, const G4ThreeVector &) const
static const G4double s_IterationPrecision2
EInside Inside(const G4ThreeVector &) const
G4String TypeStr(void) const
G4double in_iteration_process(const G4ThreeVector &, G4double, G4ThreeVector &, int) const
G4VSolid * m_BoundingShape
hold the test vectors and ease the comparison