Belle II Software  release-05-02-19
FBXWriterModule.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Leo Piilonen *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef FBXWRITERMODULE_H
12 #define FBXWRITERMODULE_H
13 
14 #include <framework/core/Module.h>
15 
16 #include <string>
17 #include <fstream>
18 
19 class G4VPhysicalVolume;
20 class G4LogicalVolume;
21 class G4VSolid;
22 class G4Polyhedron;
23 class G4String;
24 class HepPolyhedron;
25 
26 namespace Belle2 {
43  class FBXWriterModule: public Module {
44 
45  public:
46 
49 
51  void initialize() override;
52 
54  void event() override;
55 
56  private:
57 
59  void assignName(std::vector<std::string>*, unsigned int, const G4String&, int);
60 
62  void writeGeometryNode(G4VSolid*, const std::string&, unsigned long long);
63 
65  void writeMaterialNode(int, const std::string&);
66 
68  void writeLVModelNode(G4LogicalVolume*, const std::string&, unsigned long long);
69 
71  void writePVModelNode(G4VPhysicalVolume*, const std::string&, unsigned long long);
72 
74  void countEntities(G4VPhysicalVolume*);
75 
77  void addModels(G4VPhysicalVolume*, int);
78 
80  void addConnections(G4VPhysicalVolume*, int);
81 
83  void writePreamble(int, int, int);
84 
86  void writePolyhedron(G4VSolid*, G4Polyhedron*, const std::string&, unsigned long long);
87 
89  void writeSolidToLV(const std::string&, const std::string&, bool, unsigned long long, unsigned long long, unsigned long long);
90 
92  void writeSolidToPV(const std::string&, const std::string&, bool, unsigned long long, unsigned long long, unsigned long long);
93 
95  void writeLVToPV(const std::string&, const std::string&, unsigned long long, unsigned long long);
96 
98  void writePVToParentLV(const std::string&, const std::string&, unsigned long long, unsigned long long);
99 
101  void writePVToParentPV(const std::string&, const std::string&, unsigned long long, unsigned long long);
102 
104  HepPolyhedron* getBooleanSolidPolyhedron(G4VSolid*);
105 
107  bool m_First{true};
108 
111  bool m_UsePrototypes{false};
112 
114  std::string m_Filename{"belle2.fbx"};
115 
117  std::ofstream m_File;
118 
120  std::vector<std::string>* m_PVName{nullptr};
121 
123  std::vector<std::string>* m_LVName{nullptr};
124 
126  std::vector<std::string>* m_SolidName{nullptr};
127 
129  std::vector<unsigned long long>* m_PVID{nullptr};
130 
132  std::vector<unsigned long long>* m_LVID{nullptr};
133 
135  std::vector<unsigned long long>* m_MatID{nullptr};
136 
138  std::vector<unsigned long long>* m_SolidID{nullptr};
139 
141  std::vector<bool>* m_Visible{nullptr};
142 
144  std::vector<unsigned int>* m_PVCount{nullptr};
145 
147  std::vector<unsigned int>* m_LVCount{nullptr};
148 
150  std::vector<unsigned int>* m_SolidCount{nullptr};
151 
153  std::vector<unsigned int>* m_PVReplicas{nullptr};
154 
156  std::vector<unsigned int>* m_LVReplicas{nullptr};
157 
159  std::vector<unsigned int>* m_SolidReplicas{nullptr};
160 
162  std::vector<bool>* m_LVUnique{nullptr};
163 
164  };
165 
167 } //Belle2 namespace
168 #endif
Belle2::FBXWriterModule::writeLVModelNode
void writeLVModelNode(G4LogicalVolume *, const std::string &, unsigned long long)
Write FBX definition for each logical volume.
Definition: FBXWriterModule.cc:285
Belle2::FBXWriterModule::m_PVReplicas
std::vector< unsigned int > * m_PVReplicas
Count of number of replicas of each replicated physical volume.
Definition: FBXWriterModule.h:153
Belle2::FBXWriterModule::m_MatID
std::vector< unsigned long long > * m_MatID
Unique identifiers for logical volumes' color information (Material nodes)
Definition: FBXWriterModule.h:135
Belle2::FBXWriterModule::addConnections
void addConnections(G4VPhysicalVolume *, int)
Write FBX connections among all of the nodes in the tree (recursive)
Definition: FBXWriterModule.cc:483
Belle2::FBXWriterModule::writePVToParentPV
void writePVToParentPV(const std::string &, const std::string &, unsigned long long, unsigned long long)
Write FBX connection for each physical-volume daughter of a parent physical volume (bypass singleton ...
Definition: FBXWriterModule.cc:999
Belle2::FBXWriterModule::m_PVID
std::vector< unsigned long long > * m_PVID
Unique identifiers for physical volumes (Model nodes with transformation information)
Definition: FBXWriterModule.h:129
Belle2::FBXWriterModule::countEntities
void countEntities(G4VPhysicalVolume *)
Count the physical volumes, logical volumes, materials and solids (recursive)
Definition: FBXWriterModule.cc:423
Belle2::FBXWriterModule::m_SolidName
std::vector< std::string > * m_SolidName
Modified (legal-character and unique) solid name.
Definition: FBXWriterModule.h:126
Belle2::FBXWriterModule
The FBX-writer module.
Definition: FBXWriterModule.h:43
Belle2::FBXWriterModule::event
void event() override
Called for each event: this runs the FBX writer only for the first event.
Definition: FBXWriterModule.cc:53
Belle2::FBXWriterModule::writeMaterialNode
void writeMaterialNode(int, const std::string &)
Write FBX definition for each logical volume's color information.
Definition: FBXWriterModule.cc:239
Belle2::FBXWriterModule::FBXWriterModule
FBXWriterModule()
Constructor of the module.
Definition: FBXWriterModule.cc:36
Belle2::FBXWriterModule::m_Visible
std::vector< bool > * m_Visible
Flag to indicate that the logical volume is visible.
Definition: FBXWriterModule.h:141
Belle2::FBXWriterModule::m_LVID
std::vector< unsigned long long > * m_LVID
Unique identifiers for logical volumes (Model nodes with links to Geometry and Material)
Definition: FBXWriterModule.h:132
Belle2::FBXWriterModule::m_SolidReplicas
std::vector< unsigned int > * m_SolidReplicas
Count of number of replicas of each solid (extras for replicas with modified solids)
Definition: FBXWriterModule.h:159
Belle2::FBXWriterModule::m_SolidID
std::vector< unsigned long long > * m_SolidID
Unique identifiers for solids (Geometry nodes)
Definition: FBXWriterModule.h:138
Belle2::FBXWriterModule::m_LVReplicas
std::vector< unsigned int > * m_LVReplicas
Count of number of replicas of each logical volume associated with a replicated physical volume.
Definition: FBXWriterModule.h:156
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::FBXWriterModule::assignName
void assignName(std::vector< std::string > *, unsigned int, const G4String &, int)
Create unique and legal name for each solid, logical volume, physical volume.
Definition: FBXWriterModule.cc:188
Belle2::FBXWriterModule::m_UsePrototypes
bool m_UsePrototypes
User-specified flag to select whether to write and re-use logical- and physical-volume prototypes onc...
Definition: FBXWriterModule.h:111
Belle2::FBXWriterModule::m_SolidCount
std::vector< unsigned int > * m_SolidCount
Count of number of instances of each solid (typically 1)
Definition: FBXWriterModule.h:150
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::FBXWriterModule::m_LVName
std::vector< std::string > * m_LVName
Modified (legal-character and unique) logical-volume name.
Definition: FBXWriterModule.h:123
Belle2::FBXWriterModule::m_LVUnique
std::vector< bool > * m_LVUnique
Flag to indicate that a logical volume is referenced at most once (eligible for bypass)
Definition: FBXWriterModule.h:162
Belle2::FBXWriterModule::writeLVToPV
void writeLVToPV(const std::string &, const std::string &, unsigned long long, unsigned long long)
Write FBX connection for the (unique) logical volume of a physical volume.
Definition: FBXWriterModule.cc:985
Belle2::FBXWriterModule::writePreamble
void writePreamble(int, int, int)
Write FBX at the start of the file.
Definition: FBXWriterModule.cc:618
Belle2::FBXWriterModule::writePolyhedron
void writePolyhedron(G4VSolid *, G4Polyhedron *, const std::string &, unsigned long long)
Write FBX definition for the solid's polyhedron.
Definition: FBXWriterModule.cc:847
Belle2::FBXWriterModule::getBooleanSolidPolyhedron
HepPolyhedron * getBooleanSolidPolyhedron(G4VSolid *)
Create polyhedron for a boolean solid (recursive)
Definition: FBXWriterModule.cc:1008
Belle2::FBXWriterModule::m_Filename
std::string m_Filename
User-specified output filename.
Definition: FBXWriterModule.h:114
Belle2::FBXWriterModule::writeSolidToLV
void writeSolidToLV(const std::string &, const std::string &, bool, unsigned long long, unsigned long long, unsigned long long)
Write FBX connection for each logical volume's solid and color info.
Definition: FBXWriterModule.cc:967
Belle2::FBXWriterModule::addModels
void addModels(G4VPhysicalVolume *, int)
Process one physical volume for FBX-node writing (recursive)
Definition: FBXWriterModule.cc:297
Belle2::FBXWriterModule::writeSolidToPV
void writeSolidToPV(const std::string &, const std::string &, bool, unsigned long long, unsigned long long, unsigned long long)
Write FBX connection for each physical volume's solid and color info (bypass singleton logical volume...
Definition: FBXWriterModule.cc:976
Belle2::FBXWriterModule::m_First
bool m_First
Once-only flag to write FBX only on the first event.
Definition: FBXWriterModule.h:107
Belle2::FBXWriterModule::m_PVName
std::vector< std::string > * m_PVName
Modified (legal-character and unique) physical-volume name.
Definition: FBXWriterModule.h:120
Belle2::FBXWriterModule::m_LVCount
std::vector< unsigned int > * m_LVCount
Count of number of instances of each logical volume.
Definition: FBXWriterModule.h:147
Belle2::FBXWriterModule::writePVToParentLV
void writePVToParentLV(const std::string &, const std::string &, unsigned long long, unsigned long long)
Write FBX connection for each physical-volume daughter of a parent logical volume.
Definition: FBXWriterModule.cc:992
Belle2::FBXWriterModule::m_File
std::ofstream m_File
Output file.
Definition: FBXWriterModule.h:117
Belle2::FBXWriterModule::m_PVCount
std::vector< unsigned int > * m_PVCount
Count of number of instances of each physical volume.
Definition: FBXWriterModule.h:144
Belle2::FBXWriterModule::writeGeometryNode
void writeGeometryNode(G4VSolid *, const std::string &, unsigned long long)
Write FBX definition for each solid's polyhedron.
Definition: FBXWriterModule.cc:223
Belle2::FBXWriterModule::writePVModelNode
void writePVModelNode(G4VPhysicalVolume *, const std::string &, unsigned long long)
Write FBX definition for each physical volume.
Definition: FBXWriterModule.cc:938
Belle2::FBXWriterModule::initialize
void initialize() override
Initialize at the start of a job.
Definition: FBXWriterModule.cc:48