Belle II Software  release-08-01-10
OverlapCheckerModule.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <framework/core/Module.h>
12 #include <framework/datastore/StoreObjPtr.h>
13 #include <framework/dataobjects/DisplayData.h>
14 #include <G4NavigationHistory.hh>
15 
16 #include <string>
17 #include <vector>
18 #include <set>
19 
20 class G4VPhysicalVolume;
21 
22 namespace Belle2 {
39  class OverlapCheckerModule: public Module {
40 
41  public:
42 
45 
47  void initialize() override;
48 
50  void event() override;
51 
52  private:
53 
65  bool checkVolume(G4VPhysicalVolume* volume, const std::string& path, int depth = 0);
66 
68  void handleOverlap(const std::string& geant4Message);
69 
70  int m_points{10000};
71  int m_maxErrors{0};
72  int m_maxDepth{0};
73  double m_tolerance{0.};
74  std::string m_prefix{""};
75  std::vector<std::string> m_overlaps;
76  std::set<G4VPhysicalVolume*> m_seen;
77  G4NavigationHistory m_nav;
79  };
81 } //Belle2 namespace
Base class for Modules.
Definition: Module.h:72
The geometry overlap check module.
OverlapCheckerModule()
Constructor of the module.
double m_tolerance
tolerance of overlap check
void initialize() override
Initialize the module.
std::string m_prefix
check only volumes beginning with prefix
void event() override
event function: this runs the overlap checker for each event
bool checkVolume(G4VPhysicalVolume *volume, const std::string &path, int depth=0)
Check a volume for overlaps.
int m_points
number of test points
int m_maxErrors
maximum number of errors before skipping current volume
void handleOverlap(const std::string &geant4Message)
Handle a G4Exception with the overlap message issued by Geant4.
std::vector< std::string > m_overlaps
list of overlapping volumes
int m_maxDepth
maximum depth to check
std::set< G4VPhysicalVolume * > m_seen
set of logical volumes we already checked
G4NavigationHistory m_nav
navigation history to remember coordinate transformations
StoreObjPtr< DisplayData > m_displayData
Pointer to the DisplayData where we add the overlap points for rendering.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
Abstract base class for different kinds of events.