ATLAS Offline Software
LArWheelSolid.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GEO2G4_LARWHEELSOLID_H
6 #define GEO2G4_LARWHEELSOLID_H
7 #ifndef PORTABLE_LAR_SHAPE
10 #endif
11 #include "G4VSolid.hh"
12 
13 // set this to allow debug output in LArWheelSolid methods
14 // disabled by default to avoid any performance degradation
15 //#define DEBUG_LARWHEELSOLID
16 
17 // set this to use native G4 FanBound's methods for DisToIn
18 // instead of local calculations
19 //#define LARWHEELSOLID_USE_FANBOUND
20 
21 // set this to use BoundingShape's methods for DisToOut
22 // instead of local calculations
23 #define LARWHEELSOLID_USE_BS_DTO
24 
25 // change this to have more z sections
26 #define LARWHEELSOLID_ZSECT_MULT 1
27 
28 
29 // set this to check in dti and dto functions if particle direction
30 // pointing inside or outside of volume to return zero fast when it is required by spec.
31 // currently at development stage, requires accurate surface normal calculations
32 //#define CHECK_DIRTONORM_ANGLE_ON_SURFACE
33 
34 #ifdef DEBUG_LARWHEELSOLID
35 #define LWSDBG(a, b) if(Verbose >= a) b
36 #define MSG_VECTOR(v) "(" << v.x() << ", " << v.y() << ", " << v.z() << ")"
37 //#define LWS_HARD_TEST_DTI
38 //#define LWS_HARD_TEST_DTO
39 #else
40 #define LWSDBG(a, b)
41 #endif
42 
43 // Forward declarations.
44 class G4VGraphicsScene;
45 class G4VisExtent;
46 class G4Polyhedron;
47 class G4NURBS;
48 class G4VoxelLimits;
49 class G4AffineTransform;
50 class G4Polycone;
51 class LArWheelCalculator;
52 class TF1;
53 class LArFanSections;
54 class G4Polyhedra;
55 struct EMECData;
56 
57 #include "LArWheelSolid_type.h"
58 
60 {
61  switch(type){
62  case InnerAbsorberWheel: return("InnerAbsorberWheel");
63  case OuterAbsorberWheel: return("OuterAbsorberWheel");
64  case InnerElectrodWheel: return("InnerElectrodWheel");
65  case OuterElectrodWheel: return("OuterElectrodWheel");
66  case InnerAbsorberModule: return("InnerAbsorberModule");
67  case OuterAbsorberModule: return("OuterAbsorberModule");
68  case InnerElectrodModule: return("InnerElectrodModule");
69  case OuterElectrodModule: return("OuterElectrodModule");
70  case InnerLeadWheel: return("InnerLeadWheel");
71  case OuterLeadWheel: return("OuterLeadWheel");
72  case InnerGlueWheel: return("InnerGlueWheel");
73  case OuterGlueWheel: return("OuterGlueWheel");
74  case InnerAbsorberCone: return("InnerAbsorberCone");
75  case InnerElectrodCone: return("InnerElectrodCone");
76  case InnerGlueCone: return("InnerGlueCone");
77  case InnerLeadCone: return("InnerLeadCone");
78  case OuterAbsorberFrontCone: return("OuterAbsorberFrontCone");
79  case OuterElectrodFrontCone: return("OuterElectrodFrontCone");
80  case OuterGlueFrontCone: return("OuterGlueFrontCone");
81  case OuterLeadFrontCone: return("OuterLeadFrontCone");
82  case OuterAbsorberBackCone: return("OuterAbsorberBackCone");
83  case OuterElectrodBackCone: return("OuterElectrodBackCone");
84  case OuterGlueBackCone: return("OuterGlueBackCone");
85  case OuterLeadBackCone: return("OuterLeadBackCone");
86  }
87  return("unknown");
88 }
89 
90 class ATLAS_NOT_THREAD_SAFE LArWheelSolid : public G4VSolid
91 #ifndef PORTABLE_LAR_SHAPE
92 , public AthMessaging
93 #endif
94 {
95 public:
96 
97  LArWheelSolid(const G4String& name, LArWheelSolid_t type,
98  G4int zside = 1,
100  const EMECData *emecData=0
101  );
102  virtual ~LArWheelSolid();
103 
104  // Mandatory for custom solid Geant4 functions
105  EInside Inside(const G4ThreeVector&) const;
106  G4double DistanceToIn(const G4ThreeVector&,
107  const G4ThreeVector&) const;
108  G4double DistanceToIn(const G4ThreeVector&) const;
109  G4double DistanceToOut(const G4ThreeVector&,
110  const G4ThreeVector&,
111  const G4bool calcNorm = false,
112  G4bool* validNorm = 0,
113  G4ThreeVector* n = 0) const;
114  G4double DistanceToOut(const G4ThreeVector&) const;
115  G4ThreeVector SurfaceNormal (const G4ThreeVector&) const;
116  G4bool CalculateExtent(const EAxis,
117  const G4VoxelLimits&,
118  const G4AffineTransform&,
119  G4double&,
120  G4double&) const;
121  G4GeometryType GetEntityType() const;
122  void DescribeYourselfTo(G4VGraphicsScene&) const;
123  G4VisExtent GetExtent() const;
124  G4Polyhedron* CreatePolyhedron() const;
125 
126  // 07-Feb-2003 WGS: For compatibility with Geant 4.5.0
127  virtual std::ostream& StreamInfo(std::ostream& os) const { return os; }
128 
129  const G4VSolid *GetBoundingShape(void) const { return m_BoundingShape; }
130  const LArWheelCalculator *GetCalculator(void) const { return m_Calculator; }
131  LArWheelSolid_t GetType(void) const { return m_Type; }
132 
133 #ifndef PORTABLE_LAR_SHAPE
134  G4ThreeVector GetPointOnSurface(void) const;
135  G4double GetCubicVolume(void);
136  G4double GetSurfaceArea(void);
137 #endif
138 
139 private:
140  static const G4double s_Tolerance;
141  static const G4double s_AngularTolerance;
142  static const G4double s_IterationPrecision;
143  static const G4double s_IterationPrecision2;
144  static const unsigned int s_IterationsLimit;
145 
146  G4bool m_IsOuter;
149  G4double m_FanHalfThickness, m_FHTplusT, m_FHTminusT;
151  G4double m_MinPhi;
152  G4double m_MaxPhi;
153  const G4double m_PhiPosition;
154  G4VSolid* m_BoundingShape;
155 #ifdef LARWHEELSOLID_USE_FANBOUND
156  G4VSolid* m_FanBound;
157 #endif
158 
159  std::vector<G4double> m_Zsect;
161 
163 
164  // z at outer wheel "bend"
165  G4double m_Zmid;
166  // Special limit, used in dto
167  G4double m_Ymin;
168  // limits for use in service functions
169  G4double m_Zmin, m_Zmax, m_Rmin, m_Rmax;
170  //artificial level to distinguish between inner and outer cones
171  G4double m_Ymid;
172 
173  void inner_solid_init(const G4String &);
174  void outer_solid_init(const G4String &);
175  void set_phi_size(void);
176 
177  virtual G4double distance_to_in(G4ThreeVector &,
178  const G4ThreeVector &, int) const;
179  G4double in_iteration_process(const G4ThreeVector &,
180  G4double, G4ThreeVector &, int) const;
181  G4double search_for_nearest_point(const G4ThreeVector &, const G4double,
182  const G4ThreeVector &, int) const;
183  G4bool search_for_most_remoted_point(const G4ThreeVector &,
184  const G4ThreeVector &,
185  G4ThreeVector &, const int) const;
186  G4double out_iteration_process(const G4ThreeVector &,
187  G4ThreeVector &, const int) const;
188 
189  typedef enum {
190  NoCross, ExitAtInner, ExitAtOuter,
191  ExitAtFront, ExitAtBack, ExitAtSide
192  } FanBoundExit_t;
193 
194  FanBoundExit_t find_exit_point(const G4ThreeVector &p,
195  const G4ThreeVector &v,
196  G4ThreeVector &q) const;
197  G4bool fs_cross_lower(const G4ThreeVector &p, const G4ThreeVector &v,
198  G4ThreeVector &q) const;
199  G4bool fs_cross_upper(const G4ThreeVector &p, const G4ThreeVector &v,
200  G4ThreeVector &q) const;
201  G4bool check_D(G4double &b,
202  G4double A, G4double B, G4double C, G4bool) const;
203 
204  G4int select_section(const G4double &Z) const;
205 
206 #ifndef PORTABLE_LAR_SHAPE
207  EInside Inside_accordion(const G4ThreeVector&) const;
208  void get_point_on_accordion_surface(G4ThreeVector &) const;
209  void get_point_on_polycone_surface(G4ThreeVector &) const;
210  void get_point_on_flat_surface(G4ThreeVector &) const;
211  void set_failover_point(G4ThreeVector &p, const char *m = 0) const;
212 
213  G4double get_area_on_polycone(void) const;
214  G4double get_area_on_face(void) const;
215  G4double get_area_on_side(void) const;
216 
217  G4double get_area_at_r(G4double r) const;
218  G4double get_length_at_r(G4double r) const;
219 
220  void test(void);
221  void clean_tests(void);
222  void init_tests(void);
223 #endif
224 
225 protected:
226 
227  TF1 *m_f_area, *m_f_vol, *m_f_area_on_pc, *m_f_length, *m_f_side_area;
228 
229  double m_test_index;
230  friend double LArWheelSolid_fcn_area(double *, double *);
231  friend double LArWheelSolid_fcn_vol(double *, double *);
232  friend double LArWheelSolid_fcn_area_on_pc(double *, double *);
233  friend double LArWheelSolid_get_dl(double *, double *, G4int);
234  friend double LArWheelSolid_fcn_side_area(double *, double *);
235 
236 #ifdef DEBUG_LARWHEELSOLID
237  static const char* inside(EInside i)
238  {
239  switch(i){
240  case kInside: return "inside"; break;
241  case kSurface: return "surface"; break;
242  case kOutside: return "outside"; break;
243  }
244  return "unknown";
245  }
246 
247 public:
248  static G4int Verbose;
249  void SetVerbose(G4int v){ Verbose = v; }
250 #ifndef PORTABLE_LAR_SHAPE
251  G4bool test_dti(const G4ThreeVector &p,
252  const G4ThreeVector &v, const G4double distance) const;
253  G4bool test_dto(const G4ThreeVector &p,
254  const G4ThreeVector &v, const G4double distance) const;
255 #endif
256 private:
257  const char *TypeStr(void) const { return LArWheelSolidTypeString(m_Type); }
258 #endif
259 };
260 
261 #endif // GEO2G4_LARWHEELSOLID_H
262 
InnerElectrodCone
@ InnerElectrodCone
Definition: LArWheelSolid_type.h:26
LArWheelSolid::GetType
LArWheelSolid_t GetType(void) const
Definition: LArWheelSolid.h:131
LArWheelSolid::ExitAtFront
@ ExitAtFront
Definition: LArWheelSolid.h:191
InnerGlueWheel
@ InnerGlueWheel
Definition: LArWheelSolid_type.h:21
beamspotman.r
def r
Definition: beamspotman.py:676
LArWheelSolid::GetBoundingShape
const G4VSolid * GetBoundingShape(void) const
Definition: LArWheelSolid.h:129
OuterLeadFrontCone
@ OuterLeadFrontCone
Definition: LArWheelSolid_type.h:32
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
OuterAbsorberBackCone
@ OuterAbsorberBackCone
Definition: LArWheelSolid_type.h:33
LArWheelSolid::s_Tolerance
static const G4double s_Tolerance
Definition: LArWheelSolid.h:140
ATLAS_NOT_THREAD_SAFE
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Definition: checker_macros.h:212
OuterLeadBackCone
@ OuterLeadBackCone
Definition: LArWheelSolid_type.h:36
OuterGlueWheel
@ OuterGlueWheel
Definition: LArWheelSolid_type.h:22
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
DMTest::C
C_v1 C
Definition: C.h:26
EMECData
Definition: EMECData.h:131
LArWheelSolid_t
LArWheelSolid_t
Definition: LArWheelSolid_type.h:12
LArWheelSolid::m_PhiPosition
const G4double m_PhiPosition
Definition: LArWheelSolid.h:153
LArWheelSolid::StreamInfo
virtual std::ostream & StreamInfo(std::ostream &os) const
Definition: LArWheelSolid.h:127
LArWheelSolid::m_Ymin
G4double m_Ymin
Definition: LArWheelSolid.h:167
TrigInDetValidation_Base.test
test
Definition: TrigInDetValidation_Base.py:147
LArWheelSolid_fcn_side_area
double LArWheelSolid_fcn_side_area(double *x, double *p)
Definition: LArWheelSolidTests.cxx:602
LArWheelSolid::m_FHTplusT
G4double m_FHTplusT
Definition: LArWheelSolid.h:149
LArFanSections
Definition: LArFanSection.h:12
InnerElectrodModule
@ InnerElectrodModule
Definition: LArWheelSolid_type.h:19
InnerElectrodWheel
@ InnerElectrodWheel
Definition: LArWheelSolid_type.h:15
InnerGlueCone
@ InnerGlueCone
Definition: LArWheelSolid_type.h:27
OuterElectrodModule
@ OuterElectrodModule
Definition: LArWheelSolid_type.h:20
LArWheelSolid::m_Ymid
G4double m_Ymid
Definition: LArWheelSolid.h:171
OuterGlueFrontCone
@ OuterGlueFrontCone
Definition: LArWheelSolid_type.h:31
OuterAbsorberModule
@ OuterAbsorberModule
Definition: LArWheelSolid_type.h:18
LArWheelSolid_fcn_vol
double LArWheelSolid_fcn_vol(double *x, double *p)
Definition: LArWheelSolidTests.cxx:542
LArWheelSolid::GetCalculator
const LArWheelCalculator * GetCalculator(void) const
Definition: LArWheelSolid.h:130
InnerLeadWheel
@ InnerLeadWheel
Definition: LArWheelSolid_type.h:23
LArWheelSolid::m_test_index
double m_test_index
Definition: LArWheelSolid.h:229
LArWheelSolid_get_dl
double LArWheelSolid_get_dl(double *x, double *par, G4int side)
Definition: LArWheelSolidTests.cxx:570
LArWheelSolid::m_Calculator
LArWheelCalculator * m_Calculator
Definition: LArWheelSolid.h:148
ZDCMsg::Verbose
@ Verbose
Definition: ZDCMsg.h:18
OuterElectrodFrontCone
@ OuterElectrodFrontCone
Definition: LArWheelSolid_type.h:30
A
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
LArWheelSolid::s_AngularTolerance
static const G4double s_AngularTolerance
Definition: LArWheelSolid.h:141
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
InnerAbsorberWheel
@ InnerAbsorberWheel
Definition: LArWheelSolid_type.h:13
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
OuterLeadWheel
@ OuterLeadWheel
Definition: LArWheelSolid_type.h:24
OuterElectrodBackCone
@ OuterElectrodBackCone
Definition: LArWheelSolid_type.h:34
OuterGlueBackCone
@ OuterGlueBackCone
Definition: LArWheelSolid_type.h:35
LArWheelCalculator
Definition: LArWheelCalculator.h:60
LArWheelSolid_type.h
LArWheelSolid_fcn_area_on_pc
double LArWheelSolid_fcn_area_on_pc(double *x, double *p)
Definition: LArWheelSolidTests.cxx:550
InnerLeadCone
@ InnerLeadCone
Definition: LArWheelSolid_type.h:28
LArWheelSolid::m_Zsect
std::vector< G4double > m_Zsect
Definition: LArWheelSolid.h:159
InnerAbsorberModule
@ InnerAbsorberModule
Definition: LArWheelSolid_type.h:17
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
LArWheelSolid::m_fs
LArFanSections * m_fs
Definition: LArWheelSolid.h:162
LArWheelSolid::m_f_vol
TF1 * m_f_vol
Definition: LArWheelSolid.h:227
LArWheelSolid::m_Zsect_start_search
G4int m_Zsect_start_search
Definition: LArWheelSolid.h:160
OuterElectrodWheel
@ OuterElectrodWheel
Definition: LArWheelSolid_type.h:16
LArWheelSolid
Definition: LArWheelSolid.h:94
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
LArWheelSolid::s_IterationPrecision2
static const G4double s_IterationPrecision2
Definition: LArWheelSolid.h:143
LArWheelSolid::NoCross
@ NoCross
Definition: LArWheelSolid.h:190
OuterAbsorberFrontCone
@ OuterAbsorberFrontCone
Definition: LArWheelSolid_type.h:29
python.PyAthena.v
v
Definition: PyAthena.py:154
Trk::inside
@ inside
Definition: PropDirection.h:29
LArWheelSolid::m_MinPhi
G4double m_MinPhi
Definition: LArWheelSolid.h:151
LArWheelSolid::m_IsOuter
G4bool m_IsOuter
Definition: LArWheelSolid.h:146
LArWheelSolid::m_FanPhiAmplitude
G4double m_FanPhiAmplitude
Definition: LArWheelSolid.h:150
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArWheelSolid::m_Zmin
G4double m_Zmin
Definition: LArWheelSolid.h:169
AthMessaging.h
LArWheelSolid::m_Type
const LArWheelSolid_t m_Type
Definition: LArWheelSolid.h:147
LArWheelSolid_fcn_area
double LArWheelSolid_fcn_area(double *x, double *p)
Definition: LArWheelSolidTests.cxx:530
extractSporadic.q
list q
Definition: extractSporadic.py:98
InnerAbsorberCone
@ InnerAbsorberCone
Definition: LArWheelSolid_type.h:25
LArWheelSolid::s_IterationPrecision
static const G4double s_IterationPrecision
Definition: LArWheelSolid.h:142
checker_macros.h
Define macros for attributes used to control the static checker.
LArWheelSolid::m_BoundingShape
G4VSolid * m_BoundingShape
Definition: LArWheelSolid.h:154
LArWheelSolid::s_IterationsLimit
static const unsigned int s_IterationsLimit
Definition: LArWheelSolid.h:144
beamspotnt.calc
calc
Definition: bin/beamspotnt.py:1252
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
LArWheelSolid::m_Zmid
G4double m_Zmid
Definition: LArWheelSolid.h:165
OuterAbsorberWheel
@ OuterAbsorberWheel
Definition: LArWheelSolid_type.h:14
LArWheelSolid::m_MaxPhi
G4double m_MaxPhi
Definition: LArWheelSolid.h:152
LArWheelSolidTypeString
const char * LArWheelSolidTypeString(LArWheelSolid_t type)
Definition: LArWheelSolid.h:59