7#ifndef PORTABLE_LAR_SHAPE
11#include "CLHEP/Units/PhysicalConstants.h"
19 LWSDBG(1, std::cout << TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP) << std::endl);
24 LWSDBG(2, std::cout <<
"Outside BS" << std::endl);
27 G4ThreeVector p(inputP);
36 const G4double d = fabs(
GetCalculator()->DistanceToTheNearestFan(p, p_fan));
39 LWSDBG(2, std::cout <<
"dti result = " <<
result << std::endl);
42 LWSDBG(2, std::cout <<
"already inside, return 0" << MSG_VECTOR(p) << std::endl);
47 const G4ThreeVector &inputV)
const
49 LWSDBG(1, std::cout << TypeStr() <<
" DisToIn" << MSG_VECTOR(inputP)
50 << MSG_VECTOR(inputV) << std::endl);
52 G4double distance = 0.;
54 G4ThreeVector p(inputP);
55 if(inside_BS == kOutside) {
57 if(distance == kInfinity) {
58 LWSDBG(2, std::cout <<
"Infinity distance to m_BoundingShape" << MSG_VECTOR(inputP) << MSG_VECTOR(inputV) << std::endl);
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_LARWHEELSOLID
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;
127 const G4ThreeVector &p, G4double dist_p, G4ThreeVector &B,
int p_fan
130 LWSDBG(6, std::cout <<
"iip from " << p <<
" to " << B
131 <<
" dir " << (B - p).
unit()
137 unsigned int niter = 0;
144 if(dist_c * dist_p < 0. || fabs(dist_c) <
m_FHTminusT){
155 LWSDBG(7, std::cout <<
"iip result in " << niter <<
" = " << B
156 <<
" " <<
diff.mag() << std::endl);
163 const G4ThreeVector &p_in,
const G4double dist_p_in,
164 const G4ThreeVector &p_out,
int p_fan
167 LWSDBG(6, std::cout <<
"sfnp " << MSG_VECTOR(p_in) <<
" "
168 << MSG_VECTOR(p_out) << std::endl);
170 G4ThreeVector
A, B,
C, l,
diff;
176 G4double
sign = dist_p_in < 0.? -1. : 1.;
179 unsigned long niter = 0;
184 if(dist_c *
sign <= 0.){
185 LWSDBG(7, std::cout <<
"sfnp0 " << dist_c << std::endl);
192 if(d_prime < 0.)
A =
C;
199 LWSDBG(7, std::cout <<
"sfnp1 " << dist_c << std::endl);
203 if(dist_p_in *
sign < dist_c *
sign){
208 if(dist_p_out *
sign < dist_c *
sign)
C = p_out;
210 LWSDBG(7, std::cout <<
"sfnp2 " << dist_p_out << std::endl);
218 LWSDBG(4, std::cout <<
"dti: " << MSG_VECTOR(p) <<
" "
219 << MSG_VECTOR(v) << std::endl);
221 G4double distance = 0.;
222#ifdef LARWHEELSOLID_USE_FANBOUND
223 if(FanBound->Inside(p) == kOutside) {
224 const G4double d = FanBound->DistanceToIn(p, v);
229 if(p.x() >
m_fs->xmax) {
230 if(v.x() >= 0.)
return kInfinity;
231 const G4double b = (
m_fs->xmax - p.x()) / v.x();
232 const G4double y2 = p.y() + v.y() * b;
233 const G4double z2 = p.z() + v.z() * b;
234 p.set(
m_fs->xmax, y2, z2);
236 }
else if(p.x() <
m_fs->xmin) {
237 if(v.x() <= 0.)
return kInfinity;
238 const G4double b = (
m_fs->xmin - p.x()) / v.x();
239 const G4double y2 = p.y() + v.y() * b;
240 const G4double z2 = p.z() + v.z() * b;
241 p.set(
m_fs->xmin, y2, z2);
248 LWSDBG(5, std::cout <<
"dti corrected: " << MSG_VECTOR(p) << std::endl);
252 LWSDBG(5, std::cout <<
"hit fan dist_p=" << dist_p <<
", m_FHTminusT=" <<
m_FHTminusT << std::endl);
256#ifdef CHECK_DIRTONORM_ANGLE_ON_SURFACE
258 LWSDBG(5, std::cout <<
"outside fan dist_p=" << dist_p <<
", m_FHTplusT=" <<
m_FHTplusT << std::endl);
260 LWSDBG(5, std::cout <<
"on fan surface dist_p=" << dist_p <<
", m_FHTplusT=" <<
m_FHTplusT <<
", m_FHTminusT=" <<
m_FHTminusT << std::endl);
264 if ( (p-d).cosTheta(v) < -AngularTolerance ) {
273#ifdef LARWHEELSOLID_USE_FANBOUND
274 q = p + v * FanBound->DistanceToOut(p, v);
282 if(stop > start) { step = 1; start ++; stop ++; }
283 LWSDBG(5, std::cout <<
"dti sections " << start <<
" " << stop
284 <<
" " << step << std::endl);
286 for(G4int i = start; i != stop; i += step){
289 const G4double d1 = (
m_Zsect[i] - p.z()) / v.z();
290 const G4double x1 = p.x() + v.x() * d1, y1 = p.y() + v.y() * d1;
293 LWSDBG(5, std::cout << i <<
">" << p <<
" " << dist_p <<
" "
294 << p1 <<
" " << dist_p1 << std::endl);
295 G4double dd = kInfinity;
296 if(dist_p * dist_p1 < 0.){
300 LWSDBG(6, std::cout << i <<
"> dd=" << dd <<
", d2=" << d2 <<
", distance=" << distance << std::endl);
302 return distance + d2;
303 }
else if(dd < kInfinity){
304 return distance + dd;
312 LWSDBG(5, std::cout <<
"dti exit point: " << MSG_VECTOR(q) <<
" "
313 << dist_q << std::endl);
314 G4double dd = kInfinity;
315 if(dist_p * dist_q < 0.){
320 return distance + d2;
321 }
else if(dd < kInfinity){
322 return distance + dd;
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.
CLHEP::Hep3Vector NearestPointOnNeutralFibre(const CLHEP::Hep3Vector &p, int fan_number) const
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_IterationPrecision2
static const G4double s_IterationPrecision
G4int select_section(const G4double &Z) const
G4double in_iteration_process(const G4ThreeVector &, G4double, G4ThreeVector &, int) const
std::vector< G4double > m_Zsect
G4double DistanceToIn(const G4ThreeVector &, const G4ThreeVector &) const
FanBoundExit_t find_exit_point(const G4ThreeVector &p, const G4ThreeVector &v, G4ThreeVector &q) const
G4VSolid * m_BoundingShape
static const unsigned int s_IterationsLimit
virtual G4double distance_to_in(G4ThreeVector &, const G4ThreeVector &, int) const
EInside Inside(const G4ThreeVector &) const
G4double search_for_nearest_point(const G4ThreeVector &, const G4double, const G4ThreeVector &, int) const
G4double m_FanHalfThickness
const LArWheelCalculator * GetCalculator(void) const
hold the test vectors and ease the comparison